Esempio n. 1
0
        private void registrarVenta()
        {
            VentaDTO          ve    = new VentaDTO();
            List <DetalleDTO> lista = new List <DetalleDTO>();

            foreach (DataRow item in tbDetalle.Rows)
            {
                DetalleDTO d = new DetalleDTO();
                d.IdProducto = Int32.Parse(item[0].ToString());
                d.Precio     = decimal.Parse(item[2].ToString());
                d.Cantidad   = Int32.Parse(item[3].ToString());
                d.Descuento  = 0;
                lista.Add(d);
            }
            try
            {
                ve.IdCliente  = cboCliente.SelectedValue.ToString();
                ve.IdEmpleado = (int)cboEmpleado.SelectedValue;
                ve.Fecha      = DateTime.Parse(txtFecha.Text);
                ve.Monto      = decimal.Parse(txtTotal.Text);
                ve.Item       = lista;
                if (oventa.RegistrarVenta(ve) > 0)
                {
                    txtNro.Text = ve.IdVenta.ToString();
                    MessageBox.Show("Venta registrada correctamente", "Registrar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        public async Task <DetalleDTO> GetDetalle(int?id)
        {
            DetalleDTO    dto     = new DetalleDTO();
            TABLA_GENERAL general = await generalRepository.GetById(id);

            dto.idTablaGeneral     = general.idTablaGeneral;
            dto.codigoTablaGeneral = general.codigoTablaGeneral;
            dto.detalles           = await GetDetalleByIdGeneral(id);

            return(dto);
        }
Esempio n. 3
0
        public async Task <DetalleDTO> GetDetalle(int?id)
        {
            DetalleDTO    dto     = new DetalleDTO();
            D00_TBGENERAL general = await generalRepository.GetById(id);

            dto.idTab    = general.idTab;
            dto.codTab   = general.codTab;
            dto.ldetalle = await GetDetalleByIdGeneral(id);

            return(dto);
        }
Esempio n. 4
0
        // POST: Detalle/Edit/5

        public async Task <IActionResult> VistaDetalle(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            if (TempData["mensajedetalle"] != null)
            {
                ViewBag.message = TempData["mensajedetalle"].ToString();
            }
            DetalleDTO dto = await _detalleRepository.GetDetalle(id);

            return(View(dto));
        }
Esempio n. 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(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
Esempio 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);
                }
            }
        }