本文整理汇总了C#中Course.getCourseInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Course.getCourseInfo方法的具体用法?C# Course.getCourseInfo怎么用?C# Course.getCourseInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course.getCourseInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
int c; //Total # of Students returned to the main program
bool q = true; //while loop condition
//Create a new Course
Course c1 = new Course();
c = c1.getCourseInfo(); //Total Students return value
System.Console.WriteLine();
Student[] arrayofStudents;
arrayofStudents = new Student[c];
//Enter Student Information. Check to reenter
while (q == true)
{
for (int i = 0; i < c; i++)
{
arrayofStudents[i] = new Student();
System.Console.Write("Student Name: ");
arrayofStudents[i].sName = System.Console.ReadLine();
System.Console.Write("Student Number: ");
arrayofStudents[i].sNumber = int.Parse(System.Console.ReadLine());
System.Console.WriteLine();
}
System.Console.Write("True or False: Would you like to reenter the student information? ");
q = bool.Parse(System.Console.ReadLine());
System.Console.WriteLine();
}
//Print Course Information
c1.printCourseInfo();
System.Console.WriteLine();
//Print Student Information
for (int i = 0; i < c; i++)
{
System.Console.Write("Student Name: " + arrayofStudents[i].sName + ", ");
System.Console.WriteLine("Student Number: " + arrayofStudents[i].sNumber);
}
System.Console.Write("Press any key to complete...");
System.Console.ReadKey();
}
示例2: CreateRegistration
public Registration CreateRegistration(User curRegisteringUser)
{
string connection = ConfigurationManager.ConnectionStrings["EVENTSConnectionString"].ToString();
SqlConnection dbConnection = new SqlConnection(connection);
try
{
dbConnection.Open();
List<Conference> registeringConferences = new List<Conference>();
List<RegistrationLine> lineItemCourses = new List<RegistrationLine>();
HttpCookie testc = Request.Cookies["CoursesToRegisterFor"];
foreach (string course in Request.Cookies["CoursesToRegisterFor"].Values)
{
Course newCourse = new Course(course);
if (registeringConferences.ToString().Contains(((Request.Cookies["CoursesToRegisterFor"][course]))))
{
lineItemCourses.Add(new RegistrationLine(newCourse));
}
else
{
lineItemCourses.Add(new RegistrationLine(newCourse));
registeringConferences.Add(new Conference(Request.Cookies["CoursesToRegisterFor"][course]));
newCourse.getCourseInfo();
}
}
if (lineItemCourses.Count > 0)
{
Registration thisRegistration = new Registration(curRegisteringUser, lineItemCourses);
thisRegistration.CalculateCost();
SqlParameter RegisteringUserParam = new SqlParameter("@REGISTERING_USER", System.Data.SqlDbType.NVarChar, 50);
RegisteringUserParam.Value = thisRegistration.RegisteringUser.Email;
SqlParameter CostParam = new SqlParameter("@REGISTRATION_COST", System.Data.SqlDbType.Int);
CostParam.Value = thisRegistration.Cost;
SqlParameter registrationID = new SqlParameter("REGISTRATION_ID", System.Data.SqlDbType.Int);
//parameter value can be set server side and will be returned to client
registrationID.Direction = System.Data.ParameterDirection.Output;
SqlCommand createRegistration = new SqlCommand("CREATE_REGISTRATION", dbConnection);
List<SqlParameter> CreateRegistrationParameters =
new List<SqlParameter> { RegisteringUserParam, CostParam, registrationID };
createRegistration.CommandType = System.Data.CommandType.StoredProcedure;
createRegistration.Parameters.AddRange(CreateRegistrationParameters.ToArray());
createRegistration.ExecuteNonQuery();
thisRegistration.RegistrationID = createRegistration.Parameters["REGISTRATION_ID"].Value.ToString();
thisRegistration.AddRegistrationLine();
dbConnection.Close();
return thisRegistration;
}
else
return new Registration("");
}
catch (SqlException exception)
{
Response.Write("<p> Error Code " + exception.Number + ": " + exception.Message + "</p>");
return new Registration("");
}
}