Exemple #1
0
        private void btnAddLista_Click(object sender, EventArgs e)
        {
            if (txtPreco.Text != " " && txtQuantidade.Text != " " && txtTipo.Text != "" && txtTotal.Text != "" && cmbProduto.Text != " " && cmbCliente.Text != "")
            {
                if (txtTipo.Text == "Pizza" && rbBroto.Checked == false && rbInteira.Checked == false)
                {
                    MessageBox.Show("Os campos devem Broto ou inteira devem ser selecionados !!", MessageBoxButtons.OK.ToString());
                }

                else
                {
                    RecebendoValor();



                    if (txtId.Text != vendas.IdVenda.ToString())
                    {
                        vendas.IdVenda = int.Parse(txtId.Text);
                        vendas.CadastrarVenda();
                        vendas.IdVenda++;
                    }
                    vendas.IdVenda = int.Parse(txtId.Text);

                    if (vendas.CadastrarProdutoVendido() == true)
                    {
                        MessageBox.Show("adicionado ao carrinho!", MessageBoxButtons.OK.ToString());
                    }
                    else
                    {
                        MessageBox.Show("Não há estoque suficiente ao carrinho!", MessageBoxButtons.OK.ToString());
                    }

                    vendas.RetirarEstoque();

                    if (lblTotal.Text != "")
                    {
                        float total = float.Parse(txtTotal.Text);
                        total        += float.Parse(lblTotal.Text);
                        lblTotal.Text = total.ToString();
                    }
                    else
                    {
                        lblTotal.Text = vendas.Total.ToString();
                    }


                    dgvVendas.DataSource = vendas.ListarCarrinho();
                }
            }

            else
            {
                MessageBox.Show("Os campos devem ser preenchidos!!", MessageBoxButtons.OK.ToString());
            }
        }