RoadFlow2.1 临时演示

GetNames_Table.ashx.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data;
  6. namespace WebForm.Controls.SelectDictionary
  7. {
  8. /// <summary>
  9. /// GetNames_Table 的摘要说明
  10. /// </summary>
  11. public class GetNames_Table : IHttpHandler
  12. {
  13. public void ProcessRequest(HttpContext context)
  14. {
  15. context.Response.ContentType = "text/plain";
  16. string dbconn = context.Request.QueryString["dbconn"];
  17. string dbtable = context.Request.QueryString["dbtable"];
  18. string valuefield = context.Request.QueryString["valuefield"];
  19. string titlefield = context.Request.QueryString["titlefield"];
  20. string parentfield = context.Request.QueryString["parentfield"];
  21. string where = context.Request.QueryString["where"];
  22. string values = context.Request.QueryString["values"] ?? "";
  23. RoadFlow.Platform.DBConnection bdbconn = new RoadFlow.Platform.DBConnection();
  24. var conn = bdbconn.Get(dbconn.ToGuid());
  25. System.Text.StringBuilder names = new System.Text.StringBuilder();
  26. foreach (string value in values.Split(','))
  27. {
  28. if (value.IsNullOrEmpty())
  29. {
  30. continue;
  31. }
  32. string sql = "select " + titlefield + " from " + dbtable + " where " + valuefield + "='" + value + "'";
  33. DataTable dt = bdbconn.GetDataTable(conn, sql.ReplaceSelectSql());
  34. if (dt.Rows.Count > 0)
  35. {
  36. names.Append(dt.Rows[0][0].ToString());
  37. names.Append(",");
  38. }
  39. }
  40. context.Response.Write(names.ToString().TrimEnd(','));
  41. }
  42. public bool IsReusable
  43. {
  44. get
  45. {
  46. return false;
  47. }
  48. }
  49. }
  50. }