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.
546 lines
20 KiB
546 lines
20 KiB
11 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Web;
|
||
|
using System.Data;
|
||
|
using System.Text;
|
||
|
using System.Collections;
|
||
|
using System.Reflection;
|
||
|
using System.Web.Script.Serialization;
|
||
|
using FangYar.Model;
|
||
|
using FangYar.BLL;
|
||
|
|
||
|
namespace FangYar.WebUI.ashx
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// OaLeaveHandler 的摘要说明
|
||
|
/// </summary>
|
||
|
public class ZYSysEmpHandler : IHttpHandler
|
||
|
{
|
||
|
private FangYar.BLL.TBL.SysEmpBLL bll = 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 "OrgDeptTree":
|
||
|
returnstr = GetOrgDeptTree(context);
|
||
|
break;
|
||
|
case "OrgDeptTree2":
|
||
|
returnstr = GetOrgDeptTree2(context);
|
||
|
break;
|
||
|
case "getUseruId":
|
||
|
returnstr = GetUseruId(context);
|
||
|
break;
|
||
|
case "OrgEmpList":
|
||
|
returnstr = GetOrgEmpList(context);
|
||
|
break;
|
||
|
case "Add":
|
||
|
returnstr = AddOrgEmp(context);
|
||
|
break;
|
||
|
case "Edit":
|
||
|
returnstr = EditOrgEmp(context);
|
||
|
break;
|
||
|
case "GetEmpByUID":
|
||
|
returnstr = GetEmpByUID(context);
|
||
|
break;
|
||
|
//case "Del":
|
||
|
// returnstr = DelOrgEmp(context);
|
||
|
// break;
|
||
|
case "getOrgEmpGroupSelectByOrgId":
|
||
|
returnstr = getOrgEmpGroupSelectByOrgId(context);
|
||
|
break;
|
||
|
case "getOrgDeptTree"://机构-部门树(包含所在机构下部门)
|
||
|
returnstr = getOrgDeptTree(context);
|
||
|
break;
|
||
|
case "OrgDeptEmpTree":
|
||
|
returnstr = OrgDeptEmpTree(context);
|
||
|
break;
|
||
|
case "getOrgOnlyTree":
|
||
|
returnstr = getOrgOnlyTree(context);
|
||
|
break;
|
||
|
}
|
||
|
context.Response.Write(returnstr);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//机构-部门树(不包含父级机构下属消防站)
|
||
|
private string GetOrgDeptTree(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getOrgAndDeptTree(orgId);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
||
|
}
|
||
|
return returnstr;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
//机构-部门树(包含父级机构下属消防站)
|
||
|
private string GetOrgDeptTree2(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getOrgTree2(orgId);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
|
||
|
}
|
||
|
|
||
|
//获取可以绑定的登录账号
|
||
|
private string GetUseruId(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
string usersUid = context.Request.Params["usersUid"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getUseruId(orgId, usersUid);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
//查询
|
||
|
private string GetOrgEmpList(HttpContext context)
|
||
|
{
|
||
|
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"];
|
||
|
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 (type == "dept")
|
||
|
{
|
||
|
where += " dept_id ='" + treeID + "' ";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
where += " ORG_ID = '" + treeID + "'";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string[] OrgArray = OrgList.Split(',');
|
||
|
string OrgListString = "";
|
||
|
for (int i = 0; i < OrgArray.Length; i++)
|
||
|
{
|
||
|
if (i == 0)
|
||
|
{
|
||
|
OrgListString = "'" + OrgArray[i] + "'";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
OrgListString += ",'" + OrgArray[i] + "'";
|
||
|
}
|
||
|
}
|
||
|
where = " ORG_ID in (" + OrgListString + ") ";
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(keyword))
|
||
|
{
|
||
|
if (where != null)
|
||
|
{
|
||
|
where += " and ";
|
||
|
}
|
||
|
where += "( emp_name like '%" + keyword + "%' or emp_num like '%" + keyword + "%')";
|
||
|
}
|
||
|
if (where != null)
|
||
|
{
|
||
|
where += " and ";
|
||
|
}
|
||
|
where += " is_del = '0'";
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
||
|
int count = bll.GetRecordCount(where);
|
||
|
returnstr += "\"count\":" + count + ",\"data\":";
|
||
|
if (count == 0)
|
||
|
{
|
||
|
returnstr += "[]";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
List<FangYar.Model.TBL.TBL_SYS_EMP_Model> list = bll.QueryList(pageIndex, pageSize, where, "");
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
||
|
}
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//添加人员
|
||
|
private string AddOrgEmp(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
int code = -1;
|
||
|
string msg = "";
|
||
|
try
|
||
|
{
|
||
|
string usersUid = context.Request.Params["users_uid"];
|
||
|
string empName = context.Request.Params["emp_name"];
|
||
|
string empNum = context.Request.Params["emp_num"];
|
||
|
string empSex = context.Request.Params["emp_sex"];
|
||
|
string orgId = context.Request.Params["org_id"];
|
||
|
string deptId = context.Request.Params["dept_id"];
|
||
|
string empEmail = context.Request.Params["emp_email"];
|
||
|
string empMobile = context.Request.Params["emp_mobile"];
|
||
|
string idnumber = context.Request.Params["idnumber"];
|
||
|
string cert = context.Request.Params["cert"];
|
||
|
string nation = context.Request.Params["nation"];
|
||
|
string face = context.Request.Params["face"];
|
||
|
string mar = context.Request.Params["mar"];
|
||
|
string isWork = context.Request.Params["is_work"];
|
||
|
string prof = context.Request.Params["prof"];
|
||
|
string pol = context.Request.Params["pol"];
|
||
|
string photo = context.Request.Params["photo"];
|
||
|
|
||
|
//员工表
|
||
|
FangYar.Model.TBL.TBL_SYS_EMP_Model model = new Model.TBL.TBL_SYS_EMP_Model();
|
||
|
model.USERS_UID = usersUid;
|
||
|
model.EMP_NAME = empName;
|
||
|
model.EMP_NUM = empNum;
|
||
|
model.EMP_SEX = empSex;
|
||
|
model.ORG_ID = orgId;
|
||
|
model.DEPT_ID = deptId;
|
||
|
model.EMP_EMAIL = empEmail;
|
||
|
model.EMP_MOBILE = empMobile;
|
||
|
model.IDNUMBER = idnumber;
|
||
|
model.CERT = cert;
|
||
|
model.NATION = nation;
|
||
|
model.FACE = face;
|
||
|
model.MAR = mar;
|
||
|
model.IS_WORK = isWork;
|
||
|
model.PROF = prof;
|
||
|
model.POL = pol;
|
||
|
model.PHOTO = photo;
|
||
|
model.IS_DEL = "0";
|
||
|
|
||
|
if (bll.AddEmp(model))
|
||
|
{
|
||
|
msg = "添加成功!";
|
||
|
code = 1;
|
||
|
}
|
||
|
else { msg = "添加失败!"; }
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "添加失败!";
|
||
|
}
|
||
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//修改人员信息
|
||
|
private string EditOrgEmp(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
int code = -1;
|
||
|
string msg = "";
|
||
|
try
|
||
|
{
|
||
|
string empId = context.Request.Params["ID"];
|
||
|
string usersUid = context.Request.Params["users_uid"];
|
||
|
string empName = context.Request.Params["emp_name"];
|
||
|
string empNum = context.Request.Params["emp_num"];
|
||
|
string empSex = context.Request.Params["emp_sex"];
|
||
|
string orgId = context.Request.Params["org_id"];
|
||
|
string deptId = context.Request.Params["dept_id"];
|
||
|
string empEmail = context.Request.Params["emp_email"];
|
||
|
string empMobile = context.Request.Params["emp_mobile"];
|
||
|
string idnumber = context.Request.Params["idnumber"];
|
||
|
string cert = context.Request.Params["cert"];
|
||
|
string nation = context.Request.Params["nation"];
|
||
|
string face = context.Request.Params["face"];
|
||
|
string mar = context.Request.Params["mar"];
|
||
|
string isWork = context.Request.Params["is_work"];
|
||
|
string prof = context.Request.Params["prof"];
|
||
|
string pol = context.Request.Params["pol"];
|
||
|
string photo = context.Request.Params["photo"];
|
||
|
|
||
|
//员工表
|
||
|
FangYar.Model.TBL.TBL_SYS_EMP_Model model = new Model.TBL.TBL_SYS_EMP_Model();
|
||
|
model.ID = empId;
|
||
|
model.USERS_UID = usersUid;
|
||
|
model.EMP_NAME = empName;
|
||
|
model.EMP_NUM = empNum;
|
||
|
model.EMP_SEX = empSex;
|
||
|
model.ORG_ID = orgId;
|
||
|
model.DEPT_ID = deptId;
|
||
|
model.EMP_EMAIL = empEmail;
|
||
|
model.EMP_MOBILE = empMobile;
|
||
|
model.IDNUMBER = idnumber;
|
||
|
model.CERT = cert;
|
||
|
model.NATION = nation;
|
||
|
model.FACE = face;
|
||
|
model.MAR = mar;
|
||
|
model.IS_WORK = isWork;
|
||
|
model.PROF = prof;
|
||
|
model.POL = pol;
|
||
|
model.PHOTO = photo;
|
||
|
model.IS_DEL = "0";
|
||
|
|
||
|
if (bll.EditEmp(model))
|
||
|
{
|
||
|
msg = "修改成功!";
|
||
|
code = 1;
|
||
|
}
|
||
|
else { msg = "修改失败!"; }
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "修改失败!";
|
||
|
}
|
||
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
////删除人员
|
||
|
//private string DelOrgEmp(HttpContext context)
|
||
|
//{
|
||
|
// string returnstr = "";
|
||
|
// int code = -1;
|
||
|
// string msg = "";
|
||
|
// try
|
||
|
// {
|
||
|
// string EmpList = context.Request.Params["EmpList"];
|
||
|
// string[] EmpArray = EmpList.Split(',');
|
||
|
// string EmpListString = "";
|
||
|
// for (int i = 0; i < EmpArray.Length; i++)
|
||
|
// {
|
||
|
// if (i == 0)
|
||
|
// {
|
||
|
// EmpListString = "'" + EmpArray[i] + "'";
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// EmpListString += ",'" + EmpArray[i] + "'";
|
||
|
// }
|
||
|
// }
|
||
|
// if (bll.DelEmp(EmpListString))
|
||
|
// {
|
||
|
// msg = "删除成功!";
|
||
|
// code = 1;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// msg = "删除失败!";
|
||
|
// }
|
||
|
// }
|
||
|
// catch
|
||
|
// {
|
||
|
// msg = "删除失败!";
|
||
|
// }
|
||
|
// returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
||
|
// return returnstr;
|
||
|
//}
|
||
|
|
||
|
private string GetEmpByUID(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string UID = context.Request.Params["UID"];
|
||
|
|
||
|
string where = " 1=1 ";
|
||
|
if (!string.IsNullOrEmpty(UID))
|
||
|
{
|
||
|
where += " and USERS_UID = '" + UID + "'";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "{\"code\":-1,\"msg\":\"UID参数为空\",\"count\":0,\"data\":[]}";
|
||
|
}
|
||
|
returnstr = "{\"code\":1,\"msg\":\"\",";
|
||
|
int count = bll.GetRecordCount(where);
|
||
|
returnstr += "\"count\":" + count + ",\"data\":";
|
||
|
if (count == 0)
|
||
|
{
|
||
|
returnstr += "[]";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DataTable dt = bll.GetDTByUID(UID);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
||
|
}
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
|
||
|
//机构-人员分组下拉框
|
||
|
private string getOrgEmpGroupSelectByOrgId(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
FangYar.BLL.TRAIN.T_TRAININGPLAN tbll = new BLL.TRAIN.T_TRAININGPLAN();
|
||
|
DataTable dt = tbll.getOrgTreeOnlyHaveScore(orgId);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
||
|
returnstr += "}";
|
||
|
|
||
|
//DataTable dt = bll.getEmpCountByOrgId(orgId);
|
||
|
//string data = "[";
|
||
|
//int index = 0;
|
||
|
//for (int i = 0; i < dt.Rows.Count; i++)
|
||
|
//{
|
||
|
// decimal total = decimal.Parse(dt.Rows[i]["TOTAL"].ToString());
|
||
|
// if (total > 0)
|
||
|
// {
|
||
|
// string pid = dt.Rows[i]["ORG_ID"].ToString();
|
||
|
// if (index > 0) { data += ","; }
|
||
|
// data += "{";
|
||
|
// data += "\"id\":\"" + pid + "\"";
|
||
|
// data += ",\"name\":\"" + dt.Rows[i]["ORG_NAME"].ToString() + "\"";
|
||
|
// data += ",\"pid\":\"0\"";
|
||
|
// data += "}";
|
||
|
// index++;
|
||
|
// //List<FangYar.Model.TBL.TBL_SYS_EMP_Model> list = bll.getEmpListByOrgId(pid, "1");
|
||
|
// //喀什部门临时方法
|
||
|
// List<FangYar.Model.TBL.TBL_SYS_EMP_Model> list = bll.getEmpListByDeptId(pid, "1");
|
||
|
// for (int j = 0; j < list.Count; j++)
|
||
|
// {
|
||
|
// if (index > 0) { data += ","; }
|
||
|
// data += "{";
|
||
|
// data += "\"id\":\"" + list[j].USERS_UID + "\"";
|
||
|
// data += ",\"name\":\"" + list[j].EMP_NAME + "\"";
|
||
|
// data += ",\"pid\":\"" + pid + "\"";
|
||
|
// data += "}";
|
||
|
// index++;
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
//data += "]";
|
||
|
//returnstr += data + "}";
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
|
||
|
//机构-部门树(包含所在机构下部门)
|
||
|
private string getOrgDeptTree(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getOrgDeptTree(orgId);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//机构树(包含人员)
|
||
|
private string OrgDeptEmpTree(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getOrgAndDeptAndEmpTree(orgId);
|
||
|
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
|
||
|
}
|
||
|
//获取机构及所有下属机构(只有机构)
|
||
|
private string getOrgOnlyTree(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getOrgOnlyTree(orgId);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
public bool IsReusable
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|