示例#1
0
        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();
        }
        /// <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();
        }