Beispiel #1
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
            }
            else
            {
                if (prod != null)
                {
                    prod.tbCodigoProduto.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    //prod.tbEan13.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                    prod.tbDescProduto.Text      = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                    prod.req_nomeprod            = true;
                    prod.cbxSituacao.Text        = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                    prod.tbDescResumida.Text     = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
                    prod.tbMarcaProduto.Text     = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
                    prod.cbxEmb.Text             = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
                    prod.tbUnidade.Text          = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
                    prod.tbPrecoVenda.Text       = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
                    prod.tbMargemLucro.Text      = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
                    prod.tbEstoqueMinimo.Text    = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
                    prod.tbEstoqueAtual.Text     = dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString();
                    prod.tbCodigoFornecedor.Text = dataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString();
                    prod.req_idforn = true;
                    //Preenche campo fornecedor
                    //-------------------------------------------------------------------------
                    Fornecedor forn = new Fornecedor();
                    forn.IdFornecedor = Convert.ToInt32(prod.tbCodigoFornecedor.Text);
                    forn.LocalizaFornecedor();
                    prod.tbNomeFornecedor.Text = forn.RazaoSocial;
                    prod.lblEstadoEstoque.Text = dataGridView1.Rows[e.RowIndex].Cells[13].Value.ToString();
                    //Preenche campo EAN13
                    //-------------------------------------------------------------------------
                    Produtos pr = new Produtos();
                    pr.LocalizaEan(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
                    prod.tbEan13.Text = pr.Ean;

                    prod.tbPrecoCusto.Text = dataGridView1.Rows[e.RowIndex].Cells[12].Value.ToString();
                    prod.CalcularMargemReal();
                    prod.CalcularPrecoSugerido();

                    prod.butAlterar.Enabled = true;
                    prod.butExcluir.Enabled = true;
                    prod.butEans.Enabled    = true;
                    prod.butNovo.Focus();
                }
                else if (ajuste != null)
                {
                    ajuste.tbCodigo.Text     = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    ajuste.lblDescricao.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                    ajuste.butSalvar.Enabled = true;
                    ajuste.tbQtde.Focus();
                }
                else if (frmven != null)
                {
                    frmven.txtCodProduto.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    frmven.HabiDesaCamposItem(true);
                    frmven.txtQtdeProduto.Focus();
                }
                else if (frmven2 != null)
                {
                    frmven2.txtCodProduto.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    frmven2.txtCodProduto.Focus();
                    frmven2.txtQtdeProduto.Focus();
                }
                this.Dispose();
            }
        }
Beispiel #2
0
        private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                DataGridViewRow linhaAtual = dataGridView1.CurrentRow;
                int             i          = linhaAtual.Index;
                if (prod != null)
                {
                    prod.tbCodigoProduto.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    //prod.tbEan13.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    prod.tbDescProduto.Text      = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    prod.req_nomeprod            = true;
                    prod.cbxSituacao.Text        = dataGridView1.Rows[i].Cells[2].Value.ToString();
                    prod.tbDescResumida.Text     = dataGridView1.Rows[i].Cells[3].Value.ToString();
                    prod.tbMarcaProduto.Text     = dataGridView1.Rows[i].Cells[4].Value.ToString();
                    prod.cbxEmb.Text             = dataGridView1.Rows[i].Cells[5].Value.ToString();
                    prod.tbUnidade.Text          = dataGridView1.Rows[i].Cells[6].Value.ToString();
                    prod.tbPrecoVenda.Text       = dataGridView1.Rows[i].Cells[7].Value.ToString();
                    prod.tbMargemLucro.Text      = dataGridView1.Rows[i].Cells[8].Value.ToString();
                    prod.tbEstoqueMinimo.Text    = dataGridView1.Rows[i].Cells[9].Value.ToString();
                    prod.tbEstoqueAtual.Text     = dataGridView1.Rows[i].Cells[10].Value.ToString();
                    prod.tbCodigoFornecedor.Text = dataGridView1.Rows[i].Cells[11].Value.ToString();
                    prod.req_idforn = true;
                    //Preenche campo fornecedor
                    //-------------------------------------------------------------------------
                    Fornecedor forn = new Fornecedor();
                    forn.IdFornecedor = Convert.ToInt32(prod.tbCodigoFornecedor.Text);
                    forn.LocalizaFornecedor();
                    prod.tbNomeFornecedor.Text = forn.RazaoSocial;
                    //Preenche campo EAN13
                    //-------------------------------------------------------------------------
                    Produtos pr = new Produtos();
                    pr.LocalizaEan(dataGridView1.Rows[i].Cells[0].Value.ToString());
                    prod.tbEan13.Text = pr.Ean;

                    prod.tbPrecoCusto.Text     = dataGridView1.Rows[i].Cells[12].Value.ToString();
                    prod.lblEstadoEstoque.Text = dataGridView1.Rows[i].Cells[13].Value.ToString();
                    prod.CalcularMargemReal();
                    prod.CalcularPrecoSugerido();

                    prod.butAlterar.Enabled = true;
                    prod.butExcluir.Enabled = true;
                    prod.butEans.Enabled    = true;
                    prod.butNovo.Focus();
                }
                else if (ajuste != null)
                {
                    ajuste.tbCodigo.Text     = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    ajuste.lblDescricao.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    ajuste.butSalvar.Enabled = true;
                    ajuste.tbQtde.Focus();
                }
                else if (frmven != null)
                {
                    frmven.txtCodProduto.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    frmven.HabiDesaCamposItem(true);
                    frmven.txtQtdeProduto.Focus();
                }
                else if (frmven2 != null)
                {
                    frmven2.txtCodProduto.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    frmven2.txtCodProduto.Focus();
                    frmven2.txtQtdeProduto.Focus();
                }

                this.Dispose();
            }
            else if (e.KeyCode == Keys.Escape)
            {
                radDescricao.Checked = true;
                txtPesquisa.Clear();
                txtPesquisa.Focus();
                this.CancelButton = butSair;
            }
            else if (e.KeyCode == Keys.F7)
            {
                DataGridViewRow  linhaAtual = dataGridView1.CurrentRow;
                int              i          = linhaAtual.Index;
                FormCadCodBarras barcode    = new FormCadCodBarras();
                barcode.IdProduto         = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value);
                barcode.gpbCodBarras.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
                barcode.MdiParent         = this.ParentForm;
                barcode.Show();
            }
        }