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.

107 lines
4.4 KiB

  1. using Swift.DAL.Remittance.APIPartner;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Library;
  4. using System;
  5. using System.Data;
  6. namespace Swift.web.Remit.APIPartners
  7. {
  8. public partial class AddApiPartner : System.Web.UI.Page
  9. {
  10. private string ViewFunctionId = "20191200";
  11. private string AddEditFunctionId = "20191210";
  12. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  13. private readonly APIPartnerDao _apiDao = new APIPartnerDao();
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. Authenticate();
  17. if (!IsPostBack)
  18. {
  19. Misc.MakeNumericTextbox(ref minTxnLimit);
  20. Misc.MakeNumericTextbox(ref maxTxnLimit);
  21. PopulateDDL();
  22. if (GetId() != "")
  23. {
  24. PopulateData();
  25. }
  26. }
  27. }
  28. private void PopulateDDL()
  29. {
  30. _sl.SetDDL(ref countryDDL, "EXEC proc_sendPageLoadData @flag='pCountry'", "countryId", "countryName", "", "Select Country");
  31. _sl.SetDDL(ref partnerDDL, "EXEC PROC_API_ROUTE_PARTNERS @flag='partner'", "agentId", "agentName", "", "Select Partner");
  32. }
  33. private void Authenticate()
  34. {
  35. _sl.CheckAuthentication(ViewFunctionId);
  36. if (!_sl.HasRight(AddEditFunctionId))
  37. {
  38. btnSave.Enabled = false;
  39. btnSave.Visible = false;
  40. }
  41. }
  42. protected void PopulateData()
  43. {
  44. DataRow dr = _apiDao.GetData(GetId(), GetStatic.GetUser());
  45. if (dr == null)
  46. {
  47. Response.Redirect("RouteApiPartners.aspx");
  48. }
  49. partnerDDL.SelectedValue = dr["AgentId"].ToString();
  50. countryDDL.SelectedValue = dr["CountryId"].ToString();
  51. PopulateLimtCurrency();
  52. isActiveDDL.SelectedValue = (dr["IsActive"].ToString() == "True" || dr["IsActive"].ToString() == "1") ? "1" : "0";
  53. IsRealTimeDDL.SelectedValue = (dr["isRealTime"].ToString() == "True" || dr["isRealTime"].ToString() == "1") ? "1" : "0";
  54. minTxnLimit.Text = GetStatic.ShowDecimal(dr["minTxnLimit"].ToString());
  55. maxTxnLimit.Text = GetStatic.ShowDecimal(dr["maxTxnLimit"].ToString());
  56. ddlLimitCurrency.SelectedValue = dr["LimitCurrency"].ToString();
  57. exRateCalcByPartner.SelectedValue = (dr["exRateCalByPartner"].ToString() == "True" || dr["exRateCalByPartner"].ToString() == "1") ? "1" : "0";
  58. PopulatePayoutModeDDL(dr["PaymentMethod"].ToString());
  59. }
  60. protected void btnSave_Click(object sender, EventArgs e)
  61. {
  62. var tst1 = maxTxnLimit.Text.ToString();
  63. string flag = string.IsNullOrEmpty(GetId()) ? "i" : "u";
  64. var tst = minTxnLimit.Text;
  65. DbResult _dbRes = _apiDao.InsertUpdate(flag, partnerDDL.SelectedValue, countryDDL.SelectedValue, payoutMethodDDL.SelectedValue,
  66. isActiveDDL.SelectedValue, GetStatic.GetUser(), GetId(), IsRealTimeDDL.SelectedValue, minTxnLimit.Text.ToString(), maxTxnLimit.Text.ToString(), ddlLimitCurrency.SelectedValue, exRateCalcByPartner.SelectedValue, ddlActiveMobile.SelectedValue);
  67. if (_dbRes.ErrorCode != "0")
  68. {
  69. GetStatic.AlertMessage(this, _dbRes.Msg);
  70. }
  71. GetStatic.SetMessage(_dbRes);
  72. Response.Redirect("RouteApiPartners.aspx");
  73. }
  74. protected string GetId()
  75. {
  76. return GetStatic.ReadQueryString("id", "");
  77. }
  78. protected void countryDDL_SelectedIndexChanged(object sender, EventArgs e)
  79. {
  80. PopulatePayoutModeDDL();
  81. PopulateLimtCurrency();
  82. }
  83. private void PopulatePayoutModeDDL(string selectedValue = "")
  84. {
  85. string sql = "PROC_API_ROUTE_PARTNERS @flag='payout-method', @countryId = " + _sl.FilterString(countryDDL.SelectedValue);
  86. _sl.SetDDL(ref payoutMethodDDL, sql, "serviceTypeId", "typeTitle", selectedValue, "All");
  87. }
  88. private void PopulateLimtCurrency(string selectedValue = "")
  89. {
  90. string sql = "EXEC PROC_API_ROUTE_PARTNERS @flag='limit-currency', @countryId = " + _sl.FilterString(countryDDL.SelectedValue);
  91. _sl.SetDDL(ref ddlLimitCurrency, sql, "currencyCode", "currencyCode", selectedValue, "Select Limit Currency");
  92. }
  93. }
  94. }