You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
306 lines
10 KiB
306 lines
10 KiB
11 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Web;
|
||
|
|
||
|
namespace FangYar.WebUI.ashx
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// DicDetailHandler 的摘要说明
|
||
|
/// </summary>
|
||
|
public class DicDetailHandler : IHttpHandler
|
||
|
{
|
||
|
|
||
|
private FangYar.BLL.TBL.SysDicdetailBLL bll = new BLL.TBL.SysDicdetailBLL();
|
||
|
private FangYar.BLL.ToTree_BLL blltree = new BLL.ToTree_BLL();
|
||
|
public void ProcessRequest(HttpContext context)
|
||
|
{
|
||
|
context.Response.ContentType = "text/json";
|
||
|
string action = context.Request.Params["Action"];
|
||
|
string returnstr = "";
|
||
|
switch (action)
|
||
|
{
|
||
|
case "List":
|
||
|
returnstr = GetModelList(context);
|
||
|
break;
|
||
|
case "Add":
|
||
|
returnstr = AddModel(context);
|
||
|
break;
|
||
|
case "Edit":
|
||
|
returnstr = EditModel(context);
|
||
|
break;
|
||
|
case "Del":
|
||
|
returnstr = DelModel(context);
|
||
|
break;
|
||
|
case "OrgTree":
|
||
|
returnstr = GetOrgTree(context);
|
||
|
break;
|
||
|
case "TreeList":
|
||
|
returnstr = GetModelByTree(context);
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
context.Response.Write(returnstr);
|
||
|
}
|
||
|
//查询
|
||
|
private string GetModelList(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string keywords = context.Request.Params["keywords"];
|
||
|
string limit = context.Request.Params["limit"];
|
||
|
string page = context.Request.Params["page"];
|
||
|
int pageIndex = 1;
|
||
|
int pageSize = 10;
|
||
|
if (!string.IsNullOrEmpty(limit)) { pageIndex = int.Parse(page); }
|
||
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
||
|
string where = null;
|
||
|
if (!string.IsNullOrEmpty(keywords))
|
||
|
{
|
||
|
where = "DIC_TEXT like '" + keywords + "' or DIC_VALUE like '" + keywords + "' order by DIC_ORDER";
|
||
|
}
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
||
|
int count = bll.Count(where);
|
||
|
returnstr += "\"count\":" + count + ",\"data\":";
|
||
|
if (count == 0)
|
||
|
{
|
||
|
returnstr += "[]";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
List<FangYar.Model.TBL.TBL_SYS_DICDETAIL_Model> list = bll.QueryList(pageIndex, pageSize, where, null);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
||
|
}
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
|
||
|
}
|
||
|
//添加
|
||
|
private string AddModel(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
int code = -1;
|
||
|
string msg = "";
|
||
|
try
|
||
|
{
|
||
|
string dicText = context.Request.Params["dicText"];
|
||
|
string dicValue = context.Request.Params["dicValue"];
|
||
|
string dicFID = context.Request.Params["dicFID"];
|
||
|
string dicOrder = context.Request.Params["dicOrder"];
|
||
|
string modCode = context.Request.Params["modCode"];
|
||
|
if (string.IsNullOrEmpty(dicText))
|
||
|
{
|
||
|
msg = "名称不能为空!";
|
||
|
}
|
||
|
|
||
|
else if (string.IsNullOrEmpty(dicValue))
|
||
|
{
|
||
|
msg = "值不能为空!";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
FangYar.Model.TBL.TBL_SYS_DICDETAIL_Model model = new Model.TBL.TBL_SYS_DICDETAIL_Model();
|
||
|
model.ID = Guid.NewGuid().ToString("N");
|
||
|
model.DIC_TEXT = dicText;
|
||
|
model.DIC_VALUE = dicValue;
|
||
|
model.DIC_FID = dicFID;
|
||
|
model.DIC_ORDER = dicOrder;
|
||
|
model.MOD_CODE = modCode;
|
||
|
if (bll.Add(model))
|
||
|
{
|
||
|
msg = "添加成功!";
|
||
|
code = 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
msg = "添加失败!";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "添加失败!";
|
||
|
}
|
||
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
//修改
|
||
|
private string EditModel(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
int code = -1;
|
||
|
string msg = "";
|
||
|
try
|
||
|
{
|
||
|
string ID = context.Request.Params["ID"];
|
||
|
string dicText = context.Request.Params["dicText"];
|
||
|
string dicValue = context.Request.Params["dicValue"];
|
||
|
string dicFID = context.Request.Params["dicFID"];
|
||
|
string dicOrder = context.Request.Params["dicOrder"];
|
||
|
string modCode = context.Request.Params["modCode"];
|
||
|
|
||
|
if (string.IsNullOrEmpty(dicText))
|
||
|
{
|
||
|
msg = "名称不能为空!";
|
||
|
}
|
||
|
|
||
|
else if (string.IsNullOrEmpty(dicValue))
|
||
|
{
|
||
|
msg = "值不能为空!";
|
||
|
}
|
||
|
|
||
|
else
|
||
|
{
|
||
|
|
||
|
FangYar.Model.TBL.TBL_SYS_DICDETAIL_Model model = bll.GetModelByID(ID);
|
||
|
if (model == null)
|
||
|
{
|
||
|
msg = "应用记录不存在!";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
model.DIC_TEXT = dicText;
|
||
|
model.DIC_VALUE = dicValue;
|
||
|
model.DIC_FID = dicFID;
|
||
|
model.DIC_ORDER = dicOrder;
|
||
|
model.MOD_CODE = modCode;
|
||
|
if (bll.Edit(model))
|
||
|
{
|
||
|
msg = "修改成功!";
|
||
|
code = 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
msg = "修改失败!";
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "修改失败!";
|
||
|
}
|
||
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
//删除
|
||
|
private string DelModel(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
int code = -1;
|
||
|
string msg = "";
|
||
|
try
|
||
|
{
|
||
|
string UIDList = context.Request.Params["UIDList"];
|
||
|
UIDList = UIDList.Replace(",", "','");
|
||
|
if (bll.Delete(UIDList))
|
||
|
{
|
||
|
msg = "删除成功!";
|
||
|
code = 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
msg = "删除失败!";
|
||
|
}
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "删除失败!";
|
||
|
}
|
||
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
//字典表机构树
|
||
|
private string GetOrgTree(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string treeid = context.Request.Params["treeid"];
|
||
|
|
||
|
|
||
|
string where = null;
|
||
|
if (!string.IsNullOrEmpty(treeid))
|
||
|
{
|
||
|
where = " MOD_CODE = " + treeid;
|
||
|
}
|
||
|
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
|
||
|
list = blltree.GetTree("MOD_CODE", "' '", "MOD_NAME", "TBL_SYS_DICMOD", where, list);
|
||
|
returnstr = "{\"data\":";
|
||
|
if (list.Count == 0)
|
||
|
{
|
||
|
returnstr += "[]";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
||
|
}
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"data\":[]}";
|
||
|
}
|
||
|
return returnstr;
|
||
|
|
||
|
}
|
||
|
//点击树查询
|
||
|
private string GetModelByTree(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string treeID = context.Request.Params["treeID"];
|
||
|
string limit = context.Request.Params["limit"];
|
||
|
string page = context.Request.Params["page"];
|
||
|
int pageIndex = 1;
|
||
|
int pageSize = 10;
|
||
|
if (!string.IsNullOrEmpty(limit)) { pageIndex = int.Parse(page); }
|
||
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
||
|
string where = null;
|
||
|
if (!string.IsNullOrEmpty(treeID))
|
||
|
{
|
||
|
where = "MOD_CODE='" + treeID + "' order by DIC_ORDER";
|
||
|
}
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
||
|
int count = bll.Count(where);
|
||
|
returnstr += "\"count\":" + count + ",\"data\":";
|
||
|
if (count == 0)
|
||
|
{
|
||
|
returnstr += "[]";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
List<FangYar.Model.TBL.TBL_SYS_DICDETAIL_Model> list = bll.QueryList(pageIndex, pageSize, where, null);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
||
|
}
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
|
||
|
|
||
|
}
|
||
|
public bool IsReusable
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|