コード例 #1
0
 private void buscaOrcCompleto()
 {
     if ((bsOrcamento.Current as TRegistro_Orcamento) != null)
     {
         (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto =
             TCN_OrcProjeto.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                   (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                   (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                   string.Empty,
                                   string.Empty,
                                   null);
         (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.ForEach(p =>
         {
             p.lFicha =
                 TCN_FichaTec.Buscar(p.Cd_empresa,
                                     p.Id_orcamentostr,
                                     p.Nr_versaostr,
                                     p.Id_projetostr,
                                     p.Id_registrostr,
                                     string.Empty,
                                     null);
         });
         //Buscar Despesas
         (bsOrcamento.Current as TRegistro_Orcamento).lDespesas =
             TCN_Despesas.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                 (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                 (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                 string.Empty,
                                 string.Empty,
                                 null);
         //Buscar Tarefas
         (bsOrcamento.Current as TRegistro_Orcamento).lTarefas =
             TCN_Tarefas.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                null);
         //Buscar mao obra
         (bsOrcamento.Current as TRegistro_Orcamento).lMaoObra =
             TCN_CadMaoObra.Busca(
                 (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                 (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                 (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                 string.Empty,
                 null);
         //Buscar encargos
         (bsOrcamento.Current as TRegistro_Orcamento).lOEncargo =
             TCN_OrcamentoEncargo.Buscar(
                 string.Empty,
                 (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                 (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                 (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                 null);
     }
 }
コード例 #2
0
        private void bsOrcamento_PositionChanged(object sender, EventArgs e)
        {
            if (bsOrcamento.Current != null)
            {
                //Buscar Projetos
                (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto =
                    TCN_OrcProjeto.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                          (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                          (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                          string.Empty,
                                          string.Empty,
                                          null);
                bsOrcamento.ResetCurrentItem();

                //if (!(string.IsNullOrEmpty((bsOrcamento.Current as TRegistro_Orcamento).nr_lanctofiscal)))
                //{
                //    bsNotaFiscal.DataSource =
                //                new CamadaDados.Faturamento.NotaFiscal.TCD_LanFaturamento().Select(
                //                    new TpBusca[]
                //                {
                //                    new TpBusca()
                //                    {
                //                        vNM_Campo = string.Empty,
                //                        vOperador = "exists",
                //                        vVL_Busca = "(select 1 from tb_fat_pedido x "+
                //                                    "where x.Nr_Pedido = a.nr_pedido "+
                //                                    "and x.nr_pedido = "+(bsOrcamento.Current as TRegistro_Orcamento).nr_lanctofiscal.ToString()+")"
                //                    }
                //                }, 0, string.Empty);
                //    bsNotaFiscal.ResetCurrentItem();

                //}

                if (bsProjeto.Current != null)
                {
                    (bsProjeto.Current as TRegistro_OrcProjeto).lFicha =
                        TCN_FichaTec.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                            (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                            (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                            string.Empty,
                                            string.Empty,
                                            string.Empty,
                                            null);
                }
                bsItens.ResetCurrentItem();
            }
            else
            {
                MessageBox.Show("Selecione um Projeto!", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #3
0
        private void bsOrcamento_PositionChanged(object sender, EventArgs e)
        {
            if (bsOrcamento.Current != null)
            { //Buscar Atividades
                (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto =
                    TCN_OrcProjeto.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                          (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                          (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                          string.Empty,
                                          string.Empty,
                                          null);
                //Buscar Despesas
                (bsOrcamento.Current as TRegistro_Orcamento).lDespesas =
                    TCN_Despesas.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                        (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                        (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                        string.Empty,
                                        string.Empty,
                                        null);
                //Buscar Tarefas
                (bsOrcamento.Current as TRegistro_Orcamento).lTarefas =
                    TCN_Tarefas.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                       (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                       (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                       null);
                //Buscar mao obra
                (bsOrcamento.Current as TRegistro_Orcamento).lMaoObra =
                    TCN_CadMaoObra.Busca(
                        (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                        (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                        (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                        string.Empty,
                        null);
                (bsOrcamento.Current as TRegistro_Orcamento).lOEncargo =
                    TCN_OrcamentoEncargo.Buscar(string.Empty,
                                                (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                                (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                                (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr, null);
                calculaEncargos();



                bsOrcamento.ResetCurrentItem();
                bsAtividade_PositionChanged(this, new EventArgs());
            }
        }
コード例 #4
0
        public static string Excluir(TRegistro_Orcamento val, BancoDados.TObjetoBanco banco)
        {
            bool             st_transacao = false;
            TCD_CadFatDireto qtb_orc      = new TCD_CadFatDireto();

            try
            {
                if (banco == null)
                {
                    st_transacao = qtb_orc.CriarBanco_Dados(true);
                }
                else
                {
                    qtb_orc.Banco_Dados = banco;
                }
                //Excluir despesas
                val.lDespesas.ForEach(p => TCN_Despesas.Excluir(p, qtb_orc.Banco_Dados));
                val.lDespesasDel.ForEach(p => TCN_Despesas.Excluir(p, qtb_orc.Banco_Dados));
                //Excluir Projetos
                val.lOrcProjeto.ForEach(p => TCN_OrcProjeto.Excluir(p, qtb_orc.Banco_Dados));
                val.lOrcProjetoDel.ForEach(p => TCN_OrcProjeto.Excluir(p, qtb_orc.Banco_Dados));
                //Excluir Orcamento
                // qtb_orc.Excluir(val);
                if (st_transacao)
                {
                    qtb_orc.Banco_Dados.Commit_Tran();
                }
                return("OK");
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    qtb_orc.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro excluir orçamento: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    qtb_orc.deletarBanco_Dados();
                }
            }
        }
コード例 #5
0
 private void bsOrcamento_PositionChanged(object sender, EventArgs e)
 {
     if (bsOrcamento.Current != null)
     {
         (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto =
             TCN_OrcProjeto.Buscar(vCd_Empresa, vId_Orcamento, (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr, string.Empty, string.Empty, null);
         (bsOrcamento.Current as TRegistro_Orcamento).lDespesas =
             TCN_Despesas.Buscar(vCd_Empresa, vId_Orcamento, (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr, string.Empty, string.Empty, null);
         (bsOrcamento.Current as TRegistro_Orcamento).lMaoObra =
             TCN_CadMaoObra.Busca(vId_Orcamento, (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr, vCd_Empresa, string.Empty, null);
         (bsOrcamento.Current as TRegistro_Orcamento).lOEncargo =
             TCN_OrcamentoEncargo.Buscar(string.Empty, vCd_Empresa, (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr, vId_Orcamento, null);
         bsOrcamento.ResetCurrentItem();
         bsAtividade.ResetCurrentItem();
         bsAtividade_PositionChanged(this, new EventArgs());
         bsAtividade.ResetCurrentItem();
         edit_tot_orcamento_cont.Value = decimal.Add(edit_custo_orcamento.Value, decimal.Multiply(edit_custo_orcamento.Value, decimal.Divide((bsOrcamento.Current as TRegistro_Orcamento).Pc_margemcont, 100)));
         tot_comissao.Value            = decimal.Multiply((bsOrcamento.Current as TRegistro_Orcamento).total_orcamento, decimal.Divide((bsOrcamento.Current as TRegistro_Orcamento).Pc_comissao, 100));
         total_comi = tot_comissao.Value;
     }
 }
コード例 #6
0
        private void bsOrcamento_PositionChanged(object sender, EventArgs e)
        {
            if (bsOrcamento.Current != null)
            {
                //Buscar Atividades
                (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto =
                    TCN_OrcProjeto.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                          (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                          (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                          string.Empty,
                                          string.Empty,
                                          null);
                (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.ForEach(p =>
                {
                    p.lFicha = TCN_FichaTec.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                                   (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                                   (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                                   p.Id_projetostr, string.Empty, string.Empty, null);
                });

                bsOrcamento.ResetCurrentItem();
            }
        }
コード例 #7
0
        private void bsOrcamento_PositionChanged(object sender, EventArgs e)
        {
            if (bsOrcamento.Current != null)
            {
                if ((bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.Count <= 0)
                {
                    //Buscar Atividades
                    (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto =
                        TCN_OrcProjeto.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                              (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                              (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                              string.Empty,
                                              string.Empty,
                                              null);
                }
                (bsOrcamento.Current as TRegistro_Orcamento).lRequisitos =
                    TCN_RequisitoORc.Buscar(string.Empty, (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa, (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                            (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr, null);


                (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.ForEach(p =>
                {
                    p.lFicha = TCN_FichaTec.Buscar(p.Cd_empresa,
                                                   p.Id_orcamentostr,
                                                   (p).Nr_versaostr,
                                                   p.Id_projetostr,
                                                   p.Id_registrostr,
                                                   "",
                                                   null);



                    p.lFicha.ForEach(o => {
                        o.quantidade_agregar = o.Quantidade;
                    });
                });

                if ((bsOrcamento.Current as TRegistro_Orcamento).lDespesas.Count <= 0)
                {
                    //Buscar Despesas
                    (bsOrcamento.Current as TRegistro_Orcamento).lDespesas =
                        TCN_Despesas.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                            (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                            (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                            string.Empty,
                                            string.Empty,
                                            null);
                }
                if ((bsOrcamento.Current as TRegistro_Orcamento).lMaoObra.Count <= 0)
                {
                    //Buscar mao obra
                    (bsOrcamento.Current as TRegistro_Orcamento).lMaoObra =
                        CamadaNegocio.Empreendimento.Cadastro.TCN_CadMaoObra.Busca(
                            (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                            (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                            (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                            string.Empty,
                            null);
                }
                if ((bsOrcamento.Current as TRegistro_Orcamento).lOEncargo.Count <= 0)
                {
                    //Buscar encargos
                    (bsOrcamento.Current as TRegistro_Orcamento).lOEncargo =
                        CamadaNegocio.Empreendimento.Cadastro.TCN_OrcamentoEncargo.Buscar(
                            string.Empty,
                            (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                            (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                            (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                            null);
                }
                bsOrcamento.ResetCurrentItem();
                bsProjeto_PositionChanged(this, new EventArgs());
                bsProjeto.ResetCurrentItem();
            }
        }
コード例 #8
0
        private void toolStripLabel1_Click(object sender, EventArgs e)
        {
            if (bsOrcamento.Current == null)
            {
                return;
            }

            using (FRequisicaoCompra comp = new FRequisicaoCompra())
            {//Buscar Atividades
                TRegistro_Orcamento orc = new TRegistro_Orcamento();
                orc             = (bsOrcamento.Current as TRegistro_Orcamento);
                orc.lOrcProjeto =
                    TCN_OrcProjeto.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                          (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                          (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                          string.Empty,
                                          string.Empty,
                                          null);
                orc.lOrcProjeto.ForEach(p =>
                {
                    TpBusca[] filtro = new TpBusca[0];
                    if (!string.IsNullOrEmpty(p.Cd_empresa))
                    {
                        Array.Resize(ref filtro, filtro.Length + 1);
                        filtro[filtro.Length - 1].vNM_Campo = "a.cd_empresa";
                        filtro[filtro.Length - 1].vOperador = "=";
                        filtro[filtro.Length - 1].vVL_Busca = "'" + p.Cd_empresa.Trim() + "'";
                    }
                    if (!string.IsNullOrEmpty(p.Id_orcamentostr))
                    {
                        Array.Resize(ref filtro, filtro.Length + 1);
                        filtro[filtro.Length - 1].vNM_Campo = "a.id_orcamento";
                        filtro[filtro.Length - 1].vOperador = "=";
                        filtro[filtro.Length - 1].vVL_Busca = p.Id_orcamentostr;
                    }
                    if (!string.IsNullOrEmpty(p.Nr_versaostr))
                    {
                        Array.Resize(ref filtro, filtro.Length + 1);
                        filtro[filtro.Length - 1].vNM_Campo = "a.nr_versao";
                        filtro[filtro.Length - 1].vOperador = "=";
                        filtro[filtro.Length - 1].vVL_Busca = p.Nr_versaostr;
                    }
                    if (!string.IsNullOrEmpty(p.Id_projetostr))
                    {
                        Array.Resize(ref filtro, filtro.Length + 1);
                        filtro[filtro.Length - 1].vNM_Campo = "a.id_atividade";
                        filtro[filtro.Length - 1].vOperador = "=";
                        filtro[filtro.Length - 1].vVL_Busca = p.Id_projetostr;
                    }
                    if (!string.IsNullOrEmpty(p.Id_registrostr))
                    {
                        Array.Resize(ref filtro, filtro.Length + 1);
                        filtro[filtro.Length - 1].vNM_Campo = "a.Id_Registro";
                        filtro[filtro.Length - 1].vOperador = "=";
                        filtro[filtro.Length - 1].vVL_Busca = p.Id_registrostr;
                    }

                    Array.Resize(ref filtro, filtro.Length + 1);
                    filtro[filtro.Length - 1].vOperador = "not exists ";
                    filtro[filtro.Length - 1].vVL_Busca = " (select 1 from TB_EMP_CompraEmpreendimento x " +
                                                          "where a.id_orcamento = x.id_orcamento and a.nr_versao = x.nr_versao " +
                                                          "and a.ID_Atividade = x.ID_Atividade and a.ID_Ficha = x.ID_Ficha " +
                                                          "and a.ID_Registro = x.ID_Registro and a.cd_empresa = x.cd_empresa) ";



                    p.lFicha = new TCD_FichaTec().Select(filtro, 0, string.Empty);
                });
                comp.rOrcamento = orc;
                if (comp.ShowDialog() == DialogResult.OK)
                {
                    TList_FichaTec lficha = new TList_FichaTec();
                    lficha = comp.objetoItens.lFicha;
                    //(bsOrcamento.Current as TRegistro_Orcamento).St_registro = "E";
                    TList_FichaTec lficha2 = new TList_FichaTec();
                    lficha.ForEach(p =>
                    {
                        if (p.st_agregar)
                        {
                            lficha2.Add(p);
                        }
                    });

                    try
                    {
                        TCN_Orcamento.GravarOrcReq((bsOrcamento.Current as TRegistro_Orcamento), lficha2, null);
                        MessageBox.Show("Requisição de compra gravada com sucesso.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LimparFiltros();
                        afterBusca();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #9
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if ((bsOrcamento.Current) != null)
            {
                if ((bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("T"))
                {
                    if (CamadaNegocio.Diversos.TCN_Usuario_RegraEspecial.ValidaRegra(Parametros.pubLogin, "VISAO PROJETISTA", null))
                    {
                        if (MessageBox.Show("Orcamento está em " + (bsOrcamento.Current as TRegistro_Orcamento).Status + ", Deseja finalizar o projeto e evoluir para execução?", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                            MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                        {
                            try
                            {
                                bsOrcamento_PositionChanged(this, new EventArgs());
                                TList_FichaTec lficha = new TList_FichaTec();

                                //valida
                                TList_CadCFGEmpreendimento lcfg = new TCD_CadCFGEmpreendimento().Select(
                                    new TpBusca[]
                                {
                                    new TpBusca()
                                    {
                                        vNM_Campo = "a.cd_empresa",
                                        vOperador = "=",
                                        vVL_Busca = (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa
                                    }
                                }, 1, string.Empty);
                                if (string.IsNullOrEmpty(lcfg[0].tp_requisicao) || string.IsNullOrEmpty(lcfg[0].tp_requisicaodir))
                                {
                                    MessageBox.Show("Favor corrigir a configuração do empreendimento!\n (Tipo Requisição)", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.ForEach(o =>
                                {
                                    o.lFicha.ForEach(p =>
                                    {
                                        if (p.Tot_saldo < p.Quantidade)
                                        {
                                            p.st_agregar         = true;
                                            p.quantidade_agregar = p.Quantidade;
                                        }
                                    });
                                });

                                TList_FichaTec lista_nao_cadastrados = new TList_FichaTec();
                                bool           lista = false;
                                (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.ForEach(o =>
                                {
                                    o.lFicha.ForEach(p =>
                                    {
                                        if (string.IsNullOrEmpty(p.Cd_produto))
                                        {
                                            lista_nao_cadastrados.Add(p);
                                            lista = true;
                                        }
                                    });
                                });

                                if (lista)
                                {
                                    using (FListCadProd ls = new FListCadProd())
                                    {
                                        ls.rLItens = lista_nao_cadastrados;
                                        if (ls.ShowDialog() == DialogResult.OK)
                                        {
                                            (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.ForEach(o =>
                                            {
                                                o.lFicha.ForEach(p =>
                                                {
                                                    ls.rLItens.ForEach(i =>
                                                    {
                                                        if (p.Ds_produto.Equals(i.Ds_produto))
                                                        {
                                                            p.Cd_produto = i.Cd_produto;
                                                            CamadaNegocio.Empreendimento.TCN_FichaTec.Gravar(p, null);
                                                        }
                                                    });
                                                });
                                            });
                                            bsOrcamento.ResetCurrentItem();
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                }

                                using (FRequisicaoCompra comp = new FRequisicaoCompra())
                                {//Buscar Atividades
                                    TRegistro_Orcamento orc = new TRegistro_Orcamento();
                                    orc             = (bsOrcamento.Current as TRegistro_Orcamento);
                                    orc.lOrcProjeto =
                                        TCN_OrcProjeto.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa,
                                                              (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr,
                                                              (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr,
                                                              string.Empty,
                                                              string.Empty,
                                                              null);
                                    orc.lOrcProjeto.ForEach(p =>
                                    {
                                        TpBusca[] filtro = new TpBusca[0];
                                        if (!string.IsNullOrEmpty(p.Cd_empresa))
                                        {
                                            Array.Resize(ref filtro, filtro.Length + 1);
                                            filtro[filtro.Length - 1].vNM_Campo = "a.cd_empresa";
                                            filtro[filtro.Length - 1].vOperador = "=";
                                            filtro[filtro.Length - 1].vVL_Busca = "'" + p.Cd_empresa.Trim() + "'";
                                        }
                                        if (!string.IsNullOrEmpty(p.Id_orcamentostr))
                                        {
                                            Array.Resize(ref filtro, filtro.Length + 1);
                                            filtro[filtro.Length - 1].vNM_Campo = "a.id_orcamento";
                                            filtro[filtro.Length - 1].vOperador = "=";
                                            filtro[filtro.Length - 1].vVL_Busca = p.Id_orcamentostr;
                                        }
                                        if (!string.IsNullOrEmpty(p.Nr_versaostr))
                                        {
                                            Array.Resize(ref filtro, filtro.Length + 1);
                                            filtro[filtro.Length - 1].vNM_Campo = "a.nr_versao";
                                            filtro[filtro.Length - 1].vOperador = "=";
                                            filtro[filtro.Length - 1].vVL_Busca = p.Nr_versaostr;
                                        }
                                        if (!string.IsNullOrEmpty(p.Id_projetostr))
                                        {
                                            Array.Resize(ref filtro, filtro.Length + 1);
                                            filtro[filtro.Length - 1].vNM_Campo = "a.id_atividade";
                                            filtro[filtro.Length - 1].vOperador = "=";
                                            filtro[filtro.Length - 1].vVL_Busca = p.Id_projetostr;
                                        }
                                        if (!string.IsNullOrEmpty(p.Id_registrostr))
                                        {
                                            Array.Resize(ref filtro, filtro.Length + 1);
                                            filtro[filtro.Length - 1].vNM_Campo = "a.Id_Registro";
                                            filtro[filtro.Length - 1].vOperador = "=";
                                            filtro[filtro.Length - 1].vVL_Busca = p.Id_registrostr;
                                        }

                                        Array.Resize(ref filtro, filtro.Length + 1);
                                        filtro[filtro.Length - 1].vOperador = "not exists ";
                                        filtro[filtro.Length - 1].vVL_Busca = " (select 1 from TB_EMP_CompraEmpreendimento x " +
                                                                              "where a.id_orcamento = x.id_orcamento and a.nr_versao = x.nr_versao " +
                                                                              "and a.ID_Atividade = x.ID_Atividade and a.ID_Ficha = x.ID_Ficha " +
                                                                              "and a.ID_Registro = x.ID_Registro and a.cd_empresa = x.cd_empresa) ";



                                        p.lFicha = new TCD_FichaTec().Select(filtro, 0, string.Empty);
                                    });
                                    comp.rOrcamento = orc;
                                    if (comp.ShowDialog() == DialogResult.OK)
                                    {
                                        lficha = comp.objetoItens.lFicha;
                                        //(bsOrcamento.Current as TRegistro_Orcamento) = comp.rOrcamento;
                                        (bsOrcamento.Current as TRegistro_Orcamento).St_registro = "E";
                                        TList_FichaTec lficha2 = new TList_FichaTec();
                                        lficha.ForEach(p =>
                                        {
                                            if (p.st_agregar)
                                            {
                                                lficha2.Add(p);
                                            }
                                        });
                                        TCN_Orcamento.GravarOrcReq((bsOrcamento.Current as TRegistro_Orcamento), lficha2, null);

                                        // MessageBox.Show("Orçamento gravado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        LimparFiltros();
                                        //cbHomologacao.Checked = true;
                                        afterBusca();
                                        MessageBox.Show("Orçamento está aguardando em execução.", "Orçamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                            }
                            catch (Exception ex)
                            { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Usuário não tem permissão de projetista para esta evolução.", "Orçamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("Selecione um orcamento!", "Orçamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }