desarrollando editar
parent
c165c4e507
commit
1af942cd9a
|
|
@ -19,6 +19,7 @@ using System.Threading.Tasks;
|
||||||
using VentaUniformes.Application.Persistencia.Producto.Queries.GetAllProduct;
|
using VentaUniformes.Application.Persistencia.Producto.Queries.GetAllProduct;
|
||||||
using VentaUniformes.Application.VentasView;
|
using VentaUniformes.Application.VentasView;
|
||||||
using VentaUniformes.Application.VentasView.historico;
|
using VentaUniformes.Application.VentasView.historico;
|
||||||
|
using VentaUniformes.Application.VentasView.Editar;
|
||||||
namespace VentaUniformes.Application
|
namespace VentaUniformes.Application
|
||||||
{
|
{
|
||||||
public static class DependencyInjectionService
|
public static class DependencyInjectionService
|
||||||
|
|
@ -64,6 +65,9 @@ namespace VentaUniformes.Application
|
||||||
|
|
||||||
|
|
||||||
services.AddTransient<IVentasHistoricoViewService, VentasHistoricoViewService>();
|
services.AddTransient<IVentasHistoricoViewService, VentasHistoricoViewService>();
|
||||||
|
services.AddTransient<IEditarVentaViewService, EditarVentaViewService>();
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Sesion
|
#region Sesion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,5 +31,7 @@ namespace VentaUniformes.Application.Interfaces
|
||||||
public Task<bool> AddLineSales(List<SaleLineEntity> e);
|
public Task<bool> AddLineSales(List<SaleLineEntity> e);
|
||||||
|
|
||||||
public Task<List<SaleEntity>> GetSale(int top, string alumnoFilter);
|
public Task<List<SaleEntity>> GetSale(int top, string alumnoFilter);
|
||||||
|
public Task<SaleEntity> GetSale(int IdSale);
|
||||||
|
public Task<List<SaleLineEntity>> GetLineSale(int IdSale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VentaUniformes.Application.VentasView.Editar
|
||||||
|
{
|
||||||
|
public class EditarVentaViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Alumno { get; set; }
|
||||||
|
public string Curso { get; set; }
|
||||||
|
public int ModoPago { get; set; }
|
||||||
|
public bool isBill { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string DNI { get; set; }
|
||||||
|
public List<LineEditarVentaViewModel> Productos { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VentaUniformes.Application.VentasView.Editar
|
||||||
|
{
|
||||||
|
internal class EditarVentaViewService
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VentaUniformes.Application.VentasView.Editar
|
||||||
|
{
|
||||||
|
public interface IEditarVentaViewService
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VentaUniformes.Application.VentasView.Editar
|
||||||
|
{
|
||||||
|
public class LineEditarVentaViewModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public float Price { get; set; }
|
||||||
|
public int Cantidad { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,7 @@ namespace VentaUniformes.Application.VentasView
|
||||||
public interface IVentasViewService
|
public interface IVentasViewService
|
||||||
{
|
{
|
||||||
public Task<VentasViewModel> GetNewVenta();
|
public Task<VentasViewModel> GetNewVenta();
|
||||||
public Task<VentasViewModel> GetVenta(int IdVenta);
|
|
||||||
public Task<bool> BorraVenta(int idSale);
|
public Task<bool> BorraVenta(int idSale);
|
||||||
public Task<bool> Save(VentasViewModel model);
|
public Task<bool> Save(VentasViewModel model);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,6 @@ namespace VentaUniformes.Application.VentasView
|
||||||
res.Productos = _mapper.Map<List<LineVentasViewModel>>(l);
|
res.Productos = _mapper.Map<List<LineVentasViewModel>>(l);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
public async Task<VentasViewModel> GetVenta(int IdVenta)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> Save(VentasViewModel model)
|
public async Task<bool> Save(VentasViewModel model)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ using VentaUniformes.Application.Persistencia.Producto.Queries.GetAllProduct;
|
||||||
using VentaUniformes.Application.VentasView;
|
using VentaUniformes.Application.VentasView;
|
||||||
using VentaUniformes.Application.VentasView.historico;
|
using VentaUniformes.Application.VentasView.historico;
|
||||||
using VentaUniformes.Domain.Entities.Sale;
|
using VentaUniformes.Domain.Entities.Sale;
|
||||||
|
using VentaUniformes.Application.VentasView.Editar;
|
||||||
|
|
||||||
namespace VentaUniformes.Application.configuration
|
namespace VentaUniformes.Application.configuration
|
||||||
{
|
{
|
||||||
|
|
@ -31,6 +32,7 @@ namespace VentaUniformes.Application.configuration
|
||||||
CreateMap<GetAllProductModel, ProductEntity>().ReverseMap();
|
CreateMap<GetAllProductModel, ProductEntity>().ReverseMap();
|
||||||
CreateMap<LineVentasViewModel, ProductEntity>().ReverseMap();
|
CreateMap<LineVentasViewModel, ProductEntity>().ReverseMap();
|
||||||
CreateMap<VentaLineHistoricoViewModel, SaleEntity>().ReverseMap();
|
CreateMap<VentaLineHistoricoViewModel, SaleEntity>().ReverseMap();
|
||||||
|
CreateMap<LineEditarVentaViewModel, ProductEntity>().ReverseMap();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace VentaUniformes.app.Controllers
|
||||||
|
{
|
||||||
|
public class EditarVentaController : Controller
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
@model VentaUniformes.Application.VentasView.Editar.EditarVentaViewModel;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Venta uniformes";
|
||||||
|
}
|
||||||
|
<form asp-action="Principal" method="post">
|
||||||
|
<div class="row">
|
||||||
|
<!-- Columna izquierda: tabla de productos enctype="multipart/form-data-->
|
||||||
|
<div class="col-md-8" form-group>
|
||||||
|
<input asp-for="Id" type="hidden" />
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Alumno"></label>
|
||||||
|
<input asp-for="Alumno" class="form-control" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Curso"></label>
|
||||||
|
<input asp-for="Curso" class="form-control" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="isBill">
|
||||||
|
<input type="checkbox" asp-for="isBill" id="con-factura" onchange="toggleFactura()" /> Con factura
|
||||||
|
</label>
|
||||||
|
<div id="factura">
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Name">Nombre</label>
|
||||||
|
<input asp-for="Name" id="name-factura" class="form-control" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="DNI">DNI</label>
|
||||||
|
<input asp-for="DNI" id="dni-factura" class="form-control" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Input (oculto inicialmente) -->
|
||||||
|
<div id="campoInput" style="display:none; margin-top:10px;">
|
||||||
|
<label for="inputOpcional">Texto adicional:</label>
|
||||||
|
<input type="text" id="inputOpcional" name="inputOpcional" placeholder="Escribe algo..." />
|
||||||
|
</div>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Nombre</th>
|
||||||
|
<th>Descripcion</th>
|
||||||
|
<th>Precio</th>
|
||||||
|
<th>Cantidad</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@for (int i = 0; i < Model.Productos.Count; i++)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@Model.Productos[i].Name</td>
|
||||||
|
<td>@Model.Productos[i].Description</td>
|
||||||
|
<td>@Model.Productos[i].Price.ToString("C")</td>
|
||||||
|
<td>
|
||||||
|
<input asp-for="Productos[i].Cantidad" class="form-control cantidad-input" data-precio="@Model.Productos[i].Price.ToString().Replace(',','.')" data-index="@i" data-idp="@Model.Productos[i].Id" type="number" min="0" />
|
||||||
|
<input asp-for="Productos[i].Id" type="hidden" />
|
||||||
|
<input asp-for="Productos[i].Price" type="hidden" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<!-- Columna derecha: resumen de total y método de pago -->
|
||||||
|
|
||||||
|
<div class="col-md-4 form-group">
|
||||||
|
<div class="card form-group">
|
||||||
|
<div class="card-body form-group">
|
||||||
|
|
||||||
|
<h5 class="card-title">Resumen</h5>
|
||||||
|
<p><strong>Total:<span id="total">0.00</span> €</strong></p>
|
||||||
|
|
||||||
|
<h6>Método de pago</h6>
|
||||||
|
<div class="form-check">
|
||||||
|
<div>
|
||||||
|
<label>
|
||||||
|
@Html.RadioButtonFor(m => m.ModoPago,0)
|
||||||
|
Efectivo
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>
|
||||||
|
@Html.RadioButtonFor(m => m.ModoPago, 1)
|
||||||
|
Tarjeta
|
||||||
|
</label>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary mt-3">Procesar Venta</button>
|
||||||
|
@if (ViewData["Mensaje"] != null)
|
||||||
|
{
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
@ViewData["Mensaje"]
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
@section Scripts {
|
||||||
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
//actualizacion del total
|
||||||
|
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
toggleFactura();
|
||||||
|
$(".cantidad-input").on('input', function () {
|
||||||
|
let total = 0;
|
||||||
|
$(".cantidad-input").each(function () {
|
||||||
|
let cantidad = $(this).val();
|
||||||
|
let precio = $(this).data("precio");
|
||||||
|
total += cantidad * precio;
|
||||||
|
});
|
||||||
|
$("#total").text(total.toFixed(2));
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
function toggleFactura() {
|
||||||
|
var checkbox = document.getElementById("con-factura");
|
||||||
|
var divfactura = document.getElementById("factura");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (checkbox.checked) {
|
||||||
|
divfactura.style.display = "block"; // Mostrar el input
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
divfactura.style.display = "none"; // Ocultar el input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- Columna izquierda: tabla de productos enctype="multipart/form-data-->
|
<!-- Columna izquierda: tabla de productos enctype="multipart/form-data-->
|
||||||
<div class="col-md-8" form-group>
|
<div class="col-md-8" form-group>
|
||||||
|
<input asp-for="Id" type="hidden" />
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Alumno"></label>
|
<label asp-for="Alumno"></label>
|
||||||
<input asp-for="Alumno" class="form-control" />
|
<input asp-for="Alumno" class="form-control" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue