private void GetRoleByUserID() { int roleid = new BCtrl_SysUser().GetRoleByUserID(userId); hidrole.Value = roleid.ToString(); hidOriginRole.Value = roleid.ToString(); }
private void InitRoleList() { DataTable dt = new BCtrl_SysUser().GetAllRole(); this.rptRole.DataSource = dt; this.rptRole.DataBind(); }
private void BindAdminData() { BCtrl_SysUser bllSysuser = new BCtrl_SysUser(); AdminEntity entity = bllSysuser.QuerySysUserEntity(pid); if (entity != null) { this.txtLoginname.Disabled = true; this.divUserpwd.Visible = false; this.divConfirmuserpwd.Visible = false; this.txtLoginname.Value = entity.User_Name; this.txtTruename.Value = entity.TrueName; this.selsex.Value = entity.User_Sex.ToString(); this.txtUser_Tel.Value = entity.User_Tel; this.txtUser_Mobile.Value = entity.User_Mobile; this.txtUser_Mail.Value = entity.User_Mail; this.selDepartMent.Value = entity.User_DeptID.ToString(); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "adminEdit", "<script>bootbox.dialog(\"参数异常!\", [{\"label\": \"OK\",\"class\": \"btn-small btn-primary\",callback: function () { window.location.href = 'AdminManager.aspx?fun=" + Master.fun + "';}}]);</script>"); } }
public string ChangeAdminPwd(HttpContext context) { int userID = 0; string pwd = context.Request.Form["pwd"]; if (!string.IsNullOrEmpty(pwd) && int.TryParse(context.Request.Form["pid"], out userID) && userID > 0) { BCtrl_SysUser bll = new BCtrl_SysUser(); pwd = MD5.Encode(WebKeys.AdminPwdRandom, pwd.Trim()); bool isSuccess = bll.UpdatePassword(userID, pwd); if (isSuccess) { ClearCacheOrSession.ClearAdminCacheByCRUD(userID); return("{\"status\":1}"); } else { return("{\"status\":0}"); } } else { return("{\"status\":-1}"); } }
public string IsUseableByUsername(HttpContext context) { bool isUseable = false; string username = context.Request.Form["username"]; if (!string.IsNullOrEmpty(username)) { BCtrl_SysUser sysUserBll = new BCtrl_SysUser(); isUseable = sysUserBll.IsUseableByUsername(username.Trim()); } if (isUseable) { return("true"); } else { return("false"); } }
private DataTable GetQueryData(bool isDownload) { BCtrl_SysUser bll = new BCtrl_SysUser(); int totalcnt = 0; AdminSearchEntity entity = new Entity.AdminSearchEntity(); entity.LoginName = _strLoginName; entity.TrueName = _StrTrueName; entity.PageSize = base.PageSize; entity.PageIndex = base.PageIndex; entity.UseDBPagination = !isDownload; DataTable table = bll.QueryAdminTable(entity, out totalcnt); base.TotalRecords = totalcnt; return(table); }
public string IsUseableByEmail(HttpContext context) { bool isUseable = false; string email = context.Request.Form["email"]; int pid = 0; int.TryParse(context.Request["pid"], out pid); if (!string.IsNullOrEmpty(email)) { BCtrl_SysUser sysUserBll = new BCtrl_SysUser(); isUseable = sysUserBll.IsUseableByEmail(email.Trim(), pid); } if (isUseable) { return("true"); } else { return("false"); } }
public string InitData(HttpContext context) { string status = "{\"status\":-1}"; if (base.CurrentAdmin.Sys_RoleID == 100) { BCtrl_SysUser bll = new BCtrl_SysUser(); if (bll.InitDataBase()) { ClearCacheOrSession.ClearAdminCacheByCRUD(); status = "{\"status\":1}"; } else { status = "{\"status\":0}"; } } else { status = "{\"status\":2}"; //没有权限执行操作 } return(status); }
public string DeleteAdmin(HttpContext context) { int userID = 0; if (int.TryParse(context.Request.Form["pid"], out userID) && userID > 0) { BCtrl_SysUser bllSysuser = new BCtrl_SysUser(); bool isSuccess = bllSysuser.Delete(userID); if (isSuccess) { ClearCacheOrSession.ClearAdminCacheByCRUD(userID); return("{\"status\":1}"); } else { return("{\"status\":0}"); } } else { return("{\"status\":-1}"); } }
public string AdminLogins(HttpContext context) { string loginname = context.Request.Form["un"]; string password = context.Request.Form["pw"]; string valid = context.Request.Form["va"]; string returnUrl = context.Request.Form["url"]; if (string.IsNullOrEmpty(loginname) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(valid)) { return("{\"state\":-9}"); //传递参数不完整 } else { if (valid.Equals(DateTime.Now.Day.ToString())) { BCtrl_SysUser sysUserBll = new BCtrl_SysUser(); #region 管理员登录验证 string userid = ""; password = MD5.Encode(WebKeys.AdminPwdRandom, password); //尝试登录 //if (new PassportServiceProxy().TryLogin(loginname, password, "NewBookSystem", out userid)) if (sysUserBll.TryLogin(loginname, password, out userid)) { if (!string.IsNullOrEmpty(userid)) { //查询用户所属角色能访问的频道 List <FunctionEntity> list = new BCtrl_Function().GetFunction(userid); if (list.Count != 0) { AdminSessionEntity ue = new BCtrl_SysUser().QuerySysUserInfo(userid); if (ue != null) { ue.Sys_LoginName = loginname; ue.Sys_UserID = userid; ue.Functions = list; context.Session[WebKeys.AdminSessionKey] = ue; return("{\"state\":1}"); //登录成功 } else { return("{\"state\":-7}"); //登录成功但在系统中为找到授权 } } else { return("{\"state\":-6}"); //登录成功但无使用功能权限 } } else { return("{\"state\":-1}"); //登录失败 用户名密码错误 } } else { return("{\"state\":-1}"); //登录失败 用户名密码错误 } #endregion #region 搭建时测试 //if (loginname == "zl" && password == "123456") //{ // AdminSessionEntity ue = new AdminSessionEntity(); // ue.Sys_LoginName = loginname; // ue.Sys_UserID = "1"; // context.Session[WebKeys.AdminSessionKey] = ue; // string result = "{\"state\":1, \"url\":\"" + returnUrl + "\"}"; // return result; //登录成功 //} //else //{ // return "{\"state\":-1}"; //登录失败 用户名密码错误 //} #endregion } else { //验证码不正确 return("{\"state\":-8}"); //验证码不正确 } } }
/// <summary> /// 提交表单 /// </summary> private void SubmitForm() { if (ValidateData()) { BCtrl_SysUser bllSysuser = new BCtrl_SysUser(); bool isSuccess = false; AdminEntity entity = null; if (pid > 0) { #region 修改 entity = bllSysuser.QuerySysUserEntity(pid); if (entity != null) { entity.TrueName = this.txtTruename.Value.Trim(); entity.User_Sex = int.Parse(this.selsex.Value); entity.User_Tel = this.txtUser_Tel.Value.Trim(); entity.User_Mobile = this.txtUser_Mobile.Value.Trim(); entity.User_Mail = this.txtUser_Mail.Value.Trim(); entity.User_DeptID = int.Parse(this.selDepartMent.Value); isSuccess = bllSysuser.Update(entity); if (isSuccess) { Page.ClientScript.RegisterStartupScript(this.GetType(), "adminEdit", "<script>bootbox.dialog(\"保存成功!\", [{\"label\": \"OK\",\"class\": \"btn-small btn-primary\",callback: function () {window.location.href = 'AdminManager.aspx?fun=" + Master.fun + "';}}]);</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "adminEdit", "<script>bootbox.alert(\"保存失败\");</script>"); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "adminEdit", "<script>bootbox.dialog(\"当前用户不存在或已被删除!\", [{\"label\": \"OK\",\"class\": \"btn-small btn-primary\",callback: function () { window.location.href = 'AdminManager.aspx?fun=" + Master.fun + "';}}]);</script>"); } #endregion } else { #region 新增 entity = new AdminEntity(); entity.User_Name = this.txtLoginname.Value.Trim(); entity.TrueName = this.txtTruename.Value.Trim(); entity.User_Pwd = MD5.Encode(WebKeys.AdminPwdRandom, this.txtUserpwd.Value.Trim()); entity.User_Sex = int.Parse(this.selsex.Value); entity.User_Tel = this.txtUser_Tel.Value.Trim(); entity.User_Mobile = this.txtUser_Mobile.Value.Trim(); entity.User_Mail = this.txtUser_Mail.Value.Trim(); entity.User_DeptID = int.Parse(this.selDepartMent.Value); entity.IsValid = false; entity.RegisterDate = DateTime.Now; isSuccess = bllSysuser.Insert(entity); if (isSuccess) { Page.ClientScript.RegisterStartupScript(this.GetType(), "adminEdit", "<script>bootbox.dialog(\"添加成功!\", [{\"label\": \"OK\",\"class\": \"btn-small btn-primary\",callback: function () {window.location.href = 'AdminManager.aspx?fun=" + Master.fun + "';}}]);</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "adminEdit", "<script>bootbox.alert(\"添加失败\");</script>"); } #endregion } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "adminEdit", "<script>bootbox.alert(\"请检查必填项或数据格式是否正确\");</script>"); } }