Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            VendaAtual = (VendaCabecalhoDTO)Session["VendaCabecalho"];
            if (VendaAtual.ListaVendaDetalhe == null)
            {
                VendaAtual.ListaVendaDetalhe = new List <VendaDetalheDTO>();
            }

            if (Request.QueryString["id_produto"] != null)
            {
                using (ServidorClient Servico = new ServidorClient())
                {
                    /// EXERCICIO: implemente a persistencia dos dados da venda
                    ///
                    ProdutoDTO produto = new ProdutoDTO();
                    produto.Id = int.Parse(Request.QueryString["id_produto"]);
                    produto    = Servico.SelectProdutoId(produto);

                    VendaAtual.ListaVendaDetalhe.Add(new VendaDetalheDTO());
                    VendaAtual.ListaVendaDetalhe[VendaAtual.ListaVendaDetalhe.Count - 1].Produto = produto;

                    if (VendaAtual.ValorTotal == null)
                    {
                        VendaAtual.ValorTotal = produto.ValorVenda;
                    }
                    else
                    {
                        VendaAtual.ValorTotal = VendaAtual.ValorTotal + produto.ValorVenda;
                    }
                }
            }

            Session["VendaCabecalho"] = VendaAtual;

            LabelMensagens.Text = "";
            AdicionarCabecalho();
            //

            if (Session["IdColaborador"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                if (Session["UsuarioAdministrador"].ToString() != "S")
                {
                    Response.Redirect("SemAcesso.aspx");
                }

                LabelTitulo.Text = "Cliente Logado: " + Session["UsuarioNome"].ToString();
            }

            //
            LabelTitulo.Text = "Cliente Logado: " + Session["UsuarioNome"].ToString();

            CarregarDados();
        }