protected void DDL_EmoloyeeName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                ViewState["UserCode"] = DDL_EmoloyeeName.SelectedValue;
                database db = new database();

                PayGroupID = db.getDb_Value("select PayGrpID from tblEmployee where UserCode='" + ViewState["UserCode"] + "'");

                if (PayGroupID > 0)
                {
                    BL_SalarySettings  objBL  = new BL_SalarySettings();
                    EWA_SalarySettings objEWA = new EWA_SalarySettings();
                    objEWA.Action   = "GetPayDetails";
                    objEWA.OrgId    = Convert.ToInt32(ViewState["OrgID"]);
                    objEWA.PayGrpID = Convert.ToInt32(PayGroupID);

                    //int.Parse(PayGroupID).ToString();//Convert.ToInt32(ViewState["PayGrpID"]);
                    objEWA.UserCode    = DDL_EmoloyeeName.SelectedValue;
                    objEWA.SalaryMonth = Convert.ToDateTime(txtMonth.Text).Month.ToString();
                    objEWA.PostedMonth = Convert.ToDateTime(txtMonth.Text).Month.ToString();
                    DataSet ds = objBL.GetSalarySettings(objEWA);


                    if (ds.Tables[0].Rows.Count > 0 || ds.Tables[1].Rows.Count > 0 || ds.Tables[2].Rows.Count > 0 || ds.Tables[3].Rows.Count > 0)
                    {
                        Get_OrganizationDetails(Convert.ToInt32(ViewState["OrgID"]));
                        lblName.Text        = ds.Tables[4].Rows[0][1].ToString();
                        lblDesignation.Text = DDL_Designation.SelectedItem.ToString();

                        lblName1.Text        = ds.Tables[4].Rows[0][1].ToString();
                        lblDesignation1.Text = DDL_Designation.SelectedItem.ToString();
                        double    GrossSalary = 0, Deductions = 0, NetSalary = 0, leaveDeductions = 0;
                        DataTable dt = new DataTable();
                        dt.Columns.Add("Description");
                        dt.Columns.Add("Earnings");
                        dt.Columns.Add("Deductions");
                        DataRow dr;

                        if (ds.Tables[3].Rows.Count > 0)
                        {
                            dr    = dt.NewRow();
                            dr[0] = "Basic Salary";
                            dr[1] = ds.Tables[3].Rows[0][0].ToString();
                            dr[2] = "";
                            dt.Rows.Add(dr);
                            txtBasicSalary = Convert.ToDouble(ds.Tables[3].Rows[0][0].ToString());
                            GrossSalary    = GrossSalary + Convert.ToDouble(ds.Tables[3].Rows[0][0].ToString());
                        }

                        int i = 0;
                        while (ds.Tables[0].Rows.Count > i)
                        {
                            dr          = dt.NewRow();
                            dr[0]       = ds.Tables[0].Rows[i][0].ToString();
                            dr[1]       = ds.Tables[0].Rows[i][1].ToString();
                            dr[2]       = "";
                            GrossSalary = GrossSalary + Convert.ToDouble(ds.Tables[0].Rows[i][1].ToString());
                            i++;
                            dt.Rows.Add(dr);
                        }

                        i = 0;
                        while (ds.Tables[1].Rows.Count > i)
                        {
                            dr         = dt.NewRow();
                            dr[0]      = ds.Tables[1].Rows[i][0].ToString();
                            dr[1]      = "";
                            dr[2]      = ds.Tables[1].Rows[i][1].ToString();
                            Deductions = Deductions + Convert.ToDouble(ds.Tables[1].Rows[i][1].ToString());
                            i++;
                            dt.Rows.Add(dr);
                        }

                        int    days     = DateTime.DaysInMonth(Convert.ToDateTime(txtMonth.Text).Year, Convert.ToDateTime(txtMonth.Text).Month);
                        double leaveday = 0;

                        if (ds.Tables[2].Rows.Count > 0 && ds.Tables[2].Rows[0][0].ToString() != "")
                        {
                            leaveday        = Convert.ToDouble(ds.Tables[2].Rows[0][0].ToString());
                            leaveDeductions = Convert.ToDouble((String.Format("{0:0.00}", (GrossSalary / days) * leaveday)).ToString());


                            dr    = dt.NewRow();
                            dr[0] = "Leave Deductions";
                            dr[1] = "";
                            dr[2] = leaveDeductions;
                            dt.Rows.Add(dr);
                            Deductions = Deductions + leaveDeductions;
                        }

                        lblWorkday.Text = (days - leaveday).ToString();
                        lblAbsence.Text = leaveday.ToString();

                        lblWorkday1.Text = (days - leaveday).ToString();
                        lblAbsence1.Text = leaveday.ToString();

                        dr    = dt.NewRow();
                        dr[0] = "Total";
                        dr[1] = GrossSalary;
                        dr[2] = Deductions;
                        dt.Rows.Add(dr);

                        NetSalary = GrossSalary - Deductions;

                        dr    = dt.NewRow();
                        dr[0] = "";
                        dr[1] = "Net Salary";
                        dr[2] = NetSalary;
                        dt.Rows.Add(dr);

                        GridView1.DataSource = dt;
                        GridView1.DataBind();

                        GridView2.DataSource = dt;
                        GridView2.DataBind();

                        i = 0;
                        while (GridView1.Rows.Count > i)
                        {
                            GridView1.Rows[i].Cells[1].HorizontalAlign = HorizontalAlign.Center;
                            GridView1.Rows[i].Cells[2].HorizontalAlign = HorizontalAlign.Center;

                            i++;
                        }

                        GridView1.Rows[GridView1.Rows.Count - 1].Cells[0].BorderStyle = BorderStyle.None;
                        GridView1.Rows[GridView1.Rows.Count - 1].Cells[1].Font.Bold   = true;
                        GridView1.Rows[GridView1.Rows.Count - 1].Cells[2].Font.Bold   = true;
                        GridView1.Rows[GridView1.Rows.Count - 1].Cells[1].ForeColor   = System.Drawing.Color.DodgerBlue;

                        GridView1.Rows[GridView1.Rows.Count - 2].Cells[0].Font.Bold       = true;
                        GridView1.Rows[GridView1.Rows.Count - 2].Cells[1].Font.Bold       = true;
                        GridView1.Rows[GridView1.Rows.Count - 2].Cells[2].Font.Bold       = true;
                        GridView1.Rows[GridView1.Rows.Count - 2].Cells[0].HorizontalAlign = HorizontalAlign.Center;

                        lblGross.Text = GrossSalary.ToString();
                        lblNet.Text   = NetSalary.ToString();

                        txtGrossSalary = GrossSalary;
                        txtNetSalary   = NetSalary;
                        txtDeductions  = Deductions;


                        lblGross1.Text = GrossSalary.ToString();
                        lblNet1.Text   = NetSalary.ToString();



                        if (ds.Tables[4].Rows.Count > 0)
                        {
                            lblPaymentDate.Text   = DateTime.Now.Date.ToShortDateString();
                            lblBankName.Text      = ds.Tables[4].Rows[0][0].ToString();
                            lblHolderName.Text    = ds.Tables[4].Rows[0][1].ToString();
                            lblAccountNumber.Text = ds.Tables[4].Rows[0][2].ToString();
                            lblBankBranch.Text    = ds.Tables[4].Rows[0][3].ToString();

                            lblPaymentDate1.Text   = DateTime.Now.Date.ToShortDateString();
                            lblBankName1.Text      = ds.Tables[4].Rows[0][0].ToString();
                            lblHolderName1.Text    = ds.Tables[4].Rows[0][1].ToString();
                            lblAccountNumber1.Text = ds.Tables[4].Rows[0][2].ToString();
                            lblBankBranch1.Text    = ds.Tables[4].Rows[0][3].ToString();
                        }


                        Panel2.Visible             = true;
                        btnPostSalary.Visible      = true;
                        btnPrintSalarySlip.Visible = true;
                    }
                    else
                    {
                        GeneralErr("Record Not Found...!");
                    }
                }
                else
                {
                    msgBox.ShowMessage("Please Apply Pay Scale...!", "Information", UserControls.MessageBox.MessageStyle.Information);
                }
            }
            catch (Exception exp)
            {
                GeneralErr(exp.Message.ToString());
            }
        }
        protected void btnShow_Click(object sender, EventArgs e)
        {
            try
            {
                ViewState["UserCode"] = Session["UserCode"].ToString();

                BL_SalarySettings  objBL  = new BL_SalarySettings();
                EWA_SalarySettings objEWA = new EWA_SalarySettings();
                objEWA.Action      = "StaffGetSalary_Details";
                objEWA.OrgId       = Convert.ToInt32(ViewState["OrgID"]);
                objEWA.PayGrpID    = 0;
                objEWA.UserCode    = Session["UserCode"].ToString();
                objEWA.SalaryMonth = Convert.ToDateTime(txtMonth.Text).Month.ToString();
                objEWA.PostedMonth = txtMonth.Text;
                DataSet ds = objBL.GetSalarySettings(objEWA);

                if (ds.Tables[0].Rows.Count > 0 && ds.Tables[1].Rows.Count > 0 && ds.Tables[2].Rows.Count > 0 && ds.Tables[3].Rows.Count > 0)
                {
                    lbl_CollegeName.Text    = ds.Tables[3].Rows[0]["OrgName"].ToString();
                    lbl_CollegeAddress.Text = ds.Tables[3].Rows[0]["Address"].ToString();
                    lbl_Number.Text         = ds.Tables[3].Rows[0]["PhoneNo"].ToString();
                    lbl_website.Text        = ds.Tables[3].Rows[0]["Website"].ToString();

                    lbl_CollegeName1.Text    = lbl_CollegeName.Text;
                    lbl_CollegeAddress1.Text = ds.Tables[3].Rows[0]["Address"].ToString();
                    lbl_Number1.Text         = ds.Tables[3].Rows[0]["PhoneNo"].ToString();
                    lbl_website1.Text        = ds.Tables[3].Rows[0]["Website"].ToString();

                    lblmonthyear.Text   = Convert.ToDateTime(txtMonth.Text).ToString("MMMM") + " " + Convert.ToDateTime(txtMonth.Text).Year.ToString();
                    lblName.Text        = ds.Tables[0].Rows[0]["EmployeeName"].ToString();
                    lblDesignation.Text = ds.Tables[0].Rows[0]["Designation"].ToString();

                    lblName1.Text        = lblName.Text;
                    lblmonthyear1.Text   = lblmonthyear.Text;
                    lblDesignation1.Text = lblDesignation.Text;

                    lblGross.Text  = ds.Tables[0].Rows[0]["GorssSalary"].ToString();
                    lblNet.Text    = ds.Tables[0].Rows[0]["NetSalary"].ToString();
                    lblGross1.Text = lblGross.Text;
                    lblNet1.Text   = lblNet.Text;


                    lblPaymentDate.Text   = Convert.ToDateTime(ds.Tables[0].Rows[0]["TransDate"].ToString()).ToString("dd-MM-yyyy");
                    lblBankName.Text      = ds.Tables[0].Rows[0]["BankName"].ToString();
                    lblHolderName.Text    = lblName.Text;
                    lblAccountNumber.Text = ds.Tables[0].Rows[0]["BankAccountNumber"].ToString();
                    lblBankBranch.Text    = ds.Tables[0].Rows[0]["BankBranchName"].ToString();

                    lblPaymentDate1.Text   = Convert.ToDateTime(ds.Tables[0].Rows[0]["TransDate"].ToString()).ToString("dd-MM-yyyy");
                    lblBankName1.Text      = ds.Tables[0].Rows[0]["BankName"].ToString();
                    lblHolderName1.Text    = lblName.Text;
                    lblAccountNumber1.Text = ds.Tables[0].Rows[0]["BankAccountNumber"].ToString();
                    lblBankBranch1.Text    = ds.Tables[0].Rows[0]["BankBranchName"].ToString();


                    int    days     = DateTime.DaysInMonth(Convert.ToDateTime(txtMonth.Text).Year, Convert.ToDateTime(txtMonth.Text).Month);
                    double leaveday = 0;
                    lblWorkday.Text = days.ToString();
                    lblAbsence.Text = "0";

                    lblWorkday1.Text = days.ToString();
                    lblAbsence1.Text = "0";
                    if (ds.Tables[2].Rows.Count > 0 && ds.Tables[2].Rows[0][0].ToString() != "")
                    {
                        leaveday         = Convert.ToDouble(ds.Tables[2].Rows[0][0].ToString());
                        lblWorkday.Text  = String.Format("{0:0.00}", (days - leaveday)).ToString();
                        lblAbsence.Text  = leaveday.ToString();
                        lblWorkday1.Text = String.Format("{0:0.00}", (days - leaveday)).ToString();
                        lblAbsence1.Text = leaveday.ToString();
                    }



                    DataTable dt = new DataTable();
                    dt.Columns.Add("Description");
                    dt.Columns.Add("Earnings");
                    dt.Columns.Add("Deductions");
                    DataRow dr;


                    int i = 0;
                    while (ds.Tables[1].Rows.Count > i)
                    {
                        if (ds.Tables[1].Rows[i]["ContentAction"].ToString() == "Earning")
                        {
                            dr    = dt.NewRow();
                            dr[0] = ds.Tables[1].Rows[i]["CategoryName"].ToString();
                            dr[1] = ds.Tables[1].Rows[i]["ContentValue"].ToString();
                            dr[2] = "";
                            dt.Rows.Add(dr);
                        }
                        else
                        {
                            dr    = dt.NewRow();
                            dr[0] = ds.Tables[1].Rows[i]["CategoryName"].ToString();
                            dr[1] = "";
                            dr[2] = ds.Tables[1].Rows[i]["ContentValue"].ToString();
                            dt.Rows.Add(dr);
                        }

                        i++;
                    }



                    dr    = dt.NewRow();
                    dr[0] = "Total";
                    dr[1] = lblGross.Text;
                    dr[2] = ds.Tables[0].Rows[0]["TotalDeduction"].ToString();
                    dt.Rows.Add(dr);


                    dr    = dt.NewRow();
                    dr[0] = "";
                    dr[1] = "Net Salary";
                    dr[2] = lblNet.Text;
                    dt.Rows.Add(dr);

                    GridView1.DataSource = dt;
                    GridView1.DataBind();

                    GridView2.DataSource = dt;
                    GridView2.DataBind();

                    i = 0;
                    while (GridView1.Rows.Count > i)
                    {
                        GridView1.Rows[i].Cells[1].HorizontalAlign = HorizontalAlign.Center;
                        GridView1.Rows[i].Cells[2].HorizontalAlign = HorizontalAlign.Center;

                        i++;
                    }

                    GridView1.Rows[GridView1.Rows.Count - 1].Cells[0].BorderStyle = BorderStyle.None;
                    GridView1.Rows[GridView1.Rows.Count - 1].Cells[1].Font.Bold   = true;
                    GridView1.Rows[GridView1.Rows.Count - 1].Cells[2].Font.Bold   = true;
                    GridView1.Rows[GridView1.Rows.Count - 1].Cells[1].ForeColor   = System.Drawing.Color.DeepSkyBlue;
                    GridView1.Rows[GridView1.Rows.Count - 1].Cells[2].ForeColor   = System.Drawing.Color.DeepSkyBlue;


                    Panel2.Visible             = true;
                    btnPrintSalarySlip.Visible = true;
                }
                else
                {
                    Panel2.Visible             = false;
                    btnPrintSalarySlip.Visible = false;
                    msgBox.ShowMessage("Salary not posted yet...!", "Information", UserControls.MessageBox.MessageStyle.Information);
                }
            }
            catch (Exception exp)
            {
                GeneralErr(exp.Message.ToString());
            }
        }