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.

155 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.VoucherEntry
  7. {
  8. public partial class List : System.Web.UI.Page
  9. {
  10. private const string ViewFunctionId = "20150000,20150010,20150020,20150030";
  11. private const string DateFunctionId = "20150040";
  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. transactionDate.Text = DateTime.Today.ToString("d");
  22. transactionDate.Attributes.Add("readonly", "readonly");
  23. //transactionDate.ReadOnly = true;
  24. PopulateDDL();
  25. }
  26. }
  27. private void PopulateDDL()
  28. {
  29. _sdd.SetDDL(ref voucherType, "EXEC Proc_dropdown_remit @FLAG='voucherDDL'", "value", "functionName", "", "");
  30. }
  31. private void Authenticate()
  32. {
  33. _sdd.CheckAuthentication(ViewFunctionId);
  34. }
  35. protected bool AllowChangeDate()
  36. {
  37. return _sdd.HasRight(DateFunctionId);
  38. }
  39. protected void addBtn_Click(object sender, EventArgs e)
  40. {
  41. if (GetStatic.ParseDouble(amt.Text) <= 0)
  42. {
  43. GetStatic.AlertMessage(this, "Please enter valid Amount! ");
  44. amt.Text = " ";
  45. amt.Focus();
  46. return;
  47. }
  48. //var result = _vrd.InsertTempVoucherEntry(GetStatic.GetSessionId(),GetStatic.GetUser(),acInfo.Value,dropDownDrCr.Text,amt.Text);
  49. //if (result.ErrorCode == "1")
  50. //{
  51. // GetStatic.AlertMessage(this, result.Msg);
  52. //}
  53. //else
  54. //{
  55. // ShowTempVoucher();
  56. //}
  57. }
  58. private void ShowTempVoucher()
  59. {
  60. //show data on div
  61. int sno = 0, drCount = 0, crCount = 0;
  62. double drTotal = 0, crTotal = 0;
  63. var dt = _vrd.GetTempVoucherEntryData(GetStatic.GetSessionId());
  64. var sb = new StringBuilder("");
  65. sb.AppendLine("<div class=\"table-responsive\">");
  66. sb.AppendLine("<table class=\"table table-bordered\">");
  67. sb.AppendLine("<tr >");
  68. sb.AppendLine("<th >S. No</th>");
  69. sb.AppendLine("<th >AC information</th>");
  70. sb.AppendLine("<th >Type</th>");
  71. sb.AppendLine("<th>Amount</th>");
  72. sb.AppendLine("<th>Select</th>");
  73. sb.AppendLine("</tr>");
  74. if (dt == null || dt.Rows.Count == 0)
  75. {
  76. sb.AppendLine("<tr><td colspan='5' align='center'>No transaction found!</td></tr></table></div>");
  77. rpt_tempVoucherTrans.InnerHtml = sb.ToString();
  78. return;
  79. }
  80. foreach (DataRow item in dt.Rows)
  81. {
  82. sno++;
  83. if (item["part_tran_type"].ToString().ToLower() == "dr")
  84. {
  85. drCount++;
  86. drTotal = drTotal + Convert.ToDouble(item["tran_amt"]);
  87. }
  88. else if (item["part_tran_type"].ToString().ToLower() == "cr")
  89. {
  90. crCount++;
  91. crTotal = crTotal + Convert.ToDouble(item["tran_amt"]);
  92. }
  93. sb.AppendLine("<tr>");
  94. sb.AppendLine("<td nowrap='nowrap' width='10%'>" + sno.ToString() + " </td>");
  95. sb.AppendLine("<td nowrap='nowrap' width='50%'> " + item["acct_num"].ToString() + "</td>");
  96. sb.AppendLine("<td nowrap='nowrap' width='5%'>" + item["part_tran_type"].ToString() + " </td>");
  97. 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>");
  98. 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>");
  99. sb.AppendLine("</tr>");
  100. }
  101. sb.AppendLine("<tr>");
  102. 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>");
  103. sb.AppendLine("</tr>");
  104. sb.AppendLine("<tr>");
  105. 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>");
  106. sb.AppendLine("</tr>");
  107. sb.AppendLine("</table>");
  108. sb.AppendLine("</div>");
  109. rpt_tempVoucherTrans.InnerHtml = sb.ToString();
  110. }
  111. protected void btnDelete_Click(object sender, EventArgs e)
  112. {
  113. var res = _vrd.DeleteRecordVoucherEntry(hdnRowId.Value);
  114. if (res.ErrorCode == "0")
  115. {
  116. GetStatic.AlertMessage(this, res.Msg);
  117. }
  118. ShowTempVoucher();
  119. }
  120. protected void btnUnSave_Click(object sender, EventArgs e)
  121. {
  122. ShowTempVoucher();
  123. }
  124. protected void btnSave_Click(object sender, EventArgs e)
  125. {
  126. string date = transactionDate.Text;
  127. var res = _vrd.SaveTempTransaction(GetStatic.GetSessionId(), date, narrationField.Text, voucherType.SelectedValue, chequeNo.Text, GetStatic.GetUser(), "");
  128. if (res.ErrorCode == "0")
  129. {
  130. chequeNo.Text = "";
  131. narrationField.Text = "";
  132. rpt_tempVoucherTrans.InnerHtml = res.Msg;
  133. }
  134. else
  135. {
  136. GetStatic.AlertMessage(this, res.Msg);
  137. }
  138. }
  139. }
  140. }