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.
257 lines
8.6 KiB
257 lines
8.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// SysEmpOutHandler 的摘要说明
|
|
/// </summary>
|
|
public class SysEmpOutHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL();
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "人员退出操作请求", "");
|
|
|
|
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
//机构树
|
|
case "GetOrgEmpOutList":
|
|
returnstr = GetOrgEmpList(context);
|
|
break;
|
|
//批量删除
|
|
case "Del":
|
|
returnstr = DelOrgEmp(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
|
|
}
|
|
|
|
|
|
//查询
|
|
private string GetOrgEmpList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
//是否查询包含管理员账号数据
|
|
string is_admin = context.Request.Params["is_admin"];
|
|
//是否查询删除人员数据
|
|
string is_DelQueyr = context.Request.Params["is_DelQueyr"] + "";
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
|
|
pageIndex = pageIndex < 1 ? 1 : pageIndex;
|
|
|
|
int startIndex = (pageIndex - 1) * pageSize;
|
|
|
|
|
|
string sqlStr = @"
|
|
WITH t1 as(
|
|
SELECT e.*,o.ORG_NAME old_ORG_NAME from tbl_sys_emp_exit_log e LEFT JOIN fire_org o on e.old_org_id=o.ORG_ID
|
|
)
|
|
SELECT t1.CREATETIME ExitTime,t1.Exit_Remark,t1.old_ORG_NAME,e.* from tbl_sys_emp e LEFT JOIN t1 on e.USERS_UID=t1.USERS_UID
|
|
WHERE e.ORG_ID ='" + OrgId + "' ";
|
|
|
|
if (string.IsNullOrWhiteSpace(is_DelQueyr))
|
|
{
|
|
sqlStr += " and IS_DEL='0' ";
|
|
}
|
|
else
|
|
{
|
|
if (is_DelQueyr == "1")
|
|
{
|
|
sqlStr += " and IS_DEL='1' ";
|
|
}
|
|
else
|
|
{
|
|
sqlStr += " and IS_DEL='0' ";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
sqlStr += " and ( e.EMP_NAME like '%" + keyword + "%' or e.USERS_UID like '%" + keyword + "%' or e.EMP_MOBILE like '%" + keyword + "%') ";
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(is_admin))
|
|
{
|
|
|
|
if (is_admin == "1")
|
|
{
|
|
sqlStr += " and IS_ADMIN='1' ";
|
|
}
|
|
else
|
|
{
|
|
sqlStr += " and IS_ADMIN='0' ";
|
|
}
|
|
}
|
|
|
|
sqlStr += @" ORDER BY e.EMP_NAME LIMIT " + startIndex + ", " + pageSize;
|
|
|
|
var dt1 = FangYar.Common.MySqlHelper.QueryTable(sqlStr);
|
|
|
|
sqlStr = @"
|
|
WITH t1 as(
|
|
SELECT e.*,o.ORG_NAME old_ORG_NAME from tbl_sys_emp_exit_log e LEFT JOIN fire_org o on e.old_org_id=o.ORG_ID
|
|
)
|
|
SELECT count(1) from tbl_sys_emp e LEFT JOIN t1 on e.USERS_UID=t1.USERS_UID
|
|
WHERE e.ORG_ID ='" + OrgId + "' ";
|
|
|
|
if (string.IsNullOrWhiteSpace(is_DelQueyr))
|
|
{
|
|
sqlStr += " and IS_DEL='0' ";
|
|
}
|
|
else
|
|
{
|
|
if (is_DelQueyr == "1")
|
|
{
|
|
sqlStr += " and IS_DEL='1' ";
|
|
}
|
|
else
|
|
{
|
|
sqlStr += " and IS_DEL='0' ";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
sqlStr += " and ( e.EMP_NAME like '%" + keyword + "%' or e.USERS_UID like '%" + keyword + "%' or e.EMP_MOBILE like '%" + keyword + "%') ";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(is_admin))
|
|
{
|
|
|
|
if (is_admin == "1")
|
|
{
|
|
sqlStr += " and IS_ADMIN='1' ";
|
|
}
|
|
else
|
|
{
|
|
sqlStr += " and IS_ADMIN='0' ";
|
|
}
|
|
}
|
|
|
|
sqlStr += @" ORDER BY e.EMP_NAME ";
|
|
|
|
var dt2 = FangYar.Common.MySqlHelper.QueryTable(sqlStr);
|
|
|
|
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
returnstr += "\"count\":" + dt2.Rows[0][0] + ",\"data\":";
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt1);
|
|
returnstr += "}";
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除人员
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string DelOrgEmp(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string delempdvc = "";
|
|
try
|
|
{
|
|
string EmpList = context.Request.Params["EmpList"];
|
|
string UserUid = context.Request.Params["UserUid"];
|
|
string EmpNos = context.Request.Params["EmpNos"];
|
|
string[] EmpArray = EmpList.Split(',');
|
|
string EmpListString = "";
|
|
for (int i = 0; i < EmpArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
EmpListString = "'" + EmpArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
EmpListString += ",'" + EmpArray[i] + "'";
|
|
}
|
|
}
|
|
|
|
string[] UidArray = UserUid.Split(',');
|
|
string UserUidString = "";
|
|
for (int i = 0; i < UidArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
UserUidString = "'" + UidArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
UserUidString += ",'" + UidArray[i] + "'";
|
|
}
|
|
}
|
|
|
|
|
|
if (bll.DelEmp(EmpListString, UserUidString))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员退出操作请求", "删除异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"delempdvc\":\"" + delempdvc + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "人员退出操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|