コード例 #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();
        }
コード例 #2
0
 public VendaCabecalhoDTO salvarAtualizarVendaCabecalho(VendaCabecalhoDTO vendaCabecalho)
 {
     try
     {
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             VendaDAL DAL = new VendaDAL(session);
             DAL.saveOrUpdate(vendaCabecalho);
             session.Flush();
         }
         return(vendaCabecalho);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
コード例 #3
0
 public IList <VendaCabecalhoDTO> selectVendaCabecalho(VendaCabecalhoDTO vendaCabecalho)
 {
     try
     {
         IList <VendaCabecalhoDTO> resultado = null;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             VendaDAL DAL = new VendaDAL(session);
             resultado = DAL.select(vendaCabecalho);
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
コード例 #4
0
 public int deleteVendaCabecalho(VendaCabecalhoDTO vendaCabecalho)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             VendaDAL DAL = new VendaDAL(session);
             DAL.delete(vendaCabecalho);
             session.Flush();
             resultado = 0;
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
コード例 #5
0
 public new List <VendaCabecalhoDTO> selectVendaCabecalho(VendaCabecalhoDTO dtoPesquisa)
 {
     return(base.selectVendaCabecalho(dtoPesquisa));
 }