Пример #1
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            frm_Pesquisa.nomeFormulario = nomeFormulario;
            frm_Pesquisa fp = new frm_Pesquisa();

            fp.ShowDialog();
            if (fp.Codigo != null)
            {
                using (IConnection Conexion = new Connection())
                {
                    IDAO <Produto> dao  = new DAOProduto(Conexion);
                    Produto        prod = dao.FindOrDefault(fp.Codigo);
                    txtCodigo.Text = prod.Id.ToString();
                    txtNome.Text   = prod.Nome;
                    txtPreco.Text  = prod.preço.ToString();
                    dgvProduto.Rows.Clear();
                    int renglon = dgvProduto.Rows.Add();
                    dgvProduto.Rows[renglon].Cells["Id"].Value    = prod.Id.ToString();
                    dgvProduto.Rows[renglon].Cells["Nome"].Value  = cultureinfo.TextInfo.ToTitleCase(prod.Nome.ToString().ToLower().Trim());
                    dgvProduto.Rows[renglon].Cells["Preco"].Value = cultureinfo.TextInfo.ToTitleCase(prod.preço.ToString().ToLower().Trim());

                    btnAdd.Visible = false;
                    //btnBuscar.Visible = false;
                    btnSalvar.Visible   = true;
                    btnDelete.Visible   = true;
                    btnCancelar.Visible = true;
                }
            }
        }
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     frm_Pesquisa.nomeFormulario = nomeFormulario;
     frm_Pesquisa fp = new frm_Pesquisa();
     fp.ShowDialog();
     if (fp.Codigo != null)
     {
         using (IConnection Conexion = new Connection())
         {
             IDAO<Cliente> daoCli = new DAOCliente(Conexion);
             Cliente cli = daoCli.FindOrDefault(fp.Codigo);
             txtCodigo.Text = cli.Id.ToString();
             txtNome.Text = cli.Nome;
             txtTelefone.Text = cli.Telefone;
             dgvCliente.Rows.Clear();
             int renglon = dgvCliente.Rows.Add();
             dgvCliente.Rows[renglon].Cells["Id"].Value = cli.Id.ToString();
             dgvCliente.Rows[renglon].Cells["Nome"].Value = cultureinfo.TextInfo.ToTitleCase(cli.Nome.ToString().ToLower().Trim());
             dgvCliente.Rows[renglon].Cells["Telefone"].Value = cultureinfo.TextInfo.ToTitleCase(cli.Telefone.ToString().ToLower().Trim());
       
             btnAdd.Visible = false;
             //btnBuscar.Visible = false;
             btnSalvar.Visible = true;
             btnDelete.Visible = true;
             btnCancelar.Visible = true;
         }
     }
 }
        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;
                }
            }
        }