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.

138 lines
5.3 KiB

  1. using Swift.DAL.BL.Remit.Transaction;
  2. using Swift.web.Library;
  3. using System;
  4. using System.Data;
  5. using System.Threading.Tasks;
  6. namespace Swift.web.AgentNew.Transaction.ApproveTxn
  7. {
  8. public partial class Manage : System.Web.UI.Page
  9. {
  10. private const string ViewFunctionId = "40101800";
  11. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  12. private readonly ApproveTransactionDao atd = new ApproveTransactionDao();
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. Authenticate();
  16. GetStatic.AttachConfirmMsg(ref btnApprove, "Are you sure to APPROVE this transaction?");
  17. if (!IsPostBack)
  18. {
  19. }
  20. LoadTransaction();
  21. }
  22. private void Authenticate()
  23. {
  24. _sdd.CheckAuthentication(ViewFunctionId);
  25. }
  26. private void LoadTransaction()
  27. {
  28. string tranNo = GetTranNo();
  29. ucTran.SearchData(tranNo, "", "", "", "APPROVE", "ADMIN: VIEW TXN TO APPROVE");
  30. divTranDetails.Visible = ucTran.TranFound;
  31. if (!ucTran.TranFound)
  32. {
  33. divControlno.InnerHtml = "<h2>No Transaction Found</h2>";
  34. return;
  35. }
  36. }
  37. protected string GetTranNo()
  38. {
  39. return GetStatic.ReadQueryString("id", "");
  40. }
  41. private void Approve()
  42. {
  43. string newSession = Guid.NewGuid().ToString().Replace("-", "");
  44. var result = atd.GetHoldedTxnForApprovedByAdmin(GetStatic.GetUser(), GetTranNo(), newSession);
  45. if (!result.ResponseCode.Equals("NotForTPAPI"))
  46. {
  47. GetStatic.AlertMessage(Page, result.Msg);
  48. GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();");
  49. LoadTransaction();
  50. }
  51. //var dr = atd.ApproveHoldedTXN(GetStatic.GetUser(), GetTranNo());
  52. //SendApprovalMailToCustomers();
  53. //GetStatic.AlertMessage(Page, dr.Msg);
  54. //if (dr.ErrorCode.Equals("0"))
  55. //{
  56. // GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();");
  57. // LoadTransaction();
  58. //}
  59. }
  60. private void SendApprovalMailToCustomers()
  61. {
  62. Task.Factory.StartNew(() => { SendEmail(); });
  63. }
  64. private void SendEmail()
  65. {
  66. DataTable mailDetails = atd.GetMailDetails("system");
  67. if (mailDetails.Rows.Count == 0 || mailDetails == null)
  68. {
  69. return;
  70. }
  71. foreach (DataRow item in mailDetails.Rows)
  72. {
  73. string res = SendEmailNotification(item);
  74. if (res != "Mail Send")
  75. {
  76. atd.ErrorEmail("system", item["rowId"].ToString());
  77. }
  78. }
  79. }
  80. private string SendEmailNotification(DataRow item)
  81. {
  82. string msgSubject = "JME Control No.: " + item["controlNoDec"].ToString();
  83. string toEmailId = item["createdBy"].ToString();
  84. string msgBody = "Dear " + item["SenderName"];
  85. msgBody += "<br/><br/>This is to acknowledge that you have successfully completed your transaction through JME Online Remit System.";
  86. msgBody += "<br/><br/>Kindly take a note of the following transaction details for your record.";
  87. msgBody += "<br/><br/>JME Number: " + item["controlNoDec"].ToString();
  88. msgBody += "<br/>Amount sent: " + item["collCurr"].ToString() + " " + GetStatic.ShowDecimal(item["tAmt"].ToString());
  89. msgBody += "<br/>Payment method: " + item["paymentMethod"].ToString();
  90. msgBody += "<br/>Pay-out country: " + item["pcountry"].ToString();
  91. msgBody += "<br/>Account holding bank Name: " + item["payountBankOrAgent"].ToString();
  92. msgBody += "<br/>Account number: " + item["accNo"].ToString();
  93. msgBody += "<br/>Account holder’s name: " + item["receiverName"].ToString();
  94. msgBody += "<br/>Payout Amount: " + item["payoutCurr"].ToString() + " " + GetStatic.ShowDecimal(item["pAmt"].ToString());
  95. msgBody += "<br/><br/>You can keep track of your payment status by https://online.gmeremit.com/.";
  96. msgBody +=
  97. "<br><br>If you need further assistance kindly email us at support@jme.com.np or call us at 15886864 or 01029596864. or visit our website <a href=\"http://www.gmeremit.com\"> www.gmeremit.com </a>";
  98. msgBody +=
  99. "<br><br><br>We look forward to provide you excellent service.";
  100. msgBody +=
  101. "<br><br>Thank You.";
  102. msgBody +=
  103. "<br><br><br>Regards,";
  104. msgBody +=
  105. "<br>JME Online Team";
  106. msgBody +=
  107. "<br>Seoul, Korea ";
  108. msgBody +=
  109. "<br>Phone number 15886864 ";
  110. SmtpMailSetting mail = new SmtpMailSetting
  111. {
  112. MsgBody = msgBody,
  113. MsgSubject = msgSubject,
  114. ToEmails = toEmailId
  115. };
  116. return mail.SendSmtpMail(mail);
  117. }
  118. protected void btnApprove_Click(object sender, EventArgs e)
  119. {
  120. Approve();
  121. }
  122. }
  123. }