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.9 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.DollarVoucherEntry
  7. {
  8. public partial class List : System.Web.UI.Page
  9. {
  10. private const string ViewFunctionId = "20150080";
  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 usdAmt);
  21. Misc.MakeAmountTextBox(ref rate);
  22. Misc.MakeAmountTextBox(ref lcAmt);
  23. transactionDate.Text = DateTime.Today.ToString("yyyy-MM-dd");
  24. transactionDate.Attributes.Add("readonly", "readonly");
  25. lcAmt.Attributes.Add("readonly", "readonly");
  26. //transactionDate.ReadOnly = true;
  27. }
  28. }
  29. private void Authenticate()
  30. {
  31. _sdd.CheckAuthentication(ViewFunctionId);
  32. }
  33. protected bool AllowChangeDate()
  34. {
  35. return _sdd.HasRight(DateFunctionId);
  36. }
  37. protected void addBtn_Click(object sender, EventArgs e)
  38. {
  39. if (GetStatic.ParseDouble(usdAmt.Text) <= 0)
  40. {
  41. GetStatic.AlertMessage(this, "Please enter valid Amount! ");
  42. usdAmt.Text = " ";
  43. usdAmt.Focus();
  44. return;
  45. }
  46. var result = _vrd.InsertTempVoucherEntryUSD(GetStatic.GetSessionId(), GetStatic.GetUser(), acInfo.Value, trantype.SelectedValue,
  47. usdAmt.Text, rate.Text, lcAmt.Text);
  48. if (result.ErrorCode == "1")
  49. {
  50. GetStatic.AlertMessage(this, result.Msg);
  51. }
  52. else
  53. {
  54. ShowTempVoucher();
  55. }
  56. }
  57. private void ShowTempVoucher()
  58. {
  59. //show data on div
  60. int sno = 0, drCount = 0, crCount = 0;
  61. double drTotal = 0, crTotal = 0;
  62. var dt = _vrd.GetTempVoucherEntryDataFRV(GetStatic.GetSessionId());
  63. var sb = new StringBuilder("");
  64. sb.AppendLine("<div class=\"table-responsive\">");
  65. sb.AppendLine("<table class=\"table table-bordered\">");
  66. sb.AppendLine("<tr >");
  67. sb.AppendLine("<th >S. No</th>");
  68. sb.AppendLine("<th >AC information</th>");
  69. sb.AppendLine("<th >Type</th>");
  70. sb.AppendLine("<th>(USD) Amount</th>");
  71. sb.AppendLine("<th>Ex. Rate</th>");
  72. sb.AppendLine("<th>LC Amt</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='7' 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' align='right' width='25%'> <div align='right' style='font-size:12px !important'> " + GetStatic.ShowDecimal(item["usd_rate"].ToString()) + "</div> </td>");
  100. sb.AppendLine("<td nowrap='nowrap' align='right' width='25%'> <div align='right' style='font-size:12px !important'> " + GetStatic.ShowDecimal(item["lc_amt_cr"].ToString()) + "</div> </td>");
  101. 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>");
  102. sb.AppendLine("</tr>");
  103. }
  104. sb.AppendLine("<tr>");
  105. 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>");
  106. sb.AppendLine("</tr>");
  107. sb.AppendLine("<tr>");
  108. 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>");
  109. sb.AppendLine("</tr>");
  110. sb.AppendLine("</table>");
  111. sb.AppendLine("</div>");
  112. rpt_tempVoucherTrans.InnerHtml = sb.ToString();
  113. }
  114. protected void btnDelete_Click(object sender, EventArgs e)
  115. {
  116. var res = _vrd.DeleteRecordVoucherEntryFRV(hdnRowId.Value);
  117. if (res.ErrorCode == "0")
  118. {
  119. GetStatic.AlertMessage(this, res.Msg);
  120. }
  121. ShowTempVoucher();
  122. }
  123. protected void btnUnSave_Click(object sender, EventArgs e)
  124. {
  125. ShowTempVoucher();
  126. }
  127. protected void btnSave_Click(object sender, EventArgs e)
  128. {
  129. string date = transactionDate.Text;
  130. var res = _vrd.SaveTempTransactionUSD(GetStatic.GetSessionId(), date, narrationField.Text, chequeNumber.Text, "J", GetStatic.GetUser(), "");
  131. if (res.ErrorCode == "0")
  132. {
  133. narrationField.Text = "";
  134. rpt_tempVoucherTrans.InnerHtml = res.Msg;
  135. }
  136. else
  137. {
  138. GetStatic.AlertMessage(this, res.Msg);
  139. }
  140. }
  141. }
  142. }