private void AdicionarItemsNoListBox(DataRow Linha, ValorComComanda volorComanda) { try { if (Convert.ToInt32(Linha["Quantidade"]) != 0) { // if () //{ //} volorComanda.Nome = Linha["NOME"].ToString(); volorComanda.Id = Convert.ToInt32(Linha["ID"]); exckui.Id = volorComanda.Id; volorComanda.PrecoTotal = Convert.ToDouble(Linha["TOTAL"]); volorComanda.Quantidade = Convert.ToInt32(Linha["Quantidade"]); exckui.Quantidade = volorComanda.Quantidade; lucroTotal += Convert.ToDouble(Linha["Lucro"]); listExluirEstoque.Add(exckui); exckui = new ExcluirEstoque(); string ValoresParaMostrar = volorComanda.ToString(); Total += volorComanda.PrecoTotal; lbl_Total.Values.ExtraText = Total.ToString("C"); rtb_MiniRelatorio.Text += ValoresParaMostrar; } else { volorComanda = new ValorComComanda(); volorComanda.Nome = Linha["NOME"].ToString(); volorComanda.Id = Convert.ToInt32(Linha["ID"]); exckui.Id = volorComanda.Id; volorComanda.PrecoTotal = Convert.ToDouble(Linha["TOTAL"]); exckui.Quantidade = 0; lucroTotal += Convert.ToDouble(Linha["Lucro"]); listExluirEstoque.Add(exckui); exckui = new ExcluirEstoque(); string ValoresParaMostrar = volorComanda.ToString(); Total += volorComanda.PrecoTotal; lbl_Total.Values.ExtraText = Total.ToString("C"); rtb_MiniRelatorio.Text += ValoresParaMostrar; } } catch (Exception Erro) { LimparTxtDeCodigo(); Message("Não Foi Possível Carregar Os Items: " + Erro, "Erro"); } }
private void txt_Produto_KeyPress(object sender, KeyPressEventArgs e) { if (k_ComCodigoDeBarra.Checked || k_rdbSemCodigoDeBarra.Checked) { if ((Keys)e.KeyChar == Keys.Enter) { if (txt_Quantidade.Text.Length > 0 && txt_Produto.Text.Length > 0) { if (k_rdbSemCodigoDeBarra.Checked == true && k_ComCodigoDeBarra.Checked == false) { try { ValorComComanda volorComanda = new ValorComComanda(); if (produtoDao.SelectProdutoPorId(Convert.ToInt32(txt_Produto.Text), "Nao"))//produtoDao.SelectProdutoPorId(produto, "Pes") { DataRow Linha = produtoDao.selectProdutoSomadoSemComandaPorId(Convert.ToInt32(txt_Quantidade.Text), Convert.ToInt32(txt_Produto.Text)).Rows[0]; if (Linha != null) { txt_Produto.Text = string.Empty; AdicionarItemsNoListBox(Linha, volorComanda); } else { Message("Não Foi Encontrado Produto Com O ID: " + txt_CodigoProduto.Text + " Verifique Se O ID Corresponde A Um Produto Com Peso", "Aviso"); LimparTxtDeCodigo(); FonoNotxtProduto(); } } else { Message("Codigo Não Corresponde a Um Produto", "Aviso"); LimparTxtDeCodigo(); FonoNotxtProduto(); } } catch (Exception Erro) { LimparTxtDeCodigo(); txt_Produto.Text = string.Empty; Message("Erro Ao Carregar O Produto: " + Erro.Message, "Erro"); } } else if (k_ComCodigoDeBarra.Checked == true && k_rdbSemCodigoDeBarra.Checked == false) { try { ValorComComanda volorComanda = new ValorComComanda(); /*if (produtoDao.selectFullProdutoPorIDComEstoque(Convert.ToInt32(txt_Produto.Text),"Nao") == null) { MessageBox.Show("Nulão"); }*/ if (produtoDao.SelectProdutoPorCodigo(txt_Produto.Text, "Nao")) { //MessageBox.Show("Test"); DataRow Linha = produtoDao.selectProdutoSomadoSemComandaPorCodigo(Convert.ToInt32(txt_Quantidade.Text), txt_Produto.Text).Rows[0]; if (Linha != null) { txt_Produto.Text = string.Empty; AdicionarItemsNoListBox(Linha, volorComanda); } else { Message("Não Foi Encontrado Produto Com O Codigo De Barra: " + txt_CodigoProduto.Text + " Verifique Se O Codigo Corresponde A Um Produto Com Peso", "Aviso"); LimparTxtDeCodigo(); FonoNotxtProduto(); } } else { Message("Codigo Não Corresponde a Um Produto", "Aviso"); LimparTxtDeCodigo(); FonoNotxtProduto(); } } catch (Exception Erro) { LimparTxtDeCodigo(); Message("Erro Ao Carregar O Produto: " + Erro.Message, "Erro"); } } } else { txt_Produto.Text = string.Empty; Message("É Necessario Selecionar Um Produto E Uma Quantidade", "Aviso"); FonoNotxtProduto(); } } } else { Message("Marque Um Tipo[Com Código De Barra/Sem Código de Barra] Antes De Encaminhar O Produto Para A Venda", "Aviso"); LimparTxtDeCodigo(); } //} //else //{ // Message("Antes De Apertar [Enter] É Necessario Selecionar Um Produto","Aviso"); // FonoNotxtProduto(); //} }
private void txt_CodigoProduto_KeyPress(object sender, KeyPressEventArgs e) { if ((Keys)e.KeyChar == Keys.Enter) { if (k_rdbComComanda.Checked) { try { if (produtoDao.selectValorDaComanda(txt_CodigoProduto.Text).Rows.Count > 0) { ValorComComanda volorComanda = new ValorComComanda(); int LinhaAPercorrer = produtoDao.selectValorDaComanda(txt_CodigoProduto.Text).Rows.Count; Comanda comanda = new Comanda(); comanda.Codigo = txt_CodigoProduto.Text; Comanda x = (listComanda.Find(c => c.Codigo == comanda.Codigo)); //listComanda.FindAll(c=>c.Codigo == comanda.Codigo); //bool jaExiste =(listComanda.Where(c=>c.Codigo ==comanda.Codigo).Count() > 0 ); if (x == null) { listComanda.Add(comanda); x = null; JogaValoresparaComanda(volorComanda); } else { Message("Não É Permitido Passar A Mesma Comanda Mais De Uma Vez", "Aviso"); LimparTxtDeCodigo(); } } else { Message("Não Existe Produtos Adicionados Nessa Comanda, Ou Comanda Inexistente", "Aviso"); LimparTxtDeCodigo(); // x = new Comanda(); } } catch (Exception Erro) { LimparTxtDeCodigo(); Message("Erro Ao Carregar O Produto: " + Erro.Message, "Erro"); } } else { LimparTxtDeCodigo(); Message("Escolha O Modo De Pagamento[Com Comanda/Sem Comanda] Antes De Encaminhar O Produto Para A Venda", ""); } } }
private void JogaValoresparaComanda(ValorComComanda volorComanda) { foreach (DataRow LinhaPreco in produtoDao.selectValorDaComandaPorPreco(txt_CodigoProduto.Text).Rows) { if (Convert.ToInt32(LinhaPreco["Quantidade"]) == 0) { lucroTotal += Convert.ToDouble(LinhaPreco["totalMax"]); } } foreach (DataRow Linha in produtoDao.selectValorDaComanda(txt_CodigoProduto.Text).Rows) { // if (volorComanda.Quantidade >= 1) //{ volorComanda.Id = Convert.ToInt32(Linha["ID"]); volorComanda.IdComanda = Convert.ToInt32(Linha["IDCOMANDA"]); volorComanda.Nome = Linha["Nome"].ToString(); volorComanda.IdProduto = Convert.ToInt32(Linha["IDPRODUTO"]); //exckui.Id = volorComanda.IdProduto; volorComanda.PrecoTotal = Convert.ToDouble(Linha["PRECOTOTAL"]); volorComanda.Quantidade = Convert.ToInt32(Linha["QUANTIDADE"]); //exckui.Quantidade = volorComanda.Quantidade; //listExluirEstoque.Add(exckui); // exckui = new ExcluirEstoque(); //------------------------ //------------------- lucroTotal += Convert.ToDouble(Linha["total"]); // } //-------------------- string ValoresParaMostrar = null; if (Convert.ToInt32(Linha["QUANTIDADE"]) != 0) { ValoresParaMostrar = string.Format("Nome: {0} - Quantidade: {1}x - Preço Total: {2}", volorComanda.Nome, volorComanda.Quantidade, volorComanda.PrecoTotal.ToString("C") + "\n"); } else { ValoresParaMostrar = string.Format("Nome: {0} - Peso - Preço Total: {1}", volorComanda.Nome, volorComanda.PrecoTotal.ToString("C") + "\n"); } Total += volorComanda.PrecoTotal; lbl_Total.Values.ExtraText = Total.ToString("C"); rtb_MiniRelatorio.Text += ValoresParaMostrar; txt_CodigoProduto.Text = string.Empty; } }