public void seleciona_produto(Int32 id, String codigo_barras) { Zenfox_Software_OO.Cadastros.Entidade_Produto item = new Zenfox_Software_OO.Cadastros.Entidade_Produto(); if (id > 0) { item.id = id; } if (codigo_barras.Length > 0) { item.ean = codigo_barras; } Zenfox_Software_OO.Cadastros.Produto cmd = new Zenfox_Software_OO.Cadastros.Produto(); item = cmd.seleciona_entidade(item); if (item.id > 0) { this.id_produto = item.id; txt_descricao_produto.Text = item.nome_produto; txt_quantidade.Text = "1"; lbl_valor_produto.Text = "R$ " + item.valor_venda; txt_quantidade.Focus(); } else { this.id_produto = 0; txt_descricao_produto.Text = ""; txt_quantidade.Text = "0"; lbl_valor_produto.Text = "R$ 0.00"; txt_codigo_barras.Focus(); } }
private void txt_quantidade_KeyUp(object sender, KeyEventArgs e) { if (qtd_enter == false) { if (e.KeyCode == Keys.Enter) { if (txt_quantidade.Text.Length > 0) { if (Int32.Parse(txt_quantidade.Text) > 0) { //this.dataGridView1.Rows.Add("five", "six", "seven", "eight"); Zenfox_Software_OO.Cadastros.Entidade_Produto item = new Zenfox_Software_OO.Cadastros.Entidade_Produto(); Zenfox_Software_OO.Cadastros.Produto cmd = new Zenfox_Software_OO.Cadastros.Produto(); if (this.id_produto == 0) { MessageBox.Show("Nenhum produto selecionado !"); qtd_enter = true; return; } item.id = this.id_produto; item = cmd.seleciona_entidade(item); DataGridViewRow row = (DataGridViewRow)dg_venda.Rows[0].Clone(); row.Cells[0].Value = item.id; row.Cells[1].Value = item.nome_produto; row.Cells[2].Value = txt_quantidade.Text; row.Cells[3].Value = item.valor_venda; row.Cells[4].Value = 0; row.Cells[5].Value = (Int32.Parse(txt_quantidade.Text)) * item.valor_venda; dg_venda.Rows.Add(row); limpa_produto(); calcula_total(); } } else { MessageBox.Show("Você deve informar uma quantidade válida !"); qtd_enter = true; } } } else { qtd_enter = false; } }
public void preenche_campos() { Zenfox_Software_OO.Cadastros.Produto cmd = new Zenfox_Software_OO.Cadastros.Produto(); Zenfox_Software_OO.Cadastros.Entidade_Produto item = cmd.seleciona_entidade(new Zenfox_Software_OO.Cadastros.Entidade_Produto() { id = this.id }); txtData.Text = item.data_cadastro; txt_nome_produto.Text = item.nome_produto; txt_ean.Text = item.ean; txtValor_Compra.Text = item.valor_compra.ToString(); txtPreco_Venda.Text = item.valor_venda.ToString(); txtPreco_Atacado.Text = item.valor_venda_atacado.ToString(); txtPreco_Venda_Margem.Text = item.valor_venda_margem.ToString(); //txtPreco_Atacado_Margem.Text = item.valor_venda_atacado_margem.ToString(); txtNCM.Text = item.ncm; if (item.cfop == 5101) { txtCFOP.SelectedIndex = txtCFOP.Items.IndexOf("5101 - Venda de produção do estabelecimento"); } if (item.cfop == 5102) { txtCFOP.SelectedIndex = txtCFOP.Items.IndexOf("5102 - Venda de mercadoria adquirida ou recebida de terceiros"); } if (item.cfop == 5103) { txtCFOP.SelectedIndex = txtCFOP.Items.IndexOf("5103 - Venda de produção do estabelecimento, efetuada fora do estabelecimento"); } if (item.cfop == 5405) { txtCFOP.SelectedIndex = txtCFOP.Items.IndexOf("5405 - Venda de mercadoria adquirida ou recebida de terceiros em operação com mercadoria sujeita ao regime de substituição tributária, na condição de contribuinte substituído"); } txt_estoque.Text = item.estoque.ToString(); txt_estoque_maximo.Text = item.estoque_maximo.ToString(); txt_estoque_minimo.Text = item.estoque_minimo.ToString(); }
private void button1_Click(object sender, EventArgs e) { Zenfox_Software_OO.Cadastros.Entidade_Produto item = new Zenfox_Software_OO.Cadastros.Entidade_Produto(); // Validando NCM if (txtNCM.Text.Length >= 8) { //Validando CFOP try { if (Int32.Parse(txtCFOP.SelectedItem.ToString().Split('-')[0].Trim()) > 0) { //Validando EAN if (txt_ean.Text != null && txt_ean.Text != "") { Zenfox_Software_OO.ACBR acbr = new Zenfox_Software_OO.ACBR(); if (acbr.valida_ncm(txtNCM.Text)) { item.id = this.id; //Dados Produto try { if (cb_fornecedor.SelectedValue.ToString() != null && cb_fornecedor.SelectedValue.ToString() != "") { item.fornecedor = Int32.Parse(cb_fornecedor.SelectedValue.ToString()); } else { item.fornecedor = 0; } } catch { item.fornecedor = 0; } item.nome_produto = txt_nome_produto.Text; item.ean = txt_ean.Text; #region Valores if (txtValor_Compra.Text.Length > 0) { item.valor_compra = Double.Parse(txtValor_Compra.Text); } else { item.valor_compra = 0; } if (txtPreco_Venda.Text.Length > 0) { item.valor_venda = Double.Parse(txtPreco_Venda.Text); } else { item.valor_compra = 0; } if (txtPreco_Venda_Margem.Text.Length > 0) { item.valor_venda_margem = Double.Parse(txtPreco_Venda_Margem.Text); } else { item.valor_venda_margem = 0; } if (txtPreco_Atacado.Text.Length > 0) { item.valor_venda_atacado = Double.Parse(txtPreco_Atacado.Text); } else { item.valor_venda_atacado = 0; } // if (txtPreco_Atacado_Margem.Text.Length > 0) // item.valor_venda_atacado_margem = Double.Parse(txtPreco_Atacado_Margem.Text); // else // item.valor_venda_atacado_margem = 0; #endregion item.cfop = Int32.Parse(txtCFOP.SelectedItem.ToString().Split('-')[0].Trim()); item.ncm = txtNCM.Text; #region Estoque if (txt_estoque_inicial.Text.Length > 0) { item.estoque_inicial = Double.Parse(txt_estoque_inicial.Text); } else { item.estoque_inicial = 0; } if (txt_estoque_minimo.Text.Length > 0) { item.estoque_minimo = Double.Parse(txt_estoque_minimo.Text); } else { item.estoque_minimo = 0; } if (txt_estoque_maximo.Text.Length > 0) { item.estoque_maximo = Double.Parse(txt_estoque_maximo.Text); } else { item.estoque_maximo = 0; } if (txt_estoque.Text.Length > 0) { item.estoque = Double.Parse(txt_estoque.Text); } else { item.estoque = 0; } #endregion Zenfox_Software_OO.Cadastros.Produto cmd = new Zenfox_Software_OO.Cadastros.Produto(); try { cmd.salva(item); MessageBox.Show("Cadastro realizado com sucesso !"); this.Close(); } catch (Exception ee) { MessageBox.Show(ee.Message); } } else { MessageBox.Show("NCM Inválido !"); } } else { MessageBox.Show("Você precisa informar o Código Barras(EAN) deste produto"); tabControl1.SelectedTab = tabPage1; txt_ean.Focus(); } } else { MessageBox.Show("Você precisa informar o CFOP deste produto"); tabControl1.SelectedTab = tabPage2; txtCFOP.Focus(); } } catch (Exception ee) { MessageBox.Show(ee.Message); // tabControl1.SelectedTab = tabPage2; // txtNCM.Focus(); } } else { MessageBox.Show("Você precisa informar o NCM válido deste produto"); tabControl1.SelectedTab = tabPage2; txtNCM.Focus(); } }