getDefect.ashx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <%@ WebHandler Language="C#" Class="getDefect" %>
  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 getDefect : 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. D.DEFECTID,
  23. D.DEFECTCODE,
  24. D.DEFECTNAME,
  25. T.DEFECTTYPENAME || '_' || D.DEFECTNAME AS DEFECTFULLNAME
  26. FROM
  27. TP_MST_DEFECT D
  28. LEFT JOIN TP_MST_DEFECTTYPE T ON D.DEFECTTYPEID = T.DEFECTTYPEID
  29. WHERE
  30. t.DEFECTTYPEID > 0
  31. AND d.VALUEFLAG = '1'
  32. ORDER BY
  33. t.DISPLAYNO,
  34. d.DISPLAYNO
  35. ",
  36. new CDAParameter("ACCOUNTID", context.Session["accountId"])
  37. );
  38. DataRow dr = dt.NewRow();
  39. dr["DEFECTID"] = 0;
  40. dr["DEFECTCODE"] = "";
  41. dr["DEFECTNAME"] = "无";
  42. dr["DEFECTFULLNAME"] = "无";
  43. dt.Rows.InsertAt(dr,0);
  44. if (context.Request["select"] is object)
  45. context.Response.Write(dt.ToJson());
  46. else
  47. context.Response.Write(new JsonResult(dt).ToJson());
  48. }
  49. }
  50. public bool IsReusable
  51. {
  52. get
  53. {
  54. return false;
  55. }
  56. }
  57. }