Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string idusuario = HttpContext.Current.Session["UsuarioID"].ToString();

            Modelos.Carrito car             = new Modelos.Carrito();
            DataTable       dvtCarrito      = car.todosResgistros(idusuario);
            int             id_producto     = Convert.ToInt32(dvtCarrito.Rows[0]["id_producto"].ToString());
            string          nombre_producto = dvtCarrito.Rows[0]["nombre_producto"].ToString();
            int             cantidad        = Convert.ToInt32(dvtCarrito.Rows[0]["cantidad"].ToString());
            float           precio          = float.Parse(dvtCarrito.Rows[0]["precio"].ToString());
            string          fecha           = dvtCarrito.Rows[0]["fecha"].ToString();
            double          sub_total       = Convert.ToDouble(dvtCarrito.Rows[0]["total"].ToString()) / 1.16;
            double          iva             = sub_total * 0.16;
            float           total           = float.Parse(Session["total"].ToString());
            int             usuario         = Convert.ToInt32(idusuario);

            Modelos.Ventas.agregarVenta(fecha, usuario, sub_total, iva, total);

            Modelos.Ventas ven = new Modelos.Ventas();

            DataTable dvtventas = ven.ventas(idusuario);
            int       id_venta  = Convert.ToInt32(dvtventas.Rows[0]["id_venta"].ToString());

            Modelos.DetalleVenta.agregarDetalleVenta(id_venta, cantidad, id_producto, precio, total);

            Modelos.Productos pro          = new Modelos.Productos();
            DataTable         dvtProductos = pro.buscarProducto(Convert.ToString(id_producto));
            int existencia = Convert.ToInt32(dvtProductos.Rows[0]["existencia"].ToString());

            pro.actualizarExistencia(existencia, cantidad, id_producto);
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         string          idusuario = HttpContext.Current.Session["UsuarioID"].ToString();
         Modelos.Carrito car       = new Modelos.Carrito();
         Listado.DataSource = car.todosResgistros(idusuario);
         Listado.DataBind();
         lblTotal.Text = Session["total"].ToString();
     }
     catch
     {
         Response.Write("Necesitas iniciar sesion para entrar al carrito");
     }
 }