protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         LoadDDLs();
         if (CurrentCheckedStudent != 0)
         {
             //BindData();
             DBLayer db = new DBLayer();
             DataSet ds = new DataSet();
             ds = db.GetStudent(CurrentCheckedStudent);
             if (ds.Tables[0].Rows.Count > 0)
             {
                 uiGridViewStudentsAbsence.DataSource = db.GetMonthlyAttendanceReportByStudentID(CurrentCheckedStudent);
                 uiGridViewStudentsAbsence.DataBind();
                 uiLabelStudentName.Text = ds.Tables[0].Rows[0]["ArStudentName"].ToString() + ds.Tables[0].Rows[0]["ArFatherName"].ToString();
                 DataSet StudentClassRoom = new DataSet();
                 StudentClassRoom = db.GetClassRoom(Convert.ToInt32(ds.Tables[0].Rows[0]["ClassRoomID"].ToString()));
                 DataSet StudentClass = new DataSet();
                 StudentClass = db.GetClass(Convert.ToInt32(StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString()));
                 uiLabelClass.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
             }
             uiPanelCurrentStudents.Visible = false;
             uiPanelCurrent.Visible = true;
         }
         else
         {
             uiPanelCurrentStudents.Visible = true;
             uiPanelCurrent.Visible = false;
             BindStudentData();
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         LoadDDLs();
         if (CurrentActiveStudent != 0)
         {
             //BindData();
             DBLayer db = new DBLayer();
             DataSet ds = new DataSet();
             ds = db.GetStudent(CurrentActiveStudent);
             if (ds.Tables[0].Rows.Count > 0)
             {
                 uiGridViewStudentResults.DataSource = db.GetResultByStudentIDAndSchoolYearForAdmin(CurrentActiveStudent, Convert.ToInt32(uiDropDownListSchoolYear.SelectedValue));
                 uiGridViewStudentResults.DataBind();
                 uiLabelStudentName.Text = ds.Tables[0].Rows[0]["ArStudentName"].ToString() + ds.Tables[0].Rows[0]["ArFatherName"].ToString();
                 DataSet StudentClassRoom = new DataSet();
                 StudentClassRoom = db.GetClassRoom(Convert.ToInt32(ds.Tables[0].Rows[0]["ClassRoomID"].ToString()));
                 DataSet StudentClass = new DataSet();
                 StudentClass = db.GetClass(Convert.ToInt32(StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString()));
                 uiLabelClass.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
             }
             uiPanelCurrentStudents.Visible = false;
             uiPanelCurrent.Visible = true;
         }
         else
         {
             uiPanelCurrentStudents.Visible = true;
             uiPanelCurrent.Visible = false;
             BindStudentData();
         }
     }
 }
        protected void uiButtonViewResult_Click(object sender, EventArgs e)
        {
            DBLayer db = new DBLayer();
            DataSet Student= new DataSet();
            Student = db.GetStudent(Convert.ToInt32(Session["CurrentLoggedInStudent"].ToString()));
            DataSet StudentClassRoom = new DataSet();
            StudentClassRoom = db.GetClassRoom(Convert.ToInt32(Student.Tables[0].Rows[0]["ClassRoomID"].ToString()));
            DataSet StudentClass = new DataSet();
            StudentClass = db.GetClass(Convert.ToInt32(StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString()));
            DataSet ClassType = new DataSet();
            ClassType = db.GetClassType(Convert.ToInt32(StudentClass.Tables[0].Rows[0]["ClassTypeID"].ToString()));

            DataSet CoursesInTotal = new DataSet();
            DataSet CoursesRemaining = new DataSet();

            CoursesInTotal = db.GetAllCoursesByClassAndInTotal(Convert.ToInt32(StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString()), true);
            CoursesRemaining = db.GetAllCoursesByClassAndInTotal(Convert.ToInt32(StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString()), false);

            switch (StudentClass.Tables[0].Rows[0]["ClassTypeID"].ToString())
            {
                case "1":
                    uiDataListKidResults.DataSource = db.GetResultByStudentIDAndSchoolYear(Convert.ToInt32(Session["CurrentLoggedInStudent"].ToString()), Convert.ToInt32(uiDropDownListSchoolYear.SelectedValue),FHMT, FHF, SHMT, SHF);
                    uiDataListKidResults.DataBind();
                    uiLabelKidName.Text = Student.Tables[0].Rows[0]["ArStudentname"].ToString() + " " + Student.Tables[0].Rows[0]["Arfathername"].ToString();
                    uiLabelClass.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
                    uiPanelKids.Visible = true;
                    uiPanelPrepratory.Visible = false;
                    uiPanelPrimary.Visible = false;
                    break;
                case "2":
                    DataSet AllCoursesPrimary = db.GetResultByStudentIDAndSchoolYear(Convert.ToInt32(Session["CurrentLoggedInStudent"].ToString()), Convert.ToInt32(uiDropDownListSchoolYear.SelectedValue), FHMT, FHF, SHMT, SHF);
                    /*DataRow[] InTotalCourses = AllCoursesPrimary.Tables[0].Select("InTotal = 1");                    */
                    uiDataListCourseInTotalPrimary.DataSource = AllCoursesPrimary;
                    uiDataListCourseInTotalPrimary.DataBind();
                    uiLabelStudentName.Text = Student.Tables[0].Rows[0]["ArStudentname"].ToString() + " " + Student.Tables[0].Rows[0]["Arfathername"].ToString();
                    uiLabelClassPrim.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
                    uiLabelClassPrimary.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
                    uiPanelKids.Visible = false;
                    uiPanelPrepratory.Visible = false;
                    uiPanelPrimary.Visible = true;
                    break;
                case "3":
                    DataSet AllCoursesPrep = db.GetResultByStudentIDAndSchoolYear(Convert.ToInt32(Session["CurrentLoggedInStudent"].ToString()), Convert.ToInt32(uiDropDownListSchoolYear.SelectedValue), FHMT, FHF, SHMT, SHF);
                    uiDataListPrep.DataSource = AllCoursesPrep;
                    uiDataListPrep.DataBind();
                    uiLabelStudentNamePrep.Text = Student.Tables[0].Rows[0]["ArStudentname"].ToString() + " " + Student.Tables[0].Rows[0]["Arfathername"].ToString();
                    uiLabelClassPrep.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
                    uiLabelClassPreparatory.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
                    uiPanelKids.Visible = false;
                    uiPanelPrepratory.Visible = true;
                    uiPanelPrimary.Visible = false;
                    break;
                default:
                    break;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDDLs();
                if (Session["CurrentLoggedInStudent"] != null)
                {
                    int id = Convert.ToInt32(Session["CurrentLoggedInStudent"].ToString());
                    DBLayer db = new DBLayer ();
                    DataSet ds = new DataSet ();
                    ds = db.GetStudent(id);
                    DataSet StudentClassRoom = new DataSet();
                    StudentClassRoom = db.GetClassRoom(Convert.ToInt32(ds.Tables[0].Rows[0]["ClassRoomID"].ToString()));
                    uiDropDownListClasses.SelectedValue = StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString();

                    uiDropDownListClassRooms.DataSource = db.GetAllClassRoomsByClassID(Convert.ToInt32(uiDropDownListClasses.SelectedValue));
                    uiDropDownListClassRooms.DataTextField = "ArName";
                    uiDropDownListClassRooms.DataValueField = "ClassRoomID";
                    uiDropDownListClassRooms.DataBind();
                    uiDropDownListClassRooms.SelectedValue = ds.Tables[0].Rows[0]["ClassRoomID"].ToString();
                    BindData();
                }
            }
        }
 protected void uiGridViewStudents_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "EditFees")
     {
         int id = Convert.ToInt32(e.CommandArgument.ToString());
         CurrentStudentActive = id;
         DBLayer db = new DBLayer();
         DataSet ds = new DataSet();
         ds = db.GetStudent(CurrentStudentActive);
         if (ds.Tables[0].Rows.Count > 0)
         {
             uiGridViewStudentsFees.DataSource = db.GetFeesByClassAndClassRoomAndSchoolYear(Convert.ToInt32(uiDropDownListClasses.SelectedValue),
                                                     Convert.ToInt32(uiDropDownListClassRooms.SelectedValue),
                                                     Convert.ToInt32(uiDropDownListSchoolYear.SelectedValue));
             uiGridViewStudentsFees.DataBind();
             uiLabelStudentName.Text = ds.Tables[0].Rows[0]["ARStudentName"].ToString() + " " + ds.Tables[0].Rows[0]["ArFatherName"].ToString();
             DataSet StudentClassRoom = new DataSet();
             StudentClassRoom = db.GetClassRoom(Convert.ToInt32(ds.Tables[0].Rows[0]["ClassRoomID"].ToString()));
             DataSet StudentClass = new DataSet();
             StudentClass = db.GetClass(Convert.ToInt32(StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString()));
             uiLabelClass.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
         }
         uiPanelCurrentFees.Visible = false;
         uiPanelCurrent.Visible = true;
     }
 }
        protected void uiGridViewStudents_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditStudent")
            {
                int id = Convert.ToInt32(e.CommandArgument.ToString());
                CurrentStudent = id;
                DBLayer db = new DBLayer();
                DataSet ds = new DataSet();
                ds = db.GetStudent(id);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    uiTextBoxEnName.Text = ds.Tables[0].Rows[0]["ENStudentName"].ToString();
                    uiTextBoxArName.Text = ds.Tables[0].Rows[0]["ArStudentName"].ToString();
                    uiTextBoxENFatherName.Text = ds.Tables[0].Rows[0]["ENFatherName"].ToString();
                    uiTextBoxARFatherName.Text = ds.Tables[0].Rows[0]["ArFatherName"].ToString();
                    uiTextBoxNationalNo.Text = ds.Tables[0].Rows[0]["FatherNationalNumber"].ToString();
                    uiTextBoxJobDesc.Text = ds.Tables[0].Rows[0]["FatherJobDesc"].ToString();
                    uiTextBoxEmail.Text = ds.Tables[0].Rows[0]["Email"].ToString();
                    uiTextBoxTele.Text = ds.Tables[0].Rows[0]["Tele"].ToString();
                    uiTextBoxMobile.Text = ds.Tables[0].Rows[0]["Mobile"].ToString();
                    uiTextBoxAddress.Text = ds.Tables[0].Rows[0]["StudentAddress"].ToString();
                    uiCheckBoxIsActive.Checked = (bool)ds.Tables[0].Rows[0]["IsActive"];
                    uiTextBoxUsername.Text = ds.Tables[0].Rows[0]["UserName"].ToString();

                    DataSet StudentClassRoom = new DataSet();
                    StudentClassRoom = db.GetClassRoom(Convert.ToInt32(ds.Tables[0].Rows[0]["ClassRoomID"].ToString()));

                    uiDropDownListStudentClass.SelectedValue = StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString();
                    uiDropDownListStudentClassRoom.DataSource = db.GetAllClassRoomsByClassID(Convert.ToInt32(uiDropDownListStudentClass.SelectedValue));
                    uiDropDownListStudentClassRoom.DataTextField = "ArName";
                    uiDropDownListStudentClassRoom.DataValueField = "ClassRoomID";
                    uiDropDownListStudentClassRoom.DataBind();
                    if (uiDropDownListStudentClassRoom.Items.Count > 0)
                    {
                        uiDropDownListStudentClassRoom.SelectedValue = ds.Tables[0].Rows[0]["ClassRoomID"].ToString();
                    }
                }
                uiPanelCurrentStudents.Visible = false;
                uiPanelCurrent.Visible = true;

                uiPanelMonthlyReport.Visible = false;
                uiPanelAttendanceReport.Visible = false;
                uiPanelFees.Visible = false;
                uiPanelInstallments.Visible = false;
            }
            else if (e.CommandName == "DeleteStudent")
            {
                int id = Convert.ToInt32(e.CommandArgument.ToString());
                CurrentStudent = id;
                DBLayer db = new DBLayer();
                db.DeleteStudent(id);
                uiPanelCurrentStudents.Visible = true;
                uiPanelCurrent.Visible = false;
                uiPanelPrint.Visible = false;

                uiPanelMonthlyReport.Visible = false;
                uiPanelAttendanceReport.Visible = false;
                uiPanelFees.Visible = false;
                uiPanelInstallments.Visible = false;
                BindData();
            }
            else if (e.CommandName == "EditMonthlyReport")
            {
                int id = Convert.ToInt32(e.CommandArgument.ToString());
                Session["CurrentCheckedStudent"] = id;
                ucMonthlyReport1.BindData();
                uiPanelMonthlyReport.Visible = true;
                uiPanelAttendanceReport.Visible = false;
                uiPanelFees.Visible = false;
                uiPanelInstallments.Visible = false;
            }

            else if (e.CommandName == "EditAttedanceReport")
            {
                int id = Convert.ToInt32(e.CommandArgument.ToString());
                Session["CurrentCheckedStudentForAtt"] = id;
                ucAttendanceReport1.BindData();
                uiPanelAttendanceReport.Visible = true;
                uiPanelMonthlyReport.Visible = false;
                uiPanelFees.Visible = false;
                uiPanelInstallments.Visible = false;
            }

            else if (e.CommandName == "EditFees")
            {
                int id = Convert.ToInt32(e.CommandArgument.ToString());
                Session["CurrentStudentActive"] = id;
                ucFees1.BindData();
                uiPanelAttendanceReport.Visible = false;
                uiPanelMonthlyReport.Visible = false;
                uiPanelFees.Visible = true;
                uiPanelInstallments.Visible = false;
            }

            else if (e.CommandName == "EditInstallments")
            {
                int id = Convert.ToInt32(e.CommandArgument.ToString());
                Session["CurrentStudentToPay"] = id;
                ucInstallment1.BindData();
                uiPanelAttendanceReport.Visible = false;
                uiPanelMonthlyReport.Visible = false;
                uiPanelFees.Visible = false;
                uiPanelInstallments.Visible = true;
            }
        }
 private void BindData()
 {
     DBLayer db = new DBLayer();
     DataSet ds = new DataSet();
     ds = db.GetStudent(CurrentCheckedStudent);
     if (ds.Tables[0].Rows.Count > 0)
     {
         uiGridViewStudentsAbsence.DataSource = db.GetMonthlyAttendanceReportByStudentID(CurrentCheckedStudent);
         uiGridViewStudentsAbsence.DataBind();
         uiLabelStudentName.Text = ds.Tables[0].Rows[0]["ARStudentName"].ToString() + " " + ds.Tables[0].Rows[0]["ArFatherName"].ToString();
         DataSet StudentClassRoom = new DataSet();
         StudentClassRoom = db.GetClassRoom(Convert.ToInt32(ds.Tables[0].Rows[0]["ClassRoomID"].ToString()));
         DataSet StudentClass = new DataSet();
         StudentClass = db.GetClass(Convert.ToInt32(StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString()));
         uiLabelClass.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
     }
     uiPanelCurrentStudents.Visible = false;
     uiPanelCurrent.Visible = true;
 }
 protected void uiGridViewStudents_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "EditReports")
     {
         int id = Convert.ToInt32(e.CommandArgument.ToString());
         CurrentCheckedStudent = id;
         DBLayer db = new DBLayer();
         DataSet ds = new DataSet();
         ds = db.GetStudent(CurrentCheckedStudent);
         if (ds.Tables[0].Rows.Count > 0)
         {
             uiGridViewStudentsAbsence.DataSource = db.GetMonthlyAttendanceReportByStudentID(CurrentCheckedStudent);
             uiGridViewStudentsAbsence.DataBind();
             uiLabelStudentName.Text = ds.Tables[0].Rows[0]["ARStudentName"].ToString() + " " + ds.Tables[0].Rows[0]["ArFatherName"].ToString();
             DataSet StudentClassRoom = new DataSet();
             StudentClassRoom = db.GetClassRoom(Convert.ToInt32(ds.Tables[0].Rows[0]["ClassRoomID"].ToString()));
             DataSet StudentClass = new DataSet();
             StudentClass = db.GetClass(Convert.ToInt32(StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString()));
             uiLabelClass.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
         }
         uiPanelCurrentStudents.Visible = false;
         uiPanelCurrent.Visible = true;
     }
 }
 private void BindData()
 {
     DBLayer db = new DBLayer();
     DataSet ds = new DataSet();
     ds = db.GetStudent(CurrentActiveStudent);
     if (ds.Tables[0].Rows.Count > 0)
     {
         uiGridViewStudentResults.DataSource = db.GetResultByStudentIDAndSchoolYearForAdmin(CurrentActiveStudent, Convert.ToInt32(uiDropDownListSchoolYear.SelectedValue));
         uiGridViewStudentResults.DataBind();
         uiLabelStudentName.Text = ds.Tables[0].Rows[0]["ArStudentName"].ToString() + ds.Tables[0].Rows[0]["ArFatherName"].ToString();
         DataSet StudentClassRoom = new DataSet();
         StudentClassRoom = db.GetClassRoom(Convert.ToInt32(ds.Tables[0].Rows[0]["ClassRoomID"].ToString()));
         DataSet StudentClass = new DataSet();
         StudentClass = db.GetClass(Convert.ToInt32(StudentClassRoom.Tables[0].Rows[0]["ClassID"].ToString()));
         uiLabelClass.Text = StudentClass.Tables[0].Rows[0]["ArName"].ToString();
     }
     uiPanelCurrentStudents.Visible = false;
     uiPanelCurrent.Visible = true;
 }