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.

386 lines
16 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. using Business.Configuration;
  2. using Business.Customer;
  3. using Common.Helper;
  4. using Common.Model.BankModel;
  5. using JMEAgentSystem.Library;
  6. using Newtonsoft.Json;
  7. using Repository.DAO;
  8. using Repository.DAO.SendTxnIRHDao;
  9. using Repository.Model;
  10. using Repository.ThirdPartyApiServices;
  11. using Swift.API.Common;
  12. using Swift.API.Common.ExRate;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Data;
  16. using System.Linq;
  17. using System.Web;
  18. using System.Web.Script.Serialization;
  19. using System.Web.UI;
  20. using System.Web.UI.WebControls;
  21. namespace JMEAgentSystem.WebPages.SendTxn
  22. {
  23. public partial class SendTxnRequest : System.Web.UI.Page
  24. {
  25. private readonly ICustomerServices _customerServices = AutoFacContainer.Resolve<ICustomerServices>();
  26. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  27. private readonly SendTxnIRHDao st = new SendTxnIRHDao();
  28. RemittanceDao _rdao = new RemittanceDao();
  29. protected void Page_Load(object sender, EventArgs e)
  30. {
  31. if (!IsPostBack)
  32. {
  33. try
  34. {
  35. GetStatic.PrintMessage(this.Page);
  36. populateDdl();
  37. var methodName = GetStatic.ReadFormData("MethodName", "");
  38. switch (methodName)
  39. {
  40. case "PaymentModePcountry":
  41. LoadDataFromDdl("pMode");
  42. break;
  43. case "loadAgentBank":
  44. LoadDataFromDdl("agentByPmode");
  45. break;
  46. case "getPayoutPartner":
  47. GetPayoutPartner();
  48. break;
  49. case "PopulateBranch":
  50. GetBankBranch();
  51. break;
  52. case "CalculateTxn":
  53. Calculate();
  54. break;
  55. case "loadCustomerDataSendPage":
  56. LoadCustomerDataSendPage();
  57. break;
  58. case "getBenefeciaryDetails":
  59. GetBenefeciaryDetails();
  60. break;
  61. }
  62. }
  63. catch (Exception ex)
  64. {
  65. }
  66. }
  67. }
  68. private void GetBenefeciaryDetails()
  69. {
  70. string benefeciaryId = Request.Form["BenefeciaryId"];
  71. if (string.IsNullOrWhiteSpace(benefeciaryId))
  72. {
  73. GetStatic.JsonResponse(new { errorCode = "1", Msg = "Invalid Receiver selected" }, this);
  74. }
  75. var receiverData = st.GetBenefeciaryDetails(GetStatic.GetUser(), benefeciaryId);
  76. Response.ContentType = "text/plain";
  77. var json = _rdao.DataTableToJson(receiverData);
  78. Response.Write(json);
  79. Response.End();
  80. }
  81. private void LoadCustomerDataSendPage()
  82. {
  83. string customerIdNumber = Request.Form["CustomerIdNumber"];
  84. if (string.IsNullOrWhiteSpace(customerIdNumber))
  85. {
  86. GetStatic.JsonResponse(new { errorCode = "1", Msg = "Customer ID Number can not be blak" }, this);
  87. }
  88. var receiverList = st.ValidateData(GetStatic.GetUser(), customerIdNumber);
  89. Response.ContentType = "text/plain";
  90. var json = _rdao.DataTableToJson(receiverList);
  91. Response.Write(json);
  92. Response.End();
  93. }
  94. public void populateDdl()
  95. {
  96. LoadReceiverCountry(ref pCountry, "", "SELECT");
  97. _sdd.SetDDL(ref relationship, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=2100", "valueId", "detailTitle", "", "Select..");
  98. _sdd.SetDDL(ref purpose, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3800", "valueId", "detailTitle", "8060", "Select..");
  99. }
  100. private void LoadDataFromDdl(string type)
  101. {
  102. var pAgentFv = Request.Form["pAgent"];
  103. var pModeFv = Request.Form["pmode"];
  104. var pCountryFv = Request.Form["pCountry"];
  105. DataTable dt = null;
  106. switch (type)
  107. {
  108. case "pMode":
  109. dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, GetStatic.GetAgent(), "recModeByCountry", GetStatic.GetUser());
  110. break;
  111. case "agentByPmode":
  112. if (string.IsNullOrWhiteSpace(pModeFv) || string.IsNullOrWhiteSpace(pCountryFv))
  113. {
  114. Response.Write(null);
  115. Response.End();
  116. return;
  117. }
  118. dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, GetStatic.GetAgent(), "recAgentByRecModeAjaxagent", GetStatic.GetUser());
  119. break;
  120. case "LoadScheme":
  121. dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, pAgentFv, "schemeBysCountryrAgent", GetStatic.GetUser());
  122. break;
  123. }
  124. Response.ContentType = "text/plain";
  125. var json = _rdao.DataTableToJson(dt);
  126. Response.Write(json);
  127. Response.End();
  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 GetPayoutPartner()
  135. {
  136. string pCountry = Request.Form["pCountry"];
  137. string pMode = Request.Form["pMode"];
  138. //var dt = st.LoadCustomerData(searchType, searchValue, "s", GetStatic.GetCountryId(), GetStatic.GetSettlingAgent());
  139. var dt = st.GetPayoutPartner(GetStatic.GetUser(), pCountry, pMode);
  140. if (dt == null)
  141. {
  142. Response.Write("");
  143. Response.End();
  144. return;
  145. }
  146. Response.ContentType = "text/plain";
  147. string json = DataTableToJson(dt);
  148. Response.Write(json);
  149. Response.End();
  150. }
  151. public static string DataTableToJson(DataTable table)
  152. {
  153. if (table == null)
  154. return "";
  155. var list = new List<Dictionary<string, object>>();
  156. foreach (DataRow row in table.Rows)
  157. {
  158. var dict = new Dictionary<string, object>();
  159. foreach (DataColumn col in table.Columns)
  160. {
  161. dict[col.ColumnName] = string.IsNullOrEmpty(row[col].ToString()) ? "" : row[col];
  162. }
  163. list.Add(dict);
  164. }
  165. var serializer = new JavaScriptSerializer();
  166. string json = serializer.Serialize(list);
  167. return json;
  168. }
  169. public string GetAPIPartnerId()
  170. {
  171. string partnerIds = GetStatic.ReadWebConfig("transfast", "") + "," + GetStatic.ReadWebConfig("jmeNepal", "") + "," + GetStatic.ReadWebConfig("donga", "");
  172. return partnerIds;
  173. }
  174. protected void GetBankBranch()
  175. {
  176. string bank = Request.Form["Bank"];
  177. string Country = Request.Form["Country"];
  178. string searchText = Request.Form["searchText"];
  179. string page = Request.Form["page"];
  180. if (string.IsNullOrWhiteSpace(bank))
  181. {
  182. GetStatic.JsonResponse("", this);
  183. }
  184. BankSearchModel bankSearchModel = new BankSearchModel()
  185. {
  186. SearchType = "",
  187. SearchValue = searchText,
  188. PAgent = bank,
  189. PAgentType = "I",
  190. PCountryName = Country,
  191. PayoutPartner = Request.Form["payoutPartner"],
  192. PaymentMode = Request.Form["PayMode"]
  193. };
  194. IList<BranchModel> bankModelList = st.LoadBranchByAgent(bankSearchModel);
  195. GetStatic.JsonResponse(bankModelList, this);
  196. //JsonSerialize(bankModelList);
  197. }
  198. protected void Calculate()
  199. {
  200. DataTable dt = new DataTable();
  201. ExRateRequest exRate = new ExRateRequest();
  202. ExchangeRateAPIService ExService = new ExchangeRateAPIService();
  203. exRate.RequestedBy = "core";
  204. string a = Request.Form["IsExrateFromPartner"];
  205. exRate.isExRateCalcByPartner = (Request.Form["IsExrateFromPartner"] == "true") ? true : false;
  206. exRate.PCountry = Request.Form["pCountry"];
  207. exRate.pCountryName = Request.Form["pCountrytxt"];
  208. exRate.ServiceType = Request.Form["pMode"];
  209. exRate.PaymentType = Request.Form["pModetxt"];
  210. exRate.PAgent = Request.Form["pAgent"];
  211. var pAgentBranch = Request.Form["pAgentBranch"];
  212. exRate.CAmount = Request.Form["collAmt"];
  213. exRate.PAmount = Request.Form["payAmt"];
  214. exRate.SCurrency = Request.Form["collCurr"];
  215. exRate.PCurrency = Request.Form["payCurr"];
  216. exRate.CustomerId = Request.Form["senderId"];
  217. exRate.SchemeId = Request.Form["schemeCode"];
  218. exRate.ForexSessionId = Request.Form["couponId"];
  219. exRate.IsManualSc = (Request.Form["isManualSc"] == "N" ? false : true);
  220. exRate.ManualSc = Request.Form["sc"];
  221. if (exRate.isExRateCalcByPartner)
  222. {
  223. exRate.SCountry = GetStatic.GetCountryId();
  224. exRate.SSuperAgent = GetStatic.GetSuperAgent();
  225. exRate.SAgent = GetStatic.GetAgent();
  226. exRate.SBranch = GetStatic.GetBranch();
  227. exRate.CollCurrency = Request.Form["collCurr"];
  228. exRate.pCountryCode = Request.Form["PCountryCode"];
  229. exRate.ProviderId = Request.Form["payoutPartner"];
  230. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":transfast:exRate";
  231. exRate.ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40);
  232. JsonResponse res = ExService.GetExchangeRate(exRate);
  233. ExRateResponse _exrate = (ExRateResponse)res.Data;
  234. //dt = st.GetExRateTP(GetStatic.GetUser()
  235. // , GetStatic.GetCountryId()
  236. // , GetStatic.GetSuperAgent()
  237. // , GetStatic.GetAgent()
  238. // , GetStatic.GetBranch()
  239. // , exRate.SCurrency
  240. // , exRate.PCountry
  241. // , exRate.PAgent
  242. // , exRate.PCurrency
  243. // , exRate.ServiceType
  244. // , exRate.CAmount
  245. // , exRate.PAmount
  246. // , exRate.SchemeId
  247. // , exRate.CustomerId
  248. // //, GetStatic.GetSessionId()
  249. // , exRate.ForexSessionId
  250. // , Request.Form["isManualSc"]
  251. // , exRate.ManualSc
  252. // , _exrate.exRate
  253. // , exRate.PCurrency
  254. // );
  255. }
  256. else
  257. {
  258. dt = st.GetExRate(GetStatic.GetUser()
  259. , GetStatic.GetCountryId()
  260. , "393877"
  261. , "394390"
  262. , "394390"
  263. , exRate.SCurrency
  264. , exRate.PCountry
  265. , exRate.PAgent
  266. , exRate.PCurrency
  267. , exRate.ServiceType
  268. , exRate.CAmount
  269. , exRate.PAmount
  270. , exRate.SchemeId
  271. , exRate.CustomerId
  272. //, GetStatic.GetSessionId()
  273. , exRate.ForexSessionId
  274. , "N"
  275. , "N"
  276. );
  277. }
  278. Response.ContentType = "text/plain";
  279. var json = DataTableToJson(dt);
  280. Response.Write(json);
  281. Response.End();
  282. }
  283. protected void Save_Click(object sender, EventArgs e)
  284. {
  285. var idNumber = senderIdNumber.Text;
  286. var receiverFullNameValue = receiverFullName.Text;
  287. var receiveraddressValue = receiveraddress.Text;
  288. var receiverMobileNumberValue = receiverMobileNumber.Text;
  289. var pCountryId = pCountry.SelectedValue;
  290. var pmodeId = hddPmode.Value;
  291. var pagentId = hddPagent.Value;
  292. var branchId = hddpBranch.Value;
  293. var accountnoValue = accountNo.Text;
  294. var cAmt = txtCollAmt.Text;
  295. var tamt = hddTamt.Value;
  296. var serviceCharge = hddServiceCharge.Value;
  297. var purposeOfRemittanceId = purpose.SelectedValue;
  298. var otherPurpose = purposeOther.Text;
  299. var relationShipId = relationship.SelectedValue;
  300. var otherRelation = otherRelationshipTextBox.Text;
  301. var referralNameValue = referralName.Text;
  302. SendTransactionModel sendTxn = new SendTransactionModel()
  303. {
  304. IdNumber = idNumber,
  305. ReceiverFullName = receiverFullNameValue,
  306. Receiveraddress = receiveraddressValue,
  307. ReceiverMobileNumber = receiverMobileNumberValue,
  308. PCountryId = pCountryId,
  309. PmodeId = pmodeId,
  310. PagentId = pagentId,
  311. BranchId = branchId,
  312. AccountNumber = accountnoValue,
  313. CAmt = cAmt,
  314. Tamt = tamt,
  315. ServiceCharge = serviceCharge,
  316. PurposeOfRemittance = purposeOfRemittanceId,
  317. OtherPurposeOfRemittance = otherPurpose,
  318. RelationShip = relationShipId,
  319. OtherRelationShip = otherRelation,
  320. ReferralName = referralNameValue,
  321. BranchManual = branch_manual.Text
  322. };
  323. var result = st.SaveSendRequest(GetStatic.GetUser(), sendTxn);
  324. if(result.ErrorCode == "0")
  325. {
  326. if (result.ErrorCode == "0" && !string.IsNullOrEmpty(hddImgURL.Value) && !string.IsNullOrWhiteSpace(hddImgURL.Value))
  327. {
  328. var res = _customerServices.GetCustomerDetailsForFileUpload(result.Extra.Split('|')[0]).Split('|');
  329. var customerId = res[0];
  330. var membershipId = res[1];
  331. var registerDate = res[2];
  332. string signatureName = GetStatic.UploadSignatureImage(hddImgURL.Value, registerDate, membershipId, customerId);
  333. if (signatureName != "1")
  334. {
  335. _customerServices.AddCustomerSignature(customerId, GetStatic.GetUser(), signatureName, "agent-upload-txn", result.Id);
  336. }
  337. }
  338. var url = ("PrintSendMoneyRequestDetails.aspx?customerId=" + result.Extra.Split('|')[1] + "&rowId=" + result.Id);
  339. Response.Redirect(url);
  340. }
  341. else
  342. {
  343. pCountry.SelectedValue = "";
  344. GetStatic.AlertMessage(this.Page, result.Msg);
  345. }
  346. }
  347. }
  348. }