private void btGerar_Click(object sender, EventArgs e) { try { for (int i = 0; i < dgEtiquetas.Rows.Count; i++) { ProdutosBLL objPro = new ProdutosBLL(); objPro.localizar("pro_codigo", dgEtiquetas.Rows[i].Cells[0].Value.ToString()); CodigoBarraBLL objCB = new CodigoBarraBLL(); objCB.pro_codigoBarra = String.Format("*{0}*", objPro.pro_codigoBarra); objCB.pro_precoVenda = objPro.pro_precoVenda; objCB.pro_nome = objPro.pro_nome; for (int j = 0; j < int.Parse(dgEtiquetas.Rows[i].Cells[2].Value.ToString()); j++) { objCB.inserir(); } objCB = null; objPro = null; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void button5_Click(object sender, EventArgs e) { try { decimal subtotal = 0; if (txtCodigo.Text != "" && dgDados.Rows.Count > 0) { for (int i = 0; i < dgDados.Rows.Count; i++) { objCP.cp_compras = int.Parse(txtCodigo.Text); ProdutosBLL objPro = new ProdutosBLL(); objPro.localizar(dgDados.Rows[i].Cells[1].Value.ToString(), "pro_nome"); objCP.cp_produtos = objPro.pro_codigo; objCP.localizarProdutoDaCompra(objCP.cp_compras, objCP.cp_produtos); //procurar pelo produto atual if (((bool)dgDados.Rows[i].Cells[0].Value == false)) { objCP.cp_chegou = "Não"; } else { objCP.cp_chegou = "Sim"; objCP.cp_quantidade = decimal.Parse(dgDados.Rows[i].Cells[2].Value.ToString()); //quantidade objCP.cp_subtotal = objCP.cp_quantidade * objCP.cp_valorUnitario; subtotal += objCP.cp_subtotal; objPro.pro_quantidade += objCP.cp_quantidade; objPro.alterarQuantidade(); LançamentoEstoqueProduto("ENTRADA", objPro.pro_codigo, DateTime.Now, dgDados.Rows[i].Cells[1].Value.ToString(), global.codUsuario, global.nomeUsuario, decimal.Parse(dgDados.Rows[i].Cells[2].Value.ToString()), "Entrada via compras"); } objCP.alterar();//Alterar status objPro = null; } limpar(); objCom.com_codigo = objCP.cp_compras; objCom.com_valorTotal = subtotal; objCom.alterarEntradaMercadoria(); objCP.limpar(); MessageBox.Show("Entrada de mercadorias inserida com sucesso", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void lbProdutos_SelectedIndexChanged(object sender, EventArgs e) { try { if (lbProdutos.SelectedIndex >= 0) { ProdutosBLL objPro = new ProdutosBLL(); objPro.localizar(lbProdutos.SelectedItem.ToString(), "pro_nome"); nudQuantidade.Value = objPro.pro_quantidade; objPro = null; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void btInserir_Click(object sender, EventArgs e) { try { ProdutosBLL objPro = new ProdutosBLL(); if (lbProdutos.SelectedIndex < 0) { throw new Exception("Por favor, selecione um produto da lista"); } if (nudQuantidade.Value < 1) { throw new Exception("Por favor, selecione uma quantidade superior a 0"); } objPro.localizar("pro_codigo", lbProdutos.SelectedItem.ToString()); int achou = 0; for (int i = 0; i < dgEtiquetas.Rows.Count; i++) { if (dgEtiquetas.Rows[i].Cells[0].Value.ToString() == objPro.pro_codigo.ToString()) { achou = 1; int quantidade = int.Parse(dgEtiquetas.Rows[i].Cells[2].Value.ToString()); quantidade += int.Parse(nudQuantidade.Value.ToString()); dgEtiquetas.Rows[i].Cells[2].Value = quantidade; } } if (achou == 0) { dgEtiquetas.Rows.Add(objPro.pro_codigo, objPro.pro_nome, nudQuantidade.Value); } objPro = null; if (lbProdutos.SelectedIndex < lbProdutos.Items.Count - 1) { lbProdutos.SelectedIndex = lbProdutos.SelectedIndex + 1; } else if (lbProdutos.SelectedIndex == lbProdutos.Items.Count - 1) { lbProdutos.SelectedIndex = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void txtNumero_Leave(object sender, EventArgs e) { try { // Localizar usuário dgDados.Rows.Clear(); int cod; int.TryParse(txtCodigo.Text, out cod); if (cod != 0) { objCP.limpar(); objCP.cp_compras = cod; objCP.localizarLeave(objCP.cp_compras.ToString(), "cp_compras"); if (objCP.cp_compras != 0) { DataTable tab = objCP.localizarComRetorno(objCP.cp_compras.ToString(), "cp_compras"); for (int i = 0; i < tab.Rows.Count; i++) { ProdutosBLL objPro = new ProdutosBLL(); objPro.localizar(tab.Rows[i][1].ToString(), "pro_codigo"); if (tab.Rows[i][5].ToString() != "Sim") { dgDados.Rows.Add(false, objPro.pro_nome, tab.Rows[i][3].ToString()); } //else //dgDados.Rows.Add(true, objPro.pro_nome, tab.Rows[i][3].ToString()); objPro = null; } } else { limpar(); } } else { limpar(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }