public static void BindGrvEmpExclaim(GridView gvw, string ExClaim_No) { EmpExclaimDetailDAL _dalEmpExclaimDetailDAL = null; Hashtable _htParameters = null; try { _dalEmpExclaimDetailDAL = new EmpExclaimDetailDAL(); _htParameters = new Hashtable(); _htParameters["p_ExClaim_No"] = ExClaim_No; DataTable dt = new DataTable(); dt = _dalEmpExclaimDetailDAL.GetRows(_htParameters); gvw.DataSource = dt; gvw.DataBind(); if (dt.Rows.Count > 0) { decimal total = dt.AsEnumerable().Sum(row => row.Field <decimal>("Total_Cost")); gvw.FooterRow.Cells[14].Text = "Total"; gvw.FooterRow.Cells[14].HorizontalAlign = HorizontalAlign.Right; gvw.FooterRow.Cells[14].Font.Bold = true; gvw.FooterRow.Cells[15].HorizontalAlign = HorizontalAlign.Right; gvw.FooterRow.Cells[15].Font.Bold = true; gvw.FooterRow.Cells[15].Text = total.ToString("N2"); } } catch (Exception ex) { throw ex; } }
private void BindGridClaim() { EmpExclaimDetailDAL _dalEmpExclaimDetailDAL = null; Hashtable _htParameters = null; try { _dalEmpExclaimDetailDAL = new EmpExclaimDetailDAL(); _htParameters = new Hashtable(); if (txtExClaim_No.Text != "") { //Shared.BindGrvEmpExclaim(grvExpenseClaimDetail, txtSPD_No.Text); _htParameters["p_ExClaim_No"] = txtExClaim_No.Text; } else { _htParameters["p_SPD_No"] = txtSPD_No.Text; //Shared.BindGrvEmpExclaim(grvExpenseClaimDetail, txtExClaim_No.Text); } DataTable dt = new DataTable(); dt = _dalEmpExclaimDetailDAL.GetRows(_htParameters); grvExpenseClaimDetail.DataSource = dt; grvExpenseClaimDetail.DataBind(); if (dt.Rows.Count > 0) { decimal total = dt.AsEnumerable().Sum(row => row.Field <decimal>("Total_Cost")); grvExpenseClaimDetail.FooterRow.Cells[5].Text = "Total"; grvExpenseClaimDetail.FooterRow.Cells[5].HorizontalAlign = HorizontalAlign.Right; grvExpenseClaimDetail.FooterRow.Cells[5].Font.Bold = true; grvExpenseClaimDetail.FooterRow.Cells[6].HorizontalAlign = HorizontalAlign.Right; grvExpenseClaimDetail.FooterRow.Cells[6].Font.Bold = true; grvExpenseClaimDetail.FooterRow.Cells[6].Text = total.ToString("N2"); } } catch (Exception ex) { Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null); } }