protected void AddCourseSureButton_Click(object sender, EventArgs e) { tea = (Teacher)Session["teacher"]; Course newcourse = new Course(); if (cournumTextBox.Text == "") CoursenumLabel.Visible = true; else if (cournameTextBox.Text == "") { CoursenumLabel.Visible = false; CoursenameLabel.Visible = true; } else { newcourse.teacher = tea.username; newcourse.name = cournameTextBox.Text; newcourse.num = cournumTextBox.Text; DateTime start = Convert.ToDateTime(courstart_timeTextBox.Text + " 00:00:00"); newcourse.start_time = start; DateTime end = Convert.ToDateTime(courend_timeTextBox.Text + " 23:59:59"); newcourse.end_time = end; CourMan.AddCourse(newcourse); Response.Write("<script>alert('成功添加!');location.href='AddCourse.aspx';</script>"); //Response.Redirect("AddCourse.aspx"); } }
//插入teacher public bool AddTeacher(Teacher teacher) { DataClassesDataContext da = new DataClassesDataContext(); Teacher t = new Teacher(); t = teacher; da.Teacher.InsertOnSubmit(t); da.SubmitChanges(); return true; }
protected void Page_Load(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(Request.Form["name"]) && !string.IsNullOrEmpty(Request.Form["password"]))//获取form中的参数 { string UserName = Request.Form["name"].ToString(); string UserPassword = Request.Form["password"].ToString(); string Identity = Request["status"]; string Major = Request["account"]; if (Identity == student.ID) { StudentManager StudentMan = new StudentManager(); Student stu = new Student(); stu.username = UserName; stu.passwd = UserPassword; stu.name = UserName; if (Major == null) { Major = string.Empty; } stu.major = Major; //stu.grade = string.Empty; StudentMan.AddStudent(stu); Session["student"] = stu; Session["UserRole"] = "Student"; Response.Redirect("StudentMainForm.aspx"); } else if (Identity == teacher.ID) { TeacherManager TeacherMan = new TeacherManager(); Teacher tea = new Teacher(); tea.username = UserName; tea.passwd = UserPassword; tea.name = UserName; TeacherMan.AddTeacher(tea); Session["teacher"] = tea; Session["UserRole"] = "Teacher"; Response.Redirect("AddCourse.aspx"); } } } catch (Exception ex) { Response.Write("<Script Language=JavaScript>alert('用户名已存在!');</Script>"); } }
protected void dcnameTextBox_TextChanged(object sender, EventArgs e) { tea = (Teacher)Session["teacher"]; Course deletecourse = new Course(); List<Course> courseforteacher = CourMan.GetCourseForTeacher(tea.username); foreach (var c in courseforteacher) { if (c.name == dcnameTextBox.Text.ToString()) { deletecourse = c; break; } } Session["deletecourse"] = deletecourse; dcnumTextBox.Text = deletecourse.num; dcstart_timeLabel.Text = deletecourse.start_time.ToString(); dcend_timeLabel.Text = deletecourse.end_time.ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Teacher") { Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>"); return; } //获取课程信息 tea = (Teacher)Session["teacher"]; courseforteacher = CourMan.GetCourseForTeacher(tea.username); Session["courselist"] = courseforteacher; foreach (var c in courseforteacher) { if (c.num == Request.QueryString["Coursenum"]) { course = c; break; } } allassigncoursenameLabel.Text = course.name; }
partial void DeleteTeacher(Teacher instance);
partial void UpdateTeacher(Teacher instance);
partial void InsertTeacher(Teacher instance);
protected void Page_Load(object sender, EventArgs e) { if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Teacher") { Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>"); return; } //获取课程信息 tea = (Teacher)Session["teacher"]; List<Course> courseforteacher = CourMan.GetCourseForTeacher(tea.username); foreach (var c in courseforteacher) { if (c.num == Request.QueryString["Coursenum"]) { course = c; break; } } //显示课程名 coursenameLabel.Text = course.name; //删除问题时弹窗 DeletePro.Attributes.Add("onclick", "return confirm('确定要删吗?');"); }
//bool firstNodeExpandFlag = false; protected void Page_Load(object sender, EventArgs e) { foreach (string str in Session.Keys) { if (str.Equals("student")) { stu = (Student)Session["student"]; welcome.Text = "欢迎" + stu.username; initTreeView(); } else if (str.Equals("teacher")) { tea = (Teacher)Session["teacher"]; welcome.Text = "欢迎您," + tea.username; initTeacherTreeView(); } } }