Esempio n. 1
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);
            }
        }
Esempio n. 2
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);
            }
        }