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.

204 lines
7.5 KiB

  1. using Newtonsoft.Json;
  2. using Swift.DAL.APIDataMappingDao;
  3. using Swift.DAL.SwiftDAL;
  4. using Swift.web.Library;
  5. using System;
  6. using System.Data;
  7. using System.Text;
  8. namespace Swift.web.Remit.APIDataMapping.BankDataMapping
  9. {
  10. public partial class ShowMappedData : System.Web.UI.Page
  11. {
  12. protected APIMapping _dao = new APIMapping();
  13. private const string ViewFunctionId = "20201800";
  14. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. Authenticate();
  18. if (!IsPostBack)
  19. {
  20. //PopulateList();
  21. }
  22. GetStatic.PrintMessage(Page);
  23. PopulateList();
  24. string MethodName = Request.Form["MethodName"];
  25. switch (MethodName)
  26. {
  27. case "EditMappedData":
  28. SaveEditedData();
  29. break;
  30. case "RemoveMappedData":
  31. RemoveMappedData();
  32. break;
  33. }
  34. }
  35. private void Authenticate()
  36. {
  37. _sl.CheckAuthentication(ViewFunctionId);
  38. }
  39. public void PopulateList()
  40. {
  41. detailsLabel.Text = "Mapping for: " + GetPartnerName() + " >> " + GetStatic.ReadQueryString("countryName", "") + " >> " + GetStatic.ReadQueryString("paymentTypeName", "");
  42. DataTable dt = _dao.ShowMappedList(GetStatic.GetUser(), GetCountry(), GetPaymentMode(), GetPartner());
  43. if (null == dt || dt.Rows.Count == 0)
  44. {
  45. return;
  46. }
  47. string stringToSearch = "";
  48. string pattern = "";
  49. int pcnt = 0;
  50. bool res = false;
  51. string style = "";
  52. StringBuilder sb = new StringBuilder();
  53. foreach (DataRow item in dt.Rows)
  54. {
  55. stringToSearch = item["MASTER_BANK_NAME"].ToString().Replace(".", "");
  56. pattern = item["BANK_NAME"].ToString().Replace(".", "");
  57. res = FuzzyMatcher.FuzzyMatch(stringToSearch, pattern, out pcnt);
  58. string color = "";
  59. switch (pcnt > 0 && pcnt < 30 ? "1" :
  60. pcnt >= 30 && pcnt < 60 ? "2" :
  61. pcnt >= 60 && pcnt < 90 ? "3" :
  62. pcnt >= 90 ? "4" : "d")
  63. {
  64. case "1":
  65. color = "#ff935c";//orange
  66. break;
  67. case "2":
  68. color = "#f9e090";//yellow
  69. break;
  70. case "3":
  71. color = "#1b7fbd";//blue
  72. break;
  73. case "4":
  74. color = "#47e4bb";//green
  75. break;
  76. default:
  77. color = "#dc5353";//red
  78. break;
  79. }
  80. style = (!string.IsNullOrEmpty(color)) ? "style=\"background-color: " + color + "; color: white;\"" : "";
  81. sb.AppendLine("<tr " + style + ">");
  82. sb.AppendLine("<td>" + item["MASTER_BANK_NAME"].ToString() + "</td>");
  83. sb.AppendLine("<td>" + item["JME_BANK_CODE"].ToString() + "</td>");
  84. sb.AppendLine("<td>" + GetStatic.MakeAutoCompleteControlNew(item["JME_BANK_CODE"].ToString(), "'category' : 'remit-mapBankData'", item["BANK_CODE1"].ToString(), item["BANK_NAME"].ToString()) + "</td>");
  85. //sb.AppendLine("<td>" + item["BANK_NAME"].ToString() + "</td>");
  86. sb.AppendLine("<td>" + item["BANK_CODE1"].ToString() + "</td>");
  87. sb.AppendLine("<td><button class=\"btn btn-dark\" id='edit_" + item["JME_BANK_CODE"].ToString() + "' onclick=Editclicked('" + item["JME_BANK_CODE"].ToString() + "') >Edit</button>&nbsp;&nbsp;<button disabled onclick=\"SavedClicked('" + item["MASTER_BANK_ID"].ToString() + "','" + item["JME_BANK_CODE"].ToString() + "')\" class=\"btn btn-default\" id='save_" + item["JME_BANK_CODE"].ToString() + "'>Save</button>&nbsp;&nbsp;<button onclick=\"DeleteClicked('" + item["MASTER_BANK_ID"].ToString() + "','" + item["JME_BANK_CODE"].ToString() + "')\" class=\"btn btn-default\" id='delete_" + item["JME_BANK_CODE"].ToString() + "'>Remove Mapping</button></td>");
  88. sb.AppendLine("</tr>");
  89. }
  90. masterTableBody.InnerHtml = sb.ToString();
  91. }
  92. protected string GetCountry()
  93. {
  94. return GetStatic.ReadQueryString("country", "");
  95. }
  96. protected string GetPartner()
  97. {
  98. return GetStatic.ReadQueryString("partner", "");
  99. }
  100. protected string GetPartnerName()
  101. {
  102. return GetStatic.ReadQueryString("partnerName", "");
  103. }
  104. protected string GetCountryName()
  105. {
  106. return GetStatic.ReadQueryString("countryName", "");
  107. }
  108. protected string GetPaymentTypeName()
  109. {
  110. return GetStatic.ReadQueryString("paymentTypeName", "");
  111. }
  112. protected string GetPaymentMode()
  113. {
  114. return GetStatic.ReadQueryString("paymentType", "");
  115. }
  116. protected string GetNoOfRows()
  117. {
  118. return GetStatic.ReadQueryString("noOfBanksDDL", "");
  119. }
  120. protected void btnSaveMainTable_Click(object sender, EventArgs e)
  121. {
  122. DbResult _dbRes = _dao.SaveMainTable(GetStatic.GetUser(), GetCountry(), GetPaymentMode(), GetPartner());
  123. if (_dbRes.ErrorCode == "0")
  124. {
  125. PopulateList();
  126. GetStatic.AlertMessage(this, _dbRes.Msg);
  127. }
  128. else
  129. {
  130. GetStatic.AlertMessage(this, _dbRes.Msg);
  131. }
  132. }
  133. protected void SaveEditedData()
  134. {
  135. string rowId = Request.Form["hdnEditedRowNumber"];
  136. string countryName = Request.Form["countryName"];
  137. string paymentTypeId = Request.Form["paymentTypeId"];
  138. string apiPartner = Request.Form["apiPartner"];
  139. string changedBankId = Request.Form["changedBankId"];
  140. DbResult res = _dao.SaveEditedData(GetStatic.GetUser(), rowId, countryName, paymentTypeId, apiPartner, changedBankId);
  141. if (res.ErrorCode == "0")
  142. {
  143. PopulateList();
  144. GetStatic.AlertMessage(this, res.Msg);
  145. }
  146. else
  147. {
  148. GetStatic.AlertMessage(this, res.Msg);
  149. }
  150. Response.ContentType = "application/json";
  151. Response.Write(JsonConvert.SerializeObject(res));
  152. Response.End();
  153. }
  154. protected void RemoveMappedData()
  155. {
  156. string rowId = Request.Form["hdnEditedRowNumber"];
  157. string countryName = Request.Form["countryName"];
  158. string paymentTypeId = Request.Form["paymentTypeId"];
  159. string apiPartner = Request.Form["apiPartner"];
  160. string changedBankId = Request.Form["changedBankId"];
  161. DbResult res = _dao.RemoveEditedData(GetStatic.GetUser(), rowId, countryName, paymentTypeId, apiPartner, changedBankId);
  162. if (res.ErrorCode == "0")
  163. {
  164. PopulateList();
  165. GetStatic.AlertMessage(this, res.Msg);
  166. }
  167. else
  168. {
  169. GetStatic.AlertMessage(this, res.Msg);
  170. }
  171. Response.ContentType = "application/json";
  172. Response.Write(JsonConvert.SerializeObject(res));
  173. Response.End();
  174. }
  175. }
  176. }