using Swift.DAL.BL.Remit.Transaction;
using Swift.web.Library;
using System;
using System.Data;
using System.Text;
namespace Swift.web.AgentPanel.Reports.soaInt
{
public partial class Manage : System.Web.UI.Page
{
private SwiftLibrary sl = new SwiftLibrary();
private const string ViewFunctionId = "40121100";
protected void Page_Load(object sender, EventArgs e)
{
Authenticate();
if (!IsPostBack)
{
DivRptHead.Visible = false;
fromDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
toDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
}
}
private void Authenticate()
{
sl.CheckAuthentication(ViewFunctionId);
}
protected void BtnSave_Click(object sender, EventArgs e)
{
DivFrm.Visible = false;
DivRptHead.Visible = true;
DataTable Dt = new TranAgentReportDao().AgentSoaReportAgentNew(fromDate.Text, toDate.Text, GetStatic.GetAgent(), GetStatic.GetBranch(), GetStatic.GetUser());
LoadSoaHtml(Dt);
lblFrmDate.Text = fromDate.Text;
lbltoDate.Text = toDate.Text;
lblAgentName.Text = GetStatic.GetAgentName() + " - " + GetStatic.GetBranchName();
lblGeneratedDate.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
lblGeneratedBy.Text = GetStatic.GetUser();
//Need to pickup from agent Master settlement currecny
string agentCurr = new TranAgentReportDao().AgentCurrency(GetStatic.GetAgent());
lblCurr.Text = agentCurr;
}
private void LoadSoaHtml(DataTable dt)
{
int cols = dt.Columns.Count;
var str = new StringBuilder("
");
str.Append("");
str.Append("Date | ");
str.Append("Particulars | ");
str.Append("DR | ");
str.Append("CR | ");
str.Append("Balance | ");
str.Append(" | ");
str.Append("
");
int cnt = 0;
double DR = 0.00;
double CR = 0.00;
double BAL = 0.00;
double OPBal = 0.00;
double CrTotal = 0.00;
double DrTotal = 0.00;
double GTotal = -0.00;
string DrCr = "";
if (dt.Rows.Count == 0)
{
str.Append("No Record Found Or your have selected Invalid Search Criteria |
");
rptDiv.InnerHtml = str.ToString();
return;
}
OPBal = double.Parse(dt.Rows[0]["DR"].ToString());
//BAL = OPBal;
DrCr = (OPBal < 0) ? "DR" : "CR";
str.Append("");
str.Append(" | ");
str.Append("Opening Balance | ");
str.Append(" | ");
str.Append(" | ");
str.Append("" + GetStatic.ShowDecimal(Math.Abs(OPBal).ToString()) + " | ");
str.Append("" + DrCr + " | ");
str.Append("
");
foreach (DataRow dr in dt.Rows)
{
cnt = cnt + 1;
BAL = 0;
if (dr["Particulars"].ToString() != "Opening Balance")
{
str.Append("");
DR = DR + double.Parse(dr["DR"].ToString());
CR = CR + double.Parse(dr["CR"].ToString());
BAL = BAL + (OPBal - DR + CR);
DrCr = (BAL < 0) ? "DR" : "CR";
GTotal = GTotal + BAL;
if (double.Parse(dr["DR"].ToString()) > 0)
{
DrTotal = DrTotal + 1;
}
else
{
CrTotal = CrTotal + 1;
}
for (int i = 0; i < cols; i++)
{
if (i > 1)
{
str.Append("" + GetStatic.ShowDecimal(dr[i].ToString()) +
" | ");
}
else
{
str.Append("" + dr[i].ToString() + " | ");
}
}
str.Append("" + GetStatic.ShowDecimal(Math.Abs(BAL).ToString()) + " | ");
str.Append("" + DrCr + " | ");
str.Append("
");
}
}
str.Append("");
str.Append("Total | ");
str.Append("" + GetStatic.ShowDecimal(DR.ToString()) + " | ");
str.Append("" + GetStatic.ShowDecimal(CR.ToString()) + " | ");
str.Append(" | ");
str.Append("
");
str.Append("");
rptDiv.InnerHtml = str.ToString();
lblOpSing.Text = (OPBal < 0) ? "DR" : "CR";
lblOpAmt.Text = GetStatic.ShowDecimal(Math.Abs(OPBal).ToString());
if (BAL == 0)
{
lblCloAmt.Text = GetStatic.ShowDecimal(Math.Abs(OPBal).ToString());
lblCloSign.Text = (OPBal < 0) ? "DR" : "CR";
}
else
{
lblCloAmt.Text = GetStatic.ShowDecimal(Math.Abs(BAL).ToString());
lblCloSign.Text = (BAL < 0) ? "DR" : "CR";
}
lblDrTotal.Text = GetStatic.ShowDecimal(DR.ToString());
lblCrTotal.Text = GetStatic.ShowDecimal(CR.ToString());
lblAmtMsg.Text = (BAL > 0) ? "Payable to Agent" : "Receivable From Agent";
}
}
}