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.

92 lines
3.3 KiB

  1. using Swift.DAL.SwiftDAL;
  2. using Swift.web.Library;
  3. using System;
  4. using System.Data;
  5. using System.Text;
  6. namespace Swift.web.AgentNew.SendOnBehalf
  7. {
  8. public partial class FormLoader : System.Web.UI.Page
  9. {
  10. private string _bankId = GetStatic.ReadQueryString("bankId", "");
  11. private string _isBranchByName = GetStatic.ReadQueryString("isBranchByName", "");
  12. private string _branchSelected = GetStatic.ReadQueryString("branchSelected", "");
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. ReturnValue();
  16. }
  17. private void ReturnValue()
  18. {
  19. switch (GetQueryType())
  20. {
  21. case "bb":
  22. PopulateBranchName();
  23. break;
  24. }
  25. }
  26. private string GetQueryType()
  27. {
  28. return GetStatic.ReadQueryString("type", "");
  29. }
  30. private void PopulateBranchName()
  31. {
  32. var dao = new RemittanceDao();
  33. var html = new StringBuilder();
  34. if (string.IsNullOrEmpty(_bankId) || _bankId == "undefined")
  35. {
  36. return;
  37. }
  38. var sql = "EXEC proc_dropDownLists @flag = 'pickBranchById', @agentId=" + dao.FilterString(_bankId);
  39. var dt = dao.ExecuteDataset(sql).Tables[0];
  40. if (dt == null || dt.Rows.Count == 0)
  41. {
  42. html.Append("<select id=\"branch\" class=\"form-control\"><option value = \"-1\">No Branches Found</option></select>");
  43. Response.Write(html.ToString());
  44. return;
  45. }
  46. html.Append("<select id=\"branch\" class=\"form-control\" >");
  47. html.Append("<option value = \"\">Select</option>");
  48. if (string.IsNullOrEmpty(_isBranchByName))
  49. {
  50. foreach (DataRow dr in dt.Rows)
  51. {
  52. html.Append("<option value = \"" + dr["agentId"] + "\">" + dr["agentName"] + "</option>");
  53. }
  54. }
  55. else
  56. {
  57. foreach (DataRow dr in dt.Rows)
  58. {
  59. if (_isBranchByName.ToUpper() == "Y")
  60. {
  61. if (_branchSelected.ToUpper() == dr["agentName"].ToString().ToUpper())
  62. {
  63. html.Append("<option value = \"" + dr["agentId"] + "\" selected=\"selected\">" + dr["agentName"] + "</option>");
  64. }
  65. else
  66. {
  67. html.Append("<option value = \"" + dr["agentId"] + "\">" + dr["agentName"] + "</option>");
  68. }
  69. }
  70. else
  71. {
  72. if (_branchSelected == dr["agentId"].ToString())
  73. {
  74. html.Append("<option value = \"" + dr["agentId"] + "\" selected=\"selected\">" + dr["agentName"] + "</option>");
  75. }
  76. else
  77. {
  78. html.Append("<option value = \"" + dr["agentId"] + "\">" + dr["agentName"] + "</option>");
  79. }
  80. }
  81. }
  82. }
  83. html.Append("</select>");
  84. Response.Write(html.ToString());
  85. }
  86. }
  87. }