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.

170 lines
6.5 KiB

4 years ago
  1. using Common.Helper;
  2. using JMEAgentSystem.Library;
  3. using Repository.DAO;
  4. using Repository.DAO.SendTxnIRHDao;
  5. using Repository.ThirdPartyApiServices;
  6. using Swift.API.Common;
  7. using Swift.API.Common.ExRate;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Linq;
  12. using System.Web;
  13. using System.Web.Script.Serialization;
  14. using System.Web.UI;
  15. using System.Web.UI.WebControls;
  16. namespace JMEAgentSystem.WebPages.Calculator
  17. {
  18. public partial class Calculator : System.Web.UI.Page
  19. {
  20. private readonly SendTxnIRHDao st = new SendTxnIRHDao();
  21. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  22. RemittanceDao _rdao = new RemittanceDao();
  23. protected void Page_Load(object sender, EventArgs e)
  24. {
  25. populateDdl();
  26. var methodName = GetStatic.ReadFormData("MethodName", "");
  27. if (methodName != "")
  28. {
  29. switch (methodName)
  30. {
  31. case "PaymentModePcountry":
  32. LoadDataFromDdl("pMode");
  33. break;
  34. case "CalculateTxn":
  35. Calculate();
  36. break;
  37. }
  38. }
  39. }
  40. protected void Calculate()
  41. {
  42. DataTable dt = new DataTable();
  43. ExRateRequest exRate = new ExRateRequest();
  44. ExchangeRateAPIService ExService = new ExchangeRateAPIService();
  45. exRate.RequestedBy = "core";
  46. exRate.isExRateCalcByPartner = (Request.Form["IsExrateFromPartner"] == "true") ? true : false;
  47. //exRate.isExRateCalcByPartner = true;
  48. exRate.PCountry = Request.Form["pCountry"];
  49. exRate.pCountryName = Request.Form["pCountrytxt"];
  50. exRate.ServiceType = Request.Form["pMode"];
  51. exRate.PaymentType = Request.Form["pModetxt"];
  52. exRate.PAgent = Request.Form["pAgent"];
  53. var pAgentBranch = Request.Form["pAgentBranch"];
  54. exRate.CAmount = Request.Form["collAmt"];
  55. exRate.PAmount = Request.Form["payAmt"];
  56. exRate.SCurrency = Request.Form["collCurr"];
  57. exRate.PCurrency = Request.Form["payCurr"];
  58. exRate.CustomerId = Request.Form["senderId"];
  59. exRate.SchemeId = Request.Form["schemeCode"];
  60. exRate.ForexSessionId = Request.Form["couponId"];
  61. exRate.IsManualSc = (Request.Form["isManualSc"] == "N" ? false : true);
  62. exRate.ManualSc = Request.Form["sc"];
  63. if (exRate.isExRateCalcByPartner)
  64. {
  65. exRate.SCountry = GetStatic.GetCountryId();
  66. exRate.SSuperAgent = "393877";
  67. exRate.SAgent = "394390";
  68. exRate.SBranch = "394390";
  69. exRate.CollCurrency = Request.Form["collCurr"];
  70. exRate.pCountryCode = Request.Form["pCountry"];
  71. exRate.ProviderId = "394130";
  72. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":transfast:exRate";
  73. exRate.ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40);
  74. JsonResponse res = ExService.GetExchangeRate(exRate);
  75. ExRateResponse _exrate = (ExRateResponse)res.Data;
  76. //dt = st.GetExRateTP(GetStatic.GetUser()
  77. // , GetStatic.GetCountryId()
  78. // , GetStatic.GetSuperAgent()
  79. // , GetStatic.GetAgent()
  80. // , GetStatic.GetBranch()
  81. // , exRate.SCurrency
  82. // , exRate.PCountry
  83. // , exRate.PAgent
  84. // , exRate.PCurrency
  85. // , exRate.ServiceType
  86. // , exRate.CAmount
  87. // , exRate.PAmount
  88. // , exRate.SchemeId
  89. // , exRate.CustomerId
  90. // //, GetStatic.GetSessionId()
  91. // , exRate.ForexSessionId
  92. // , Request.Form["isManualSc"]
  93. // , exRate.ManualSc
  94. // , _exrate.exRate
  95. // , exRate.PCurrency
  96. // );
  97. }
  98. else
  99. {
  100. dt = st.GetExRate(GetStatic.GetUser()
  101. , GetStatic.GetCountryId()
  102. , "393877"
  103. , "394390"
  104. , "394390"
  105. , exRate.SCurrency
  106. , exRate.PCountry
  107. , exRate.PAgent
  108. , exRate.PCurrency
  109. , exRate.ServiceType
  110. , exRate.CAmount
  111. , exRate.PAmount
  112. , exRate.SchemeId
  113. , exRate.CustomerId
  114. //, GetStatic.GetSessionId()
  115. , exRate.ForexSessionId
  116. , "N"
  117. , "N"
  118. );
  119. }
  120. Response.ContentType = "text/plain";
  121. var json = _rdao.DataTableToJson(dt);
  122. Response.Write(json);
  123. Response.End();
  124. }
  125. public void populateDdl()
  126. {
  127. LoadReceiverCountry(ref pCountry, "", "SELECT");
  128. }
  129. private void LoadReceiverCountry(ref DropDownList ddl, string defaultValue, string label)
  130. {
  131. var sql = "EXEC proc_sendPageLoadData @flag='pCountry',@countryId='" + GetStatic.GetCountryId() + "',@agentid='" + GetStatic.GetAgentId() + "'";
  132. _sdd.SetDDL(ref ddl, sql, "countryId", "countryName", defaultValue, label);
  133. }
  134. private void LoadDataFromDdl(string type)
  135. {
  136. var pAgentFv = Request.Form["pAgent"];
  137. var pModeFv = Request.Form["pmode"];
  138. var pCountryFv = Request.Form["pCountry"];
  139. DataTable dt = null;
  140. switch (type)
  141. {
  142. case "pMode":
  143. dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, GetStatic.GetAgent(), "recModeByCountry", GetStatic.GetUser());
  144. break;
  145. }
  146. Response.ContentType = "text/plain";
  147. var json = _rdao.DataTableToJson(dt);
  148. Response.Write(json);
  149. Response.End();
  150. }
  151. }
  152. }