Пример #1
0
        public DataSet.DsPSMS.ATTENDANCE_RESULTDataTable selectAttendanceData(DataSet.DsPSMS.ST_STUDENT_DATARow sr, DataSet.DsPSMS.ST_ATTENDANCE_DATARow dr, out string msg)
        {
            DataSet.DsPSMS.ATTENDANCE_RESULTDataTable result = new DataSet.DsPSMS.ATTENDANCE_RESULTDataTable();
            if (dr == null)
            {
                msg = "data is empty";
                return(null);
            }
            try
            {
                db.Open();
                result = db.selectAttendanceData(sr, dr);
                if (result != null)
                {
                    msg = result.Rows.Count + " day found";
                }
                else
                {
                    result = null;
                    msg    = "attendance not found";
                }
            }
            catch
            {
                msg = "error has occure when insert data";
                return(null);
            }
            finally
            {
                db.Close();
            }

            return(result);
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (!checkValidation())
            {
                gridViewAttendance.DataSource = null;
                gridViewAttendance.DataBind();
                studentRow              = new DataSet.DsPSMS.ST_STUDENT_DATADataTable().NewST_STUDENT_DATARow();
                studentRow.EDU_YEAR     = Convert.ToInt16(eduYearList.Text);
                studentRow.GRADE_ID     = gradeList.Text;
                studentRow.ROOM_ID      = roomList.Text;
                studentRow.ROLL_NO      = "";
                studentRow.STUDENT_NAME = "";

                if (attendDate.Text.Trim().Length == 0)
                {
                    DataSet.DsPSMS.ST_STUDENT_DATADataTable resultDt = attService.selectStudentData(studentRow, out msg);
                    if (resultDt == null || resultDt.Count == 0)
                    {
                        ModelState.AddModelError(string.Empty, "Data doesn't found");
                        gridViewAttendance.DataSource = null;
                        gridViewAttendance.DataBind();
                    }
                    else
                    {
                        gridViewAttendance.DataSource = resultDt;
                        gridViewAttendance.DataBind();
                    }
                }
                else
                {
                    DataSet.DsPSMS.ST_ATTENDANCE_DATARow adr = new DataSet.DsPSMS.ST_ATTENDANCE_DATADataTable().NewST_ATTENDANCE_DATARow();
                    adr.ATTENDANCE_DATE = attendDate.Text;
                    DataSet.DsPSMS.ATTENDANCE_RESULTDataTable resultDt = attService.selectAttendanceData(studentRow, adr, out msg);

                    if (resultDt.Count != 0)
                    {
                        gridViewAttendance.DataSource = resultDt;
                        gridViewAttendance.DataBind();

                        for (int i = 0; i < resultDt.Count; i++)
                        {
                            Label date = (Label)gridViewAttendance.Rows[i].FindControl("Date");
                            date.Text = resultDt.Rows[i]["ATTENDANCE_DATE"].ToString();

                            CheckBox chkAM = (CheckBox)gridViewAttendance.Rows[i].FindControl("AM");
                            chkAM.Checked = false;
                            if (Convert.ToInt16(resultDt.Rows[i]["MORNING"]) == 1)
                            {
                                chkAM.Checked = true;
                            }
                            else
                            {
                                chkAM.Checked = false;
                            }

                            CheckBox chkPM = (CheckBox)gridViewAttendance.Rows[i].FindControl("PM");
                            chkPM.Checked = false;
                            if (Convert.ToInt16(resultDt.Rows[i]["EVENING"]) == 1)
                            {
                                chkPM.Checked = true;
                            }
                            else
                            {
                                chkPM.Checked = false;
                            }
                        }
                    }
                }
                showAllButton();
            }
        }