コード例 #1
0
        private void btnInserir_Click(object sender, EventArgs e)
        {
            btnInserir.Enabled    = false;
            btnAlterar.Enabled    = false;
            btnExcluir.Enabled    = false;
            btnGravar.Enabled     = true;
            btnCancelar.Enabled   = true;
            txtNome.Enabled       = true;
            txtFornecedor.Enabled = true;
            txtPreco.Enabled      = true;
            txtQtd.Enabled        = true;
            produtoTableAdapter taProduto = new produtoTableAdapter();
            string novoID;
            int    valorID;

            try
            {
                novoID = taProduto.UltimoID().ToString();

                if (int.TryParse(novoID.ToString(), out valorID))
                {
                    txtID.Text = (valorID + 1).ToString();
                }
                else
                {
                    MessageBox.Show("ID com valor errado. Tente novamente.");
                }
            }
            catch
            {
                txtID.Text = "1";
            }
        }
コード例 #2
0
        public frmCadastroProduto()
        {
            InitializeComponent();
            txtID.Enabled = true;
            btnOK.Enabled = false;
            produtoTableAdapter taProduto = new produtoTableAdapter();

            string novoID;
            int    valorID;

            try
            {
                novoID = taProduto.UltimoID().ToString();

                if (int.TryParse(novoID.ToString(), out valorID))
                {
                    txtID.Text = (valorID + 1).ToString();
                }
                else
                {
                    MessageBox.Show("ID com valor errado. Tente novamente.");
                }
            }
            catch
            {
                txtID.Text = "1";
            }
            txtNome.Enabled       = false;
            txtPreco.Enabled      = false;
            txtQtd.Enabled        = false;
            txtFornecedor.Enabled = false;
        }
コード例 #3
0
ファイル: frmVenda.cs プロジェクト: GlauciaLS/Adega
        private void btnInserir_Click(object sender, EventArgs e)
        {
            try { int quantidade = int.Parse(txtQtd.Text);
                  int estoque    = int.Parse(txtEstoque.Text);
                  if (quantidade <= estoque)
                  {
                      string descricao = txtDescricaoProdutos.Text;
                      string preco     = txtPreco.Text;
                      preco = preco.Replace("R$", "");

                      string desconto = txtDesconto.Text;
                      desconto = desconto.Replace("R$", "");

                      double precoComDesconto = Convert.ToDouble(preco) - Convert.ToDouble(desconto);
                      double subtotal         = precoComDesconto * Convert.ToDouble(txtQtd.Text);



                      dgvProdutos.Rows.Add(txtCodigo.Text, txtProduto.Text, txtQtd.Text, txtPreco.Text, txtDesconto.Text, subtotal);
                      {
                          decimal total = 0;
                          int     i     = 0;
                          for (i = 0; i < dgvProdutos.Rows.Count; i++)
                          {
                              total = total + Convert.ToDecimal(dgvProdutos.Rows[i].Cells["Subtotal"].Value);
                          }
                          txtTotal.Text = "R$" + (total).ToString();

                          string novoEstoque            = (Convert.ToDecimal(txtEstoque.Text) - Convert.ToDecimal(txtQtd.Text)).ToString();
                          produtoTableAdapter taProduto = new produtoTableAdapter();
                          taProduto.UpdateEstoque(novoEstoque, txtCodigo.Text);
                          string produtoNovo = txtProduto.Text;

                          if (txtDescricaoProdutos.Text != "")
                          {
                              txtDescricaoProdutos.Text = descricao + ", " + txtProduto.Text;
                          }
                          else if (txtDescricaoProdutos.Text == "")
                          {
                              txtDescricaoProdutos.Text = txtProduto.Text;
                          }
                      }

                      txtQtd.Text      = "";
                      txtPreco.Text    = "";
                      txtProduto.Text  = "";
                      txtCodigo.Text   = "";
                      txtEstoque.Text  = "";
                      txtDesconto.Text = "R$0";
                  }
                  else
                  {
                      MessageBox.Show("A quantidade ultrapassa o estoque.");
                  } }
            catch
            {
                MessageBox.Show("Favor completar os espaços em branco.");
            }
        }
コード例 #4
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            txtNome.Enabled       = true;
            txtPreco.Enabled      = true;
            txtQtd.Enabled        = true;
            txtID.Enabled         = true;
            txtFornecedor.Enabled = true;

            produtoTableAdapter taProduto = new produtoTableAdapter();

            DataTable dtPessoa;

            dtPessoa = taProduto.PesquisaProduto(txtID.Text);

            if (dtPessoa.Rows.Count == 0)
            {
                MessageBox.Show("Produto não cadastrado.");
                txtNome.Enabled  = false;
                txtPreco.Enabled = false;
                txtQtd.Enabled   = false;

                txtFornecedor.Enabled = false;
                txtID.Enabled         = true;
            }
            else
            {
                txtID.Text         = dtPessoa.Rows[0]["codProduto"].ToString();
                txtNome.Text       = dtPessoa.Rows[0]["nomeProduto"].ToString();
                txtQtd.Text        = dtPessoa.Rows[0]["qtdProduto"].ToString();
                txtPreco.Text      = dtPessoa.Rows[0]["precoProduto"].ToString();
                txtFornecedor.Text = dtPessoa.Rows[0]["fornecedorProduto"].ToString();

                txtNome.Enabled       = true;
                txtPreco.Enabled      = true;
                txtQtd.Enabled        = true;
                txtID.Enabled         = true;
                txtFornecedor.Enabled = true;
                btnGravar.Enabled     = true;
                btnCancelar.Enabled   = true;
                btnInserir.Enabled    = false;
                btnAlterar.Enabled    = false;
                btnExcluir.Enabled    = false;
                btnOK.Enabled         = true;
                btnGravar.Text        = "Confirmar";
            }
        }
コード例 #5
0
ファイル: frmVenda.cs プロジェクト: GlauciaLS/Adega
        private void btnPesquisaCodigo_Click(object sender, EventArgs e)
        {
            if (txtProduto.Text == "")
            {
                produtoTableAdapter taProduto = new produtoTableAdapter();

                DataTable dtProduto;
                dtProduto = taProduto.PesquisaProduto(txtCodigo.Text);

                if (dtProduto.Rows.Count == 0)
                {
                    MessageBox.Show("Produto não encontrado. Verifique se o mesmo foi cadastrado ou digitado corretamente.");
                }
                else
                {
                    txtCodigo.Text  = dtProduto.Rows[0]["codProduto"].ToString();
                    txtProduto.Text = dtProduto.Rows[0]["nomeProduto"].ToString();
                    txtEstoque.Text = dtProduto.Rows[0]["qtdProduto"].ToString();
                    txtPreco.Text   = dtProduto.Rows[0]["precoProduto"].ToString();
                }
            }
            else if (txtCodigo.Text == "")
            {
                produtoTableAdapter taProduto = new produtoTableAdapter();

                DataTable dtProduto;
                dtProduto = taProduto.PesquisaPorNomeProduto(txtProduto.Text);

                if (dtProduto.Rows.Count == 0)
                {
                    MessageBox.Show("Produto não encontrado. Verifique se o mesmo foi cadastrado ou digitado corretamente.");
                }
                else
                {
                    txtCodigo.Text  = dtProduto.Rows[0]["codProduto"].ToString();
                    txtProduto.Text = dtProduto.Rows[0]["nomeProduto"].ToString();
                    txtEstoque.Text = dtProduto.Rows[0]["qtdProduto"].ToString();
                    txtPreco.Text   = dtProduto.Rows[0]["precoProduto"].ToString();
                }
            }
        }
コード例 #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Confirma alteração?", "Alterando...", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                produtoTableAdapter taProduto = new produtoTableAdapter();
                taProduto.UpdateQuery(txtID.Text, txtNome.Text, txtQtd.Text, txtPreco.Text, txtFornecedor.Text, txtID.Text);
                Limpar_Caixas();
                txtID.Enabled         = true;
                txtNome.Enabled       = false;
                txtPreco.Enabled      = false;
                txtQtd.Enabled        = false;
                txtFornecedor.Enabled = false;
                btnInserir.Enabled    = true;
                btnExcluir.Enabled    = true;
                btnAlterar.Enabled    = true;
                btnCancelar.Enabled   = false;
                btnOK.Enabled         = false;
                string novoID;
                int    valorID;
                try
                {
                    novoID = taProduto.UltimoID().ToString();

                    if (int.TryParse(novoID.ToString(), out valorID))
                    {
                        txtID.Text = (valorID + 1).ToString();
                    }
                    else
                    {
                        MessageBox.Show("ID com valor errado. Tente novamente.");
                    }
                }
                catch
                {
                    txtID.Text = "1";
                }
            }
        }
コード例 #7
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            txtNome.Enabled       = true;
            txtPreco.Enabled      = true;
            lblWUad.Enabled       = true;
            txtID.Enabled         = true;
            txtFornecedor.Enabled = true;

            produtoTableAdapter taProduto = new produtoTableAdapter();

            DataTable dtPessoa;

            dtPessoa = taProduto.PesquisaProduto(txtID.Text);

            if (dtPessoa.Rows.Count == 0)
            {
                MessageBox.Show("Produto não cadastrado.");
                txtNome.Enabled  = false;
                txtPreco.Enabled = false;
                lblWUad.Enabled  = false;

                txtFornecedor.Enabled = false;
                txtID.Enabled         = true;
            }
            else
            {
                txtID.Text         = dtPessoa.Rows[0]["codProduto"].ToString();
                txtNome.Text       = dtPessoa.Rows[0]["nomeProduto"].ToString();
                txtQtd.Text        = dtPessoa.Rows[0]["qtdProduto"].ToString();
                txtPreco.Text      = dtPessoa.Rows[0]["precoProduto"].ToString();
                txtFornecedor.Text = dtPessoa.Rows[0]["fornecedorProduto"].ToString();


                txtNome.Enabled       = true;
                txtPreco.Enabled      = true;
                txtQtd.Enabled        = true;
                txtID.Enabled         = true;
                txtFornecedor.Enabled = true;

                if (MessageBox.Show("Confirma exclusão?", "Excluindo...", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    taProduto.DeleteQuery(txtID.Text);
                    Limpar_Caixas();
                    txtNome.Enabled       = false;
                    txtPreco.Enabled      = false;
                    txtQtd.Enabled        = false;
                    txtID.Enabled         = true;
                    txtFornecedor.Enabled = false;
                    string novoID;
                    int    valorID;
                    txtNome.Text        = "";
                    txtPreco.Text       = "R$";
                    txtQtd.Text         = "";
                    txtFornecedor.Text  = "";
                    btnCancelar.Enabled = false;
                    MessageBox.Show("Excluído com sucesso.");
                    try
                    {
                        novoID = taProduto.UltimoID().ToString();

                        if (int.TryParse(novoID.ToString(), out valorID))
                        {
                            txtID.Text = (valorID + 1).ToString();
                        }
                        else
                        {
                            MessageBox.Show("ID com valor errado. Tente novamente.");
                        }
                    }
                    catch
                    {
                        txtID.Text = "1";
                    }
                }
                else
                {
                    btnCancelar.Enabled   = true;
                    txtNome.Enabled       = false;
                    txtPreco.Enabled      = false;
                    txtQtd.Enabled        = false;
                    txtFornecedor.Enabled = false;
                    txtNome.Text          = "";
                    txtPreco.Text         = "R$";
                    txtQtd.Text           = "";
                    txtFornecedor.Text    = "";
                }
            }
        }