Ejemplo n.º 1
0
        private void btnAddProduto_Click(object sender, EventArgs e)
        {
            try
            {
                frmAdicionarProduto frm = new frmAdicionarProduto();
                frm.ShowDialog();

                if (frm.ItemSelecionado != null)
                {
                    DTOPedidoItem dados = frm.ItemSelecionado;
                    produtosItens.Add(dados);

                    lstProdutos.Items.Add("NOME: " + dados.NomeProduto + "  R$: " + dados.ValorProduto + "  QNT: " + dados.Quantidade);


                    lblPrecoTotal.Text = lblPrecoTotal.Text == "PREÇO TOTAL" ? "0" : lblPrecoTotal.Text;
                    lblPrecoTotal.Text = (Convert.ToDecimal(lblPrecoTotal.Text) + dados.ValorProduto * dados.Quantidade).ToString();
                }

                if (lstProdutos.Items.Count > 1)
                {
                    lstProdutos.SelectedIndex = 0;
                }
            }

            catch
            {
                MessageBox.Show("OCORREU UM ERRO!", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void btnAddProduto_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtProduto.Text.Length >= 3)
                {
                    DTOPedidoItem produto = new DTOPedidoItem();
                    produto.NomeProduto  = txtProduto.Text;
                    produto.Quantidade   = Convert.ToInt32(nudQuantidade.Value);
                    produto.ValorProduto = nudPreco.Value;

                    this.ItemSelecionado = produto;

                    this.Close();
                }
                else
                {
                    MessageBox.Show("INSIRA PELO MENOS 3 CARACTERES NO NOME DO PRODUTO.", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch
            {
                MessageBox.Show("OCORREU UM ERRO!", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }