/// <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 }
private DataTable transferListToDataTable(List<Attendance> attenList) { StudentBLL stuBLL = new StudentBLL(); DataTable dt = new DataTable(); //设置自增长列 DataColumn colNumber = new DataColumn("ID"); colNumber.AutoIncrement = true;//设置是否为自增列 colNumber.AutoIncrementSeed = 1;//设置自增初始值 colNumber.AutoIncrementStep = 1;//设置每次子增值 dt.Columns.Add(colNumber); dt.Columns.Add("stuId", Type.GetType("System.String")); dt.Columns.Add("name", Type.GetType("System.String")); dt.Columns.Add("gender", Type.GetType("System.String")); dt.Columns.Add("status", Type.GetType("System.String")); dt.Columns.Add("remark", Type.GetType("System.String")); foreach (Attendance att in attenList) { Student stud = stuBLL.get(att.StudID); DataRow dr = dt.NewRow(); dr[1] = stud.StuId; dr[2] = stud.Name; dr[3] = stud.Gender; dr[4] = att.Status; dr[5] = att.Remark; dt.Rows.Add(dr); } return dt; }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { StudentBLL stuBLL = new StudentBLL(); string name = TextBox_name.Text.Trim(); string gender = RadioButton_male.Checked ? "男" : "女"; string birth = DropDownList_yearPart1.SelectedValue + DropDownList_yearPart2.SelectedValue + DropDownList_yearPart3.SelectedValue + DropDownList_yearPart4.SelectedValue; birth += DropDownList_month.SelectedValue; string phone = TextBox_phone.Text.Trim(); string address = TextBox_address.Text.Trim(); string classID = DropDownList_class.SelectedValue; stu.Name = name; stu.Gender = gender; stu.Birth = birth; stu.Phone = phone; stu.Address = address; stu.ClassID = classID; stuBLL.update(stu); Response.Write("<script>alert('修改成功!');location.href='showStudents.aspx';</script>"); } }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { ClassBLL classBLL = new ClassBLL(); StudentBLL stuBLL = new StudentBLL(); UserBLL userBLL = new UserBLL(); string stuId = TextBox_stuId.Text.Trim(); string name = TextBox_name.Text.Trim(); string gender = RadioButton_male.Checked ? "男" : "女"; string birth = DropDownList_yearPart1.SelectedValue + DropDownList_yearPart2.SelectedValue + DropDownList_yearPart3.SelectedValue + DropDownList_yearPart4.SelectedValue; birth += DropDownList_month.SelectedValue; string phone = TextBox_phone.Text.Trim(); string address = TextBox_address.Text.Trim(); string classID = DropDownList_class.SelectedValue; if (stuBLL.getByStuId(stuId) == null) { if (userBLL.getByUsername(stuId) == null) { #region 在用户表中创建新用户 User user = new User(); user.UserName = stuId; user.Password = EncryptUtil.MD5Encrypt("12345678"); user.Type = "4"; userBLL.save(user); #endregion Class clazz = classBLL.get(classID); clazz.StudCount = (Convert.ToInt32(clazz.StudCount) + 1).ToString(); classBLL.update(clazz); Student stu = new Student(); stu.StuId = stuId; stu.Name = name; stu.Gender = gender; stu.Birth = birth; stu.Phone = phone; stu.Address = address; stu.ClassID = classID; stu.UserID = userBLL.getByUsername(stuId).Id; stuBLL.save(stu); Response.Write("<script>alert('添加成功!');location.href='addStudent.aspx';</script>"); } else Response.Write("<script>alert('添加失败,用户名已存在!');location.href='addStudent.aspx';</script>"); } else { checkStuId.ErrorMessage = "学号已存在!"; checkStuId.IsValid = false; } } }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { User user = Session["User"] as User; Student stud = new StudentBLL().getByUserId(user.Id); Label_name.Text = stud.Name; CommonBLL commBLL = new CommonBLL(); GridView1.DataSource = commBLL.getSingleStudentAttendStatistics(stud.Id,true); GridView1.DataBind(); }
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 GetStudentWeb() { string stu = "select * from Student where State=0 "; if (!string.IsNullOrEmpty(txtStuID.Text)) { stu += " and [StudentID]='" + txtStuID.Text + "'"; } if (!string.IsNullOrEmpty(txtStuName.Text)) { stu += " and [StudentName]='" + txtStuName.Text + "'"; } if (!string.IsNullOrEmpty(txtPhone.Text)) { stu += " and [Phone]='" + txtPhone.Text + "'"; } if (!string.IsNullOrEmpty(txtAccommodationtime.Text)) { stu += " and [Accommodationtime]='" + txtAccommodationtime.Text + "'"; } if (!string.IsNullOrEmpty(txtleavetime.Text)) { stu += " and [leavetime]='" + txtleavetime.Text + "'"; } PagedDataSource pd = new PagedDataSource(); pd.AllowPaging = true; pd.PageSize = 8; BLL.StudentBLL studentBll = new BLL.StudentBLL(); pd.DataSource = studentBll.GetStudentBLL(stu); int index = (int)ViewState["PageIndex"]; if (index < 1) { index = pd.PageCount; } if (index > pd.PageCount) { index = 1; } pd.CurrentPageIndex = index - 1; lblPage.Text = "第" + (index) + "页/共" + pd.PageCount + "页"; ListView1.DataSource = pd; ListView1.DataBind(); }
private void bind() { string id = Request.QueryString["id"].ToString(); StudentBLL stuBLL = new StudentBLL(); stu = stuBLL.get(id); Label_stuId.Text = stu.StuId; TextBox_name.Text = stu.Name; if (stu.Gender.Equals("女")) RadioButton_female.Checked = true; PageUtil.bindDropDownList(DropDownList_yearPart1, stu.Birth[0].ToString()); PageUtil.bindDropDownList(DropDownList_yearPart2, stu.Birth[1].ToString()); PageUtil.bindDropDownList(DropDownList_yearPart3, stu.Birth[2].ToString()); PageUtil.bindDropDownList(DropDownList_yearPart4, stu.Birth[3].ToString()); PageUtil.bindDropDownList(DropDownList_month, stu.Birth.Substring(4, 2)); TextBox_phone.Text = stu.Phone; TextBox_address.Text = stu.Address; PageUtil.bindDropDownList(DropDownList_class, stu.ClassID); }
private void bind() { User user = (User)Session["user"]; StudentBLL studBll = new StudentBLL(); Student stud = studBll.getByUserId(user.Id); CommonBLL commonBll = new CommonBLL(); // 根据班级ID得到课程信息 string filter = "1=1"; filter += weekId.SelectedIndex == 0 ? "" : " and week='" + weekId.SelectedValue + "'"; DataTable dt = PageUtil.getProcessedDataTable(commonBll.getWorkAttendanceByClassID(stud.ClassID), filter); 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(); }
protected void ImageButton_delete_Click(object sender, ImageClickEventArgs e) { ImageButton imageButton = sender as ImageButton; string id = imageButton.CommandArgument; ClassBLL classBLL = new ClassBLL(); StudentBLL stuBLL = new StudentBLL(); UserBLL userBLL = new UserBLL(); Student stu = stuBLL.get(id); User user = userBLL.get(stu.UserID); stuBLL.delete(stu); userBLL.delete(user); Class clazz = classBLL.get(stu.ClassID); clazz.StudCount = (Convert.ToInt32(clazz.StudCount) - 1).ToString(); classBLL.update(clazz); Response.Write("<script>alert('删除成功!');location.href='showStudents.aspx';</script>"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["User"] != null) { string username = ""; User user = Session["User"] as User; int type = Convert.ToInt32(user.Type); switch (type) { case 1: username = new TeacherBLL().getByUserId(user.Id).Name; break; case 2: username = new TeacherBLL().getByUserId(user.Id).Name; break; case 3: username = new StudentBLL().getByUserId(user.Id).Name; break; case 4: username = new StudentBLL().getByUserId(user.Id).Name; break; case 5: username = new StaffBLL().getByUserId(user.Id).Name; break; case 6: username = new StaffBLL().getByUserId(user.Id).Name; break; } Label_username.Text = username; } } }
public void bind() { User user = (User)Session["user"]; ClassBLL classBLL = new ClassBLL(); StudentBLL studBll = new StudentBLL(); Student stud = studBll.getByUserId(user.Id); Class clazz = classBLL.get(stud.ClassID); className.Text = clazz.Name; CommonBLL commBLL = new CommonBLL(); DataTable dt = commBLL.getClassStudentAttendStatistics(clazz.Id, stud.Id, 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(); }
/// <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(); }