using Swift.web.Library; using System; using System.Data; using System.Text; namespace Swift.web.AccountReport.LiquidityReport { public partial class LiquidityStatementResult : System.Web.UI.Page { private SwiftLibrary sl = new SwiftLibrary(); protected void Page_Load(object sender, EventArgs e) { sl.CheckSession(); if (!IsPostBack) { PopulateGrid(); } startDate.Text = DateTime.Now.ToString("d"); toDate.Text = DateTime.Now.ToString("d"); } private void PopulateGrid() { string stDate = startDate.Text; string endDate = toDate.Text; string company_id = GetStatic.ReadQueryString("company_id", ""); string acNum = GetStatic.ReadQueryString("ac_num", ""); string query = "select acct_name from ac_master WITH (NOLOCK) where acct_num=" + sl.FilterString(acNum) + ""; string sql = "Exec spa_branchstatement @flag=a" + ",@startDate=" + sl.FilterString(stDate) + ",@endDate=" + sl.FilterString(endDate) + ",@acnum=" + sl.FilterString(acNum) + ",@company_id=" + sl.FilterString(company_id) + ""; DataTable acdt = sl.ExecuteDataTable(query); accNum.Text = acNum; if (acdt != null && acdt.Rows.Count > 0) { acct_name.Text = acdt.Rows[0]["acct_name"].ToString(); } StringBuilder sb = new StringBuilder(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); DataTable dt = sl.ExecuteDataTable(sql); if (dt.Rows.Count == 0 || dt.Rows == null) { sb.AppendLine("
Tran DateDescription
Dr Amount 
Cr Amount
Balance
No Data to display
"); tblRpt.InnerHtml = sb.ToString(); return; } int count = 0; int i = 0; int balance = 0; int drTotal = 0; int crTotal = 0; int openBalance = 0; int cntDR = 0; int cntCR = 0; while (i != dt.Rows.Count) { drTotal += Convert.ToInt32(dt.Rows[i]["DRTotal"]); crTotal += Convert.ToInt32(dt.Rows[i]["cRTotal"]); balance += Convert.ToInt32(dt.Rows[i]["end_clr_balance"]) + Convert.ToInt32(dt.Rows[i]["cRTotal"]) - Convert.ToInt32(dt.Rows[i]["DRTotal"]); if (count == 1) openBalance = Convert.ToInt32(dt.Rows[i]["end_clr_balance"]); if (Convert.ToInt32(dt.Rows[i]["DRTotal"]) > 0) cntDR = cntDR + 1; if (Convert.ToInt32(dt.Rows[i]["cRTotal"]) > 0) cntCR = cntCR + 1; count++; sb.AppendLine(""); if (dt.Rows[i]["TRNDate"].ToString() != "1900.01.01") { sb.AppendLine("" + dt.Rows[i]["TRNDate"] + ""); } sb.AppendLine(" " + dt.Rows[i]["tran_rmks"] + ""); sb.AppendLine(""); sb.AppendLine("
"); sb.AppendLine(""); if (Convert.ToInt32(dt.Rows[i]["DRTotal"]) != 0) sb.AppendLine(dt.Rows[i]["DRTotal"] + "
"); else sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine("
"); sb.AppendLine(""); if (Convert.ToInt32(dt.Rows[i]["cRTotal"]) != 0) sb.AppendLine(dt.Rows[i]["cRTotal"] + "
"); else sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine("
" + balance + "
"); sb.AppendLine(""); if (balance < 0) sb.AppendLine("DR"); else if (balance > 0) sb.AppendLine("CR"); sb.AppendLine(""); sb.AppendLine(""); i++; } sb.AppendLine(""); sb.AppendLine("
"); sb.AppendLine(""); sb.AppendLine(" "); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(" "); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(" "); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine("
Opening Balance:
  
" + openBalance + "
DR:
<%=cntDR%> 
<%=ShowDecimal(DRTotal)%>
CR:
<%=cntCR%> 
<%=ShowDecimal(cRTotal)%>
Closing Balance:
 "); if (balance < 0) sb.AppendLine("DR"); else if (balance > 0) sb.AppendLine("CR"); sb.AppendLine("
"); sb.AppendLine("" + balance + "
"); sb.AppendLine(""); sb.AppendLine(" "); tblRpt.InnerHtml = sb.ToString(); } } }