帮助!!!我不知道错误是什么! 我尝试了很多东西,但是我无法解决这个问题,所以我需要一些经验丰富的人帮助做到这一点。 我希望你能帮助我。
班级:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Descripción breve de Venta
/// </summary>
public class Venta
{
private static int _ultimaCantidadVentas = 0;
public static int UltimaCantidadVentas
{
get
{
return _ultimaCantidadVentas;
}
}
private int _codigoProducto;
private int _numeroVentas;
private int _clientesCompra;
private DateTime _fechaVenta;
private DateTime _fechaPago;
private double _total;
public int CodigoProducto
{
get
{
return _codigoProducto;
}
set
{
if (value < 0)
{
throw new ExcepcionPersonalizada("El código de producto debe ser entero mayor a 0.");
}
_codigoProducto = value;
}
}
public int NumeroVentas
{
get
{
return _numeroVentas;
}
set
{
if (value < 0)
{
throw new ExcepcionPersonalizada("El numero de ventas no puede ser menor que 0.");
}
_numeroVentas = value;
}
}
public int ClientesCompra
{
get
{
return _clientesCompra;
}
set
{
if (value < 0)
{
throw new ExcepcionPersonalizada("El numero de clientes que compra no puede ser menor que 0.");
}
_clientesCompra = value;
}
}
public DateTime FechaVenta
{
get
{
return _fechaVenta;
}
set
{
/*if (value < DateTime.Now)
{
throw new ExcepcionPersonalizada("La fecha de venta no puede ser menor al dia de hoy.");
}*/
_fechaVenta = value;
}
}
public DateTime FechaPago
{
get
{
return _fechaPago;
}
set
{
if (value < DateTime.Today)
{
throw new ExcepcionPersonalizada("La fecha de pago no puede ser menor al dia de hoy.");
}
_fechaPago = value;
}
}
public double Total
{
get
{
return _total;
}
set
{
if (value < 0)
{
throw new ExcepcionPersonalizada("La venta total no puede ser menor que 0.");
}
_total = value;
}
}
public Venta()
{
}
public Venta(int codigoProducto, int numeroVentas, int clientesCompra, DateTime fechaVenta, DateTime fechaPago, double total)
{
CodigoProducto = codigoProducto;
NumeroVentas = numeroVentas;
ClientesCompra = clientesCompra;
FechaVenta = fechaVenta;
FechaPago = fechaPago;
Total = total;
}
public override string ToString()
{
return "Venta --> Cliente: " + ClientesCompra + ", Producto: " + CodigoProducto + ", Cantidad de Producto: " + NumeroVentas + ", Fecha de Venta: " + FechaVenta + ", Fecha de Pago: " + FechaPago + ", Total de la Venta: " + Total;
}
}