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.

408 lines
17 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
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. case "PCurrPcountry":
  62. PCurrPcountry();
  63. break;
  64. }
  65. }
  66. catch (Exception ex)
  67. {
  68. }
  69. }
  70. }
  71. private void GetBenefeciaryDetails()
  72. {
  73. string benefeciaryId = Request.Form["BenefeciaryId"];
  74. if (string.IsNullOrWhiteSpace(benefeciaryId))
  75. {
  76. GetStatic.JsonResponse(new { errorCode = "1", Msg = "Invalid Receiver selected" }, this);
  77. }
  78. var receiverData = st.GetBenefeciaryDetails(GetStatic.GetUser(), benefeciaryId);
  79. Response.ContentType = "text/plain";
  80. var json = _rdao.DataTableToJson(receiverData);
  81. Response.Write(json);
  82. Response.End();
  83. }
  84. private void LoadCustomerDataSendPage()
  85. {
  86. string customerIdNumber = Request.Form["CustomerIdNumber"];
  87. if (string.IsNullOrWhiteSpace(customerIdNumber))
  88. {
  89. GetStatic.JsonResponse(new { errorCode = "1", Msg = "Customer ID Number can not be blak" }, this);
  90. }
  91. var receiverList = st.ValidateData(GetStatic.GetUser(), customerIdNumber);
  92. Response.ContentType = "text/plain";
  93. var json = _rdao.DataTableToJson(receiverList);
  94. Response.Write(json);
  95. Response.End();
  96. }
  97. public void populateDdl()
  98. {
  99. LoadReceiverCountry(ref pCountry, "", "SELECT");
  100. _sdd.SetDDL(ref relationship, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=2100", "valueId", "detailTitle", "", "Select..");
  101. _sdd.SetDDL(ref purpose, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3800", "valueId", "detailTitle", "8060", "Select..");
  102. }
  103. private void LoadDataFromDdl(string type)
  104. {
  105. var pAgentFv = Request.Form["pAgent"];
  106. var pModeFv = Request.Form["pmode"];
  107. var pCountryFv = Request.Form["pCountry"];
  108. DataTable dt = null;
  109. switch (type)
  110. {
  111. case "pMode":
  112. dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, GetStatic.GetAgent(), "recModeByCountry", GetStatic.GetUser());
  113. break;
  114. case "agentByPmode":
  115. if (string.IsNullOrWhiteSpace(pModeFv) || string.IsNullOrWhiteSpace(pCountryFv))
  116. {
  117. Response.Write(null);
  118. Response.End();
  119. return;
  120. }
  121. dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, GetStatic.GetAgent(), "recAgentByRecModeAjaxagent", GetStatic.GetUser());
  122. break;
  123. case "LoadScheme":
  124. dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, pAgentFv, "schemeBysCountryrAgent", GetStatic.GetUser());
  125. break;
  126. }
  127. Response.ContentType = "text/plain";
  128. var json = _rdao.DataTableToJson(dt);
  129. Response.Write(json);
  130. Response.End();
  131. }
  132. private void LoadReceiverCountry(ref DropDownList ddl, string defaultValue, string label)
  133. {
  134. var sql = "EXEC proc_sendPageLoadData @flag='pCountry',@countryId='" + GetStatic.GetCountryId() + "',@agentid='" + GetStatic.GetAgentId() + "'";
  135. _sdd.SetDDL(ref ddl, sql, "countryId", "countryName", defaultValue, label);
  136. }
  137. private void GetPayoutPartner()
  138. {
  139. string pCountry = Request.Form["pCountry"];
  140. string pMode = Request.Form["pMode"];
  141. //var dt = st.LoadCustomerData(searchType, searchValue, "s", GetStatic.GetCountryId(), GetStatic.GetSettlingAgent());
  142. var dt = st.GetPayoutPartner(GetStatic.GetUser(), pCountry, pMode);
  143. if (dt == null)
  144. {
  145. Response.Write("");
  146. Response.End();
  147. return;
  148. }
  149. Response.ContentType = "text/plain";
  150. string json = DataTableToJson(dt);
  151. Response.Write(json);
  152. Response.End();
  153. }
  154. public static string DataTableToJson(DataTable table)
  155. {
  156. if (table == null)
  157. return "";
  158. var list = new List<Dictionary<string, object>>();
  159. foreach (DataRow row in table.Rows)
  160. {
  161. var dict = new Dictionary<string, object>();
  162. foreach (DataColumn col in table.Columns)
  163. {
  164. dict[col.ColumnName] = string.IsNullOrEmpty(row[col].ToString()) ? "" : row[col];
  165. }
  166. list.Add(dict);
  167. }
  168. var serializer = new JavaScriptSerializer();
  169. string json = serializer.Serialize(list);
  170. return json;
  171. }
  172. public string GetAPIPartnerId()
  173. {
  174. string partnerIds = GetStatic.ReadWebConfig("transfast", "") + "," + GetStatic.ReadWebConfig("jmeNepal", "") + "," + GetStatic.ReadWebConfig("donga", "");
  175. return partnerIds;
  176. }
  177. protected void GetBankBranch()
  178. {
  179. string bank = Request.Form["Bank"];
  180. string Country = Request.Form["Country"];
  181. string searchText = Request.Form["searchText"];
  182. string page = Request.Form["page"];
  183. if (string.IsNullOrWhiteSpace(bank))
  184. {
  185. GetStatic.JsonResponse("", this);
  186. }
  187. BankSearchModel bankSearchModel = new BankSearchModel()
  188. {
  189. SearchType = "",
  190. SearchValue = searchText,
  191. PAgent = bank,
  192. PAgentType = "I",
  193. PCountryName = Country,
  194. PayoutPartner = Request.Form["payoutPartner"],
  195. PaymentMode = Request.Form["PayMode"]
  196. };
  197. IList<BranchModel> bankModelList = st.LoadBranchByAgent(bankSearchModel);
  198. GetStatic.JsonResponse(bankModelList, this);
  199. //JsonSerialize(bankModelList);
  200. }
  201. protected void Calculate()
  202. {
  203. DataTable dt = new DataTable();
  204. ExRateRequest exRate = new ExRateRequest();
  205. ExchangeRateAPIService ExService = new ExchangeRateAPIService();
  206. exRate.RequestedBy = "core";
  207. string a = Request.Form["IsExrateFromPartner"];
  208. exRate.isExRateCalcByPartner = (Request.Form["IsExrateFromPartner"] == "true") ? true : false;
  209. exRate.PCountry = Request.Form["pCountry"];
  210. exRate.pCountryName = Request.Form["pCountrytxt"];
  211. exRate.ServiceType = Request.Form["pMode"];
  212. exRate.PaymentType = Request.Form["pModetxt"];
  213. exRate.PAgent = Request.Form["pAgent"];
  214. exRate.PAgentId = Request.Form["pAgent"];
  215. var pAgentBranch = Request.Form["pAgentBranch"];
  216. exRate.CAmount = Request.Form["collAmt"];
  217. exRate.PAmount = Request.Form["payAmt"];
  218. exRate.SCurrency = Request.Form["collCurr"];
  219. exRate.PCurrency = Request.Form["payCurr"];
  220. exRate.CustomerId = Request.Form["senderId"];
  221. exRate.SchemeId = Request.Form["schemeCode"];
  222. exRate.ForexSessionId = Request.Form["couponId"];
  223. exRate.IsManualSc = (Request.Form["isManualSc"] == "N" ? false : true);
  224. exRate.ManualSc = Request.Form["sc"];
  225. if (exRate.isExRateCalcByPartner)
  226. {
  227. exRate.SCountry = GetStatic.GetCountryId();
  228. exRate.SSuperAgent = GetStatic.GetSuperAgent();
  229. exRate.SAgent = GetStatic.GetAgent();
  230. exRate.SBranch = GetStatic.GetBranch();
  231. exRate.CollCurrency = Request.Form["collCurr"];
  232. exRate.pCountryCode = Request.Form["PCountryCode"];
  233. exRate.ProviderId = Request.Form["payoutPartner"];
  234. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":transfast:exRate";
  235. exRate.ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40);
  236. JsonResponse res = ExService.GetExchangeRate(exRate);
  237. ExRateResponse _exrate = (ExRateResponse)res.Data;
  238. dt = st.GetExRateTP(GetStatic.GetUser()
  239. , GetStatic.GetCountryId()
  240. , "393877"
  241. , GetStatic.GetAgent()
  242. , "394389"
  243. , exRate.SCurrency
  244. , exRate.PCountry
  245. , exRate.PAgent
  246. , exRate.PCurrency
  247. , exRate.ServiceType
  248. , exRate.CAmount
  249. , exRate.PAmount
  250. , exRate.SchemeId
  251. , exRate.CustomerId
  252. , GetStatic.GetSessionId()
  253. , exRate.ForexSessionId
  254. , Request.Form["isManualSc"]
  255. , exRate.ManualSc
  256. , _exrate.exRate
  257. , exRate.PCurrency
  258. , exRate.CalcBy
  259. );
  260. }
  261. else
  262. {
  263. dt = st.GetExRate(GetStatic.GetUser()
  264. , GetStatic.GetCountryId()
  265. , "393877"
  266. , "394390"
  267. , "394390"
  268. , exRate.SCurrency
  269. , exRate.PCountry
  270. , exRate.PAgent
  271. , exRate.PCurrency
  272. , exRate.ServiceType
  273. , exRate.CAmount
  274. , exRate.PAmount
  275. , exRate.SchemeId
  276. , exRate.CustomerId
  277. //, GetStatic.GetSessionId()
  278. , exRate.ForexSessionId
  279. , "N"
  280. , "N"
  281. );
  282. }
  283. Response.ContentType = "text/plain";
  284. var json = DataTableToJson(dt);
  285. Response.Write(json);
  286. Response.End();
  287. }
  288. protected void Save_Click(object sender, EventArgs e)
  289. {
  290. var idNumber = senderIdNumber.Text;
  291. var receiverFullNameValue = receiverFullName.Text;
  292. var receiveraddressValue = receiveraddress.Text;
  293. var receiverMobileNumberValue = receiverMobileNumber.Text;
  294. var pCountryId = pCountry.SelectedValue;
  295. var pmodeId = hddPmode.Value;
  296. var pagentId = hddPagent.Value;
  297. var branchId = hddpBranch.Value;
  298. var accountnoValue = accountNo.Text;
  299. var cAmt = txtCollAmt.Text;
  300. var tamt = hddTamt.Value;
  301. var serviceCharge = hddServiceCharge.Value;
  302. var purposeOfRemittanceId = purpose.SelectedValue;
  303. var otherPurpose = purposeOther.Text;
  304. var relationShipId = relationship.SelectedValue;
  305. var otherRelation = otherRelationshipTextBox.Text;
  306. var referralNameValue = referralName.Text;
  307. var collectionMode = ddlCollMode.SelectedValue;
  308. SendTransactionModel sendTxn = new SendTransactionModel()
  309. {
  310. IdNumber = idNumber,
  311. ReceiverFullName = receiverFullNameValue,
  312. Receiveraddress = receiveraddressValue,
  313. ReceiverMobileNumber = receiverMobileNumberValue,
  314. PCountryId = pCountryId,
  315. PmodeId = pmodeId,
  316. PagentId = pagentId,
  317. BranchId = branchId,
  318. AccountNumber = accountnoValue,
  319. CAmt = cAmt,
  320. Tamt = tamt,
  321. ServiceCharge = serviceCharge,
  322. PurposeOfRemittance = purposeOfRemittanceId,
  323. OtherPurposeOfRemittance = otherPurpose,
  324. RelationShip = relationShipId,
  325. OtherRelationShip = otherRelation,
  326. ReferralName = referralNameValue,
  327. BranchManual = branch_manual.Text,
  328. bankName = hddPagentName.Value,
  329. branchName = hddPBranchName.Value,
  330. collMode = collectionMode
  331. };
  332. var result = st.SaveSendRequest(GetStatic.GetUser(), sendTxn);
  333. if (result.ErrorCode == "0")
  334. {
  335. if (result.ErrorCode == "0" && !string.IsNullOrEmpty(hddImgURL.Value) && !string.IsNullOrWhiteSpace(hddImgURL.Value))
  336. {
  337. var res = _customerServices.GetCustomerDetailsForFileUpload(result.Extra.Split('|')[0]).Split('|');
  338. var customerId = res[0];
  339. var membershipId = res[1];
  340. var registerDate = res[2];
  341. string signatureName = GetStatic.UploadSignatureImage(hddImgURL.Value, registerDate, membershipId, customerId);
  342. if (signatureName != "1")
  343. {
  344. _customerServices.AddCustomerSignature(customerId, GetStatic.GetUser(), signatureName
  345. , "Staff Visit - Send Txn(Customer Signature)", result.Id);
  346. }
  347. }
  348. var url = ("PrintSendMoneyRequestDetails.aspx?customerId=" + result.Extra.Split('|')[1] + "&rowId=" + result.Id);
  349. Response.Redirect(url);
  350. }
  351. else
  352. {
  353. pCountry.SelectedValue = "";
  354. GetStatic.AlertMessage(this.Page, result.Msg);
  355. }
  356. }
  357. private void PCurrPcountry()
  358. {
  359. string pCountry = Request.Form["pCountry"];
  360. string pMode = Request.Form["pMode"];
  361. string pAgent = Request.Form["pAgent"];
  362. DataTable Dt = st.LoadPayCurr(pCountry, pMode, pAgent);
  363. Response.ContentType = "text/plain";
  364. string json = DataTableToJson(Dt);
  365. Response.Write(json);
  366. Response.End();
  367. }
  368. }
  369. }