using Swift.DAL.AccountReportOld;
using Swift.web.Library;
using System;
using System.Data;
using System.Web;
namespace Swift.web.AccountReportOld.AccountStatementOld
{
public partial class StatementResultDollorOld : System.Web.UI.Page
{
private SwiftLibrary _sl = new SwiftLibrary();
private AccountStatementOldDAO st = new AccountStatementOldDAO();
protected void Page_Load(object sender, EventArgs e)
{
_sl.CheckSession();
if (!IsPostBack)
{
//startDate.ReadOnly = true;
//endDate.ReadOnly = true;
startDate.Text = GetStatic.ReadQueryString("startDate", "");
endDate.Text = GetStatic.ReadQueryString("endDate", "");
acNumber.Text = GetStatic.ReadQueryString("acNum", "");
acName.Text = GetStatic.ReadQueryString("acName", "");
GenerateReport();
}
}
private void GenerateReport()
{
var dt = st.GetStatementResultDollor(acNumber.Text, startDate.Text, endDate.Text);
if (dt == null || dt.Rows.Count == 0)
{
return;
}
var sb = new System.Text.StringBuilder("");
sb.AppendLine("
");
sb.AppendLine("");
sb.AppendLine("Tran Date | ");
sb.AppendLine("Description | ");
sb.AppendLine("Dr Amount | ");
sb.AppendLine("Cr Amount | ");
sb.AppendLine("Balance | ");
sb.AppendLine("
");
double DRTotal = 0, cRTotal = 0, BAlance = 0, OpenBalnce = 0;
int cntDR = 0, cntCR = 0, sn = 0;
foreach (DataRow item in dt.Rows)
{
sb.AppendLine("");
if (sn == 0)
{
OpenBalnce = GetStatic.ParseDouble(item["end_clr_balance"].ToString());
}
sn++;
DRTotal += GetStatic.ParseDouble(item["DRTotal"].ToString());
cRTotal += GetStatic.ParseDouble(item["cRTotal"].ToString());
BAlance += GetStatic.ParseDouble(item["end_clr_balance"].ToString()) + GetStatic.ParseDouble(item["cRTotal"].ToString()) - GetStatic.ParseDouble(item["DRTotal"].ToString());
if (GetStatic.ParseDouble(item["DRTotal"].ToString()) > 0)
{
cntDR++;
}
if (GetStatic.ParseDouble(item["cRTotal"].ToString()) > 0)
{
cntCR++;
}
string amt = (GetStatic.ParseDouble(item["DRTotal"].ToString()) != 0 ? item["DRTotal"].ToString() : "");
string drLink = "";
drLink += amt + "";
string cramt = (GetStatic.ParseDouble(item["cRTotal"].ToString()) != 0 ? item["cRTotal"].ToString() : "");
string crLink = "";
crLink += amt + "";
sb.AppendLine("" + (item["TRNDate"].ToString() == "1900.01.01" ? " " : item["TRNDate"]) + " | ");
sb.AppendLine("" + item["tran_rmks"] + " | ");
sb.AppendLine("" + GetStatic.ShowDecimal(item["DRTotal"].ToString()) + " | ");
sb.AppendLine("" + GetStatic.ShowDecimal(item["cRTotal"].ToString()) + " | ");
sb.AppendLine("" + GetStatic.ShowDecimal(BAlance.ToString()) + " " + (BAlance < 0 ? "DR" : "CR") + " | ");
sb.AppendLine("
");
}
sb.AppendLine("
");
tableBody.InnerHtml = sb.ToString();
openingBalance.Text = GetStatic.ShowDecimal(OpenBalnce.ToString());
crCount.Text = cntCR.ToString();
drCount.Text = cntDR.ToString();
drAmt.Text = GetStatic.ShowDecimal(DRTotal.ToString());
crAmt.Text = GetStatic.ShowDecimal(cRTotal.ToString());
drOrCr.Text = (BAlance < 0 ? "DR" : "CR");
closingBalanceAmt.Text = GetStatic.ShowDecimal(BAlance.ToString());
}
protected void goBtn_Click(object sender, EventArgs e)
{
GenerateReport();
}
protected void pdf_Click(object sender, EventArgs e)
{
GetStatic.GetPDF(HttpUtility.UrlDecode(hidden.Value));
}
}
}