public void LocalizarCategoria() { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexão); BLLCategoria bll = new BLLCategoria(cx); ModeloCategoria modelo = bll.CarregaModeloCategoria(codigo); PreencheCampos(modelo); alteraBotoes(); }
private void btnLocalizar_Click(object sender, EventArgs e) { if (codigo != 0) { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexão); BLLCategoria bll = new BLLCategoria(cx); ModeloCategoria modelo = bll.CarregaModeloCategoria(codigo); PreencheCampos(modelo); } else { frmConsultaCategoria f = new frmConsultaCategoria(); Close(); f.ShowDialog(); f.Dispose(); } }
private void btLocalizar_Click(object sender, EventArgs e) { frmConsultaCategoria f = new frmConsultaCategoria(); f.ShowDialog(); if (f.codigo != 0) { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLCategoria bll = new BLLCategoria(cx); ModeloCategoria modelo = bll.CarregaModeloCategoria(f.codigo); txtCodigo.Text = modelo.CatCod.ToString(); txtNome.Text = modelo.CatNome; alteraBotoes(3); } else { this.LimpaTela(); this.alteraBotoes(1); } f.Dispose(); }
private void txtNome_Leave(object sender, EventArgs e) { if (this.operacao == "Inserir") { int r = 0; DALConexao cnx = new DALConexao(DadosDaConexao.StringDeConexao); BLLCategoria bll = new BLLCategoria(cnx); r = bll.VerificaCategoria(txtNome.Text); if (r > 0) { DialogResult d = MessageBox.Show("Já existe um registro com esse valor. Deseja Alterar o registro?", "Aviso", MessageBoxButtons.YesNo); if (d.ToString() == "Yes") { this.operacao = "Alterar"; ModeloCategoria modelo = bll.CarregaModeloCategoria(r); txtCodigo.Text = modelo.CatCod.ToString(); txtNome.Text = modelo.CatNome.ToString(); this.alteraBotoes(3); } } } }
private void btLocalizar_Click(object sender, EventArgs e) { Frm_ConsultaCategoria consultaCategoria = new Frm_ConsultaCategoria(); //CRIA O FORMULARIO DE CONSULTA DA CATEGORIA consultaCategoria.ShowDialog(); //EXIBE O FORMULARIO if (consultaCategoria.Codigo != 0) //VERIFICA SE O CODIGO É DIFERENTE DE 0 - ENTAO ELE SELECIONOU UMA CATEGORIA PARA ALTERAR { DALConexao dalConexao = new DALConexao(DadosDaConexao.StringDeConexao); //CRIA A CONEXAO BLLCategoria bllCategoria = new BLLCategoria(dalConexao); //CRIA A CONEXAO ModeloCategoria modeloCategoria = bllCategoria.CarregaModeloCategoria(consultaCategoria.Codigo); //CRIA O DLL. carrega o modelo ! Apartir do modelo criado por meio do CarregaModelo, e tem como parametro o CODIGO que o usuario selecionou. txtCodigo.Text = modeloCategoria.CatCod.ToString(); //PEGA AS INFORMACOES E VOLTA NA TELA txtNome.Text = modeloCategoria.CatNome; //PEGA AS INFORMACOES E VOLTA NA TELA AlterarBotoes(3); } else { LimpaTela(); AlterarBotoes(1); } consultaCategoria.Dispose(); }