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.

94 lines
3.2 KiB

  1. using Newtonsoft.Json;
  2. using Swift.DAL.APIDataMappingDao;
  3. using Swift.web.Library;
  4. using System;
  5. using System.Data;
  6. using System.Text;
  7. using System.Web.UI.WebControls;
  8. namespace Swift.web.Remit.APIDataMapping.BankDataMapping
  9. {
  10. public partial class Continue : System.Web.UI.Page
  11. {
  12. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  13. protected APIMapping _dao = new APIMapping();
  14. private const string ViewFunctionId = "20201800";
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. Authenticate();
  18. if (!IsPostBack)
  19. {
  20. PopulateDDL();
  21. }
  22. string methodName = Request.Form["MethodName"];
  23. switch (methodName)
  24. {
  25. case "GetMasterBankList":
  26. GetMasterBankList();
  27. break;
  28. }
  29. }
  30. private void Authenticate()
  31. {
  32. _sl.CheckAuthentication(ViewFunctionId);
  33. }
  34. private void PopulateDDL()
  35. {
  36. _sl.SetDDL(ref partnerDDL, "PROC_MAP_BANK_DATA @FLAG = 'PARTNER'", "AGENTID", "AGENTNAME", "", "Select Partner");
  37. _sl.SetDDL(ref countryDDL, "PROC_MAP_BANK_DATA @FLAG = 'COUNTRY'", "COUNTRYCODE", "COUNTRYNAME", "", "Select Country");
  38. }
  39. protected void countryDDL_SelectedIndexChanged(object sender, EventArgs e)
  40. {
  41. PopulatePayoutMode(countryDDL.SelectedValue, ref payoutMethodDDL);
  42. }
  43. private void PopulatePayoutMode(string selectedValue, ref DropDownList ddl)
  44. {
  45. if (string.IsNullOrEmpty(selectedValue))
  46. {
  47. ddl.Items.Clear();
  48. return;
  49. }
  50. string sql = "PROC_MAP_BANK_DATA @flag='PAYOUT-MODE', @COUNTRY_CODE = " + _sl.FilterString(selectedValue);
  51. _sl.SetDDL(ref ddl, sql, "serviceTypeId", "typeTitle", selectedValue, "Select Paymet Mode");
  52. }
  53. protected void GetMasterBankList()
  54. {
  55. DataSet ds = _dao.GetMasterBankList(GetStatic.GetUser());
  56. var result = GenerateTable(ds);
  57. Response.ContentType = "text/plain";
  58. Response.Write(JsonConvert.SerializeObject(result).ToString());
  59. Response.End();
  60. }
  61. private string GenerateTable(DataSet result)
  62. {
  63. var sb = new StringBuilder("");
  64. foreach (DataRow item in result.Tables[0].Rows)
  65. {
  66. DataRow[] rows = result.Tables[0].Select("BANK_NAME = ('" + item["BANK_NAME"].ToString() + "')");
  67. GetRows(rows, ref sb);
  68. }
  69. return sb.ToString();
  70. }
  71. private void GetRows(DataRow[] rows, ref StringBuilder sb)
  72. {
  73. if (rows.Length == 0 || rows == null)
  74. {
  75. sb.AppendLine("<tr><td colspan='4' align='center'>No data to Display!</td></tr>");
  76. }
  77. foreach (DataRow item in rows)
  78. {
  79. sb.AppendLine("<tr>");
  80. sb.AppendLine("<td>" + item["SN"].ToString() + "</td>");
  81. sb.AppendLine("<td>" + item["BANK_NAME"].ToString() + "</td>");
  82. sb.AppendLine("</tr>");
  83. }
  84. }
  85. }
  86. }