Exemplo n.º 1
0
        public frmVenda()
        {
            InitializeComponent();
            VendasTableAdapter taVenda = new VendasTableAdapter();
            string             novoCodigo;
            int valorCodigo;

            txtDesconto.Text = "R$0";
            try
            {
                novoCodigo = taVenda.UltimoID().ToString();

                if (int.TryParse(novoCodigo.ToString(), out valorCodigo))
                {
                    txtCodVenda.Text = (valorCodigo + 1).ToString();
                }
                else
                {
                    MessageBox.Show("Código com valor errado. Tente novamente.");
                }
            }
            catch
            {
                txtCodVenda.Text = "1";
            }
        }
Exemplo n.º 2
0
        private void btnVenda_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja adicionar ao valor de débito?", "Adicionando...", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                pessoasTableAdapter taPessoa = new pessoasTableAdapter();

                DataTable dtPessoa;
                taPessoa.UpdateQuery1(txtTotal.Text, txtID.Text);
                MessageBox.Show("Operação realizada com sucesso!");

                string data     = DateTime.Now.ToString();
                string produtos = txtDescricaoProdutos.Text;

                VendasTableAdapter taVenda = new VendasTableAdapter();
                taVenda.Insert(txtCodVenda.Text, txtTotal.Text, txtID.Text, produtos, data);

                string novoCodigo;
                int    valorCodigo;

                try
                {
                    novoCodigo = taVenda.UltimoID().ToString();

                    if (int.TryParse(novoCodigo.ToString(), out valorCodigo))
                    {
                        txtCodVenda.Text = (valorCodigo + 1).ToString();
                    }
                    else
                    {
                        MessageBox.Show("Código com valor errado. Tente novamente.");
                    }
                }
                catch
                {
                    txtCodVenda.Text = "1";
                }
            }
            else
            {
                VendasTableAdapter taVenda  = new VendasTableAdapter();
                string             data     = DateTime.Now.ToString();
                string             produtos = txtDescricaoProdutos.Text;


                taVenda.Insert(txtCodVenda.Text, txtTotal.Text, txtID.Text, produtos, data);

                string novoCodigo;
                int    valorCodigo;

                try
                {
                    novoCodigo = taVenda.UltimoID().ToString();

                    if (int.TryParse(novoCodigo.ToString(), out valorCodigo))
                    {
                        txtCodVenda.Text = (valorCodigo + 1).ToString();
                    }
                    else
                    {
                        MessageBox.Show("Código com valor errado. Tente novamente.");
                    }
                }
                catch
                {
                    txtCodVenda.Text = "1";
                }



                MessageBox.Show("Venda realizada com sucesso.");
            }

            txtDescricaoProdutos.Text = "";
            txtTotal.Text             = "";
            txtCliente.Text           = "";
            txtID.Text                = "";
            txtAtualFiado.Text        = "";
            txtDesconto.Text          = "R$0";
            txtDescricaoProdutos.Text = "";
            dgvProdutos.Rows.Clear();
        }