コード例 #1
0
        private string LoadData()
        {
            //获取用户信息
            SeatManage.ClassModel.UserInfo LoginUser = GetUserInfo(this.LoginId);
            if (LoginUser == null)
            {
                return("TimeOut");
            }
            //  ShowUserInfo(LoginUser);您好,欢迎访问系统应用!
            string msg = "您好[" + LoginUser.UserName + "],欢迎你回来!";

            ViewBag.welcomeMsg = msg;
            List <SeatManage.ClassModel.SysMenuInfo> listSysMenu = LoginUser.UserMenus;

            StringBuilder menuString = new StringBuilder("[");
            var           rootPath   = System.Configuration.ConfigurationManager.AppSettings["rootPath"];

            rootPath = rootPath == null ? "" : rootPath;
            foreach (SysMenuInfo item in listSysMenu)
            {
                if (item.MenuID <= 3)
                {
                    continue;                     //不加载系统设置功能
                }
                menuString.Append("	{ \"id\":\"" + item.MenuID + "\", \"parentId\":\"0\", \"name\":\"" + item.MenuName + "\", \"isParent\": \"true\",\"backgroundPosition\":\"0px - 80px\",\"img\":\"./ skin / topIcons / icon01.png\"},");
                foreach (SysMenuInfo subItem in item.ChildMenu)
                {
                    menuString.Append("{ \"id\":\"" + subItem.MenuID + "\", \"parentId\":\"" + item.MenuID + "\", \"name\":\"" + subItem.MenuName + "\",\"url\":\"" + rootPath + "/" + subItem.MenuLink + "\", \"target\":\"frmright\",\"icon\": \"./skin/nav_icon_bg.png\",\"backgroundPosition\":\"0px - 128px\"},");
                }
            }
            string str = menuString.ToString().TrimEnd(',');

            str += "]";
            return(str);
        }
コード例 #2
0
        /// <summary>
        /// 根据学号获取读者的登录信息
        /// </summary>
        /// <param name="cardNo">学号</param>
        /// <returns></returns>
        public SeatManage.ClassModel.UserInfo GetUserInfo(string LoginId)
        {
            if (string.IsNullOrEmpty(LoginId))
            {
                return(null);
            }
            string strWhere = "LoginId=@loginId";

            SqlParameter[] parameters =
            {
                new SqlParameter("@loginId", LoginId)
            };
            DataSet ds = dalUser_All.GetList(strWhere, parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                SeatManage.ClassModel.UserInfo userInfo = new SeatManage.ClassModel.UserInfo();
                userInfo.LoginId  = ds.Tables[0].Rows[0]["LoginID"].ToString();
                userInfo.Password = ds.Tables[0].Rows[0]["UsrPwd"].ToString();
                userInfo.UserType = (UserType)int.Parse(ds.Tables[0].Rows[0]["UsrType"].ToString());
                userInfo.UserName = ds.Tables[0].Rows[0]["UsrName"].ToString();
                userInfo.IsUsing  = (LogStatus)int.Parse(ds.Tables[0].Rows[0]["UsrEnabled"].ToString());
                userInfo.Remark   = ds.Tables[0].Rows[0]["Remark"].ToString();
                if (ds.Tables[0].Rows[0]["IPLockIPAdress"] != null)
                {
                    userInfo.LockIPAdress = ds.Tables[0].Rows[0]["IPLockIPAdress"].ToString();
                }
                return(userInfo);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 删除读者信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool delete(SeatManage.ClassModel.UserInfo model)
        {
            SqlParameter[] parameters = new SqlParameter[1] {
                new SqlParameter("@LoginID", model.LoginId)
            };
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete Users_ALL ");
            strSql.Append(" where LoginID=@LoginID");
            try
            {
                int i = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                if (i > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
コード例 #4
0
 /// <summary>
 /// 添加用户
 /// </summary>
 private void AddUser()
 {
     if (!string.IsNullOrEmpty(txtLoginID.Text) && !string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtPassword_d.Text) && (txtPassword.Text == txtPassword_d.Text))
     {
         if (SeatManage.Bll.Users_ALL.GetUserInfo(txtLoginID.Text.Trim()) != null)
         {
             FineUI.Alert.Show("输入的用户名重复,请重新输入!");
         }
         else
         {
             SeatManage.ClassModel.UserInfo user = new SeatManage.ClassModel.UserInfo();
             user.LoginId  = txtLoginID.Text.Trim();
             user.Password = SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32(txtPassword.Text.Trim());
             user.Remark   = txtRemark.Text.Trim();
             user.UserName = txtUserName.Text.Trim();
             if (clbused.Checked)
             {
                 user.IsUsing = SeatManage.EnumType.LogStatus.Valid;
             }
             else
             {
                 user.IsUsing = SeatManage.EnumType.LogStatus.Fail;
             }
             user.UserRoomRight.LoginID = user.LoginId;
             user.UserType = SeatManage.EnumType.UserType.Admin;
             user.UserRoomRight.RightRoomList.Clear();
             foreach (FineUI.CheckItem item in clbroom.Items)
             {
                 if (item.Selected)
                 {
                     user.UserRoomRight.RightRoomList.Add(new SeatManage.ClassModel.ReadingRoomInfo()
                     {
                         No = item.Value
                     });
                 }
             }
             user.ReloID.Clear();
             foreach (FineUI.CheckItem item in clbRole.Items)
             {
                 if (item.Selected)
                 {
                     user.ReloID.Add(int.Parse(item.Value));
                 }
             }
             if (SeatManage.Bll.Users_ALL.AddNewUser(user))
             {
                 PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                 FineUI.Alert.ShowInTop("用户添加成功!");
             }
             else
             {
                 FineUI.Alert.Show("数据错误添加失败!");
             }
         }
     }
     else
     {
         FineUI.Alert.Show("信息输入有误或不完整,请核对输入信息!");
     }
 }
コード例 #5
0
        public JsonResult ChangePass(string passOld, string pass1, string pass2)
        {
            JsonResult result = null;

            SeatManage.ClassModel.UserInfo user = SeatManage.Bll.Users_ALL.GetUserInfo(LoginId);
            if (user.Password != SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32(passOld))
            {
                result = Json(new { status = "no", message = "原密码错误,请重新输入!" }, JsonRequestBehavior.AllowGet);
            }
            else if (pass1 != pass2)
            {
                result = Json(new { status = "no", message = "两次新密码输入不匹配" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                user.Password = SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32(pass1);
                if (SeatManage.Bll.Users_ALL.UpdateUserOnlyInfo(user))
                {
                    //密码更新成功
                    result = Json(new { status = "yes", message = "密码更新成功" }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    //密码更新失败
                    result = Json(new { status = "no", message = "密码更新失败" }, JsonRequestBehavior.AllowGet);
                }
            }
            return(result);
        }
コード例 #6
0
 /// <summary>
 /// 获取用户信息
 /// </summary>
 /// <param name="loginid"></param>
 /// <returns></returns>
 private SeatManage.ClassModel.UserInfo GetUserInfo(string loginid)
 {
     SeatManage.ClassModel.UserInfo user = SeatManage.Bll.Users_ALL.GetUserInfo(loginid);
     if (user != null)
     {
         user.ReloID        = SeatManage.Bll.Users_ALL.GetRoleID(loginid);
         user.UserRoomRight = SeatManage.Bll.T_SM_ManagerPotency.GetManangePotencyByLoginID(loginid);
         user.UserMenus     = SeatManage.Bll.SysMenu.GetUserMenus(loginid);
         //获取全部对的阅览室权限
         if (loginid == "admin" || loginid == "user")
         {
             List <SeatManage.ClassModel.ReadingRoomInfo> rightrooms = SeatManage.Bll.ClientConfigOperate.GetReadingRooms(null);
             if (user.UserRoomRight == null || rightrooms.Count != user.UserRoomRight.RightRoomList.Count)
             {
                 user.UserRoomRight.RightRoomList.Clear();
                 foreach (SeatManage.ClassModel.ReadingRoomInfo room in rightrooms)
                 {
                     user.UserRoomRight.RightRoomList.Add(room);
                 }
                 SeatManage.Bll.Users_ALL.UpdateUserInfo(user);
             }
         }
     }
     return(user);
 }
コード例 #7
0
        /// <summary>
        /// 更新读者信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(SeatManage.ClassModel.UserInfo model)
        {
            SqlParameter[] parameters = new SqlParameter[7] {
                new SqlParameter("@UsrName", model.UserName),
                new SqlParameter("@LoginID", model.LoginId),
                new SqlParameter("@UsrPwd", model.Password),
                new SqlParameter("@UsrEnabled", (int)model.IsUsing),
                new SqlParameter("@UsrType", (int)model.UserType),
                new SqlParameter("@Remark", model.Remark),
                new SqlParameter("@IPLockIPAdress", model.LockIPAdress)
            };
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Users_ALL ");
            strSql.Append(" set UsrName=@UsrName,UsrPwd=@UsrPwd,LoginID=@LoginID  ,UsrEnabled=@UsrEnabled, UsrType=@UsrType,Remark=@Remark,IPLockIPAdress=@IPLockIPAdress ");
            strSql.Append(" where LoginID=@LoginID");
            try
            {
                int i = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                if (i > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
コード例 #8
0
        /// <summary>
        /// 添加新的用户并且授权。
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public HandleResult Add(SeatManage.ClassModel.UserInfo model)
        {
            SqlParameter[] parameters = new SqlParameter[7] {
                new SqlParameter("@UsrName", model.UserName),
                new SqlParameter("@LoginID", model.LoginId),
                new SqlParameter("@UsrPwd", model.Password),
                new SqlParameter("@UsrEnabled", (int)model.IsUsing),
                new SqlParameter("@UsrType", (int)model.UserType),
                new SqlParameter("@Remark", model.Remark),
                new SqlParameter("@ExcResult", SqlDbType.Int)
            };
            parameters[6].Direction = ParameterDirection.Output;
            if (string.IsNullOrEmpty(model.UserName))
            {
                parameters[0].SqlValue = DBNull.Value;
            }
            DbHelperSQL.Execute_Proc("[Proc_AddUserAll]", parameters);
            string id = parameters[1].Value.ToString();

            if (string.IsNullOrEmpty(id))
            {
                return(HandleResult.Failed);
            }
            else
            {
                return(HandleResult.Successed);
            }
        }
コード例 #9
0
        /// <summary>
        /// 获取全部用户
        /// </summary>
        /// <returns></returns>
        public List <UserInfo> GetUsers()
        {
            List <UserInfo> list = new List <UserInfo>();

            try
            {
                DataSet ds = dalUser_All.GetList(null, null);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        SeatManage.ClassModel.UserInfo userInfo = new SeatManage.ClassModel.UserInfo();
                        userInfo.LoginId  = dr["LoginID"].ToString();
                        userInfo.Password = dr["UsrPwd"].ToString();
                        userInfo.UserType = (UserType)int.Parse(dr["UsrType"].ToString());
                        userInfo.UserName = dr["UsrName"].ToString();
                        userInfo.IsUsing  = (LogStatus)int.Parse(dr["UsrEnabled"].ToString());
                        userInfo.Remark   = dr["Remark"].ToString();
                        if (dr["IPLockIPAdress"] != null)
                        {
                            userInfo.LockIPAdress = dr["IPLockIPAdress"].ToString();
                        }
                        list.Add(userInfo);
                    }
                }
                return(list);
            }
            catch
            {
                throw;
            }
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string cmd = Request.Form["subCmd"];

            if (Request.Cookies["userInfo"] != null)//存在记录的cookies信息
            {
                string loginId = CookiesManager.GetCookiesValue(CookiesManager.LoginID);
                SeatManage.ClassModel.UserInfo LoginUser = GetUserInfo(loginId);
                Session[CookiesManager.LoginID] = LoginUser.LoginId;
                Session[CookiesManager.Name]    = LoginUser.UserName;
                Response.Redirect("Pad/SeatPad.aspx");
            }
            //通过页面验证,执行登录操作
            if (cmd == "Login")
            {
                string loginId  = txt_LoginID.Value;
                string password = txt_Password.Value;
                SeatManage.Bll.Users_ALL userinfocheck = new SeatManage.Bll.Users_ALL();
                try
                {
                    loginId = userinfocheck.CheckUser(loginId, password);
                    //判断返回信息是否为空
                    if (string.IsNullOrEmpty(loginId))
                    {
                        spanWarmInfo.Visible   = true;
                        spanWarmInfo.InnerText = "用户名或密码错误";
                    }
                    else
                    {
                        SeatManage.ClassModel.UserInfo LoginUser = GetUserInfo(loginId);
                        Session[CookiesManager.LoginID] = LoginUser.LoginId;
                        Session[CookiesManager.Name]    = LoginUser.UserName;
                        if (LoginUser.UserType == SeatManage.EnumType.UserType.Admin)
                        {
                            //若选择记住密码,则记录用户信息cookies
                            if (chk_RemPasspword.Checked == true)
                            {
                                CookiesManager.SetPadCookies(loginId, password);
                            }
                            else//清除cookies
                            {
                                CookiesManager.RemoveCookies("userInfo");
                            }
                            Response.Redirect("Pad/SeatPad.aspx");
                        }
                        else
                        {
                            spanWarmInfo.Visible   = true;
                            spanWarmInfo.InnerText = "您不具备访问权限";
                        }
                    }
                }
                catch (Exception ex)
                {
                    spanWarmInfo.Visible   = true;
                    spanWarmInfo.InnerText = "数据库连接出错";
                }
            }
        }
コード例 #11
0
 /// <summary>
 /// 更新读者
 /// </summary>
 private void UpdateUser()
 {
     SeatManage.ClassModel.UserInfo user = SeatManage.Bll.Users_ALL.GetUserInfo(Request.QueryString["id"]);
     user.UserRoomRight = new SeatManage.ClassModel.ManagerPotency();
     user.ReloID        = new List <int>();
     if (!string.IsNullOrEmpty(txtPassword.Text.Trim()) || !string.IsNullOrEmpty(txtPassword_d.Text.Trim()))
     {
         if (txtPassword.Text.Trim() == txtPassword_d.Text.Trim())
         {
             user.Password = SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32(txtPassword.Text.Trim());
         }
         else
         {
             FineUI.Alert.Show("新密码输入有误,请核对两次输入的密码!");
         }
     }
     user.Remark       = txtRemark.Text.Trim();
     user.LockIPAdress = txtIPAdd.Text.Trim();
     user.UserName     = txtUserName.Text.Trim();
     if (clbused.Checked)
     {
         user.IsUsing = SeatManage.EnumType.LogStatus.Valid;
     }
     else
     {
         user.IsUsing = SeatManage.EnumType.LogStatus.Fail;
     }
     user.UserRoomRight.LoginID = user.LoginId;
     user.UserType = SeatManage.EnumType.UserType.Admin;
     user.UserRoomRight.RightRoomList.Clear();
     foreach (FineUI.CheckItem item in clbroom.Items)
     {
         if (item.Selected)
         {
             user.UserRoomRight.RightRoomList.Add(new SeatManage.ClassModel.ReadingRoomInfo()
             {
                 No = item.Value
             });
         }
     }
     user.ReloID.Clear();
     foreach (FineUI.CheckItem item in clbRole.Items)
     {
         if (item.Selected)
         {
             user.ReloID.Add(int.Parse(item.Value));
         }
     }
     if (SeatManage.Bll.Users_ALL.UpdateUserInfo(user))
     {
         PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
         FineUI.Alert.ShowInTop("用户修改成功!");
     }
     else
     {
         FineUI.Alert.Show("数据错误修改失败!");
     }
 }
コード例 #12
0
 /// <summary>
 /// 获取用户信息
 /// </summary>
 /// <param name="loginid"></param>
 /// <returns></returns>
 private SeatManage.ClassModel.UserInfo GetUserInfo(string loginid)
 {
     SeatManage.ClassModel.UserInfo user = SeatManage.Bll.Users_ALL.GetUserInfo(loginid);
     if (user != null)
     {
         user.ReloID        = SeatManage.Bll.Users_ALL.GetRoleID(loginid);
         user.UserRoomRight = SeatManage.Bll.T_SM_ManagerPotency.GetManangePotencyByLoginID(loginid);
     }
     return(user);
 }
コード例 #13
0
 /// <summary>
 /// 简单更新用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool UpdateUser(SeatManage.ClassModel.UserInfo user)
 {
     try
     {
         return(dalUser_All.Update(user));
     }
     catch
     {
         throw;
     }
 }
コード例 #14
0
 /// <summary>
 /// 获取帐号、需要在客户端验证密码。验证成功返回用户基础信息,否则返回空
 /// </summary>
 /// <param name="cardNum"></param>
 /// <param name="beforeDays"></param>
 /// <returns></returns>
 public string GetReaderAccount(string cardNum, string password)
 {
     try
     {
         if (string.IsNullOrEmpty(cardNum.Trim()) || string.IsNullOrEmpty(password.Trim()))
         {
             JM_HandleResult result = new JM_HandleResult();
             result.Result = false;
             result.Msg    = "用户名或密码不能为空!";
             return(SeatManage.SeatManageComm.JSONSerializer.Serialize(result));
         }
         JM_ReaderInfo reader = null;
         SeatManage.ClassModel.UserInfo user = seatDataService.GetUserInfo(cardNum);
         if (user != null)
         {
             string strPwd = SeatManageComm.MD5Algorithm.GetMD5Str32(password);
             if (strPwd.Equals(user.Password))
             {
                 reader        = new JM_ReaderInfo();
                 reader.CardNo = user.LoginId;
                 reader.Name   = user.UserName;
                 return(SeatManageComm.JSONSerializer.Serialize(reader));
             }
             else
             {
                 JM_HandleResult result = new JM_HandleResult();
                 result.Result = false;
                 result.Msg    = "用户名或密码错误!";
                 return(SeatManage.SeatManageComm.JSONSerializer.Serialize(result));
             }
         }
         else
         {
             JM_HandleResult result = new JM_HandleResult();
             result.Result = false;
             result.Msg    = "用户名或密码错误!";
             return(SeatManage.SeatManageComm.JSONSerializer.Serialize(result));
         }
     }
     catch (Exception ex)
     {
         SeatManage.SeatManageComm.WriteLog.Write("选择座位遇到异常:" + ex.Message);
         JM_HandleResult result = new JM_HandleResult();
         result.Result = false;
         result.Msg    = "执行遇到异常!";
         return(SeatManage.SeatManageComm.JSONSerializer.Serialize(result));
     }
 }
コード例 #15
0
        /// <summary>
        /// 编辑模式获取用户信息
        /// </summary>
        private void ShowUserInfo()
        {
            string loginid = Request.QueryString["id"];

            SeatManage.ClassModel.UserInfo user = SeatManage.Bll.Users_ALL.GetUserInfo(loginid);
            if (user != null)
            {
                user.ReloID        = SeatManage.Bll.Users_ALL.GetRoleID(loginid);
                user.UserRoomRight = SeatManage.Bll.T_SM_ManagerPotency.GetManangePotencyByLoginID(loginid);
            }
            txtLoginID.Text        = user.LoginId;
            txtLoginID.Readonly    = true;
            txtPassword.Label      = "新密码";
            txtPassword.Required   = false;
            txtPassword_d.Required = false;
            txtUserName.Required   = false;
            txtRemark.Text         = user.Remark;
            txtIPAdd.Text          = user.LockIPAdress;
            txtUserName.Text       = user.UserName;
            if (user.IsUsing == SeatManage.EnumType.LogStatus.Valid)
            {
                clbused.Checked = true;
            }
            else
            {
                clbused.Checked = false;
            }
            foreach (FineUI.CheckItem ci in clbRole.Items)
            {
                foreach (int role in user.ReloID)
                {
                    if (ci.Value == role.ToString())
                    {
                        ci.Selected = true;
                    }
                }
            }
            foreach (FineUI.CheckItem ci in clbroom.Items)
            {
                foreach (ReadingRoomInfo no in user.UserRoomRight.RightRoomList)
                {
                    if (ci.Value == no.No)
                    {
                        ci.Selected = true;
                    }
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// 检查用户登录密码并返回用户信息。验证错误,返回用户不存在的异常
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <param name="connStr">学校访问地址</param>
        /// <returns></returns>
        public SeatManage.ClassModel.ReaderInfo CheckAndGetReaderInfo(UserInfo user)
        {
            //验证密码
            string readerNo = "";

            try
            {
                //readerNo = seatManage.CheckUser(user.LoginId, user.Password);
                SeatManage.ClassModel.UserInfo reader = seatManage.GetUserInfo(user.LoginId);
                if (reader != null)
                {
                    if (reader.Password.Equals(SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32(user.Password)) && reader.IsUsing == EnumType.LogStatus.Valid)
                    {
                        readerNo = reader.LoginId;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            if (string.IsNullOrEmpty(readerNo))
            {
                throw new Exception("用户名或密码错误");
            }
            try
            {
                ReaderInfo reader = seatManage.GetReader(readerNo, true);
                if (reader != null)
                {
                    return(reader);
                }
                else
                {
                    throw new Exception("用户名或密码错误");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("验证失败"));
            }
        }
コード例 #17
0
        public JsonResult RemoveUser(string LoginId)
        {
            JsonResult result = null;

            SeatManage.ClassModel.UserInfo user = new SeatManage.ClassModel.UserInfo();
            user.LoginId = LoginId;
            if (user.LoginId == "admin" || user.LoginId == "user" || user.LoginId == "reader")
            {
                return(Json(new { status = "no", message = "删除失败[" + LoginId + "]是保留用戶,不能刪除" }, JsonRequestBehavior.AllowGet));
            }
            if (!SeatManage.Bll.Users_ALL.DeleteUser(user))
            {
                result = Json(new { status = "no", message = "删除失败" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                result = Json(new { status = "yes", message = "删除成功" }, JsonRequestBehavior.AllowGet);
            }
            return(result);
        }
 /// <summary>
 /// 管理员登录
 /// </summary>
 /// <param name="loginId">用户名</param>
 /// <param name="password">密码</param>
 /// <returns>登录成功返回用户信息,登录失败返回错误信息</returns>
 public string AdminLogin(string loginId, string password)
 {
     try
     {
         if (string.IsNullOrEmpty(loginId.Trim()) || string.IsNullOrEmpty(password.Trim()))
         {
             JM_HandleResultObject result = new JM_HandleResultObject();
             result.Result = false;
             result.Msg    = "用户名或密码不能为空!";
             return(SeatManage.SeatManageComm.JSONSerializer.Serialize(result));
         }
         JM_User user = null;
         SeatManage.ClassModel.UserInfo userInfo = seatDataService.GetUserInfo(loginId);
         if (userInfo != null)
         {
             string strPwd = SeatManageComm.MD5Algorithm.GetMD5Str32(password);
             if (strPwd.Equals(userInfo.Password))
             {
                 user          = new JM_User();
                 user.LoginId  = userInfo.LoginId;
                 user.UserName = userInfo.UserName;
                 if (userInfo.UserType == SeatManage.EnumType.UserType.Admin)
                 {
                     JM_HandleResultObject result = new JM_HandleResultObject();
                     result.Result = true;
                     result.Msg    = user;
                     return(SeatManageComm.JSONSerializer.Serialize(result));
                 }
                 else
                 {
                     JM_HandleResultObject result = new JM_HandleResultObject();
                     result.Result = false;
                     result.Msg    = "您不具备管理员权限!请使用管理员账号登录";
                     return(SeatManageComm.JSONSerializer.Serialize(result));
                 }
             }
             else
             {
                 JM_HandleResultObject result = new JM_HandleResultObject();
                 result.Result = false;
                 result.Msg    = "用户名或密码错误!";
                 return(SeatManage.SeatManageComm.JSONSerializer.Serialize(result));
             }
         }
         else
         {
             JM_HandleResultObject result = new JM_HandleResultObject();
             result.Result = false;
             result.Msg    = "用户名或密码错误!";
             return(SeatManage.SeatManageComm.JSONSerializer.Serialize(result));
         }
     }
     catch (Exception ex)
     {
         SeatManage.SeatManageComm.WriteLog.Write("登录遇到异常:" + ex.Message);
         JM_HandleResultObject result = new JM_HandleResultObject();
         result.Result = false;
         result.Msg    = "执行遇到异常!";
         return(SeatManage.SeatManageComm.JSONSerializer.Serialize(result));
     }
 }
コード例 #19
0
        public ActionResult AddOrEdit(string op, string LoginId)
        {
            SeatManage.ClassModel.UserInfo user = new SeatManage.ClassModel.UserInfo();
            StringBuilder roleHtml = new StringBuilder();
            StringBuilder roomHtml = new StringBuilder();

            List <SeatManage.ClassModel.SysRolesDicInfo> rolelist = SeatManage.Bll.SysRolesDic.GetRoleList(null, null);
            List <SeatManage.ClassModel.ReadingRoomInfo> roomlist = SeatManage.Bll.ClientConfigOperate.GetReadingRooms(null);


            if (op == "add")
            {
                foreach (var role in rolelist)
                {
                    roleHtml.Append("<input type=\"checkbox\"  ID=\"role_" + role.RoleID + "\" name=\"role_" + role.RoleID + "\" /><label for=\"role_" + role.RoleID + "\" class=\"hand\">" + role.RoleName + "</label>");
                }
                foreach (ReadingRoomInfo room in roomlist)
                {
                    roomHtml.Append("<input type=\"checkbox\"  ID=\"room_" + room.No + "\" name=\"room_" + room.No + "\" /><label for=\"room_" + room.No + "\" class=\"hand\">" + room.Name + "</label>");
                }
            }
            else if (op == "edit")
            {
                user = SeatManage.Bll.Users_ALL.GetUserInfo(LoginId);
                if (user != null)
                {
                    user.ReloID        = SeatManage.Bll.Users_ALL.GetRoleID(LoginId);
                    user.UserRoomRight = SeatManage.Bll.T_SM_ManagerPotency.GetManangePotencyByLoginID(LoginId);
                }
                foreach (var role in rolelist)
                {
                    string str = "<input type=\"checkbox\"  ID=\"role_" + role.RoleID + "\" name=\"role_" + role.RoleID + "\" /><label for=\"role_" + role.RoleID + "\" class=\"hand\">" + role.RoleName + "</label>";
                    foreach (int userRole in user.ReloID)
                    {
                        if (userRole == int.Parse(role.RoleID))
                        {
                            str = "<input type=\"checkbox\" checked=\"true\"  ID=\"role_" + role.RoleID + "\" name=\"role_" + role.RoleID + "\" /><label for=\"role_" + role.RoleID + "\" class=\"hand\">" + role.RoleName + "</label>";
                        }
                    }
                    roleHtml.Append(str);
                }
                foreach (var room in roomlist)
                {
                    string str = "<input type=\"checkbox\"  ID=\"room_" + room.No + "\" name=\"room_" + room.No + "\" /><label for=\"room_" + room.No + "\" class=\"hand\">" + room.Name + "</label>";
                    foreach (ReadingRoomInfo rr in user.UserRoomRight.RightRoomList)
                    {
                        if (rr.No == room.No)
                        {
                            str = "<input type=\"checkbox\" checked=\"true\"  ID=\"room_" + room.No + "\" name=\"room_" + room.No + "\" /><label for=\"room_" + room.No + "\" class=\"hand\">" + room.Name + "</label>";
                        }
                    }
                    roomHtml.Append(str);
                }
            }

            ViewBag.roleHtml = roleHtml.ToString();
            ViewBag.roomHtml = roomHtml.ToString();
            ViewBag.User     = user;
            ViewBag.op       = op;
            return(View());
        }
コード例 #20
0
        /// <summary>
        /// 保存或者更新
        /// </summary>
        /// <returns></returns>
        public JsonResult SaveOrUpdate()
        {
            JsonResult result = null;
            List <SeatManage.ClassModel.SysRolesDicInfo> rolelist = SeatManage.Bll.SysRolesDic.GetRoleList(null, null);
            List <SeatManage.ClassModel.ReadingRoomInfo> roomlist = SeatManage.Bll.ClientConfigOperate.GetReadingRooms(null);
            string LoginId     = Request.Params["LoginId"];
            string txtUserName = Request.Params["txtUserName"];
            string txtPassword = Request.Params["txtPassword"];
            string txtRemark   = Request.Params["txtRemark"];
            bool   IsUsing     = Request.Params["IsUsing"] == null ? false : true;

            bool saveOrUpdateIsOk = false;

            if (Request.Params["op"] == "add") //新增
            {
                SeatManage.ClassModel.UserInfo user = new SeatManage.ClassModel.UserInfo();
                user.LoginId  = LoginId;
                user.UserName = txtUserName;
                user.Password = SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32(txtPassword);   // user.Password = SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32(txtPassword.Text.Trim());
                user.Remark   = txtRemark;
                user.IsUsing  = IsUsing ? SeatManage.EnumType.LogStatus.Valid : SeatManage.EnumType.LogStatus.Fail;
                user.ReloID   = new List <int>();
                foreach (var role in rolelist)
                {
                    if (Request.Params["role_" + role.RoleID] != null)
                    {
                        user.ReloID.Add(int.Parse(role.RoleID));
                    }
                }
                user.UserRoomRight = new ManagerPotency();
                user.UserRoomRight.RightRoomList = new List <ReadingRoomInfo>();
                user.UserRoomRight.LoginID       = LoginId;
                foreach (var room in roomlist)
                {
                    if (Request.Params["room_" + room.No] != null)
                    {
                        user.UserRoomRight.RightRoomList.Add(new SeatManage.ClassModel.ReadingRoomInfo()
                        {
                            No = room.No
                        });
                    }
                }
                saveOrUpdateIsOk = SeatManage.Bll.Users_ALL.AddNewUser(user);
            }
            else //编辑
            {
                SeatManage.ClassModel.UserInfo user = SeatManage.Bll.Users_ALL.GetUserInfo(LoginId);
                user.LoginId  = LoginId;
                user.UserName = txtUserName;
                user.Password = SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32(txtPassword);
                user.Remark   = txtRemark;
                user.IsUsing  = IsUsing ? SeatManage.EnumType.LogStatus.Valid : SeatManage.EnumType.LogStatus.Fail;
                user.ReloID.Clear();
                foreach (var role in rolelist)
                {
                    if (Request.Params["role_" + role.RoleID] != null)
                    {
                        user.ReloID.Add(int.Parse(role.RoleID));
                    }
                }
                user.UserRoomRight.RightRoomList.Clear();
                user.UserRoomRight.LoginID = LoginId;
                foreach (var room in roomlist)
                {
                    if (Request.Params["room_" + room.No] != null)
                    {
                        user.UserRoomRight.RightRoomList.Add(new SeatManage.ClassModel.ReadingRoomInfo()
                        {
                            No = room.No
                        });
                    }
                }
                saveOrUpdateIsOk = SeatManage.Bll.Users_ALL.UpdateUserInfo(user);
            }

            result = saveOrUpdateIsOk ? Json(new { status = "yes", message = "保存成功" }, JsonRequestBehavior.AllowGet) : Json(new { status = "no", message = "保存失败" }, JsonRequestBehavior.AllowGet);
            // var jsonstr = JsonConvert.SerializeObject(result);
            return(result);
        }