Exemple #1
0
        private void btnCollect_Click(object sender, EventArgs e)
        {
            DataTable dt = null;

            objHRdb = new HRInfo();
            try
            {
                dt = objHRdb.EmployeeDeductionsDetails(dtpMonth.Value.ToString("MMMyyyy").ToUpper()).Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            gvEmpLoanDetails.Rows.Clear();

            try
            {
                if (dt.Rows.Count > 0)
                {
                    for (int iVar = 0; iVar < dt.Rows.Count; iVar++)
                    {
                        gvEmpLoanDetails.Rows.Add();
                        gvEmpLoanDetails.Rows[iVar].Cells["SLNO"].Value          = (iVar + 1).ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["CompCode"].Value      = dt.Rows[iVar]["ld_Comp_Code"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["BranchCode"].Value    = dt.Rows[iVar]["ld_Bran_Code"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["Ecode"].Value         = dt.Rows[iVar]["ld_eora_code"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["EmpName"].Value       = dt.Rows[iVar]["ld_emp_name"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["Desig"].Value         = dt.Rows[iVar]["ld_desig_name"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["Department"].Value    = dt.Rows[iVar]["ld_dept_name"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["PersonalLoan"].Value  = dt.Rows[iVar]["ld_Pers_Loan"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["ComputerLoan"].Value  = dt.Rows[iVar]["ld_laptop_Loan"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["VehicleLoan"].Value   = dt.Rows[iVar]["ld_veh_loan"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["SalaryAdvance"].Value = dt.Rows[iVar]["ld_sal_Adv"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["Other"].Value         = dt.Rows[iVar]["ld_Other_dedu"].ToString();
                        gvEmpLoanDetails.Rows[iVar].Cells["Total"].Value         = dt.Rows[iVar]["ld_tot_dedu"].ToString();
                    }

                    foreach (DataGridViewRow oItem in gvEmpLoanDetails.Rows)
                    {
                        if (Convert.ToDouble(oItem.Cells["PersonalLoan"].Value.ToString()) == 0)
                        {
                            oItem.Cells["PersonalLoan"].Value = "";
                        }
                        if (Convert.ToDouble(oItem.Cells["ComputerLoan"].Value.ToString()) == 0)
                        {
                            oItem.Cells["ComputerLoan"].Value = "";
                        }
                        if (Convert.ToDouble(oItem.Cells["VehicleLoan"].Value.ToString()) == 0)
                        {
                            oItem.Cells["VehicleLoan"].Value = "";
                        }
                        if (Convert.ToDouble(oItem.Cells["SalaryAdvance"].Value.ToString()) == 0)
                        {
                            oItem.Cells["SalaryAdvance"].Value = "";
                        }
                        if (Convert.ToDouble(oItem.Cells["Other"].Value.ToString()) == 0)
                        {
                            oItem.Cells["Other"].Value = "";
                        }
                        if (Convert.ToDouble(oItem.Cells["Total"].Value.ToString()) == 0)
                        {
                            oItem.Cells["Total"].Value = "";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            calculateTotal();
        }