private void btBuscaProduto_Click(object sender, EventArgs e)
        {
            ClassProduto c = new ClassProduto();
            string       s = txtPesqProduto.Text;

            dgvProduto.DataSource = c.SearchProdNomeV(s);
        }
Beispiel #2
0
        private void btPesq_Click(object sender, EventArgs e)
        {
            ClassProduto cProd = new ClassProduto();

            if (cbTipo.SelectedIndex == -1)
            {
                MessageBox.Show("Selecione um Tipo de pesquisa!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (cbTipo.SelectedIndex == 0 && rdAtiv.Checked == true)
            {
                dgRes.DataSource = cProd.SearchProdStatus();
            }
            if (cbTipo.SelectedIndex == 0 && rdAtiv.Checked == false)
            {
                dgRes.DataSource = cProd.SearchProdStatusIna();
            }
            if (cbTipo.SelectedIndex == 1 && txtPes.Text != "")
            {
                cProd.txtSearch = txtPes.Text; dgRes.DataSource = cProd.SearchProdNome();
            }
            if (cbTipo.SelectedIndex == 3 && cbPlat.SelectedIndex != -1)
            {
                cProd.CodPlatS = Convert.ToInt32(cbPlat.SelectedValue); dgRes.DataSource = cProd.SearchProdPlat();
            }
            if (cbTipo.SelectedIndex == 4 && cbCat.SelectedIndex != -1)
            {
                cProd.CatProdS = Convert.ToInt32(cbCat.SelectedValue); dgRes.DataSource = cProd.SearchProdCat();
            }
            if (cbTipo.SelectedIndex == 5 && txtPes.Text != "")
            {
                dgRes.DataSource = cProd.SearchProdCod(Convert.ToInt32(txtPes.Text));
            }
        }
Beispiel #3
0
        private void btDel_Click(object sender, EventArgs e)
        {
            if (dgRes.SelectedCells.Count > 0)
            {
                ClassProduto cp = new ClassProduto();
                cp.ReturnProd(Convert.ToInt32(dgRes.SelectedRows[0].Cells[0].Value));

                if (MessageBox.Show("Você Deseja Realmente Excluir o Produto'" + cp.NomeProd + "'?", "Alerta!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    int aux = cp.DelProd();

                    if (aux != 0)
                    {
                        MessageBox.Show("O Produto '" + cp.NomeProd + "' foi Excluido com Sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    else
                    {
                        MessageBox.Show("Erro ao realizar Exclusão.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    btPesq_Click(this, new EventArgs());
                }
            }
        }
Beispiel #4
0
        private void btEdit_Click(object sender, EventArgs e)
        {
            if (dgRes.SelectedCells.Count > 0)
            {
                ClassProduto cp = new ClassProduto();
                cp.ReturnProd(Convert.ToInt32(dgRes.SelectedRows[0].Cells[0].Value));
                frmCadastroProduto fp = new frmCadastroProduto();

                fp.txtNome.Text      = cp.NomeProd.ToString();
                fp.txtDataCad.Text   = cp.DataCadProd.ToString();
                fp.txtPreco.Text     = cp.PrecoProd.ToString();
                fp.txtDescricao.Text = cp.DescProd.ToString();
                fp.txtQtde.Text      = cp.QtdeProd.ToString();
                fp.txtCod.Text       = cp.CodProd.ToString();
                fp.UpdatePlat        = cp.CodPlat;
                fp.UpdateCat         = cp.CatProd;

                fp.chkAtivo.Enabled = true;
                if (cp.StatusProd == 1)
                {
                    fp.chkAtivo.Checked = true;
                }
                else
                {
                    fp.chkAtivo.Checked = false;
                }

                fp.btCad.Visible = false;
                fp.btAtt.Visible = true;
                fp.ShowDialog();
                btPesq_Click(this, new EventArgs());
            }
        }
        private void AttQtde(int qtde, int cod)
        {
            ClassProduto cp = new ClassProduto();

            cp.VProdFill(cod);
            int e = cp.QtdeProd;

            cp.VProdUpdate(e - qtde, cod);
        }
        private void btAtt_Click(object sender, EventArgs e)
        {
            if (txtNome.Text != "" && txtQtde.Text != "" && CbPlat.TabIndex != -1)
            {
                ClassConexao cCon  = new ClassConexao();
                ClassProduto cProd = new ClassProduto();

                decimal Preco;
                int     Qtde = Convert.ToInt32(txtQtde.Text);

                if (txtPreco.Text != "")
                {
                    Preco = Convert.ToDecimal(txtPreco.Text);
                }
                else
                {
                    Preco = 0;
                }


                if (chkAtivo.Checked == false)
                {
                    cProd.StatusProd = 0;
                }
                else
                {
                    cProd.StatusProd = 1;
                }

                cProd.CodProd   = Convert.ToInt32(txtCod.Text);
                cProd.NomeProd  = txtNome.Text;
                cProd.PrecoProd = Preco;
                cProd.DescProd  = txtDescricao.Text;
                cProd.QtdeProd  = Qtde;
                cProd.CodPlat   = Convert.ToInt32(CbPlat.SelectedValue);
                cProd.CatProd   = Convert.ToInt32(CbCat.SelectedValue);

                int aux = cProd.AttProd();

                if (aux != 0)
                {
                    MessageBox.Show("O produto '" + cProd.NomeProd + "' foi Atualizado com Sucesso!");
                    this.Close();
                }

                else
                {
                    MessageBox.Show("Erro ao Realizar Atualização!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Verificar Campos!", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void dgvProduto_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            ClassProduto cp = new ClassProduto();

            bool a = cp.VProdFill((int)dgvProduto.SelectedRows[0].Cells[0].Value);

            if (a)
            {
                int  Estq, Qtde;
                bool tem = lstCarrinho.Any(c => c.Produto == (int)dgvProduto.SelectedRows[0].Cells[0].Value);

                if (tem)
                {
                    int linha = -1;

                    foreach (DataGridViewRow row in dgvItens.Rows)
                    {
                        if (row.Cells[0].Value.ToString().Equals(dgvProduto.SelectedRows[0].Cells[0].Value.ToString()))
                        {
                            linha = row.Index;
                            break;
                        }
                    }
                    Estq = cp.QtdeProd - Convert.ToInt32(dgvItens.Rows[linha].Cells[2].Value);
                    if (Estq == 0)
                    {
                        Qtde = 0;
                    }
                    else
                    {
                        Qtde = 1;
                    }
                }

                else
                {
                    Estq = cp.QtdeProd;
                    Qtde = 1;
                }


                txtProduto.Text = cp.NomeProd;
                txtEstoque.Text = Estq.ToString();
                txtValor.Text   = cp.PrecoProd.ToString("n2");
                txtQtde.Text    = Qtde.ToString();
                txtQtde.Select();
                txtQtde_TextChanged(this, new EventArgs());

                CodLastProd = cp.CodProd;
                QtdeN       = 0;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtNome.Text != "" && txtQtde.Text != "" && CbPlat.TabIndex != 1 && CbCat.SelectedIndex != -1)
            {
                ClassConexao cCon  = new ClassConexao();
                ClassProduto cProd = new ClassProduto();

                decimal Preco;
                int     Qtde = Convert.ToInt32(txtQtde.Text);

                if (txtPreco.Text != "")
                {
                    Preco = Convert.ToDecimal(txtPreco.Text);
                }
                else
                {
                    Preco = 0;
                }

                cProd.NomeProd   = txtNome.Text;
                cProd.PrecoProd  = Preco;
                cProd.DescProd   = txtDescricao.Text;
                cProd.QtdeProd   = Qtde;
                cProd.StatusProd = 1;
                cProd.CodPlat    = Convert.ToInt32(CbPlat.SelectedValue);
                cProd.CatProd    = Convert.ToInt32(CbCat.SelectedValue);

                int aux = cProd.CadastrarProduto();

                if (aux != 0)
                {
                    MessageBox.Show("O Produto '" + cProd.NomeProd + "' foi cadastrado com sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                else
                {
                    MessageBox.Show("Erro ao Realizar Cadastro.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Verificar Campos!", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtNome.BackColor  = Color.DarkRed;
                txtQtde.BackColor  = Color.DarkRed;
                txtPreco.BackColor = Color.DarkRed;
            }
        }
        private void AttGrid()
        {
            ClassProduto cp = new ClassProduto();
            DataTable    dt = new DataTable();

            dt.Columns.Add(new DataColumn("Código"));
            dt.Columns.Add(new DataColumn("Produto"));
            dt.Columns.Add(new DataColumn("Qtde."));
            dt.Columns.Add(new DataColumn("Preço"));

            foreach (ClassCarrinho item in lstCarrinho)
            {
                if (item.Produto == CodLastProd && QtdeN != 0)
                {
                    item.Qtde = QtdeN;
                }
                dt.Rows.Add(item.Produto, cp.VProdNome(item.Produto), item.Qtde, item.Valor);
                dt.AcceptChanges();
            }
            dgvItens.DataSource = dt;
        }