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.

227 lines
8.5 KiB

  1. using Swift.API.Common;
  2. using Swift.API.Common.Amend;
  3. using Swift.API.ThirdPartyApiServices;
  4. using Swift.DAL.BL.Remit.Transaction;
  5. using Swift.DAL.SwiftDAL;
  6. using Swift.web.Library;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Web;
  13. using System.Web.UI;
  14. using System.Web.UI.WebControls;
  15. namespace Swift.web.Remit.Transaction.ModifyRequest
  16. {
  17. public partial class TransactionDetail : System.Web.UI.Page
  18. {
  19. private const string ViewFunctionId = "90300000";
  20. protected const string GridName = "grdPenAgntTxnModify";
  21. private readonly ModifyTransactionDao dao = new ModifyTransactionDao();
  22. private readonly RemittanceLibrary sl = new RemittanceLibrary();
  23. private readonly StaticDataDdl sdd = new StaticDataDdl();
  24. protected void Page_Load(object sender, EventArgs e)
  25. {
  26. Authenticate();
  27. if (!IsPostBack)
  28. {
  29. PopulateData();
  30. }
  31. GetStatic.ResizeFrame(Page);
  32. }
  33. private void PopulateData()
  34. {
  35. // emailAdd.Text = sl.GetBranchEmail(GetStatic.GetBranch(), GetStatic.GetUser());
  36. sdd.SetStaticDdl(ref txnmodifyField, "8100", "", "");
  37. PopulateTransactionDetail();
  38. }
  39. private void Authenticate()
  40. {
  41. sl.CheckAuthentication(ViewFunctionId);
  42. }
  43. protected string GetControlNo()
  44. {
  45. return GetStatic.ReadQueryString("controlNo", "");
  46. }
  47. protected bool ShowCommentFlag()
  48. {
  49. return GetStatic.ReadQueryString("commentFlag", "Y") != "N";
  50. }
  51. protected bool ShowBankDetail()
  52. {
  53. return (GetStatic.ReadQueryString("showBankDetail", "N") == "Y");
  54. }
  55. private void PopulateTransactionDetail()
  56. {
  57. string txnId = GetStatic.ReadQueryString("tranId", "");
  58. string cntNo = GetControlNo();
  59. if (txnId != "" || cntNo != "")
  60. {
  61. ucTran.ShowCommentBlock = ShowCommentFlag();
  62. ucTran.ShowBankDetail = ShowBankDetail();
  63. ucTran.SearchData(txnId, cntNo, "", "", "SEARCH", "ADM: VIEW TXN (SEARCH TRANSACTION)");
  64. if (!ucTran.TranFound)
  65. {
  66. GetStatic.ShowErrorMessage("Transaction Not Found");
  67. return;
  68. }
  69. if (ucTran.TranStatus != "Payment")
  70. {
  71. GetStatic.ShowErrorMessage("Transaction not authorised for modification; Status:" + ucTran.TranStatus + "!");
  72. return;
  73. }
  74. divTranDetails.Visible = ucTran.TranFound;
  75. modtable.Visible = ucTran.TranFound;
  76. divControlno.Visible = ucTran.TranFound;
  77. if (ucTran.PSuperAgent == "394428")
  78. {
  79. txnmodifyField.Visible = false;
  80. txnReceiver.Visible = true;
  81. nameTable.Visible = true;
  82. btnAdd.Visible = false;
  83. }
  84. else
  85. {
  86. txnmodifyField.Visible = true;
  87. txnReceiver.Visible = false;
  88. btnAdd.Visible = true;
  89. }
  90. }
  91. }
  92. protected void btnAdd_Click(object sender, EventArgs e)
  93. {
  94. }
  95. private void TXNRequestDeatil(DataTable dt)
  96. {
  97. if (dt != null && dt.Rows.Count != 0)
  98. {
  99. dispRequest.Visible = true;
  100. StringBuilder sb = new StringBuilder("");
  101. sb.AppendLine("<table class='table' border='0' cellspacing='0' cellpadding='3'>");
  102. sb.AppendLine("<tr><th class='frmTitle'>S.N</th><th class='frmTitle'>Comments</th><th class='frmTitle'>Delete</th></tr>");
  103. for (int i = 0; i < dt.Rows.Count; i++)
  104. {
  105. sb.AppendLine("<tr><td>" + (i + 1) + "</td>");
  106. sb.AppendLine("<td nowrap='nowrap'>" + dt.Rows[i]["message"] + "</td>");
  107. sb.AppendLine("<td><img alt='Delete' src='../../../Images/delete.gif' onClick='Delete(" + dt.Rows[i]["rowId"] + ")' /> </td></tr>");
  108. }
  109. sb.AppendLine("</table>");
  110. dispRequest.InnerHtml = sb.ToString();
  111. return;
  112. }
  113. dispRequest.Visible = false;
  114. }
  115. protected void btnRequest_Click(object sender, EventArgs e)
  116. {
  117. AmendDataNew();
  118. }
  119. private void ManageMessage(DbResult dbResult)
  120. {
  121. if (dbResult.ErrorCode != "0")
  122. {
  123. GetStatic.SetMessage(dbResult);
  124. GetStatic.AlertMessage(Page);
  125. return;
  126. }
  127. Response.Redirect("search.aspx?controlNo=" + ucTran.CtrlNo );
  128. }
  129. protected void btnDelete_Click(object sender, EventArgs e)
  130. {
  131. DataTable dt = dao.TXNDelete(GetStatic.GetUser(), rowid.Value, ucTran.CtrlNo);
  132. TXNRequestDeatil(dt);
  133. }
  134. protected void txnmodifyField_SelectedIndexChanged(object sender, EventArgs e)
  135. {
  136. }
  137. private void PrintMessage(string msg)
  138. {
  139. GetStatic.CallBackJs1(Page, "Result", "alert('" + msg + "')");
  140. }
  141. protected void AmendDataNew()
  142. {
  143. TxnAmendReceiver AmendedReceiverData = new TxnAmendReceiver() { RFirstName = txtFirstName.Text.Trim(), RMiddleName= txtMiddleName.Text.Trim(), RLastName = txtFirstLastName.Text.Trim() };
  144. TxnAmendSender AmendedSenderData = new TxnAmendSender();
  145. DataTable dt = new DataTable(); ;
  146. DbResult _dbRes = dao.GetTxnForAmendmentApi(GetStatic.GetUser(), ucTran.CtrlNo);
  147. if (_dbRes.Msg.Equals("394428")) //cebauna
  148. {
  149. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":" + _dbRes.Msg + ":AmendApi";
  150. AmendTransactionRequestService resp = new AmendTransactionRequestService();
  151. JsonResponse _resp = resp.AmendTransactionService(new AmendTransaction()
  152. {
  153. ProviderId = _dbRes.Msg,
  154. TfPinno = ucTran.CtrlNo,
  155. ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40),
  156. AmendReceiver = AmendedReceiverData,
  157. AmendSender = new TxnAmendSender(),
  158. AmendAgent = new TxnAmendAgnet(),
  159. Reason= ModifyReason.Text.Trim()
  160. });
  161. UcTranDao _obj = new UcTranDao();
  162. _obj.AddComment(GetStatic.GetUser(), ucTran.CtrlNo, ucTran.TranNo, $"{_dbRes.Extra2} - {_resp.Msg}");
  163. if (_resp.ResponseCode == "0")
  164. {
  165. //dt = dao.TXNReqUpdate(GetStatic.GetUser(), ucTran.CtrlNo, modifyField, newValue, fieldName, fieldValue);
  166. DbResult dbResult = dao.UpdateTransaction(GetStatic.GetUser()
  167. , ucTran.TranNo
  168. , "receiverName"
  169. , _dbRes.Extra1
  170. , null
  171. , null
  172. , txtFirstName.Text
  173. , txtMiddleName.Text
  174. , txtFirstLastName.Text
  175. , null
  176. , null
  177. , ""
  178. , GetStatic.GetSessionId()
  179. );
  180. if (dbResult.ErrorCode == "0")
  181. {
  182. string mes = GetStatic.ParseResultJsPrint(dbResult);
  183. string scriptName = "CallBack";
  184. string functionName = "CallBack('" + mes + "','" + "Search.aspx" + "')";
  185. GetStatic.CallBackJs1(Page, scriptName, functionName);
  186. }
  187. else
  188. {
  189. PrintMessage($"{_dbRes.Extra2} error - {dbResult.Msg}");
  190. }
  191. }
  192. else
  193. {
  194. PrintMessage($"{_dbRes.Extra2} amend api error - {_resp.Msg}");
  195. }
  196. }
  197. }
  198. }
  199. }