Exemplo n.º 1
0
        //------------------------------------------------------------------------------------------
        /// <summary>
        /// 增加一条记录
        /// </summary>
        /// <param name="entity"></param>
        public bool Append(User_info entity)
        {
            string sqlCmd = "insert into mp_user_info (DeptID ,UserLoginName ,UserPassword ,UserName ,IsAdmin ,Description ,CreateTime ,LastModifyTime ,ModifiedUserID ,MobliePhone ,WorkPhone ,Email ,Status ,Address ,Deleted ,Groups ,Level ,MaxCreateNumber ,ExpireTime ,Province ,City ,GroupNames ,MakeRate ,NotMakeRate ,AgentRate ,CreateUser) values (@DeptID ,@UserLoginName ,@UserPassword ,@UserName ,@IsAdmin ,@Description ,@CreateTime ,@LastModifyTime ,@ModifiedUserID ,@MobliePhone ,@WorkPhone ,@Email ,@Status ,@Address ,@Deleted ,@Groups ,@Level ,@MaxCreateNumber ,@ExpireTime ,@Province ,@City ,@GroupNames ,@MakeRate ,@NotMakeRate ,@AgentRate ,@CreateUser);SELECT  LAST_INSERT_ID();";
            MySqlParameter[] pars = new MySqlParameter[26];
            pars[0] = new MySqlParameter("@DeptID",entity.DeptID);
            pars[1] = new MySqlParameter("@UserLoginName",entity.UserLoginName);
            pars[2] = new MySqlParameter("@UserPassword",entity.UserPassword);
            pars[3] = new MySqlParameter("@UserName",entity.UserName);
            pars[4] = new MySqlParameter("@IsAdmin",entity.IsAdmin);
            pars[5] = new MySqlParameter("@Description",entity.Description);
            pars[6] = new MySqlParameter("@CreateTime",entity.CreateTime);
            pars[7] = new MySqlParameter("@LastModifyTime",entity.LastModifyTime);
            pars[8] = new MySqlParameter("@ModifiedUserID",entity.ModifiedUserID);
            pars[9] = new MySqlParameter("@MobliePhone",entity.MobliePhone);
            pars[10] = new MySqlParameter("@WorkPhone",entity.WorkPhone);
            pars[11] = new MySqlParameter("@Email",entity.Email);
            pars[12] = new MySqlParameter("@Status",entity.Status);
            pars[13] = new MySqlParameter("@Address",entity.Address);
            pars[14] = new MySqlParameter("@Deleted",entity.Deleted);
            pars[15] = new MySqlParameter("@Groups",entity.Groups);
            pars[16] = new MySqlParameter("@Level",entity.Level);
            pars[17] = new MySqlParameter("@MaxCreateNumber",entity.MaxCreateNumber);
            pars[18] = new MySqlParameter("@ExpireTime",entity.ExpireTime);
            pars[19] = new MySqlParameter("@Province",entity.Province);
            pars[20] = new MySqlParameter("@City",entity.City);
            pars[21] = new MySqlParameter("@GroupNames",entity.GroupNames);
            pars[22] = new MySqlParameter("@MakeRate",entity.MakeRate);
            pars[23] = new MySqlParameter("@NotMakeRate",entity.NotMakeRate);
            pars[24] = new MySqlParameter("@AgentRate",entity.AgentRate);
            pars[25] = new MySqlParameter("@CreateUser",entity.CreateUser);

            entity.UserID = Convert.ToInt32(MySqlHelper.ExecuteScalar(CommandType.Text, sqlCmd,pars));
            return true;
        }
Exemplo n.º 2
0
 //------------------------------------------------------------------------------------------
 /// <summary>
 /// 新增一条记录
 /// </summary>
 /// <param name="entity"></param>
 public bool Append(User_info entity)
 {
     try
     {
         bool result = _User_infoDal.Append(entity);
         ClearCacheData();
         return result;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
        public ActionResult SaveAdmin(int? UserID)
        {
            string backUrl = Url.Action("adminlist");
            User_info entity = new User_info();
            string[] allowProperty = new string[] { "UserName", "UserLoginName", "Level", "Status", "MobliePhone", "Email", "MaxCreateNumber", "ExpireTime", "Province", "City", "MakeRate", "NotMakeRate" };

            PageCommandType type = PageCommandType.增加;
            if (UserID.HasValue)
            {
                type = PageCommandType.更新;
                //目前只考虑主键只有一个,且为自增长
                entity = User_infoBLL.Current.GetByID(UserID.Value);

            }
            TryUpdateModel(entity, allowProperty);

            entity.LastModifyTime = DateTime.Now;
            //end
            User_info checkNameStore = User_infoBLL.Current.GetByUserLoginName(entity.UserLoginName);
            //验证
            if (string.IsNullOrEmpty(entity.UserLoginName))
            {
                return CommonResult.ShowMessage("登陆名不能为空!", backUrl);
            }

            var groupsID = DTLRequest.GetRequestIntList("groups").Distinct();
            entity.GroupNames = string.Join(",", Role_groupBLL.Current.CacheAllDataList().Where(item => groupsID.Contains(item.GroupID)));
            entity.Groups = string.Join(",", groupsID);
            entity.GroupNames = string.Join(",", Role_groupBLL.Current.CacheAllDataList().Where(item => entity.UsersGroupsList.Contains(item.GroupID)).Select(item => item.GroupName));

            string passwrod = DTLRequest.GetString("UserPassword");

            int? createUserID = null;// CurrentUserInfo.CurrentUser.UserID;
            //增加操作
            if (type == PageCommandType.增加)
            {
                if (string.IsNullOrEmpty(passwrod))
                {
                    return CommonResult.ShowMessage("登陆密码不能空!", backUrl);
                }

                if (checkNameStore != null)
                {
                    return CommonResult.ShowMessage("已经存在账号登陆名", backUrl);
                }

                entity.CreateTime = DateTime.Now;
                entity.UserPassword = Utils.MD5(passwrod);

                entity.CreateUser = createUserID ?? CurrentUserInfo.CurrentUser.UserID;

                if (User_infoBLL.Current.Append(entity))
                {
                    return CommonResult.ShowMessage("增加成功", backUrl);
                }
            }
            else if (type == PageCommandType.更新)
            {
                if (createUserID.HasValue)
                {
                    entity.CreateUser = createUserID.Value;
                }
                if (!string.IsNullOrEmpty(passwrod))
                {
                    entity.UserPassword = Utils.MD5(passwrod);
                }
                if (checkNameStore != null && entity.UserID != checkNameStore.UserID)
                {
                    return CommonResult.ShowMessage("已经存在账号登陆名", backUrl);
                }

                if (User_infoBLL.Current.Update(entity))
                {
                    return CommonResult.ShowMessage("更新成功", backUrl);
                }
            }
            return CommonResult.ShowMessage("保存失败", backUrl);
        }
Exemplo n.º 4
0
 public void SetUserAuthInfo(User_info userinfo)
 {
     //设置用户分组
     userinfo.UserGroup = Role_groupBLL.Current.CacheAllDataList().Where(item => userinfo.UsersGroupsList.Contains(item.GroupID)).ToList();
     //调用用户资源
     //先获取去重复的资源ID列表
     var resids = new List<int>();
     userinfo.UserGroup.ForEach(item => resids.AddRange(item.Auth_ResourceList));
     resids = resids.Distinct().ToList();
     userinfo.UserResource = Role_resourceBLL.Current.CacheAllDataList().Where(item => resids.Contains(item.ResourceID)).OrderByDescending(item => item.Sort).ToList();
     //设置用户actions
     var actionIDs = new List<int>();
     userinfo.UserGroup.ForEach(item => actionIDs.AddRange(item.Auth_ActionList));
     actionIDs = actionIDs.Distinct().ToList();
     userinfo.UserAction = Role_actionBLL.Current.CacheAllDataList().Where(item => actionIDs.Contains(item.ActionID)).OrderByDescending(item => item.Sort).ToList();
 }
Exemplo n.º 5
0
 /// <summary>
 /// 判断当前用户是否拥有某个功能的权限
 /// </summary>
 /// <param name="cotrollerName">控制器名</param>
 /// <param name="actionName">功能名</param>
 /// <returns>如果有权限就返回True,如果相应的控制器不存在,或者已经被禁用,或者无权限则返回False</returns>
 public bool HasActionAuth(User_info info, string cotrollerName, string actionName)
 {
     return info.UserAction.Where(item => item.ControllerName.Equals(cotrollerName, StringComparison.InvariantCultureIgnoreCase) &&
         item.ActionName.Equals(actionName, StringComparison.InvariantCultureIgnoreCase) &&
         item.Status == 1).FirstOrDefault() != null;
 }
Exemplo n.º 6
0
 //------------------------------------------------------------------------------------------
 /// <summary>
 /// 把reader转换成Entity
 /// </summary>
 /// <param name="table">表数据</param>
 /// <returns></returns>
 private User_info DataReaderToEntity(IDataReader reader)
 {
     User_info entity= new User_info();
     entity.UserID = Convert.ToInt32(reader["UserID"]) ;
     entity.DeptID = Convert.ToInt32(reader["DeptID"]) ;
     entity.UserLoginName = Convert.ToString(reader["UserLoginName"]) ;
     entity.UserPassword = Convert.ToString(reader["UserPassword"]) ;
     entity.UserName = Convert.ToString(reader["UserName"]) ;
     entity.IsAdmin = Convert.ToString(reader["IsAdmin"]) ;
     entity.Description = Convert.ToString(reader["Description"]) ;
     entity.CreateTime = Convert.ToDateTime(reader["CreateTime"]) ;
     entity.LastModifyTime = Convert.ToDateTime(reader["LastModifyTime"]) ;
     entity.ModifiedUserID = Convert.ToString(reader["ModifiedUserID"]) ;
     entity.MobliePhone = Convert.ToString(reader["MobliePhone"]) ;
     entity.WorkPhone = Convert.ToString(reader["WorkPhone"]) ;
     entity.Email = Convert.ToString(reader["Email"]) ;
     entity.Status = Convert.ToInt32(reader["Status"]) ;
     entity.Address = Convert.ToString(reader["Address"]) ;
     entity.Deleted = Convert.ToInt32(reader["Deleted"]) ;
     entity.Groups = Convert.ToString(reader["Groups"]) ;
     entity.Level = Convert.ToInt32(reader["Level"]) ;
     entity.MaxCreateNumber = Convert.ToInt32(reader["MaxCreateNumber"]) ;
     entity.ExpireTime = Convert.ToDateTime(reader["ExpireTime"]) ;
     entity.Province = Convert.ToString(reader["Province"]) ;
     entity.City = Convert.ToString(reader["City"]) ;
     entity.GroupNames = Convert.ToString(reader["GroupNames"]) ;
     entity.MakeRate = Convert.ToDecimal(reader["MakeRate"]) ;
     entity.NotMakeRate = Convert.ToDecimal(reader["NotMakeRate"]) ;
     entity.AgentRate = Convert.ToDecimal(reader["AgentRate"]) ;
     entity.CreateUser = Convert.ToInt32(reader["CreateUser"]) ;
     return entity;
 }
Exemplo n.º 7
0
        //------------------------------------------------------------------------------------------
        /// <summary>
        /// 更新一条记录
        /// </summary>
        /// <param name="entity"></param>
        public bool Update(User_info entity)
        {
            string sqlCmd = "update mp_user_info set  DeptID = @DeptID, UserLoginName = @UserLoginName, UserPassword = @UserPassword, UserName = @UserName, IsAdmin = @IsAdmin, Description = @Description, CreateTime = @CreateTime, LastModifyTime = @LastModifyTime, ModifiedUserID = @ModifiedUserID, MobliePhone = @MobliePhone, WorkPhone = @WorkPhone, Email = @Email, Status = @Status, Address = @Address, Deleted = @Deleted, Groups = @Groups, Level = @Level, MaxCreateNumber = @MaxCreateNumber, ExpireTime = @ExpireTime, Province = @Province, City = @City, GroupNames = @GroupNames, MakeRate = @MakeRate, NotMakeRate = @NotMakeRate, AgentRate = @AgentRate, CreateUser = @CreateUser  where   UserID =  @UserID ";

            MySqlParameter[] pars = new MySqlParameter[27];
            pars[0] = new MySqlParameter("@UserID",entity.UserID);
            pars[1] = new MySqlParameter("@DeptID",entity.DeptID);
            pars[2] = new MySqlParameter("@UserLoginName",entity.UserLoginName);
            pars[3] = new MySqlParameter("@UserPassword",entity.UserPassword);
            pars[4] = new MySqlParameter("@UserName",entity.UserName);
            pars[5] = new MySqlParameter("@IsAdmin",entity.IsAdmin);
            pars[6] = new MySqlParameter("@Description",entity.Description);
            pars[7] = new MySqlParameter("@CreateTime",entity.CreateTime);
            pars[8] = new MySqlParameter("@LastModifyTime",System.DateTime.Now);
            pars[9] = new MySqlParameter("@ModifiedUserID",entity.ModifiedUserID);
            pars[10] = new MySqlParameter("@MobliePhone",entity.MobliePhone);
            pars[11] = new MySqlParameter("@WorkPhone",entity.WorkPhone);
            pars[12] = new MySqlParameter("@Email",entity.Email);
            pars[13] = new MySqlParameter("@Status",entity.Status);
            pars[14] = new MySqlParameter("@Address",entity.Address);
            pars[15] = new MySqlParameter("@Deleted",entity.Deleted);
            pars[16] = new MySqlParameter("@Groups",entity.Groups);
            pars[17] = new MySqlParameter("@Level",entity.Level);
            pars[18] = new MySqlParameter("@MaxCreateNumber",entity.MaxCreateNumber);
            pars[19] = new MySqlParameter("@ExpireTime",entity.ExpireTime);
            pars[20] = new MySqlParameter("@Province",entity.Province);
            pars[21] = new MySqlParameter("@City",entity.City);
            pars[22] = new MySqlParameter("@GroupNames",entity.GroupNames);
            pars[23] = new MySqlParameter("@MakeRate",entity.MakeRate);
            pars[24] = new MySqlParameter("@NotMakeRate",entity.NotMakeRate);
            pars[25] = new MySqlParameter("@AgentRate",entity.AgentRate);
            pars[26] = new MySqlParameter("@CreateUser",entity.CreateUser);

            return MySqlHelper.ExecuteNonQuery(CommandType.Text,sqlCmd,  pars);
        }