Exemplo n.º 1
0
 public void cargarPedidoDetalle()
 {
     try
     {
         string cartJson = "";
         if (!string.IsNullOrEmpty(CarritoId) && !CarritoId.Equals("0"))
         {
             cartJson = CarritoBLL.GetCarritoById(CarritoId).Contenido;
         }
         else
         {
             return;
         }
         if (cartJson != null)
         {
             JavaScriptSerializer js = new JavaScriptSerializer();
             Dictionary <string, DatorProductoCarrito> carrito = js.Deserialize <Dictionary <string, DatorProductoCarrito> >(cartJson);
             DetallePedidoGridView.DataSource = carrito.Values;
             DetallePedidoGridView.DataBind();
         }
         else
         {
             return;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
    public void cargarFactura()
    {
        int facturaId = Convert.ToInt32(Session["FacturaId"]);

        //int facturaId = 11;
        try
        {
            int ventaId = cargarQRCode(facturaId);

            List <Pedido> listaPedido = PedidoBLL.GetPedidoListForSearch("p.[ventaId]in (" + ventaId + ")");
            string        cartJson    = "";
            if (!string.IsNullOrEmpty(listaPedido[0].CarritoId))
            {
                cartJson = CarritoBLL.GetCarritoById(listaPedido[0].CarritoId).Contenido;
            }
            JavaScriptSerializer js = new JavaScriptSerializer();
            Dictionary <string, DatorProductoCarrito> carrito = js.Deserialize <Dictionary <string, DatorProductoCarrito> >(cartJson);
            pedidoRepeater.DataSource = carrito.Values;
            pedidoRepeater.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemplo n.º 3
0
 public static bool GetCarritoIdForUsuarioIniciado(int userId, HttpContext context)
 {
     try
     {
         bool   existeCarrito = false;
         string carritoId     = "";
         FoodGood.Carrito.Carrito objCarrito = CarritoBLL.GetCarritoByIdUsurio(userId);
         if (objCarrito != null)
         {
             carritoId = objCarrito.CarritoId;
             string     cookieName = "FoodGoodCartId";
             HttpCookie cookie     = context.Request.Cookies[cookieName];
             if (cookie == null)
             {
                 cookie         = new HttpCookie(cookieName, carritoId);
                 cookie.Expires = DateTime.Now.AddDays(365);
                 context.Response.Cookies.Add(cookie);
             }
             else
             {
                 try
                 {
                     string valorLogin       = LoginUtilities.ObtenerLoginCookies();
                     JavaScriptSerializer js = new JavaScriptSerializer();
                     Dictionary <string, DatorProductoCarrito> carritoNuevo   = PedidoUtilities.GetCarrito();
                     Dictionary <string, DatorProductoCarrito> carritoAntiguo = js.Deserialize <Dictionary <string, DatorProductoCarrito> >(objCarrito.Contenido);
                     foreach (KeyValuePair <string, DatorProductoCarrito> recorrido in carritoAntiguo)
                     {
                         if (!carritoNuevo.ContainsKey(recorrido.Key))
                         {
                             carritoNuevo.Add(recorrido.Key, recorrido.Value);
                             UpdateCarrito(carritoNuevo);
                         }
                     }
                     CarritoBLL.DeleteCarrito(objCarrito.CarritoId);
                 }
                 catch (Exception ex)
                 {
                     //error fucionar las lista de articulos de carrito
                     throw ex;
                 }
             }
             //string cookieEmailName = "KomodoSuscription";
             //HttpCookie cookieEmail = context.Request.Cookies[cookieEmailName];
             //if (cookieEmail == null)
             //{
             //    cookie = new HttpCookie(cookieEmailName, cookieEmailName);
             //    cookie.Expires = DateTime.Now.AddDays(365);
             //    context.Response.Cookies.Add(cookie);
             //}
             existeCarrito = true;
         }
         return(existeCarrito);
     }
     catch (Exception ex)
     { throw ex; }
 }
 public ActionResult Edit([Bind(Include = "car_id,cln_id,car_tipo")] Carrito carrito)
 {
     if (ModelState.IsValid)
     {
         CarritoBLL.Update(carrito);
         return(RedirectToAction("Index"));
     }
     ViewBag.cln_id = new SelectList(ClienteBLL.List(), "cln_id", "cln_tipo", carrito.cln_id);
     return(View(carrito));
 }
 public ActionResult Edit([Bind(Include = "crf_id,cbf_id,car_id")] CuerpoFactura cuerpoFactura)
 {
     if (ModelState.IsValid)
     {
         CuerpoFacturaBLL.Update(cuerpoFactura);
         return(RedirectToAction("Index"));
     }
     ViewBag.cbf_id = new SelectList(CabezaFacturaBLL.List(), "cbf_id", "cbf_id", cuerpoFactura.cbf_id);
     ViewBag.car_id = new SelectList(CarritoBLL.List(), "car_id", "car_tipo", cuerpoFactura.car_id);
     return(View(cuerpoFactura));
 }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "pcr_id,car_id,prd_id,pcr_est,prd_cnt,pcr_dateOfCreated")] ProductoEnCarrito productoEnCarrito)
 {
     if (ModelState.IsValid)
     {
         ProductoEnCarritoBLL.Update(productoEnCarrito);
         return(RedirectToAction("Index"));
     }
     ViewBag.car_id = new SelectList(CarritoBLL.List(), "car_id", "car_tipo", productoEnCarrito.car_id);
     ViewBag.prd_id = new SelectList(ProductoBLL.List(), "prd_id", "prd_nom", productoEnCarrito.prd_id);
     return(View(productoEnCarrito));
 }
Exemplo n.º 7
0
 public IHttpActionResult MisCarritosPagados(int id)
 {
     try
     {
         List <Carrito> carritos = CarritoBLL.ObtenerCarritosPagados(id);
         return(Content(HttpStatusCode.OK, carritos));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message + id.ToString()));
     }
 }
Exemplo n.º 8
0
 public IHttpActionResult MiCarritoPendiente(int id)
 {
     try
     {
         Carrito carrito = CarritoBLL.ObtenerCarritoPendiente(id);
         return(Content(HttpStatusCode.OK, carrito));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message + id.ToString()));
     }
 }
Exemplo n.º 9
0
 public IHttpActionResult Put(Carrito carrito)
 {
     try
     {
         CarritoBLL.Update(carrito);
         return(Content(HttpStatusCode.Accepted, "Carrito actualizado correctamente"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message + carrito.ToString()));
     }
 }
Exemplo n.º 10
0
 public IHttpActionResult Get(int id)
 {
     try
     {
         Carrito carrito = CarritoBLL.Get(id);
         return(Content(HttpStatusCode.OK, carrito));
     }
     catch (Exception)
     {
         return(NotFound());
     }
 }
Exemplo n.º 11
0
    public static Carrito InsertarCarrito(string idOrdenCompra, string idProducto, string cantidadProducto,
                                          string precio, string subTotal)
    {
        Carrito objCarrito = CarritoBLL.InsertWithReturn(idOrdenCompra, idProducto, cantidadProducto,
                                                         precio, subTotal);
        Producto objProducto = ProductoBLL.SelectById(Convert.ToInt32(idProducto));
        int      stock       = objProducto.Stock;

        stock = stock - Convert.ToInt32(cantidadProducto);
        ProductoBLL.UpdateStock(idProducto, stock);
        return(objCarrito);
    }
        // GET: Carritos/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Carrito carrito = CarritoBLL.Get(id);

            if (carrito == null)
            {
                return(HttpNotFound());
            }
            return(View(carrito));
        }
Exemplo n.º 13
0
        public static void UpdateCarrito(Dictionary <string, DatorProductoCarrito> carrito, HttpContext context)
        {
            try
            {
                string cartId = obtenerIdCarrito(context);

                //FoodGood.Carrito.Carrito cartTemp = CarritoBLL.GetCarritoById(cartId);
                //if (cartTemp.conservarCarrito)
                //{
                //    CloneAndRemoveOldCart(cartTemp.Email, cartTemp.UserId);
                //    return;
                //}

                JavaScriptSerializer js = new JavaScriptSerializer();
                string jsonCart         = js.Serialize(carrito);

                //TODO: Actualizar carrito en la base de datos

                //string email = null;
                int?usuarioId = null;

                //if (!string.IsNullOrEmpty(SuscripcionUtilities.GetCorreoSuscripto()))
                //{
                //    email = SuscripcionUtilities.GetCorreoSuscripto();
                //}
                //if (context.User.Identity.IsAuthenticated)
                //{
                //    usuarioId = UserBLL.GetUserByUsername(context.User.Identity.Name).UserId;
                //    email = UserBLL.GetUserByUsername(context.User.Identity.Name).Email;
                //}

                string clave = LoginUtilities.ObtenerLoginCookies();
                FoodGood.Usuario.Usuario user = LoginUtilities.LoginUser(clave);
                if (user != null)
                {
                    usuarioId = user.UsuarioId;
                }

                FoodGood.Carrito.Carrito obj = new FoodGood.Carrito.Carrito();
                obj.CarritoId = cartId;
                obj.UsuarioId = usuarioId;
                obj.Contenido = jsonCart;
                obj.Fecha     = DateTime.Now;

                CarritoBLL.UpdateCarrtio(obj);
            }
            catch (Exception ex)
            { log.Error("Error al actualizar el carrito en la base de datos", ex); }
        }
        // GET: Carritos/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Carrito carrito = CarritoBLL.Get(id);

            if (carrito == null)
            {
                return(HttpNotFound());
            }
            ViewBag.cln_id = new SelectList(ClienteBLL.List(), "cln_id", "cln_tipo", carrito.cln_id);
            return(View(carrito));
        }
Exemplo n.º 15
0
        // GET: ProductoEnCarritos/Details/5
        public ActionResult AddCarrito(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ViewBag.car_id = new SelectList(CarritoBLL.List(), "car_id", "car_tipo");
            Producto producto = ProductoBLL.Get(id);

            ViewBag.producto = producto;
            if (producto == null)
            {
                return(HttpNotFound());
            }
            return(View());
        }
        // GET: CuerpoFacturas/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CuerpoFactura cuerpoFactura = CuerpoFacturaBLL.Get(id);

            if (cuerpoFactura == null)
            {
                return(HttpNotFound());
            }
            ViewBag.cbf_id = new SelectList(CabezaFacturaBLL.List(), "cbf_id", "cbf_id", cuerpoFactura.cbf_id);
            ViewBag.car_id = new SelectList(CarritoBLL.List(), "car_id", "car_tipo", cuerpoFactura.car_id);
            return(View(cuerpoFactura));
        }
Exemplo n.º 17
0
        // GET: ProductoEnCarritos/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductoEnCarrito productoEnCarrito = ProductoEnCarritoBLL.Get(id);
            Producto          producto          = ProductoBLL.Get(productoEnCarrito.prd_id);

            if (productoEnCarrito == null)
            {
                return(HttpNotFound());
            }
            ViewBag.car_id   = new SelectList(CarritoBLL.List(), "car_id", "car_tipo", productoEnCarrito.car_id);
            ViewBag.prd_id   = new SelectList(ProductoBLL.List(), "prd_id", "prd_nom", productoEnCarrito.prd_id);
            ViewBag.cantidad = producto.prd_cnt + productoEnCarrito.prd_cnt;
            return(View(productoEnCarrito));
        }
Exemplo n.º 18
0
        public static Dictionary <string, DatorProductoCarrito> GetCarrito()
        {
            try
            {
                string cartId   = obtenerIdCarrito();
                string cartJson = "{}";
                //TODO: Obtener carrito en JSON de la base de datos
                if (!string.IsNullOrEmpty(cartId))
                {
                    cartJson = CarritoBLL.GetCarritoById(cartId).Contenido;
                }

                JavaScriptSerializer js = new JavaScriptSerializer();
                Dictionary <string, DatorProductoCarrito> carrito = js.Deserialize <Dictionary <string, DatorProductoCarrito> >(cartJson);
                return(carrito);
            }
            catch (Exception ex)
            { log.Error("Error al obtener el carrito de la base de datos", ex); return(null); }
        }
 // GET: CuerpoFacturas/Create
 public ActionResult Create()
 {
     ViewBag.cbf_id = new SelectList(CabezaFacturaBLL.List(), "cbf_id", "cbf_id");
     ViewBag.car_id = new SelectList(CarritoBLL.List(), "car_id", "car_tipo");
     return(View());
 }
 // GET: Carritos
 public ActionResult Index()
 {
     return(View(CarritoBLL.List()));
 }
 public ActionResult DeleteConfirmed(int id)
 {
     CarritoBLL.Delete(id);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 22
0
        public static string SetupShoppingCart(HttpContext context)
        {
            string cookieName = "FoodGoodCartId";

            string userName = context.User.Identity.Name;
            string guid     = "";
            //if (string.IsNullOrEmpty(userName))
            //{
            HttpCookie cookie = context.Request.Cookies[cookieName];

            if (cookie == null)
            {
                guid           = Guid.NewGuid().ToString();
                cookie         = new HttpCookie(cookieName, guid);
                cookie.Expires = DateTime.Now.AddDays(365);
                context.Response.Cookies.Add(cookie);
                try
                {
                    FoodGood.Carrito.Carrito obj = new FoodGood.Carrito.Carrito();
                    obj.CarritoId = guid;
                    //obj.UsuarioId =
                    obj.Contenido = "{}";
                    obj.Fecha     = DateTime.Now;
                    CarritoBLL.InsertCarrito(obj);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                guid = cookie.Value;
            }
            //}
            //else
            //{
            //    //TODO: Obenter el GUID del carrito para el usuario logueado
            //    guid = "";
            //    HttpCookie cookie = context.Request.Cookies[cookieName];

            //    if (string.IsNullOrEmpty(guid))
            //    {
            //        guid = new Guid().ToString();
            //    }
            //    else
            //    {
            //        string oldGuid = "";
            //        if (cookie != null)
            //            oldGuid = cookie.Value;

            //        if (!string.IsNullOrEmpty(oldGuid))
            //        {
            //            //TODO: Eliminar el carrito asignado a este usua
            //        }

            //    }

            //    if (cookie != null)
            //    {
            //        context.Response.Cookies.Remove(cookieName);
            //    }
            //    cookie = new HttpCookie(cookieName, guid);
            //    cookie.Expires = DateTime.Now.AddDays(365);
            //    context.Response.Cookies.Add(cookie);
            //}

            return(guid);
        }
Exemplo n.º 23
0
        //public static bool GetCarritoEnCuotas()
        //{
        //    try
        //    {
        //        string cartId = obtenerIdCarrito();
        //        bool value = false;
        //        //TODO: Obtener valor de la base de datos
        //        if (!string.IsNullOrEmpty(cartId))
        //            value = CarritoBLL.GetCarritoById(cartId).EnCuotas;
        //        //
        //        return value;
        //    }
        //    catch (Exception ex)
        //    { log.Error("Error al obtener el estado del carrito", ex); return false; }
        //}

        public static void SearchAndUpdateCarrito(string carritoId)
        {
            try
            {
                string cookieName   = "FoodGoodCartId";
                bool   cookieExists = HttpContext.Current.Request.Cookies[cookieName] != null;
                if (!cookieExists)
                {
                    PedidoUtilities.SetupShoppingCart();
                }
                JavaScriptSerializer js = new JavaScriptSerializer();
                Dictionary <string, DatorProductoCarrito> carrito = js.Deserialize <Dictionary <string, DatorProductoCarrito> >(CarritoBLL.GetCarritoById(carritoId).Contenido);
                UpdateCarrito(carrito);
            }
            catch (Exception ex)
            { log.Error("Error en SearchAndUpdateCarrito, busqueda y actualizacion de carrito", ex); }
        }
Exemplo n.º 24
0
    //[WebMethod]
    public void hacerElPedidoVentaYfactura(int tipoPago)
    {
        DateTime fechaPedido = DateTime.Now;

        try
        {
            string  nombreCliente   = txtNombreFactura.Text;
            string  apellidoCliente = TextApellido.Text;
            int     numNit          = Convert.ToInt32(txtNit.Text);
            string  montoFormateado = TotalLiteral.Text.Replace(".", ",");
            decimal montoTotal      = Convert.ToDecimal(montoFormateado);
            decimal latitud         = GpsSelectorControl.Latitud;
            decimal longitud        = GpsSelectorControl.Longitud;
            try
            {
                Venta objVenta = new Venta();
                objVenta.NombreCliente   = nombreCliente;
                objVenta.ApellidoCliente = apellidoCliente;
                objVenta.Nit             = numNit;
                objVenta.MontoTotal      = montoTotal;
                objVenta.PagoTotal       = montoTotal;
                objVenta.MontoCambio     = 0;
                objVenta.MontoDescuento  = 0;
                objVenta.FechaPedido     = fechaPedido;
                //objVenta.FechaEntrega = null;
                //objVenta.FechaAnulacion = ;
                objVenta.Estado   = Resources.InitMasterPage.PendienteEnvio;
                objVenta.Latitud  = latitud;
                objVenta.Longitud = longitud;
                int ventaIdInsertado = InsertVenta(objVenta);
                ventaIdHiddenfiel.Value = ventaIdInsertado.ToString();
                //escribirvalor.Text = ventaIdInsertado.ToString();
                try
                {
                    string  carritoId  = PedidoUtilities.obtenerIdCarrito();
                    Usuario objUsuario = LoginUtilities.GetUserLogged();
                    Pedido  objPedido  = new Pedido();
                    objPedido.UsuarioId       = objUsuario.UsuarioId;
                    objPedido.DepartamentoId  = Convert.ToInt32(CiudadComboBox.SelectedValue);
                    objPedido.Direccion       = DireccionTextBox.Text;
                    objPedido.NombreCliente   = nombreCliente;
                    objPedido.ApellidoCliente = apellidoCliente;
                    objPedido.Nit             = numNit;
                    objPedido.FechaPedido     = fechaPedido;
                    objPedido.CarritoId       = carritoId;
                    objPedido.TipoPago        = tipoPago;
                    objPedido.VentaId         = ventaIdInsertado;
                    objPedido.MontoTotal      = montoTotal;
                    objPedido.Latitud         = latitud;
                    objPedido.Longitud        = longitud;

                    //completar el llenado del objeto Factura con la ventaId y el codigo de contrcon la lista de disificacion



                    int pedidoId = insertPedido(objPedido);
                    pedidoIdHiddenField.Value = pedidoId.ToString();
                    if (tipoPago == 2)
                    {
                        int FacturaId = hacerFacturaPagaTerminada(ventaIdInsertado);
                        FacturaIdInsertadoHiddenField.Value = FacturaId.ToString();

                        CargarResumenPedido(pedidoId);
                    }
                    if (tipoPago == 1 || tipoPago == 3)
                    {
                        pagarCreditoTarjeta(montoTotal, ventaIdInsertado, objUsuario.UsuarioId, fechaPedido);
                    }
                    CarritoBLL.UpdateCarrtioADeshabilitado(PedidoUtilities.obtenerIdCarrito());
                    PedidoUtilities.borrarCarritoIdCookie();
                    if (tipoPago == 3)
                    {
                        verFactura.Visible = false;
                        //Response.Redirect("~/Carrito.aspx");
                        //return;
                    }

                    //string carritoIdCookie = PedidoUtilities.obtenerIdCarrito;
                    //PedidoBLL.UpdatePedVentFactura(pedidoId);


                    //ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", @"alert('tu pedido ha sido exitoso ')", true);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemplo n.º 25
0
 // GET: ProductoEnCarritos/Create
 public ActionResult Create()
 {
     ViewBag.car_id = new SelectList(CarritoBLL.List(), "car_id", "car_tipo");
     ViewBag.prd_id = new SelectList(ProductoBLL.List(), "prd_id", "prd_nom");
     return(View());
 }