You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
6.3 KiB

  1. using Swift.DAL.BL.Remit.Transaction;
  2. using Swift.web.Library;
  3. using System;
  4. using System.Data;
  5. using System.Text;
  6. namespace Swift.web.AgentPanel.Reports.soaInt
  7. {
  8. public partial class Manage : System.Web.UI.Page
  9. {
  10. private SwiftLibrary sl = new SwiftLibrary();
  11. private const string ViewFunctionId = "40121100";
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. Authenticate();
  15. if (!IsPostBack)
  16. {
  17. DivRptHead.Visible = false;
  18. fromDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
  19. toDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
  20. }
  21. }
  22. private void Authenticate()
  23. {
  24. sl.CheckAuthentication(ViewFunctionId);
  25. }
  26. protected void BtnSave_Click(object sender, EventArgs e)
  27. {
  28. DivFrm.Visible = false;
  29. DivRptHead.Visible = true;
  30. DataTable Dt = new TranAgentReportDao().AgentSoaReportAgentNew(fromDate.Text, toDate.Text, GetStatic.GetAgent(), GetStatic.GetBranch(), GetStatic.GetUser());
  31. LoadSoaHtml(Dt);
  32. lblFrmDate.Text = fromDate.Text;
  33. lbltoDate.Text = toDate.Text;
  34. lblAgentName.Text = GetStatic.GetAgentName() + " - " + GetStatic.GetBranchName();
  35. lblGeneratedDate.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
  36. lblGeneratedBy.Text = GetStatic.GetUser();
  37. //Need to pickup from agent Master settlement currecny
  38. string agentCurr = new TranAgentReportDao().AgentCurrency(GetStatic.GetAgent());
  39. lblCurr.Text = agentCurr;
  40. }
  41. private void LoadSoaHtml(DataTable dt)
  42. {
  43. int cols = dt.Columns.Count;
  44. var str = new StringBuilder("<table class='table table-responsive table-condensed table-bordered'>");
  45. str.Append("<tr>");
  46. str.Append("<th><div align=\"left\">Date</div></th>");
  47. str.Append("<th><div align=\"left\">Particulars</div></th>");
  48. str.Append("<th><div align=\"left\">DR</div></th>");
  49. str.Append("<th><div align=\"left\">CR</div></th>");
  50. str.Append("<th><div align=\"left\">Balance</div></th>");
  51. str.Append("<th><div align=\"left\">&nbsp;</div></th>");
  52. str.Append("</tr>");
  53. int cnt = 0;
  54. double DR = 0.00;
  55. double CR = 0.00;
  56. double BAL = 0.00;
  57. double OPBal = 0.00;
  58. double CrTotal = 0.00;
  59. double DrTotal = 0.00;
  60. double GTotal = -0.00;
  61. string DrCr = "";
  62. if (dt.Rows.Count == 0)
  63. {
  64. str.Append("<tr><td colspan='4'><b>No Record Found Or your have selected Invalid Search Criteria</td></tr></table>");
  65. rptDiv.InnerHtml = str.ToString();
  66. return;
  67. }
  68. OPBal = double.Parse(dt.Rows[0]["DR"].ToString());
  69. //BAL = OPBal;
  70. DrCr = (OPBal < 0) ? "DR" : "CR";
  71. str.Append("<tr>");
  72. str.Append("<td><div align=\"left\"></div></td>");
  73. str.Append("<td><div align=\"left\">Opening Balance</div></td>");
  74. str.Append("<td><div align=\"left\"></div></td>");
  75. str.Append("<td><div align=\"left\"></div></td>");
  76. str.Append("<td><div align=\"right\"><b>" + GetStatic.ShowDecimal(Math.Abs(OPBal).ToString()) + "</b></div></td>");
  77. str.Append("<td>" + DrCr + "</td>");
  78. str.Append("</tr>");
  79. foreach (DataRow dr in dt.Rows)
  80. {
  81. cnt = cnt + 1;
  82. BAL = 0;
  83. if (dr["Particulars"].ToString() != "Opening Balance")
  84. {
  85. str.Append("<tr>");
  86. DR = DR + double.Parse(dr["DR"].ToString());
  87. CR = CR + double.Parse(dr["CR"].ToString());
  88. BAL = BAL + (OPBal - DR + CR);
  89. DrCr = (BAL < 0) ? "DR" : "CR";
  90. GTotal = GTotal + BAL;
  91. if (double.Parse(dr["DR"].ToString()) > 0)
  92. {
  93. DrTotal = DrTotal + 1;
  94. }
  95. else
  96. {
  97. CrTotal = CrTotal + 1;
  98. }
  99. for (int i = 0; i < cols; i++)
  100. {
  101. if (i > 1)
  102. {
  103. str.Append("<td><div align=\"right\">" + GetStatic.ShowDecimal(dr[i].ToString()) +
  104. "</div></td>");
  105. }
  106. else
  107. {
  108. str.Append("<td><div align=\"left\">" + dr[i].ToString() + "</div></td>");
  109. }
  110. }
  111. str.Append("<td><div align=\"right\"><b>" + GetStatic.ShowDecimal(Math.Abs(BAL).ToString()) + "</b></div></td>");
  112. str.Append("<td>" + DrCr + "</td>");
  113. str.Append("</tr>");
  114. }
  115. }
  116. str.Append("<tr>");
  117. str.Append("<td colspan='2'><div align=\"right\"><b>Total</b> </div></td>");
  118. str.Append("<td><div align=\"right\"><b>" + GetStatic.ShowDecimal(DR.ToString()) + "</b></div></td>");
  119. str.Append("<td><div align=\"right\"><b>" + GetStatic.ShowDecimal(CR.ToString()) + "</b></div></td>");
  120. str.Append("<td colspan=\"2\"></td>");
  121. str.Append("</tr>");
  122. str.Append("</table>");
  123. rptDiv.InnerHtml = str.ToString();
  124. lblOpSing.Text = (OPBal < 0) ? "DR" : "CR";
  125. lblOpAmt.Text = GetStatic.ShowDecimal(Math.Abs(OPBal).ToString());
  126. if (BAL == 0)
  127. {
  128. lblCloAmt.Text = GetStatic.ShowDecimal(Math.Abs(OPBal).ToString());
  129. lblCloSign.Text = (OPBal < 0) ? "DR" : "CR";
  130. }
  131. else
  132. {
  133. lblCloAmt.Text = GetStatic.ShowDecimal(Math.Abs(BAL).ToString());
  134. lblCloSign.Text = (BAL < 0) ? "DR" : "CR";
  135. }
  136. lblDrTotal.Text = GetStatic.ShowDecimal(DR.ToString());
  137. lblCrTotal.Text = GetStatic.ShowDecimal(CR.ToString());
  138. lblAmtMsg.Text = (BAL > 0) ? "Payable to Agent" : "Receivable From Agent";
  139. }
  140. }
  141. }