getOrganization.ashx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <%@ WebHandler Language="C#" Class="getOrganization" %>
  2. using System;
  3. using System.Web;
  4. using System.Web.SessionState;
  5. using System.Data;
  6. using System.Text;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using Newtonsoft.Json;
  10. using Newtonsoft.Json.Linq;
  11. using Curtain.DataAccess;
  12. using DK.XuWei.WebMes;
  13. public class getOrganization : IHttpHandler, IReadOnlySessionState
  14. {
  15. public void ProcessRequest(HttpContext context)
  16. {
  17. context.Response.ContentType = "text/plain";
  18. using(IDataAccess conn = DataAccess.Create())
  19. {
  20. DataTable dt = conn.ExecuteDatatable(@"
  21. SELECT
  22. ORGANIZATIONID AS id,
  23. ORGANIZATIONCODE AS code,
  24. ORGANIZATIONNAME AS text,
  25. '' AS url
  26. FROM
  27. TP_MST_ORGANIZATION
  28. WHERE
  29. VALUEFLAG = '1'
  30. ORDER BY
  31. ORGANIZATIONCODE
  32. ");
  33. string rootId = dt.Rows[0]["id"].ToString();
  34. string rootCode = dt.Rows[0]["code"].ToString();
  35. string rootText = dt.Rows[0]["text"].ToString();
  36. string children = Easyui.TableToEasyUITree(dt, rootCode, 3);
  37. string jsonStr = "[{\"id\":\"" + rootId + "\",\"text\":\"" + rootText + "\"" + children + "}]";
  38. context.Response.Write(jsonStr);
  39. }
  40. }
  41. public bool IsReusable
  42. {
  43. get
  44. {
  45. return false;
  46. }
  47. }
  48. }