private void btnBuscar_Click(object sender, EventArgs e)
        {
            frm_Pesquisa.nomeFormulario = nomeFormulario;
            frm_Pesquisa fp = new frm_Pesquisa();

            fp.ShowDialog();
            if (fp.Codigo != null)
            {
                edit = true;
                btnUpdate.Visible   = true;
                btnCancelar.Visible = true;
                lstOD.Clear();
                cboCliente.Enabled = false;

                using (IConnection Conexion = new Connection())
                {
                    dgvOrcamento.Rows.Clear();
                    //Pesquisa Orçamento Cabeceira
                    IDAO <OrcCab> dao = new DAOOrcCab(Conexion);
                    OrcCab        oc  = dao.FindOrDefault(fp.Codigo);
                    if (oc != null)
                    {
                        txtCodigo.Text           = oc.Nro.ToString();
                        cboCliente.SelectedValue = oc.IdCliente.ToString();
                        txtData.Text             = oc.Data.ToString();
                    }
                    //Pesquisa Orçamento Detalhe
                    IDAO <OrcDet> dod = new DAOOrcDet(Conexion);
                    foreach (OrcDet od in dod.All())
                    {
                        if (oc.Nro == od.Nro)
                        {
                            int renglon = dgvOrcamento.Rows.Add();
                            dgvOrcamento.Rows[renglon].Cells["Id"].Value        = od.Nro.ToString();
                            dgvOrcamento.Rows[renglon].Cells["IdProduto"].Value = od.IdProduto.ToString();
                            dgvOrcamento.Rows[renglon].Cells["PUnit"].Value     = od.PUnit.ToString();
                            dgvOrcamento.Rows[renglon].Cells["Qtd"].Value       = od.Qtd.ToString();
                            dgvOrcamento.Rows[renglon].Cells["Total"].Value     = od.Total.ToString();
                        }
                    }
                    btnAdd.Visible    = true;
                    btnUpdate.Visible = false;
                    //btnBuscar.Visible = false;
                    btnSalvar.Visible   = false;
                    btnDelete.Visible   = false;
                    btnCancelar.Visible = true;
                    btnDelOrc.Visible   = true;
                }
            }
        }
 private void btnDelOrc_Click(object sender, EventArgs e)
 {
     using (IConnection Conexion = new Connection())
     {
         IDAO <OrcCab> dao = new DAOOrcCab(Conexion);
         OrcCab        oc  = dao.FindOrDefault(txtCodigo.Text);
         if (oc != null)
         {
             dao.Delete(oc);
         }
     }
     DefaultObjetos();
     cboCliente.Enabled = true;
 }
Beispiel #3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtCodigo.Text == "")
            {
                mensagemInfoExibir("Informe o código para pesquisar!", "Pesquisa");
                txtCodigo.Focus();
                return;
            }
            if (nomeFormulario == "frmCliente")
            {
                using (IConnection Conexion = new Connection())
                {
                    IDAO <Cliente> daoCli = new DAOCliente(Conexion);
                    Cliente        cli    = daoCli.FindOrDefault(txtCodigo.Text);
                    if (cli != null)
                    {
                        dgvSearch.Rows.Clear();
                        int renglon = dgvSearch.Rows.Add();
                        dgvSearch.Rows[renglon].Cells["Id"].Value   = cli.Id.ToString();
                        dgvSearch.Rows[renglon].Cells["Nome"].Value = cli.Nome.ToString();
                    }
                    else
                    {
                        mensagemInfoExibir("Codigo não existe!", "Pesquisa");
                        txtCodigo.Focus();
                    }
                }
            }

            if (nomeFormulario == "frmProduto")
            {
                using (IConnection Conexion = new Connection())
                {
                    IDAO <Produto> daoProd = new DAOProduto(Conexion);
                    Produto        prod    = daoProd.FindOrDefault(txtCodigo.Text);
                    if (prod != null)
                    {
                        dgvSearch.Rows.Clear();
                        int renglon = dgvSearch.Rows.Add();
                        dgvSearch.Rows[renglon].Cells["Id"].Value   = prod.Id.ToString();
                        dgvSearch.Rows[renglon].Cells["Nome"].Value = prod.Nome.ToString();
                    }
                    else
                    {
                        mensagemInfoExibir("Codigo não existe!", "Pesquisa");
                        txtCodigo.Focus();
                    }
                }
            }

            if (nomeFormulario == "frmOrcamento")
            {
                using (IConnection Conexion = new Connection())
                {
                    IDAO <OrcCab> dao = new DAOOrcCab(Conexion);
                    OrcCab        oc  = dao.FindOrDefault(txtCodigo.Text);
                    if (oc != null)
                    {
                        dgvSearch.Rows.Clear();
                        int renglon = dgvSearch.Rows.Add();
                        dgvSearch.Rows[renglon].Cells["Id"].Value   = oc.Nro.ToString();
                        dgvSearch.Rows[renglon].Cells["Data"].Value = oc.Data.ToString();
                    }
                    else
                    {
                        mensagemInfoExibir("Codigo não existe!", "Pesquisa");
                        txtCodigo.Focus();
                    }
                }
            }
        }