Exemplo n.º 1
0
 public PedidosEnvio()
 {
     idioma        = new LenguajeEntidad();
     _sucursalCore = new SucursalCore();
     cotizacion    = new MonedaEmpresaEntidad();
     moneda        = new MonedaEntidad();
     _coreMoneda   = new MonedaCore();
 }
        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");
        }
Exemplo n.º 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();
        }
Exemplo n.º 4
0
        public static bool ChequearPedido()
        {
            List <SucursalEntidad> sucursalesDisponibles;
            SucursalCore           _sucursalCore = new SucursalCore();
            List <PedidoLista>     ProdCantEnPedido;
            var Current = HttpContext.Current;
            List <PedidoDetalleEntidad> unosPedidosDetalles = new List <PedidoDetalleEntidad>();

            ProdCantEnPedido = (List <PedidoLista>)Current.Session["Pedido"];
            if (ProdCantEnPedido != null && ProdCantEnPedido.Count > 0)
            {
                PedidoDetalleEntidad unPedDet;
                //Para armar lista PedidosDetalles y enviarlo como param a la BLL y obtener sucursales con stock suficiente
                foreach (PedidoLista UnProdCant in ProdCantEnPedido)
                {
                    unPedDet                       = new PedidoDetalleEntidad();
                    unPedDet.miProducto            = new ProductoEntidad();
                    unPedDet.miProducto.IdProducto = UnProdCant.Producto.IdProducto;
                    unPedDet.Cantidad              = UnProdCant.Cantidad;
                    unosPedidosDetalles.Add(unPedDet);
                }
            }

            sucursalesDisponibles = _sucursalCore.TraerSucursalesConStock(unosPedidosDetalles);

            if (sucursalesDisponibles.Count > 0)
            {
                return(true);
            }
            //Current.Session.Add("SucursalesDisponibles", sucursalesDisponibles); //Guardo en Sesión las sucursales disponibles para tomarlas en WebMethod "FormaEnvio"
            //Por si lo quito de PedidosEnvio, puede ir aca solamente la línea de arriba
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        protected void btnConsultar_Click(object sender, EventArgs e)
        {
            Consultas.Clear();

            ProductoEntidad        unProducto;
            List <ProductoEntidad> productos;

            if (!string.IsNullOrWhiteSpace(txtProductoaBuscar.Text))
            {
                productos = ProductoBLL.FindAllByDescripProducto(txtProductoaBuscar.Text);
            }
            else
            {
                return;
            }

            if (productos != null && productos.Count > 0)
            {
                unProducto = (ProductoEntidad)productos.First();

                //StockSucursalEntidad unStock = StockBLL1.Select(item.miProducto.IdProducto, laAdquisicion.miSucursal.IdSucursal, laAdquisicion.CUIT);

                List <StockSucursalEntidad> StockDeProducto = new List <StockSucursalEntidad>();
                StockDeProducto = StockBLL1.SelectByIdProducto(unProducto.IdProducto);

                ConsultaDTO Consulta = new ConsultaDTO();
                Consulta.IdProducto  = unProducto.IdProducto;
                Consulta.Descripcion = unProducto.DescripProducto;
                if (StockDeProducto.Count > 0)
                {
                    if (Int32.Parse(cboSucursal.SelectedValue) < 0) //Si no se indica sucursal se muestra stock total
                    {
                        hIdSuc.Value  = "";
                        hIdProd.Value = "";
                        foreach (StockSucursalEntidad unProdSucStock in StockDeProducto)
                        {
                            Consulta.CantidadEnStock += unProdSucStock.CantidadProducto;
                        }
                    }
                    else //Se indica sucursal y se muestra el sucursal en la misma
                    {
                        if (StockDeProducto.Exists(X => X.IdSucursal == Int32.Parse(cboSucursal.SelectedValue) && X.IdProducto == unProducto.IdProducto))
                        {
                            hIdSuc.Value  = cboSucursal.SelectedValue;
                            hIdProd.Value = unProducto.IdProducto.ToString();
                            StockSucursalEntidad unProdSucStock = StockDeProducto.First(X => X.IdSucursal == Int32.Parse(cboSucursal.SelectedValue) && X.IdProducto == unProducto.IdProducto);
                            Consulta.CantidadEnStock = unProdSucStock.CantidadProducto;
                        }
                    }
                }
                else
                {
                    SucursalCore coreSucursal   = new SucursalCore();
                    var          listSucursales = coreSucursal.FindAll();

                    StockSucursalEntidad NuevoStock = new StockSucursalEntidad();
                    NuevoStock.IdProducto       = unProducto.IdProducto;
                    NuevoStock.CantidadProducto = 0;
                    NuevoStock.CUIT             = ConfigSection.Default.Site.Cuit;
                    NuevoStock.IdSucursal       = listSucursales[0].IdSucursal;;

                    StockCore StockBLL = new StockCore();
                    StockBLL.Insert(NuevoStock);

                    Consulta.CantidadEnStock = 0;
                }

                Consultas.Add(Consulta);
                CargarGrillaStock();
            }
        }
Exemplo n.º 6
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);
                }
            }
        }
Exemplo n.º 7
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;
                }
            }
        }
        ////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();

            //Session["FormaEnvio"] = 1;
            //Session["Seleccionada"] = coreSucursal.FindAll()[0].IdSucursal;



            idioma = new LenguajeEntidad();

            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;
                }
                cotizacion = new MonedaEmpresaEntidad();
                cotizacion = (MonedaEmpresaEntidad)Session["Cotizacion"];
                Session.Add("cotizacionAnterior", "");
            }
            else
            {
                cotizacion.IdMoneda        = Convert.ToInt16(Master.obtenerValorDropDown());
                Session["Cotizacion"]      = cotizacion;
                idioma.DescripcionLenguaje = Master.obtenerIdiomaCombo();
                Session["Idioma"]          = idioma;
            }
            if (cotizacion != null)
            {
                moneda = _coreMoneda.selectMoneda(cotizacion.IdMoneda);
            }
            DropDownList lblIdioma = FindControlFromMaster <DropDownList>("ddlLanguages");

            if (lblIdioma != null)
            {
                lblIdioma.SelectedValue = idioma.DescripcionLenguaje;
            }
            DropDownList lblStatus = FindControlFromMaster <DropDownList>("MonedaDRW");

            if (lblStatus != null)
            {
                if (cotizacion != null)
                {
                    lblStatus.SelectedValue = cotizacion.IdMoneda.ToString();
                }
            }

            if (!IsPostBack)
            {
                if (Current.Session["Productos"] == null)
                {
                    Response.Redirect("/Areas/Public/Forms/Home.aspx");
                }
                lista = (List <PedidoLista>)Current.Session["Pedido"];

                FormaEntrega = (int?)Current.Session["FormaEnvio"];
                //pedido = (int?)Current.Session["UltimoPedido"];
                totalizado = lista.Select(x => x.Cantidad * x.Producto.PrecioUnitario).Sum();
                //TODO: sacarle el precio de envio hardcodeado:
                if (FormaEntrega != null && FormaEntrega == (int)FormaEntregaEntidad.Options.Correo)
                {
                    totalizado = totalizado + 100;
                }
            }
            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;
                }
            }
        }