Esempio n. 1
0
 private void bbCorrigirFicha_Click(object sender, EventArgs e)
 {
     if (bsFichaTec.Current != null)
     {
         using (TFFichaTec fFicha = new TFFichaTec())
         {
             if ((bsFichaTec.Current as TRegistro_FichaTec).lfichaItens.Count <= 0)
             {
                 if ((bsFichaTec.Current as TRegistro_FichaTec).st_composto.Equals("S"))
                 {
                     if ((bsFichaTec.Current as TRegistro_FichaTec).lfichaItens.Count <= 0)
                     {
                         (bsFichaTec.Current as TRegistro_FichaTec).lfichaItens.Clear();
                         if ((bsFichaTec.Current as TRegistro_FichaTec).lfichaItens != null)
                         {
                             (bsFichaTec.Current as TRegistro_FichaTec).lfichaItens = TCN_FichaItens.Buscar((bsFichaTec.Current as TRegistro_FichaTec).Cd_empresa,
                                                                                                            (bsFichaTec.Current as TRegistro_FichaTec).Id_orcamentostr, (bsFichaTec.Current as TRegistro_FichaTec).Nr_versaostr,
                                                                                                            (bsFichaTec.Current as TRegistro_FichaTec).Id_projetostr, (bsFichaTec.Current as TRegistro_FichaTec).Id_fichastr,
                                                                                                            string.Empty, null);
                         }
                     }
                     if ((bsFichaTec.Current as TRegistro_FichaTec).lfichaItens.Count <= 0)
                     {
                         CamadaDados.Estoque.Cadastros.TList_FichaTecProduto lFichaitens = CamadaNegocio.Estoque.Cadastros.TCN_FichaTecProduto.Buscar((bsFichaTec.Current as TRegistro_FichaTec).Cd_produto, string.Empty, null);
                         lFichaitens.ForEach(iten =>
                         {
                             TRegistro_FichaItens item = new TRegistro_FichaItens();
                             item.Cd_itemstr           = iten.Cd_item;
                             item.ds_item     = iten.Ds_item;
                             item.quantidade  = iten.Quantidade;
                             item.vl_unitario = iten.Vl_custoservico;
                             item.vl_subtotal = iten.Vl_subtotalservico;
                             (bsFichaTec.Current as TRegistro_FichaTec).lfichaItens.Add(item);
                         });
                     }
                 }
             }
             fFicha.rFicha      = bsFichaTec.Current as TRegistro_FichaTec;
             fFicha.pCd_empresa = (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa;
             if (fFicha.ShowDialog() == DialogResult.OK)
             {
                 int position = bsFichaTec.Position;
                 bsFichaTec.RemoveCurrent();
                 bsFichaTec.Insert(position, fFicha.rFicha);
                 MessageBox.Show("Ficha técinica adicionada com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }
Esempio n. 2
0
        public static string Excluir(TRegistro_FichaItens val, BancoDados.TObjetoBanco banco)
        {
            bool           st_transacao = false;
            TCD_FichaItens qtb_desp     = new TCD_FichaItens();

            try
            {
                if (banco == null)
                {
                    st_transacao = qtb_desp.CriarBanco_Dados(true);
                }
                else
                {
                    qtb_desp.Banco_Dados = banco;
                }
                //Excluir Funcionarios
                //val.lFunc.ForEach(p => TCN_Funcionarios.Excluir(p, qtb_desp.Banco_Dados));
                //val.lFuncDel.ForEach(p => TCN_Funcionarios.Excluir(p, qtb_desp.Banco_Dados));
                qtb_desp.Excluir(val);
                if (st_transacao)
                {
                    qtb_desp.Banco_Dados.Commit_Tran();
                }
                return(val.Id_fichastr);
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    qtb_desp.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro excluir despesa: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    qtb_desp.deletarBanco_Dados();
                }
            }
        }
Esempio n. 3
0
        public static string Gravar(TRegistro_FichaItens val, BancoDados.TObjetoBanco banco)
        {
            bool           st_transacao = false;
            TCD_FichaItens qtb_desp     = new TCD_FichaItens();

            try
            {
                if (banco == null)
                {
                    st_transacao = qtb_desp.CriarBanco_Dados(true);
                }
                else
                {
                    qtb_desp.Banco_Dados = banco;
                }
                val.Cd_itemstr = CamadaDados.TDataQuery.getPubVariavel(qtb_desp.Gravar(val), "@P_CD_ITEM");

                if (st_transacao)
                {
                    qtb_desp.Banco_Dados.Commit_Tran();
                }
                return(val.Cd_itemstr.ToString());
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    qtb_desp.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro gravar ficha: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    qtb_desp.deletarBanco_Dados();
                }
            }
        }
Esempio n. 4
0
 private void bbExcluirProjeto_Click(object sender, EventArgs e)
 {
     if (bsItens.Current != null)
     {
         if (MessageBox.Show("Deseja Realmente Excluir o item?", "Mensagem",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
         {
             TRegistro_FichaItens ficha = new TRegistro_FichaItens();
             ficha.Cd_item         = Convert.ToDecimal((bsItens.Current as TRegistro_FichaItens).Cd_itemstr);
             ficha.Id_fichastr     = pId_Ficha;
             ficha.Id_orcamentostr = pId_Orcamento;
             ficha.Id_projetostr   = (bsFichaTec.Current as TRegistro_FichaTec).Id_projetostr;
             ficha.Id_projeto      = (bsFichaTec.Current as TRegistro_FichaTec).Id_projeto;
             ficha.Nr_versaostr    = pNr_Versao;
             ficha.Cd_empresa      = pCd_empresa;
             ficha.quantidade      = (bsItens.Current as TRegistro_FichaItens).quantidade;
             ficha.vl_unitario     = (bsItens.Current as TRegistro_FichaItens).vl_unitario;
             (bsFichaTec.Current as TRegistro_FichaTec).lfichaItensDel.Add(ficha);
             bsItens.RemoveCurrent();
         }
         calculatotal();
     }
 }
Esempio n. 5
0
        private void bbImportar_Click(object sender, EventArgs e)
        {
            if (bsOrcamento.Current != null)
            {
                string id_orcamento = string.Empty;
                using (TFConsultaProjetos cProjetos = new TFConsultaProjetos())
                {
                    if (cProjetos.ShowDialog() == DialogResult.OK)
                    {
                        TList_Orcamento lorcamento = new TList_Orcamento();
                        TList_Orcamento lprojeto2  = new TList_Orcamento();
                        lorcamento = cProjetos.lOrc;
                        lorcamento.ForEach(o => {
                            o.lDespesas.Where(p => p.st_importar).ToList().ForEach(p =>
                            {
                                p.Id_orcamentostr = (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr;
                                p.Nr_versaostr    = (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr;
                                p.Id_RegDesp      = (bsDespesas.Count) + 1;
                                bsDespesas.Add(p);
                            });
                            o.lOEncargo.Where(p => p.st_importar).ToList().ForEach(p =>
                            {
                                p.Id_orcamentostr = (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr;
                                p.Nr_versaostr    = (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr;
                                p.vl_encargo      = decimal.Zero;
                                bsEncargo.Add(p);
                            });
                            o.lMaoObra.Where(p => p.st_importar).ToList().ForEach(p =>
                            {
                                p.Id_orcamentostr = (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr;
                                p.Nr_versaostr    = (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr;
                                p.Id_MaoObra      = (bsMaoObra).Count + 1;
                                bsMaoObra.Add(p);
                            });
                            o.lOrcProjeto.Where(p => p.st_importar).ToList().ForEach(p =>
                            {
                                TList_FichaTec lista = new TList_FichaTec();
                                p.lFicha.Where(i => i.st_agregar).ToList().ForEach(i =>
                                {
                                    i.Quantidade         = i.quantidade_agregar;
                                    i.quantidade_agregar = decimal.Zero;
                                    i.Id_ficha           = decimal.Zero;
                                    i.Id_orcamentostr    = (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr;
                                    i.Id_projetostr      = string.Empty;
                                    i.Nr_versaostr       = (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr;
                                    i.Vl_subtotal        = i.Vl_unitario * i.Quantidade;
                                    if (i.st_composto.Equals("S"))
                                    {
                                        CamadaDados.Estoque.Cadastros.TList_FichaTecProduto lFichaitens = CamadaNegocio.Estoque.Cadastros.TCN_FichaTecProduto.Buscar(i.Cd_produto, string.Empty, null);
                                        lFichaitens.ForEach(iten =>
                                        {
                                            TRegistro_FichaItens item = new TRegistro_FichaItens();
                                            item.Cd_itemstr           = iten.Cd_item;
                                            item.ds_item     = iten.Ds_item;
                                            item.quantidade  = iten.Quantidade;
                                            item.vl_unitario = iten.Vl_custoservico;
                                            item.vl_subtotal = iten.Vl_subtotalservico;
                                            i.lfichaItens.Add(item);
                                        });
                                    }

                                    lista.Add(i);
                                });

                                p.Id_orcamentostr = (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr;
                                p.Id_projeto      = (bsAtividade).Count + 1;
                                p.Nr_versaostr    = (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr;
                                p.lFicha          = lista;
                                bsAtividade.Add(p);

                                bsAtividade.ResetCurrentItem();
                            });
                        });
                        bsAtividade.Position = bsAtividade.Count - 1;
                        MessageBox.Show("Importado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("Selecione um Orcamento.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 6
0
        private void afterficha()
        {
            bool   valor_composto = false;
            string cdprod         = string.Empty;

            if (!string.IsNullOrEmpty(CD_PRODUTO.Text))
            {
                object obj = new CamadaDados.Estoque.TCD_LanPrecoItem().BuscarEscalar(new TpBusca[]
                {
                    new TpBusca()
                    {
                        vNM_Campo = "a.cd_produto",
                        vOperador = "=",
                        vVL_Busca = "" + CD_PRODUTO.Text + ""
                    },
                    new TpBusca()
                    {
                        vNM_Campo = "a.CD_TabelaPreco",
                        vOperador = "=",
                        vVL_Busca = "" + pCd_tabelapreco + ""
                    },
                    new TpBusca()
                    {
                        vNM_Campo = "a.cd_empresa",
                        vOperador = "=",
                        vVL_Busca = "" + pCd_empresa + ""
                    }
                }, "a.vl_precovenda");
                if (obj != null)
                {
                    if (!string.IsNullOrEmpty(obj.ToString()))
                    {
                        vl_unitario.Value = Convert.ToDecimal(obj.ToString());
                    }
                }
                else if (rProd == null ? false : rProd.St_composto)
                {
                    valor_composto = true;
                }
            }
            if (bsFichaTec.Current != null)
            {
                if (rProd != null)
                {
                    if (rProd.St_composto)
                    {
                        (bsFichaTec.Current as TRegistro_FichaTec).lfichaItens.Clear();
                        if ((bsFichaTec.Current as TRegistro_FichaTec).lfichaItens != null)
                        {
                            (bsFichaTec.Current as TRegistro_FichaTec).lfichaItens = CamadaNegocio.Empreendimento.TCN_FichaItens.Buscar((bsFichaTec.Current as TRegistro_FichaTec).Cd_empresa,
                                                                                                                                        (bsFichaTec.Current as TRegistro_FichaTec).Id_orcamentostr, (bsFichaTec.Current as TRegistro_FichaTec).Nr_versaostr,
                                                                                                                                        (bsFichaTec.Current as TRegistro_FichaTec).Id_projetostr, (bsFichaTec.Current as TRegistro_FichaTec).Id_fichastr,
                                                                                                                                        string.Empty, null);
                        }

                        //busca itens produto
                        TList_FichaTecProduto lFichaptd = CamadaNegocio.Estoque.Cadastros.TCN_FichaTecProduto.Buscar(CD_PRODUTO.Text, string.Empty, null);
                        if ((bsFichaTec.Current as TRegistro_FichaTec).lfichaItens.Count <= 0)
                        {
                            if (lFichaptd.Count > 0)
                            {
                                decimal total = decimal.Zero;
                                bsItens.Clear();
                                lFichaptd.ForEach(p =>
                                {
                                    TRegistro_FichaItens ficha = new TRegistro_FichaItens();
                                    ficha.Cd_itemstr           = p.Cd_item;
                                    ficha.ds_item     = p.Ds_item;
                                    ficha.quantidade  = p.Quantidade;
                                    ficha.vl_subtotal = p.Vl_subtotalservico;
                                    ficha.vl_unitario = p.Vl_custoservico;
                                    (bsFichaTec.Current as TRegistro_FichaTec).lfichaItens.Add(ficha);
                                    total += p.Vl_subtotalservico;
                                });
                                if (valor_composto)
                                {
                                    vl_unitario.Value = total;
                                }
                                bsItens.ResetCurrentItem();
                            }
                        }
                    }
                    (bsFichaTec.Current as TRegistro_FichaTec).Cd_produto = rProd.CD_Produto;
                    (bsFichaTec.Current as TRegistro_FichaTec).Ds_produto = rProd.DS_Produto;
                    (bsFichaTec.Current as TRegistro_FichaTec).Cd_unidade = rProd.CD_Unidade;
                    (bsFichaTec.Current as TRegistro_FichaTec).Ds_unidade = rProd.DS_Unidade;
                    (bsFichaTec.Current as TRegistro_FichaTec).Sg_unidade = rProd.Sigla_unidade;
                    bsFichaTec.ResetCurrentItem();
                    System.Collections.Hashtable hs = new System.Collections.Hashtable();
                    vl_ultimacompra.Value = rProd.Vl_ultimacompra;
                    vl_unitario.Value     = vl_unitario.Value > decimal.Zero ? vl_unitario.Value : rProd.Vl_precovenda;
                }
            }
            if (rProd == null ? false : bsItens.Count > 0 || rProd.St_composto)
            {
                Height = 593;
                ficha  = true;
            }
            else
            {
                Height = 190;
                ficha  = false;
            }
        }
Esempio n. 7
0
        private void TFFichaTec_Load(object sender, EventArgs e)
        {
            if (projetista)
            {
                panelDados2.Visible = false;
            }

            pDados.set_FormatZero();


            if (vSt_Proj && rficha == null)
            {
                bsFichaTec.AddNew();
                editDefault1.Text = vId_atividade;
                editDefault2.Text = vDs_atividade;
                editDefault1.Focus();
            }
            else if (rficha == null)
            {
                bsFichaTec.AddNew();
                if (!string.IsNullOrEmpty(CD_PRODUTO.Text))
                {
                    quantidade.Focus();
                }
                else
                {
                    ds_produto.Focus();
                }
                editDefault1.Text   = vId_atividade;
                editDefault2.Text   = vDs_atividade;
                panelDados3.Enabled = false;
            }
            else
            {
                panelDados3.Enabled = false;
                TList_FichaItens lprod = new TList_FichaItens();
                bsFichaTec.DataSource = new TList_FichaTec()
                {
                    rficha
                };
                ds_produto.Text   = rficha.Ds_produto;
                vl_unitario.Value = rficha.Vl_unitario;
                if (rficha.lfichaItens.Count > 0)
                {
                    rficha.lfichaItens.ForEach(p =>
                    {
                        TRegistro_FichaItens prod = new TRegistro_FichaItens();
                        prod.Cd_itemstr           = p.Cd_itemstr.ToString();
                        prod.quantidade           = p.quantidade;
                        prod.vl_unitario          = p.vl_unitario;
                        prod.vl_subtotal          = p.vl_unitario * p.quantidade;
                        object a = new TCD_CadProduto().BuscarEscalar(new TpBusca[] {
                            new Utils.TpBusca()
                            {
                                vNM_Campo = "a.cd_produto",
                                vOperador = "=",
                                vVL_Busca = p.Cd_itemstr.ToString()
                            }
                        }, "a.ds_produto");
                        prod.ds_item = a.ToString();

                        lprod.Add(prod);
                    });
                    bsItens.DataSource = lprod;
                }
                //cd_produto_Leave(this, new EventArgs());
                quantidade.Focus();
                TList_FichaTecProduto lFichaptd = new TList_FichaTecProduto();
                //busca itens produto
                if (!string.IsNullOrEmpty(CD_PRODUTO.Text))
                {
                    lFichaptd = CamadaNegocio.Estoque.Cadastros.TCN_FichaTecProduto.Buscar(CD_PRODUTO.Text, string.Empty, null);
                    if (lFichaptd.Count > 0 && bsItens.Count <= 0)
                    {
                        bsItens.Clear();
                        lFichaptd.ForEach(p =>
                        {
                            TRegistro_FichaItens pro = new TRegistro_FichaItens();
                            pro.Cd_itemstr           = p.Cd_item;
                            pro.ds_item     = p.Ds_item;
                            pro.quantidade  = p.Quantidade;
                            pro.vl_unitario = p.Vl_custoservico;
                            bsItens.Add(p);
                        });
                        bsItens.ResetCurrentItem();
                    }
                }
            }

            if (bsItens.Count > 0)
            {
                Height = 593;
                ficha  = true;
            }
            else
            {
                Height = 190;
                ficha  = false;
            }
            calculatotal();
        }