コード例 #1
0
        public List <UserManageViewModel> selectUsers(string loginId, int userState, int pageIndex, out int pageTotal, out int pageCount, out string Msg, out int Code)
        {
            Expression <Func <P_Person, bool> > where = c => true;
            if (!string.IsNullOrEmpty(loginId))
            {
                where = where.And(c => c.PersonName.Contains(loginId));
            }
            if (userState == 0 || userState == 1)
            {
                where = where.And(c => c.AccountState == userState);
            }

            using (var db = new PeiSongEntities())
            {
                //总条数
                pageTotal = db.P_Person.Where(where).Count();
                //总页数
                pageCount = Convert.ToInt32(Math.Ceiling((decimal)pageTotal / PageSize.Count));
                var list = db.P_Person.Where(where).Skip((pageIndex - 1) * PageSize.Count).Take(PageSize.Count).Select(t => new UserManageViewModel {
                    Uid = t.PersonID, LoginID = t.LogID, Phone = t.PersonPhone, State = Enum.GetName(typeof(OrderState), Convert.ToInt32(t.AccountState))
                }).ToList();
                Msg  = "操作成功";
                Code = (int)ReturnCode.OK;
                return(list);
            }
        }
コード例 #2
0
        public UserInfoSelfViewModel app_UserLogin(string loginID, string secretString, out string Msg, out int Code)
        {
            using (var db = new PeiSongEntities())
            {
                var userInfo = db.P_Person.Single(c => c.PersonID == loginID);
                if (userInfo == null)
                {
                    Msg = "用户不存在";
                }
                string pwd = Encrypt_Helper_SF.UserMd5(secretString.Trim() + "SF_Frame_app_8");
                if (userInfo.PersonPwd != pwd)
                {
                    Msg = "账号或密码错误";
                }
                Msg  = "登录成功";
                Code = (int)ReturnCode.OK;
                UserInfoSelfViewModel model = new UserInfoSelfViewModel();
                model.UserID  = userInfo.PersonID.ToString();
                model.LoginId = userInfo.LogID;
                model.Phone   = userInfo.PersonPhone;
                // model.Address = userInfo.Address;
                model.UserName = userInfo.PersonName;

                return(model);
            }
        }
コード例 #3
0
        public bool UpdateUser(UserViewModel modelView, out string error_msg, out int error_code)
        {
            bool returnValue = false;

            error_msg  = "操作失败";
            error_code = (int)ReturnCode.OPERATION_FAILED;
            using (var db = new PeiSongEntities())
            {
                S_User model = db.S_User.FirstOrDefault(c => c.UserID == modelView.UserID);
                model.LogCode    = modelView.LoginId;
                model.UserName   = modelView.UserName;
                model.Gender     = modelView.Gender;
                model.UserPhone  = modelView.UserPhone; // modelView.Address;
                model.RoleID     = modelView.RoleID;    // (int)RecordState.NORMAL;
                model.UserState  = modelView.UserState;
                model.Updator    = modelView.Updator;
                model.UpdateTime = DateTime.Now;
                if (db.SaveChanges() > 0)
                {
                    error_msg   = "添加成功";
                    error_code  = (int)ReturnCode.OK;
                    returnValue = true;
                }
                return(returnValue);
            }
        }
コード例 #4
0
        //add userInfo
        public bool AddUser(UserViewModel modelView, out string error_msg, out int error_code)
        {
            bool returnValue = false;

            error_msg  = "操作失败";
            error_code = (int)ReturnCode.OPERATION_FAILED;
            using (var db = new PeiSongEntities())
            {
                S_User model = new S_User();
                model.UserID     = Guid.NewGuid().ToString("N");
                model.LogCode    = modelView.LoginId;
                model.UserPwd    = Encrypt_Helper_SF.UserMd5(modelView.UserPwd.Trim() + "SF_Frame_app_8");
                model.UserName   = modelView.UserName;
                model.Gender     = modelView.Gender;
                model.UserPhone  = modelView.UserPhone;
                model.RoleID     = "0";// (int)RecordState.NORMAL;
                model.UserState  = (int)UserState.NORMAL;
                model.Creator    = modelView.Creator;
                model.CreateTime = DateTime.Now;
                db.S_User.Add(model);
                if (db.SaveChanges() > 0)
                {
                    error_msg   = "添加成功";
                    error_code  = (int)ReturnCode.OK;
                    returnValue = true;
                }
                return(returnValue);
            }
        }
コード例 #5
0
ファイル: UserLogin.cs プロジェクト: Liwenyuan123/ordercenter
        public UserInfoSelfViewModel app_UserLogin(string loginID, string loginPwd, out string error_message, out int error_code)
        {
            using (var db = new PeiSongEntities())
            {
                var userInfo = db.S_User.FirstOrDefault(c => c.LogCode == loginID);
                UserInfoSelfViewModel model = new UserInfoSelfViewModel();
                if (userInfo == null)
                {
                    error_message = "用户不存在"; error_code = -1; return(model);
                }
                string pwd = Encrypt_Helper_SF.UserMd5(loginPwd + "SF_Frame_app_8");
                if (userInfo.UserPwd != pwd)
                {
                    error_message = "账号或密码错误"; error_code = -1; return(model);
                }
                error_message = "登录成功";
                error_code    = (int)ReturnCode.OK;

                model.UserID   = userInfo.UserID.ToString();
                model.LoginId  = userInfo.LogCode;
                model.Phone    = userInfo.UserPhone;
                model.UserName = userInfo.UserName;
                return(model);
            }
        }
コード例 #6
0
        //select all usersInfo
        public List <S_User> SelectUsers(string loginName, int userState, int pageIndex, int pageSize, out int pageTotal, out string error_msg, out int error_code)
        {
            error_msg  = "操作失败";
            error_code = (int)ReturnCode.OPERATION_FAILED;
            List <S_User> userList = new List <S_User>();

            using (var db = new PeiSongEntities())
            {
                pageTotal = db.S_User.Where(c => c.LogCode == loginName && c.UserState == userState).Count();
                userList  = db.S_User.Where(c => c.LogCode == loginName && c.UserState == userState).OrderByDescending(c => c.CreateTime).Skip(pageIndex * pageSize).Take(pageSize).ToList();
            }
            return(userList);
        }
コード例 #7
0
 //updatePassWord
 public bool updatePassWord(string uid, string pwd, out string Msg)
 {
     using (var db = new PeiSongEntities())
     {
         Msg = "操作失败";
         var model = db.P_Person.FirstOrDefault(c => c.PersonID.ToString() == uid);
         model.PersonPwd = Encrypt_Helper_SF.UserMd5(pwd + "SF_Frame_app_8");
         bool re = db.SaveChanges() > 0;
         if (re)
         {
             Msg = "修改成功";
         }
         return(re);
     }
 }
コード例 #8
0
 //update UserState
 public bool UpdateUserState(string userID, int userState, out string error_msg, out int error_code)
 {
     error_msg  = "操作失败";
     error_code = (int)ReturnCode.OPERATION_FAILED;
     using (var db = new PeiSongEntities())
     {
         var model = db.S_User.FirstOrDefault(c => c.UserID == userID);
         model.UserState = userState;
         if (db.SaveChanges() > 0)
         {
             error_msg  = "操作成功";
             error_code = (int)ReturnCode.OK;
             return(true);
         }
         return(false);
     }
 }
コード例 #9
0
 public List <UserManageViewModel> updateUser(string uid, string loginId, string userName, string phone, out string Msg, out int Code)
 {
     Msg  = "操作失败";
     Code = (int)ReturnCode.OPERATION_FAILED;
     using (var db = new PeiSongEntities())
     {
         var model = db.P_Person.FirstOrDefault(c => c.PersonID == uid);
         model.PersonID    = loginId;
         model.PersonName  = userName;
         model.PersonPhone = phone;
         if (db.SaveChanges() > 0)
         {
             Msg  = "修改成功";
             Code = (int)ReturnCode.OK;
         }
         List <UserManageViewModel> list = db.P_Person.Where(c => c.AccountState == (int)RecordState.NORMAL).Select(c => new UserManageViewModel()
         {
             Uid = c.PersonID, LoginID = c.LogID, UserName = c.PersonName, Phone = c.PersonPhone, State = Enum.GetName(typeof(RecordState), c.AccountState)
         }).ToList();
         return(list);
     }
 }