Esempio n. 1
0
        private void btnEditaProduto_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtQtdProd.Text != "" && int.Parse(txtQtdProd.Text) != 0)
                {
                    ClassItensOrcamento o = new ClassItensOrcamento();
                    o.PRODUTOSID = int.Parse(txtIdProd.Text);
                    o.ORCAMENTOID = int.Parse(txtIdOrcamento.Text);
                    o.QUANTIDADE = int.Parse(txtQtdProd.Text);
                    o.AlterarQuantidade();

                    dtgVenda.DataSource = o.ListaItens();
                }
                else
                {
                    MessageBox.Show("O campo quantidade não pode ser nulo/vazio !");
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void btnExcluirProduto_Click(object sender, EventArgs e)
        {
            try
            {
                ClassItensOrcamento o = new ClassItensOrcamento();
                o.PRODUTOSID = int.Parse(txtIdProd.Text);
                o.ORCAMENTOID = int.Parse(txtIdOrcamento.Text);
                o.QUANTIDADE = int.Parse(txtQtdProd.Text);
                o.ExcluirProdutoItem();

                dtgVenda.DataSource = o.ListaItens();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnPesID_Click(object sender, EventArgs e)
        {
            try
            {
                ClassItensOrcamento o = new ClassItensOrcamento();
                o.ORCAMENTOID = int.Parse(txtIdOrcamento.Text);
                DataTable dt = o.ListaItens();
                if (dt.Rows.Count != 0)
                {
                    dtgItensOr.DataSource = o.ListaItens();
                }
                else
                {
                    MessageBox.Show("Não existem itens para o orçamento solicitado !");
                    txtIdOrcamento.Focus();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 4
0
        private void btnIncluir_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtCliente.Text != "")
                {
                    if (txtIdKit.Text != "")
                    {
                        if (txtQtd.Text != "")
                        {
                            ClassOrcamento o = new ClassOrcamento();
                            if (txtIdOrcamento.Text == "")
                            {
                                o.CLIENTE = txtCliente.Text;
                                string dateTime = DateTime.Now.ToString();
                                string d = Convert.ToDateTime(dateTime).ToString("yyyy-MM-dd");
                                o.DATA = d;
                                o.NovoOrcamento();
                                DataTable numero = o.NumeroOrcamento();
                                txtIdOrcamento.Text = numero.Rows[0].ItemArray[0].ToString();
                                txtCliente.Enabled = false;
                            }

                            ClassItensKit i = new ClassItensKit();
                            i.KITID = int.Parse(txtIdKit.Text);
                            DataTable retorna = i.RetornoProdutos();
                            ClassItensOrcamento itensO = new ClassItensOrcamento();
                            for (int c = 0; c < retorna.Rows.Count; c++)
                            {
                                int a = int.Parse(retorna.Rows[c].ItemArray[0].ToString());

                                bool venda = false;
                                int produto = 0;

                                if (dtgVenda.RowCount != 0)
                                {
                                    for (int r = 0; r < dtgVenda.RowCount; r++)
                                    {
                                        int b = int.Parse(dtgVenda.Rows[r].Cells[1].Value.ToString());
                                        if (a == b)
                                        {
                                            produto = a;
                                            venda = true;
                                            break;
                                        }
                                    }
                                }

                                itensO.ORCAMENTOID = int.Parse(txtIdOrcamento.Text);

                                if (venda)
                                {
                                    itensO.PRODUTOSID = produto;
                                    itensO.QUANTIDADE = int.Parse(retorna.Rows[c].ItemArray[1].ToString()) * int.Parse(txtQtd.Text);
                                    itensO.AlterarProduto();

                                }
                                else
                                {
                                    itensO.PRODUTOSID = int.Parse(retorna.Rows[c].ItemArray[0].ToString());
                                    itensO.QUANTIDADE = int.Parse(retorna.Rows[c].ItemArray[1].ToString()) * int.Parse(txtQtd.Text);

                                    itensO.NovosItens();
                                }

                            }

                            dtgVenda.DataSource = itensO.ListaItens();
                            txtIdKit.Text = "";
                            txtNome.Text = "";
                            txtQtd.Text = "";
                            o.IDORCAMENTO = int.Parse(txtIdOrcamento.Text);

                            double t = 0;

                            for (int v = 0; v < dtgVenda.RowCount - 1; v++)
                            {
                                t += double.Parse(dtgVenda.Rows[v].Cells[4].Value.ToString());
                            }

                            txtTotal.Text = t.ToString();
                        }
                        else
                        {
                            MessageBox.Show("Digite a quantidade antes de incluir !");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Importe um kit antes de prosseguir !");
                    }
                }
                else {
                    MessageBox.Show("Digite o nome do cliente para prosseguir !"); }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void btnPesquisar_Click(object sender, EventArgs e)
 {
     try
     {
         ClassOrcamento o = new ClassOrcamento();
         ClassItensOrcamento i = new ClassItensOrcamento();
         switch (cmbCampos.Text)
         {
             case "Nome Cliente":
                 o.CLIENTE = txtPesquisa.Text;
                 dtgOrcamento.DataSource = o.ListaCliente();
                 break;
             case"Data":
                 o.DATA = datePesquisa.Value.ToString("yyyy-MM-dd");
                 dtgOrcamento.DataSource = o.ListaData();
                 break;
             default:
                 MessageBox.Show("Escolha uma opção válida !");
                 cmbCampos.Text = "Selecione...";
                 break;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void dtgOrcamento_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                txtIdOrcamento.Text = dtgOrcamento.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtCliente.Text = dtgOrcamento.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtData.Text = dtgOrcamento.Rows[e.RowIndex].Cells[2].Value.ToString();
                ClassItensOrcamento i = new ClassItensOrcamento();
                i.ORCAMENTOID = int.Parse(txtIdOrcamento.Text);
                dtgItensOr.DataSource = i.ListaItens();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }