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.
263 lines
9.3 KiB
263 lines
9.3 KiB
using MESClassLibrary.BLL.User;
|
|
using MESWebSite.CommonClass;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace MESWebSite.HttpHandlers
|
|
{
|
|
/// <summary>
|
|
/// UserHandler 的摘要说明
|
|
/// </summary>
|
|
public class UserHandler : IHttpHandler
|
|
{
|
|
public class parmQuery
|
|
{
|
|
public string UserName { get; set; }
|
|
public int page { get; set; }
|
|
public int pagesize { get; set; }
|
|
}
|
|
|
|
public class parmNew
|
|
{
|
|
public Guid UserID { get; set; }
|
|
public string UserName { get; set; }
|
|
public string Password { get; set; }
|
|
public string RealName { get; set; }
|
|
public string Sex { get; set; }
|
|
public string Tel { get; set; }
|
|
public string Department { get; set; }
|
|
public Guid DepartmentID { get; set; }
|
|
public string IsEnabled { get; set; }
|
|
public string MenuList { get; set; }
|
|
public string opName { get; set; }
|
|
|
|
}
|
|
|
|
public class parmEdit
|
|
{
|
|
public Guid UserID { get; set; }
|
|
public string UserName { get; set; }
|
|
public string Password { get; set; }
|
|
public string RealName { get; set; }
|
|
public string Sex { get; set; }
|
|
public string Tel { get; set; }
|
|
public string Department { get; set; }
|
|
public Guid DepartmentID { get; set; }
|
|
public string IsEnabled { get; set; }
|
|
public string MenuList { get; set; }
|
|
public string opName { get; set; }
|
|
|
|
}
|
|
|
|
public class parmDelete
|
|
{
|
|
public string UserID { get; set; }
|
|
public string opName { get; set; }
|
|
}
|
|
|
|
public class parmQueryMenuTree
|
|
{
|
|
public Guid UserID { get; set; }
|
|
}
|
|
|
|
HttpRequest Request = null;
|
|
HttpResponse Response = null;
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
|
|
Request = context.Request;
|
|
Response = context.Response;
|
|
|
|
|
|
|
|
string method = Request.Params["method"];
|
|
switch (method)
|
|
{
|
|
case "QueryForCombobox":
|
|
QueryForCombobox();
|
|
break;
|
|
case "QueryList":
|
|
QueryList();
|
|
break;
|
|
case "SaveInfo":
|
|
SaveInfo();
|
|
break;
|
|
case "DelInfo":
|
|
DelInfo();
|
|
break;
|
|
case "QueryDepartment":
|
|
QueryDepartment();
|
|
break;
|
|
case "QueryMenuTree":
|
|
QueryMenuTree();
|
|
break;
|
|
}
|
|
}
|
|
void QueryForCombobox()
|
|
{
|
|
UserBLL bll = new UserBLL();
|
|
Response.Write(bll.GetComboboxData());
|
|
Response.End();
|
|
|
|
}
|
|
|
|
void QueryList()
|
|
{
|
|
|
|
parmQuery parms = new parmQuery();
|
|
if (Request.Params["UserName"] != null)
|
|
parms.UserName = Request.Params["UserName"].ToString();
|
|
else
|
|
parms.UserName = "";
|
|
parms.page = Convert.ToInt32(Request.Params["page"].ToString());
|
|
parms.pagesize = Convert.ToInt32(Request.Params["rows"].ToString());
|
|
|
|
DataSet ds = SQLHelper.QueryDataSet(CommandType.StoredProcedure, "user_sel", SQLHelper.ModelToParameterList(parms).ToArray());
|
|
|
|
string jsonStr = JEasyUIHelper.DataSetToJSONdatagrid(ds);
|
|
Response.Write(jsonStr);
|
|
Response.End();
|
|
}
|
|
|
|
void SaveInfo()
|
|
{
|
|
if (Request.Params["ID"] == "")
|
|
{
|
|
//新增数据
|
|
parmNew parms = new parmNew();
|
|
parms.UserID = Guid.NewGuid();
|
|
parms.UserName = Request.Params["UserName"].ToString();
|
|
parms.Password = Request.Params["password"].ToString();
|
|
parms.RealName = Request.Params["RealName"].ToString();
|
|
parms.Sex = Request.Params["Sex"].ToString();
|
|
parms.Tel = Request.Params["Tel"].ToString();
|
|
parms.Department = Request.Params["Department"].ToString();
|
|
parms.DepartmentID = Guid.Parse(Request.Params["DepartmentID"].ToString());
|
|
parms.IsEnabled = Request.Params["IsEnabled"].ToString();
|
|
parms.MenuList = Microsoft.JScript.GlobalObject.unescape(Request.Params["MenuList"].ToString());
|
|
parms.opName = HttpContext.Current.Request.Cookies["LoginUserInfo"]["UserID"].ToString();
|
|
try
|
|
{
|
|
SQLHelper.ExecuteNonQuery(CommandType.StoredProcedure, "user_ins", SQLHelper.ModelToParameterList(parms).ToArray());
|
|
Response.Write("true");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Response.Write(ex.Message);
|
|
}
|
|
Response.End();
|
|
}
|
|
else
|
|
{
|
|
//编辑数据
|
|
parmEdit parms = new parmEdit();
|
|
parms.UserID = new Guid(Request.Params["ID"].ToString());
|
|
parms.UserName = Request.Params["UserName"].ToString();
|
|
parms.Password = Request.Params["Password"].ToString();
|
|
parms.RealName = Request.Params["RealName"].ToString();
|
|
parms.Sex = Request.Params["Sex"].ToString();
|
|
parms.Tel = Request.Params["Tel"].ToString();
|
|
parms.Department = Request.Params["Department"].ToString();
|
|
parms.DepartmentID = Guid.Parse(Request.Params["DepartmentID"].ToString());
|
|
parms.IsEnabled = Request.Params["IsEnabled"].ToString();
|
|
parms.MenuList = Microsoft.JScript.GlobalObject.unescape(Request.Params["MenuList"].ToString());
|
|
parms.opName = HttpContext.Current.Request.Cookies["LoginUserInfo"]["UserID"].ToString();
|
|
|
|
try
|
|
{
|
|
SQLHelper.ExecuteNonQuery(CommandType.StoredProcedure, "user_upd", SQLHelper.ModelToParameterList(parms).ToArray());
|
|
Response.Write("true");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Response.Write(ex.Message);
|
|
}
|
|
Response.End();
|
|
}
|
|
}
|
|
|
|
void DelInfo()
|
|
{
|
|
parmDelete parms = new parmDelete();
|
|
parms.UserID = Request.Params["ID"].ToString();
|
|
parms.opName = HttpContext.Current.Request.Cookies["LoginUserInfo"]["UserID"].ToString();
|
|
try
|
|
{
|
|
SQLHelper.ExecuteNonQuery(CommandType.StoredProcedure, "user_del", SQLHelper.ModelToParameterList(parms).ToArray());
|
|
Response.Write("true");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Response.Write(ex.Message);
|
|
}
|
|
Response.End();
|
|
}
|
|
|
|
void QueryDepartment()
|
|
{
|
|
DataSet ds = SQLHelper.QueryDataSet(CommandType.StoredProcedure, "user_department_sel", null);
|
|
|
|
string jsonStr = JSONHelper.DataTableToJSON(ds.Tables[0]);
|
|
Response.Write(jsonStr);
|
|
Response.End();
|
|
}
|
|
|
|
void QueryMenuTree()
|
|
{
|
|
parmQueryMenuTree parms = new parmQueryMenuTree();
|
|
if (Request.Params["UserID"] != null)
|
|
parms.UserID = new Guid(Request.Params["UserID"].ToString());
|
|
else
|
|
parms.UserID = new Guid();
|
|
|
|
DataSet ds = SQLHelper.QueryDataSet(CommandType.StoredProcedure, "user_menu_sel", SQLHelper.ModelToParameterList(parms).ToArray());
|
|
|
|
List<JEasyUITree.TreeNode> tree = new List<JEasyUITree.TreeNode>();
|
|
//增加第一层菜单
|
|
foreach (DataRow r in ds.Tables[0].Rows)
|
|
{
|
|
JEasyUITree.TreeNode node = new JEasyUITree.TreeNode();
|
|
node.id = r["MenuID"].ToString();
|
|
node.text = r["MenuName"].ToString();
|
|
node.state = "closed";
|
|
tree.Add(node);
|
|
}
|
|
//增加第二层菜单, 按用户菜单授权设置checkbox
|
|
DataTable dt = ds.Tables[1];
|
|
DataTable dt1 = ds.Tables[2];
|
|
foreach (JEasyUITree.TreeNode node in tree)
|
|
{
|
|
node.children = new List<JEasyUITree.TreeNode>();
|
|
DataRow[] rows = dt.Select("ParentMenuID='" + node.id.ToString() + "'");
|
|
foreach (DataRow r in rows)
|
|
{
|
|
JEasyUITree.TreeNode nd = new JEasyUITree.TreeNode();
|
|
nd.id = r["MenuID"].ToString();
|
|
nd.text = r["MenuName"].ToString();
|
|
DataRow[] rows1 = dt1.Select("MenuID='" + nd.id + "'");
|
|
if (rows1.Length > 0)
|
|
nd.@checked = true;
|
|
node.children.Add(nd);
|
|
}
|
|
}
|
|
|
|
string jsonStr = JSONHelper.ObjectToJSON(tree);
|
|
Response.Write(jsonStr);
|
|
Response.End();
|
|
|
|
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|