private void btnDisplayPromotionDetails_Click(object sender, EventArgs e) { objHRdb = new HRInfo(); DataTable dt = new DataTable(); gvEmpPromotionDetails.Rows.Clear(); if (CheckData() == true) { try { if (cbFilterType.SelectedIndex == 1) { string CompCode = cbCompany.SelectedValue.ToString(); string BranCode = cbBranches.SelectedValue.ToString(); DateTime FromDate = dtpFrmDate.Value; DateTime ToDate = dtpToDate.Value; dt = objHRdb.GetPromotionDetlByDate(CompCode, BranCode, FromDate, ToDate).Tables[0]; } else { dt = objHRdb.GetPromotionDetlByEcode(Convert.ToInt32(txtEcodeSearch.Text)).Tables[0]; } if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { gvEmpPromotionDetails.Rows.Add(); gvEmpPromotionDetails.Rows[i].Cells["SLNO"].Value = (i + 1).ToString(); gvEmpPromotionDetails.Rows[i].Cells["PromotionCode"].Value = dt.Rows[i]["PromotionCode"].ToString(); gvEmpPromotionDetails.Rows[i].Cells["ApplNo"].Value = dt.Rows[i]["ApplNo"].ToString(); gvEmpPromotionDetails.Rows[i].Cells["Ecode"].Value = dt.Rows[i]["Ecode"].ToString(); gvEmpPromotionDetails.Rows[i].Cells["EmpName"].Value = dt.Rows[i]["EmpName"].ToString(); gvEmpPromotionDetails.Rows[i].Cells["DeptName"].Value = dt.Rows[i]["DeptName"].ToString(); gvEmpPromotionDetails.Rows[i].Cells["LetterType"].Value = dt.Rows[i]["PromotionName"].ToString(); gvEmpPromotionDetails.Rows[i].Cells["LetterRefNo"].Value = dt.Rows[i]["LetterRefNo"].ToString(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { objSQLdb = null; dt = null; } } }