private void FillEmpDetails(string sMonth) { objSQLdb = new SQLDB(); objHRdb = new HRInfo(); DataTable dt = new DataTable(); gvEmpLopDetails.Rows.Clear(); char cStatus = 'P'; string strCommand = ""; string CompCode = cbCompany.SelectedValue.ToString(); if (cbDept.SelectedIndex > 0) { string BranCode = cbBranches.SelectedValue.ToString(); try { strCommand = "SELECT * FROM HR_EMP_LOPS WHERE HEL_COMPANY_CODE='" + CompCode + "' AND HEL_BRANCH_CODE='" + BranCode + "' AND HEL_DEPT_CODE=" + Convert.ToInt32(cbDept.SelectedValue) + " AND HEL_DOC_MONTH='" + Convert.ToDateTime(dtpMonth.Value).ToString("MMM/yyyy") + "'"; //"' AND HEL_APPR_STATUS='p' "; dt = objSQLdb.ExecuteDataSet(strCommand).Tables[0]; if (dt.Rows.Count > 0) { strCommand = ""; dt = null; dt = objHRdb.EmployeeLOPDetails_Get(CompCode, BranCode, Convert.ToInt32(cbDept.SelectedValue), sMonth).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { flagUpdate = true; dtpFrmDate.Value = Convert.ToDateTime(dt.Rows[0]["FromDate"].ToString()); dtpToDate.Value = Convert.ToDateTime(dt.Rows[0]["ToDate"].ToString()); gvEmpLopDetails.Rows.Add(); gvEmpLopDetails.Rows[i].Cells["SLNO"].Value = (i + 1).ToString(); gvEmpLopDetails.Rows[i].Cells["ApplNo"].Value = dt.Rows[i]["ApplNo"].ToString(); gvEmpLopDetails.Rows[i].Cells["TotLeaves"].Value = dt.Rows[i]["EmpLeaves"].ToString(); gvEmpLopDetails.Rows[i].Cells["Ecode"].Value = dt.Rows[i]["Ecode"].ToString(); gvEmpLopDetails.Rows[i].Cells["EmpName"].Value = dt.Rows[i]["EmpName"].ToString(); gvEmpLopDetails.Rows[i].Cells["Desig"].Value = dt.Rows[i]["EmpDesig"].ToString(); gvEmpLopDetails.Rows[i].Cells["TotDays"].Value = dt.Rows[i]["WorkingDays"].ToString(); gvEmpLopDetails.Rows[i].Cells["Lops"].Value = dt.Rows[i]["EmpLops"].ToString(); gvEmpLopDetails.Rows[i].Cells["EmpCLs"].Value = dt.Rows[i]["EmpCLs"].ToString(); gvEmpLopDetails.Rows[i].Cells["EmpSLs"].Value = dt.Rows[i]["EmpSLs"].ToString(); gvEmpLopDetails.Rows[i].Cells["EmpELs"].Value = dt.Rows[i]["EmpELs"].ToString(); gvEmpLopDetails.Rows[i].Cells["WorkedDays"].Value = dt.Rows[i]["WorkedDays"].ToString(); double Workingdays = Convert.ToDouble(dt.Rows[i]["WorkingDays"] + ""); double Lops = Convert.ToDouble(dt.Rows[i]["EmpLops"].ToString()); double paidDays = Workingdays - Lops; gvEmpLopDetails.Rows[i].Cells["PaidDays"].Value = Convert.ToString(paidDays); } } else { strCommand = ""; dt = null; strCommand = "SELECT ECODE,HRIS_EMP_NAME,HAMH_APPL_NUMBER,desig_desc " + " FROM EORA_MASTER " + " INNER JOIN HR_APPL_MASTER_HEAD ON HAMH_EORA_CODE=ECODE " + " INNER JOIN DESIG_MAS ON desig_code=DESG_ID " + " WHERE DEPT_ID=" + Convert.ToInt32(cbDept.SelectedValue) + " AND company_code='" + cbCompany.SelectedValue.ToString() + "' AND BRANCH_CODE='" + cbBranches.SelectedValue.ToString() + "'"; dt = objSQLdb.ExecuteDataSet(strCommand).Tables[0]; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { gvEmpLopDetails.Rows.Add(); gvEmpLopDetails.Rows[i].Cells["SLNO"].Value = (i + 1).ToString(); gvEmpLopDetails.Rows[i].Cells["ApplNo"].Value = dt.Rows[i]["HAMH_APPL_NUMBER"].ToString(); gvEmpLopDetails.Rows[i].Cells["TotLeaves"].Value = 0; gvEmpLopDetails.Rows[i].Cells["Ecode"].Value = dt.Rows[i]["ECODE"].ToString(); gvEmpLopDetails.Rows[i].Cells["EmpName"].Value = dt.Rows[i]["HRIS_EMP_NAME"].ToString(); gvEmpLopDetails.Rows[i].Cells["Desig"].Value = dt.Rows[i]["desig_desc"].ToString(); gvEmpLopDetails.Rows[i].Cells["TotDays"].Value = txtTotDays.Text; } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { objSQLdb = null; dt = null; } } }