| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using HySoft.Common;
- using System.Data;
- namespace HySoft.BaseCallCenter.Web.askmanage.ajax
- {
- /// <summary>
- /// questioncategory 的摘要说明
- /// </summary>
- public class questioncategory : IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- string action = CommonRequest.GetQueryString("action");
- switch (action)
- {
- case "getlist":
- context.Response.Write(LoadList(context));
- break;
- case "delete":
- context.Response.Write(DeleteById(context));
- break;
- }
- }
- #region 删除分类
- private string DeleteById(HttpContext context)
- {
- int res = 0;
- string str="error";
- DataTable dt = new DataTable();
- try
- {
- dt = new BLL.T_Ask_Question().GetList(" F_CategoryId=" + context.Request.Params["id"] + " ").Tables[0];
- res = dt.Rows.Count;
- if (res > 0)
- {
- str = res.ToString();
- }
- else
- {
- if (new BLL.T_Ask_QuestionCategory().Delete(Convert.ToInt32(context.Request.Params["id"])))
- {
- str = "success";
- }
- else
- {
- str = "error";
- }
- }
- }
- catch (Exception ex)
- {
- }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- return str;
- }
- #endregion
- #region 获取数据
- private string LoadList(HttpContext context)
- {
- string res = "";
- DataTable dt = new DataTable();
- string sql = " ";
- try
- {
- string strpageindex = context.Request.Params["page"];
- int pageindex = 1;
- string strpagesize = context.Request.Params["pagesize"];
- int pagesize = 10;
- if (strpageindex.Trim() != "")
- {
- try
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- catch
- { }
- }
- if (strpagesize.Trim() != "")
- {
- try
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- catch
- { }
- }
- int recordCount = 0;
- Model.PageData<Model.T_Ask_QuestionCategory> pageModel = new Model.PageData<Model.T_Ask_QuestionCategory>();
- dt = BLL.PagerBLL.GetListPager(
- "T_Ask_QuestionCategory",
- "F_CategoryId",
- "*",
- sql,
- "ORDER BY F_CategoryId desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- System.Collections.Generic.List<Model.T_Ask_QuestionCategory> modelList = new BLL.T_Ask_QuestionCategory().DataTableToList(dt);
- pageModel.Rows = modelList;
- pageModel.Total = recordCount;
- System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(Model.PageData<Model.T_Ask_QuestionCategory>));
- using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
- {
- //JSON序列化
- serializer.WriteObject(stream, pageModel);
- res = System.Text.Encoding.UTF8.GetString(stream.ToArray());
- }
- }
- catch (Exception err)
- {
- //res = err.ToString();
- }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- return res;
- }
- #endregion
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
- }
|