//------------------------------------------------------------------------------------------------------------------- private void btLocalizar_Click(object sender, EventArgs e) { BLLUndMedida bll = new BLLUndMedida(); dgvDados.DataSource = bll.ListagemComFiltro(txtValor.Text); txtValor.Clear(); txtValor.Focus(); }
//------------------------------------------------------------------------------------------------------------------- private void btLocalizar_Click(object sender, EventArgs e) { try { frmConsultaProduto fcproduto = new frmConsultaProduto(); fcproduto.ShowDialog(); if (fcproduto.codigo != -1) { BLLProduto bll = new BLLProduto(); ModeloProduto modelo = bll.carregaModelo(fcproduto.codigo); txtCodigo.Text = modelo.pro_cod.ToString(); txtNome.Text = modelo.pro_nome.ToString(); rtbDescricao.Text = modelo.pro_descricao.ToString(); //pbFoto.Image = (Image) modelo.pro_foto; try { MemoryStream ms = new MemoryStream(modelo.pro_foto); pbFoto.Image = Image.FromStream(ms); } catch (Exception erro) { } //txtfoto.Text = modelo.pro_foto.ToString(); txtValorPago.Text = modelo.pro_valorvenda.ToString(); txtValorVenda.Text = modelo.pro_valorvenda.ToString(); NUDQuantidade.Text = modelo.pro_qtde.ToString(); cbUmed.SelectedValue = modelo.umed_cod.ToString(); cbCategoria.SelectedValue = modelo.cat_cod.ToString(); cbSubCategoria.SelectedValue = modelo.scat_cod.ToString(); BLLCategoria bllcat = new BLLCategoria(); cbCategoria.DataSource = bllcat.Listagem(); cbCategoria.DisplayMember = "cat_nome"; cbCategoria.ValueMember = "cat_cod"; try { BLLSubCategoria bllsub = new BLLSubCategoria(); cbSubCategoria.DataSource = bllsub.ListagemComCodigo((int)cbCategoria.SelectedValue); cbSubCategoria.DisplayMember = "scat_nome"; cbSubCategoria.ValueMember = "scat_cod"; } catch { } BLLUndMedida bllumed = new BLLUndMedida(); cbUmed.DataSource = bllumed.Listagem(); cbUmed.DisplayMember = "umed_nome"; cbUmed.ValueMember = "umed_cod"; txtTamanho.Text = modelo.pro_tamanho.ToString(); txtCodigoBarras.Text = modelo.pro_codigobarras.ToString(); this.alteraBotoes(3); } fcproduto.Dispose(); }catch (Exception error) { MessageBox.Show(error.Message); } }
//------------------------------------------------------------------------------------------------------------------- private void btAddUndMedida_Click(object sender, EventArgs e) { frmCadastroTipoRoupa frm = new frmCadastroTipoRoupa(); frm.ShowDialog(); frm.Dispose(); BLLUndMedida obj = new BLLUndMedida(); cbUmed.DataSource = obj.Listagem(); cbUmed.DisplayMember = "umed_nome"; cbUmed.ValueMember = "umed_cod"; }
//------------------------------------------------------------------------------------------------------------------- private void btExcluir_Click(object sender, EventArgs e) { try { DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d.ToString() == "Yes") { BLLUndMedida bll = new BLLUndMedida(); bll.Excluir(Convert.ToInt32(txtCodigo.Text)); this.limpaTela(); this.alteraBotoes(1); } } catch (Exception erro) { MessageBox.Show("Impossivel excluir o registro. \n O registro está sendo utilizado em outro local", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); this.alteraBotoes(3); } }
//------------------------------------------------------------------------------------------------------------------- private void btLocalizar_Click(object sender, EventArgs e) { try { frmConsultaUndMedida frm = new frmConsultaUndMedida(); frm.ShowDialog(); if (frm.codigo >= 0) { BLLUndMedida bll = new BLLUndMedida(); ModeloUndMedida modelo = bll.carregaModelo(frm.codigo); txtCodigo.Text = modelo.umed_cod.ToString(); txtNome.Text = modelo.umed_nome; this.alteraBotoes(3); } frm.Dispose(); }catch (Exception error) { MessageBox.Show(error.Message); } }
//------------------------------------------------------------------------------------------------------------------- private void frmCadastroProduto_Load(object sender, EventArgs e) { this.alteraBotoes(1); BLLCategoria bllcat = new BLLCategoria(); cbCategoria.DataSource = bllcat.Listagem(); cbCategoria.DisplayMember = "cat_nome"; cbCategoria.ValueMember = "cat_cod"; try { BLLSubCategoria bllsub = new BLLSubCategoria(); cbSubCategoria.DataSource = bllsub.ListagemComCodigo((int)cbCategoria.SelectedValue); cbSubCategoria.DisplayMember = "scat_nome"; cbSubCategoria.ValueMember = "scat_cod"; } catch { } BLLUndMedida bllumed = new BLLUndMedida(); cbUmed.DataSource = bllumed.Listagem(); cbUmed.DisplayMember = "umed_nome"; cbUmed.ValueMember = "umed_cod"; }
//------------------------------------------------------------------------------------------------------------------- private void btSalvar_Click(object sender, EventArgs e) { try { BLLUndMedida bll = new BLLUndMedida(); ModeloUndMedida modelo = new ModeloUndMedida(); modelo.umed_nome = txtNome.Text; if (this.operacao == "inserir") { bll.Incluir(modelo); MessageBox.Show("Cadastro inserido com código: " + modelo.umed_cod, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { modelo.umed_cod = Convert.ToInt32(txtCodigo.Text); bll.Alterar(modelo); MessageBox.Show("Cadastro alterado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.limpaTela(); this.alteraBotoes(1); } catch (Exception error) { MessageBox.Show(error.Message); } }
//------------------------------------------------------------------------------------------------------------------- private void txtNome_Leave(object sender, EventArgs e) { if (operacao == "inserir") { int r = 0; BLLUndMedida bll = new BLLUndMedida(); r = bll.VerificaUnidadeDeMedida(txtNome.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"; ModeloUndMedida modelo = bll.carregaModelo(r); txtCodigo.Text = modelo.umed_cod.ToString(); txtNome.Text = modelo.umed_nome; //this.alteraBotoes(3); txtNome.Clear(); txtNome.Focus(); } else { txtNome.Clear(); txtNome.Focus(); } } else { txtNome.Clear(); txtNome.Focus(); } } } }