protected void btnSubmit_Click(object sender, EventArgs e)
    {
        List <ATTEmployeeDeputaion> LSTEmpDeputation = (List <ATTEmployeeDeputaion>)Session["EmpDepReturn"];

        int countErr = 0;

        for (int j = 0; j <= this.grdEmpDepReturn.Rows.Count - 1; j++)
        {
            bool val = true;
            LSTEmpDeputation[j].ReturnDate = ((TextBox)grdEmpDepReturn.Rows[j].FindControl("TextBox1")).Text;

            string leavedate  = LSTEmpDeputation[j].LeaveDate;
            string returndate = LSTEmpDeputation[j].ReturnDate;

            if (returndate.Trim() != "")
            {
                val = (CheckDateIsValid(leavedate, returndate));
            }
            if (!val)
            {
                countErr++;
            }


            LSTEmpDeputation[j].Action = "ER";
        }
        try
        {
            if (countErr == 0)
            {
                List <ATTEmployeeDeputaion> LST = LSTEmpDeputation.FindAll(
                    delegate(ATTEmployeeDeputaion obj)
                {
                    return(obj.ReturnDate != "");
                }
                    );
                if (BLLEmployeeDeputation.SaveEmpForDeputation(LST))
                {
                    this.lblStatusMessage.Text = "**Employee Deputation Return Successfully Save";
                    this.programmaticModalPopup.Show();
                    int    orgid  = int.Parse(Session["Orgid"].ToString());
                    string active = "Y";
                    List <ATTEmployeeDeputaion> LSTEmpDepReturn = BLLEmployeeDeputation.GetEmpForDeputationReturn(orgid, active);
                    this.grdEmpDepReturn.DataSource = LSTEmpDepReturn;
                    this.grdEmpDepReturn.DataBind();
                    return;
                }
            }
            else
            {
                this.lblStatusMessage.Text = countErr.ToString() + ".  data has invalid date<br/>**Leave Date Is Greater Than Return Date";
                this.programmaticModalPopup.Show();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void btnRawanaSave_Click(object sender, EventArgs e)
    {
        List <ATTEmployeeDeputaion> LSTEmpDepLeave = (List <ATTEmployeeDeputaion>)Session["EmpDepNoLeave"];

        if (LSTEmpDepLeave.Count == 0)
        {
            this.lblStatusMessage.Text = "**Sorry! There Is No Data To Save";
            this.programmaticModalPopup.Show();
            return;
        }
        //List<ATTEmployeeDeputaion> LSTEmpDepOther = new List<ATTEmployeeDeputaion>();
        try
        {
            for (int j = 0; j <= this.grdEmpDepRamana.Rows.Count - 1; j++)
            {
                LSTEmpDepLeave[j].LeaveDate = ((TextBox)grdEmpDepRamana.Rows[j].FindControl("TextBox1")).Text;
                bool check = ((CheckBox)grdEmpDepRamana.Rows[j].Cells[14].FindControl("chkBox")).Checked;
                if (check)
                {
                    LSTEmpDepLeave[j].Active = "Y";
                    LSTEmpDepLeave[j].Action = "E";
                }
                else
                {
                    LSTEmpDepLeave[j].Active = "N";
                    LSTEmpDepLeave[j].Action = "E";
                }
            }

            if (BLLEmployeeDeputation.SaveEmpForDeputation(LSTEmpDepLeave))
            {
                this.lblStatusMessage.Text = "**Employee Deputation Leave Successfully Save";
                this.programmaticModalPopup.Show();
                this.ddlDeputaionOrgEdit.SelectedIndex = -1;
                this.txtDecisionDateEdit.Text          = "";
                this.txtResponsibilityEdit.Text        = "";
                this.txtDecision.Text = "";


                Session["EmpDepNoLeave"]   = BLLEmployeeDeputation.GetEmpForDeputation(GetEmployeeFilterDep(), "wld");
                grdEmpDepRamana.DataSource = Session["EmpDepNoLeave"];
                grdEmpDepRamana.DataBind();
                grdEmployee.DataSource = BLLEmployeeDeputation.GetEmpForDeputation(GetEmployeeFilter(), "wod");
                //grdEmpDepRamana.DataSource = Session["EmpDepNoLeave"];
                //grdEmpDepRamana.DataBind();
                return;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.txtDecisionDate.Text == "")
        {
            this.lblStatusMessage.Text = "र्कपया काज निर्णय मिति बर्नुहोस्";
            this.programmaticModalPopup.Show();
            return;
        }
        double empId = double.Parse(Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[0].Text).ToString());

        foreach (GridViewRow row in this.grdEmpDepRamana.Rows)
        {
            if (int.Parse(row.Cells[0].Text) == empId)
            {
                this.lblStatusMessage.Text = "**कर्मचारी काजको लागि सिफारिस भैसकेको छ";
                this.programmaticModalPopup.Show();
                return;
            }
        }
        int    orgId           = int.Parse(Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[3].Text).ToString());
        int    desId           = int.Parse(Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[5].Text).ToString());
        string createdDate     = Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[7].Text).ToString();
        int    postId          = int.Parse(Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[8].Text).ToString());
        string fromDate        = Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[9].Text).ToString();
        string decisionDate    = this.txtDecisionDate.Text;
        int    dep_org_id      = int.Parse(this.ddlDeputationOrganization.SelectedValue);
        int    dicision_ver_by = 0;
        string responsibility  = this.txtResponsibility.Text;
        string active          = "Y";
        string entry_by        = Session["UserName"].ToString();
        List <ATTEmployeeDeputaion> LSTAddDep;

        if (Session["EmpDepNoLeave"] != null)
        {
            LSTAddDep = (List <ATTEmployeeDeputaion>)Session["EmpDepNoLeave"];
        }
        else
        {
            LSTAddDep = new List <ATTEmployeeDeputaion>();
        }
        if (this.ddlDeputationOrganization.SelectedIndex < -1)
        {
            this.lblStatusMessage.Text = "काज कार्यालय छान्नुहोस्";
            this.programmaticModalPopup.Show();
        }
        else if (this.ddlDeputationOrganization.SelectedIndex > 0)
        {
            ATTEmployeeDeputaion objAddDep = new ATTEmployeeDeputaion();
            objAddDep.EmpID              = empId;
            objAddDep.OrgID              = orgId;
            objAddDep.DesID              = desId;
            objAddDep.CreatedDate        = createdDate;
            objAddDep.PostID             = postId;
            objAddDep.FromDate           = fromDate;
            objAddDep.DecisionDate       = decisionDate;
            objAddDep.DepOrgID           = dep_org_id;
            objAddDep.DecisionVerifiedBy = dicision_ver_by;
            objAddDep.Responsibilities   = responsibility;
            objAddDep.Active             = active;
            objAddDep.EntryBy            = entry_by;
            objAddDep.Action             = "A";
            objAddDep.LeaveDate          = "";
            objAddDep.LeaveVerifiedBy    = 0;
            LSTAddDep.Add(objAddDep);

            //Session["DeputaionWOLeave"] = LSTAddDep;
            if (BLLEmployeeDeputation.SaveEmpForDeputation(LSTAddDep))
            {
                this.lblStatusMessage.Text = "Employee Deputation Saved Successfully";
                this.programmaticModalPopup.Show();

                Session["EmpDepNoLeave"]   = BLLEmployeeDeputation.GetEmpForDeputation(GetEmployeeFilterDep(), "wld");
                grdEmpDepRamana.DataSource = Session["EmpDepNoLeave"];
                grdEmpDepRamana.DataBind();
                //grdEmployee.DataSource = BLLEmployeeDeputation.GetEmpForDeputation(GetEmployeeFilter(), "wod");
                //this.grdEmployee.DataBind();
                this.ddlDeputationOrganization.SelectedIndex = -1;
                this.txtDecisionDate.Text   = "";
                this.txtResponsibility.Text = "";
                this.txtVerifiedBy.Text     = "";
                return;
            }
        }
    }