本文整理汇总了C#中Course类的典型用法代码示例。如果您正苦于以下问题:C# Course类的具体用法?C# Course怎么用?C# Course使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Course类属于命名空间,在下文中一共展示了Course类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: imgBtnSave_Click
//添加考试科目事件
protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
{
if (Page.IsValid)
{
Course course = new Course(); //创建考试科目对象
//start:胡媛媛修改,去掉考试科目输入框两边的空格,加trim(),2010-4-29
course.Name = txtName.Text.Trim(); //设置考试科目对象属性
//程军添加,添加考试科目,名称不能相同。2010-4-25
DataBase db = new DataBase();
string mySql = "select * from Course where Name ='" + txtName.Text.Trim() + "'";
//end:胡媛媛修改,去掉考试科目输入框两边的空格,加trim(),2010-4-29
if (db.GetRecord(mySql))
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('课程章节重复!')</script>");
this.txtName.Focus();
}
else
{
if (course.InsertByProc()) //调用添加考试科目方法添加考试科目
{
lblMessage.Text = "成功添加该章节科目!";
}
else
{
lblMessage.Text = "添加该章节失败!";
}
}
//程军添加,添加考试科目,名称不能相同。2010-4-25
}
}
示例2: Main
/* 02. Write a console application that uses the data.*/
/// <summary>
/// Mains this instanse.
/// </summary>
public static void Main()
{
Database.SetInitializer(new MigrateDatabaseToLatestVersion<StudentSystemContext, Configuration>());
using (var db = new StudentSystemContext())
{
var pesho = new Student { Name = "Pesho", Number = 666 };
db.Students.Add(pesho);
db.SaveChanges();
var dbCourse = new Course
{
Name = "Database Course",
Description = "Basic Database operations",
Materials = "http://telerikacademy.com/Courses/Courses/Details/98"
};
db.Courses.Add(dbCourse);
db.SaveChanges();
var course = db.Courses.First(c => c.Name == dbCourse.Name);
var student = db.Students.First(s => s.Number == pesho.Number);
var hw = new Homework
{
Content = "Empty Homework",
TimeSent = DateTime.Now,
CourseId = course.CourseId,
StudentId = student.StudentID
};
db.Homeworks.Add(hw);
db.SaveChanges();
}
ListStudents();
}
示例3: EnsureCourseNumberCanNotAcceptValuesLessNonPositiveValues
public void EnsureCourseNumberCanNotAcceptValuesLessNonPositiveValues()
{
int number = -1;
string name = "C#";
Course course = new Course(name, number);
}
示例4: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
//do insert or update
using (DefaultConnectionEF db = new DefaultConnectionEF())
{
Course objC = new Course();
if (!String.IsNullOrEmpty(Request.QueryString["CourseID"]))
{
Int32 CourseID = Convert.ToInt32(Request.QueryString["CourseID"]);
objC = (from c in db.Courses
where c.CourseID == CourseID
select c).FirstOrDefault();
}
//populate the course from the input form
objC.Title = txtTitle.Text;
objC.Credits = Convert.ToInt32(txtCredits.Text);
objC.DepartmentID = Convert.ToInt32(ddlDepartment.SelectedValue);
if (String.IsNullOrEmpty(Request.QueryString["CourseID"]))
{
//add
db.Courses.Add(objC);
}
//save and redirect
db.SaveChanges();
Response.Redirect("courses.aspx");
}
}
示例5: StudentLeavingCourseShouldNotThrowException
public void StudentLeavingCourseShouldNotThrowException()
{
Student student = new Student("Humpty Dumpty", 10000);
Course course = new Course("Unit Testing");
student.AttendCourse(course);
student.LeaveCourse(course);
}
示例6: btnAdd_Click
protected void btnAdd_Click(object sender, EventArgs e)
{
//Student s = new Student();
//s.EnrolStudent((int)(gvCourse.SelectedValue), int.Parse(ddlNewStudents.SelectedValue), DateTime.Today.Year.ToString());
//lblMessage.Text = "Student added";
//gvClass.DataBind();
//displayStudent();
Course objCourse = new Course();
//get information for enrolling student
int studentID = int.Parse(ddlNewStudents.SelectedValue);
int courseID = (int)gvCourse.SelectedValue;
string year = DateTime.Now.Year.ToString();
int numRowsAffected = objCourse.EnrolStudent(studentID, courseID, year);
//display confirmation message
if (numRowsAffected > 0)
{
lblMessage.Text = "New student added";
lblMessage.CssClass = "confirmation";
}
else
{
lblMessage.Text = "Faild to add new student";
lblMessage.CssClass = "error";
}
}
示例7: School_AddCourseTest
public void School_AddCourseTest()
{
Course java = new Course("Java");
School myTestSchool = new School();
myTestSchool.AddCourse(java);
Assert.AreEqual(java.CourseName, myTestSchool.Courses[0].CourseName);
}
示例8: CheckIfCourseNameIsChangedAfterCourseCreation
public void CheckIfCourseNameIsChangedAfterCourseCreation()
{
Course course = new Course("math");
course.Name = "financial math";
Assert.AreEqual("financial math", course.Name, string.Format("Expected output after course name change financial math. Received {0}", course.Name));
}
示例9: CourseShouldThrowAnApplicationExceptionWhenTheSameStudentIsAddedMoreThanOnce
public void CourseShouldThrowAnApplicationExceptionWhenTheSameStudentIsAddedMoreThanOnce()
{
Course testCourse = new Course("Test");
Student testStudent = new Student("a");
testCourse.AddStudent(testStudent);
testCourse.AddStudent(testStudent);
}
示例10: AddLOsToCourse
public ActionResult AddLOsToCourse(Course course)
{
string stringOfLoIds = Request["selectedIds"];
if (!stringOfLoIds.IsEmpty())
{
List<string> listOfLoIds = stringOfLoIds.Split(',').ToList();
foreach (var id in listOfLoIds)
{
var id1 = id;
var lo = _dbContext.LOs.Find(x => x.Id == ObjectId.Parse(id1)).SingleAsync().Result;
if (lo != null)
{
course.Duration += lo.Duration;
course.AddLo(lo.Id);
}
}
}
ModelState.Clear();
if (course.Id != ObjectId.Empty)
{
_logger.Trace("LO or LOs added to course during course editing");
return View("EditCourse", course);
}
else
{
_logger.Trace("LO or LOs added to course during manual course creating");
return View("ManualCourseCreating", course);
}
}
示例11: Main
private static void Main()
{
try
{
Student pesho = new Student("Pesho Georgiev");
Student gosho = new Student("Gosho Ivanov");
Student misho = new Student("Misho Cekov");
Student sasho = new Student("Sasho Kostov");
Course telerikAcademy = new Course("Telerik Academy");
Course webProgramming = new Course("Web Programming");
webProgramming.AddStudent(sasho);
telerikAcademy.AddStudent(pesho);
telerikAcademy.AddStudent(gosho);
telerikAcademy.AddStudent(misho);
telerikAcademy.RemoveStudent(gosho);
Console.WriteLine(gosho.ToString() + " was removed from course.");
Console.WriteLine("Courses:");
Console.WriteLine(telerikAcademy);
School freeSchool = new School("School of Computer Sciences");
freeSchool.AddCourse(webProgramming);
freeSchool.AddCourse(telerikAcademy);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
示例12: Main
public static void Main()
{
var streamReader = new StreamReader("../../students.txt");
var multiDiuctionary = new OrderedMultiDictionary<Course, Student>(true);
using (streamReader)
{
string line = streamReader.ReadLine();
while (line != null)
{
string[] parameters = line.Split(new char[] { ' ', '|' }, StringSplitOptions.RemoveEmptyEntries);
string courseName = parameters[2];
var course = new Course(courseName);
string firstName = parameters[0];
string lastName = parameters[1];
var student = new Student(firstName, lastName);
multiDiuctionary.Add(course, student);
line = streamReader.ReadLine();
}
}
PrintCourses(multiDiuctionary);
}
示例13: SchoolShouldAddCourseCorrectly
public void SchoolShouldAddCourseCorrectly()
{
var school = new School("Telerik Academy");
var course = new Course("C#");
school.AddCourse(course);
Assert.AreSame(course, school.Courses.First());
}
示例14: btnAdd_Click
void btnAdd_Click(object sender, EventArgs e)
{
foreach (Control item in this.Controls)
{
TextBox tb = null;
if (item is TextBox)
{
tb = item as TextBox;
if (string.IsNullOrEmpty(tb.Text.Trim()))
{
ShowMessage(tb.Tag + "不能为空");
return;
}
}
}
int credit = 0;
bool b = Int32.TryParse(this.tbCcredit.Text.Trim(), out credit);
if (!b)
{
ShowMessage("学分只能为数字,请重新输入!");
return;
}
CourseMgrDataContext c = new CourseMgrDataContext();
Course course = new Course();
course.Cname = this.tbCname.Text.Trim();
course.Cmajorname = this.tbCmajorname.Text.Trim();
course.Cinfo = this.tbCinfo.Text.Trim();
course.Cteacher = this.tbCteacher.Text.Trim();
course.Ctime = this.tbCtime.Text.Trim();
course.Ccredit = credit;
c.Course.InsertOnSubmit(course);
c.SubmitChanges();
ShowMessage("添加新课程成功");
this.DialogResult = DialogResult.OK;
}
示例15: VerifyCompletion
//**************************************
//
public bool VerifyCompletion(Course c)
{
bool outcome = false;
// Step through all TranscriptEntries, looking for one
// which reflects a Section of the Course of interest.
foreach ( TranscriptEntry te in TranscriptEntries ) {
Section s = te.Section;
if ( s.IsSectionOf(c) ) {
// Ensure that the grade was high enough.
if ( TranscriptEntry.PassingGrade(te.Grade) ) {
outcome = true;
// We've found one, so we can afford to
// terminate the loop now.
break;
}
}
}
return outcome;
}