Agregar archivos de proyecto.
This commit is contained in:
156
bdGrupoSanchoToro/extensiones/entidades.cs
Normal file
156
bdGrupoSanchoToro/extensiones/entidades.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class entidades:INotifyPropertyChanged
|
||||
{
|
||||
|
||||
[NotMapped]
|
||||
public virtual string RazonSocialNIF
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.RazonSocial + " (NIF: " + this.NIF + ")";
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual string Poblacion
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtienePoblacion(this.CodigoMunicipio);
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual string Provincia
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtieneProvincia(this.CodigoMunicipio);
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string PoblacionProvincia
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((Poblacion ?? "") == (Provincia ?? ""))
|
||||
{
|
||||
return Poblacion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Poblacion + " (" + Provincia + ")";
|
||||
}
|
||||
}
|
||||
catch (Exception )
|
||||
{
|
||||
return "** DESCONOCIDO **";
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string DireccionCompleta
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return CodigoPostal + " " + PoblacionProvincia;
|
||||
}
|
||||
catch (Exception )
|
||||
{
|
||||
return "** DESCONOCIDO **";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<entidades> ObtieneClientesActuales(tscGrupoSanchoToro bd)
|
||||
{
|
||||
return bd.entidades.Where(x=> x.EsCliente && x.FechaBaja.HasValue==false).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
//public double? PendientePago
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (this.idEntidad == 0)
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tscGrupoSanchoToro bd = (tscGrupoSanchoToro)this.ObtieneContexto();
|
||||
// if (bd is not null)
|
||||
// {
|
||||
// double mcs = bd.movimientoscaja.Where(x => x.idFactura.HasValue == false).Select(x => x.Importe).ToList().Sum(x => x);
|
||||
// double facs = bd.facturas.Where(x => x.idCliente == this.idEntidad).Select(x => x.TotalFactura).ToList().Sum(x => x);
|
||||
// double pagos = bd.movimientoscaja.Where(x => x.idFactura.HasValue && x.facturas.idCliente == this.idEntidad).Select(x => x.Importe).ToList().Sum(x => x);
|
||||
// double ImpPen = Math.Round(facs - mcs - pagos, 2, MidpointRounding.AwayFromZero);
|
||||
// if (ImpPen > 0d)
|
||||
// {
|
||||
// return ImpPen;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
public void RefrescaCamposSoloLectura()
|
||||
{
|
||||
this.OnPropertyChanged("Provincia");
|
||||
this.OnPropertyChanged("Poblacion");
|
||||
this.OnPropertyChanged("PendientePago");
|
||||
}
|
||||
|
||||
public string Advertencias
|
||||
{
|
||||
get
|
||||
{
|
||||
string sAdvertencias = "";
|
||||
foreach (var ad in this.expedientesentidades.Where(x => x.EsAdvertencia).ToList())
|
||||
sAdvertencias += " -- " + ad.Descripcion;
|
||||
if (!string.IsNullOrEmpty(sAdvertencias))
|
||||
sAdvertencias = sAdvertencias.Substring(4);
|
||||
return sAdvertencias;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user