Example #1
0
        private void BB_AdcLista_Click(object sender, EventArgs e)
        {
            EditDefault edit = new EditDefault();

            edit.NM_CampoBusca = "CD_Produto";
            string vColunas = "DS_Produto|Descrição Produto|350;" +
                              "CD_Produto|Cód. Produto|100;" +
                              "a.codigo_alternativo|Referencia|80;" +
                              "a.ds_tecnica|Descrição Tecnica|200;" +
                              "f.ds_Marca|Marca|100;" +
                              "b.ds_Unidade|Unidade|100;" +
                              "b.sigla_unidade|UND|80;" +
                              "c.ds_Grupo|Grupo|100;" +
                              "a.cd_condfiscal_produto|Cd. CondFiscal|80;" +
                              "d.ds_condfiscal_produto|Condição Fiscal|100";
            string vParamFixo = "isnull(a.st_registro, 'A')|<>|'C'";

            UtilPesquisa.BTN_BUSCALISTA(vColunas, edit, new TCD_CadProduto(), vParamFixo);
            string s = edit.Text.Replace("(", "");

            s = s.Replace(")", "");
            s = s.Replace("'", "");
            string[] vs = s.Split(',');
            if (vs.Length > 0 && !string.IsNullOrEmpty(s))
            {
                foreach (string v in vs)
                {
                    TpBusca[] tps = new TpBusca[0];
                    Estruturas.CriarParametro(ref tps, "a.cd_produto", v);

                    //Busca do valor unitario
                    object obj = new CamadaDados.Estoque.TCD_LanPrecoItem().BuscarEscalar(
                        new TpBusca[]
                    {
                        new TpBusca()
                        {
                            vNM_Campo = "a.cd_produto",
                            vOperador = "=",
                            vVL_Busca = v
                        },
                        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");
                    decimal value = decimal.Zero;
                    if (obj != null)
                    {
                        if (!string.IsNullOrEmpty(obj.ToString()))
                        {
                            value = Convert.ToDecimal(obj.ToString());
                        }
                    }

                    TRegistro_FichaTec tec = new TRegistro_FichaTec()
                    {
                        Id_projetostr = (bsFichaTec.Current as TRegistro_FichaTec).Id_projetostr,
                        Cd_produto    = v.SoNumero(),
                        Ds_produto    = new TCD_CadProduto().BuscarEscalar(tps, "a.ds_produto").ToString(),
                        Quantidade    = 1,
                        Vl_unitario   = value,
                        Vl_subtotal   = value
                    };

                    lFicha.Add(tec);
                }

                DialogResult = DialogResult.OK;
            }
        }
Example #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;
            }
        }