软测单独项目
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.
 
 
 
 
 
 

329 lines
12 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// SysEmpPolHandler 的摘要说明
/// </summary>
public class SysEmpPolHandler : IHttpHandler
{
BLL.TBL.TBL_SYS_EMP_POLBLL bLL = new BLL.TBL.TBL_SYS_EMP_POLBLL();
private FangYar.BLL.TBL.SysEmpBLL bll_Emp = new FangYar.BLL.TBL.SysEmpBLL();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string action = context.Request.Params["Action"];
string returnstr = "";
switch (action)
{
case "List":
returnstr = List(context);
break;
case "SetPol":
returnstr = SetPol(context);
break;
case "OrgEmpList":
returnstr = GetOrgEmpList(context);
break;
case "PolLevelList":
returnstr = PolLevelList(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string List(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
string keyword = context.Request.Params["keywords"];
string type = context.Request.Params["type"];
string page = context.Request.Params["page"];
string limit = context.Request.Params["limit"];
int pageIndex = 1;
int pageSize = 10;
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
string where = "1=1";
if (!string.IsNullOrEmpty(OrgId))
{
where += " and ORG_ID = '" + OrgId + "'";
}
if (!string.IsNullOrEmpty(keyword))
{
if (where != null)
{
where += " and ";
}
where += "( mtitle like '%" + keyword + "%' or mADDR like '%" + keyword + "%')";
}
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = 0;
List<FangYar.Model.TBL_SYS_EMP_POL> list = bLL.PageList(pageIndex, pageSize, where, " mdate desc", ref count);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch (Exception ex)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
}
return returnstr;
}
//查询
private string GetOrgEmpList(HttpContext context)
{
//VIEW_SYS_EMP_POL
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
string OrgList = context.Request.Params["OrgList"];
string keyword = context.Request.Params["keywords"];
string treeID = context.Request.Params["treeID"];
string type = context.Request.Params["type"];
string page = context.Request.Params["page"];
string limit = context.Request.Params["limit"];
string searchTime = context.Request.Params["searchTime"];
string searchAccess = context.Request.Params["searchAccess"];
string is_content = context.Request.Params["is_content"];
int pageIndex = 1;
int pageSize = 10;
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
string where = null;
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
{
if (is_content == "1")
{
where = "( org_id in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids) ) ";
where += " or DEPT_ID in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids))) ";
}
else
{
where = "( ORG_ID = '" + treeID + "'";
where += " or DEPT_ID = '" + treeID + "')";
}
}
else
{
if (is_content == "1")
{
where = " (orgid in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids)) ";
where += " or DEPT_ID in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids))) ";
}
else
{
where = "(ORGID = '" + OrgId + "'";
where += " or DEPT_ID = '" + OrgId + "')";
}
}
if (!string.IsNullOrEmpty(keyword))
{
if (where != null)
{
where += " and ";
}
where += "( emp_name like '%" + keyword + "%' or idnumber like '%" + keyword + "%')";
}
if (!string.IsNullOrEmpty(searchTime))
{
string startTime = "", endTime = "";
if (searchTime.IndexOf(" - ") != -1)
{
startTime = Regex.Split(searchTime, " - ", RegexOptions.IgnoreCase)[0];
endTime = Regex.Split(searchTime, " - ", RegexOptions.IgnoreCase)[1];
}
if (!string.IsNullOrEmpty(startTime))
{
if (where != null)
{
where += " and ";
}
where += "ENLISTED_TIME >= '" + startTime + "'";
}
if (!string.IsNullOrEmpty(endTime))
{
if (where != null)
{
where += " and ";
}
where += "ENLISTED_TIME <= '" + endTime + "'";
}
}
if (!string.IsNullOrEmpty(searchAccess))
{
if (where != null)
{
where += " and ";
}
where += "IS_ACCESS = '" + searchAccess + "'";
}
if (where != null)
{
where += " and ";
}
where += " is_del = '0'";
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = 0;
List<FangYar.Model.VIEW_SYS_EMP_POL> list = bLL.PageListVIEW(pageIndex, pageSize, where, " PNEXTTIME desc", ref count);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch (Exception ex)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
}
return returnstr;
}
private string PolLevelList(HttpContext context)
{
string returnstr = "";
try
{
string type = context.Request.Params["type"];
returnstr = "{\"code\":0,\"msg\":\"\",";
List<FangYar.Model.TBL_SYS_POLLEVEL> list = bLL.PageListPOLLEVEL("1=1", "PNOWLLEVEL asc");
returnstr += "\"data\":";
returnstr += FangYar.Common.JsonHelper.ToJson(list);
returnstr += "}";
}
catch (Exception ex)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
}
return returnstr;
}
//修改
private string SetPol(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string id = context.Request.Params["id"];//
string orgid = context.Request.Params["orgid"];//
string puid = context.Request.Params["puid"];//
string puname = context.Request.Params["puname"];//
string pn1 = context.Request.Params["pn1"];//
string pn2 = context.Request.Params["pn2"];//
string pt1 = context.Request.Params["pt1"]; //
string pt2 = context.Request.Params["pt2"]; //
string pt3 = context.Request.Params["pt3"]; //
string plv1 = context.Request.Params["plv1"];//
string plv2 = context.Request.Params["plv2"];//
string ptype = context.Request.Params["ptype"];//
FangYar.Model.TBL_SYS_EMP_POL model;
bool ifadd = true;
if (string.IsNullOrEmpty(id))
{
model = new Model.TBL_SYS_EMP_POL();
model.ID = Guid.NewGuid().ToString("N");//
}
else
{
model = bLL.GetModelByID(id);
if (model != null)
{
ifadd = false;
}
else
{
model = new Model.TBL_SYS_EMP_POL();
model.ID = Guid.NewGuid().ToString("N");//
}
}
model.PUID = puid;
model.PUNAME = puname;
model.ORG_ID = orgid;
model.PTYPE = ptype;
model.PNOWNAME = pn1;
model.PNOWTIME = DateTime.Parse(pt1);
model.PNOWLLEVEL = plv1;
model.PNEXTNAME = pn2;
model.PNEXTLLEVEL = plv2;
model.PNEXTTIME = DateTime.Parse(pt2);
model.PREMINDTIME = DateTime.Parse(pt3);
model.A_TIME = DateTime.Now;
var isset = false;
if (ifadd)
{
isset = bLL.Add(model);
}
else
{
isset = bLL.Edit(model);
}
if (isset)
{
//更改员工表
//var gis = bLL_Common.Update<FangYar.Model.TBL.TBL_SYS_EMP>(new { POL = model.PNOWLLEVEL.ToString() }, it => it.ID == puid);
var umo = bll_Emp.UPDPOLByID(model.PNOWLLEVEL, puid);
msg = "设置成功!";
code = 1;
}
else { msg = "设置失败!"; }
}
catch (Exception e)
{
msg = "设置失败!";
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}