市长热线演示版

pageritems.ashx.cs 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data;
  6. using HySoft.Common;
  7. namespace HySoft.BaseCallCenter.Web.askmanage.ajax
  8. {
  9. /// <summary>
  10. /// pageritems 的摘要说明
  11. /// </summary>
  12. public class pageritems : IHttpHandler
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. context.Response.ContentType = "text/plain";
  17. string action = CommonRequest.GetQueryString("action");
  18. switch (action)
  19. {
  20. case "getlist":
  21. context.Response.Write(LoadList(context));
  22. break;
  23. case "add":
  24. context.Response.Write(Add(context));
  25. break;
  26. case "addall":
  27. context.Response.Write(AddAll(context));
  28. break;
  29. case "modify":
  30. context.Response.Write(Modify(context));
  31. break;
  32. case "move":
  33. context.Response.Write(Move(context));
  34. break;
  35. case "delete":
  36. context.Response.Write(Delete(context));
  37. break;
  38. case "deleteall":
  39. context.Response.Write(DeleteAll(context));
  40. break;
  41. case "gettemplist":
  42. context.Response.Write(LoadTempList(context));
  43. break;
  44. case "addtemp":
  45. context.Response.Write(AddTemp(context));
  46. break;
  47. case "addalltemp":
  48. context.Response.Write(AddAllTemp(context));
  49. break;
  50. case "modifytemp":
  51. context.Response.Write(ModifyTemp(context));
  52. break;
  53. case "movetemp":
  54. context.Response.Write(MoveTemp(context));
  55. break;
  56. case "deletetemp":
  57. context.Response.Write(DeleteTemp(context));
  58. break;
  59. case "deletealltemp":
  60. context.Response.Write(DeleteAllTemp(context));
  61. break;
  62. }
  63. }
  64. #region 选项数据操作
  65. #region 获取数据
  66. private string LoadList(HttpContext context)
  67. {
  68. string res = "";
  69. DataTable dt = new DataTable();
  70. string sql = " ";
  71. try
  72. {
  73. string strpageindex = context.Request.Params["page"];
  74. int pageindex = 1;
  75. string strpagesize = context.Request.Params["pagesize"];
  76. int pagesize = 10;
  77. string questionid = "0";
  78. try
  79. {
  80. questionid = context.Request.Params["questionid"];
  81. if (questionid.Trim() != "")
  82. {
  83. sql = " and F_QuestionId=" + questionid + " ";
  84. }
  85. }
  86. catch
  87. { }
  88. if (strpageindex.Trim() != "")
  89. {
  90. try
  91. {
  92. pageindex = Convert.ToInt32(strpageindex);
  93. }
  94. catch
  95. { }
  96. }
  97. if (strpagesize.Trim() != "")
  98. {
  99. try
  100. {
  101. pagesize = Convert.ToInt32(strpagesize);
  102. }
  103. catch
  104. { }
  105. }
  106. int recordCount = 0;
  107. Model.PageData<Model.T_Ask_QuestionItems> pageModel = new Model.PageData<Model.T_Ask_QuestionItems>();
  108. dt = BLL.PagerBLL.GetListPager(
  109. "T_Ask_QuestionItems",
  110. "F_ItemId",
  111. "*",
  112. " " + sql,
  113. "ORDER BY F_Sort ",
  114. pagesize,
  115. pageindex,
  116. true,
  117. out recordCount);
  118. System.Collections.Generic.List<Model.T_Ask_QuestionItems> modelList = new BLL.T_Ask_QuestionItems().DataTableToList(dt);
  119. pageModel.Rows = modelList;
  120. pageModel.Total = recordCount;
  121. System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(Model.PageData<Model.T_Ask_QuestionItems>));
  122. using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
  123. {
  124. //JSON序列化
  125. serializer.WriteObject(stream, pageModel);
  126. res = System.Text.Encoding.UTF8.GetString(stream.ToArray());
  127. }
  128. }
  129. catch (Exception err)
  130. {
  131. //res = err.ToString();
  132. }
  133. finally
  134. {
  135. dt.Clear();
  136. dt.Dispose();
  137. }
  138. return res;
  139. }
  140. #endregion
  141. #region 添加数据
  142. private string Add(HttpContext context)
  143. {
  144. string res = "error";
  145. try
  146. {
  147. Model.T_Ask_PagerItems itemmodel = new Model.T_Ask_PagerItems();
  148. int pagerid = 0;
  149. try
  150. {
  151. pagerid = Convert.ToInt32(context.Request.Params["id"]);
  152. }
  153. catch
  154. { }
  155. itemmodel.F_PagerId = pagerid;
  156. int questionid = 0;
  157. try
  158. {
  159. questionid = Convert.ToInt32(context.Request.Params["questionid"]);
  160. }
  161. catch
  162. { }
  163. itemmodel.F_QuestionId = questionid;
  164. string sort = "0";
  165. try
  166. {
  167. sort = context.Request.Params["sort"];
  168. if (sort.Trim() != "")
  169. {
  170. itemmodel.F_Sort = Convert.ToInt32(sort) + 1;
  171. }
  172. }
  173. catch
  174. { }
  175. int itemid = new BLL.T_Ask_PagerItems().Add(itemmodel);
  176. if (itemid > 0)
  177. {
  178. res = "success";
  179. }
  180. }
  181. catch
  182. { }
  183. return res;
  184. }
  185. #endregion
  186. #region 批量添加数据
  187. private string AddAll(HttpContext context)
  188. {
  189. string res = "error";
  190. try
  191. {
  192. string arr = context.Request.Params["arrid"];
  193. string[] arrid = arr.Split(',');
  194. string sort = "0";
  195. int intsort = 0;
  196. try
  197. {
  198. sort = context.Request.Params["sort"];
  199. intsort = Convert.ToInt32(sort) + 1;
  200. }
  201. catch
  202. { }
  203. foreach (string squestionid in arrid)
  204. {
  205. Model.T_Ask_PagerItems model = new Model.T_Ask_PagerItems();
  206. int pagerid = 0;
  207. try
  208. {
  209. pagerid = Convert.ToInt32(context.Request.Params["id"]);
  210. }
  211. catch
  212. { }
  213. model.F_PagerId = pagerid;
  214. int questionid = 0;
  215. try
  216. {
  217. questionid = Convert.ToInt32(squestionid);
  218. }
  219. catch
  220. { }
  221. model.F_QuestionId = questionid;
  222. try
  223. {
  224. if (sort.Trim() != "")
  225. {
  226. model.F_Sort = intsort;
  227. intsort++;
  228. }
  229. }
  230. catch
  231. { }
  232. int i = new BLL.T_Ask_PagerItems().Add(model);
  233. if (i > 0)
  234. {
  235. res = "success";
  236. }
  237. }
  238. }
  239. catch
  240. { }
  241. return res;
  242. }
  243. #endregion
  244. #region 修改数据
  245. private string Modify(HttpContext context)
  246. {
  247. string res = "error";
  248. try
  249. {
  250. Model.T_Ask_PagerItems model = new BLL.T_Ask_PagerItems().GetModel(Convert.ToInt32(context.Request.Params["itemid"]));
  251. //model.F_ItemName = context.Request.Params["itemvalue"];
  252. if (new BLL.T_Ask_PagerItems().Update(model))
  253. {
  254. res = "success";
  255. }
  256. }
  257. catch
  258. { }
  259. return res;
  260. }
  261. #endregion
  262. #region 移动排序
  263. private string Move(HttpContext context)
  264. {
  265. string res = "error";
  266. DataTable dt = new DataTable();
  267. try
  268. {
  269. //"ajax/pageritems.ashx?action=" + optaction + "&pagerid=" + id + "&itemid=" + itemid + "&sort=" + ssort + "&movetype=" + type + "&timeno=" + timeno
  270. string sql = "";
  271. string order = "";
  272. int sort = Convert.ToInt32(context.Request.Params["sort"]);
  273. int itemid = Convert.ToInt32(context.Request.Params["itemid"]);
  274. int pagerid = Convert.ToInt32(context.Request.Params["pagerid"]);
  275. sql += " F_PagerId=" + pagerid + " ";
  276. int newsort = 0;
  277. int newitemid = 0;
  278. if (context.Request.Params["movetype"] == "-1")
  279. {
  280. sql += " and F_Sort<" + sort.ToString();
  281. order = " order by F_Sort desc";
  282. }
  283. else
  284. {
  285. sql += " and F_Sort>" + sort.ToString();
  286. order = " order by F_Sort ";
  287. }
  288. dt = new BLL.T_Ask_PagerItems().GetList(sql + " " + order).Tables[0];
  289. if (dt.Rows.Count > 0)
  290. {
  291. newitemid = Convert.ToInt32(dt.Rows[0]["F_ItemId"].ToString());
  292. newsort = Convert.ToInt32(dt.Rows[0]["F_Sort"].ToString());
  293. }
  294. Model.T_Ask_PagerItems newmodel = new BLL.T_Ask_PagerItems().GetModel(newitemid);
  295. newmodel.F_Sort = sort;
  296. if (new BLL.T_Ask_PagerItems().Update(newmodel))
  297. {
  298. res = "success";
  299. }
  300. Model.T_Ask_PagerItems model = new BLL.T_Ask_PagerItems().GetModel(itemid);
  301. model.F_Sort = newsort;
  302. if (new BLL.T_Ask_PagerItems().Update(model))
  303. {
  304. res = "success";
  305. }
  306. }
  307. catch
  308. { }
  309. finally
  310. {
  311. dt.Clear();
  312. dt.Dispose();
  313. }
  314. return res;
  315. }
  316. #endregion
  317. #region 删除数据
  318. private string Delete(HttpContext context)
  319. {
  320. string res = "error";
  321. try
  322. {
  323. if (new BLL.T_Ask_PagerItems().Delete(Convert.ToInt32(context.Request.Params["itemid"])))
  324. {
  325. res = "success";
  326. }
  327. }
  328. catch
  329. { }
  330. return res;
  331. }
  332. #endregion
  333. #region 批量删除数据
  334. private string DeleteAll(HttpContext context)
  335. {
  336. string res = "error";
  337. try
  338. {
  339. string arr = context.Request.Params["arrid"];
  340. string[] arrid = arr.Split(',');
  341. foreach (string itemid in arrid)
  342. {
  343. if (new BLL.T_Ask_PagerItems().Delete(Convert.ToInt32(itemid)))
  344. {
  345. res = "success";
  346. }
  347. }
  348. }
  349. catch
  350. { }
  351. return res;
  352. }
  353. #endregion
  354. #endregion
  355. #region 选项临时数据操作
  356. #region 获取临时数据
  357. private string LoadTempList(HttpContext context)
  358. {
  359. string res = "";
  360. return res;
  361. }
  362. #endregion
  363. #region 添加临时数据
  364. private string AddTemp(HttpContext context)
  365. {
  366. string res = "error";
  367. try
  368. {
  369. Model.T_Sys_TempItems model = new Model.T_Sys_TempItems();
  370. model.F_TempName = "T_Ask_PagerItems";
  371. string userid = "0";
  372. try
  373. {
  374. userid = context.Request.Params["userid"];
  375. if (userid.Trim() != "")
  376. {
  377. model.F_UserId = Convert.ToInt32(userid);
  378. }
  379. }
  380. catch
  381. { }
  382. string questionid = "0";
  383. try
  384. {
  385. questionid = context.Request.Params["questionid"];
  386. if (questionid.Trim() != "")
  387. {
  388. model.ExpandIntField1 = Convert.ToInt32(questionid);
  389. }
  390. }
  391. catch
  392. { }
  393. string sort = "0";
  394. try
  395. {
  396. sort = context.Request.Params["sort"];
  397. if (sort.Trim() != "")
  398. {
  399. model.ExpandIntField3 = Convert.ToInt32(sort) + 1;
  400. }
  401. }
  402. catch
  403. { }
  404. int i = new BLL.T_Sys_TempItems().Add(model);
  405. if (i > 0)
  406. {
  407. res = "success";
  408. }
  409. }
  410. catch
  411. { }
  412. return res;
  413. }
  414. #endregion
  415. #region 添加临时数据
  416. private string AddAllTemp(HttpContext context)
  417. {
  418. string res = "error";
  419. try
  420. {
  421. string arr = context.Request.Params["arrid"];
  422. string[] arrid = arr.Split(',');
  423. string sort = "0";
  424. int intsort = 0;
  425. try
  426. {
  427. sort = context.Request.Params["sort"];
  428. intsort = Convert.ToInt32(sort) + 1;
  429. }
  430. catch
  431. { }
  432. foreach (string questionid in arrid)
  433. {
  434. Model.T_Sys_TempItems model = new Model.T_Sys_TempItems();
  435. model.F_TempName = "T_Ask_PagerItems";
  436. string userid = "0";
  437. try
  438. {
  439. userid = context.Request.Params["userid"];
  440. if (userid.Trim() != "")
  441. {
  442. model.F_UserId = Convert.ToInt32(userid);
  443. }
  444. }
  445. catch
  446. { }
  447. try
  448. {
  449. model.ExpandIntField1 = Convert.ToInt32(questionid);
  450. }
  451. catch
  452. { }
  453. try
  454. {
  455. if (sort.Trim() != "")
  456. {
  457. model.ExpandIntField3 = intsort;
  458. intsort++;
  459. }
  460. }
  461. catch
  462. { }
  463. int i = new BLL.T_Sys_TempItems().Add(model);
  464. if (i > 0)
  465. {
  466. res = "success";
  467. }
  468. }
  469. }
  470. catch
  471. { }
  472. return res;
  473. }
  474. #endregion
  475. #region 修改临时数据
  476. private string ModifyTemp(HttpContext context)
  477. {
  478. string res = "error";
  479. try
  480. {
  481. Model.T_Sys_TempItems model = new BLL.T_Sys_TempItems().GetModel(Convert.ToInt32(context.Request.Params["itemid"]));
  482. model.ExpandVchField1 = context.Request.Params["itemvalue"];
  483. if (new BLL.T_Sys_TempItems().Update(model))
  484. {
  485. res = "success";
  486. }
  487. }
  488. catch
  489. { }
  490. return res;
  491. }
  492. #endregion
  493. #region 移动排序
  494. private string MoveTemp(HttpContext context)
  495. {
  496. string res = "error";
  497. DataTable dt = new DataTable();
  498. try
  499. {
  500. //ajax/questionitems.ashx?action=" + optaction + "&questionid=" + id + "&itemid=" + itemid+"&sort="+sort+"&movetype="+type
  501. string sql = "";
  502. string order = "";
  503. int sort = Convert.ToInt32(context.Request.Params["sort"]);
  504. int itemid = Convert.ToInt32(context.Request.Params["itemid"]);
  505. int newsort = 0;
  506. int newitemid = 0;
  507. if (context.Request.Params["movetype"] == "-1")
  508. {
  509. sql = " ExpandIntField3<" + sort.ToString();
  510. order = " order by ExpandIntField3 desc";
  511. }
  512. else
  513. {
  514. sql = " ExpandIntField3>" + sort.ToString();
  515. order = " order by ExpandIntField3 ";
  516. }
  517. dt = new BLL.T_Sys_TempItems().GetList(sql + " " + order).Tables[0];
  518. if (dt.Rows.Count > 0)
  519. {
  520. newitemid = Convert.ToInt32(dt.Rows[0]["F_Id"].ToString());
  521. newsort = Convert.ToInt32(dt.Rows[0]["ExpandIntField3"].ToString());
  522. }
  523. Model.T_Sys_TempItems newmodel = new BLL.T_Sys_TempItems().GetModel(newitemid);
  524. newmodel.ExpandIntField3 = sort;
  525. if (new BLL.T_Sys_TempItems().Update(newmodel))
  526. {
  527. res = "success";
  528. }
  529. Model.T_Sys_TempItems model = new BLL.T_Sys_TempItems().GetModel(itemid);
  530. model.ExpandIntField3 = newsort;
  531. if (new BLL.T_Sys_TempItems().Update(model))
  532. {
  533. res = "success";
  534. }
  535. }
  536. catch
  537. { }
  538. finally
  539. {
  540. dt.Clear();
  541. dt.Dispose();
  542. }
  543. return res;
  544. }
  545. #endregion
  546. #region 删除临时数据
  547. private string DeleteTemp(HttpContext context)
  548. {
  549. string res = "error";
  550. try
  551. {
  552. if (new BLL.T_Sys_TempItems().Delete(Convert.ToInt32(context.Request.Params["itemid"])))
  553. {
  554. res = "success";
  555. }
  556. }
  557. catch
  558. { }
  559. return res;
  560. }
  561. #endregion
  562. #region 删除临时数据
  563. private string DeleteAllTemp(HttpContext context)
  564. {
  565. string res = "error";
  566. try
  567. {
  568. string arr = context.Request.Params["arrid"];
  569. string[] arrid = arr.Split(',');
  570. foreach (string itemid in arrid)
  571. {
  572. if (new BLL.T_Sys_TempItems().Delete(Convert.ToInt32(itemid)))
  573. {
  574. res = "success";
  575. }
  576. }
  577. }
  578. catch
  579. { }
  580. return res;
  581. }
  582. #endregion
  583. #endregion
  584. public bool IsReusable
  585. {
  586. get
  587. {
  588. return false;
  589. }
  590. }
  591. }
  592. }