/// <summary> /// 绑定数据源 /// </summary> private void bind() { string id = Request.QueryString["id"].ToString(); AttendanceBLL attendBLL = new AttendanceBLL(); attend = attendBLL.get(id); CourseTableBLL ctBLL = new CourseTableBLL(); CourseTable ct = ctBLL.get(attend.CourTableID); ClassBLL classBLL = new ClassBLL(); TeacherBLL teacherBLL = new TeacherBLL(); CourseBLL courseBLL = new CourseBLL(); StudentBLL stuBLL = new StudentBLL(); #region 绑定页面数据 Label_class.Text = classBLL.get(ct.ClassID).Name; Label_course.Text = courseBLL.get(ct.CourId).Name; Label_teacher.Text = teacherBLL.get(ct.TeachID).Name; Label_student.Text = stuBLL.get(attend.StudID).Name; Label_oldStatus.Text = attend.Status; Label_week.Text = ct.Week; Label_weekDay.Text = ct.WeekDay; Label_courseTime.Text = ct.CourseTime; Label_place.Text = ct.Place; #endregion }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { string courTableID = Request.QueryString["courTableID"]; CourseTableBLL ctBLL = new CourseTableBLL(); TeacherBLL teacherBLL = new TeacherBLL(); CourseBLL courBLL = new CourseBLL(); ClassBLL classBLL = new ClassBLL(); CourseTable ct = ctBLL.get(courTableID); Class clazz = classBLL.get(ct.ClassID); #region 页面数据绑定 className.Text = clazz.Name; courseName.Text = courBLL.get(ct.CourId).Name; teacherName.Text = teacherBLL.get(ct.TeachID).Name; week.Text = "第" + ct.Week + "周"; weekDay.Text = ct.WeekDay; classtTime.Text = ct.CourseTime; classAddress.Text = ct.Place; CommonBLL commBLL = new CommonBLL(); DataTable dt = commBLL.getAbsentStudent(courTableID, false); AspNetPager1.RecordCount = dt.Rows.Count; int from = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize + 1; int to = from + AspNetPager1.PageSize - 1 > AspNetPager1.RecordCount ? AspNetPager1.RecordCount : from + AspNetPager1.PageSize - 1; GridView1.DataSource = PageUtil.getPaged(dt, from, to); GridView1.DataBind(); #endregion }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { string semester = DropDownList_semester_from.SelectedValue + "-" + DropDownList_semester_to.SelectedValue + "学年" + DropDownList_semester_end.SelectedValue; int week_from = Convert.ToInt32(DropDownList_week_from.SelectedValue); int week_to = Convert.ToInt32(DropDownList_week_to.SelectedValue); string weekDay = DropDownList_weekDay.SelectedValue; string place = TextBox_place.Text; string courseTime = DropDownList_courseTime.SelectedValue + "节"; string teachId = DropDownList_teacher.SelectedValue; string classId = DropDownList_class.SelectedValue; string courId = DropDownList_course.SelectedValue; CourseTableBLL courTableBLL = new CourseTableBLL(); CourseTable courTable = new CourseTable(); courTable.Semester = semester; courTable.WeekDay = weekDay; courTable.Place = place; courTable.CourseTime = courseTime; courTable.TeachID = teachId; courTable.ClassID = classId; courTable.CourId = courId; for (int i = week_from; i <= week_to; i++) { courTable.Week = i.ToString(); courTableBLL.save(courTable); } Response.Write("<script>alert('添加成功!');location.href='addCourseTable.aspx';</script>"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CourseTableBLL ctBLL = new CourseTableBLL(); ClassBLL classBLL = new ClassBLL(); CourseBLL courBLL = new CourseBLL(); TeacherBLL teachBLL = new TeacherBLL(); DropDownList_class.DataSource = classBLL.getAll(); DropDownList_class.DataTextField = "name"; DropDownList_class.DataValueField = "ID"; DropDownList_class.DataBind(); DropDownList_course.DataSource = courBLL.getByClassId(DropDownList_class.SelectedValue); DropDownList_course.DataTextField = "name"; DropDownList_course.DataValueField = "ID"; DropDownList_course.DataBind(); string filterTeacher = "classID='" + DropDownList_class.SelectedValue + "' and courId='" + DropDownList_course.SelectedValue + "'"; DataTable tempDt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filterTeacher, null, false); DataView dv = tempDt.DefaultView; tempDt = dv.ToTable(true, "teachID"); foreach (DataRow dr in tempDt.Rows) { Teacher teacher = teachBLL.get(dr["teachID"].ToString()); DropDownList_teacher.Items.Add(new ListItem(teacher.Name, teacher.Id)); } bind(); } }
protected void ImageButton_delete_Click(object sender, ImageClickEventArgs e) { ImageButton imageButton = sender as ImageButton; string id = imageButton.CommandArgument; AttendanceBLL attendBLL = new AttendanceBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); CourseTable ct = ctBLL.get(id); string filter = "courId='" + ct.CourId + "' and teachID='" + ct.TeachID + "' and classID='" + ct.ClassID; filter += "' and semester='" + ct.Semester + "' and weekDay='" + ct.WeekDay + "' and courseTime='" + ct.CourseTime + "'"; DataTable dt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filter, null, false); foreach (DataRow dr in dt.Rows) { attendBLL.deleteByCourseTableId(dr["ID"].ToString()); CourseTable tempCt = new CourseTable(); tempCt.Id = dr["ID"].ToString(); ctBLL.delete(tempCt); } Response.Write("<script>alert('删除成功!');location.href='showCourseTable.aspx';</script>"); }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { string id = Request.QueryString["ID"].ToString(); string week = Request.QueryString["week"].ToString(); CourseBLL courBLL = new CourseBLL(); TeacherBLL teacherBLL = new TeacherBLL(); ClassBLL classBLL = new ClassBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); ct = ctBLL.get(id); #region 页面数据绑定 Label_course.Text = courBLL.get(ct.CourId).Name; Label_teacher.Text = teacherBLL.get(ct.TeachID).Name; Label_class.Text = classBLL.get(ct.ClassID).Name; PageUtil.bindDropDownList(DropDownList_semester_from, ct.Semester.Substring(0, 4)); PageUtil.bindDropDownList(DropDownList_semester_to, ct.Semester.Substring(5, 4)); PageUtil.bindDropDownList(DropDownList_semester_end, ct.Semester.Substring(9, 3)); PageUtil.bindDropDownList(DropDownList_week_from, week.Split('-')[0]); PageUtil.bindDropDownList(DropDownList_week_to, week.Split('-')[1]); PageUtil.bindDropDownList(DropDownList_weekDay, ct.WeekDay); TextBox_place.Text = ct.Place; PageUtil.bindDropDownList(DropDownList_courseTime, ct.CourseTime.Split('节')[0]); #endregion }
protected void Button_submit_Click(object sender, EventArgs e) { if (!checkEmpty()) { string userName = TextBox_userName.Text.Trim(); string password = TextBox_password.Text.Trim(); StaffBLL staffBLL = new StaffBLL(); UserBLL userBLL = new UserBLL(); User user = userBLL.getByUsername(userName); if (user != null) { //取得加密后的密码 string encryptPWD = EncryptUtil.MD5Encrypt(password); if (!user.Password.Equals(encryptPWD)) { //密码不匹配的情况 checkPassword.ErrorMessage = "密码输入错误!"; checkPassword.IsValid = false; } else { Staff staff = staffBLL.getByUserId(user.Id); if (staff != null && staff.Type.Equals("超级管理员")) { //用户检查通过的情况 AttendanceBLL attendBLL = new AttendanceBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); string filter = "semester='" + GlobalVars.SEMESTER + "'"; DataTable dt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filter, null, false); foreach (DataRow dr in dt.Rows) { attendBLL.deleteByCourseTableId(dr["ID"].ToString()); } Response.Write("<script>alert('考勤初始化成功!');location.href='../mainPages/welcome.aspx';</script>"); } else { checkUsername.ErrorMessage = "该用户没有权限!"; checkUsername.IsValid = false; } } } else { checkUsername.ErrorMessage = "账号不存在!"; checkUsername.IsValid = false; } } }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { AttendanceBLL attendBLL = new AttendanceBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); string filter = "courId='" + ct.CourId + "' and teachID='" + ct.TeachID + "' and classID='" + ct.ClassID; filter += "' and semester='" + ct.Semester + "' and weekDay='" + ct.WeekDay + "' and courseTime='" + ct.CourseTime + "'"; #region 先删除旧数据 DataTable dt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filter, null, false); foreach (DataRow dr in dt.Rows) { attendBLL.deleteByCourseTableId(dr["ID"].ToString()); CourseTable tempCt = new CourseTable(); tempCt.Id = dr["ID"].ToString(); ctBLL.delete(tempCt); } #endregion #region 后添加新数据 string semester = DropDownList_semester_from.SelectedValue + "-" + DropDownList_semester_to.SelectedValue + "学年" + DropDownList_semester_end.SelectedValue; int week_from = Convert.ToInt32(DropDownList_week_from.SelectedValue); int week_to = Convert.ToInt32(DropDownList_week_to.SelectedValue); string weekDay = DropDownList_weekDay.SelectedValue; string place = TextBox_place.Text; string courseTime = DropDownList_courseTime.SelectedValue + "节"; string teachId = ct.TeachID; string classId = ct.ClassID; string courId = ct.CourId; CourseTable courTable = new CourseTable(); courTable.Semester = semester; courTable.WeekDay = weekDay; courTable.Place = place; courTable.CourseTime = courseTime; courTable.TeachID = teachId; courTable.ClassID = classId; courTable.CourId = courId; for (int i = week_from; i <= week_to; i++) { courTable.Week = i.ToString(); ctBLL.save(courTable); } #endregion Response.Write("<script>alert('修改成功!');location.href='showCourseTable.aspx';</script>"); } }
public void bind() { courTableID = Request.QueryString["courTableID"]; User user = Session["User"] as User; TeacherBLL teachBLL = new TeacherBLL(); StudentBLL studBLL = new StudentBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); CourseTable ct = ctBLL.get(courTableID); ClassBLL classBll = new ClassBLL(); Class cla = classBll.get(ct.ClassID); className.Text = cla.Name; dt = studBLL.getByClassId(ct.ClassID).Tables[0]; if (Session["attenList"] != null) { attenList = Session["attenList"] as List <Attendance>; } else { attenList = new List <Attendance>(); foreach (DataRow dr in dt.Rows) { Attendance attend = new Attendance(); attend.Status = "正常"; attend.Remark = ""; attend.Recorder = "教师"; attend.RecorderID = teachBLL.getByUserId(user.Id).Id; attend.StudID = dr["ID"].ToString(); attend.CourTableID = courTableID; attenList.Add(attend); } } AspNetPager1.RecordCount = dt.Rows.Count; int from = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize + 1; int to = from + AspNetPager1.PageSize - 1 > AspNetPager1.RecordCount ? AspNetPager1.RecordCount : from + AspNetPager1.PageSize - 1; GridView1.DataSource = PageUtil.resort(PageUtil.getPaged(dt, from, to)); GridView1.DataBind(); initStatusAndRemark(); }
protected void DropDownList_course_SelectedIndexChanged(object sender, EventArgs e) { CourseTableBLL ctBLL = new CourseTableBLL(); TeacherBLL teachBLL = new TeacherBLL(); DropDownList_teacher.Items.Clear(); string filterTeacher = "classID='" + DropDownList_class.SelectedValue + "' and courId='" + DropDownList_course.SelectedValue + "'"; DataTable tempDt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filterTeacher, null, false); DataView dv = tempDt.DefaultView; tempDt = dv.ToTable(true, "teachID"); foreach (DataRow dr in tempDt.Rows) { Teacher teacher = teachBLL.get(dr["teachID"].ToString()); DropDownList_teacher.Items.Add(new ListItem(teacher.Name, teacher.Id)); } bind(); }
public void bind() { List <Attendance> attenList = Session["attenList"] as List <Attendance>; CourseTableBLL ctBLL = new CourseTableBLL(); TeacherBLL teachBll = new TeacherBLL(); CourseBLL courBLL = new CourseBLL(); ClassBLL classBLL = new ClassBLL(); CourseTable ct = ctBLL.get(attenList[0].CourTableID); Class clazz = classBLL.get(ct.ClassID); #region 页面数据绑定 className.Text = clazz.Name; courseName.Text = courBLL.get(ct.CourId).Name; teacherName.Text = teachBll.get(ct.TeachID).Name; week.Text = "第" + ct.Week + "周"; weekDay.Text = ct.WeekDay; classtTime.Text = ct.CourseTime; classAddress.Text = ct.Place; lateNumber.Text = attenList.Where(x => x.Status.Equals("迟到")).ToList().Count.ToString(); absences.Text = attenList.Where(x => !x.Status.Equals("正常")).ToList().Count.ToString(); allNumber.Text = clazz.StudCount; attRate.Text = FormatUtil.doubleToPercent(attenList.Where(x => x.Status.Equals("正常")).ToList().Count / Convert.ToDouble(clazz.StudCount)); DataTable dt = transferListToDataTable(attenList); AspNetPager1.RecordCount = dt.Rows.Count; int from = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize + 1; int to = from + AspNetPager1.PageSize - 1 > AspNetPager1.RecordCount ? AspNetPager1.RecordCount : from + AspNetPager1.PageSize - 1; GridView1.DataSource = PageUtil.resort(PageUtil.getPaged(dt, from, to)); GridView1.DataBind(); #endregion }
/// <summary> /// 页面数据绑定 /// </summary> private void bind() { CourseTableBLL ctBLL = new CourseTableBLL(); StudentBLL stuBLL = new StudentBLL(); //绑定页面查询条件的数据 DropDownList_student.Items.Clear(); DropDownList_student.DataSource = stuBLL.getByClassId(DropDownList_class.SelectedValue); DropDownList_student.DataTextField = "name"; DropDownList_student.DataValueField = "ID"; DropDownList_student.DataBind(); DropDownList_week.Items.Clear(); string filterWeek = "classID='" + DropDownList_class.SelectedValue + "' and courId='" + DropDownList_course.SelectedValue + "'"; filterWeek += " and teachID='" + DropDownList_teacher.SelectedValue + "'"; DataTable tempDt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filterWeek, null, false); int week_from = tempDt.Rows.Count == 0 ? 0 : tempDt.Select().Min(r => Convert.ToInt32(r["week"].ToString())); int week_to = tempDt.Rows.Count == 0 ? 0 : tempDt.Select().Max(r => Convert.ToInt32(r["week"].ToString())); for (int i = week_from; i <= week_to; i++) { DropDownList_week.Items.Add(i.ToString()); } string preValue = DropDownList_weekDay.SelectedValue; DropDownList_weekDay.Items.Clear(); string filterWeekDay = "week='" + DropDownList_week.SelectedValue + "'"; tempDt = PageUtil.getProcessedDataTable(tempDt, filterWeekDay, "weekDay", false); foreach (DataRow dr in tempDt.Rows) { DropDownList_weekDay.Items.Add(dr["weekDay"].ToString()); } PageUtil.bindDropDownList(DropDownList_weekDay, preValue); DropDownList_courseTime.Items.Clear(); string filterCourTime = "weekDay='" + DropDownList_weekDay.SelectedValue + "'"; tempDt = PageUtil.getProcessedDataTable(tempDt, filterCourTime, "courseTime", false); foreach (DataRow dr in tempDt.Rows) { DropDownList_courseTime.Items.Add(dr["courseTime"].ToString()); } string filterPlace = "courseTime='" + DropDownList_courseTime.SelectedValue + "'"; tempDt = PageUtil.getProcessedDataTable(tempDt, filterPlace, null, false); Label_place.Text = tempDt.Rows.Count == 0 ? "" : tempDt.Rows[0]["place"].ToString(); Label_courTableId.Text = tempDt.Rows.Count == 0 ? "" : tempDt.Rows[0]["ID"].ToString(); }