コード例 #1
0
        public bool UpdateUserInfo(UserInfo userInfo)
        {
            //var sqlText = string.Format("update {0} set UserName='******',Password='******' where UserID=@userID", _userInfoTableName);
            //var paras = new OleDbParameter[3];
            //paras[0] = new OleDbParameter("userName", userInfo.UserName);
            //paras[1] = new OleDbParameter("password", userInfo.Password);
            //paras[2] = new OleDbParameter("userID", userInfo.UserID);

            var sqlText = string.Format("update {0} set [UserName]='{1}',[Password]='{2}' where [UserID]={3}", _userInfoTableName, userInfo.UserName, userInfo.Password, userInfo.UserID);
            return new OLESqlHelper().ExecuteNoneQuery(sqlText);
        }
コード例 #2
0
        public UserInfo GetUserInfoByName(string userName)
        {
            var sqlText = "select * from UserInfo where UserName=@userName";
            var paras = new OleDbParameter[1];
            paras[0] = new OleDbParameter("userName", userName);

            using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) {
                using (var reader = new OLESqlHelper().GetReader(sqlText, connection, paras)) {
                    reader.Read();
                    var userInfo = new UserInfo();
                    userInfo.UserID = reader.GetInt32(0);
                    userInfo.UserName = reader.GetString(1);
                    userInfo.Password = reader.GetString(2);
                    return userInfo;
                }
            }
        }
コード例 #3
0
ファイル: UserBLL.cs プロジェクト: 0811112150/HappyDayHistory
        public CResult<bool> UpdateUserInfo(WebUserInfo webUserInfo)
        {
            if (webUserInfo == null) {
                return new CResult<bool>(false, ErrorCode.ParameterError);
            }
            if (string.IsNullOrEmpty(webUserInfo.UserName) || string.IsNullOrEmpty(webUserInfo.OldPassword)
            || string.IsNullOrEmpty(webUserInfo.NewPassword) || string.IsNullOrEmpty(webUserInfo.ConfirmPassword)) {
                return new CResult<bool>(false, ErrorCode.ParameterError);
            }
            if (webUserInfo.NewPassword != webUserInfo.ConfirmPassword) {
                return new CResult<bool>(false, ErrorCode.ParameterError);
            }

            var oldUserInfo = GetUserInfoByID(webUserInfo.UserID).Data;
            if (oldUserInfo == null) {
                return new CResult<bool>(false, ErrorCode.UserNotExist);
            }
            if (oldUserInfo.OldPassword != webUserInfo.OldPassword) {
                return new CResult<bool>(false, ErrorCode.UserPasswordError);
            }

            if (oldUserInfo.UserName == webUserInfo.UserName && oldUserInfo.OldPassword == webUserInfo.NewPassword) {
                return new CResult<bool>(true);
            }

            var userInfo = new UserInfo() {
                UserID = webUserInfo.UserID,
                Password = webUserInfo.NewPassword,
                UserName = webUserInfo.UserName,
            };

            if (new UserInfoDAL().UpdateUserInfo(userInfo)) {
                return new CResult<bool>(true);
            } else {
                return new CResult<bool>(false, ErrorCode.SaveDataFailed);
            }
        }