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.

142 lines
5.5 KiB

  1. using Swift.DAL.Model;
  2. using Swift.DAL.Remittance.ReferralSetup;
  3. using Swift.web.Library;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. namespace Swift.web.Remit.ReferralSetup
  12. {
  13. public partial class CommisionRuleSetup : System.Web.UI.Page
  14. {
  15. RemittanceLibrary rl = new RemittanceLibrary();
  16. SwiftLibrary sl = new SwiftLibrary();
  17. private readonly ReferralSetupDao _refDao = new ReferralSetupDao();
  18. private string ViewFunctionId = "20201700";
  19. protected void Page_Load(object sender, EventArgs e)
  20. {
  21. Authenticate();
  22. if (!IsPostBack)
  23. {
  24. effectiveFrom.Text = DateTime.Now.ToString("yyyy-MM-dd");
  25. Misc.MakeNumericTextbox(ref commPercent);
  26. //Misc.MakeNumericTextbox(ref fxPercent);
  27. Misc.MakeNumericTextbox(ref flatTxnWise);
  28. //Misc.MakeNumericTextbox(ref newCustomer);
  29. //PopulateDdl();
  30. //if(EditOrNot() == "true")
  31. //{
  32. // partnerDDL.Enabled = false;
  33. //}
  34. if(GetRefId() != "")
  35. {
  36. PopulateData();
  37. }
  38. }
  39. }
  40. private void PopulateData()
  41. {
  42. try
  43. {
  44. DataRow res = _refDao.GetCommissionData(GetStatic.GetUser(), GetRefId(),GetPartnerId(), GetRowId());
  45. //partnerDDL.SelectedValue = res["PARTNER_ID"].ToString();
  46. commPercent.Text = res["COMM_PCNT"].ToString();
  47. //fxPercent.Text = res["FX_PCNT"].ToString();
  48. //applyFxPercentOn.Text = res["APPLY_FX_PERCENT_ON"].ToString();
  49. flatTxnWise.Text = res["FLAT_TXN_WISE"].ToString();
  50. //newCustomer.Text = res["NEW_CUSTOMER"].ToString();
  51. effectiveFrom.Text = res["EFFECTIVE_FROM"].ToString();
  52. isActive.SelectedValue = (bool.Parse(res["IS_ACTIVE"].ToString()) == false) ? "0" : "1";
  53. //deductPCommOnSc.SelectedValue = (bool.Parse(res["DEDUCT_P_COMM_ON_SC"].ToString()) == false) ? "0" : "1";
  54. //deductTaxOnSc.SelectedValue = (bool.Parse(res["DEDUCT_TAX_ON_SC"].ToString()) == false) ? "0" : "1";
  55. }
  56. catch (Exception ex)
  57. {
  58. GetStatic.AlertMessage(this.Page, ex.Message);
  59. }
  60. }
  61. private void Authenticate()
  62. {
  63. sl.CheckAuthentication(ViewFunctionId);
  64. }
  65. //private void PopulateDdl()
  66. //{
  67. // rl.SetDDL(ref partnerDDL, "EXEC PROC_API_ROUTE_PARTNERS @flag='partner'", "agentId", "agentName", "", "Select Partner");
  68. // //sl.SetDDL(ref partner,"Exec ")
  69. //}
  70. private string GetRefId()
  71. {
  72. return GetStatic.ReadQueryString("referral_id", "");
  73. }
  74. public string GetRefCode()
  75. {
  76. hdnReferralCode.Value = GetStatic.ReadQueryString("referralCode", "");
  77. return hdnReferralCode.Value;
  78. }
  79. private string GetPartnerId()
  80. {
  81. return GetStatic.ReadQueryString("partnerId", "");
  82. }
  83. private string EditOrNot()
  84. {
  85. return GetStatic.ReadQueryString("edit", "");
  86. }
  87. protected void save_Click(object sender, EventArgs e)
  88. {
  89. try
  90. {
  91. //string partner = partnerDDL.SelectedValue;
  92. string commissionPercent = commPercent.Text;
  93. //string forexPercent = fxPercent.Text;
  94. //string applyFxPercentOnValue = applyFxPercentOn.SelectedValue;
  95. string flatTransactionWise = flatTxnWise.Text;
  96. //string nCustomer = newCustomer.Text;
  97. string efrom = effectiveFrom.Text;
  98. string active = isActive.SelectedValue;
  99. //string deductTaxOnSC = deductTaxOnSc.SelectedValue;
  100. //string deductPCommOnSC = deductPCommOnSc.SelectedValue;
  101. //int a = GetRefId().ToString().ToInt();
  102. CommissionModel cm = new CommissionModel() {
  103. //PartnerId = partnerDDL.SelectedValue.ToInt(),
  104. CommissionPercent = commPercent.Text.ToDecimal(),
  105. //ForexPercent = fxPercent.Text.ToDecimal(),
  106. //ApplyFxPercentOn = applyFxPercentOnValue,
  107. FlatTxnWise = flatTxnWise.Text.ToDecimal(),
  108. //NewCustomer = newCustomer.Text.ToDecimal(),
  109. EffectiveFrom = DateTime.Parse(effectiveFrom.Text),
  110. isActive = isActive.SelectedValue,
  111. ReferralId = GetRefId(),
  112. ReferralCode = GetRefCode(),
  113. ROW_ID = GetRowId(),
  114. //deductTaxOnSC = deductTaxOnSC,
  115. //deductPCommOnSC = deductPCommOnSC
  116. };
  117. var res = _refDao.SaveCommissionData(GetStatic.GetUser(), cm,EditOrNot());
  118. GetStatic.SetMessage(res);
  119. string url = "CommissionRuleList.aspx?referralCode=" + GetRefCode() + "";
  120. Response.Redirect(url);
  121. }
  122. catch (Exception ex)
  123. {
  124. GetStatic.AlertMessage(this.Page, ex.Message);
  125. }
  126. }
  127. private string GetRowId()
  128. {
  129. return GetStatic.ReadQueryString("row_id", "");
  130. }
  131. }
  132. }