public DTOPermission Permin(int id) { string query = "select tb_usuario.id_usuario, tb_permissao.bt_adm, tb_permissao.bt_rh, tb_permissao.bt_fin, tb_permissao.bt_cont, tb_permissao.bt_comp, tb_permissao.bt_vend from tb_usuario inner join tb_permissao on tb_usuario.id_usuario = tb_permissao.id_usuario WHERE tb_usuario.id_usuario = @id"; List <MySqlParameter> parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("id", id)); ProjetoDataBase sql = new ProjetoDataBase(); MySqlDataReader reader = sql.ExecuteSelectParamters(query, parameters); DTOPermission var = new DTOPermission(); if (reader.Read() == true) { var.IdUser = reader.GetInt32("id_usuario"); var.Administrator = reader.GetBoolean("bt_adm"); var.Rh = reader.GetBoolean("bt_rh"); var.Fin = reader.GetBoolean("bt_fin"); var.Cont = reader.GetBoolean("bt_cont"); var.Comp = reader.GetBoolean("bt_comp"); var.Vend = reader.GetBoolean("bt_vend"); } reader.Close(); return(var); }
public async Task <IHttpActionResult> add([FromBody] DTOPermission permission) { #region /// 检查输入信息正确性 if (!ModelState.IsValid) { return(BadRequest(this.GetModelStateError(ModelState))); } #endregion try { // 调用服务创建 var result = await Service.CreateAsync(permission); // 根据服务返回值确定返回 if (result.ResultType == Common.OperationResultType.Success) { return(Ok(true)); } return(BadRequest(result.Message)); } catch (BusinessException ex) { return(BadRequest(ex.Message)); } catch (ComponentException ex) { return(BadRequest(ex.Message)); } }
/// <summary> /// 创建实体 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual async Task <OperationResult> CreateAsync(DTOPermission entity) { //校验参数!=NULL PublicHelper.CheckArgument(entity, "entity"); // 实体模型转换 var permission = DtoMap.Map <SysPermission>(entity); // 校验实体 var validateResult = await Validator.ValidateAsync(permission); if (validateResult.ResultType != OperationResultType.Success) { return(validateResult); } try { // 添加到实体集合中 repository.Insert(permission, AutoSaved); // 返回正确 return(new OperationResult(OperationResultType.Success)); } catch (DataAccessException ex) { return(new OperationResult(OperationResultType.Error, ex.Message)); } }
public DTOPermission Permin(int id) { PermissaoDataBase c = new PermissaoDataBase(); DTOPermission a = c.Permin(id); if (a.IdUser >= 1) { return(a); } else { a.IdUser = 0; } return(a); }
public void UpdatePerms(DTOPermission Perm) { string query = "UPDATE tb_permissao SET bt_adm = @bt_adm,bt_rh = @bt_rh,bt_fin = @bt_fin,bt_cont = @bt_cont,bt_comp = @bt_comp,bt_vend = @bt_vend WHERE id_usuario = @id_usuario"; List <MySqlParameter> parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("bt_adm", Perm.Administrator)); parameters.Add(new MySqlParameter("bt_rh", Perm.Rh)); parameters.Add(new MySqlParameter("bt_fin", Perm.Fin)); parameters.Add(new MySqlParameter("bt_cont", Perm.Cont)); parameters.Add(new MySqlParameter("bt_comp", Perm.Comp)); parameters.Add(new MySqlParameter("bt_vend", Perm.Vend)); parameters.Add(new MySqlParameter("id_usuario", Perm.IdUser)); ProjetoDataBase database = new ProjetoDataBase(); database.ExecuteInsertParamters(query, parameters); }
public void SavePermission(DTOPermission Perm) { string query = "insert into tb_permissao(bt_adm,bt_rh,bt_fin,bt_cont,bt_comp,bt_vend,id_usuario) values (@bt_adm,@bt_rh,@bt_fin,@bt_cont,@bt_comp,@bt_vend,@id_usuario)"; List <MySqlParameter> parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("bt_adm", Perm.Administrator)); parameters.Add(new MySqlParameter("bt_rh", Perm.Rh)); parameters.Add(new MySqlParameter("bt_fin", Perm.Fin)); parameters.Add(new MySqlParameter("bt_cont", Perm.Cont)); parameters.Add(new MySqlParameter("bt_comp", Perm.Comp)); parameters.Add(new MySqlParameter("bt_vend", Perm.Vend)); parameters.Add(new MySqlParameter("id_usuario", Perm.IdUser)); ProjetoDataBase database = new ProjetoDataBase(); database.ExecuteInsertParamters(query, parameters); }
/// <summary> /// 更新实体 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual async Task <OperationResult> UpdateAsync(DTOPermission entity) { /// 更新角色信息 /// 考虑是否需要限制更改角色名称 /// 其他更新信息同样存在这个问题 //校验参数!=NULL PublicHelper.CheckArgument(entity, "entity"); // 获取用户 var permission = repository.Entities.SingleOrDefault(m => m.Name.Equals(entity.Name)); if (permission == null) { return(new OperationResult(OperationResultType.Warning, String.Format(CultureInfo.CurrentCulture, Systems.SysResources.PermissionNotExist , entity.Name))); } // 实体模型转换 permission = DtoMap.Map <DTOPermission, SysPermission>(entity, permission); // 校验实体 var validateResult = await Validator.ValidateAsync(permission); if (validateResult.ResultType != OperationResultType.Success) { return(validateResult); } try { //更新实体 repository.Update(permission, AutoSaved); // 返回正确 return(new OperationResult(OperationResultType.Success)); } catch (DataAccessException ex) { return(await Task.FromResult <OperationResult>( new OperationResult(OperationResultType.Error, ex.Message))); } }
public void permAcc(DTOPermission a) { this.permGuardID = a; id = a.IdUser; if (a.Administrator) { tsmRH.Visible = true; tsmConfigs.Visible = true; tsmCompras.Visible = true; tsmLogistica.Visible = true; tsmFin.Visible = true; tsmVendas.Visible = true; tsmCont.Visible = true; } if (a.Rh) { tsmRH.Visible = true; } if (a.Fin) { tsmFin.Visible = true; } if (a.Cont) { tsmCont.Visible = true; } if (a.Comp) { tsmCompras.Visible = true; tsmLogistica.Visible = true; } if (a.Vend) { tsmVendas.Visible = true; } }
public void Save(string email, string nome, string pass, string user, string cpf, DateTime nascimento, string cep, string telefone, decimal numerodacasa, decimal salariobruto, bool adm, bool vendas, bool compras, bool contabilidade, bool fin, bool rh, string setor, decimal va, decimal vr, decimal sf, bool saude, bool transporte, bool rhcargos, bool ageral, bool mkt, bool cont, bool gerentelocal) { if (email == string.Empty || nome == string.Empty || pass == string.Empty || user == string.Empty || cpf == string.Empty || cpf == string.Empty || cep == string.Empty || numerodacasa == 0 || salariobruto < 0) { MessageBox.Show("FALHA,PREENCHA OS CAMPOS!", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Clear = false; } else if (rhcargos == false && ageral == true && mkt == true && cont == true && gerentelocal == true) { MessageBox.Show("FALHA,PREENCHA OS CAMPOS!", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Clear = false; } else { CrudDataBase SaveDB = new CrudDataBase(); // Salvar o usuário DTOUser usuarioDTO = new DTOUser(); usuarioDTO.Nome = nome; usuarioDTO.User = user; usuarioDTO.Password = pass; usuarioDTO.Email = email; usuarioDTO.Cpf = cpf; usuarioDTO.Birth = nascimento; usuarioDTO.PostalCode = cep; usuarioDTO.HouseNumber = numerodacasa; usuarioDTO.Telefone = telefone; int idUsuario = SaveDB.SaveUser(usuarioDTO); // Salvar permissão DTOPermission permissaoDTO = new DTOPermission(); permissaoDTO.Administrator = adm; permissaoDTO.Rh = rh; permissaoDTO.Fin = fin; permissaoDTO.Cont = contabilidade; permissaoDTO.Vend = vendas; permissaoDTO.Comp = compras; permissaoDTO.IdUser = idUsuario; SaveDB.SavePermission(permissaoDTO); //Salvar cargos DTOCargos cargosDTO = new DTOCargos(); cargosDTO.AGeral = ageral; cargosDTO.Contabilidade = cont; cargosDTO.Marketing = mkt; cargosDTO.GerenteLocal = gerentelocal; cargosDTO.Rh = rhcargos; cargosDTO.IdUser = idUsuario; SaveDB.SaveCargo(cargosDTO); //Salvar o setor DTOSector setorDTO = new DTOSector(); setorDTO.Setor = setor; setorDTO.IdUsuario = idUsuario; SaveDB.SaveSetor(setorDTO); //Salvar beneficios DTOBenefit beneficiosDTO = new DTOBenefit(); beneficiosDTO.CommuterBenefits = transporte; beneficiosDTO.FamilySalary = sf; beneficiosDTO.HealthInsurance = saude; beneficiosDTO.MealTicket = vr; beneficiosDTO.MealVoucher = va; beneficiosDTO.IdUsuario = idUsuario; SaveDB.SaveBenef(beneficiosDTO); //Salvar salário bruto DTOSalarioBruto salariobrutoDTO = new DTOSalarioBruto(); salariobrutoDTO.IdUser = idUsuario; salariobrutoDTO.SalarioBruto = salariobruto; SaveDB.SaveSalarioBruto(salariobrutoDTO); MessageBox.Show("NOVA ADMISSÃO REALIZADA!", "TOPMOVIE", MessageBoxButtons.OK, MessageBoxIcon.Information); Clear = true; } }