protected void uiDropDownListClasses_SelectedIndexChanged(object sender, EventArgs e)
 {
     DBLayer db = new DBLayer();
     uiDropDownListClassRooms.DataSource = db.GetAllClassRoomsByClassID(Convert.ToInt32(uiDropDownListClasses.SelectedValue));
     uiDropDownListClassRooms.DataTextField = "ArName";
     uiDropDownListClassRooms.DataValueField = "ClassRoomID";
     uiDropDownListClassRooms.DataBind();
 }
        private void LoadDDLs()
        {
            DBLayer db = new DBLayer();
            uiDropDownListClasses.DataSource = db.GetAllClass();
            uiDropDownListClasses.DataTextField = "ArName";
            uiDropDownListClasses.DataValueField = "ClassID";
            uiDropDownListClasses.DataBind();
            uiDropDownListClasses.SelectedIndex = 0;

            uiDropDownListClassRooms.DataSource = db.GetAllClassRoomsByClassID(Convert.ToInt32(uiDropDownListClasses.SelectedValue));
            uiDropDownListClassRooms.DataTextField = "ArName";
            uiDropDownListClassRooms.DataValueField = "ClassRoomID";
            uiDropDownListClassRooms.DataBind();
        }
        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 == "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;
            }
        }