protected void txtEspessura_DataBinding(object sender, EventArgs e) { TextBox txt = (TextBox)sender; GridViewRow linhaControle = txt.Parent.Parent as GridViewRow; string tipo = txt.ID.IndexOf("Troca_") > -1 ? "Troca_" : "Novo_"; if (tipo != "Troca_") { ProdutoTrocaDevolucao prodTroca = linhaControle.DataItem as ProdutoTrocaDevolucao; txt.Enabled = prodTroca.Espessura <= 0; } else { ProdutoTrocado prodTroca = linhaControle.DataItem as ProdutoTrocado; txt.Enabled = prodTroca.Espessura <= 0; } }
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(); }