/// <summary> /// 用户名和密码返回实体 /// </summary> /// <param name="UserName"></param> /// <param name="Password"></param> /// <returns></returns> public Model.Angel_Admin GetModel(string UserName, string Password) { string Md5string = AngelDESEncrypt.Encrypt(Password); Adal.SetConditionString(string.Format(" LoginName='{0}' and Password='******'", UserName, Md5string)); if (Adal.Condition_DataExist()) { DataTable table = Adal.GetDataTable(); Model.Angel_Admin model = new Model.Angel_Admin(); foreach (DataRow row in table.Rows) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["RoleId"] != null && row["RoleId"].ToString() != "") { model.RoleId = int.Parse(row["RoleId"].ToString()); } if (row["LoginName"] != null) { model.LoginName = row["LoginName"].ToString(); } if (row["Password"] != null) { model.Password = row["Password"].ToString(); } if (row["UserName"] != null) { model.UserName = row["UserName"].ToString(); } if (row["UserEmail"] != null) { model.UserEmail = row["UserEmail"].ToString(); } if (row["IsWorking"] != null && row["IsWorking"].ToString() != "") { model.IsWorking = int.Parse(row["IsWorking"].ToString()); } if (row["AddTime"] != null && row["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(row["AddTime"].ToString()); } } return(model); } else { return(null); } }
public void ProcessRequest(HttpContext context) { AngelRM.Business.Angel_Admin ObjectBLL = new Business.Angel_Admin(); string ActionName = context.Request.Params["action"]; //根据相应的表进行操作 switch (ActionName) { case "SaveDB": Model.Angel_Admin modeobj = new Model.Angel_Admin(); modeobj.RoleId = Convert.ToInt32(context.Request.Params["RoleId"]); modeobj.LoginName = context.Request.Params["LoginName"]; modeobj.Password = AngelDESEncrypt.Encrypt(context.Request.Params["Password"]); modeobj.UserName = context.Request.Params["UserName"]; modeobj.UserEmail = context.Request.Params["UserEmail"]; modeobj.AddTime = DateTime.Now; modeobj.IsWorking = Convert.ToInt32(context.Request.Params["IsWorking"]); if (modeobj.LoginName == "" || modeobj.LoginName == null || modeobj.RoleId == null || modeobj.AddTime == null || modeobj.IsWorking == null) { context.Response.Write("{\"success\":false}"); } if (context.Request.Params["method"] == "add") { bool iscount = ObjectBLL.Add(modeobj); if (iscount) { context.Response.Write("{\"success\":true}"); return; } else { context.Response.Write("{\"success\":false}"); } } if (context.Request.Params["method"] == "modify") { modeobj.ID = Convert.ToInt32(context.Request.Params["id"]); if (ObjectBLL.Update(modeobj)) { context.Response.Write("{\"success\":true}"); } else { context.Response.Write("{\"success\":false}"); } } break; //修改管理员密码 case "UpPwd": AdminPage admininfo = new AdminPage(); Model.Angel_Admin modelpwd = admininfo.GetAdminInfo(); string OldPassword = AngelDESEncrypt.Encrypt(context.Request.Params["OldPasswrod"]); string NewPassword = AngelDESEncrypt.Encrypt(context.Request.Params["NewPassword"]); if (context.Request.Params["OldPasswrod"] == "" || context.Request.Params["OldPasswrod"] == null || context.Request.Params["NewPassword"] == "" || context.Request.Params["NewPassword"] == null) { context.Response.Write("{\"success\":false}"); return; } if (OldPassword == modelpwd.Password) { modelpwd.Password = NewPassword; if (ObjectBLL.Update(modelpwd)) { context.Response.Write("{\"success\":true}"); } else { context.Response.Write("{\"success\":false}"); } } else { context.Response.Write("{\"success\":false}"); } break; //删除信息 case "DelDB": string id = context.Request.Params["id"]; if (ObjectBLL.Delete(id)) { context.Response.Write("{\"success\":true}"); } else { context.Response.Write("{\"success\":false}"); } break; case "List": break; default: context.Response.Write("{\"success\":false}"); break; } }