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.

162 lines
6.1 KiB

10 months ago
10 months ago
  1. using System;
  2. using Newtonsoft.Json;
  3. using Swift.DAL.BL.Remit.Transaction;
  4. using Swift.DAL.SwiftDAL;
  5. using Swift.web.Library;
  6. namespace Swift.web.Remit.Transaction.Modify
  7. {
  8. public partial class ModifyLocation : System.Web.UI.Page
  9. {
  10. private const string ViewFunctionId = "20121520";
  11. private readonly StaticDataDdl sd = new StaticDataDdl();
  12. private readonly ModifyTransactionDao mtd = new ModifyTransactionDao();
  13. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. Authenticate();
  17. if (!IsPostBack)
  18. {
  19. DisplayLabel();
  20. lblOldValue.Text = getOldValue();
  21. var countryId = GetStatic.ReadQueryString("pCountryId","");
  22. if(countryId == "151")
  23. {
  24. bankBranch.Visible = false;
  25. }
  26. else
  27. {
  28. bankBranch.Visible = true;
  29. }
  30. }
  31. }
  32. private void Authenticate()
  33. {
  34. _sl.CheckAuthentication(ViewFunctionId);
  35. }
  36. private void DisplayLabel()
  37. {
  38. var countryId = GetStatic.ReadQueryString("pCountryId", "");
  39. var user = GetStatic.GetUser();
  40. lblFieldName.Text = GetLabel();
  41. if (getFieldName() == "pAgentLocation")//paying agent location
  42. {
  43. sd.SetDDL(ref ddlNewValue, "EXEC proc_apiLocation @flag='l'", "districtCode", "districtName", "", "Select");
  44. }
  45. if (getFieldName() == "accountNo")// bank account number
  46. {
  47. rptShowOther.Visible = false;
  48. rptAccountNo.Visible = true;
  49. }
  50. if (getFieldName() == "BankName")// bank & branch
  51. {
  52. showBranch.Visible = true;
  53. rptShowOther.Visible = false;
  54. sd.SetDDL(ref ddlBank, "EXEC proc_agentMaster @flag = 'bankList' ,@pCountryId = " + countryId + "", "agentId", "agentName", "", "Select");
  55. }
  56. if (getFieldName() == "BranchName")//bank branch
  57. {
  58. string BankId = mtd.SelectBankName(GetStatic.GetUser(), GetTranId().ToString());
  59. sd.SetDDL(ref ddlNewValue, "EXEC PROC_API_BANK_BRANCH_SETUP @flag = 'getBranch-new', @CountryId = " + countryId + " ,@PaymentMethod = '2' ,@user = " + user + " ,@bankId = " + BankId + "", "agentId", "agentName", "", "Select");
  60. }
  61. if (getFieldName() == "pBranchName")//paying Branch
  62. {
  63. rptShowOther.Visible = false;
  64. rptAccountNo.Visible = false;
  65. rptBranch.Visible = true;
  66. }
  67. }
  68. private string GetLabel()
  69. {
  70. return GetStatic.ReadQueryString("label", "");
  71. }
  72. private string getFieldName()
  73. {
  74. return GetStatic.ReadQueryString("fieldName", "");
  75. }
  76. private string getOldValue()
  77. {
  78. return GetStatic.ReadQueryString("oldValue", "");
  79. }
  80. protected long GetTranId()
  81. {
  82. return GetStatic.ReadNumericDataFromQueryString("tranId");
  83. }
  84. private void PopulateDll()
  85. {
  86. }
  87. protected void btnUpdate_Click(object sender, EventArgs e)
  88. {
  89. OnUpdate();
  90. }
  91. private void OnUpdate()
  92. {
  93. string newValue = "";
  94. string pCountryId = GetStatic.ReadQueryString("pCountryId", "");
  95. if (getFieldName() == "accountNo")
  96. newValue = txtNewValue.Text;
  97. else if (getFieldName() == "pBranchName")
  98. newValue = hdnBranchId.Value;
  99. else
  100. newValue = ddlNewValue.Text;
  101. /*
  102. if (GetStatic.GetIsApiFlag() == "Y")
  103. {
  104. if (getFieldName() == "pAgentLocation")
  105. {
  106. var ds = mtd.UpdatePayoutLocationApi(GetStatic.GetUser(), GetTranId().ToString(), newValue);
  107. if (ds == null)
  108. return;
  109. if(ds.Tables.Count > 1)
  110. {
  111. }
  112. }
  113. }
  114. * */
  115. DbResult dbResult = mtd.UpdateTransactionPayoutLocation(GetStatic.GetUser()
  116. , GetTranId().ToString()
  117. , getFieldName()
  118. , getOldValue()
  119. , newValue
  120. , ddlBank.Text
  121. , ddlBranch.Text
  122. , GetStatic.GetIsApiFlag()
  123. , GetStatic.GetSessionId()
  124. , pCountryId
  125. );
  126. ManageMessage(dbResult);
  127. }
  128. private void ManageMessage(DbResult dbResult)
  129. {
  130. var mes = JsonConvert.SerializeObject(dbResult);
  131. //mes = mes.Replace("<center>", "");
  132. //mes = mes.Replace("</center>", "");
  133. var scriptName = "CallBack";
  134. var functionName = "CallBack('" + mes + "');";
  135. GetStatic.CallBackJs1(Page, scriptName, functionName);
  136. }
  137. protected void ddlBank_SelectedIndexChanged(object sender, EventArgs e)
  138. {
  139. var countryId = GetStatic.ReadQueryString("pCountryId", "");
  140. var user = GetStatic.GetUser();
  141. if (ddlBank.Text != "")
  142. {
  143. sd.SetDDL(ref ddlBranch, "EXEC PROC_API_BANK_BRANCH_SETUP @flag = 'getBranch-new', @CountryId = " + countryId + " ,@PaymentMethod = '2' ,@user = " + user + " ,@bankId = " + ddlBank.Text + "", "agentId", "agentName", "", "Select");
  144. //sd.SetDDL(ref ddlBranch, "EXEC proc_agentMaster @flag = 'bbl', @parentId = " + ddlBank.Text + "", "agentId", "agentName", "", "Select");
  145. }
  146. }
  147. }
  148. }