private void btnLocalizar_Click(object sender, EventArgs e) { frmConsultaSubCategoria consultaSubCategoria = new frmConsultaSubCategoria(); consultaSubCategoria.ShowDialog(); try { if (consultaSubCategoria.Codigo != 0) { DALConexao conexao = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubCategoria categoria = new BLLSubCategoria(conexao); ModeloSubCategoria modelo = categoria.CarregarModeloSubCategoria(consultaSubCategoria.Codigo); txtCodigo.Text = modelo.Scat_cod.ToString(); txtSubCategoria.Text = modelo.Scat_nome; cboCategoria.SelectedValue = modelo.Cat_cod; alterarBotoes(3); } else { this.limparTela(); this.alterarBotoes(1); } consultaSubCategoria.Dispose(); } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, "Impossivel encontrar o registro. \n O resistro esta sendo utilizado em outro local " + ex.Message, "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Alterar(ModeloSubCategoria modelo) { if (modelo.SCatNome.Trim().Length == 0) { aviso("O nome da SubCategoria é obrigatório"); return; } else if (modelo.CatCod <= 0) { aviso("O nome da Categoria é obrigatório"); return; } else if (modelo.SCat_Cod <= 0) { aviso("O código da SubCategoria é obrigatório"); return; } else { try { DALSubCategoria DALobj = new DALSubCategoria(conexao); DALobj.Alterar(modelo); BllAviso.aviso("Operação realizada com sucesso!!!"); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Ops. Parece que algo deu errado"); return; } } }
private void btnSalvar_Click(object sender, EventArgs e) { try { ModeloSubCategoria modelo = new ModeloSubCategoria(); modelo.Scat_nome = txtSubCategoria.Text; modelo.Cat_cod = Convert.ToInt32(cboCategoria.SelectedValue); DALConexao dao = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubCategoria categoria = new BLLSubCategoria(dao); if (this.operacao == "inserir") { //cadastrar categoria.Incluir(modelo); MetroFramework.MetroMessageBox.Show(this, "Cadastrado com sucesso! ", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); this.limparTela(); this.alterarBotoes(1); } else { //alterar modelo.Scat_cod = Convert.ToInt32(txtCodigo.Text); categoria.Alterar(modelo); MetroFramework.MetroMessageBox.Show(this, "Editado com sucesso! ", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); this.limparTela(); this.alterarBotoes(1); } } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, "Ops Ocorreu algum erro! " + ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { ModeloSubCategoria modeloSubCategoria = new ModeloSubCategoria(); modeloSubCategoria.SCatNome = txtNomeSubCategoria.Text; modeloSubCategoria.CatCod = Convert.ToInt32(cbCategoria.SelectedValue); if (this.operacao == Inserir) { QueryDB.IncluirSubCategoria(modeloSubCategoria); MessageBox.Show("Cadastro efetuado com sucesso!! \nCódigo: " + modeloSubCategoria.SCatCod.ToString()); } else { modeloSubCategoria.SCatCod = Convert.ToInt32(txtCodigoSubCategoria.Text); QueryDB.AlterarSubCategoria(modeloSubCategoria); MessageBox.Show("Cadastro alterado com sucesso!!"); } this.LimparDadosDaTela(); this.AlteraBotoes(Convert.ToInt32(OperacaoFormulario.Inserir_Localizar)); } catch (Exception Error) { MessageBox.Show(Error.Message); } }
public void Alterar(ModeloSubCategoria modelo) { try { SqlCommand cmd = new SqlCommand(); //inicializando uma nova instância da classe sql cmd.Connection = conexao.ObjetoConexao; //erro 2: erro ao alterar uma subcategoria. Erro ocorreu porque o comabdo SQL estava com o AND no lugar da ,. //cmd.CommandText = "UPDATE SUBCATEGORIA SET SCAT_NOME = @NOME AND CAT_COD = @CATCOD WHERE SCAT_COD = @SCATCOD;"; cmd.CommandText = "UPDATE SUBCATEGORIA SET SCAT_NOME = @NOME, CAT_COD = @CATCOD WHERE SCAT_COD = @SCATCOD;"; cmd.Parameters.AddWithValue("@NOME", modelo.SCatNome); cmd.Parameters.AddWithValue("@CATCOD", modelo.CatCod); cmd.Parameters.AddWithValue("@SCATCOD", modelo.ScatCod); conexao.Conectar(); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conexao.Desconectar(); } }
//------------------------------------------------------------------------------------------------------------------- private void txtSubCategoria_Leave(object sender, EventArgs e) { if (operacao == "inserir") { int r = 0; BLLSubCategoria bll = new BLLSubCategoria(); r = bll.VerificaSubCategoria(txtSubCategoria.Text); if (r > 0) { DialogResult d = MessageBox.Show("Já existe um registro com esse valor. Deseja alterar o registro?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d.ToString() == "Yes") { DialogResult di = MessageBox.Show("Deseja realmente sobreescrever esse registro? Ao aceitar a operação, o registro antes cadastrado será permanentemente deletado!", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (di.ToString() == "Yes") { this.operacao = "alterar"; ModeloSubCategoria modelo = bll.carregaModelo(r); txtSubCodigo.Text = modelo.scat_cod.ToString(); txtSubCategoria.Text = modelo.scat_nome; //this.alteraBotoes(3); } else { txtSubCategoria.Clear(); txtSubCategoria.Focus(); } } else { txtSubCategoria.Clear(); txtSubCategoria.Focus(); } } } }
private void btnSalvarSubCategoria_Click(object sender, EventArgs e) { if (MessageBox.Show("Deseja efetuar alteração?", "Alterar item", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ModeloSubCategoria modelo = new ModeloSubCategoria(); DALConexao cx = new DALConexao(DadosdaConexao.StringDeConexao); modelo.ScatCod = Convert.ToInt32(codigo); modelo.CatCod = Convert.ToInt32(catCodigo); modelo.ScatNome = inputInserirSubCategoria.Text; BLLSubCategoria bll = new BLLSubCategoria(cx); bll.Alterar(modelo); inputInserirSubCategoria.Text = String.Empty; MessageBox.Show("Item alterado"); btnInserirSubCategoria.Visible = true; btnSalvarSubCategoria.Visible = false; btnExcluirSubCategoria.Visible = false; gridViewSubCategoria.DataSource = bll.Localizar(inputInserirSubCategoria.Text); } else { MessageBox.Show("Item não alterado!", "Alterar item", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public ModeloSubCategoria CarregaSubCategoria(int codigo) { ModeloSubCategoria subModelo_Cat = new ModeloSubCategoria(); using (SqlCommand command = new SqlCommand()) { command.Connection = conexao.ObjetoConexao; command.CommandText = @"SELECT SUBCATEGORIA.CAT_COD, SUBCATEGORIA.SCAT_COD, SUBCATEGORIA.SCAT_NOME FROM SUBCATEGORIA WHERE SCAT_COD = @CODIGO"; command.Parameters.AddWithValue("@CODIGO", codigo); conexao.Conectar(); SqlDataReader registro = command.ExecuteReader(); if (registro.HasRows) { registro.Read(); subModelo_Cat.CatCod = Convert.ToInt32(registro["CAT_COD"]); subModelo_Cat.SCatCod = Convert.ToInt32(registro["SCAT_COD"]); subModelo_Cat.SCatNome = Convert.ToString(registro["SCAT_NOME"]); } conexao.Desconectar(); return(subModelo_Cat); } }
private void btSalvar_Click(object sender, EventArgs e) { try { ModeloSubCategoria modelosubCategoria = new ModeloSubCategoria(); modelosubCategoria.ScatNome = txt_Nome.Text; //ler os valores da tela modelosubCategoria.CatCod = Convert.ToInt32(cb_CatCod.SelectedValue); //ler os valores da tela -- SelectedValue = VALOR SELECIONADO //GRAVA OS DADOS NO BANCO DALConexao dalConexao = new DALConexao(DadosDaConexao.StringDeConexao); //CRIA CONEXAO BLLSubCategoria bllsubCategoria = new BLLSubCategoria(dalConexao); //CRIA DLL DA SUBCATEGORIA if (Operacao == "inserir") { bllsubCategoria.Incluir(modelosubCategoria); //CHAMA INCLUIR MessageBox.Show("Cadastro efetuado com sucesso : Código " + modelosubCategoria.ScatCod.ToString()); //MOSTRA NA TELA A MENSAGEM } else { //ALTERAR UMA CATEGORIA modelosubCategoria.ScatCod = Convert.ToInt32(txt_ScatCod.Text); //ler o codigo da subcategoria e pegar o valor da tela bllsubCategoria.Alterar(modelosubCategoria); //chama o ALTERAR MessageBox.Show("Cadastro alterado com sucesso !"); } LimpaTela(); AlterarBotoes(1); } catch (Exception ex) { throw new Exception(ex.Message); //qualquer erro que der sera exibido uma mensagem na tela } }
private void btnSalvar_Click(object sender, EventArgs e) { try { //leitura dos dados da tela ModeloSubCategoria modeloSubCategoria = new ModeloSubCategoria(); modeloSubCategoria.ScatNome = txtNome.Text; modeloSubCategoria.CatCod = Convert.ToInt32(cmbCatCod.SelectedValue); //obj para gravar os dados no banco DALConexao cnx = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubCategoria bllSubCategoria = new BLLSubCategoria(cnx); if (this.operacao == "Inserir") { bllSubCategoria.Incluir(modeloSubCategoria); MessageBox.Show("Cadastro efetuado, Codigo: " + modeloSubCategoria.ScatCod.ToString()); } else { modeloSubCategoria.ScatCod = Convert.ToInt32(txtScatCod.Text); bllSubCategoria.Alterar(modeloSubCategoria); MessageBox.Show("Cadastro alterado"); } this.LimpaTela(); this.alteraBotoes(1); } catch (Exception erro) { MessageBox.Show(erro.Message); } }
private void btSalvar_Click(object sender, EventArgs e) { try { //leitura de dados ModeloSubCategoria modelo = new ModeloSubCategoria(); modelo.ScatNome = txtNomeSubcategoria.Text; modelo.CatCod = Convert.ToInt32(cbNomeCategoria.SelectedValue); // obj para gravar os dados no banco DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubcategoria bll = new BLLSubcategoria(cx); if (this.operacao == "inserir") { //cadastrar uma subcategoria bll.Incluir(modelo); MessageBox.Show("Cadastro efetuado com sucesso! \n O código da subcategoria é: " + modelo.ScatCod.ToString()); } else { //alterar uma subcategoria modelo.ScatCod = Convert.ToInt32(txtSCod.Text); bll.Alterar(modelo); MessageBox.Show("Cadastro atualizado com sucesso!"); } this.limpaTela(); this.alteraBotoes(1); } catch (Exception erro) { MessageBox.Show(erro.Message); } }
private void btnLocalizar_Click(object sender, EventArgs e) { frmConsultaSubCategoria tela = new frmConsultaSubCategoria(); tela.ShowDialog(); if (tela.codigo != 0) { DALConexao con = new DALConexao(DadosConexao.StringConexao); BLLSubCategoria sc = new BLLSubCategoria(con); ModeloSubCategoria m = sc.carregaSubCategoria(tela.codigo); txtCodigoSubCategoria.Text = m.CodSubCat.ToString(); txtNomeSubCategoria.Text = m.SubCategoriaNome; cbCategoria.SelectedValue = m.FKCatCod; this.AlteraBotoes(3); } else { this.LimparCampos(); this.AlteraBotoes(1); } tela.Dispose(); }
public ModeloSubCategoria CarregaModeloSubCategoria(int codigo) { try { ModeloSubCategoria modelo = new ModeloSubCategoria(); SqlCommand cmd = new SqlCommand("[dbo].[spSubCategoriaConsultarCodigo]", conexao._conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@scat_cod", codigo); conexao.Conectar(); SqlDataReader registro = cmd.ExecuteReader(); if (registro.HasRows) { registro.Read(); modelo.scat_cod = Convert.ToInt32(registro["CODIGO_SUBCATEGORIA"]); modelo.snome = Convert.ToString(registro["NOME_SUBCATEGORIA"]); modelo.cat_cod = Convert.ToInt32(registro["CODIGO_CATEGORIA"]); } return(modelo); } catch (Exception erro) { throw new Exception(erro.Message); } finally { conexao.Desconectar(); } }
//------------------------------------------------------------------------------------------------------------------- public void Alterar(ModeloSubCategoria obj) { try { SqlCommand cmd = new SqlCommand(); cmd.Connection = cn.Conexao; cmd.CommandText = "UPDATE subcategoria SET scat_nome = @nome, cat_cod = @catcod WHERE scat_cod = @cod"; cmd.Parameters.AddWithValue("@nome", obj.scat_nome); cmd.Parameters.AddWithValue("@cod", obj.scat_cod); cmd.Parameters.AddWithValue("@catcod", obj.cat_cod); cn.Conectar(); cmd.ExecuteNonQuery(); } catch (SqlException ex) { throw new Exception("Servidor SQL Erro: " + ex.Message); } catch (Exception ex) { throw new Exception(ex.Message); } finally { //cn.Desconectar(); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { //Leitura dos dados; ModeloSubCategoria modelo = new ModeloSubCategoria(); modelo.snome = txtNome.Text; modelo.cat_cod = Convert.ToInt32(cbxCategoria.SelectedValue); //Objeto para gravar os dados no banco DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexão); BLLSubCategoria bll = new BLLSubCategoria(cx); if (txtCodigo.Text == "") { //Cadastrar uma categoria bll.Incluir(modelo); Mensagem("SUB CATEGORIA INSERIDA, CÓDIGO: " + modelo.cat_cod.ToString(), Color.Blue); } else { //Alterar uma categoria modelo.scat_cod = Convert.ToInt32(txtCodigo.Text); bll.Alterar(modelo); Mensagem("SUB CATEGORIA ALTERADA ", Color.Blue); } LimpaTela(); alteraBotoes(); } catch (Exception erro) { Erro(erro.Message); } }
//------------------------------------------------------------------------------------------------------------------- public void Incluir(ModeloSubCategoria obj) { try { //command SqlCommand cmd = new SqlCommand(); cmd.Connection = cn.Conexao; cmd.CommandText = "insert into subcategoria(scat_nome, cat_cod) values (@scatnome, @catcod); select @@IDENTITY;"; cmd.Parameters.AddWithValue("@scatnome", obj.scat_nome); cmd.Parameters.AddWithValue("@catcod", obj.cat_cod); cn.Conectar(); obj.cat_cod = Convert.ToInt32(cmd.ExecuteScalar()); } catch (SqlException ex) { throw new Exception("SQL ERROR: " + ex.Message); } catch (Exception ex) { throw new Exception("ERROR: " + ex.Message); } finally { //cn.Desconectar(); } }
public ModeloSubCategoria CarregaModeloSubCategoria(int _Codigo) { try { ModeloSubCategoria modelosubCategoria = new ModeloSubCategoria(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conexao.ObjetoConexao; cmd.CommandText = " select * from subcategoria where Scat_cod = @codigo"; cmd.Parameters.AddWithValue("@codigo", _Codigo); conexao.Conectar(); SqlDataReader Registro = cmd.ExecuteReader(); if (Registro.HasRows) //verificando se existe alguma linha dentro de objeto registr { Registro.Read(); // tiver alguma coisa, LEIA A LINHA modelosubCategoria.CatCod = Convert.ToInt32(Registro["cat_cod"]); modelosubCategoria.ScatNome = Convert.ToString(Registro["scat_nome"]); modelosubCategoria.ScatCod = Convert.ToInt32(Registro["scat_cod"]); } conexao.Desconectar(); return(modelosubCategoria); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conexao.Desconectar(); } }
private void btLocalizar_Click(object sender, EventArgs e) { frmConsultaSubCategoria f = new frmConsultaSubCategoria(); // obj para gravar os dados no banco DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubcategoria bll = new BLLSubcategoria(cx); //exibe o frmConsultaCategoria para seleção da alteração f.ShowDialog(); //verifica se foi armazenado uma categoria no frmConsultaCategoria if (f.codigo != 0) { ModeloSubCategoria modelo = bll.CarregarModeloSubCategoria(f.codigo); txtSCod.Text = modelo.ScatCod.ToString(); txtNomeSubcategoria.Text = modelo.ScatNome; cbNomeCategoria.SelectedValue = modelo.CatCod; alteraBotoes(3); } else { this.limpaTela(); this.alteraBotoes(1); } f.Dispose(); }
public void Incluir(ModeloSubCategoria modelo) { ValidaCampos(modelo); DALSubCategoria DALobj = new DALSubCategoria(conexao); DALobj.Incluir(modelo); }
//METEDO LISTAR TODOS public ModeloSubCategoria CarregarModeloSubCategoria(int codigo) { try { ModeloSubCategoria modelo = new ModeloSubCategoria(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conexao.ObjetoConexao; cmd.CommandText = "select * from subcategoria where scat_cod = @scat_cod"; cmd.Parameters.AddWithValue("@scat_cod", codigo); conexao.Conectar(); SqlDataReader registro = cmd.ExecuteReader(); if (registro.HasRows) { registro.Read(); modelo.Scat_cod = Convert.ToInt32(registro["scat_cod"]); modelo.Scat_nome = Convert.ToString(registro["scat_nome"]); modelo.Cat_cod = Convert.ToInt32(registro["cat_cod"]); } return(modelo); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conexao.Desconectar(); } }
public void Alterar(ModeloSubCategoria modelo) { try { SqlCommand cmd = new SqlCommand(); cmd.Connection = conexao.ObjetoConexao; cmd.CommandText = "update subcategoria set scat_nome = @nome, cat_cod = @catcod, scat_data = @data, scat_time = @time, scat_status = @status where scat_cod = @scatcod"; cmd.Parameters.AddWithValue("@nome", modelo.ScatNome); cmd.Parameters.AddWithValue("@catcod", modelo.CatCod); cmd.Parameters.AddWithValue("@scatcod", modelo.ScatCod); cmd.Parameters.AddWithValue("@data", modelo.ScatData); cmd.Parameters.AddWithValue("@time", modelo.ScatTime); cmd.Parameters.AddWithValue("@status", modelo.ScatStatus); conexao.Conectar(); cmd.ExecuteNonQuery(); } catch (Exception erro) { throw new Exception(erro.Message); } finally { conexao.Desconectar(); } }
private void btLocalizar_Click(object sender, EventArgs e) { //Alterna imagens dos botões btLocalizar.ImageIndex = 3; frmConsultaSubCategoria frmSubCCateg = new frmConsultaSubCategoria(); frmSubCCateg.ShowDialog(); if (frmSubCCateg.codigo != 0) { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); DLLSubCategoria dll = new DLLSubCategoria(cx); ModeloSubCategoria modelo = dll.CarregaModeloSubCategoria(frmSubCCateg.codigo); txtSCatCod.Text = modelo.ScatCod.ToString(); txtNome.Text = modelo.ScatNome; txtSCatData.Text = modelo.ScatData; cbCatCod.SelectedValue = Convert.ToString(modelo.CatCod); label1.Visible = true; this.alteraBotoes(3); closeCadSubCategoria = 3; } else { this.LimpaTela(); this.alteraBotoes(1); btLocalizar.ImageIndex = 2; } frmSubCCateg.Dispose(); }
private void btsalvar_Click(object sender, EventArgs e) { try { ModeloSubCategoria modelo = new ModeloSubCategoria(); modelo.ScatNome = txtNome.Text; modelo.CatCod = Convert.ToInt32(cbCatCod.SelectedValue); //obj para gravar os dados no banco DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BBLSubCategoria bll = new BBLSubCategoria(cx); if (this.operacao == "inserir") { //cadastrar uma categoria bll.incluir(modelo); MessageBox.Show("Nova SubCategoria Cadastrada com sucesso: Código" + modelo.ScatCod.ToString()); } else { //alterar uma categoria modelo.ScatCod = Convert.ToInt32(txtScatCod.Text); bll.alterar(modelo); MessageBox.Show("SubCategoria Alterada com Sucesso"); } this.LimpaTela(); this.alteraBotoes(1); } catch (Exception erro) { MessageBox.Show(erro.Message); } }
public ModeloSubCategoria carregaSubCategoria(int codigo) { ModeloSubCategoria m = new ModeloSubCategoria(); SqlCommand cmd = new SqlCommand(); cmd.Connection = CONEXAO.objConexao; cmd.CommandText = "select * from subcategoria where scat_cod = " + codigo.ToString() + "; "; CONEXAO.Conectar(); SqlDataReader registro = cmd.ExecuteReader(); if (registro.HasRows) { registro.Read(); m.CodSubCat = Convert.ToInt32(registro["scat_cod"]); m.SubCategoriaNome = Convert.ToString(registro["scat_nome"]); m.FKCatCod = Convert.ToInt32(registro["cat_cod"]); } CONEXAO.Desconectar(); return(m); }
private void btnLocalizar_Click(object sender, EventArgs e) { frmConsultaSubCategoria f = new frmConsultaSubCategoria(); f.ShowDialog(); if (f.codigo != 0) { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubCategoria bll = new BLLSubCategoria(cx); ModeloSubCategoria modelo = bll.CarregaModeloSubCategoria(f.codigo); txtCodigoSubCat.Text = modelo.ScatCod.ToString(); txtNomeSubCat.Text = modelo.SCatNome; cbNomeCat.SelectedValue = modelo.CatCod; AlteraBotoes(3); } else { this.LimpaTela(); this.AlteraBotoes(1); } f.Dispose(); }
private void btSalvar_Click(object sender, EventArgs e) { try { ModeloSubCategoria modelo = new ModeloSubCategoria(); modelo.SCatNome = txtScatNome.Text; modelo.CatCod = Convert.ToInt32(cbCat.SelectedValue); DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubCategoria bll = new BLLSubCategoria(cx); if (this.operacao == "inserir") { bll.Incluir(modelo); MessageBox.Show("Cadastro efetuado: Código " + modelo.SCatCod.ToString()); } else { modelo.SCatCod = Convert.ToInt32(txtScatCod.Text); bll.Alterar(modelo); MessageBox.Show("Cadastro alterado! "); } this.LimpaTela(); this.alteraBotoes(1); } catch (Exception erro) { MessageBox.Show(erro.Message); } }
//========================================================================================================================================== private void btSalvar_Click(object sender, EventArgs e) //aula 16 { try { //leitura dos dados ModeloSubCategoria modelo = new ModeloSubCategoria(); modelo.ScatNome = txtNome.Text; //nome da subcatagoria modelo.CatCod = Convert.ToInt32(cbCatCod.SelectedValue); //pegao o valor oculto do combobox correspondente a catagoria selecionada e converte para inteiro //obj para gravar os dados no banco DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubCategoria bll = new BLLSubCategoria(cx); if (this.operacao == "inserir") { //cadastrar uma categoria bll.Incluir(modelo); MessageBox.Show("Cadastro efetuado: Código " + modelo.ScatCod.ToString()); } else { //alterar uma categoria modelo.ScatCod = Convert.ToInt32(txtScatCod.Text); bll.Alterar(modelo); MessageBox.Show("Cadastro alterado"); } this.LimpaTela(); this.alteraBotoes(1); } catch (Exception erro) { MessageBox.Show(erro.Message); } }
private void ValidaCampos(ModeloSubCategoria modelo) { if (modelo.snome.Trim().Length == 0) { throw new Exception("nome"); } modelo.snome = modelo.snome.ToUpper(); }
public void LocalizarSubCategoria() { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexão); BLLSubCategoria bll = new BLLSubCategoria(cx); ModeloSubCategoria modelo = bll.CarregaModeloSubCategoria(codigo); PreencheCampos(modelo); alteraBotoes(); }
public void Alterar(ModeloSubCategoria modelo) { if (modelo.cat_cod <= 0) { throw new Exception("código"); } ValidaCampos(modelo); DALSubCategoria DALobj = new DALSubCategoria(conexao); DALobj.Alterar(modelo); }