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.

91 lines
3.2 KiB

  1. using Swift.DAL.BL.Remit.Administration.Customer;
  2. using Swift.web.Library;
  3. using System;
  4. using System.Data;
  5. using System.Text;
  6. namespace Swift.web.BillVoucher.RefundWalletAmt
  7. {
  8. public partial class List : System.Web.UI.Page
  9. {
  10. private const string ViewFunctionId = "20153100";
  11. private SwiftLibrary _sl = new SwiftLibrary();
  12. private readonly CustomersDao _obj = new CustomersDao();
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. Authenticate();
  16. }
  17. private void Authenticate()
  18. {
  19. _sl.CheckAuthentication(ViewFunctionId);
  20. }
  21. protected void btnRefund_Click(object sender, EventArgs e)
  22. {
  23. if (GetStatic.ParseInt(refundAmt.Text) <= 0)
  24. {
  25. GetStatic.AlertMessage(this, "Refund amount can not be negetive");
  26. return;
  27. }
  28. if (GetStatic.ParseInt(hddAvailableBalance.Value) < GetStatic.ParseInt(refundAmt.Text))
  29. {
  30. GetStatic.AlertMessage(this, "Refund amount can not more than available amount");
  31. return;
  32. }
  33. var dbresult = _obj.RefundBalance(GetStatic.GetUser(), CustomerInfo.Value, refundAmt.Text, chargeAmt.Text);
  34. if (dbresult.ErrorCode == "0")
  35. {
  36. tblHistory.InnerHtml = dbresult.Msg;
  37. hddAvailableBalance.Value = "";
  38. refundAmt.Text = "";
  39. chargeAmt.Text = "";
  40. btnRefund.Visible = false;
  41. return;
  42. }
  43. GetStatic.AlertMessage(this, dbresult.Msg);
  44. return;
  45. }
  46. protected void btnSearch_Click(object sender, EventArgs e)
  47. {
  48. double availableBalance = 0;
  49. if (!string.IsNullOrEmpty(CustomerInfo.Value))
  50. {
  51. DataTable dt = _obj.GetWalletInfo(GetStatic.GetUser(), CustomerInfo.Value);
  52. if (dt == null || dt.Rows.Count == 0)
  53. {
  54. return;
  55. }
  56. if (dt.Rows[0]["errorCode"].ToString() != "0")
  57. {
  58. return;
  59. }
  60. StringBuilder sb = new StringBuilder();
  61. foreach (DataRow item in dt.Rows)
  62. {
  63. sb.AppendLine("<tr>");
  64. sb.AppendLine("<td>" + item["customerName"].ToString() + "</td>");
  65. sb.AppendLine("<td>" + item["idNumber"].ToString() + "</td>");
  66. sb.AppendLine("<td>" + GetStatic.ShowDecimal(item["availableBalance"].ToString()) + "</td>");
  67. sb.AppendLine("</tr>");
  68. availableBalance = GetStatic.ParseDouble(item["availableBalance"].ToString());
  69. }
  70. tblHistory.InnerHtml = sb.ToString();
  71. hddAvailableBalance.Value = availableBalance.ToString();
  72. if (availableBalance <= 0)
  73. {
  74. btnRefund.Visible = false;
  75. searchDetail.Visible = false;
  76. }
  77. else
  78. {
  79. btnRefund.Visible = true;
  80. searchDetail.Visible = true;
  81. }
  82. }
  83. }
  84. }
  85. }