cambios 17/02/2026

This commit is contained in:
2026-02-17 13:47:52 +01:00
parent 79ae74ee26
commit 28e20494ae
51 changed files with 3199 additions and 691 deletions

View File

@@ -0,0 +1,80 @@
using Castle.Core.Configuration;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using tsUtilidades.Extensiones;
namespace bdGrupoSanchoToro.Importaciones
{
public class ImportaARTICULOS
{
public static void Importar(byte[] Fichero)
{
try
{
var bd = tscGrupoSanchoToro.NuevoContexto();
var lp = bd.productos.Where(x=> x.Tipo!=(int)db.productos.TipoProductoEnum.GRUA).ToList();
var la = bd.articulos.ToList();
var ds = new XSD.ARTICULOS();
ds.ReadXml(new System.IO.MemoryStream(Fichero));
int i = 1;
int Ultimalinea = ds.Tables["Datos"].Rows.Count;
foreach (XSD.ARTICULOS.DatosRow ar in ds.Tables["Datos"].Rows)
{
try
{
var pr = lp.FirstOrDefault(x => x.Codigo == ar.ARCPR || x.Descripcion == ar.ARDES.Trim());
if (pr == null)
{
string sDes = ImportaPRODUCTOS.pros.FirstOrDefault(x=>x.PRCOD == ar.ARCPR )?.PRDES;
pr = lp.FirstOrDefault(x => x.Descripcion == sDes);
}
if (pr != null)
{
var art = la.FirstOrDefault(x => x.idProducto == pr.idProducto && x.CodigoArticulo == ar.ARNSE.Trim()) ;
if (art == null)
{
art = new bdGrupoSanchoToro.db.articulos();
bd.articulos.Add(art);
la.Add(art);
}
art.idProductoNavigation = pr;
art.CodigoArticulo = ar.ARNSE.Trim();
art.NumeroSerie = ar.ARNSE.Trim();
art.FechaBaja = ar.ARFEN.FechaStringADateOnly();
//art.FechaBaja = ar.CPFBA.FechaStringADateOnly();
// art.Matricula = ar.CPMAT;
i = i + 1;
if (i > 1000)
{
bd.SaveChanges();
i = 0;
}
}
else
{
Debug.Write("aqui");
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
bd.SaveChanges();
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
}
}

View File

@@ -16,12 +16,12 @@ namespace bdGrupoSanchoToro.Importaciones
var bd = tscGrupoSanchoToro.NuevoContexto();
var le = bd.enumeraciones.ToList();
var grs = bd.gruposenumeraciones.ToList();
var dsprueba = new XSD.CTESGESL();
var ds = new XSD.CTESGESL();
dsprueba.ReadXml(new System.IO.MemoryStream(Fichero));
ds.ReadXml(new System.IO.MemoryStream(Fichero));
int i = 1;
int Ultimalinea = dsprueba.Tables["Datos"].Rows.Count;
foreach (XSD.CTESGESL.DatosRow Proant in dsprueba.Tables["Datos"].Rows)
int Ultimalinea = ds.Tables["Datos"].Rows.Count;
foreach (XSD.CTESGESL.DatosRow Proant in ds.Tables["Datos"].Rows)
{
try
{

View File

@@ -1,5 +1,7 @@
using bdGrupoSanchoToro.db;
using System.Diagnostics;
using System.Linq.Dynamic.Core;
using tsUtilidades.Extensiones;
namespace bdGrupoSanchoToro.Importaciones
{
public class ImportaGRUASGC
@@ -9,34 +11,38 @@ namespace bdGrupoSanchoToro.Importaciones
try
{
var bd = tscGrupoSanchoToro.NuevoContexto();
var dsprueba = new XSD.GRUASGC();
var ds = new XSD.GRUASGC();
dsprueba.ReadXml(new System.IO.MemoryStream(Fichero));
int Ultimalinea = dsprueba.Tables["Datos"].Rows.Count;
ds.ReadXml(new System.IO.MemoryStream(Fichero));
int Ultimalinea = ds.Tables["Datos"].Rows.Count;
var lp = bd.productos.ToList();
var lm = bd.marcas.ToList();
var lv = bd.versionesgruas.ToList();
var grs = dsprueba.Tables["Datos"].Rows.Cast<XSD.GRUASGC.DatosRow>().ToList().OrderBy(x=> OrdenGRUASGC(x)).ToList();
var grs = ds.Tables["Datos"].Rows.Cast<XSD.GRUASGC.DatosRow>().ToList().OrderBy(x=> OrdenGRUASGC(x)).ToList();
foreach (XSD.GRUASGC.DatosRow gr in grs)
{
try
{
if (gr.CGMAR=="SAE") gr.CGMAR = "SAEZ";
if (gr.CGMAR == "COMANSA LINDE LC8552") gr.CGMAR = "COMANSA";
var mar = lm.First(x => x.Marca == gr.CGMAR);
string sDescripcion = "GRÚA " + mar.Marca + " " + gr.CGMDL;
bdGrupoSanchoToro.db.productos pr = lp.FirstOrDefault(x => x.Descripcion== sDescripcion);
if (pr == null)
{
pr = new productos()
{
idEmpresa = 1,
{
Codigo = "GR-" + gr.CGCOD,
Descripcion = sDescripcion,
DescripcionAbreviada = (mar.Marca + " " + gr.CGMDL).Acortar(45),
idMarcaNavigation = mar,
FechaAlta = DateOnly.FromDateTime(DateTime.Now),
Modelo = gr.CGMDL,
Tipo = (int)productos.TipoProductoEnum.GRUA
Tipo = (int)productos.TipoProductoEnum.GRUA,
idFamilia=42
};
bd.Add(pr);
lp.Add(pr);
bd.SaveChanges();

View File

@@ -0,0 +1,67 @@
using Castle.Core.Configuration;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using tsUtilidades.Extensiones;
namespace bdGrupoSanchoToro.Importaciones
{
public class ImportaGRUASPC
{
public static void Importar(byte[] Fichero)
{
try
{
var bd = tscGrupoSanchoToro.NuevoContexto();
var lp = bd.productos.Where(x=> x.Tipo==(int)db.productos.TipoProductoEnum.GRUA).ToList();
var la = bd.articulos.ToList();
var ds = new XSD.GRUASPC();
ds.ReadXml(new System.IO.MemoryStream(Fichero));
int i = 1;
int Ultimalinea = ds.Tables["Datos"].Rows.Count;
foreach (XSD.GRUASPC.DatosRow grua in ds.Tables["Datos"].Rows)
{
try
{
string codp = "GR-" + grua.CPCGG;
if (grua.CPMAR == "SAE") grua.CPMAR = "SAEZ";
if (grua.CPMAR == "COMANSA LINDE LC8552") grua.CPMAR = "COMANSA";
var gr = lp.First(x => x.Codigo == codp || (x.idMarcaNavigation.Marca == grua.CPMAR && x.Modelo == grua.CPMDL));
var art = la.FirstOrDefault(x =>x.idProducto==gr.idProducto && x.CodigoArticulo == grua.CPCOD.Trim());
if (art == null)
{
art = new bdGrupoSanchoToro.db.articulos();
bd.articulos.Add(art);
la.Add(art);
}
art.idProductoNavigation = gr;
art.CodigoArticulo = grua.CPCOD.Trim();
art.FechaAlta= grua.CPFAL.FechaStringADateOnly();
art.FechaBaja = grua.CPFBA.FechaStringADateOnly();
art.Matricula = grua.CPMAT;
i = i + 1;
if (i > 1000)
{
bd.SaveChanges();
i = 0;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
bd.SaveChanges();
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
}
}

View File

@@ -11,6 +11,7 @@ namespace bdGrupoSanchoToro.Importaciones
{
public class ImportaPRODUCTOS
{
public static List<XSD.PRODUCTOS.DatosRow> pros;
public static void Importar(byte[] Fichero)
{
try
@@ -23,14 +24,14 @@ namespace bdGrupoSanchoToro.Importaciones
var lp = bd.productos.ToList();
var lf = bd.familias.ToList();
var lm = bd.marcas.ToList();
var lfh = bd.enumeraciones.Where(x=> x.idGrupoEnumeracionNavigation.Grupo=="FAMH").ToList();
var pros = ds.Tables["Datos"].Rows.Cast<XSD.PRODUCTOS.DatosRow>().ToList();
var lfh = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "FAMH").ToList();
pros = ds.Tables["Datos"].Rows.Cast<XSD.PRODUCTOS.DatosRow>().ToList();
foreach (XSD.PRODUCTOS.DatosRow pro in pros)
{
try
{
bdGrupoSanchoToro.db.productos p = lp.FirstOrDefault(x => x.Codigo == pro.PRCOD || x.DescripcionAbreviada.RemoveDiacritics() ==pro.PRDES.Trim().RemoveDiacritics().ToUpper() || x.Descripcion.RemoveDiacritics().ToUpper()==pro.PRDESL.Trim().RemoveDiacritics().ToUpper() );
bdGrupoSanchoToro.db.productos p = lp.FirstOrDefault(x => x.Codigo == pro.PRCOD || x.DescripcionAbreviada.RemoveDiacritics() == pro.PRDES.Trim().RemoveDiacritics().ToUpper() || x.Descripcion.RemoveDiacritics().ToUpper() == pro.PRDESL.Trim().RemoveDiacritics().ToUpper());
if (p == null)
{
p = new productos()
@@ -45,7 +46,7 @@ namespace bdGrupoSanchoToro.Importaciones
p.DescripcionAbreviada = pro.PRDES.Trim().RemoveDiacritics().ToUpper();
p.FechaAlta = DateOnly.FromDateTime(DateTime.Now);
familias? fam = bd.familias.FirstOrDefault(x => x.Codigo == pro.PRFAM);
p.idFamilia = fam == null ? null : fam.idFamilia;
p.idFamilia = fam == null ? 42 : fam.idFamilia;
if (pro.PRMAR.NothingAVacio() != "")
{
var mar = lm.FirstOrDefault(x => x.Marca == pro.PRMAR);
@@ -65,11 +66,11 @@ namespace bdGrupoSanchoToro.Importaciones
p.idMarca = null;
}
p.Modelo = pro.PRMDL;
p.Servicio = (pro.PRCFP=="AL" ? true : false);
// p.Servicio = (pro.PRCFP == "AL" ? true : false);
p.idFamiliaHomologacion = null;
if (pro.PRFAMH!="")
if (pro.PRFAMH != "")
{
var fh=lfh.FirstOrDefault(x=> x.Codigo==("FAMH." + pro.PRFAMH));
var fh = lfh.FirstOrDefault(x => x.Codigo == ("FAMH." + pro.PRFAMH));
if (fh != null)
{
p.idFamiliaHomologacion = fh.idEnumeracion;
@@ -85,7 +86,7 @@ namespace bdGrupoSanchoToro.Importaciones
p.Tipo = (int)productos.TipoProductoEnum.CONSUMIBLES;
break;
}
case "CG":
case "CG":
{
p.Tipo = (int)productos.TipoProductoEnum.ELEMENTO_GRUA;
break;
@@ -105,12 +106,18 @@ namespace bdGrupoSanchoToro.Importaciones
p.Tipo = (int)productos.TipoProductoEnum.REPUESTO;
break;
}
default:
{
p.Tipo = (int)productos.TipoProductoEnum.ELEMENTO_GRUA;
break;
}
}
}
}
p.PrecioVenta = double.Parse(pro.PRPVP, CultureInfo.InvariantCulture);
p.ReferenciaFabrica = pro.PRRFA;
p.PrefijoNumeroSerie = pro.PRPNS;
p.PrefijoNumeroSerie = pro.PRPNS;
bd.SaveChanges();
}

View File

@@ -16,11 +16,13 @@ namespace bdGrupoSanchoToro.Importaciones
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto();
//00
//Importa("GRUASGC", bdGrupoSanchoToro.Importaciones.ImportaGRUASGC.Importar, de); //00
Importa("GRUASGC", bdGrupoSanchoToro.Importaciones.ImportaGRUASGC.Importar, de); //00
//Importa("FAMILIAS", bdGrupoSanchoToro.Importaciones.ImportaFAMILIAS.Importar, de); //00
//Importa("FAMILIAS", bdGrupoSanchoToro.Importaciones.ImportaFAMILIAS.Importar, de); //00
//Importa("CTESGESL", bdGrupoSanchoToro.Importaciones.ImportaCTESGESL.Importar, de); //00
Importa("PRODUCTOS", bdGrupoSanchoToro.Importaciones.ImportaPRODUCTOS.Importar, de); //00
Importa("GRUASPC", bdGrupoSanchoToro.Importaciones.ImportaGRUASPC.Importar, de); //00
Importa("ARTICULOS", bdGrupoSanchoToro.Importaciones.ImportaARTICULOS.Importar, de); //00
//Importa("GRUPRO", bdGrupoSanchoToro.Importaciones.ImportaGrupoProductos.Importar, de); //01
//Importa("CAMPAÑAS", bdGrupoSanchoToro.Importaciones.ImportaCampañas.Importar, de); //02

View File

@@ -71,6 +71,8 @@ public partial class albaranes
public DateOnly? FechaPrevistaFinSubalquiler { get; set; }
public int idEmpresa { get; set; }
public virtual municipios? CodigoMunicipioCargaNavigation { get; set; }
public virtual municipios? CodigoMunicipioDescargaNavigation { get; set; }
@@ -83,6 +85,8 @@ public partial class albaranes
public virtual almacenes? idAlmacenOrigenNavigation { get; set; }
public virtual empresas idEmpresaNavigation { get; set; } = null!;
public virtual entidades? idEntidadNavigation { get; set; }
public virtual presupuestos? idPresupuestoNavigation { get; set; }

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using PropertyChanged;
namespace bdGrupoSanchoToro.db;
[AddINotifyPropertyChangedInterface]
public partial class desgloseproductos
{
public int idDesglose { get; set; }
public int idProductoPadre { get; set; }
public int idProducto { get; set; }
public int Unidades { get; set; }
public int UnidadesMinimas { get; set; }
public int UnidadesMaximas { get; set; }
public string? DescripcionAdicional { get; set; }
public int? Version { get; set; }
public virtual ICollection<detallepresupuesto> detallepresupuesto { get; set; } = new List<detallepresupuesto>();
public virtual productos idProductoNavigation { get; set; } = null!;
public virtual productos idProductoPadreNavigation { get; set; } = null!;
}

View File

@@ -15,6 +15,8 @@ public partial class detallepresupuesto
public double Cantidad { get; set; }
public double GastosPorUnidad { get; set; }
public double Precio { get; set; }
public int idPresupuesto { get; set; }
@@ -23,10 +25,24 @@ public partial class detallepresupuesto
public string? Observaciones { get; set; }
public int? idDetallePresupuestoPadre { get; set; }
public int? idDesgloseProducto { get; set; }
public string? Parametros { get; set; }
public int? NumeroAsientos { get; set; }
public virtual ICollection<detallepresupuesto> InverseidDetallePresupuestoPadreNavigation { get; set; } = new List<detallepresupuesto>();
public virtual ICollection<detallesfacturas> detallesfacturas { get; set; } = new List<detallesfacturas>();
public virtual articulos? idArticuloNavigation { get; set; }
public virtual desgloseproductos? idDesgloseProductoNavigation { get; set; }
public virtual detallepresupuesto? idDetallePresupuestoPadreNavigation { get; set; }
public virtual presupuestos idPresupuestoNavigation { get; set; } = null!;
public virtual productos idProductoNavigation { get; set; } = null!;

View File

@@ -17,10 +17,6 @@ public partial class detallesalbaranes
public double Cantidad { get; set; }
public double Peso { get; set; }
public double Volumen { get; set; }
public bool EsVenta { get; set; }
public bool IncluidoEnPresupuesto { get; set; }
@@ -29,6 +25,14 @@ public partial class detallesalbaranes
public int? idUltimaFactura { get; set; }
public DateTime? FechaCancelacion { get; set; }
public int? idUsuarioQueCancela { get; set; }
public string? MotivoCancelacion { get; set; }
public string? Observaciones { get; set; }
public virtual albaranes idAlbaranNavigation { get; set; } = null!;
public virtual albaranes? idAlbaranRecogidaNavigation { get; set; }
@@ -38,4 +42,6 @@ public partial class detallesalbaranes
public virtual productos idProductoNavigation { get; set; } = null!;
public virtual facturas? idUltimaFacturaNavigation { get; set; }
public virtual usuarios? idUsuarioQueCancelaNavigation { get; set; }
}

View File

@@ -27,6 +27,8 @@ public partial class empresas
public string Codigo { get; set; } = null!;
public virtual ICollection<albaranes> albaranes { get; set; } = new List<albaranes>();
public virtual ICollection<almacenes> almacenes { get; set; } = new List<almacenes>();
public virtual ICollection<cajas> cajas { get; set; } = new List<cajas>();
@@ -43,7 +45,5 @@ public partial class empresas
public virtual ICollection<plantillas> plantillas { get; set; } = new List<plantillas>();
public virtual ICollection<productos> productos { get; set; } = new List<productos>();
public virtual ICollection<seriesfacturas> seriesfacturas { get; set; } = new List<seriesfacturas>();
}

View File

@@ -71,8 +71,6 @@ public partial class entidades
public virtual ICollection<correos> correos { get; set; } = new List<correos>();
public virtual ICollection<eventos> eventos { get; set; } = new List<eventos>();
public virtual ICollection<expedientesentidades> expedientesentidades { get; set; } = new List<expedientesentidades>();
public virtual ICollection<facturas> facturas { get; set; } = new List<facturas>();
@@ -87,5 +85,7 @@ public partial class entidades
public virtual usuarios? idUsuarioModificadorNavigation { get; set; }
public virtual ICollection<obras> obras { get; set; } = new List<obras>();
public virtual ICollection<presupuestos> presupuestos { get; set; } = new List<presupuestos>();
}

View File

@@ -57,7 +57,7 @@ public partial class facturas
public string? ObservacionesAImprimir { get; set; }
public int? idEvento { get; set; }
public int? idObra { get; set; }
public double ImportePagado { get; set; }
@@ -87,7 +87,7 @@ public partial class facturas
public virtual ficheros? idDatosClienteOriginalNavigation { get; set; }
public virtual eventos? idEventoNavigation { get; set; }
public virtual obras? idObraNavigation { get; set; }
public virtual seriesfacturas idSerieFacturaNavigation { get; set; } = null!;

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using PropertyChanged;
namespace bdGrupoSanchoToro.db;
[AddINotifyPropertyChangedInterface]
public partial class modelospermitidos
{
public int idModeloPermitido { get; set; }
public int idProducto { get; set; }
public int idModeloGrua { get; set; }
public bool Version_Apoyada { get; set; }
public bool Version_Automontante { get; set; }
public bool Version_Bicolumna { get; set; }
public bool Version_Empotrada { get; set; }
public bool Version_ConTraslacion { get; set; }
public virtual productos idModeloGruaNavigation { get; set; } = null!;
public virtual productos idProductoNavigation { get; set; } = null!;
}

View File

@@ -27,7 +27,7 @@ public partial class municipios
public virtual ICollection<entidades> entidades { get; set; } = new List<entidades>();
public virtual ICollection<eventos> eventos { get; set; } = new List<eventos>();
public virtual ICollection<facturas> facturas { get; set; } = new List<facturas>();
public virtual ICollection<obras> obras { get; set; } = new List<obras>();
}

View File

@@ -5,9 +5,9 @@ using PropertyChanged;
namespace bdGrupoSanchoToro.db;
[AddINotifyPropertyChangedInterface]
public partial class eventos
public partial class obras
{
public int idEvento { get; set; }
public int idObra { get; set; }
public string Descripcion { get; set; } = null!;

View File

@@ -15,7 +15,7 @@ public partial class presupuestos
public int idCliente { get; set; }
public int? idEvento { get; set; }
public int? idObra { get; set; }
public double ImporteBruto { get; set; }
@@ -37,14 +37,6 @@ public partial class presupuestos
public double Kilometros { get; set; }
public DateOnly? FechaInicioEvento { get; set; }
public DateOnly? FechaFinEvento { get; set; }
public DateOnly? FechaMontaje { get; set; }
public DateOnly? FechaDesmontaje { get; set; }
public virtual ICollection<albaranes> albaranes { get; set; } = new List<albaranes>();
public virtual ICollection<detallepresupuesto> detallepresupuesto { get; set; } = new List<detallepresupuesto>();
@@ -55,7 +47,7 @@ public partial class presupuestos
public virtual ficheros? idDatosClienteOriginalNavigation { get; set; }
public virtual eventos? idEventoNavigation { get; set; }
public virtual obras? idObraNavigation { get; set; }
public virtual usuarios? idUsuarioNavigation { get; set; }
}

View File

@@ -15,15 +15,13 @@ public partial class productos
public string Descripcion { get; set; } = null!;
public int? idFamilia { get; set; }
public int idFamilia { get; set; }
public int? idTipoHomologacion { get; set; }
public bool? Servicio { get; set; }
public string? ReferenciaFabrica { get; set; }
public int? Tipo { get; set; }
public int Tipo { get; set; }
public string? CodigoBarras { get; set; }
@@ -51,8 +49,6 @@ public partial class productos
public string? Observaciones { get; set; }
public int? idEmpresa { get; set; }
public double? UltimoPrecioCoste { get; set; }
public double? UltimoPrecioCompra { get; set; }
@@ -77,8 +73,16 @@ public partial class productos
public double? PrecioVenta { get; set; }
public string? UnidadesPorEmpresa { get; set; }
public bool? FacturarComoVentaPorDefecto { get; set; }
public virtual ICollection<articulos> articulos { get; set; } = new List<articulos>();
public virtual ICollection<desgloseproductos> desgloseproductosidProductoNavigation { get; set; } = new List<desgloseproductos>();
public virtual ICollection<desgloseproductos> desgloseproductosidProductoPadreNavigation { get; set; } = new List<desgloseproductos>();
public virtual ICollection<desglosetiposofertas> desglosetiposofertas { get; set; } = new List<desglosetiposofertas>();
public virtual ICollection<detallepresupuesto> detallepresupuesto { get; set; } = new List<detallepresupuesto>();
@@ -89,9 +93,7 @@ public partial class productos
public virtual ICollection<detallesfacturasrecibidas> detallesfacturasrecibidas { get; set; } = new List<detallesfacturasrecibidas>();
public virtual empresas? idEmpresaNavigation { get; set; }
public virtual familias? idFamiliaNavigation { get; set; }
public virtual familias idFamiliaNavigation { get; set; } = null!;
public virtual marcas? idMarcaNavigation { get; set; }
@@ -99,6 +101,10 @@ public partial class productos
public virtual usuarios? idUsuarioModificadorNavigation { get; set; }
public virtual ICollection<modelospermitidos> modelospermitidosidModeloGruaNavigation { get; set; } = new List<modelospermitidos>();
public virtual ICollection<modelospermitidos> modelospermitidosidProductoNavigation { get; set; } = new List<modelospermitidos>();
public virtual ICollection<stocks> stocks { get; set; } = new List<stocks>();
public virtual ICollection<tablaalturas> tablaalturas { get; set; } = new List<tablaalturas>();

View File

@@ -35,6 +35,8 @@ public partial class usuarios
public virtual ICollection<correos> correos { get; set; } = new List<correos>();
public virtual ICollection<detallesalbaranes> detallesalbaranes { get; set; } = new List<detallesalbaranes>();
public virtual ICollection<documentosfacturas> documentosfacturas { get; set; } = new List<documentosfacturas>();
public virtual ICollection<documentosfacturasrecibidas> documentosfacturasrecibidas { get; set; } = new List<documentosfacturasrecibidas>();
@@ -45,8 +47,6 @@ public partial class usuarios
public virtual ICollection<entidades> entidadesidUsuarioModificadorNavigation { get; set; } = new List<entidades>();
public virtual ICollection<eventos> eventos { get; set; } = new List<eventos>();
public virtual ICollection<expedientesarticulos> expedientesarticulos { get; set; } = new List<expedientesarticulos>();
public virtual ICollection<expedientesentidades> expedientesentidades { get; set; } = new List<expedientesentidades>();
@@ -67,6 +67,8 @@ public partial class usuarios
public virtual ICollection<movimientoscaja> movimientoscajaidUsuarioSupervisaNavigation { get; set; } = new List<movimientoscaja>();
public virtual ICollection<obras> obras { get; set; } = new List<obras>();
public virtual ICollection<presupuestos> presupuestos { get; set; } = new List<presupuestos>();
public virtual ICollection<productos> productosidUsuarioCreadorNavigation { get; set; } = new List<productos>();

View File

@@ -65,23 +65,25 @@ public partial class v_albaranesextendidos
public int? idEntidad { get; set; }
public int? idEvento { get; set; }
public int idEmpresa { get; set; }
public string? DescripcionEvento { get; set; }
public int? idObra { get; set; }
public string? Telefono1Evento { get; set; }
public string? DescripcionObra { get; set; }
public string? Telefono2Evento { get; set; }
public string? Telefono1Obra { get; set; }
public string? PersonaContactoEvento { get; set; }
public string? Telefono2Obra { get; set; }
public string? DireccionEvento { get; set; }
public string? PersonaContactoObra { get; set; }
public string? CodigoPostalEvento { get; set; }
public string? DireccionObra { get; set; }
public string? CodigoMunicipioEvento { get; set; }
public string? CodigoPostalObra { get; set; }
public string? ObservacionesEvento { get; set; }
public string? CodigoMunicipioObra { get; set; }
public string? ObservacionesObra { get; set; }
public string? NIF { get; set; }

View File

@@ -52,6 +52,8 @@ public partial class GrupoSanchoToroContext : DbContext
public virtual DbSet<cuentascorreo> cuentascorreo { get; set; }
public virtual DbSet<desgloseproductos> desgloseproductos { get; set; }
public virtual DbSet<desglosetiposofertas> desglosetiposofertas { get; set; }
public virtual DbSet<detallepresupuesto> detallepresupuesto { get; set; }
@@ -76,8 +78,6 @@ public partial class GrupoSanchoToroContext : DbContext
public virtual DbSet<enumeraciones> enumeraciones { get; set; }
public virtual DbSet<eventos> eventos { get; set; }
public virtual DbSet<expedientesarticulos> expedientesarticulos { get; set; }
public virtual DbSet<expedientesentidades> expedientesentidades { get; set; }
@@ -112,12 +112,16 @@ public partial class GrupoSanchoToroContext : DbContext
public virtual DbSet<menus> menus { get; set; }
public virtual DbSet<modelospermitidos> modelospermitidos { get; set; }
public virtual DbSet<movimientosbancarios> movimientosbancarios { get; set; }
public virtual DbSet<movimientoscaja> movimientoscaja { get; set; }
public virtual DbSet<municipios> municipios { get; set; }
public virtual DbSet<obras> obras { get; set; }
public virtual DbSet<permisos> permisos { get; set; }
public virtual DbSet<plantillas> plantillas { get; set; }
@@ -170,6 +174,8 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.idAlmacenDestino, "albaranes_almacenes02_idx");
entity.HasIndex(e => e.idEmpresa, "albaranes_empresas_idx");
entity.HasIndex(e => e.idEntidad, "albaranes_entidades_idx");
entity.HasIndex(e => e.CodigoMunicipioCarga, "albaranes_municipios01_idx");
@@ -255,6 +261,10 @@ public partial class GrupoSanchoToroContext : DbContext
.HasForeignKey(d => d.idAlmacenOrigen)
.HasConstraintName("albaranes_almacenes01");
entity.HasOne(d => d.idEmpresaNavigation).WithMany(p => p.albaranes)
.HasForeignKey(d => d.idEmpresa)
.HasConstraintName("albaranes_empresas");
entity.HasOne(d => d.idEntidadNavigation).WithMany(p => p.albaranes)
.HasForeignKey(d => d.idEntidad)
.HasConstraintName("albaranes_entidades");
@@ -400,10 +410,7 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.idProveedor, "articulos_proveedores_idx");
entity.Property(e => e.CodigoArticulo)
.HasMaxLength(10)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.CodigoArticulo).HasMaxLength(20);
entity.Property(e => e.Matricula).HasMaxLength(20);
entity.Property(e => e.NumeroSerie)
.HasMaxLength(40)
@@ -809,6 +816,27 @@ public partial class GrupoSanchoToroContext : DbContext
.HasConstraintName("cuentascorreos_empresas");
});
modelBuilder.Entity<desgloseproductos>(entity =>
{
entity.HasKey(e => e.idDesglose).HasName("PRIMARY");
entity.HasIndex(e => e.idProducto, "productos01_hijo_idx");
entity.HasIndex(e => e.idProductoPadre, "productosPadre_01_idx");
entity.Property(e => e.DescripcionAdicional)
.HasMaxLength(60)
.UseCollation("utf8mb4_0900_as_ci");
entity.HasOne(d => d.idProductoNavigation).WithMany(p => p.desgloseproductosidProductoNavigation)
.HasForeignKey(d => d.idProducto)
.HasConstraintName("productos01_hijo");
entity.HasOne(d => d.idProductoPadreNavigation).WithMany(p => p.desgloseproductosidProductoPadreNavigation)
.HasForeignKey(d => d.idProductoPadre)
.HasConstraintName("productos00_padre");
});
modelBuilder.Entity<desglosetiposofertas>(entity =>
{
entity.HasKey(e => e.idDesglose).HasName("PRIMARY");
@@ -836,17 +864,33 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.idProducto, "detallepresupuesto_productos_idx");
entity.HasIndex(e => e.idDesgloseProducto, "detallespresupuesto_desgloseproductos_idx");
entity.HasIndex(e => e.idDetallePresupuestoPadre, "detallespresupuesto_detallespresupuestos_idx");
entity.Property(e => e.Cantidad).HasDefaultValueSql("'1'");
entity.Property(e => e.Observaciones)
.HasMaxLength(255)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
.UseCollation("utf8mb4_0900_as_ci");
entity.Property(e => e.Parametros)
.HasMaxLength(100)
.UseCollation("utf8mb4_0900_as_ci");
entity.HasOne(d => d.idArticuloNavigation).WithMany(p => p.detallepresupuesto)
.HasForeignKey(d => d.idArticulo)
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("detallepresupuesto_articulos");
entity.HasOne(d => d.idDesgloseProductoNavigation).WithMany(p => p.detallepresupuesto)
.HasForeignKey(d => d.idDesgloseProducto)
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("detallespresupuesto_desgloseproductos");
entity.HasOne(d => d.idDetallePresupuestoPadreNavigation).WithMany(p => p.InverseidDetallePresupuestoPadreNavigation)
.HasForeignKey(d => d.idDetallePresupuestoPadre)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("detallespresupuesto_detallespresupuestos");
entity.HasOne(d => d.idPresupuestoNavigation).WithMany(p => p.detallepresupuesto)
.HasForeignKey(d => d.idPresupuesto)
.HasConstraintName("detallespresupuesto_presupuestos");
@@ -871,6 +915,12 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.idProducto, "detallesalbaranes_productos_idx");
entity.HasIndex(e => e.idUsuarioQueCancela, "detallesalbaranes_usuarios_idx");
entity.Property(e => e.FechaCancelacion).HasColumnType("datetime");
entity.Property(e => e.MotivoCancelacion).HasMaxLength(100);
entity.Property(e => e.Observaciones).HasMaxLength(100);
entity.HasOne(d => d.idAlbaranNavigation).WithMany(p => p.detallesalbaranesidAlbaranNavigation)
.HasForeignKey(d => d.idAlbaran)
.HasConstraintName("detallesalbaranes_albaranes");
@@ -894,13 +944,18 @@ public partial class GrupoSanchoToroContext : DbContext
.HasForeignKey(d => d.idUltimaFactura)
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("detallesalbaranes_facturas");
entity.HasOne(d => d.idUsuarioQueCancelaNavigation).WithMany(p => p.detallesalbaranes)
.HasForeignKey(d => d.idUsuarioQueCancela)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("detallesalbaranes_usuarios");
});
modelBuilder.Entity<detallesfacturas>(entity =>
{
entity.HasKey(e => e.idDetalle).HasName("PRIMARY");
entity.HasIndex(e => e.idDetallePresupuesto, "detallesfacturas_detallespresupuestos_idx");
entity.HasIndex(e => e.idDetallePresupuesto, "detallesfacturas_detallepresupuestos_idx");
entity.HasIndex(e => e.idFactura, "detallesfacturas_facturas_idx");
@@ -918,7 +973,7 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasOne(d => d.idDetallePresupuestoNavigation).WithMany(p => p.detallesfacturas)
.HasForeignKey(d => d.idDetallePresupuesto)
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("detallesfacturas_detallespresupuestos");
.HasConstraintName("detallesfacturas_detallepresupuestos");
entity.HasOne(d => d.idDetalleRTFNavigation).WithMany(p => p.detallesfacturas)
.HasForeignKey(d => d.idDetalleRTF)
@@ -1078,14 +1133,14 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.Descripcion, "Descripcion_UNIQUE").IsUnique();
entity.HasIndex(e => e.idEmpresa, "ejercicioscontables_empresas_idx");
entity.HasIndex(e => e.idEmpresa, "ejercicioscontables_empresascontables_idx");
entity.Property(e => e.Descripcion).HasMaxLength(40);
entity.Property(e => e.NivelesCuentas).HasMaxLength(20);
entity.HasOne(d => d.idEmpresaNavigation).WithMany(p => p.ejercicioscontables)
.HasForeignKey(d => d.idEmpresa)
.HasConstraintName("ejercicioscontables_empresas");
.HasConstraintName("ejercicioscontables_empresascontables");
});
modelBuilder.Entity<empresas>(entity =>
@@ -1280,70 +1335,6 @@ public partial class GrupoSanchoToroContext : DbContext
.HasConstraintName("enumeraciones_gruposenumeraciones");
});
modelBuilder.Entity<eventos>(entity =>
{
entity.HasKey(e => e.idEvento).HasName("PRIMARY");
entity.HasIndex(e => new { e.idEntidad, e.Descripcion }, "eventos_descripcion_unique").IsUnique();
entity.HasIndex(e => e.idEntidad, "obras_entidades_idx");
entity.HasIndex(e => e.CodigoMunicipio, "obras_municipios_idx");
entity.HasIndex(e => e.idUsuario, "obras_usuarios_idx");
entity.Property(e => e.CodigoMunicipio)
.HasMaxLength(10)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.CodigoPostal)
.HasMaxLength(10)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Descripcion)
.HasMaxLength(200)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Direccion)
.HasMaxLength(200)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Email)
.HasMaxLength(100)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Observaciones)
.HasMaxLength(200)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.PersonaContacto)
.HasMaxLength(80)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
entity.Property(e => e.Telefono1)
.HasMaxLength(20)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
entity.Property(e => e.Telefono2)
.HasMaxLength(20)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
entity.HasOne(d => d.CodigoMunicipioNavigation).WithMany(p => p.eventos)
.HasForeignKey(d => d.CodigoMunicipio)
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("destinosmontajes_municipios");
entity.HasOne(d => d.idEntidadNavigation).WithMany(p => p.eventos)
.HasForeignKey(d => d.idEntidad)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("destinosmontajes_entidades");
entity.HasOne(d => d.idUsuarioNavigation).WithMany(p => p.eventos)
.HasForeignKey(d => d.idUsuario)
.HasConstraintName("destinosmontajes_usuarios");
});
modelBuilder.Entity<expedientesarticulos>(entity =>
{
entity.HasKey(e => e.idExpediente).HasName("PRIMARY");
@@ -1436,7 +1427,7 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.idCliente, "facturas_clientes_idx");
entity.HasIndex(e => e.idEvento, "facturas_eventos_idx");
entity.HasIndex(e => e.idObra, "facturas_eventos_idx");
entity.HasIndex(e => e.FechaEnvioAsesoria, "facturas_fechaenvioasesoria");
@@ -1501,10 +1492,10 @@ public partial class GrupoSanchoToroContext : DbContext
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("facturas_DatosOriginales");
entity.HasOne(d => d.idEventoNavigation).WithMany(p => p.facturas)
.HasForeignKey(d => d.idEvento)
entity.HasOne(d => d.idObraNavigation).WithMany(p => p.facturas)
.HasForeignKey(d => d.idObra)
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("facturas_eventos");
.HasConstraintName("facturas_obras");
entity.HasOne(d => d.idSerieFacturaNavigation).WithMany(p => p.facturas)
.HasForeignKey(d => d.idSerieFactura)
@@ -1827,6 +1818,23 @@ public partial class GrupoSanchoToroContext : DbContext
.HasConstraintName("menus_permisos");
});
modelBuilder.Entity<modelospermitidos>(entity =>
{
entity.HasKey(e => e.idModeloPermitido).HasName("PRIMARY");
entity.HasIndex(e => e.idModeloGrua, "modelospermiticos__idx");
entity.HasIndex(e => e.idProducto, "modelospermitidos_productos_idx");
entity.HasOne(d => d.idModeloGruaNavigation).WithMany(p => p.modelospermitidosidModeloGruaNavigation)
.HasForeignKey(d => d.idModeloGrua)
.HasConstraintName("modelospermiticos_modelosgruas");
entity.HasOne(d => d.idProductoNavigation).WithMany(p => p.modelospermitidosidProductoNavigation)
.HasForeignKey(d => d.idProducto)
.HasConstraintName("modelospermitidos_productos");
});
modelBuilder.Entity<movimientosbancarios>(entity =>
{
entity.HasKey(e => e.idMovimientoBancario).HasName("PRIMARY");
@@ -1972,6 +1980,70 @@ public partial class GrupoSanchoToroContext : DbContext
.HasConstraintName("municipios_provincias");
});
modelBuilder.Entity<obras>(entity =>
{
entity.HasKey(e => e.idObra).HasName("PRIMARY");
entity.HasIndex(e => new { e.idEntidad, e.Descripcion }, "eventos_descripcion_unique").IsUnique();
entity.HasIndex(e => e.idEntidad, "obras_entidades_idx");
entity.HasIndex(e => e.CodigoMunicipio, "obras_municipios_idx");
entity.HasIndex(e => e.idUsuario, "obras_usuarios_idx");
entity.Property(e => e.CodigoMunicipio)
.HasMaxLength(10)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.CodigoPostal)
.HasMaxLength(10)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Descripcion)
.HasMaxLength(200)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Direccion)
.HasMaxLength(200)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Email)
.HasMaxLength(100)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Observaciones)
.HasMaxLength(200)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.PersonaContacto)
.HasMaxLength(80)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
entity.Property(e => e.Telefono1)
.HasMaxLength(20)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
entity.Property(e => e.Telefono2)
.HasMaxLength(20)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
entity.HasOne(d => d.CodigoMunicipioNavigation).WithMany(p => p.obras)
.HasForeignKey(d => d.CodigoMunicipio)
.HasConstraintName("obra_municipios");
entity.HasOne(d => d.idEntidadNavigation).WithMany(p => p.obras)
.HasForeignKey(d => d.idEntidad)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("obras_entidades");
entity.HasOne(d => d.idUsuarioNavigation).WithMany(p => p.obras)
.HasForeignKey(d => d.idUsuario)
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("obra_usuarios");
});
modelBuilder.Entity<permisos>(entity =>
{
entity.HasKey(e => e.idPermiso).HasName("PRIMARY");
@@ -2047,7 +2119,7 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.idCliente, "presupuestos_clientes_idx");
entity.HasIndex(e => e.idEvento, "presupuestos_obras_idx");
entity.HasIndex(e => e.idObra, "presupuestos_obras_idx");
entity.HasIndex(e => e.idUsuario, "presupuestos_usuarios_idx");
@@ -2066,10 +2138,10 @@ public partial class GrupoSanchoToroContext : DbContext
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("presupuestos_DatosOriginales");
entity.HasOne(d => d.idEventoNavigation).WithMany(p => p.presupuestos)
.HasForeignKey(d => d.idEvento)
entity.HasOne(d => d.idObraNavigation).WithMany(p => p.presupuestos)
.HasForeignKey(d => d.idObra)
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("presupuestos_eventos");
.HasConstraintName("presupuestos_obras");
entity.HasOne(d => d.idUsuarioNavigation).WithMany(p => p.presupuestos)
.HasForeignKey(d => d.idUsuario)
@@ -2137,8 +2209,6 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.idUsuarioModificador, "productos_02_usuarios_idx");
entity.HasIndex(e => e.idEmpresa, "productos_empresas_idx");
entity.HasIndex(e => e.idFamilia, "productos_familias_idx");
entity.HasIndex(e => e.idMarca, "productos_marcas_idx");
@@ -2150,6 +2220,7 @@ public partial class GrupoSanchoToroContext : DbContext
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
entity.Property(e => e.DescripcionAbreviada).HasMaxLength(45);
entity.Property(e => e.FacturarComoVentaPorDefecto).HasDefaultValueSql("b'0'");
entity.Property(e => e.FechaBaja).HasColumnType("datetime");
entity.Property(e => e.Modelo).HasMaxLength(50);
entity.Property(e => e.Observaciones)
@@ -2159,14 +2230,11 @@ public partial class GrupoSanchoToroContext : DbContext
entity.Property(e => e.PrecioVenta).HasDefaultValueSql("'0'");
entity.Property(e => e.PrefijoNumeroSerie).HasMaxLength(8);
entity.Property(e => e.ReferenciaFabrica).HasMaxLength(45);
entity.HasOne(d => d.idEmpresaNavigation).WithMany(p => p.productos)
.HasForeignKey(d => d.idEmpresa)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("productos_empresas");
entity.Property(e => e.UnidadesPorEmpresa).HasColumnType("json");
entity.HasOne(d => d.idFamiliaNavigation).WithMany(p => p.productos)
.HasForeignKey(d => d.idFamilia)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("productos_familias");
entity.HasOne(d => d.idMarcaNavigation).WithMany(p => p.productos)
@@ -2398,7 +2466,7 @@ public partial class GrupoSanchoToroContext : DbContext
.HasMaxLength(10)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.CodigoMunicipioEvento)
entity.Property(e => e.CodigoMunicipioObra)
.HasMaxLength(10)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
@@ -2410,7 +2478,7 @@ public partial class GrupoSanchoToroContext : DbContext
.HasMaxLength(10)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.CodigoPostalEvento)
entity.Property(e => e.CodigoPostalObra)
.HasMaxLength(10)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
@@ -2422,11 +2490,11 @@ public partial class GrupoSanchoToroContext : DbContext
.HasMaxLength(100)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.DescripcionEvento)
entity.Property(e => e.DescripcionObra)
.HasMaxLength(200)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.DireccionEvento)
entity.Property(e => e.DireccionObra)
.HasMaxLength(200)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
@@ -2456,11 +2524,11 @@ public partial class GrupoSanchoToroContext : DbContext
.HasMaxLength(20)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.ObservacionesEvento)
entity.Property(e => e.ObservacionesObra)
.HasMaxLength(200)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.PersonaContactoEvento)
entity.Property(e => e.PersonaContactoObra)
.HasMaxLength(80)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
@@ -2480,7 +2548,7 @@ public partial class GrupoSanchoToroContext : DbContext
.HasMaxLength(30)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Telefono1Evento)
entity.Property(e => e.Telefono1Obra)
.HasMaxLength(20)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
@@ -2496,7 +2564,7 @@ public partial class GrupoSanchoToroContext : DbContext
.HasMaxLength(30)
.UseCollation("utf8mb3_general_ci")
.HasCharSet("utf8mb3");
entity.Property(e => e.Telefono2Evento)
entity.Property(e => e.Telefono2Obra)
.HasMaxLength(20)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
@@ -2504,7 +2572,7 @@ public partial class GrupoSanchoToroContext : DbContext
.HasMaxLength(100)
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
entity.Property(e => e.idEvento).HasDefaultValueSql("'0'");
entity.Property(e => e.idObra).HasDefaultValueSql("'0'");
});
modelBuilder.Entity<v_apuntesagrupados>(entity =>

View File

@@ -60,7 +60,7 @@ namespace bdGrupoSanchoToro.dbcontext
{
try
{
// optionsBuilder.UseMySql("server=GrupoSanchoToro;database=GrupoSanchoToro;port=13306;uid=m3soft;pwd=Romian2023--;persistsecurityinfo=True;TreatTinyAsBoolean=True;allowuservariables=True", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.2.0-mysql"));
// optionsBuilder.UseMySql("server=GrupoSanchoToro;database=GrupoSanchoToro;port=13306;uid=m3soft;pwd=SanchoToro2023--;persistsecurityinfo=True;TreatTinyAsBoolean=True;allowuservariables=True", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.2.0-mysql"));
string cs = @";persistsecurityinfo=True;TreatTinyAsBoolean=False;allowuservariables=True";
var lc = ListaConexiones();

View File

@@ -46,7 +46,7 @@ namespace bdGrupoSanchoToro
});
private static string? ConexionPorDefecto=null;
public static tscGrupoSanchoToro NuevoContexto(string NombreConexion = "" ,bool Lazy = true, bool SoloLectura = false, bool ConEventoSavingChanges = false, string aplicaciones = "")
public static tscGrupoSanchoToro NuevoContexto(string NombreConexion = "" ,bool Lazy = true, bool SoloLectura = false, bool ConObraSavingChanges = false, string aplicaciones = "")
{
@@ -71,7 +71,7 @@ namespace bdGrupoSanchoToro
var Opciones = ob.Options;
tscGrupoSanchoToro bd = new tscGrupoSanchoToro(Opciones);
bd.Aplicaciones = aplicaciones;
if (ConEventoSavingChanges) bd.SavingChanges += GuardandoCambios;
if (ConObraSavingChanges) bd.SavingChanges += GuardandoCambios;
return bd;
}

View File

@@ -95,6 +95,10 @@
"Name": "cuentascorreo",
"ObjectType": 0
},
{
"Name": "desgloseproductos",
"ObjectType": 0
},
{
"Name": "desglosetiposofertas",
"ObjectType": 0
@@ -143,10 +147,6 @@
"Name": "enumeraciones",
"ObjectType": 0
},
{
"Name": "eventos",
"ObjectType": 0
},
{
"Name": "expedientesarticulos",
"ObjectType": 0
@@ -215,6 +215,10 @@
"Name": "menus",
"ObjectType": 0
},
{
"Name": "modelospermitidos",
"ObjectType": 0
},
{
"Name": "movimientosbancarios",
"ObjectType": 0
@@ -227,6 +231,10 @@
"Name": "municipios",
"ObjectType": 0
},
{
"Name": "obras",
"ObjectType": 0
},
{
"Name": "permisos",
"ObjectType": 0

View File

@@ -0,0 +1,46 @@
using bdGrupoSanchoToro.db;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace bdGrupoSanchoToro.extensiones
{
public class DesglosePorEmpresa
{
public int Empresa { get; set; }
public double TotalUnidades { get; set; }
public double UnidadesInicialesOFabricadas { get; set; }
public double UnidadesCompradas { get; set; }
public double UnidadesAlquiladas { get; set; }
public double UnidadesAveriadas { get; set; }
public double UnidadesVendidas { get; set; }
public double UnidadesSubAlquiladas { get; set; }
public double UnidadesDesechadas { get; set; }
[NotMapped]
[JsonIgnore]
public double UnidadesDisponibles
{
get
{
return this.TotalUnidades - this.UnidadesAlquiladas - this.UnidadesAveriadas;
}
}
[NotMapped]
[JsonIgnore]
public string NombreEmpresa
{
get
{
var emp = empresas.ListadoEmpresas().FirstOrDefault(x => x.idEmpresa == Empresa);
return emp == null ? "" : emp.RazonSocial;
}
}
}
}

View File

@@ -0,0 +1,70 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace bdGrupoSanchoToro.db
{
public partial class desgloseproductos
{
[NotMapped]
public bool ContieneHijos
{
get
{
if (this.idProductoNavigation is not null && this.idProductoNavigation.desgloseproductosidProductoPadreNavigation is not null)
{
return this.idProductoNavigation.desgloseproductosidProductoPadreNavigation.Any();
}
else
{
return false;
}
}
}
[NotMapped]
public ICollection<desgloseproductos> Hijos
{
get
{
return this.idProductoNavigation.desgloseproductosidProductoPadreNavigation;
}
}
[NotMapped]
public productos ProductoPadre
{
get
{
return this.idProductoPadreNavigation;
}
set
{
this.idProductoPadreNavigation = value;
}
}
[NotMapped]
public productos Producto
{
get
{
return this.idProductoNavigation;
}
set
{
this.idProductoNavigation = value;
}
}
[NotMapped]
public bool Descatalogado
{
get
{
return idProductoNavigation.Descatalogado;
}
}
}
}

View File

@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.Linq;
using System.Runtime.CompilerServices;
namespace bdGrupoSanchoToro.db
{
public partial class detallepresupuesto:INotifyPropertyChanged
{
[NotMapped]
public productos? productos
{
get
{
return this.idProductoNavigation;
}
}
[NotMapped]
public virtual string DescripcionEspecial
{
get
{
string Des = this.idProductoNavigation.Descripcion ;
if (Des.Contains("("))
{
Des = Des.Split('(')[0];
}
return Des;
}
}
[NotMapped]
public virtual ICollection<detallepresupuesto>? detallepresupuesto1
{
get
{
return this.InverseidDetallePresupuestoPadreNavigation;
}
}
public double Importe
{
get
{
// If EsVenta Then
return Math.Round(this.Cantidad * this.Precio, 2, MidpointRounding.AwayFromZero);
// Else
// Return Math.Round(Cantidad * Precio * presupuestos.DiasAlquiler, 2, MidpointRounding.AwayFromZero)
// End If
}
}
[NotMapped]
public bool ContieneHijos
{
get
{
return this.detallepresupuesto1 is not null && this.detallepresupuesto1.Count > 0;
}
}
[NotMapped]
public virtual List<detallepresupuesto> DesgloseServicios
{
get
{
return this.detallepresupuesto1.Where(x => x.productos.Tipo == (int)productos.TipoProductoEnum.SERVICIO).ToList();
}
}
[NotMapped]
public virtual List<detallepresupuesto> DesgloseMaterial
{
get
{
return this.detallepresupuesto1.Where(x => x.productos.Tipo < (int)productos.TipoProductoEnum.SERVICIO).ToList();
}
}
public event PropertyChangedEventHandler? PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
public void RefrescaCamposTemporales()
{
this.OnPropertyChanged("Importe");
this.OnPropertyChanged("ImporteGastos");
// OnPropertyChanged("NumeroAsientosTotal")
this.OnPropertyChanged("DesgloseServicios");
this.OnPropertyChanged("DesgloseMaterial");
}
}
}

View File

@@ -1,4 +1,6 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using static bdGrupoSanchoToro.db.productos;
@@ -7,13 +9,32 @@ namespace bdGrupoSanchoToro.db
public partial class detallesalbaranes
{
//public albaranes albaranes
//{
// get
// {
// return this.idAlbaranNavigation;
// }
//}
private double? _UnidadesRecogidasTmp;
[NotMapped]
public double? UnidadesRecogidasTmp
{
get
{
if (_UnidadesRecogidasTmp.HasValue == false)
_UnidadesRecogidasTmp = Cantidad;
return _UnidadesRecogidasTmp;
}
set
{
_UnidadesRecogidasTmp = value;
}
}
[NotMapped]
public string Producto
{
get
{
return this.idProductoNavigation.Descripcion;
}
}
public string NumeroAlbaran
{
get
@@ -63,45 +84,68 @@ namespace bdGrupoSanchoToro.db
return this.idAlbaranNavigation.Entidad;
}
}
public void ActualizaProducto(bdGrupoSanchoToro.dbcontext.GrupoSanchoToroContext bd, int Factor)
public void ActualizaProducto(bdGrupoSanchoToro.tscGrupoSanchoToro bd, albaranes.TipoAlbaranEnum Tipo, int Factor,int Empresa)
{
try
{
var pr = bd.productos.First(x => x.idProducto == this.idProducto);
if (pr.Tipo != (int)TipoProductoEnum.SERVICIO )
if (pr.Tipo < (int)TipoProductoEnum.SERVICIO )
{
var almo = this.idAlbaranNavigation.idAlmacenOrigen.HasValue ? bd.almacenes.First(x => x.idAlmacen== idAlbaranNavigation.idAlmacenOrigen) : (almacenes)null;
var almd = this.idAlbaranNavigation.idAlmacenDestino.HasValue ? bd.almacenes.First(x => x.idAlmacen == this.idAlbaranNavigation.idAlmacenDestino) : (almacenes)null;
switch ((albaranes.TipoAlbaranEnum)this.idAlbaranNavigation.Tipo)
almacenes almo;
almacenes almd;
if (Tipo==albaranes.TipoAlbaranEnum.RECOGIDA || Tipo==albaranes.TipoAlbaranEnum.DEVOLUCION_SUBALQUILER)
{
almo = this.idAlbaranRecogidaNavigation.idAlmacenOrigen.HasValue ? bd.almacenes.First(x => x.idAlmacen == idAlbaranRecogidaNavigation.idAlmacenOrigen) : (almacenes)null;
almd = this.idAlbaranRecogidaNavigation.idAlmacenDestino.HasValue ? bd.almacenes.First(x => x.idAlmacen == this.idAlbaranRecogidaNavigation.idAlmacenDestino) : (almacenes)null;
// Tipo = (albaranes.TipoAlbaranEnum)this.idAlbaranRecogidaNavigation.Tipo;
}
else
{
almo = this.idAlbaranNavigation.idAlmacenOrigen.HasValue ? bd.almacenes.First(x => x.idAlmacen == idAlbaranNavigation.idAlmacenOrigen) : (almacenes)null;
almd = this.idAlbaranNavigation.idAlmacenDestino.HasValue ? bd.almacenes.First(x => x.idAlmacen == this.idAlbaranNavigation.idAlmacenDestino) : (almacenes)null;
// Tipo = (albaranes.TipoAlbaranEnum)this.idAlbaranNavigation.Tipo;
}
switch (Tipo)
{
case albaranes.TipoAlbaranEnum.COMPRA:
{
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
pr.UnidadesCompradas += this.Cantidad * (double)Factor;
pr.ActualizaUnidades(TipoUnidadesEnum.COMPRADAS, Empresa, this.Cantidad * (double)Factor);
this.ActStockGlobal(bd, pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor, Empresa);
break;
}
case albaranes.TipoAlbaranEnum.FABRICACION:
case albaranes.TipoAlbaranEnum.REGULARIZACION_STOCK:
{
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
pr.UnidadesInicialesOFabricadas += this.Cantidad * (double)Factor;
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor);
pr.ActualizaUnidades(TipoUnidadesEnum.INICIALES_O_FABRICADAS, Empresa, this.Cantidad * (double)Factor);
this.ActStockGlobal(bd, pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor, Empresa);
break;
}
case albaranes.TipoAlbaranEnum.CAMBIO_ALMACEN:
{
this.ActStockPorAlmacen(bd, Factor * -1, almo.idAlmacen, pr.idProducto);
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almo.Tipo, false, Factor * -1);
this.ActStockGlobal(bd, pr, (almacenes.TipoAlmacenEnum)almo.Tipo, false, Factor * -1, Empresa);
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almd.Tipo, false, Factor);
this.ActStockGlobal(bd, pr, (almacenes.TipoAlmacenEnum)almd.Tipo, false, Factor, Empresa);
break;
}
case albaranes.TipoAlbaranEnum.ENTREGA:
{
this.ActStockPorAlmacen(bd, Factor * -1, almo.idAlmacen, pr.idProducto);
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almo.Tipo, this.EsVenta, Factor * -1);
this.ActStockGlobal(bd,pr, (almacenes.TipoAlmacenEnum)almo.Tipo, this.EsVenta, Factor * -1, Empresa);
if (this.EsVenta == false)
{
pr.UnidadesAlquiladas += this.Cantidad * (double)Factor;
pr.ActualizaUnidades(TipoUnidadesEnum.ALQUILADAS, Empresa, this.Cantidad * (double)Factor);
}
else
{
pr.UnidadesVendidas += this.Cantidad * (double)Factor;
pr.ActualizaUnidades(TipoUnidadesEnum.VENDIDAS, Empresa, this.Cantidad * (double)Factor);
}
break;
@@ -109,27 +153,29 @@ namespace bdGrupoSanchoToro.db
case albaranes.TipoAlbaranEnum.RECOGIDA:
{
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almd.Tipo, false, Factor);
this.ActStockGlobal(bd,pr, (almacenes.TipoAlmacenEnum)almd.Tipo, false, Factor, Empresa);
pr.UnidadesAlquiladas += this.Cantidad * (double)Factor * (double)-1;
pr.ActualizaUnidades(TipoUnidadesEnum.ALQUILADAS, Empresa, this.Cantidad * (double)Factor * (double)-1);
break;
}
case albaranes.TipoAlbaranEnum.SUBALQUILER:
{
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor);
this.ActStockGlobal(bd,pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor, Empresa);
pr.UnidadesSubAlquiladas += this.Cantidad * (double)Factor;
pr.ActualizaUnidades(TipoUnidadesEnum.SUBALQUILADAS, Empresa, this.Cantidad * (double)Factor);
break;
}
case albaranes.TipoAlbaranEnum.DEVOLUCION_SUBALQUILER:
{
this.ActStockPorAlmacen(bd, Factor * -1, almo.idAlmacen, pr.idProducto);
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almo.Tipo, true, Factor * -1);
this.ActStockGlobal(bd,pr, (almacenes.TipoAlmacenEnum)almo.Tipo, true, Factor * -1, Empresa);
pr.UnidadesSubAlquiladas += this.Cantidad * (double)Factor * (double)-1;
pr.ActualizaUnidades(TipoUnidadesEnum.SUBALQUILADAS, Empresa, this.Cantidad * (double)Factor * (double)-1);
break;
}
}
// bd.SaveChanges()
bd.GuardarCambios();
}
}
catch (Exception ex)
@@ -137,7 +183,7 @@ namespace bdGrupoSanchoToro.db
throw new Exception(ex.Message, ex);
}
}
private void ActStockPorAlmacen(bdGrupoSanchoToro.dbcontext.GrupoSanchoToroContext bd, int Factor, int idAlmacen, int idProducto)
private void ActStockPorAlmacen(bdGrupoSanchoToro.tscGrupoSanchoToro bd, int Factor, int idAlmacen, int idProducto)
{
try
{
@@ -151,13 +197,14 @@ namespace bdGrupoSanchoToro.db
bd.stocks.Add(st);
}
st.Unidades += this.Cantidad * (double)Factor;
bd.GuardarCambios();
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
private void ActStockGlobal(productos pr, almacenes.TipoAlmacenEnum TipoAlmacen, bool ActTotalUnidades, int Factor)
private void ActStockGlobal(bdGrupoSanchoToro.tscGrupoSanchoToro bd, productos pr, almacenes.TipoAlmacenEnum TipoAlmacen, bool ActTotalUnidades, int Factor,int Empresa)
{
try
{
@@ -176,7 +223,11 @@ namespace bdGrupoSanchoToro.db
}
}
if (ActTotalUnidades)
{
pr.TotalUnidades += this.Cantidad * (double)Factor;
pr.ActualizaUnidades(TipoUnidadesEnum.TOTAL, Empresa, this.Cantidad * (double)Factor);
}
bd.GuardarCambios();
}
catch (Exception ex)
{

View File

@@ -0,0 +1,23 @@
using PropertyChanged;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.CompilerServices;
using tsUtilidades.Extensiones;
namespace bdGrupoSanchoToro.db
{
public partial class empresas
{
private static List<empresas>? _ListadoEmpresas;
public static List<empresas> ListadoEmpresas()
{
if (_ListadoEmpresas == null)
{
var bd= bdGrupoSanchoToro.tscGrupoSanchoToro.NuevoContexto();
_ListadoEmpresas = bd.empresas.ToList();
}
return _ListadoEmpresas;
}
}
}

View File

@@ -251,35 +251,35 @@ namespace bdGrupoSanchoToro.db
[NotMapped] public virtual string? Email2_TMP { get; set; }
[NotMapped] public virtual bool EnviarEmail_TMP { get; set; }
#region Eventos
#region Obras
[NotMapped]
public string ProvinciaEvento
public string ProvinciaObra
{
get
{
if (this.idEvento == null || this.idEventoNavigation.CodigoMunicipioNavigation == null) return "";
if (this.idObra == null || this.idObraNavigation.CodigoMunicipioNavigation == null) return "";
else
return this.idEventoNavigation.CodigoMunicipioNavigation.CodigoProvinciaNavigation.Nombre;
return this.idObraNavigation.CodigoMunicipioNavigation.CodigoProvinciaNavigation.Nombre;
}
}
[NotMapped]
public string PoblacionEvento
public string PoblacionObra
{
get
{
if (this.idEvento == null || this.idEventoNavigation.CodigoMunicipioNavigation == null) return "";
if (this.idObra == null || this.idObraNavigation.CodigoMunicipioNavigation == null) return "";
else
return this.idEventoNavigation.CodigoMunicipioNavigation.Nombre;
return this.idObraNavigation.CodigoMunicipioNavigation.Nombre;
}
}
[NotMapped]
public string DireccionEvento
public string DireccionObra
{
get
{
if (this.idEvento == null) return "";
if (this.idObra == null) return "";
else
return this.idEventoNavigation.DireccionCompleta;
return this.idObraNavigation.DireccionCompleta;
}
}
#endregion

View File

@@ -3,7 +3,7 @@
namespace bdGrupoSanchoToro.db
{
public partial class eventos
public partial class obras
{
public string DireccionCompleta
{

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,43 @@
using System;
using bdGrupoSanchoToro.db;
using bdGrupoSanchoToro.extensiones;
using Google.Protobuf.WellKnownTypes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.Json;
namespace bdGrupoSanchoToro.db
{
public partial class productos
public partial class productos : INotifyPropertyChanged
{
private List<DesglosePorEmpresa>? _DesgloseUnidades;
[NotMapped]
public List<DesglosePorEmpresa>? DesgloseUnidades
{
get
{
if (_DesgloseUnidades == null)
{
if (string.IsNullOrEmpty(UnidadesPorEmpresa))
{
_DesgloseUnidades = new List<DesglosePorEmpresa>();
}
else
{
_DesgloseUnidades = JsonSerializer.Deserialize<List<DesglosePorEmpresa>>(UnidadesPorEmpresa);
}
}
return _DesgloseUnidades;
}
set => _DesgloseUnidades=value;
}
[NotMapped]
public bool Descatalogado
{
@@ -32,24 +58,307 @@ namespace bdGrupoSanchoToro.db
}
}
}
// [NotMapped]
//public string DescripcionTipo
//{
// get
// {
// return ((TipoProductoEnum)this.Tipo).ToString().Replace("_", " ");
// }
//}
[NotMapped]
public virtual List<desgloseproductos> DesgloseMaterial
{
get
{
try
{
return this.desgloseproductosidProductoPadreNavigation.Where(x => x.Producto.Tipo < (int)TipoProductoEnum.SERVICIO).OrderBy(x => x.idProductoNavigation.Descripcion).ToList();
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
}
public event PropertyChangedEventHandler? PropertyChanged;
public void RefrescaCamposTemporales()
{
// this.OnPropertyChanged("DesgloseServicios");
this.OnPropertyChanged("DesgloseMaterial");
this.OnPropertyChanged("NumeroProductoTMP");
}
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
[NotMapped]
public string NumeroProductoTMP
{
get
{
if (this.idProducto == 0)
{
return "« AUTOMÁTICO »";
}
else
{
return this.idProducto.ToString();
}
}
}
[NotMapped]
public string DescripcionTipo
{
get
{
return ((TipoProductoEnum)this.Tipo).ToString().Replace("_", " ");
}
}
[NotMapped]
public double UnidadesDisponibles
{
get
{
return this.TotalUnidades - this.UnidadesAlquiladas - this.UnidadesAveriadas;
}
}
[NotMapped]
public int NumeroDescendientes
{
get
{
return this.desgloseproductosidProductoPadreNavigation.Count;
}
}
[NotMapped]
public virtual ICollection<desgloseproductos> Padres
{
get
{
return this.desgloseproductosidProductoNavigation;
}
}
[NotMapped]
public int NivelMaximoAscendientes
{
get
{
int NivelMaximo = 0;
int NivelActual = 0;
ObtieneNivelMaximoAscendiente(this, NivelActual, ref NivelMaximo);
return NivelMaximo - 1;
}
}
[NotMapped]
public int NivelMaximoDescendientes
{
get
{
int NivelMaximo = 0;
int NivelActual = 0;
ObtieneNivelMaximoDescendientes(this, NivelActual, ref NivelMaximo);
return NivelMaximo - 1;
}
}
[NotMapped]
public virtual List<string> ListaAscendientes
{
get
{
var Lista = new List<string>();
ObtieneListaAscendientes(this, "", ref Lista);
return Lista;
}
}
private void ObtieneListaAscendientes(productos p, string NombrePadre, ref List<string> Lista)
{
string NombreActual = (NombrePadre + "/" + p.Descripcion).TrimStart('/');
Lista.Add(NombreActual);
foreach (var d in p.Padres)
ObtieneListaAscendientes(d.ProductoPadre, NombreActual, ref Lista);
}
private void ObtieneNivelMaximoAscendiente(productos p, int NivelActual, ref int NivelMaximo)
{
NivelActual += 1;
NivelMaximo = Math.Max(NivelActual, NivelMaximo);
foreach (var d in p.Padres)
ObtieneNivelMaximoAscendiente(d.ProductoPadre, NivelActual, ref NivelMaximo);
}
public bool ContieneAscendiente(int idProducto)
{
bool bContiene = this.idProducto == idProducto;
if (!bContiene)
{
foreach (var d in Padres)
{
bContiene = d.ProductoPadre.ContieneAscendiente(idProducto);
if (bContiene)
break;
}
}
return bContiene;
}
// Public Function ContieneDescendiente(idProducto As Integer) As Boolean
// Dim bContiene As Boolean = (Me.idProducto = idProducto)
// If Not bContiene Then
// For Each d In Me.desgloseproductos
// bContiene = d.Producto.ContieneDescendiente(idProducto)
// If bContiene Then Exit For
// Next
// End If
// Return bContiene
// End Function
[NotMapped]
public bool ContieneDescendientes
{
get
{
return this.desgloseproductosidProductoPadreNavigation.Any();
}
}
private void ObtieneNivelMaximoDescendientes(productos p, int NivelActual, ref int NivelMaximo)
{
NivelActual += 1;
NivelMaximo = Math.Max(NivelActual, NivelMaximo);
foreach (var d in p.desgloseproductosidProductoPadreNavigation)
this.ObtieneNivelMaximoDescendientes(d.Producto, NivelActual, ref NivelMaximo);
}
[NotMapped] public int CantidadTMP { get; set; }
[NotMapped] public int UnidadesPropiasAIntervaloFechasTMP { get; set; }
[NotMapped] public int UnidadesSubarrendadasAIntervaloFechasTMP { get; set; }
[NotMapped] public int TotalUnidadesAIntervaloFechasTMP { get; set; }
[NotMapped] public int UnidadesPresupuestadasTMP { get; set; }
[NotMapped] public int UnidadesPresupuestadasYAceptadasTMP { get; set; }
[NotMapped] public int UnidadesDisponiblesNoPresupestadasTMP { get; set; }
[NotMapped] public int UnidadesDisponiblesNoContratadasTMP { get; set; }
[NotMapped] public int DisponibilidadTMP { get; set; }
public static void RecalculaStocks(tscGrupoSanchoToro bd, List<productos> lp = null)
{
try
{
var prds = lp is null ? bd.productos.Where(x => x.Tipo < (int)TipoProductoEnum.SERVICIO ).ToList() : lp;
foreach (var pr in prds)
{
pr.TotalUnidades = 0d;
pr.UnidadesInicialesOFabricadas = 0d;
pr.UnidadesCompradas = 0d;
pr.UnidadesVendidas = 0d;
pr.UnidadesAlquiladas = 0d;
pr.UnidadesAveriadas = 0d;
pr.UnidadesDesechadas = 0d;
pr.UnidadesSubAlquiladas = 0d;
pr.DesgloseUnidades?.Clear();
foreach (var st in pr.stocks)
st.Unidades = 0d;
bd.SaveChanges();
List<detallesalbaranes> dets = pr.detallesalbaranes.Where(x=>x.idAlbaranRecogida.HasValue==false).ToList();
foreach (var d in dets)
{
d.ActualizaProducto(bd, (albaranes.TipoAlbaranEnum)d.idAlbaranNavigation.Tipo, 1,d.idAlbaranNavigation.idEmpresa);
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
internal void ActualizaUnidades(TipoUnidadesEnum Tipo, int Empresa, double Cantidad)
{
if (DesgloseUnidades == null) DesgloseUnidades = new List<DesglosePorEmpresa>();
DesglosePorEmpresa du = DesgloseUnidades.FirstOrDefault(x => x.Empresa == Empresa);
if (du == null)
{
du = new DesglosePorEmpresa();
du.Empresa = Empresa;
du.TotalUnidades = 0d;
du.UnidadesInicialesOFabricadas = 0d;
du.UnidadesCompradas = 0d;
du.UnidadesVendidas = 0d;
du.UnidadesAlquiladas = 0d;
du.UnidadesAveriadas = 0d;
du.UnidadesDesechadas = 0d;
du.UnidadesSubAlquiladas = 0d;
DesgloseUnidades.Add(du);
}
switch (Tipo)
{
case TipoUnidadesEnum.TOTAL:
{
du.TotalUnidades += Cantidad;
break;
}
case TipoUnidadesEnum.INICIALES_O_FABRICADAS:
{
du.UnidadesInicialesOFabricadas += Cantidad;
break;
}
case TipoUnidadesEnum.COMPRADAS:
{
du.UnidadesCompradas += Cantidad;
break;
}
case TipoUnidadesEnum.ALQUILADAS:
{
du.UnidadesAlquiladas += Cantidad;
break;
}
case TipoUnidadesEnum.VENDIDAS:
{
du.UnidadesVendidas += Cantidad;
break;
}
case TipoUnidadesEnum.AVERIADAS:
{
du.UnidadesAveriadas += Cantidad;
break;
}
case TipoUnidadesEnum.DESECHADAS:
{
du.UnidadesDesechadas += Cantidad;
break;
}
case TipoUnidadesEnum.SUBALQUILADAS:
{
du.UnidadesSubAlquiladas += Cantidad;
break;
}
}
UnidadesPorEmpresa = JsonSerializer.Serialize(DesgloseUnidades);
}
public enum TipoUnidadesEnum
{
TOTAL=0,
INICIALES_O_FABRICADAS=1,
COMPRADAS = 2,
VENDIDAS=3,
ALQUILADAS=4,
AVERIADAS=5,
DESECHADAS=6,
SUBALQUILADAS=7
}
public enum TipoProductoEnum
{
GRUA = 0,
ELEMENTO_GRUA = 1,
REPUESTO =10,
PIES_GRUA = 2,
REPUESTO = 10,
OTROS_PRODUCTOS = 11,
CONSUMIBLES =12,
CONSUMIBLES = 12,
MATERIAL_OFICINA = 13,
SERVICIO = 99,
HERRAMIENTAS = 99,
SERVICIO = 100,
SOLO_OFERTAS = 200
}
}
}

View File

@@ -0,0 +1,39 @@
using static bdGrupoSanchoToro.db.albaranes;
using Microsoft.VisualBasic.CompilerServices;
namespace bdGrupoSanchoToro.db
{
public partial class v_albaranesextendidos
{
public string PoblacionCarga
{
get
{
return Conversions.ToString(municipios.ObtienePoblacion(this.CodigoMunicipioCarga));
}
}
public string PoblacionDescargarga
{
get
{
return Conversions.ToString(municipios.ObtienePoblacion(this.CodigoMunicipioDescarga));
}
}
public string NumeroAlbaran
{
get
{
return albaranes.ObtieneNumeroAlbaran(this.idAlbaran, (PrefijoAlbaranEnum)this.Tipo);
}
}
public string DescripcionTipoAlbaran
{
get
{
return ((TipoAlbaranEnum)this.Tipo).ToString().Replace("_", " ");
}
}
}
}