Пример #1
0
        private void CargarGrillaUltimosPedidos()
        {
            usuarioentidad = (UsuarioEntidad)Current.Session["Usuario"];
            PedidosaMostrar.Clear();

            PedidosEntidad = pedidoCore.SelectAllByCUIT(usuarioentidad.CUIT);

            if (PedidosEntidad.Count == 0)
            {
                sinpedidos.InnerHtml = "<strong>No existen pedidos.</a>";
            }
            else
            {
                contenedorsinpedidos.Visible = false;
            }



            for (int i = 0; i < PedidosEntidad.Count; i++)
            {
                PedidoDTO PedidoAMostrar = new PedidoDTO();
                PedidoAMostrar.cuit = PedidosEntidad[i].miUsuario.CUIT;
                DireccionEntidad DireccionEntrega = DireccionCore.DireccionSelect(PedidosEntidad[i].miDireccionEntrega.IdDireccion);
                PedidoAMostrar.DireccionEntrega = DireccionEntrega.Calle + " " + DireccionEntrega.Numero + ". " + DireccionEntrega.Localidad;
                PedidoAMostrar.FechaPedido      = PedidosEntidad[i].FechaPedido;
                PedidoAMostrar.IdPedido         = PedidosEntidad[i].IdPedido;
                PedidoAMostrar.NombreUsuario    = PedidosEntidad[i].miUsuario.NombreUsuario;
                PedidoAMostrar.NroPedido        = PedidosEntidad[i].NroPedido;

                //PedidoEstadoPedidoEntidad Estado = pedidoCore.PedidoUltimoEstadoSelect(PedidosEntidad[i].IdPedido);
                //EstadoPedidoEntidad EstadoPedido = pedidoCore.EstadoPedidoSelect(Estado.IdEstadoPedido);

                PedidoAMostrar.Estado = PedidosEntidad[i].VerEstadoActual().DescripcionEstadoPedido;
                //PedidoAMostrar.Estado = EstadoPedido.DescripcionEstadoPedido;
                PedidosDetalle       = pedidoCore.PedidosDetalleSelect(PedidosEntidad[i].IdPedido);
                PedidoAMostrar.Total = MontoTotalPorPedido(PedidosDetalle);
                PedidosaMostrar.Add(PedidoAMostrar);
            }

            grilladeultimospedidos.DataSource = null;
            PedidosaMostrar = (List <PedidoDTO>)PedidosaMostrar.OrderByDescending(X => X.NroPedido).ToList();
            grilladeultimospedidos.DataSource = PedidosaMostrar;
            grilladeultimospedidos.DataBind();
            //ddlEstadoPedido.DataSource = pedidoCore.EstadoPedidoSelectAll();

            //ddlEstadoPedido.DataValueField = "IdEstadoPedido";
            //ddlEstadoPedido.DataTextField = "DescripcionEstadoPedido";
            //ddlEstadoPedido.DataBind();
        }
        public static bool PagarWebMethod()
        {
            ComprobanteEntidad unComprobante = new ComprobanteEntidad();

            unComprobante.Detalles = new List <ComprobanteDetalleEntidad>();
            ComprobanteCore unManagerComprobante = new ComprobanteCore();
            PedidoCore      unManagerPedido      = new PedidoCore();
            SucursalCore    ManagerSucursal      = new SucursalCore();
            int             IdPedidoActual;

            List <PedidoDetalleEntidad> unosDetallesPedido = new List <PedidoDetalleEntidad>();
            var Current = HttpContext.Current;

            UsuarioEntidad logueado   = (UsuarioEntidad)Current.Session["Usuario"];
            var            sucursalId = (int?)Current.Session["Seleccionada"];

            IdPedidoActual = (int)Current.Session["UltimoPedido"];

            unosDetallesPedido = (List <PedidoDetalleEntidad>)Current.Session["DetallesPedido"];

            PedidoEntidad unPedidoPagar = new PedidoEntidad();

            unPedidoPagar             = unManagerPedido.PedidoSelectByCUIT_IDPedido(IdPedidoActual);
            unPedidoPagar.misDetalles = unManagerPedido.PedidosDetalleSelect(unPedidoPagar.IdPedido);
            SucursalEntidad unaSucursal = ManagerSucursal.SucursalTraerPorDireccionSucursal(unPedidoPagar.miDireccionEntrega.IdDireccion);

            TarjetaEntidad        unaTarjeta  = new TarjetaEntidad();
            TarjetaCore           coreTarjeta = new TarjetaCore();
            List <TarjetaEntidad> MisTarjetas = coreTarjeta.SelectAllTarjetasByCUIT_NombreUsuario(ConfigSection.Default.Site.Cuit, logueado.NombreUsuario);

            foreach (var t in MisTarjetas)
            {
                if (t.Predeterminada == true)
                {
                    unaTarjeta = t;
                }
            }

            if (unManagerPedido.PagarPedido(unaTarjeta.Numero.ToString(), unaTarjeta.CodSeguridad, (decimal)unPedidoPagar.misDetalles.Select(x => x.Cantidad * x.PrecioUnitario).Sum()))
            {
                unManagerPedido.AvanzarPaso(unPedidoPagar, unaSucursal, logueado, (int)FormaPagoEntidad.Options.ECommerce);
                LimpiarPedido();
                return(true);
            }
            LimpiarPedido();
            return(false);



            //Response.Redirect("/Areas/Public/Forms/UltimosPedidos.aspx");
        }
Пример #3
0
        public static bool PagarWebMethod()
        {
            //Obtener NroPedido seleccionado
            var   Current     = HttpContext.Current;
            Int64 unNroPedido = Int64.Parse(Current.Session["NroPedidoDesdeUltimosPedidos"].ToString());
            //Preparar variables para generar factura
            PedidoCore     unManagerPedido = new PedidoCore();
            PedidoEntidad  unPedidoPagar   = new PedidoEntidad();
            SucursalCore   ManagerSucursal = new SucursalCore();
            UsuarioEntidad logueado        = new UsuarioEntidad();

            logueado = (UsuarioEntidad)Current.Session["Usuario"];

            unPedidoPagar             = unManagerPedido.PedidoSelectByCUIT_NroPedido(unNroPedido);
            unPedidoPagar.misDetalles = unManagerPedido.PedidosDetalleSelect(unPedidoPagar.IdPedido);
            SucursalEntidad unaSucursal = ManagerSucursal.SucursalTraerPorDireccionSucursal(unPedidoPagar.miDireccionEntrega.IdDireccion);

            TarjetaEntidad        unaTarjeta  = new TarjetaEntidad();
            TarjetaCore           coreTarjeta = new TarjetaCore();
            List <TarjetaEntidad> MisTarjetas = coreTarjeta.SelectAllTarjetasByCUIT_NombreUsuario(ConfigSection.Default.Site.Cuit, logueado.NombreUsuario);

            foreach (var t in MisTarjetas)
            {
                if (t.Predeterminada == true)
                {
                    unaTarjeta = t;
                }
            }

            if (unManagerPedido.PagarPedido(unaTarjeta.Numero.ToString(), unaTarjeta.CodSeguridad, (decimal)unPedidoPagar.misDetalles.Select(x => x.Cantidad * x.PrecioUnitario).Sum()))
            {
                unManagerPedido.AvanzarPaso(unPedidoPagar, unaSucursal, logueado, (int)FormaPagoEntidad.Options.ECommerce);
                return(true);
            }
            return(false);

            //LimpiarPedido();
        }
Пример #4
0
        protected void grilladeultimospedidos_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            ProductoCore coreProducto = new ProductoCore();

            if (e.CommandName.Equals("VerDetalle"))
            {
                int           index     = Convert.ToInt32(e.CommandArgument);
                string        code      = grilladeultimospedidos.DataKeys[index].Value.ToString();
                PedidoEntidad PedidoRow = pedidoCore.PedidoSelectByCUIT_NroPedidoCliente(logueado.CUIT, Convert.ToInt64(code));
                List <PedidoDetalleEntidad> ListadeDetalles  = pedidoCore.PedidosDetalleSelect(PedidoRow.IdPedido);
                List <DetalleDTO>           ListaDetallesDTO = new List <DetalleDTO>();
                foreach (var item in ListadeDetalles)
                {
                    DetalleDTO NuevoDetalle = new DetalleDTO();
                    NuevoDetalle.Producto       = coreProducto.Find(item.miProducto.IdProducto, 1).DescripProducto;
                    NuevoDetalle.Cantidad       = item.Cantidad;
                    NuevoDetalle.PrecioUnitario = item.PrecioUnitario;
                    NuevoDetalle.Total          = NuevoDetalle.Cantidad * NuevoDetalle.PrecioUnitario;

                    ListaDetallesDTO.Add(NuevoDetalle);
                }
                grilladedetallesdelpedido.DataSource = ListaDetallesDTO;
                grilladedetallesdelpedido.DataBind();
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("$('#currentdetail').modal('show');");
                sb.Append(@"</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                        "ModalScript", sb.ToString(), false);
            }
            //if (e.CommandName.Equals("PagarPedido"))
            //{
            //    //Obtener IdPedido seleccionado
            //    int index = Convert.ToInt32(e.CommandArgument);
            //    Int64 unNroPedido = Int64.Parse(grilladeultimospedidos.DataKeys[index].Value.ToString());
            //    //variables
            //    PedidoCore unManagerPedido = new PedidoCore();
            //    var Current = HttpContext.Current;
            //    PedidoEntidad unPedidoPagar = new PedidoEntidad();
            //    SucursalCore ManagerSucursal = new SucursalCore();

            //    //Preparar parámetros a enviar a Avanzar()
            //    logueado = (UsuarioEntidad)Current.Session["Usuario"];
            //    unPedidoPagar = unManagerPedido.PedidoSelectByCUIT_NroPedido(unNroPedido);
            //    unPedidoPagar.misDetalles = unManagerPedido.PedidosDetalleSelect(unPedidoPagar.IdPedido);
            //    SucursalEntidad unaSucursal = ManagerSucursal.SucursalTraerPorDireccionSucursal(unPedidoPagar.miDireccionEntrega.IdDireccion);

            //    TarjetaEntidad unaTarjeta = new TarjetaEntidad();
            //    TarjetaCore coreTarjeta = new TarjetaCore();
            //    List<TarjetaEntidad> MisTarjetas = coreTarjeta.SelectAllTarjetasByCUIT_NombreUsuario(ConfigSection.Default.Site.Cuit, logueado.NombreUsuario);
            //    foreach (var t in MisTarjetas)
            //    {
            //        if (t.Predeterminada == true)
            //        {
            //            unaTarjeta = t;
            //        }
            //    }

            //    if (unManagerPedido.PagarPedido(unaTarjeta.Numero.ToString(), unaTarjeta.CodSeguridad, (decimal)unPedidoPagar.misDetalles.Select(x => x.Cantidad * x.miProducto.PrecioUnitario).Sum()))
            //    {
            //        unManagerPedido.AvanzarPaso(unPedidoPagar, unaSucursal, logueado);
            //        return true;
            //    }
            //    return false;

            //    CargarGrillaUltimosPedidos();
            //    Response.Redirect(Request.RawUrl);

            //}//END Pagar
        }//END GrillaMetodos
Пример #5
0
        protected void grilladeultimospedidos_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            ProductoCore coreProducto = new ProductoCore();

            if (e.CommandName.Equals("VerDetalle"))
            {
                int           index     = Convert.ToInt32(e.CommandArgument);
                string        code      = grilladeultimospedidos.DataKeys[index].Value.ToString();
                PedidoEntidad PedidoRow = pedidoCore.PedidoSelectByCUIT_NroPedidoCliente(usuarioentidad.CUIT, Convert.ToInt64(code));
                List <PedidoDetalleEntidad> ListadeDetalles  = pedidoCore.PedidosDetalleSelect(PedidoRow.IdPedido);
                List <DetalleDTO>           ListaDetallesDTO = new List <DetalleDTO>();
                foreach (var item in ListadeDetalles)
                {
                    DetalleDTO NuevoDetalle = new DetalleDTO();
                    NuevoDetalle.Producto       = coreProducto.Find(item.miProducto.IdProducto, 1).DescripProducto;
                    NuevoDetalle.Cantidad       = item.Cantidad;
                    NuevoDetalle.PrecioUnitario = item.PrecioUnitario;
                    NuevoDetalle.Total          = NuevoDetalle.Cantidad * NuevoDetalle.PrecioUnitario;

                    ListaDetallesDTO.Add(NuevoDetalle);
                }

                grilladedetallesdelpedido.DataSource = ListaDetallesDTO;
                grilladedetallesdelpedido.DataBind();
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("$('#currentdetail').modal('show');");
                sb.Append(@"</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                        "ModalScript", sb.ToString(), false);
            }

            if (e.CommandName.Equals("CambiarEstado"))
            {
                string[] unosPermisosTest = new string[] { "PedidoMod" };
                if (usuarioentidad != null && this.Master.Autenticar(unosPermisosTest))
                {
                    //variables
                    PedidoCore    unManagerPedido = new PedidoCore();
                    var           Current         = HttpContext.Current;
                    PedidoEntidad unPedidoPagar   = new PedidoEntidad();
                    SucursalCore  ManagerSucursal = new SucursalCore();

                    //Inicializacion
                    int   index       = Convert.ToInt32(e.CommandArgument);
                    Int64 unNroPedido = Int64.Parse(grilladeultimospedidos.DataKeys[index].Value.ToString());

                    //Preparar parámetros a enviar a Avanzar()
                    logueado                  = (UsuarioEntidad)Current.Session["Usuario"];
                    unPedidoPagar             = pedidoCore.PedidoSelectByCUIT_NroPedidoCliente(usuarioentidad.CUIT, unNroPedido);
                    unPedidoPagar.misDetalles = unManagerPedido.PedidosDetalleSelect(unPedidoPagar.IdPedido);
                    SucursalEntidad unaSucursal = ManagerSucursal.SucursalTraerPorDireccionSucursal(unPedidoPagar.miDireccionEntrega.IdDireccion);

                    //No se puede descancelar un Pedido
                    if (unPedidoPagar.VerEstadoActual().IdEstadoPedido == (int)EstadoPedidoEntidad.Options.Cancelado)
                    {
                        System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
                        sb2.Append(@"<script type='text/javascript'>");
                        sb2.Append("$('#BloqueadoModifFinalizado').modal('show');");
                        sb2.Append(@"</script>");
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                                "ModalScript2", sb2.ToString(), false);
                    }

                    //Pendiente hacia Pago
                    if (unPedidoPagar.VerEstadoActual().IdEstadoPedido == (int)EstadoPedidoEntidad.Options.PendientePago)
                    {
                        unManagerPedido.AvanzarPaso(unPedidoPagar, unaSucursal, logueado, (int)FormaPagoEntidad.Options.Externa);
                    }

                    //Pago Hacia EnCamino
                    else if (unPedidoPagar.VerEstadoActual().IdEstadoPedido == (int)EstadoPedidoEntidad.Options.Pago && unPedidoPagar.miFormaEntrega.IdFormaEntrega == (int)FormaEntregaEntidad.Options.Correo)
                    {
                        string unNroTracking = "TNK9966784523234";
                        unManagerPedido.AvanzarPaso(unPedidoPagar, unNroTracking);
                    }

                    //Pago Hacia ListoRetirar
                    else if (unPedidoPagar.VerEstadoActual().IdEstadoPedido == (int)EstadoPedidoEntidad.Options.Pago && unPedidoPagar.miFormaEntrega.IdFormaEntrega == (int)FormaEntregaEntidad.Options.Sucursal)
                    {
                        unManagerPedido.AvanzarPaso(unPedidoPagar);
                    }

                    //EnCamino y/o ListoRetirar hacia Entregado
                    else if (unPedidoPagar.VerEstadoActual().IdEstadoPedido == (int)EstadoPedidoEntidad.Options.EnCamino | unPedidoPagar.VerEstadoActual().IdEstadoPedido == (int)EstadoPedidoEntidad.Options.ListoRetirar)
                    {
                        unManagerPedido.AvanzarPaso(unPedidoPagar);
                    }
                }
                else
                {
                    System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
                    sb2.Append(@"<script type='text/javascript'>");
                    sb2.Append("$('#PedidoModFalse').modal('show');");
                    sb2.Append(@"</script>");
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                            "ModalScript10", sb2.ToString(), false);
                }
            }

            if (e.CommandName.Equals("CancelarPedido"))
            {
                string[] unosPermisosTest = new string[] { "PedidoCancelar" };
                if (usuarioentidad != null && this.Master.Autenticar(unosPermisosTest))
                {
                    //variables
                    PedidoCore    unManagerPedido = new PedidoCore();
                    var           Current         = HttpContext.Current;
                    PedidoEntidad unPedidoPagar   = new PedidoEntidad();
                    SucursalCore  ManagerSucursal = new SucursalCore();

                    //Inicializacion
                    int   index       = Convert.ToInt32(e.CommandArgument);
                    Int64 unNroPedido = Int64.Parse(grilladeultimospedidos.DataKeys[index].Value.ToString());

                    //Preparar parámetros a enviar a Avanzar()
                    logueado      = (UsuarioEntidad)Current.Session["Usuario"];
                    unPedidoPagar = pedidoCore.PedidoSelectByCUIT_NroPedidoCliente(usuarioentidad.CUIT, unNroPedido);

                    //Cancelar
                    if (unPedidoPagar.VerEstadoActual().IdEstadoPedido != (int)EstadoPedidoEntidad.Options.Cancelado)
                    {
                        unManagerPedido.CancelarPedido(unPedidoPagar);
                    }
                    //No se puede descancelar un pedido
                    else
                    {
                        System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
                        sb2.Append(@"<script type='text/javascript'>");
                        sb2.Append("$('#BloqueadoModifFinalizado').modal('show');");
                        sb2.Append(@"</script>");
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                                "ModalScript7", sb2.ToString(), false);
                    }

                    CargarGrillaUltimosPedidos();
                }
                else
                {
                    System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
                    sb2.Append(@"<script type='text/javascript'>");
                    sb2.Append("$('#PedidoModFalse').modal('show');");
                    sb2.Append(@"</script>");
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                            "ModalScript11", sb2.ToString(), false);
                }
            }
        }
Пример #6
0
        ////Para mantener la sesión activa
        //[WebMethod(EnableSession = true)]
        //public static void MantenerSesion()
        //{

        //}


        protected void Page_Load(object sender, EventArgs e)
        {
            var          Current      = HttpContext.Current;
            SucursalCore coreSucursal = new SucursalCore();

            idioma = new LenguajeEntidad();
            PedidoCore    ManagerPedido   = new PedidoCore();
            PedidoEntidad unPedido        = new PedidoEntidad();
            ProductoCore  ManagerProducto = new ProductoCore();

            NroPedDUltPed = Page.Request.QueryString["NroPedDUltPed"];
            if (!string.IsNullOrEmpty(NroPedDUltPed))
            {
                Current.Session["NroPedidoDesdeUltimosPedidos"] = NroPedDUltPed;
            }
            else
            {
                Response.Redirect("/Areas/Public/Forms/Home.aspx");
            }

            logueado = (UsuarioEntidad)Current.Session["Usuario"];

            if (logueado == null)
            {
                Response.Redirect("/Areas/Public/Forms/Home.aspx");
            }
            if (!IsPostBack)
            {
                idioma = (LenguajeEntidad)Session["Idioma"];

                if (idioma == null)
                {
                    idioma = new LenguajeEntidad();
                    idioma.DescripcionLenguaje = "es";
                    Session["Idioma"]          = idioma;
                }
            }
            else
            {
                idioma.DescripcionLenguaje = Master.obtenerIdiomaCombo();
                Session["Idioma"]          = idioma;
            }
            DropDownList lblIdioma = FindControlFromMaster <DropDownList>("ddlLanguages");

            if (lblIdioma != null)
            {
                lblIdioma.SelectedValue = idioma.DescripcionLenguaje;
            }

            unPedido             = ManagerPedido.PedidoSelectByCUIT_NroPedido(Int64.Parse(NroPedDUltPed));
            unPedido.misDetalles = ManagerPedido.PedidosDetalleSelect(unPedido.IdPedido);
            MonedaEmpresaEntidad cotizacion = (MonedaEmpresaEntidad)Session["Cotizacion"];

            foreach (PedidoDetalleEntidad unDet in unPedido.misDetalles)
            {
                unDet.miProducto = ManagerProducto.Find(unDet.miProducto.IdProducto, cotizacion.IdMoneda);
            }

            FormaEntrega = unPedido.miFormaEntrega.IdFormaEntrega;
            pedido       = unPedido.IdPedido;
            totalizado   = unPedido.misDetalles.Select(x => x.Cantidad * x.miProducto.PrecioUnitario).Sum();
            //TODO: sacarle el precio de envio hardcodeado:
            if (FormaEntrega != null && FormaEntrega == (int)FormaEntregaEntidad.Options.Correo)
            {
                totalizado = totalizado + 100;
            }


            unPedido.misDetalles.ForEach(x => lista.Add(new PedidoLista()
            {
                Cantidad = x.Cantidad,
                Producto = x.miProducto,
                Stock    = true
            }));

            TarjetaCore           coreTarjeta = new TarjetaCore();
            List <TarjetaEntidad> MisTarjetas = coreTarjeta.SelectAllTarjetasByCUIT_NombreUsuario(ConfigSection.Default.Site.Cuit, logueado.NombreUsuario);

            foreach (var t in MisTarjetas)
            {
                if (t.Predeterminada == true)
                {
                    MiTarjeta = t;
                }
            }
        }