private void CadastrarProdutos_Click(object sender, EventArgs e) { try { DTO_Produtos obj = new DTO_Produtos(); obj.CodBarras = textBox19.Text; obj.NomeProd = textBox20.Text; obj.DescProd = textBox30.Text; obj.PrecoProd = textBox21.Text; obj.EstoqueProd = textBox22.Text; obj.UnidadeProd = textBox23.Text; obj.TipoUnidProd = comboBox2.Text; if (radioButton1.Checked == true) { obj.AtivoProd = "ativo"; } if (radioButton2.Checked == true) { obj.AtivoProd = "inativo"; } obj.AcaoProd = "cadastro"; File.Copy(ImgOrigem, ImgDestino); string mensagem = BLL_Produtos.ValidarProdutos(obj); MessageBox.Show(mensagem, "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Não Cadastrado", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Buscar_Click_1(object sender, EventArgs e) { try { string codBarras = textBox24.Text; DTO_Produtos obj = new DTO_Produtos(); obj = BLL_Produtos.BuscarProdutos(codBarras); textBox29.Text = obj.IdProd.ToString(); textBox24.Text = obj.CodBarras; textBox25.Text = obj.NomeProd; textBox31.Text = obj.DescProd; textBox26.Text = obj.PrecoProd; textBox27.Text = obj.EstoqueProd; textBox28.Text = obj.UnidadeProd; comboBox3.Text = obj.TipoUnidProd; if (obj.AtivoProd.ToLower() == "ativo") { radioButton4.Checked = true; } if (obj.AtivoProd.ToLower() == "inativo") { radioButton3.Checked = true; } btnAlterar.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAlterar_Click_1(object sender, EventArgs e) { try { DTO_Produtos obj = new DTO_Produtos(); obj.IdProd = int.Parse(textBox29.Text); obj.CodBarras = textBox24.Text; obj.NomeProd = textBox25.Text; obj.DescProd = textBox31.Text; obj.PrecoProd = textBox26.Text; obj.EstoqueProd = textBox27.Text; obj.UnidadeProd = textBox28.Text; obj.TipoUnidProd = comboBox3.Text; if (radioButton4.Checked == true) { obj.AtivoProd = radioButton4.Text; } if (radioButton3.Checked == true) { obj.AtivoProd = radioButton3.Text; } obj.AcaoProd = "alteracao"; string mensagem = BLL_Produtos.ValidarProdutos(obj); MessageBox.Show(mensagem, "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); btnAlterar.Enabled = false; textBox24.Clear(); textBox25.Clear(); textBox26.Clear(); textBox27.Clear(); textBox28.Clear(); textBox29.Clear(); textBox31.Clear(); comboBox3.SelectedIndex = -1; radioButton4.Checked = false; radioButton3.Checked = false; textBox24.Focus(); btnAlterar.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error); } }