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.

156 lines
6.5 KiB

  1. using Swift.DAL.VoucherReport;
  2. using Swift.web.Library;
  3. using System;
  4. using System.Data;
  5. using System.Text;
  6. namespace Swift.web.BillVoucher.ManualVoucher
  7. {
  8. public partial class List : System.Web.UI.Page
  9. {
  10. private const string ViewFunctionId = "20102000,20102010,20102020,20102030";
  11. private const string DateFunctionId = "20102040";
  12. private readonly RemittanceLibrary _sdd = new RemittanceLibrary();
  13. private readonly VoucherReportDAO _vrd = new VoucherReportDAO();
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. Authenticate();
  17. if (!IsPostBack)
  18. {
  19. AllowChangeDate();
  20. Misc.MakeAmountTextBox(ref amt);
  21. Misc.MakeNumericTextbox(ref vNum);
  22. transactionDate.Text = DateTime.Today.ToString("d");
  23. transactionDate.Attributes.Add("readonly", "readonly");
  24. //transactionDate.ReadOnly = true;
  25. PopulateDDL();
  26. }
  27. }
  28. private void PopulateDDL()
  29. {
  30. _sdd.SetDDL(ref voucherType, "EXEC Proc_dropdown_remit @FLAG='voucherDDL'", "value", "functionName", "", "");
  31. }
  32. private void Authenticate()
  33. {
  34. _sdd.CheckAuthentication(ViewFunctionId);
  35. }
  36. protected bool AllowChangeDate()
  37. {
  38. return _sdd.HasRight(DateFunctionId);
  39. }
  40. protected void addBtn_Click(object sender, EventArgs e)
  41. {
  42. if (GetStatic.ParseDouble(amt.Text) <= 0)
  43. {
  44. GetStatic.AlertMessage(this, "Please enter valid Amount! ");
  45. amt.Text = " ";
  46. amt.Focus();
  47. return;
  48. }
  49. //var result = _vrd.InsertTempVoucherEntry(GetStatic.GetSessionId(), GetStatic.GetUser(), acInfo.Value, dropDownDrCr.Text, amt.Text);
  50. //if (result.ErrorCode == "1")
  51. //{
  52. // GetStatic.AlertMessage(this, result.Msg);
  53. //}
  54. //else
  55. //{
  56. // ShowTempVoucher();
  57. //}
  58. }
  59. private void ShowTempVoucher()
  60. {
  61. //show data on div
  62. int sno = 0, drCount = 0, crCount = 0;
  63. double drTotal = 0, crTotal = 0;
  64. var dt = _vrd.GetTempVoucherEntryData(GetStatic.GetSessionId());
  65. var sb = new StringBuilder("");
  66. sb.AppendLine("<div class=\"table-responsive\">");
  67. sb.AppendLine("<table class=\"table table-bordered\">");
  68. sb.AppendLine("<tr >");
  69. sb.AppendLine("<th >S. No</th>");
  70. sb.AppendLine("<th >AC information</th>");
  71. sb.AppendLine("<th >Type</th>");
  72. sb.AppendLine("<th>Amount</th>");
  73. sb.AppendLine("<th>Select</th>");
  74. sb.AppendLine("</tr>");
  75. if (dt == null || dt.Rows.Count == 0)
  76. {
  77. sb.AppendLine("<tr><td colspan='5' align='center'>No transaction found!</td></tr></table></div>");
  78. rpt_tempVoucherTrans.InnerHtml = sb.ToString();
  79. return;
  80. }
  81. foreach (DataRow item in dt.Rows)
  82. {
  83. sno++;
  84. if (item["part_tran_type"].ToString().ToLower() == "dr")
  85. {
  86. drCount++;
  87. drTotal = drTotal + Convert.ToDouble(item["tran_amt"]);
  88. }
  89. else if (item["part_tran_type"].ToString().ToLower() == "cr")
  90. {
  91. crCount++;
  92. crTotal = crTotal + Convert.ToDouble(item["tran_amt"]);
  93. }
  94. sb.AppendLine("<tr>");
  95. sb.AppendLine("<td nowrap='nowrap' width='10%'>" + sno.ToString() + " </td>");
  96. sb.AppendLine("<td nowrap='nowrap' width='50%'> " + item["acct_num"].ToString() + "</td>");
  97. sb.AppendLine("<td nowrap='nowrap' width='5%'>" + item["part_tran_type"].ToString() + " </td>");
  98. sb.AppendLine("<td nowrap='nowrap' align='right' width='25%'> <div align='right' style='font-size:12px !important'> " + GetStatic.ShowDecimal(item["tran_amt"].ToString()) + "</div> </td>");
  99. sb.AppendLine("<td nowrap='nowrap' width='5%'><div align='center'><span class=\"action-icon\"><a class=\"btn btn-xs btn-primary\" title=\"Delete\" data-placement=\"top\" data-toggle=\"tooltip\" href=\"#\" data-original-title=\"Delete\" style='text-decoration:none;' onclick='deleteRecord(" + item["tran_id"].ToString() + ")'><i class=\"fa fa-trash-o\"></i></a></span></div></td>");
  100. sb.AppendLine("</tr>");
  101. }
  102. sb.AppendLine("<tr>");
  103. sb.AppendLine("<td nowrap='nowrap' align='right' colspan='4' > <div align='right' style='font-size:12px !important'><strong>Total Dr</strong><span style=' text-align:right; font-weight: bold;' > (" + drCount.ToString() + "): &nbsp; &nbsp;" + GetStatic.ShowDecimal(drTotal.ToString()) + "</span></div> </td>");
  104. sb.AppendLine("</tr>");
  105. sb.AppendLine("<tr>");
  106. sb.AppendLine("<td nowrap='nowrap' align='right' colspan='4' > <div align='right' style='font-size:12px !important'><strong>Total Cr</strong><span style=' text-align:right; font-weight: bold;' > (" + crCount.ToString() + "): &nbsp; &nbsp;" + GetStatic.ShowDecimal(crTotal.ToString()) + "</span></div> </td>");
  107. sb.AppendLine("</tr>");
  108. sb.AppendLine("</table>");
  109. sb.AppendLine("</div>");
  110. rpt_tempVoucherTrans.InnerHtml = sb.ToString();
  111. }
  112. protected void btnDelete_Click(object sender, EventArgs e)
  113. {
  114. var res = _vrd.DeleteRecordVoucherEntry(hdnRowId.Value);
  115. if (res.ErrorCode == "0")
  116. {
  117. GetStatic.AlertMessage(this, res.Msg);
  118. }
  119. ShowTempVoucher();
  120. }
  121. protected void btnUnSave_Click(object sender, EventArgs e)
  122. {
  123. ShowTempVoucher();
  124. }
  125. protected void btnSave_Click(object sender, EventArgs e)
  126. {
  127. string date = transactionDate.Text;
  128. var res = _vrd.SaveTempTransactionManual(GetStatic.GetSessionId(), date, narrationField.Text, voucherType.SelectedValue, chequeNo.Text, vNum.Text);
  129. if (res.ErrorCode == "0")
  130. {
  131. chequeNo.Text = "";
  132. narrationField.Text = "";
  133. rpt_tempVoucherTrans.InnerHtml = res.Msg;
  134. }
  135. else
  136. {
  137. GetStatic.AlertMessage(this, res.Msg);
  138. }
  139. }
  140. }
  141. }