コード例 #1
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();
        }
コード例 #2
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;
            }
        }
コード例 #3
0
        public static TRegistro_FormulaApontamento CriarFormulaApontamentoProd(string Cd_empresa,
                                                                               string Cd_produto,
                                                                               string Cd_unidade,
                                                                               string Cd_local,
                                                                               //bool St_decomposicao,
                                                                               BancoDados.TObjetoBanco banco)
        {
            TRegistro_FormulaApontamento rFormula = new TRegistro_FormulaApontamento();

            rFormula.Cd_empresa = Cd_empresa;
            //if (!St_decomposicao)
            {
                rFormula.Cd_produto     = Cd_produto;
                rFormula.Cd_unidProduto = Cd_unidade;
                rFormula.Cd_unidade     = Cd_unidade;
                rFormula.Cd_local       = Cd_local;
                rFormula.Qt_produto     = 1;

                TList_FichaTecProduto lFicha = TCN_FichaTecProduto.Buscar(Cd_produto,
                                                                          string.Empty,
                                                                          banco);
                lFicha.ForEach(p =>
                {
                    rFormula.LFichaTec_MPrima.Add(new TRegistro_FichaTec_MPrima()
                    {
                        Cd_empresa      = Cd_empresa,
                        Cd_produto      = p.Cd_item,
                        Cd_unid_produto = p.Cd_unditem,
                        Cd_unidade      = p.Cd_unditem,
                        Cd_local        = Cd_local,
                        Qtd_produto     = p.Quantidade
                    });
                });
            }
            //else
            //{
            //    //Produto Acabado
            //    CamadaDados.Estoque.Cadastros.TList_FichaTecProduto lFicha =
            //        CamadaNegocio.Estoque.Cadastros.TCN_FichaTecProduto.Buscar(Cd_produto,
            //                                                                   string.Empty,
            //                                                                   banco);
            //    lFicha.ForEach(p =>
            //    {
            //        rFormula.LFichaTec_Acabado.Add(new TRegistro_FichaTec_Acabado()
            //        {
            //            Cd_empresa = Cd_empresa,
            //            Cd_produto = p.Cd_item,
            //            Cd_unid_produto = p.Cd_unditem,
            //            Cd_unidade = p.Cd_unditem,
            //            Cd_local = Cd_local,
            //            Qtd_produto = p.Quantidade,
            //            Pc_rateiocusto = 100
            //        });
            //    });
            //    //Materia Prima
            //    rFormula.LFichaTec_MPrima.Add(new TRegistro_FichaTec_MPrima()
            //    {
            //        Cd_empresa = Cd_empresa,
            //        Cd_produto = Cd_produto,
            //        Cd_unid_produto = Cd_unidade,
            //        Cd_unidade = Cd_unidade,
            //        Cd_local = Cd_local,
            //        Qtd_produto = 1
            //    });
            //}
            return(rFormula);
        }