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.

120 lines
3.9 KiB

4 years ago
  1. using Repository.DAO.Application;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Web;
  8. using System.Web.Services;
  9. namespace JMEAgentSystem.Component.AutoComplete
  10. {
  11. /// <summary>
  12. /// Summary description for DataSource
  13. /// </summary>
  14. [WebService(Namespace = "http://tempuri.org/")]
  15. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  16. [System.ComponentModel.ToolboxItem(false)]
  17. // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
  18. // [System.Web.Script.Services.ScriptService]
  19. public class DataSource : System.Web.Services.WebService
  20. {
  21. private bool isRemit = false;
  22. [WebMethod]
  23. public List<ValueTextPair> GetList(string category, string searchText)
  24. {
  25. return MakeList(category, "", "", "", searchText);
  26. }
  27. [WebMethod]
  28. public List<ValueTextPair> GetRemittanceList(string category, string searchText)
  29. {
  30. isRemit = true;
  31. return MakeList(category, "", "", "", searchText);
  32. }
  33. [WebMethod]
  34. public List<ValueTextPair> GetList1(string category, string param1, string searchText)
  35. {
  36. return MakeList(category, param1, "", "", searchText);
  37. }
  38. [WebMethod]
  39. public List<ValueTextPair> GetList2(string category, string param1, string param2, string searchText)
  40. {
  41. return MakeList(category, param1, param2, "", searchText);
  42. }
  43. [WebMethod]
  44. public List<ValueTextPair> GetList3(string category, string param1, string param2, string param3, string searchText)
  45. {
  46. return MakeList(category, param1, param2, param3, searchText);
  47. }
  48. private List<ValueTextPair> MakeList(string category, string param1, string param2, string param3, string searchText)
  49. {
  50. var itemList = new List<ValueTextPair>();
  51. var db = new ApplicationDAO();
  52. StringBuilder sb = new StringBuilder("eXEC proc_autocomplete @category=" + db.FilterString(category));
  53. sb.AppendLine(", @searchText=" + db.FilterString(searchText));
  54. if (!string.IsNullOrWhiteSpace(param1))
  55. {
  56. sb.AppendLine(", @param1=" + db.FilterString(param1));
  57. }
  58. if (!string.IsNullOrWhiteSpace(param2))
  59. {
  60. sb.AppendLine(", @param2=" + db.FilterString(param2));
  61. }
  62. if (!string.IsNullOrWhiteSpace(param3))
  63. {
  64. sb.AppendLine(", @param3=" + db.FilterString(param3));
  65. }
  66. var dt = new DataTable();
  67. string cat = category.Split('-')[0];
  68. if (cat.ToLower() == "remit")
  69. {
  70. sb = sb.Replace("remit-", "");
  71. dt = db.ExecuteDataset(sb).Tables[0];
  72. }
  73. else
  74. dt = db.ExecuteDataset(sb).Tables[0];
  75. //if (category == "acInfo" || category == "acInfoUSD")
  76. // dt = db.ExecuteDataset(sql).Tables[0];
  77. //else
  78. // dt = dbremit.ExecuteDataset(sql).Tables[0];
  79. foreach (DataRow row in dt.Rows)
  80. {
  81. itemList.Add(new ValueTextPair(row[0].ToString(), row[1].ToString()));
  82. }
  83. if (dt.Rows.Count == 0 && param1 == "NotClear")
  84. {
  85. itemList.Add(new ValueTextPair(searchText, searchText));
  86. }
  87. return itemList;
  88. }
  89. }
  90. public class ValueTextPair
  91. {
  92. public string Id;
  93. public string Value;
  94. public ValueTextPair(string id, string value)
  95. {
  96. Id = id;
  97. Value = value;
  98. }
  99. public ValueTextPair()
  100. {
  101. }
  102. }
  103. }