drsysparameter.ashx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <%@ WebHandler Language="C#" Class="drsysparameter" %>
  2. using System;
  3. using System.Web;
  4. using System.Web.SessionState;
  5. using System.Collections.Generic;
  6. using System.Collections.Specialized;
  7. using System.Data;
  8. using Curtain.DataAccess;
  9. using DK.XuWei.WebMes;
  10. /// <summary>
  11. /// T_MST_DR_SYSPARAMETER
  12. /// xuwei create 2020-02-08
  13. /// </summary>
  14. public class drsysparameter : IHttpHandler, IReadOnlySessionState
  15. {
  16. public void ProcessRequest(HttpContext context)
  17. {
  18. context.Response.ContentType = "text/plain";
  19. if (mes.LoginCheck() && context.Request["m"] is object)
  20. {
  21. Button b = new Button();
  22. if(mes.RightCheck("系统参数"))
  23. {
  24. b.btnIndex = true;
  25. b.btnInsert = true;
  26. b.btnInsertBatch = true;
  27. b.btnCopy = true;
  28. b.btnUpdate = true;
  29. b.btnDelete = true;
  30. b.btnCancel = true;
  31. b.btnSearch = true;
  32. b.btnDetail = true;
  33. b.btnCheckbox = true;
  34. b.btnExport = false;
  35. b.btnReload = true;
  36. };
  37. switch (context.Request["m"].ToString().ToLower())
  38. {
  39. case "b":
  40. {
  41. //按钮
  42. context.Response.Write(new JsonResult(b).ToJson());
  43. break;
  44. }
  45. case "a":
  46. {
  47. //添加
  48. if (b.btnDetail && context.Request["id"].ToString() != "")
  49. context.Response.Write(detail());
  50. else
  51. {
  52. xRecord r = new xRecord();
  53. context.Response.Write(new JsonResult(r).ToJson());
  54. }
  55. break;
  56. }
  57. case "s":
  58. {
  59. //搜索
  60. if (b.btnIndex)
  61. context.Response.Write(search(context.Request.Form));
  62. else
  63. context.Response.Write(new JsonResult(0).ToJson());
  64. break;
  65. }
  66. case "t":
  67. {
  68. //详细
  69. if (b.btnDetail)
  70. context.Response.Write(detail());
  71. else
  72. context.Response.Write(new JsonResult(0).ToJson());
  73. break;
  74. }
  75. case "i":
  76. {
  77. //插入
  78. if (b.btnInsert)
  79. context.Response.Write(insert(context.Request.Form));
  80. else
  81. context.Response.Write(new JsonResult(0).ToJson());
  82. break;
  83. }
  84. case "u":
  85. {
  86. //修改
  87. if (b.btnUpdate)
  88. context.Response.Write(update(context.Request.Form));
  89. else
  90. context.Response.Write(new JsonResult(0).ToJson());
  91. break;
  92. }
  93. case "d":
  94. {
  95. //删除
  96. if (b.btnDelete)
  97. context.Response.Write(delete());
  98. else
  99. context.Response.Write(new JsonResult(0).ToJson());
  100. break;
  101. }
  102. case "e":
  103. {
  104. //导出
  105. if (b.btnExport)
  106. {
  107. context.Response.Write(export());
  108. }
  109. else
  110. {
  111. context.Response.Write(new JsonResult(0).ToJson());
  112. }
  113. break;
  114. }
  115. default:
  116. {
  117. break;
  118. }
  119. }
  120. }
  121. else
  122. {
  123. context.Response.Write(new JsonResult(-1).ToJson());
  124. }
  125. }
  126. /// <summary>
  127. /// T_MST_DR_SYSPARAMETER 查询
  128. /// </summary>
  129. /// <returns>json</returns>
  130. private string search(NameValueCollection form)
  131. {
  132. using(IDataAccess conn=DataAccess.Create())
  133. {
  134. int page = HttpContext.Current.Request["page"] is object ? Convert.ToInt32(HttpContext.Current.Request["page"]) : 1;
  135. int rows = HttpContext.Current.Request["rows"] is object ? Convert.ToInt32(HttpContext.Current.Request["rows"]) : 10;
  136. string sort = HttpContext.Current.Request["sort"] is object ? HttpContext.Current.Request["sort"] : "";
  137. string order = HttpContext.Current.Request["order"] is object ? HttpContext.Current.Request["order"] : "";
  138. string sqlStr = @"
  139. SELECT
  140. m.PARAMETERID AS SID,
  141. m.PARAMETERID,
  142. m.PARAMETERCODE,
  143. m.PARAMETERNAME,
  144. m.PARAMETERTYPE,
  145. m.DISPLAYNO,
  146. m.FORMAT,
  147. m.REMARKS,
  148. m.VALUEFLAG,
  149. m.ACCOUNTID,
  150. m.CREATEUSERID,
  151. m.CREATETIME,
  152. m.UPDATEUSERID,
  153. m.UPDATETIME
  154. FROM
  155. T_MST_DR_SYSPARAMETER m
  156. WHERE
  157. m.VALUEFLAG = '1'
  158. AND m.ACCOUNTID = @ACCOUNTID@
  159. ";
  160. List<CDAParameter> sqlPara = new List<CDAParameter>();
  161. sqlPara.Add(new CDAParameter("ACCOUNTID", HttpContext.Current.Session["accountId"]));
  162. if(!string.IsNullOrEmpty(form["PARAMETERID"]))
  163. {
  164. sqlStr += " AND m.PARAMETERID = @PARAMETERID@ ";
  165. sqlPara.Add(new CDAParameter("PARAMETERID", form["PARAMETERID"]));
  166. }
  167. if(!string.IsNullOrEmpty(form["PARAMETERCODE"]))
  168. {
  169. sqlStr += " AND INSTR( m.PARAMETERCODE, @PARAMETERCODE@ ) > 0 ";
  170. sqlPara.Add(new CDAParameter("PARAMETERCODE", form["PARAMETERCODE"]));
  171. }
  172. if(!string.IsNullOrEmpty(form["PARAMETERNAME"]))
  173. {
  174. sqlStr += " AND INSTR( m.PARAMETERNAME, @PARAMETERNAME@ ) > 0 ";
  175. sqlPara.Add(new CDAParameter("PARAMETERNAME", form["PARAMETERNAME"]));
  176. }
  177. if(!string.IsNullOrEmpty(form["PARAMETERTYPE"]))
  178. {
  179. sqlStr += " AND INSTR( m.PARAMETERTYPE, @PARAMETERTYPE@ ) > 0 ";
  180. sqlPara.Add(new CDAParameter("PARAMETERTYPE", form["PARAMETERTYPE"]));
  181. }
  182. if(!string.IsNullOrEmpty(form["DISPLAYNO"]))
  183. {
  184. sqlStr += " AND INSTR( m.DISPLAYNO, @DISPLAYNO@ ) > 0 ";
  185. sqlPara.Add(new CDAParameter("DISPLAYNO", form["DISPLAYNO"]));
  186. }
  187. if(!string.IsNullOrEmpty(form["FORMAT"]))
  188. {
  189. sqlStr += " AND INSTR( m.FORMAT, @FORMAT@ ) > 0 ";
  190. sqlPara.Add(new CDAParameter("FORMAT", form["FORMAT"]));
  191. }
  192. if(!string.IsNullOrEmpty(form["REMARKS"]))
  193. {
  194. sqlStr += " AND INSTR( m.REMARKS, @REMARKS@ ) > 0 ";
  195. sqlPara.Add(new CDAParameter("REMARKS", form["REMARKS"]));
  196. }
  197. if(sort != "")
  198. {
  199. sqlStr += " ORDER BY " + sort + " " + order;
  200. }
  201. int total = 0;
  202. DataTable dt = conn.SelectPages(page, rows,out total, sqlStr, sqlPara.ToArray());
  203. return new JsonResult(dt) { total = total}.ToJson();
  204. }
  205. }
  206. /// <summary>
  207. /// 详细 T_MST_DR_SYSPARAMETER
  208. /// </summary>
  209. /// <returns>json</returns>
  210. private string detail()
  211. {
  212. using(IDataAccess conn= DataAccess.Create())
  213. {
  214. DataTable dt = conn.ExecuteDatatable(@"
  215. SELECT
  216. m.PARAMETERID,
  217. m.PARAMETERCODE,
  218. m.PARAMETERNAME,
  219. m.PARAMETERTYPE,
  220. m.DISPLAYNO,
  221. m.FORMAT,
  222. m.REMARKS,
  223. m.VALUEFLAG,
  224. m.ACCOUNTID,
  225. m.CREATEUSERID,
  226. m.CREATETIME,
  227. m.UPDATEUSERID,
  228. m.UPDATETIME
  229. FROM
  230. T_MST_DR_SYSPARAMETER m
  231. WHERE
  232. m.VALUEFLAG = '1'
  233. AND m.ACCOUNTID = @ACCOUNTID@
  234. AND m.PARAMETERID = @PARAMETERID@
  235. ",
  236. new CDAParameter("ACCOUNTID",HttpContext.Current.Session["accountId"]),
  237. new CDAParameter("PARAMETERID",HttpContext.Current.Request["id"])
  238. );
  239. return new JsonResult(dt).ToJson();
  240. }
  241. }
  242. /// <summary>
  243. /// 插入 T_MST_DR_SYSPARAMETER
  244. /// </summary>
  245. /// <returns>json</returns>
  246. private string insert(NameValueCollection form)
  247. {
  248. using(IDataAccess conn= DataAccess.Create())
  249. {
  250. string primaryKey = conn.GetSequenceNextval("SEQ_MST_DR_SYSPARAMETER_ID").ToString();
  251. int result = conn.ExecuteNonQuery(@"
  252. INSERT INTO T_MST_DR_SYSPARAMETER (
  253. PARAMETERID,
  254. PARAMETERCODE,
  255. PARAMETERNAME,
  256. PARAMETERTYPE,
  257. DISPLAYNO,
  258. FORMAT,
  259. REMARKS,
  260. ACCOUNTID,CREATEUSERID,UPDATEUSERID
  261. ) VALUES (
  262. @PARAMETERID@,
  263. @PARAMETERCODE@,
  264. @PARAMETERNAME@,
  265. @PARAMETERTYPE@,
  266. @DISPLAYNO@,
  267. @FORMAT@,
  268. @REMARKS@,
  269. @ACCOUNTID@,@CREATEUSERID@,@UPDATEUSERID@
  270. )
  271. ",
  272. new CDAParameter("PARAMETERID",primaryKey),
  273. new CDAParameter("PARAMETERCODE",form["PARAMETERCODE"]),
  274. new CDAParameter("PARAMETERNAME",form["PARAMETERNAME"]),
  275. new CDAParameter("PARAMETERTYPE",form["PARAMETERTYPE"]),
  276. new CDAParameter("DISPLAYNO",form["DISPLAYNO"]),
  277. new CDAParameter("FORMAT",form["FORMAT"]),
  278. new CDAParameter("REMARKS",form["REMARKS"]),
  279. new CDAParameter("ACCOUNTID",HttpContext.Current.Session["accountId"]),
  280. new CDAParameter("CREATEUSERID",HttpContext.Current.Session["userId"]),
  281. new CDAParameter("UPDATEUSERID",HttpContext.Current.Session["userId"])
  282. );
  283. return new JsonResult(1).ToJson();
  284. }
  285. }
  286. /// <summary>
  287. /// 更新 T_MST_DR_SYSPARAMETER
  288. /// </summary>
  289. /// <returns>json</returns>
  290. private string update(NameValueCollection form)
  291. {
  292. using(IDataAccess conn=DataAccess.Create())
  293. {
  294. int result = conn.ExecuteNonQuery(@"
  295. UPDATE T_MST_DR_SYSPARAMETER
  296. SET
  297. PARAMETERCODE = @PARAMETERCODE@,
  298. PARAMETERNAME = @PARAMETERNAME@,
  299. PARAMETERTYPE = @PARAMETERTYPE@,
  300. DISPLAYNO = @DISPLAYNO@,
  301. FORMAT = @FORMAT@,
  302. REMARKS = @REMARKS@,
  303. UPDATEUSERID = @UPDATEUSERID@,
  304. UPDATETIME = sysdate
  305. WHERE
  306. PARAMETERID = @PARAMETERID@
  307. ",
  308. new CDAParameter("PARAMETERCODE",form["PARAMETERCODE"]),
  309. new CDAParameter("PARAMETERNAME",form["PARAMETERNAME"]),
  310. new CDAParameter("PARAMETERTYPE",form["PARAMETERTYPE"]),
  311. new CDAParameter("DISPLAYNO",form["DISPLAYNO"]),
  312. new CDAParameter("FORMAT",form["FORMAT"]),
  313. new CDAParameter("REMARKS",form["REMARKS"]),
  314. new CDAParameter("UPDATEUSERID",HttpContext.Current.Session["userId"]),
  315. new CDAParameter("PARAMETERID",HttpContext.Current.Request["id"])
  316. );
  317. return new JsonResult(1).ToJson();
  318. }
  319. }
  320. /// <summary>
  321. /// 删除 T_MST_DR_SYSPARAMETER
  322. /// </summary>
  323. /// <returns>json</returns>
  324. private string delete()
  325. {
  326. using(IDataAccess conn= DataAccess.Create())
  327. {
  328. if (HttpContext.Current.Request["id"] is object)
  329. {
  330. int result = conn.ExecuteNonQuery(@"
  331. DELETE
  332. T_MST_DR_SYSPARAMETER
  333. WHERE
  334. INSTR(',' || @PARAMETERID@ || ',' , ',' || PARAMETERID || ',') > 0
  335. ",
  336. new CDAParameter("PARAMETERID", HttpContext.Current.Request["id"])
  337. );
  338. return new JsonResult(1).ToJson();
  339. }
  340. else
  341. {
  342. return new JsonResult(-2).ToJson();
  343. }
  344. }
  345. }
  346. /// <summary>
  347. /// 导出 T_MST_DR_SYSPARAMETER
  348. /// </summary>
  349. /// <returns>json</returns>
  350. private string export()
  351. {
  352. return search(new NameValueCollection());
  353. }
  354. private class Button
  355. {
  356. public bool btnIndex = false;
  357. public bool btnInsert = false;
  358. public bool btnInsertBatch = false;
  359. public bool btnCopy = false;
  360. public bool btnUpdate = false;
  361. public bool btnDelete = false;
  362. public bool btnCancel = false;
  363. public bool btnSearch = false;
  364. public bool btnDetail = false;
  365. public bool btnCheckbox = false;
  366. public bool btnExport = false;
  367. public bool btnReload = false;
  368. }
  369. private class xRecord
  370. {
  371. public string sid { get; set; }
  372. public string PARAMETERCODE { get; set; }
  373. public string PARAMETERNAME { get; set; }
  374. public string PARAMETERTYPE { get; set; }
  375. public string DISPLAYNO { get; set; }
  376. public string FORMAT { get; set; }
  377. public string REMARKS { get; set; }
  378. }
  379. public bool IsReusable
  380. {
  381. get
  382. {
  383. return false;
  384. }
  385. }
  386. }