protected void ctrlBenef1_Load(object sender, EventArgs e) { hdfIdProd.Value = ProdutoDAO.Instance.GetFirstProdutoCodInterno((int)Glass.Data.Model.NomeGrupoProd.Vidro); Glass.UI.Web.Controls.ctrlBenef ctrlBenef = (Glass.UI.Web.Controls.ctrlBenef)sender; ctrlBenef.CampoProdutoID = hdfIdProd; }
protected void ctrlBenef_Load(object sender, EventArgs e) { Glass.UI.Web.Controls.ctrlBenef benef = (Glass.UI.Web.Controls.ctrlBenef)sender; GridViewRow linhaControle = benef.Parent.Parent as GridViewRow; ProdutosCompra pc = linhaControle.DataItem as ProdutosCompra; Control codProd = null; if (linhaControle.FindControl("lblCodProdIns") != null) { codProd = linhaControle.FindControl("lblCodProdIns"); } else { codProd = linhaControle.FindControl("hdfCodProd"); } TextBox txtAltura = (TextBox)linhaControle.FindControl("txtAlturaIns"); TextBox txtEspessura = (TextBox)linhaControle.FindControl("txtEspessura"); TextBox txtLargura = (TextBox)linhaControle.FindControl("txtLarguraIns"); TextBox txtQuantidade = (TextBox)linhaControle.FindControl("txtQtdeIns"); TextBox txtTotalM2 = (TextBox)linhaControle.FindControl("txtTotM2"); TextBox txtValorIns = (TextBox)linhaControle.FindControl("txtValorIns"); HiddenField hdfCustoProd = (HiddenField)linhaControle.FindControl("hdfCustoProd"); benef.CampoAltura = txtAltura; benef.CampoEspessura = txtEspessura; benef.CampoLargura = txtLargura; benef.CampoQuantidade = txtQuantidade; benef.CampoTotalM2 = txtTotalM2; benef.CampoValorUnitario = txtValorIns; benef.CampoProdutoID = codProd; benef.CampoCusto = hdfCustoProd; }
protected void grdProdutos_PreRender(object sender, EventArgs e) { Glass.UI.Web.Controls.ctrlBenef benef = (Glass.UI.Web.Controls.ctrlBenef)grdProdutosComposicao.FooterRow.FindControl("ctrl_BenefInserirComposicao"); GridViewRow linhaControle = benef.Parent.Parent as GridViewRow; Control mainTable = linhaControle.Parent; while (mainTable.ID != "mainTable") { mainTable = mainTable.Parent; } var hdfIdAmbiente = (HiddenField)mainTable.FindControl("hdfIdAmbiente"); if (ProdutosPedidoDAO.Instance.CountInPedidoAmbiente(Request["idPedido"].StrParaUint(), hdfIdAmbiente.Value.StrParaUint(), true, (uint)IdProdPed) == 0) { grdProdutosComposicao.Rows[0].Visible = false; } if ((uint)IdProdPed > 0 && ProdutosPedidoDAO.Instance.IsProdLaminado((uint)IdProdPed)) { grdProdutosComposicao.ShowFooter = false; } }
protected void ctrlBenef1_Load(object sender, EventArgs e) { //Esconde a opção de beneficiamento caso for uma inserção de produto if (dtvProduto.CurrentMode != DetailsViewMode.Edit) { dtvProduto.Fields[33].Visible = false; } if (dtvProduto.CurrentMode == DetailsViewMode.Edit) { hdfIdPrimeiroProduto.Value = ProdutoDAO.Instance.GetCodInterno(Glass.Conversoes.StrParaInt(Request["idProd"])); } else { hdfIdPrimeiroProduto.Value = ProdutoDAO.Instance.GetFirstProdutoCodInterno(); } Glass.UI.Web.Controls.ctrlBenef ctrlBenef = (Glass.UI.Web.Controls.ctrlBenef)sender; ctrlBenef.CampoAltura = (TextBox)dtvProduto.FindControl("txtAlturaIns"); ctrlBenef.CampoLargura = (TextBox)dtvProduto.FindControl("txtLarguraIns"); ctrlBenef.CampoEspessura = (TextBox)dtvProduto.FindControl("txtEspessura"); ctrlBenef.CampoProdutoID = hdfIdPrimeiroProduto; ctrlBenef.ValidarEspessura = false; ctrlBenef.BloquearBeneficiamentos = String.IsNullOrEmpty(hdfIdPrimeiroProduto.Value); ctrlBenef.MensagemBloqueioBenef = "Não é possível cadastrar beneficiamentos para o primeiro produto a ser cadastrado. " + "Após inserí-lo você poderá colocar os beneficiamentos através da opção de edição do produto."; if (dtvProduto.FindControl("txtCodInterno") != null && ((TextBox)dtvProduto.FindControl("txtCodInterno")).Text == String.Empty) { ((TextBox)dtvProduto.FindControl("txtCodInterno")).Text = ProdutoDAO.Instance.GetLastId(); } }
protected void ctrlBenef_Load(object sender, EventArgs e) { Glass.UI.Web.Controls.ctrlBenef benef = (Glass.UI.Web.Controls.ctrlBenef)sender; benef.CampoAltura = hdfAlturaCalc; benef.CampoEspessura = txtEspessura; benef.CampoLargura = txtLargura; benef.CampoQuantidade = txtQtde; benef.CampoTotalM2 = Beneficiamentos.UsarM2CalcBeneficiamentos ? lblTotM2Calc : lblTotM2; benef.CampoValorUnitario = txtValor; benef.CampoCusto = hdfCustoProd; benef.CampoProdutoID = txtCodProd; benef.CampoClienteID = hdfIdCliente; benef.CampoTipoEntrega = drpTipoEntrega; benef.CampoRevenda = chkRevenda; benef.CampoPercComissao = hdfPercComissao; }
protected void ctrlBenef_Load(object sender, EventArgs e) { Glass.UI.Web.Controls.ctrlBenef benef = (Glass.UI.Web.Controls.ctrlBenef)sender; GridViewRow linhaControle = benef.Parent.Parent as GridViewRow; string tipo = benef.ID.Contains("Troca_") ? "Troca_" : "Novo_"; string tipoCampo = tipo == "Troca_" && lkbInserir.Visible ? "lbl" : "txt"; benef.ValidarEspessura = tipoCampo != "lbl"; Control codProd = linhaControle.FindControl(tipo + tipoCampo + "CodProdIns"); Control txtAltura = linhaControle.FindControl(tipo + tipoCampo + "AlturaIns"); Control txtEspessura = linhaControle.FindControl(tipo + "txtEspessura"); Control txtLargura = linhaControle.FindControl(tipo + tipoCampo + "LarguraIns"); TextBox txtQuantidade = (TextBox)linhaControle.FindControl(tipo + "txtQtdeIns"); HiddenField hdfTipoEntrega = (HiddenField)dtvTroca.FindControl("hdfTipoEntrega"); Label lblTotalM2 = Beneficiamentos.UsarM2CalcBeneficiamentos ? (Label)linhaControle.FindControl(tipo + "lblTotM2CalcIns") : (Label)linhaControle.FindControl(tipo + "lblTotM2Ins"); Control txtValorIns = linhaControle.FindControl(tipo + tipoCampo + "ValorIns"); HiddenField hdfCliRevenda = (HiddenField)dtvTroca.FindControl("hdfCliRevenda"); HiddenField hdfIdCliente = (HiddenField)dtvTroca.FindControl("hdfIdCliente"); HiddenField hdfCustoProd = (HiddenField)linhaControle.FindControl(tipo + "hdfCustoProd"); benef.CampoAltura = txtAltura; benef.CampoEspessura = txtEspessura; benef.CampoLargura = txtLargura; benef.CampoQuantidade = txtQuantidade; benef.CampoTipoEntrega = hdfTipoEntrega; benef.CampoTotalM2 = lblTotalM2; benef.CampoCusto = hdfCustoProd; benef.CampoValorUnitario = txtValorIns; benef.CampoProdutoID = codProd; benef.CampoRevenda = hdfCliRevenda; benef.CampoClienteID = hdfIdCliente; benef.CampoAplicacaoID = linhaControle.FindControl(tipo + "hdfIdAplicacao"); benef.CampoProcessoID = linhaControle.FindControl(tipo + "hdfIdProcesso"); benef.CampoAplicacao = linhaControle.FindControl(tipo + "txtAplIns"); benef.CampoProcesso = linhaControle.FindControl(tipo + "txtProcIns"); }
protected void lnkInsProd_Click(object sender, EventArgs e) { Glass.UI.Web.Controls.ctrlBenef benef = (Glass.UI.Web.Controls.ctrlBenef)grdProdutos.FooterRow.FindControl("ctrlBenefInserir"); var produto = grdProdutos.FooterRow.FindControl("ctrlSelProd") as Glass.UI.Web.Controls.ctrlSelProduto; // Cria uma instância do ProdutosPedido Produto prod = ProdutoDAO.Instance.GetElement(produto.IdProd.GetValueOrDefault()); ProdutosCompra prodCompra = new ProdutosCompra(); prodCompra.IdCompra = Glass.Conversoes.StrParaUint(Request["IdCompra"]); prodCompra.Qtde = Glass.Conversoes.StrParaFloat(((TextBox)grdProdutos.FooterRow.FindControl("txtQtdeIns")).Text); prodCompra.Valor = Glass.Conversoes.StrParaDecimal(((TextBox)grdProdutos.FooterRow.FindControl("txtValorIns")).Text); prodCompra.IdProd = (uint)prod.IdProd; prodCompra.DescricaoItemGenerico = produto.DescricaoItemGenerico; prodCompra.Altura = Glass.Conversoes.StrParaFloat(((TextBox)grdProdutos.FooterRow.FindControl("txtAlturaIns")).Text); prodCompra.Largura = Glass.Conversoes.StrParaInt(((TextBox)grdProdutos.FooterRow.FindControl("txtLarguraIns")).Text); prodCompra.TotM = Glass.Conversoes.StrParaFloat(((TextBox)grdProdutos.FooterRow.FindControl("txtTotM2")).Text); prodCompra.Espessura = Glass.Conversoes.StrParaFloat(((TextBox)grdProdutos.FooterRow.FindControl("txtEspessura")).Text); prodCompra.Obs = ((TextBox)grdProdutos.FooterRow.FindControl("txtObsIns")).Text; prodCompra.Beneficiamentos = benef.Beneficiamentos; prodCompra.NaoCobrarVidro = ((CheckBox)grdProdutos.FooterRow.FindControl("chkNaoCobrarVidro")).Checked; try { ProdutosCompraDAO.Instance.Insert(prodCompra); grdProdutos.DataBind(); dtvCompra.DataBind(); grdProdutos.PageIndex = grdProdutos.PageCount - 1; } catch (Exception ex) { Glass.MensagemAlerta.ErrorMsg("Falha ao incluir produto na Compra.", ex, Page); return; } }
protected void ctrl_Benef_Load(object sender, EventArgs e) { Glass.UI.Web.Controls.ctrlBenef benef = (Glass.UI.Web.Controls.ctrlBenef)sender; GridViewRow linhaControle = benef.Parent.Parent as GridViewRow; Control dtvPedido = linhaControle.Parent; while (dtvPedido.ID != "mainTable") { dtvPedido = dtvPedido.Parent; } dtvPedido = dtvPedido.FindControl("dtvPedido"); var tipoPedido = PedidoDAO.Instance.GetTipoPedido(null, Conversoes.StrParaUint(Request["idPedido"])); Control codProd = null; if (linhaControle.FindControl("lbl_CodProdComposicaoIns") != null) { codProd = linhaControle.FindControl("lbl_CodProdComposicaoIns"); } else { codProd = linhaControle.FindControl("txt_CodProdComposicaoIns"); } TextBox txtAltura = (TextBox)linhaControle.FindControl("txt_AlturaComposicaoIns"); TextBox txtEspessura = (TextBox)linhaControle.FindControl("txt_EspessuraComposicao"); TextBox txtLargura = (TextBox)linhaControle.FindControl("txt_LarguraComposicaoIns"); HiddenField hdfPercComissao = (HiddenField)dtvPedido.FindControl("hdfPercComissao"); TextBox txtQuantidade = (TextBox)linhaControle.FindControl("txt_QtdeComposicaoIns"); HiddenField hdfTipoEntrega = (HiddenField)dtvPedido.FindControl("hdfTipoEntrega"); HiddenField hdfTotalM2 = null; if (!Beneficiamentos.UsarM2CalcBeneficiamentos) { if (linhaControle.FindControl("hdf_TotMComposicao") != null) { hdfTotalM2 = (HiddenField)linhaControle.FindControl("hdf_TotMComposicao"); } else if (linhaControle.FindControl("hdf_TotM2ComposicaoIns") != null) { hdfTotalM2 = (HiddenField)linhaControle.FindControl("hdf_TotM2ComposicaoIns"); } } else { if (linhaControle.FindControl("hdf_TotM2CalcComposicao") != null) { hdfTotalM2 = (HiddenField)linhaControle.FindControl("hdf_TotM2CalcComposicao"); } else if (linhaControle.FindControl("hdf_TotM2CalcComposicaoIns") != null) { hdfTotalM2 = (HiddenField)linhaControle.FindControl("hdf_TotM2CalcComposicaoIns"); } } TextBox txtValorIns = (TextBox)linhaControle.FindControl("txt_ValorComposicaoIns"); HiddenField hdfCliRevenda = (HiddenField)dtvPedido.FindControl("hdfCliRevenda"); HiddenField hdfIdCliente = (HiddenField)dtvPedido.FindControl("hdfIdCliente"); HiddenField hdfCustoProd = (HiddenField)linhaControle.FindControl("hdf_CustoProdComposicao"); benef.CampoAltura = txtAltura; benef.CampoEspessura = txtEspessura; benef.CampoLargura = txtLargura; benef.CampoPercComissao = hdfPercComissao; benef.CampoQuantidade = txtQuantidade; benef.CampoQuantidadeAmbiente = null; benef.CampoTipoEntrega = hdfTipoEntrega; benef.CampoTotalM2 = hdfTotalM2; benef.CampoValorUnitario = txtValorIns; benef.CampoCusto = hdfCustoProd; benef.CampoProdutoID = codProd; benef.CampoRevenda = hdfCliRevenda; benef.CampoClienteID = hdfIdCliente; benef.CampoAplicacaoID = linhaControle.FindControl("hdf_IdAplicacaoComposicao"); benef.CampoProcessoID = linhaControle.FindControl("hdf_IdProcessoComposicao"); benef.CampoAplicacao = linhaControle.FindControl("txt_AplComposicaoIns"); benef.CampoProcesso = linhaControle.FindControl("txt_ProcComposicaoIns"); benef.IdProdPed = IdProdPed; benef.TipoBenef = tipoPedido == Glass.Data.Model.Pedido.TipoPedidoEnum.MaoDeObraEspecial ? TipoBenef.MaoDeObraEspecial : TipoBenef.Venda; }
protected void lnk_InsProdComposicao_Click(object sender, ImageClickEventArgs e) { if (grdProdutosComposicao.PageCount > 1) { grdProdutosComposicao.PageIndex = grdProdutosComposicao.PageCount - 1; } Glass.UI.Web.Controls.ctrlBenef benef = (Glass.UI.Web.Controls.ctrlBenef)grdProdutosComposicao.FooterRow.FindControl("ctrl_BenefInserirComposicao"); GridViewRow linhaControle = benef.Parent.Parent as GridViewRow; Control mainTable = linhaControle.Parent; while (mainTable.ID != "mainTable") { mainTable = mainTable.Parent; } var dtvPedido = (DetailsView)mainTable.FindControl("dtvPedido"); var hdfIdAmbiente = (HiddenField)mainTable.FindControl("hdfIdAmbiente") != null ? ((HiddenField)mainTable.FindControl("hdfIdAmbiente")).Value : string.Empty; uint idPedido = Request["IdPedido"].StrParaUint(); int idProd = !string.IsNullOrEmpty(hdf_IdProdComposicao.Value) ? hdf_IdProdComposicao.Value.StrParaInt() : 0; string alturaString = ((TextBox)grdProdutosComposicao.FooterRow.FindControl("txt_AlturaComposicaoIns")).Text; string alturaRealString = ((HiddenField)grdProdutosComposicao.FooterRow.FindControl("hdf_AlturaRealComposicaoIns")).Value; string larguraString = ((TextBox)grdProdutosComposicao.FooterRow.FindControl("txt_LarguraComposicaoIns")).Text; Single altura = Glass.Conversoes.StrParaFloat(alturaString); Single alturaReal = Glass.Conversoes.StrParaFloat(alturaRealString); int largura = !String.IsNullOrEmpty(larguraString) ? Glass.Conversoes.StrParaInt(larguraString) : 0; string idProcessoStr = ((HiddenField)grdProdutosComposicao.FooterRow.FindControl("hdf_IdProcessoComposicao")).Value; string idAplicacaoStr = ((HiddenField)grdProdutosComposicao.FooterRow.FindControl("hdf_IdAplicacaoComposicao")).Value; string espessuraString = ((TextBox)grdProdutosComposicao.FooterRow.FindControl("txt_EspessuraComposicao")).Text; float espessura = !String.IsNullOrEmpty(espessuraString) ? Glass.Conversoes.StrParaFloat(espessuraString) : 0; bool redondo = ((CheckBox)benef.FindControl("Redondo_chkSelecao")) != null ? ((CheckBox)benef.FindControl("Redondo_chkSelecao")).Checked : false; float aliquotaIcms = Glass.Conversoes.StrParaFloat(((HiddenField)grdProdutosComposicao.FooterRow.FindControl("hdf_AliquotaIcmsProdComposicao")).Value.Replace('.', ',')); decimal valorIcms = Glass.Conversoes.StrParaDecimal(((HiddenField)grdProdutosComposicao.FooterRow.FindControl("hdf_ValorIcmsProdComposicao")).Value.Replace('.', ',')); float espBenef = 0; int? alturaBenef = null; int? larguraBenef = null; int tipoEntrega = Glass.Conversoes.StrParaInt(((HiddenField)dtvPedido.FindControl("hdfTipoEntrega")).Value); uint idCliente = Glass.Conversoes.StrParaUint(((HiddenField)dtvPedido.FindControl("hdfIdCliente")).Value); bool reposicao = bool.Parse(((HiddenField)dtvPedido.FindControl("hdfIsReposicao")).Value); // Cria uma instância do ProdutosPedido ProdutosPedido prodPed = new ProdutosPedido(); prodPed.IdPedido = idPedido; prodPed.Qtde = Glass.Conversoes.StrParaFloat(((TextBox)grdProdutosComposicao.FooterRow.FindControl("txt_QtdeComposicaoIns")).Text.Replace('.', ',')); prodPed.ValorVendido = Glass.Conversoes.StrParaDecimal(((TextBox)grdProdutosComposicao.FooterRow.FindControl("txt_ValorComposicaoIns")).Text); prodPed.PercDescontoQtde = ((Glass.UI.Web.Controls.ctrlDescontoQtde)grdProdutosComposicao.FooterRow.FindControl("ctrl_DescontoQtdeComposicao")).PercDescontoQtde; prodPed.ValorTabelaPedido = ProdutoDAO.Instance.GetValorTabela(idProd, tipoEntrega, idCliente, false, reposicao, prodPed.PercDescontoQtde, (int?)idPedido, null, null); prodPed.Altura = altura; prodPed.AlturaReal = alturaReal; prodPed.Largura = largura; prodPed.IdProd = (uint)idProd; prodPed.Espessura = espessura; prodPed.Redondo = redondo; if (!string.IsNullOrEmpty(hdfIdAmbiente)) { prodPed.IdAmbientePedido = Glass.Conversoes.StrParaUint(hdfIdAmbiente); } if (!String.IsNullOrEmpty(idAplicacaoStr)) { prodPed.IdAplicacao = Glass.Conversoes.StrParaUint(idAplicacaoStr); } if (!String.IsNullOrEmpty(idProcessoStr)) { prodPed.IdProcesso = Glass.Conversoes.StrParaUint(idProcessoStr); } prodPed.AliqIcms = aliquotaIcms; prodPed.ValorIcms = valorIcms; var idLoja = PedidoDAO.Instance.ObtemIdLoja(null, idPedido); var loja = LojaDAO.Instance.GetElement(idLoja); if (loja.CalcularIpiPedido && ClienteDAO.Instance.IsCobrarIpi(null, idCliente)) { prodPed.AliqIpi = ProdutoDAO.Instance.ObtemAliqIpi(prodPed.IdProd); } prodPed.AlturaBenef = alturaBenef; prodPed.LarguraBenef = larguraBenef; prodPed.EspessuraBenef = espBenef; prodPed.Beneficiamentos = benef.Beneficiamentos; prodPed.PedCli = ((TextBox)grdProdutosComposicao.FooterRow.FindControl("txt_PedCliComposicao")).Text; prodPed.IdProdPedParent = (uint?)IdProdPed; uint idProdPed = 0; try { // Se o pedido estiver diferente de ativo-ativo/conferência não permite inserir produtos var situacao = PedidoDAO.Instance.ObtemSituacao(null, prodPed.IdPedido); if (situacao != Glass.Data.Model.Pedido.SituacaoPedido.Ativo && situacao != Glass.Data.Model.Pedido.SituacaoPedido.AtivoConferencia) { MensagemAlerta.ShowMsg("Não é possível incluir produtos em pedidos que não estejam ativos.", Page); return; } // Insere o produto_pedido idProdPed = ProdutosPedidoDAO.Instance.InsertEAtualizaDataEntrega(prodPed); ((HiddenField)grdProdutosComposicao.FooterRow.FindControl("hdf_AlturaRealComposicaoIns")).Value = ""; if (Glass.Configuracoes.PedidoConfig.TelaCadastro.ManterCodInternoCampoAoInserirProduto) { Page.ClientScript.RegisterClientScriptBlock(typeof(string), "novoProd", "ultimoCodProd = '" + ProdutoDAO.Instance.GetCodInterno((int)idProd) + "';", true); } grdProdutosComposicao.DataBind(); var grdProdutos = grdProdutosComposicao.Parent; while (grdProdutos.ID != "grdProdutos") { grdProdutos = grdProdutos.Parent; } ((DetailsView)dtvPedido).DataBind(); ((GridView)grdProdutos).DataBind(); } catch (Exception ex) { Glass.MensagemAlerta.ErrorMsg("Falha ao incluir produto no Pedido.", ex, Page); return; } }
protected void ctrlBenef_Load(object sender, EventArgs e) { Glass.UI.Web.Controls.ctrlBenef benef = (Glass.UI.Web.Controls.ctrlBenef)sender; GridViewRow linhaControle = benef.Parent.Parent as GridViewRow; Control codProd = null; if (linhaControle.FindControl("lblCodProdIns") != null) { codProd = linhaControle.FindControl("lblCodProdIns"); } else { codProd = linhaControle.FindControl("txtCodProdIns"); } HiddenField hdfAlturaCalc = (HiddenField)linhaControle.FindControl("hdfAlturaCalcIns"); TextBox txtEspessura = (TextBox)linhaControle.FindControl("txtEspessura"); TextBox txtLargura = (TextBox)linhaControle.FindControl("txtLarguraIns"); HiddenField hdfPercComissao = (HiddenField)dtvPedido.FindControl("hdfPercComissao"); TextBox txtQuantidade = (TextBox)linhaControle.FindControl("txtQtdeIns"); HiddenField hdfTipoEntrega = (HiddenField)dtvPedido.FindControl("hdfTipoEntrega"); HiddenField hdfCustoProd = (HiddenField)linhaControle.FindControl("hdfCustoProd"); HiddenField hdfTotalM2 = null; if (!Beneficiamentos.UsarM2CalcBeneficiamentos) { if (linhaControle.FindControl("hdfTotM") != null) { hdfTotalM2 = (HiddenField)linhaControle.FindControl("hdfTotM"); } else if (linhaControle.FindControl("hdfTotM2Ins") != null) { hdfTotalM2 = (HiddenField)linhaControle.FindControl("hdfTotM2Ins"); } } else { if (linhaControle.FindControl("hdfTotM2Calc") != null) { hdfTotalM2 = (HiddenField)linhaControle.FindControl("hdfTotM2Calc"); } else if (linhaControle.FindControl("hdfTotM2CalcIns") != null) { hdfTotalM2 = (HiddenField)linhaControle.FindControl("hdfTotM2CalcIns"); } } Label lblValorIns = (Label)linhaControle.FindControl("lblValorIns"); HiddenField hdfCliRevenda = (HiddenField)dtvPedido.FindControl("hdfCliRevenda"); HiddenField hdfIdCliente = (HiddenField)dtvPedido.FindControl("hdfIdCliente"); benef.CampoAltura = hdfAlturaCalc; benef.CampoEspessura = txtEspessura; benef.CampoLargura = txtLargura; benef.CampoPercComissao = hdfPercComissao; benef.CampoQuantidade = txtQuantidade; benef.CampoTipoEntrega = hdfTipoEntrega; benef.CampoTotalM2 = hdfTotalM2; benef.CampoValorUnitario = lblValorIns; benef.CampoProdutoID = codProd; benef.CampoRevenda = hdfCliRevenda; benef.CampoClienteID = hdfIdCliente; benef.CampoAplicacaoID = linhaControle.FindControl("hdfIdAplicacao"); benef.CampoProcessoID = linhaControle.FindControl("hdfIdProcesso"); benef.CampoAplicacao = linhaControle.FindControl("txtAplIns"); benef.CampoProcesso = linhaControle.FindControl("txtProcIns"); benef.TipoBenef = PedidoDAO.Instance.GetTipoPedido(null, Conversoes.StrParaUint(Request["idPedido"])) == Glass.Data.Model.Pedido.TipoPedidoEnum.MaoDeObraEspecial ? TipoBenef.MaoDeObraEspecial : TipoBenef.Venda; }
protected void imgAdd_Click(object sender, ImageClickEventArgs e) { string tipo = ((WebControl)sender).ID.IndexOf("Troca_") > -1 ? "Troca_" : "Novo_"; uint idTrocaDevolucao = Glass.Conversoes.StrParaUint(Request["idTrocaDev"]); GridViewRow linha = tipo != "Troca_" ? grdProdutosNovos.FooterRow : grdProdutosTrocados.FooterRow; Glass.UI.Web.Controls.ctrlBenef benef = (Glass.UI.Web.Controls.ctrlBenef)linha.FindControl(tipo + "ctrlBenefInserir"); Glass.UI.Web.Controls.ctrlDescontoQtde desc = (Glass.UI.Web.Controls.ctrlDescontoQtde)linha.FindControl(tipo + "ctrlDescontoQtde"); string idProd = ((HiddenField)linha.FindControl(tipo + "hdfIdProd")).Value; string idProcesso = ((HiddenField)linha.FindControl(tipo + "hdfIdProcesso")).Value; string idAplicacao = ((HiddenField)linha.FindControl(tipo + "hdfIdAplicacao")).Value; string qtde = ((TextBox)linha.FindControl(tipo + "txtQtdeIns")).Text; string valorVendido = ((TextBox)linha.FindControl(tipo + "txtValorIns")).Text; string altura = ((TextBox)linha.FindControl(tipo + "txtAlturaIns")).Text; string alturaReal = ((HiddenField)linha.FindControl(tipo + "hdfAlturaRealIns")).Value; string largura = ((TextBox)linha.FindControl(tipo + "txtLarguraIns")).Text; string totM = ((Label)linha.FindControl(tipo + "lblTotM2Ins")).Text; string totM2Calc = ((Label)linha.FindControl(tipo + "lblTotM2CalcIns")).Text; string espessura = ((TextBox)linha.FindControl(tipo + "txtEspessura")).Text; bool alterarEstoque = ((CheckBox)linha.FindControl(tipo + "chkAlterarEstoque")).Checked; bool comDefeito = tipo == "Troca_" ? ((CheckBox)linha.FindControl(tipo + "chkComDefeito")).Checked : false; if (tipo != "Troca_") { ProdutoTrocaDevolucao novo = new ProdutoTrocaDevolucao(); novo.IdTrocaDevolucao = idTrocaDevolucao; novo.IdProd = !String.IsNullOrEmpty(idProd) ? Glass.Conversoes.StrParaUint(idProd) : 0; novo.IdProcesso = !String.IsNullOrEmpty(idProcesso) ? (uint?)Glass.Conversoes.StrParaUint(idProcesso) : null; novo.IdAplicacao = !String.IsNullOrEmpty(idAplicacao) ? (uint?)Glass.Conversoes.StrParaUint(idAplicacao) : null; novo.Qtde = !String.IsNullOrEmpty(qtde) ? float.Parse(qtde.Replace('.', ',')) : 0; novo.ValorVendido = Glass.Conversoes.StrParaDecimal(valorVendido); novo.Altura = !String.IsNullOrEmpty(altura) ? float.Parse(altura) : 0; novo.AlturaReal = !String.IsNullOrEmpty(alturaReal) ? float.Parse(alturaReal) : 0; novo.Largura = !String.IsNullOrEmpty(largura) ? Glass.Conversoes.StrParaInt(largura) : 0; novo.TotM = !String.IsNullOrEmpty(totM) ? float.Parse(totM) : 0; novo.TotM2Calc = !String.IsNullOrEmpty(totM2Calc) ? float.Parse(totM2Calc) : 0; novo.Espessura = !String.IsNullOrEmpty(espessura) ? Glass.Conversoes.StrParaFloat(espessura) : 0; novo.Redondo = benef.Redondo; novo.AlterarEstoque = alterarEstoque; novo.Beneficiamentos = benef.Beneficiamentos; novo.PercDescontoQtde = desc.PercDescontoQtde; ProdutoTrocaDevolucaoDAO.Instance.Insert(novo); } else { ProdutoTrocado novo = new ProdutoTrocado(); novo.IdTrocaDevolucao = idTrocaDevolucao; novo.IdProd = !String.IsNullOrEmpty(idProd) ? Glass.Conversoes.StrParaUint(idProd) : 0; novo.IdProcesso = !String.IsNullOrEmpty(idProcesso) ? (uint?)Glass.Conversoes.StrParaUint(idProcesso) : null; novo.IdAplicacao = !String.IsNullOrEmpty(idAplicacao) ? (uint?)Glass.Conversoes.StrParaUint(idAplicacao) : null; novo.Qtde = !String.IsNullOrEmpty(qtde) ? float.Parse(qtde.Replace('.', ',')) : 0; novo.ValorVendido = Glass.Conversoes.StrParaDecimal(valorVendido); novo.Altura = !String.IsNullOrEmpty(altura) ? float.Parse(altura) : 0; novo.AlturaReal = !String.IsNullOrEmpty(alturaReal) ? float.Parse(alturaReal) : 0; novo.Largura = !String.IsNullOrEmpty(largura) ? Glass.Conversoes.StrParaInt(largura) : 0; novo.TotM = !String.IsNullOrEmpty(totM) ? float.Parse(totM) : 0; novo.TotM2Calc = !String.IsNullOrEmpty(totM2Calc) ? float.Parse(totM2Calc) : 0; novo.Espessura = !String.IsNullOrEmpty(espessura) ? Glass.Conversoes.StrParaFloat(espessura) : 0; novo.Redondo = benef.Redondo; novo.AlterarEstoque = alterarEstoque; novo.ComDefeito = comDefeito; novo.Beneficiamentos = benef.Beneficiamentos; novo.PercDescontoQtde = desc.PercDescontoQtde; ProdutoTrocadoDAO.Instance.Insert(novo); } AtualizarItens(); }