private void Interacao(ModInteracao.Interacao interacao) { negEstInserir = new NegEstInserir(); negEstAtualizar = new NegEstAtualizar(); negEstExcluir = new NegEstExcluir(); modCompetencia = new ModCompetencia(); modProduto = new ModProduto(); modEstoque = new ModEstoque(); if (CbxTipo.SelectedIndex == 0) { tipoES = 'E'; } else { tipoES = 'S'; } try { modEstoque.Id = estId; modEstoque.DataCadastro = DateTime.Parse(MktDataCadastro.Text); modEstoque.TipoES = tipoES; modEstoque.QtdProduto = int.Parse(TxtQuantidade.Text.Trim()); modEstoque.ValorProduto = decimal.Parse(TxtValor.Text); modEstoque.Competencia = new ModCompetencia(); modEstoque.Competencia.Id = compId; modEstoque.Produto = new ModProduto(); modEstoque.Produto.Id = prodId; switch (interacao) { case ModInteracao.Interacao.Gravar: negEstInserir.Inserir(modEstoque); break; case ModInteracao.Interacao.Alterar: negEstAtualizar.Atualizar(modEstoque); break; case ModInteracao.Interacao.Excluir: negEstExcluir.Excluir(modEstoque); break; default: break; } BotoesReset(); ListaEstoqueCompetencia(compId, TxtPesquisa.Text.Trim()); Informacao(compId); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Interacao(ModInteracao.Interacao interacao) { negCompInserir = new NegCompInserir(); negCompAtualizar = new NegCompAtualizar(); negCompExcluir = new NegCompExcluir(); modCompetencia = new ModCompetencia(); if (CbAtivo.Checked) { compAtivo = 'S'; } else { compAtivo = 'N'; } try { modCompetencia.Competencia = DateTime.Parse(MktCompetencia.Text); switch (interacao) { case ModInteracao.Interacao.Gravar: FecharAbrirCompAtiva('N'); modCompetencia.Ativo = compAtivo; negCompInserir.Inserir(modCompetencia); break; case ModInteracao.Interacao.Alterar: FecharAbrirCompAtiva('N'); modCompetencia.Id = compId; modCompetencia.Ativo = compAtivo; negCompAtualizar.Atualizar(modCompetencia); break; case ModInteracao.Interacao.Excluir: modCompetencia.Id = compId; negCompExcluir.Excluir(modCompetencia); break; default: MessageBox.Show("Comando Inválido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } ListarCompetencia(); BotoesReset(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public bool Excluir(ModCompetencia competencia) { strSQL = new StringBuilder(); crud = new BDCrud(); strSQL.Append("DELETE FROM Competencia "); strSQL.Append("WHERE Id = @Id"); try { crud.LimparParametros(); crud.AdicionarParametro("Id", competencia.Id); crud.Executar(CommandType.Text, strSQL.ToString()); return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }
public bool Inserir(ModCompetencia competencia) { strSQL = new StringBuilder(); crud = new BDCrud(); strSQL.Append("INSERT INTO Competencia (Data_Competencia, Ativo) "); strSQL.Append("VALUES(@Data_Competencia, @Ativo)"); try { crud.LimparParametros(); crud.AdicionarParametro("Data_Competencia", competencia.Competencia); crud.AdicionarParametro("Ativo", competencia.Ativo); crud.Executar(CommandType.Text, strSQL.ToString()); return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }
public bool AtualizarStatus(ModCompetencia competencia) { strSQL = new StringBuilder(); crud = new BDCrud(); strSQL.Append("UPDATE Competencia "); strSQL.Append("SET Ativo = @Ativo "); strSQL.Append("WHERE Id = @Id"); try { crud.LimparParametros(); crud.AdicionarParametro("Ativo", competencia.Ativo); crud.AdicionarParametro("Id", competencia.Id); crud.Executar(CommandType.Text, strSQL.ToString()); return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }