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 btnAddCat_Click(object sender, EventArgs e) { frmCadastroCategoria f = new frmCadastroCategoria(); f.ShowDialog(); f.Dispose(); DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLCategoria bll = new BLLCategoria(cx); cmbCategoria.DataSource = bll.Localizar(""); cmbCategoria.DisplayMember = "cat_nome"; cmbCategoria.ValueMember = "cat_cod"; cmbCategoria.SelectedIndex = -1; try { //combo da subcategoria BLLSubCategoria sbll = new BLLSubCategoria(cx); if (cmbCategoria.SelectedIndex >= 0) { cmbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cmbCategoria.SelectedValue); cmbSubCategoria.DisplayMember = "scat_nome"; cmbSubCategoria.ValueMember = "scat_cod"; } } catch { MessageBox.Show("Cadastre uma categoria!"); } }
private void btAdd_Categoria_Click(object sender, EventArgs e) { Frm_CadastroCategoria cadastroCategoria = new Frm_CadastroCategoria(); cadastroCategoria.ShowDialog(); cadastroCategoria.Dispose(); DALConexao dalConexao = new DALConexao(DadosDaConexao.StringDeConexao); BLLCategoria bllCategoria = new BLLCategoria(dalConexao); //FONTE DE DADO DELE. RECEBE O VALOR CONTIDO cbCategoria.DataSource = bllCategoria.Localizar(""); //DATASOURCE == pega todas as propriedades do objeto pra preencher no DataSource. cbCategoria.DisplayMember = "cat_nome"; cbCategoria.ValueMember = "cat_cod"; try { //COMBO BOX DA SUB CATEGOPRIA== BLLSubCategoria _bllsubCategoria = new BLLSubCategoria(dalConexao); cbSubcategoria.DataSource = _bllsubCategoria.LocalizaPorCategoria((int)cbCategoria.SelectedValue); //CARREGA COMBO BOX, PASSANDO COMO PARAMETRO O CODIGO DA CATEGORIA QUE ESTÁ VINCULADO A SUBCATEGORIA . O RETORNO DO METODO ! cbSubcategoria.DisplayMember = "scat_nome"; //mostra nome da subcategoria e passa para o campo do combo box cbSubcategoria.ValueMember = "scat_cod"; //mostra codigo da subcategoria e passa para o campo do combo box } catch (Exception ex) { throw new Exception(ex.Message); } }
private void frmCadastroProduto_Load(object sender, EventArgs e) { txtQtde.MaxLength = 6; this.alteraBotoes(1); //combo da categoria DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLCategoria bll = new BLLCategoria(cx); cbCategoria.DataSource = bll.Localizar(""); cbCategoria.DisplayMember = "cat_nome"; cbCategoria.ValueMember = "cat_cod"; try { //combo da subcategoria BLLSubCategoria sbll = new BLLSubCategoria(cx); cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cbCategoria.SelectedValue); cbSubCategoria.DisplayMember = "scat_nome"; cbSubCategoria.ValueMember = "scat_cod"; } catch { //MessageBox.Show("Cadastre uma categoria"); } //combo und medida BLLUnidadeDeMedida ubll = new BLLUnidadeDeMedida(cx); cbUnd.DataSource = ubll.Localizar(""); cbUnd.DisplayMember = "umed_nome"; cbUnd.ValueMember = "umed_cod"; }
private void btLocalizar_Click(object sender, EventArgs e) { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubCategoria bll = new BLLSubCategoria(cx); dgvDados.DataSource = bll.Localizar(txtValor.Text); }
//========================================================================================================================================== 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); } }
//Evento click botão salvar private void btnSalvar_Click(object sender, EventArgs e) { try { /*Aqui eu chamei a classe MCategoria que está na camada Modelo. Caso eu não chamasse ela aqui, eu não iria conseguir acessar * os atributos da classe. A classe está sendo instanciada pela varíavel modelo, que está guardando todos os atributos da * classe.*/ MSubCategoria modelo = new MSubCategoria(txtSubCatNome.Text, int.Parse(cbxCodCat.SelectedValue.ToString())); //Analisando se o usuário deseja atualizar ou salvar um novo registro if (btnSalvar.Text != "Atualizar") { BLLSubCategoria.Incluir(modelo); MessageBox.Show("Cadastro realizado com sucesso!"); } else { modelo.SubCategoriaCod = int.Parse(txtCodigo.Text); //Pegando o ID BLLSubCategoria.Alterar(modelo); MessageBox.Show("Cadastro alterado com sucesso!"); } LimpaTela(); } /* A mensagem de erro já está perfeita. Com esse método ele já idenifica o tipo de erro que está causando e retorna * para o usuário. Só precisa apenas aprimorar. Colocar um ícone e etc.*/ catch (Exception erro) { MessageBox.Show(erro.Message); } }
//------------------------------------------------------------------------------------------------------------------- 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 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 FormSubCategoria_Load(object sender, EventArgs e) { DALConexao cx = new DALConexao(DadosdaConexao.StringDeConexao); BLLCategoria bll = new BLLCategoria(cx); lkUpEditcbCategoriaCadastroSubCategoria.Properties.DataSource = bll.Localizar(""); lkUpEditcbCategoriaCadastroSubCategoria.Properties.DisplayMember = "cat_nome"; lkUpEditcbCategoriaCadastroSubCategoria.Properties.ValueMember = "cat_cod"; //lkUpEditcbCategoriaCadastroSubCategoria.Properties.Columns[0]. //lkUpEditcbCategoriaCadastroSubCategoria.Properties.Columns[0].Width = 50; //lkUpEditcbCategoriaCadastroSubCategoria.Properties.Columns[1].FieldName = "Categoria"; //lkUpEditcbCategoriaCadastroSubCategoria.Properties.Columns[1].Width = 250; BLLSubCategoria bllScat = new BLLSubCategoria(cx); gridViewSubCategoria.DataSource = bllScat.Localizar(inputInserirSubCategoria.Text); gridViewSubCategoria.Columns[0].HeaderText = "Código"; gridViewSubCategoria.Columns[0].Width = 50; gridViewSubCategoria.Columns[1].HeaderText = "Sub Categoria"; gridViewSubCategoria.Columns[1].Width = 253; gridViewSubCategoria.Columns[2].HeaderText = "Código"; gridViewSubCategoria.Columns[2].Width = 50; gridViewSubCategoria.Columns[3].HeaderText = "Categoria"; gridViewSubCategoria.Columns[3].Width = 253; btnSalvarSubCategoria.Visible = false; btnExcluirSubCategoria.Visible = false; }
private void btnPesquisarSubCategoria_Click(object sender, EventArgs e) { DALConexao cx = new DALConexao(DadosdaConexao.StringDeConexao); BLLSubCategoria bll = new BLLSubCategoria(cx); gridViewSubCategoria.DataSource = bll.Localizar(inputInserirSubCategoria.Text); }
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); } }
private void frmCadastroProduto_Load(object sender, EventArgs e) { this.alteraBotoes(1); //combo da categoria DAOConexao cx = new DAOConexao(DAOBanco.StringDeConexao); BLLCategoria bll = new BLLCategoria(cx); cbCategoria.DataSource = bll.Localizar(""); cbCategoria.DisplayMember = "cat_nome"; cbCategoria.ValueMember = "cat_cod"; //cbCategoria.AutoCompleteMode = AutoCompleteMode.Suggest; //cbCategoria.AutoCompleteSource = AutoCompleteSource.ListItems; try { //combo da subcategoria BLLSubCategoria sbll = new BLLSubCategoria(cx); cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cbCategoria.SelectedValue); cbSubCategoria.DisplayMember = "scat_nome"; cbSubCategoria.ValueMember = "scat_cod"; } catch { //MessageBox.Show("Cadastre uma categoria"); } //combo und medida BLLUnidadeMedida ubll = new BLLUnidadeMedida(cx); cbUnd.DataSource = ubll.Localizar(""); cbUnd.DisplayMember = "umed_nome"; cbUnd.ValueMember = "umed_cod"; }
private void btAddCategoria_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { frmCadastroCategoria f = new frmCadastroCategoria(); f.ShowDialog(); f.Dispose(); //combo da categoria DAOConexao cx = new DAOConexao(DAOBanco.StringDeConexao); BLLCategoria bll = new BLLCategoria(cx); cbCategoria.DataSource = bll.Localizar(""); cbCategoria.DisplayMember = "cat_nome"; cbCategoria.ValueMember = "cat_cod"; try { //combo da subcategoria BLLSubCategoria sbll = new BLLSubCategoria(cx); cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cbCategoria.SelectedValue); cbSubCategoria.DisplayMember = "scat_nome"; cbSubCategoria.ValueMember = "scat_cod"; } catch { //MessageBox.Show("Cadastre uma categoria"); } }
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(); }
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); } }
private void btnExcluir_Click(object sender, EventArgs e) { try { DialogResult mensagem = MessageBox.Show("Desaja excluir o registro?", "Aviso", MessageBoxButtons.YesNo); if (mensagem.ToString().Equals("Yes")) { DALConexao con = new DALConexao(DadosConexao.StringConexao); BLLSubCategoria sc = new BLLSubCategoria(con); sc.Excluir(Convert.ToInt32(txtCodigoSubCategoria.Text)); this.LimparCampos(); this.AlteraBotoes(1); } } catch { MessageBox.Show("Erro ao excluir registro"); this.AlteraBotoes(3); } }
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 btnAddCategoria_Click(object sender, EventArgs e) { frmCadastroCategoria f = new frmCadastroCategoria(); f.ShowDialog(); f.Dispose(); DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexão); BLLCategoria bll = new BLLCategoria(cx); cbxCategoria.DataSource = bll.Localizar(""); cbxCategoria.DisplayMember = "NOME"; cbxCategoria.ValueMember = "CODIGO"; try { //combo sub categoria BLLSubCategoria sbll = new BLLSubCategoria(cx); cbxSubCategoria.DataSource = sbll.LocalizarPorCategoria(Convert.ToInt32(cbxCategoria.SelectedValue)); cbxSubCategoria.DisplayMember = "NOME"; cbxSubCategoria.ValueMember = "CODIGO"; } catch { MessageBox.Show("Cadastre uma categoria"); } }
private void frmCadastroProduto_Load(object sender, EventArgs e) { alterarBotoes(1); ////COMBO DA CATEGORIA DALConexao conexao = new DALConexao(DadosDaConexao.StringDeConexao); BLLCategoria daoCategoria = new BLLCategoria(conexao); cboCategoria.DataSource = daoCategoria.Localizar(""); cboCategoria.DisplayMember = "cat_nome"; cboCategoria.ValueMember = "cat_cod"; //cboCategoria.AutoCompleteMode = AutoCompleteMode.Suggest; //cboCategoria.AutoCompleteSource = AutoCompleteSource.ListItems; try { BLLSubCategoria sub = new BLLSubCategoria(conexao); cboSubCategoria.DataSource = sub.LocalizaPorCategoria(1); //cbSubCategoria.DataSource = sub.LocalizaPorCategoria((int)cbCategoria.SelectedValue); cboSubCategoria.DisplayMember = "scat_nome"; cboSubCategoria.ValueMember = "scat_cod"; } catch (Exception ex) { throw new Exception(ex.Message); } //COMBO UNIDADE DE MEDIDA BLLUnidMedida daoUniMedida = new BLLUnidMedida(conexao); cboUnidMedida.DataSource = daoUniMedida.Localizar(""); cboUnidMedida.DisplayMember = "umed_nome"; cboUnidMedida.ValueMember = "umed_cod"; }
private void btLocalizar_Click(object sender, EventArgs e) { DALConexao _dalConexao = new DALConexao(DadosDaConexao.StringDeConexao); //cria conexao BLLSubCategoria _bllsubCategoria = new BLLSubCategoria(_dalConexao); //cria subcategoria Dgv_Dados.DataSource = _bllsubCategoria.Localizar(txtValor.Text); //vinculou o retorno localizar no datasource }
private void btAddSubCategoria_Click(object sender, EventArgs e) { frmCadastroSubCategoria f = new frmCadastroSubCategoria(); f.ShowDialog(); f.Dispose(); DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);//criar conexão //-------------------------------------------------------------------------------------------------- // Carragar o combobox das subcatagorias //-------------------------------------------------------------------------------------------------- try// Tratar erro caso nao tenha catagoria cadastrado, ou campo esta vazio { //so montrar a subcatagiria conforme a catagiria selecionada: //combo da subcategoria, que depende da catagoria selecionada A BLLSubCategoria sbll = new BLLSubCategoria(cx); cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cbCategoria.SelectedValue); //aula 33 7:00 cbSubCategoria.DisplayMember = "scat_nome"; //mostrar o nome (Indicar qual coluna é exibida para selecionar) cbSubCategoria.ValueMember = "scat_cod"; //armazena o codigo do item selecionado } catch { //MessageBox.Show("Cadastre uma categoria"); // https://youtu.be/XtknKZ5JAeM?list=PLfvOpw8k80Wqj1a66Qsjh8jj4hlkzKSjA&t=756 } }
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); } }
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 { 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 Localizar() { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexão); BLLSubCategoria bll = new BLLSubCategoria(cx); dgvDados.DataSource = bll.Localizar(txtValorSubCategoria.Text); }
private void frmCadastroProduto_Load(object sender, EventArgs e) { this.AlteraBotoes(1); //combo da categoria DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLCategoria bll = new BLLCategoria(cx); cmbCategoria.DataSource = bll.Localizar(""); cmbCategoria.DisplayMember = "cat_nome"; cmbCategoria.ValueMember = "cat_cod"; cmbCategoria.SelectedIndex = -1; try { //combo da subcategoria BLLSubCategoria sbll = new BLLSubCategoria(cx); if (cmbCategoria.SelectedIndex >= 0) { cmbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cmbCategoria.SelectedValue); cmbSubCategoria.DisplayMember = "scat_nome"; cmbSubCategoria.ValueMember = "scat_cod"; } } catch { MessageBox.Show("Cadastre uma categoria!"); } //combo unidade de medida BLLUnidadeDeMedida ubll = new BLLUnidadeDeMedida(cx); cmbUnMedida.DataSource = ubll.Localizar(""); cmbUnMedida.DisplayMember = "umed_nome"; cmbUnMedida.ValueMember = "umed_cod"; }
private void btnPesquisar_Click(object sender, EventArgs e) { DALConexao con = new DALConexao(DadosDaConexao.StringDeConexao); BLLSubCategoria categoria = new BLLSubCategoria(con); GridCategoria.DataSource = categoria.Localizar(txtPesquisa.Text.ToUpper()); }
private void Frm_CadastroProduto_Load(object sender, EventArgs e) //COMBO BOX DA CATEGORIA { AlterarBotoes(1); DALConexao dalConexao = new DALConexao(DadosDaConexao.StringDeConexao); BLLCategoria bllCategoria = new BLLCategoria(dalConexao); //FONTE DE DADO DELE. RECEBE O VALOR CONTIDO cbCategoria.DataSource = bllCategoria.Localizar(""); //DATASOURCE == pega todas as propriedades do objeto pra preencher no DataSource. cbCategoria.DisplayMember = "cat_nome"; cbCategoria.ValueMember = "cat_cod"; //alto completar cbCategoria.AutoCompleteMode = AutoCompleteMode.Suggest; //tipo que sera de alto completar(SUGESTAO) cbCategoria.AutoCompleteSource = AutoCompleteSource.ListItems; //itens do proprio combo box try { //COMBO BOX DA SUB CATEGOPRIA== BLLSubCategoria bllsubCategoria = new BLLSubCategoria(dalConexao); cbSubcategoria.DataSource = bllsubCategoria.LocalizaPorCategoria(Convert.ToInt32(cbCategoria.SelectedValue)); //CARREGA COMBO BOX, PASSANDO COMO PARAMETRO O CODIGO DA CATEGORIA QUE ESTÁ VINCULADO A SUBCATEGORIA . O RETORNO DO METODO ! cbSubcategoria.DisplayMember = "scat_nome"; //mostra nome da subcategoria e passa para o campo do combo box cbSubcategoria.ValueMember = "scat_cod"; //mostra codigo da subcategoria e passa para o campo do combo box } catch (Exception ex) { throw new Exception(ex.Message); } //UNIDADE DE MEDIDA== BLLUnidadeDeMedida bllunidadedeMedida = new BLLUnidadeDeMedida(dalConexao); cbUnidadeMedida.DataSource = bllunidadedeMedida.localizar(""); //VAI RECEBER O RETORNO DO METODO ! cbUnidadeMedida.DisplayMember = "umed_nome"; cbUnidadeMedida.ValueMember = "umed_cod"; }
private void Salvar() { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); if (txtNome.Text.Trim() != "") { if (tipo == "Setor") { BLLBuffet blls = new BLLBuffet(cx); DTOBuffet dtob = new DTOBuffet(); dtob.NomeBuffet = txtNome.Text.Trim().ToUpper(); dtob.DescBuffet = txtDesc.Text.Trim().ToUpper(); blls.Incluir(dtob); this.categoria = dtob.NomeBuffet; txtNome.Clear(); txtDesc.Clear(); CarregarDgv(); } if (tipo == "Categoria") { BLLCategoria bllc = new BLLCategoria(cx); DTOCategoria dtoc = new DTOCategoria(); dtoc.NomeCat = txtNome.Text.Trim().ToUpper(); dtoc.DescCat = txtDesc.Text.Trim().ToUpper(); bllc.Incluir(dtoc); this.categoria = dtoc.NomeCat; txtNome.Clear(); txtDesc.Clear(); CarregarDgv(); } if (tipo == "Subcategoria") { BLLSubCategoria bllsc = new BLLSubCategoria(cx); DTOSubCategoria dtosc = new DTOSubCategoria(); dtosc.NomeSCat = txtNome.Text.Trim().ToUpper(); dtosc.DescSCat = txtDesc.Text.Trim().ToUpper(); bllsc.Incluir(dtosc); this.categoria = dtosc.NomeSCat; txtNome.Clear(); txtDesc.Clear(); CarregarDgv(); } } }