public DadosMemoriaCalculo(ProdutoOrcamentoBenef pob) { BenefConfig bc = BenefConfigDAO.Instance.GetElement(pob.IdBenefConfig); ProdutosOrcamento pai = ProdutosOrcamentoDAO.Instance.GetElement(pob.IdProd); BenefConfigPreco bcp = BenefConfigPrecoDAO.Instance.GetByIdBenefConfig(null, pob.IdBenefConfig, pai.IdProduto.Value); Orcamento orca = OrcamentoDAO.Instance.GetElement(pai.IdOrcamento); Codigo = pai.CodInterno; Ambiente = pai.Ambiente; DescrAmbiente = pai.IdProdParent > 0 ? ProdutosOrcamentoDAO.Instance.ObtemValorCampo <string>("descricao", "idProd=" + pai.IdProdParent.Value) : null; _descricao = " " + bc.DescricaoCompleta.Trim(); Redondo = false; Qtde = pob.Qtde; ValorTabela = BenefConfigDAO.Instance.GetValorTabela(bcp, orca.TipoEntrega, orca.IdCliente); Custo = bcp.Custo; CustoTotal = pob.Custo; Valor = pob.ValorUnit; ValorTotal = pob.Valor; if (bc.TipoControle == TipoControleBenef.Bisote || bc.TipoControle == TipoControleBenef.Lapidacao) { _descricao += " " + Utils.MontaDescrLapBis(pob.BisAlt, pob.BisLarg, pob.LapAlt, pob.LapLarg, pob.EspBisote, null, null, false); } if (bc.TipoCalculo == TipoCalculoBenef.Porcentagem) { ValorTabela = Math.Round((ValorTabela / 100) * pai.ValorProd.Value, 2); Custo = Math.Round((Custo / 100) * pai.Custo, 2); } TipoCalculo = 0; }
public static bool IsBisote(uint idBenefConfig) { BenefConfig b = BenefConfigDAO.Instance.GetElement(idBenefConfig); var tipoControle = b.TipoControleParent > 0 ? b.TipoControleParent.Value : b.TipoControle; return(tipoControle == TipoControleBenef.Bisote); }
public DadosMemoriaCalculo(MaterialProjetoBenef mpb, Orcamento.TipoEntregaOrcamento?tipoEntregaOrcamento, float percComissao, string ambiente, string descrAmbiente, uint?idCliente) { BenefConfig bc = BenefConfigDAO.Instance.GetElement(mpb.IdBenefConfig); MaterialItemProjeto pai = MaterialItemProjetoDAO.Instance.GetElementByPrimaryKey(mpb.IdMaterItemProj); BenefConfigPreco bcp = BenefConfigPrecoDAO.Instance.GetByIdBenefConfig(null, mpb.IdBenefConfig, pai.IdProd); Codigo = pai.CodInterno; Ambiente = ambiente; DescrAmbiente = descrAmbiente; _descricao = " " + bc.DescricaoCompleta.Trim(); Redondo = false; Qtde = mpb.Qtd; ValorTabela = BenefConfigDAO.Instance.GetValorTabela(bcp, (int?)tipoEntregaOrcamento, idCliente); Custo = bcp.Custo; CustoTotal = mpb.Custo; Valor = mpb.ValorUnit; ValorTotal = mpb.Valor; if (bc.TipoControle == TipoControleBenef.Bisote || bc.TipoControle == TipoControleBenef.Lapidacao) { _descricao += " " + Utils.MontaDescrLapBis(mpb.BisAlt, mpb.BisLarg, mpb.LapAlt, mpb.LapLarg, mpb.EspBisote, null, null, false); } if (bc.TipoCalculo == TipoCalculoBenef.Porcentagem) { ValorTabela = Math.Round((ValorTabela / 100) * pai.Valor, 2); } TipoCalculo = 0; }
public DadosMemoriaCalculo(ProdutoPedidoEspelhoBenef ppeb) { BenefConfig bc = BenefConfigDAO.Instance.GetElement(ppeb.IdBenefConfig); ProdutosPedidoEspelho pai = ProdutosPedidoEspelhoDAO.Instance.GetElement(ppeb.IdProdPed, false); BenefConfigPreco bcp = BenefConfigPrecoDAO.Instance.GetByIdBenefConfig(null, ppeb.IdBenefConfig, pai.IdProd); int tipoEntrega = PedidoDAO.Instance.ObtemTipoEntrega(pai.IdPedido); bool maoDeObra = PedidoDAO.Instance.IsMaoDeObra(null, pai.IdPedido); Codigo = pai.CodInterno; Ambiente = !maoDeObra ? pai.AmbientePedido : AmbientePedidoEspelhoDAO.Instance.ObtemPecaVidroQtd(pai.IdAmbientePedido.Value); DescrAmbiente = pai.DescrAmbientePedido; _descricao = " " + bc.DescricaoCompleta.Trim(); Redondo = false; Qtde = ppeb.Qtd; ValorTabela = BenefConfigDAO.Instance.GetValorTabela(bcp, (int?)tipoEntrega, PedidoDAO.Instance.ObtemIdCliente(null, pai.IdPedido)); Custo = bcp.Custo; CustoTotal = ppeb.Custo; Valor = ppeb.ValorUnit; ValorTotal = ppeb.Valor; if (bc.TipoControle == TipoControleBenef.Bisote || bc.TipoControle == TipoControleBenef.Lapidacao) { _descricao += " " + Utils.MontaDescrLapBis(ppeb.BisAlt, ppeb.BisLarg, ppeb.LapAlt, ppeb.LapLarg, ppeb.EspBisote, null, null, false); } if (bc.TipoCalculo == TipoCalculoBenef.Porcentagem) { ValorTabela = Math.Round((ValorTabela / 100) * pai.ValorVendido, 2); } TipoCalculo = 0; }
/// <summary> /// Cria os beneficiamentos nas células. /// </summary> /// <param name="celula">A célula dos controles.</param> /// <param name="benef">O beneficiamento.</param> private void CreateBenef(TableCell celula, BenefConfig benef) { // Indica na célula dos controles o ID do beneficiamento celula.Attributes.Add("IdBeneficiamento", benef.IdBenefConfig.ToString()); // Formata a célula celula.Style.Add("White-space", "nowrap"); celula.Style.Add("Padding-right", "4px"); // Adiciona os controles à célula foreach (Control c in GetControls(benef)) { celula.Controls.Add(c); } }
private BeneficiamentoDto ConverterBeneficiamentoParaDto( BenefConfig beneficiamento, IEnumerable <BenefConfig> listaBeneficiamentos, IEnumerable <BenefConfigPreco> listaPrecos) { var filhos = listaBeneficiamentos.Where(filho => filho.IdParent == beneficiamento.IdBenefConfig); var precos = listaPrecos.Where(item => item.IdBenefConfig == beneficiamento.IdBenefConfig); return(new BeneficiamentoDto { Id = beneficiamento.IdBenefConfig, Nome = beneficiamento.Descricao, TipoControle = beneficiamento.TipoControle, TipoCalculo = beneficiamento.TipoCalculo, PermitirCobrancaOpcional = beneficiamento.CobrancaOpcional, CalculoPorEspessura = beneficiamento.TipoEspessura != TipoEspessuraBenef.ItemNaoPossui, Precos = precos.Select(preco => this.ConverterPrecosParaDto(preco)), Filhos = filhos.Select(filho => this.ConverterBeneficiamentoParaDto(filho, listaBeneficiamentos, listaPrecos)), }); }
/// <summary> /// Busca string contendo beneficiamentos feitos no produtoPedido /// </summary> /// <param name="idProdPed"></param> /// <returns></returns> public string GetDescrBenef(uint idProdCompra) { string descrBenef = String.Empty; foreach (ProdutosCompraBenef benef in GetBenefForDescr(idProdCompra)) { if (!Configuracoes.CompraConfig.ExibicaoDescrBenefCustomizada) { descrBenef += (benef.Qtde > 0 ? benef.Qtde.ToString() + " " : "") + benef.DescrBenef + Utils.MontaDescrLapBis(benef.BisAlt, benef.BisLarg, benef.LapAlt, benef.LapLarg, benef.EspBisote, null, null, true) + "; "; } else { string tempBenef = benef.DescrBenef; BenefConfig bc = BenefConfigDAO.Instance.GetElement(benef.IdBenefConfig); if (bc.TipoControle == TipoControleBenef.Lapidacao || bc.TipoControle == TipoControleBenef.Bisote) { tempBenef = tempBenef.Substring(0, tempBenef.IndexOf("mm")); tempBenef = tempBenef.Substring(0, tempBenef.LastIndexOf(" ")); if (benef.EspBisote > 0) { tempBenef += " " + benef.EspBisote + "mm"; } } if (tempBenef.ToLower().IndexOf("até") > -1) { tempBenef = tempBenef.Substring(0, tempBenef.ToLower().IndexOf("até")); tempBenef = tempBenef.Substring(0, tempBenef.LastIndexOf(" ")) + "; "; } descrBenef += (benef.Qtde > 0 ? benef.Qtde.ToString() + " " : "") + tempBenef + "; "; } } return(descrBenef); }
/// <summary> /// Retorna a lista de controles do beneficiamento. /// </summary> /// <param name="benef">O beneficiamento que será criado.</param> /// <returns>Um vetor com os controles do beneficiamento.</returns> private Control[] GetControls(BenefConfig benef) { // Variável de retorno List <Control> retorno = new List <Control>(); string prefixo = PrefixoControles(benef); // Cria o controle de seleção pai CheckBox chkPai = new CheckBox(); chkPai.ID = prefixo + "chkPai"; chkPai.Text = benef.Nome; chkPai.Attributes.Add("prefixoBenef", prefixo); /* Chamado 55594. */ if (!IsPostBack && !string.IsNullOrWhiteSpace(_queryStringRecuperarIds)) { if (_queryStringRecuperarIds.Split(',').Any(f => f.StrParaUint() == benef.IdBenefConfig || BenefConfigDAO.Instance.GetParentId(f.StrParaUint()) == benef.IdBenefConfig)) { chkPai.Checked = true; } } retorno.Add(chkPai); var filhos = GetSubItens(benef); // Cria os controles de seleção dos filhos if (filhos.Count > 0) { chkPai.Attributes.Add("onclick", "exibirFilhos('" + this.ClientID + "', this); " + this.ClientID + ".Exibir();"); CheckBoxList chkFilhos = new CheckBoxList(); chkFilhos.ID = prefixo + "tblFilhos"; chkFilhos.Style.Value = "margin-left: 10px; display: none"; chkFilhos.RepeatLayout = RepeatLayout.Table; chkFilhos.RepeatColumns = 4; chkFilhos.DataSource = filhos; chkFilhos.DataValueField = "IdBenefConfig"; chkFilhos.DataTextField = "Nome"; chkFilhos.DataBind(); foreach (ListItem i in chkFilhos.Items) { i.Attributes.Add("idBeneficiamento", i.Value); /* Chamado 55594. */ if (!IsPostBack && !string.IsNullOrWhiteSpace(_queryStringRecuperarIds)) { if (_queryStringRecuperarIds.Split(',').Any(f => f == i.Value.ToString())) { i.Selected = true; } } } retorno.Add(chkFilhos); } // Retorna o vetor return(retorno.ToArray()); }
/// <summary> /// Retorna o prefixo dos nomes dos controles. /// </summary> /// <param name="benef"></param> /// <returns></returns> private string PrefixoControles(BenefConfig benef) { // Retorna uma string com o nome do beneficiamento formatado return(benef.Nome.Trim().Replace(" ", "_").Replace("²", "2") + "_"); }
/// <summary> /// Retorna os sub-itens de um beneficiamento. /// </summary> /// <param name="benef">O beneficiamento pai.</param> /// <returns>Uma lista com os beneficiamentos vinculados ao pai.</returns> private IList <BenefConfig> GetSubItens(BenefConfig benef) { // Recupera os itens filhos de um beneficiamento return(BenefConfigDAO.Instance.GetByBenefConfig((uint)benef.IdBenefConfig)); }
private static void ConverterBisote(GenericBenef convertido, ItemBeneficiamentoDto beneficiamento, BenefConfig configuracao) { if (configuracao?.TipoControleParent == TipoControleBenef.Bisote) { convertido.BisAlt = beneficiamento.Altura ?? 0; convertido.BisLarg = beneficiamento.Largura ?? 0; convertido.EspBisote = (float?)beneficiamento.Espessura ?? 0; } }
private static void ConverterLapidacao(GenericBenef convertido, ItemBeneficiamentoDto beneficiamento, BenefConfig configuracao) { if (configuracao?.TipoControleParent == TipoControleBenef.Lapidacao) { convertido.LapAlt = beneficiamento.Altura ?? 0; convertido.LapLarg = beneficiamento.Largura ?? 0; } }