public void DisplayAllVouchers(string Ledger, int MonthVal, int Balance) { try { DS = obj_Ledger.LedgerEntry(Ledger, MonthVal, Balance, out StrError); if (DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0) { GrdLedgerVoucher.DataSource = DS.Tables[0]; ViewState["LedgerVoucher"] = DS.Tables[0]; GrdLedgerVoucher.DataBind(); Label3.Text = "Ledger Vouchers"; } else { GrdLedgerVoucher.DataSource = null; GrdLedgerVoucher.DataBind(); SetInitialRowLedgerVoucher(); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void SetInitialRowLedgerVoucher() { try { DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add(new DataColumn("#", typeof(int))); dt.Columns.Add(new DataColumn("VchDate", typeof(string))); dt.Columns.Add(new DataColumn("Particulars", typeof(string))); dt.Columns.Add(new DataColumn("VoucherType", typeof(string))); dt.Columns.Add(new DataColumn("VoucherID", typeof(string))); dt.Columns.Add(new DataColumn("Debit", typeof(string))); dt.Columns.Add(new DataColumn("Credit", typeof(string))); dr = dt.NewRow(); dr["#"] = 0; dr["VchDate"] = ""; dr["Particulars"] = ""; dr["VoucherType"] = ""; dr["VoucherID"] = ""; dr["Debit"] = ""; dr["Credit"] = ""; dt.Rows.Add(dr); ViewState["CurrentTable"] = dt; GrdLedgerVoucher.DataSource = dt; GrdLedgerVoucher.DataBind(); dt = null; dr = null; } catch (Exception ex) { throw new Exception(ex.Message); } }