示例#1
0
 /// <summary>
 /// 新增用户
 /// </summary>
 /// <param name="userDto"></param>
 /// <returns></returns>
 public bool InsertUser(UserDto userDto)
 {
     try
     {
         _sysUserRepository.BeginTran();//开始事务
         SysUser User = new SysUser();
         User.Id           = IdWorkerHelper.NewId();
         User.Account      = userDto.Account;
         User.Password     = DESEncrypt.Encrypt(userDto.Password);
         User.RealName     = userDto.RealName;
         User.Gender       = userDto.Gender;
         User.DepartmentId = userDto.DepartmentId;
         User.Birthday     = userDto.Birthday;
         User.Portrait     = userDto.Portrait;
         User.Email        = userDto.Email;
         User.Phone        = userDto.Phone;
         User.Remark       = userDto.Remark;
         User.Status       = (int)StatusType.Enabled;
         User.IsDeleted    = (int)IsDeletedType.No;
         User.CreateTime   = DateTime.Now;
         User.CreateUserId = _userHelper.Id;
         User.ModifyTime   = DateTime.Now;
         User.ModifyUserId = _userHelper.Id;
         bool result = _sysUserRepository.Insert(User);
         _sysUserRepository.CommitTran();
         return(result);
     }
     catch (Exception ex)
     {
         _sysUserRepository.RollbackTran();//回滚事务
         throw ex;
     }
 }