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.

234 lines
9.0 KiB

  1. using Swift.DAL.BL.Remit.Transaction;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Library;
  4. using System;
  5. using System.Data;
  6. using System.Text;
  7. namespace Swift.web.AgentPanel.Utilities.ModifyRequest
  8. {
  9. public partial class TransactionDetail : System.Web.UI.Page
  10. {
  11. private const string ViewFunctionId = "40112800";
  12. protected const string GridName = "grdPenAgntTxnModify";
  13. private readonly ModifyTransactionDao dao = new ModifyTransactionDao();
  14. private readonly RemittanceLibrary sl = new RemittanceLibrary();
  15. private readonly StaticDataDdl sdd = new StaticDataDdl();
  16. protected void Page_Load(object sender, EventArgs e)
  17. {
  18. if (!IsPostBack)
  19. {
  20. Authenticate();
  21. PopulateData();
  22. }
  23. GetStatic.ResizeFrame(Page);
  24. }
  25. private void PopulateData()
  26. {
  27. emailAdd.Text = sl.GetBranchEmail(GetStatic.GetBranch(), GetStatic.GetUser());
  28. sdd.SetStaticDdl(ref txnmodifyField, "8100", "", "");
  29. PopulateTransactionDetail();
  30. }
  31. private void Authenticate()
  32. {
  33. sl.CheckAuthentication(ViewFunctionId);
  34. }
  35. protected string GetControlNo()
  36. {
  37. return GetStatic.ReadQueryString("controlNo", "");
  38. }
  39. protected bool ShowCommentFlag()
  40. {
  41. return GetStatic.ReadQueryString("commentFlag", "Y") != "N";
  42. }
  43. protected bool ShowBankDetail()
  44. {
  45. return (GetStatic.ReadQueryString("showBankDetail", "N") == "Y");
  46. }
  47. private void PopulateTransactionDetail()
  48. {
  49. string txnId = GetStatic.ReadQueryString("tranId", "");
  50. string cntNo = GetControlNo();
  51. if (txnId != "" || cntNo != "")
  52. {
  53. ucTran.ShowCommentBlock = ShowCommentFlag();
  54. ucTran.ShowBankDetail = ShowBankDetail();
  55. ucTran.SearchData(txnId, cntNo, "", "", "SEARCH", "ADM: VIEW TXN (SEARCH TRANSACTION)");
  56. if (!ucTran.TranFound)
  57. {
  58. GetStatic.ShowErrorMessage("Transaction Not Found");
  59. return;
  60. }
  61. if (ucTran.TranStatus != "Payment")
  62. {
  63. GetStatic.ShowErrorMessage("Transaction not authorised for modification; Status:" + ucTran.TranStatus + "!");
  64. return;
  65. }
  66. divTranDetails.Visible = ucTran.TranFound;
  67. modtable.Visible = ucTran.TranFound;
  68. divControlno.Visible = ucTran.TranFound;
  69. }
  70. }
  71. protected void btnAdd_Click(object sender, EventArgs e)
  72. {
  73. var modifyField = txnmodifyField.SelectedItem.Text;
  74. var newValue = "";
  75. var fieldName = "";
  76. var fieldValue = "";
  77. if (modifyField == "Receiver Id Type")
  78. fieldName = " rIdType ";
  79. else if (modifyField == "Sender Id Type")
  80. fieldName = "sIdType";
  81. else if (modifyField == "Receiver Name")
  82. fieldName = " receiverName";
  83. else if (modifyField == "Sender Name")
  84. fieldName = "senderName";
  85. else if (modifyField == "Sender Address")
  86. fieldName = "sAddress";
  87. else if (modifyField == "Receiver Address")
  88. fieldName = "rAddress";
  89. else if (modifyField == "Receiver Contact No")
  90. fieldName = "rContactNo";
  91. else if (modifyField == "Sender Contact No")
  92. fieldName = "sContactNo";
  93. else if (modifyField == "Receiver Id No")
  94. fieldName = "rIdNo";
  95. else if (modifyField == "Sender Id No")
  96. fieldName = "sIdNo";
  97. else if (modifyField == "Payout Location")
  98. fieldName = "pAgentLocation";
  99. else if (modifyField == "Receiver Bank Ac No")
  100. fieldName = "accountNo";
  101. if (modifyField == "Sender Name" || modifyField == "Receiver Name")
  102. {
  103. newValue = txtFirstName.Text + " " + txtMiddleName.Text + " " + txtFirstLastName.Text + " " + txtSecondLastName.Text;
  104. fieldValue = "'<root><row firstName = \"" + txtFirstName.Text + "\" middleName = \"" + txtMiddleName.Text + "\" firstLastName = \"" + txtFirstLastName.Text + "\" secondLastName = \"" + txtSecondLastName.Text + "\"/></root>'";
  105. }
  106. else if (modifyField == "Sender Id Type" || modifyField == "Receiver Id Type")
  107. {
  108. newValue = idType.SelectedItem.Text;
  109. fieldValue = newValue;
  110. }
  111. else if (modifyField == "Payout Location")
  112. {
  113. newValue = idType.SelectedItem.Text;
  114. fieldValue = idType.SelectedValue;
  115. }
  116. else
  117. {
  118. newValue = txtValue.Text;
  119. fieldValue = newValue;
  120. }
  121. DataTable dt = dao.TXNReqUpdate(GetStatic.GetUser(), ucTran.CtrlNo, modifyField, newValue, fieldName, fieldValue);
  122. if (dt.Rows[0][0].ToString() == "0")
  123. {
  124. var res = new DbResult();
  125. res.Msg = dt.Rows[0][1].ToString();
  126. GetStatic.PrintMessage(Page, res);
  127. }
  128. else
  129. TXNRequestDeatil(dt);
  130. }
  131. private void TXNRequestDeatil(DataTable dt)
  132. {
  133. if (dt != null && dt.Rows.Count != 0)
  134. {
  135. dispRequest.Visible = true;
  136. StringBuilder sb = new StringBuilder("");
  137. sb.AppendLine("<table class='table' border='0' cellspacing='0' cellpadding='3'>");
  138. sb.AppendLine("<tr><th class='frmTitle'>S.N</th><th class='frmTitle'>Comments</th><th class='frmTitle'>Delete</th></tr>");
  139. for (int i = 0; i < dt.Rows.Count; i++)
  140. {
  141. sb.AppendLine("<tr><td>" + (i + 1) + "</td>");
  142. sb.AppendLine("<td nowrap='nowrap'>" + dt.Rows[i]["message"] + "</td>");
  143. sb.AppendLine("<td><img alt='Delete' src='../../../Images/delete.gif' onClick='Delete(" + dt.Rows[i]["rowId"] + ")' /> </td></tr>");
  144. }
  145. sb.AppendLine("</table>");
  146. dispRequest.InnerHtml = sb.ToString();
  147. return;
  148. }
  149. dispRequest.Visible = false;
  150. }
  151. protected void btnRequest_Click(object sender, EventArgs e)
  152. {
  153. var dbResult = dao.TXNSCchange(GetStatic.GetUser(), ucTran.CtrlNo);
  154. ManageMessage(dbResult);
  155. }
  156. private void ManageMessage(DbResult dbResult)
  157. {
  158. if (dbResult.ErrorCode != "0")
  159. {
  160. GetStatic.AlertMessage(Page);
  161. return;
  162. }
  163. Response.Redirect("Summary.aspx?controlNo=" + ucTran.CtrlNo + "&email=" + emailAdd.Text + "");
  164. }
  165. protected void btnDelete_Click(object sender, EventArgs e)
  166. {
  167. DataTable dt = dao.TXNDelete(GetStatic.GetUser(), rowid.Value, ucTran.CtrlNo);
  168. TXNRequestDeatil(dt);
  169. }
  170. protected void txnmodifyField_SelectedIndexChanged(object sender, EventArgs e)
  171. {
  172. ChangeTxnModifyField();
  173. }
  174. protected void ChangeTxnModifyField()
  175. {
  176. var modifyField = txnmodifyField.SelectedItem.Text;
  177. if (modifyField == "Sender Name" || modifyField == "Receiver Name")
  178. {
  179. newValueLabel.Visible = false;
  180. labelValue.Visible = false;
  181. nameTable.Visible = true;
  182. }
  183. else if (modifyField == "Sender Id Type")
  184. {
  185. newValueLabel.Visible = true;
  186. nameTable.Visible = false;
  187. labelValue.Visible = false;
  188. idType.Visible = true;
  189. sl.SetDDL(ref idType, "EXEC proc_countryIdType @flag = 'il', @countryId='151', @spFlag = '5201'", "valueId", "detailTitle", "", "Select");
  190. }
  191. else if (modifyField == "Receiver Id Type")
  192. {
  193. newValueLabel.Visible = true;
  194. nameTable.Visible = false;
  195. labelValue.Visible = false;
  196. idType.Visible = true;
  197. sl.SetDDL(ref idType, "EXEC proc_countryIdType @flag = 'il', @countryId='151', @spFlag = '5202'", "valueId", "detailTitle", "", "Select");
  198. }
  199. else if (modifyField == "Payout Location")
  200. {
  201. newValueLabel.Visible = true;
  202. nameTable.Visible = false;
  203. labelValue.Visible = false;
  204. idType.Visible = true;
  205. sl.SetDDL(ref idType, "EXEC proc_apiLocation @flag='l'", "districtCode", "districtName", "", "Select");
  206. }
  207. else
  208. {
  209. newValueLabel.Visible = false;
  210. nameTable.Visible = false;
  211. labelValue.Visible = true;
  212. }
  213. }
  214. }
  215. }