//protected void ddlUnit_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    if (ddlUnit.SelectedIndex < 1)
    //    {
    //        ddlSection.DataSource = null;
    //        ddlSection.DataBind();
    //    }
    //    else
    //    {
    //        int org_id = int.Parse(this.ddlOrganization.SelectedValue.ToString());
    //        int unit_id = int.Parse(this.ddlUnit.SelectedValue.ToString());
    //        List<ATTOrganizationSection> LSTOrgSec = BLLOrganizationSection.GetOrgSection(org_id, unit_id);
    //        LSTOrgSec.Insert(0, new ATTOrganizationSection(0, 0, 0, "छान्नुहोस्", "", ""));
    //        ddlSection.DataSource = LSTOrgSec;
    //        ddlSection.DataValueField = "SectionID";
    //        ddlSection.DataTextField = "SectionName";
    //        ddlSection.DataBind();
    //    }
    //}
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        List <ATTEmployeeDeputaion> LSTEmp = new List <ATTEmployeeDeputaion>();

        if (this.ddlOrganization.SelectedIndex < 1)
        {
            this.lblStatusMessage.Text = "Select An Organization";
            this.programmaticModalPopup.Show();
        }
        else
        {
            try
            {
                LSTEmp = BLLEmployeeDeputation.GetEmpForDeputation(GetEmployeeFilter(), "wod");
                if (LSTEmp.Count == 0)
                {
                    lblSearch.Text = "No records found";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        grdEmployee.DataSource = LSTEmp;
        this.grdEmployee.DataBind();
        this.grdEmployee.SelectedIndex = -1;
        Session["EmpDeputation"]       = LSTEmp;
    }
    private void LoadEmpDeputation()
    {
        List <ATTEmployeeDeputaion> LSTEmpDeputation = BLLEmployeeDeputation.GetEmpForDeputation(GetEmployeeFilterDep(), "wld");

        Session["EmpDepNoLeave"]        = LSTEmpDeputation;
        this.grdEmpDepRamana.DataSource = LSTEmpDeputation;
        this.grdEmpDepRamana.DataBind();
    }
    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;
            }
        }
    }