public frmUpdateSetor(Form frm, Enumeradores.TipoOperacao tpo, BindingSource bnd) { InitializeComponent(); try { frmGrid = frm; tpOperacao = tpo; bndSetorGrid = bnd; MdiParent = frmGrid.MdiParent; if (tpOperacao.Equals(Enumeradores.TipoOperacao.Insert)) { SetorDTOBindingSource.AddNew(); } else { setorDTO = (SetorDTO)bndSetorGrid.Current; SetorDTOBindingSource.DataSource = setorGL.GetSetor(setorDTO.Id); } setorDTO = (SetorDTO)SetorDTOBindingSource.Current; } catch { throw; } }
public IList <SetorDTO> CarregaSetor() { using (SqlConnection con = new SqlConnection()) { //Conexão com o banco con.ConnectionString = Properties.Settings.Default.Sql; SqlCommand cm = new SqlCommand(); cm.CommandType = CommandType.Text; cm.CommandText = "Select * from tb_Setor"; cm.Connection = con; SqlDataReader Leitor; IList <SetorDTO> ListarSetor = new List <SetorDTO>(); con.Open(); Leitor = cm.ExecuteReader(); if (Leitor.HasRows) { while (Leitor.Read()) { SetorDTO setor = new SetorDTO(); setor.Codigo = Convert.ToInt16(Leitor["cod_Setor"]); setor.Nome = Convert.ToString(Leitor["nome_Setor"]); setor.Descricao = Convert.ToString(Leitor["descr_Setor"]); ListarSetor.Add(setor); } } return(ListarSetor); } }
public IList <SetorDTO> buscarSetor(SetorDTO setor) { using (SqlConnection con = new SqlConnection()) { //Conexão com o banco con.ConnectionString = Properties.Settings.Default.Sql; SqlCommand cm = new SqlCommand(); cm.CommandType = CommandType.Text; cm.CommandText = "Select * from tb_Setor where nome_Setor like @nome_Setor + '%'"; cm.Connection = con; cm.Parameters.Add("nome_Setor", SqlDbType.VarChar).Value = setor.Nome; SqlDataReader Leitor; IList <SetorDTO> ListarSetor = new List <SetorDTO>(); con.Open(); Leitor = cm.ExecuteReader(); if (Leitor.HasRows) { while (Leitor.Read()) { setor.Codigo = Convert.ToInt16(Leitor["cod_Setor"]); setor.Nome = Convert.ToString(Leitor["nome_Setor"]); setor.Descricao = Convert.ToString(Leitor["descr_Setor"]); ListarSetor.Add(setor); } } return(ListarSetor); } }
private void codigosetorButtonEdit_Validated(object sender, EventArgs e) { if (!codigosetorButtonEdit.IsModified) { return; } SetorDTO setor = new SetorDTO(); if (codigosetorButtonEdit.Text.Trim() != "0" && this.Enabled == true) { try { setor = LocalizarSetor(); } catch { setor.Codigo = Convert.ToInt32(codigosetorButtonEdit.Text); Cursor = Cursors.WaitCursor; frmGridSetor frmgridsetor = new frmGridSetor(this, new MechTech.Util.Global.SystemDelegate(SetSetor)); frmgridsetor.ShowDialog(); Cursor = Cursors.Default; } } else { lblSetor.Text = "[]"; } funcsalarioDTO.Setor = setor; }
public async Task <IActionResult> Post([FromBody] SetorDTO obj) { if (obj is null) { return(BadRequest()); } return(Ok(_mapper.Map <SetorDTO>(await this.GatewayServiceProvider.Get <ISetorService>().Add(obj)))); }
public async Task <ActionResult <SetorDTO> > Patch(SetorDTO obj) { if (obj is null) { return(NotFound()); } //return Ok(_mapper.Map<SetorDTO>(await this.GatewayServiceProvider.Get<ISetorService>().Update(obj))); return(new SetorDTO()); }
public async Task <SetorDTO> Add(SetorDTO obj) { try { Setor setor = _mapper.Map <Setor>(obj); await _repository.Create(setor); } catch (Exception ex) { throw new Exception(ex + "Aconteceu um erro"); } return(obj); }
public IHttpActionResult DeleteSetor(string id) { Setor setor = db.Setor.Find(id); if (setor == null) { return(NotFound()); } SetorDTO s = new SetorDTO(setor); db.Setor.Remove(setor); db.SaveChanges(); return(Ok(s)); }
public IList <SetorDTO> selectSetor(SetorDTO setor) { try { IList <SetorDTO> resultado = null; using (ISession session = NHibernateHelper.getSessionFactory().OpenSession()) { NHibernateDAL <SetorDTO> DAL = new NHibernateDAL <SetorDTO>(session); resultado = DAL.select(setor); } return(resultado); } catch (Exception ex) { throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : "")); } }
private void Excluir() { if (MessageBox.Show("Deseja realmente excluir ?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { setorDTO = (SetorDTO)SetorDTOBindingSource.Current; try { setorGL.Delete(setorDTO.Id); SetorDTOBindingSource.RemoveCurrent(); } catch { throw; } } }
public int inserir(SetorDTO SetorDTO) { using (SqlConnection con = new SqlConnection()) { //Conexão com o banco con.ConnectionString = Properties.Settings.Default.Sql; SqlCommand cm = new SqlCommand(); cm.CommandType = CommandType.Text; con.Open(); cm.CommandText = "insert into tb_Setor (nome_Setor, descr_Setor)" + "values (@nome_Setor, @descr_Setor )"; cm.Parameters.Add("nome_Setor", SqlDbType.VarChar).Value = SetorDTO.Nome; cm.Parameters.Add("descr_Setor", SqlDbType.VarChar).Value = SetorDTO.Descricao; cm.Connection = con; int valor = cm.ExecuteNonQuery(); return(valor); } }
internal int deletarSetor(SetorDTO setor) { using (SqlConnection con = new SqlConnection()) { //Conexão com o banco con.ConnectionString = Properties.Settings.Default.Sql; SqlCommand cm = new SqlCommand("Deletar_Setores"); cm.CommandType = CommandType.Text; cm.CommandText = "delete from tb_Setor where cod_Setor =" + setor.Codigo; cm.Connection = con; con.Open(); int valor = cm.ExecuteNonQuery(); return(valor); } }
public bool Salvar(SetorDTO dto) { if (dto == null) { throw new ArgumentNullException("dto"); } bool novoItem = false; var Setor = SetorRepository.ObterPeloId(dto.Id); if (Setor == null) { Setor = new Setor(); novoItem = true; } Setor.Descricao = dto.Descricao; if (Validator.IsValid(Setor, out validationErrors)) { if (novoItem) { SetorRepository.Inserir(Setor); } else { SetorRepository.Alterar(Setor); } SetorRepository.UnitOfWork.Commit(); messageQueue.Add(Resource.Sigim.SuccessMessages.SalvoComSucesso, TypeMessage.Success); return(true); } else { messageQueue.AddRange(validationErrors, TypeMessage.Error); } return(false); }
private void deletar() { try { //VARIAVEL QUE ARMAZENA O CODIGO DA TABELA String deletar = dgvVer.CurrentRow.Cells[0].Value.ToString(); //INSTANCIAS SetorDTO setorDto = new SetorDTO(); SetorBLL SetorBLL = new Code.BLL.SetorBLL(); //ENVIA O CODIGO SELECIONADO PARA A DTO setorDto.Codigo = Convert.ToInt16(deletar); //EXECUTA A AÇÃO DA BLL/MODEL SetorBLL.DeletarSetor(setorDto); } catch (Exception erro) { MetroFramework.MetroMessageBox.Show(Owner, "Erro ao tentar deletar os dados!" + erro); } }
internal int alterar(SetorDTO setor) { using (SqlConnection con = new SqlConnection()) { //Conexão com o banco con.ConnectionString = Properties.Settings.Default.Sql; SqlCommand cm = new SqlCommand("Alterar_setor"); cm.Parameters.AddWithValue("cod_Setor", setor.Codigo); cm.Parameters.AddWithValue("nome_Setor", setor.Nome); cm.Parameters.AddWithValue("descr_Setor", setor.Descricao); cm.Connection = con; cm.CommandType = CommandType.Text; con.Open(); cm.CommandText = "update tb_Setor set nome_Setor=@nome_Setor, descr_Setor=@descr_Setor where cod_Setor = @cod_Setor"; int valor = cm.ExecuteNonQuery(); return(valor); } }
private void tlSalvar_Click(object sender, RoutedEventArgs e) { try { SetorDTO setordto = new SetorDTO(); SetorBLL setorbll = new SetorBLL(); setordto.Codigo = Convert.ToInt16(txtID.Text); setordto.Nome = txtNomeSetor.Text; setordto.Descricao = txtDescricao.Text; int x = setorbll.alterar(setordto); if (x > 0) { this.ShowMessageAsync("Sucesso!", "Dados salvos com sucesso!"); } } catch (Exception erro) { this.ShowMessageAsync("Erro!", "Erro ao tentar inserir os dados!" + erro); } }
public async Task <SetorDTO> Update(SetorDTO obj) { if (_repository.Search(c => c.Nome == obj.Nome && c.Id != obj.Id).Result.Any()) { throw new ArgumentException("já existe um setor com este nome!"); } else { try { Setor setor = _mapper.Map <SetorDTO, Setor>(obj); await _repository.Update(setor); } catch (Exception ex) { throw new Exception(ex + "Aconteceu um erro!"); } } return(obj); }
private void txtNome_KeyUp(object sender, KeyEventArgs e) { try { IList <SetorDTO> listar = new List <SetorDTO>(); { SetorDTO setor = new SetorDTO(); setor.Nome = Convert.ToString(txtNome.Text); listar = new SetorBLL().buscar(setor); dgvVer.AutoGenerateColumns = false; dgvVer.DataSource = listar; } if (txtNome.Text == "") { carregarGrid(); } } catch (Exception erro) { MetroFramework.MetroMessageBox.Show(Owner, "Erro ao tentar buscar dados!" + erro); } }
public void AlterarSetor(SetorDTO dto) { dao.Update("tbl_setor", dto, 0); }
public void ExcluirSetor(SetorDTO dto) { dao.Delete("tbl_setor", dto, 0); }
public new List <SetorDTO> selectSetor(SetorDTO Setor) { return(base.selectSetor(Setor)); }
public void InserirSetor(SetorDTO dto) { dao.Insert("tbl_setor", dto); }
public int alterar(SetorDTO setordto) { return(new SetorDAL().alterar(setordto)); }
public int DeletarSetor(SetorDTO setor) { return(stDAL.deletarSetor(setor)); }
public int inserir(SetorDTO setordto) { return(stDAL.inserir(setordto)); }
public IList <SetorDTO> buscar(SetorDTO setordto) { return(stDAL.buscarSetor(setordto)); }
public new List<SetorDTO> selectSetor(SetorDTO Setor) { return base.selectSetor(Setor); }
public virtual async Task <SetorDTO> Get(long id) { SetorDTO setor = _mapper.Map <SetorDTO>(await _repository.Get(id)); return(setor); }
public IList <SetorDTO> selectSetorPagina(int primeiroResultado, int quantidadeResultados, SetorDTO setor) { try { IList <SetorDTO> resultado = null; using (ISession session = NHibernateHelper.getSessionFactory().OpenSession()) { NHibernateDAL <SetorDTO> DAL = new NHibernateDAL <SetorDTO>(session); resultado = DAL.selectPagina <SetorDTO>(primeiroResultado, quantidadeResultados, setor); } return(resultado); } catch (Exception ex) { throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : "")); } }
public FuncSalarioDTO GetFuncsalarioFuncionarioCurrent(int id_funcionario) //31236 { try { //CAPTURAR O SALÁRIO DE ACORDO COM O MÊS/ANO ATIVO. dbCommand = db.GetStoredProcCommand(Global.EmpresaAtiva + ".GetFuncsalarioFuncionario"); db.AddInParameter(dbCommand, "@id_funcionario", DbType.Int32, id_funcionario); using (IDataReader DR = db.ExecuteReader(dbCommand)) { FuncSalarioDTO List = new FuncSalarioDTO(); while (DR.Read()) { FuncSalarioDTO tab = new FuncSalarioDTO(); tab.Id = int.Parse(DR["id"].ToString()); if (Convert.IsDBNull(DR["data"])) { tab.Data = null; } else { tab.Data = (DateTime)DR["data"]; } if (Convert.IsDBNull(DR["datareajuste"])) { tab.DataReajuste = null; } else { tab.DataReajuste = (DateTime)DR["datareajuste"]; } tab.Id_funcionario = int.Parse(DR["id_funcionario"].ToString()); //LOCALIZAR DEPARTAMENTO DepartamentoDTO departamento = new DepartamentoDTO(); if (!Convert.IsDBNull(DR["id_departamento"])) { DepartamentoDAO departamentodata = new DepartamentoDAO(); departamento.Id = Convert.ToInt32(DR["id_departamento"]); departamento = departamentodata.GetDepartamento(departamento.Id); } tab.Departamento = departamento; // //LOCALIZAR SETOR SetorDTO setor = new SetorDTO(); if (!Convert.IsDBNull(DR["id_setor"])) { SetorDAO setordata = new SetorDAO(); setor.Id = Convert.ToInt32(DR["id_setor"]); setor = setordata.GetSetor(setor.Id); } tab.Setor = setor; // //LOCALIZAR SECAO SecaoDTO secao = new SecaoDTO(); if (!Convert.IsDBNull(DR["id_secao"])) { SecaoDAO secaodata = new SecaoDAO(); secao.Id = Convert.ToInt32(DR["id_secao"]); secao = secaodata.GetSecao(secao.Id); } tab.Secao = secao; // //LOCALIZAR FUNCAO FuncaoDTO funcao = new FuncaoDTO(); if (Convert.ToInt32(DR["id_funcao"]) != 0) { FuncaoDAO funcaodata = new FuncaoDAO(); funcao.Id = Convert.ToInt32(DR["id_funcao"]); funcao = funcaodata.GetFuncao(funcao.Id); } tab.Funcao = funcao; return(tab); } } return(null); } catch { throw; } }
public new List <SetorDTO> selectSetor(SetorDTO dtoPesquisa) { return(base.selectSetor(dtoPesquisa)); }