Agregar archivos de proyecto.
This commit is contained in:
73
bdGrupoSanchoToro/extensiones/almacenes.cs
Normal file
73
bdGrupoSanchoToro/extensiones/almacenes.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class almacenes:INotifyPropertyChanged
|
||||
{
|
||||
public string DescripcionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((TipoAlmacenEnum)this.Tipo).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
public string Poblacion
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtienePoblacion(this.CodigoMunicipio);
|
||||
}
|
||||
}
|
||||
|
||||
public string Provincia
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtieneProvincia(this.CodigoMunicipio);
|
||||
}
|
||||
}
|
||||
public string PoblacionProvincia
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((Poblacion ?? "") == (Provincia ?? ""))
|
||||
{
|
||||
return Poblacion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Poblacion + " (" + Provincia + ")";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "** DESCONOCIDO **";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public void RefrescaCamposSoloLectura()
|
||||
{
|
||||
this.OnPropertyChanged("Provincia");
|
||||
this.OnPropertyChanged("Poblacion");
|
||||
}
|
||||
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
|
||||
public enum TipoAlmacenEnum : int
|
||||
{
|
||||
ALMACEN = 0,
|
||||
TALLER_REPARACIONES = 1,
|
||||
UNIDADES_DESCARTADAS = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
37
bdGrupoSanchoToro/extensiones/cajas.cs
Normal file
37
bdGrupoSanchoToro/extensiones/cajas.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class cajas
|
||||
{
|
||||
public double SaldoPendienteCierre
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.movimientoscaja.Where(x => x.idMovimientoCierre.HasValue == false).Sum(x => x.Importe);
|
||||
}
|
||||
}
|
||||
public double SaldoActual
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(Math.Round(this.SaldoAlCierre, 2, MidpointRounding.AwayFromZero) + Math.Round(SaldoPendienteCierre, 2, MidpointRounding.AwayFromZero), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
public string DescripcionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((TipoCajaEnum)this.Tipo).ToString();
|
||||
}
|
||||
}
|
||||
public enum TipoCajaEnum
|
||||
{
|
||||
CONTADO = 0,
|
||||
BANCO = 1
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
29
bdGrupoSanchoToro/extensiones/codigospostales.cs
Normal file
29
bdGrupoSanchoToro/extensiones/codigospostales.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class codigospostales
|
||||
{
|
||||
[NotMapped]
|
||||
public virtual string Provincia
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.CodigoMunicipioNavigation.CodigoProvinciaNavigation.Nombre;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string Poblacion
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.CodigoMunicipioNavigation.Nombre;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
94
bdGrupoSanchoToro/extensiones/conciliacionesbancarias.cs
Normal file
94
bdGrupoSanchoToro/extensiones/conciliacionesbancarias.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class conciliacionesbancarias
|
||||
{
|
||||
[NotMapped]
|
||||
public double ImporteExtractosConciliados
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.movimientosbancarios.Sum(x => x.Importe);
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public double ImporteApuntesConciliados
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.movimientoscaja.Sum(x => x.Importe);
|
||||
}
|
||||
}
|
||||
|
||||
private int? _Anno;
|
||||
|
||||
[NotMapped]
|
||||
public int? Anno
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Anno.HasValue)
|
||||
{
|
||||
return _Anno;
|
||||
}
|
||||
else if (this.FechaInicio == DateOnly.MinValue)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.FechaInicio.Year;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Anno = value;
|
||||
if (_Mes.HasValue)
|
||||
{
|
||||
this.FechaInicio = new DateOnly((int)_Anno, (int)_Mes, 1);
|
||||
this.FechaFin = new DateOnly((int)_Anno, (int)_Mes, DateTime.DaysInMonth((int)_Anno, (int)_Mes));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private int? _Mes;
|
||||
|
||||
[NotMapped]
|
||||
public int? Mes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Mes.HasValue)
|
||||
{
|
||||
return _Mes;
|
||||
}
|
||||
else if (this.FechaInicio == DateOnly.MinValue)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.FechaInicio.Month;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Mes = value;
|
||||
if (_Anno.HasValue)
|
||||
{
|
||||
this.FechaInicio = new DateOnly((int)_Anno, (int)_Mes, 1);
|
||||
this.FechaFin = new DateOnly((int)_Anno, (int)_Mes, DateTime.DaysInMonth((int)_Anno, (int)_Mes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
127
bdGrupoSanchoToro/extensiones/correos.cs
Normal file
127
bdGrupoSanchoToro/extensiones/correos.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Net.Mime;
|
||||
using tsEFCore8.Extensiones;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
[NotMapped]
|
||||
public partial class correos
|
||||
{
|
||||
[NotMapped]
|
||||
public virtual string FicheroAdjunto
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idFicheroAdjunto.HasValue)
|
||||
{
|
||||
return this.idFicheroAdjuntoNavigation.NombreFichero;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraRegistroCorreon(tscGrupoSanchoToro bd, string Asunto, string Cuerpo, bdGrupoSanchoToro.db.cuentascorreo cuenta, string Destinatario, string ConCopia, string ConCopiaOculta, byte[] FicheroAdjunto = null, string NombreFicheroAdjunto = "", int? idAplicacion = default, string CodigoAplicacion = "", int? idEntidad = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sRutaAdjunto = "";
|
||||
var correo = new correos()
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
Copia = ConCopia,
|
||||
CopiaOculta = ConCopiaOculta,
|
||||
DireccionRespuesta = cuenta.Remitente,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
Remitente = cuenta.Remitente,
|
||||
idAplicacion = idAplicacion,
|
||||
CodigoAplicacion = CodigoAplicacion,
|
||||
idEntidad = idEntidad
|
||||
};
|
||||
if (bdGrupoSanchoToro.db.Utilidades.idUsuario > 0)
|
||||
correo.idUsuario = bdGrupoSanchoToro.db.Utilidades.idUsuario;
|
||||
bd.correos.Add(correo);
|
||||
if (FicheroAdjunto is not null)
|
||||
{
|
||||
var fi = new bdGrupoSanchoToro.db.ficheros();
|
||||
fi.Descripcion = "Fichero Adjunto Correo";
|
||||
fi.NombreFichero = NombreFicheroAdjunto;
|
||||
fi.Fichero = FicheroAdjunto;
|
||||
fi.Fecha = DateTime.Now;
|
||||
fi.idTipo = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.ADJCOR").idEnumeracion;
|
||||
correo.idFicheroAdjuntoNavigation = fi;
|
||||
}
|
||||
bd.GuardarCambios();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Write(ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//public static void ProcesaCorreos()
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// var bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
// var EmailEnPruebas = bd.enumeraciones.First(x => x.Codigo == @"CONF.EMAILENPRUEBAS").ValorAlfabeticoLargo;
|
||||
// var EmailCopiaOculta = bd.enumeraciones.First(x => x.Codigo == @"CONF.EMAILCOPIAOCULTAS").ValorAlfabeticoLargo;
|
||||
// // Dim EmailCopiaOculta = bd.enumeraciones.First(Function(x) x.Codigo = "CONF.EMAILCOPIAOCULTA").ValorAlfabeticoLargo
|
||||
|
||||
// var cors = bd.correos.Where(x=>x.FechaAnulacion == null && x.FechaEnvio == null && x.idcuenta !=null).ToList();
|
||||
// foreach (var c in cors)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// c.Asunto = c.Asunto.Replace(Environment.NewLine, " ");
|
||||
// bool bIntentar = false;
|
||||
// if (c.FechaUltimoIntento == null)
|
||||
// { bIntentar = true; }
|
||||
// else
|
||||
// {
|
||||
// if (DateTime.UtcNow.Subtract(c.FechaUltimoIntento.Value).TotalHours>1 ) bIntentar = true;
|
||||
// }
|
||||
// if (bIntentar)
|
||||
// {
|
||||
// string sPass = c.idcuentaNavigation.Password;
|
||||
// if (System.IO.Directory.Exists(@"C:\tecnosis.tfs"))
|
||||
// {
|
||||
// c.Destinatario = "manmog@tecnosis.net";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
|
||||
// throw;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Debug.Write(ex.Message);
|
||||
// throw;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
101
bdGrupoSanchoToro/extensiones/detallesfacturas.cs
Normal file
101
bdGrupoSanchoToro/extensiones/detallesfacturas.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using tsUtilidades.Extensiones;
|
||||
using System.Globalization;
|
||||
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class detallesfacturas
|
||||
{
|
||||
|
||||
public double Importe
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.Cantidad * this.Precio, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
public string Descripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.idProductoNavigation.Descripcion + " " + this.Observaciones.NothingAVacio()).Trim();
|
||||
}
|
||||
}
|
||||
private byte[]? _DetalleRTF;
|
||||
|
||||
[NotMapped]
|
||||
public byte[] DetalleRTF
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DetalleRTF == null)
|
||||
{
|
||||
if (this.idDetalleRTFNavigation != null && this.idDetalleRTFNavigation.Fichero != null)
|
||||
{
|
||||
_DetalleRTF = idDetalleRTFNavigation.Fichero;
|
||||
}
|
||||
else
|
||||
{
|
||||
_DetalleRTF = new byte[0];
|
||||
}
|
||||
}
|
||||
return _DetalleRTF;
|
||||
}
|
||||
set
|
||||
{
|
||||
_DetalleRTF = value;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public bool DetalleRTFModificado { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string DetalleRTFString
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (this.idDetalleRTFNavigation != null && this.idDetalleRTFNavigation.Fichero != null && this.idDetalleRTFNavigation.Fichero.Length>0)
|
||||
{
|
||||
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
|
||||
return encoding.GetString( idDetalleRTFNavigation.Fichero);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ConvertToRtf(this.Descripcion,9.75);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string ConvertToRtf(string inputText, double fontSize)
|
||||
{
|
||||
// Validar el tamaño de la fuente
|
||||
if (fontSize <= 0)
|
||||
{
|
||||
throw new ArgumentException("El tamaño de la fuente debe ser mayor que cero.");
|
||||
}
|
||||
|
||||
// Crear el encabezado RTF
|
||||
StringBuilder rtf = new StringBuilder();
|
||||
rtf.Append(@"{\rtf1\ansi\deff0");
|
||||
rtf.Append(@"{\fonttbl{\f0 Arial;}}");
|
||||
string fs = Math.Round(fontSize * 2,0).ToString(CultureInfo.InvariantCulture);
|
||||
rtf.Append(@"\fs").Append(fs); // RTF usa la mitad del tamaño de punto
|
||||
|
||||
// Agregar el texto
|
||||
rtf.Append(" ");
|
||||
rtf.Append(inputText.Replace("\n", @"\par "));
|
||||
|
||||
// Cerrar el documento RTF
|
||||
rtf.Append("}");
|
||||
|
||||
return rtf.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
28
bdGrupoSanchoToro/extensiones/detallesfacturasrecibidas.cs
Normal file
28
bdGrupoSanchoToro/extensiones/detallesfacturasrecibidas.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using PropertyChanged;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class detallesfacturasrecibidas
|
||||
{
|
||||
public double Importe
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.Cantidad * this.Precio, 4, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
public string Descripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.idProductoNavigation.Descripcion + " " + this.Observaciones.NothingAVacio()).Trim();
|
||||
}
|
||||
}
|
||||
//public byte[]? DetalleRTF { get { } set { } }
|
||||
|
||||
}
|
||||
}
|
||||
26
bdGrupoSanchoToro/extensiones/documentosfacturas.cs
Normal file
26
bdGrupoSanchoToro/extensiones/documentosfacturas.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class documentosfacturas
|
||||
{
|
||||
|
||||
public string DescripcionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((TipoDocumentoFacturaEnum)this.Tipo).ToString();
|
||||
}
|
||||
}
|
||||
public enum TipoDocumentoFacturaEnum
|
||||
{
|
||||
FACTURA_IMPRESA = 0,
|
||||
RECIBO = 1,
|
||||
ALBARAN =2,
|
||||
OTROS=99
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
26
bdGrupoSanchoToro/extensiones/documentosfacturasrecibidas.cs
Normal file
26
bdGrupoSanchoToro/extensiones/documentosfacturasrecibidas.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class documentosfacturasrecibidas
|
||||
{
|
||||
|
||||
public string DescripcionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((TipoDocumentoFacturaEnum)this.Tipo).ToString();
|
||||
}
|
||||
}
|
||||
public enum TipoDocumentoFacturaEnum
|
||||
{
|
||||
FACTURA_IMPRESA = 0,
|
||||
RECIBO = 1,
|
||||
ALBARAN = 2,
|
||||
OTROS = 99
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
31
bdGrupoSanchoToro/extensiones/eventos.cs
Normal file
31
bdGrupoSanchoToro/extensiones/eventos.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class eventos
|
||||
{
|
||||
public string DireccionCompleta
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.CodigoMunicipioNavigation is not null)
|
||||
{
|
||||
if ((this.CodigoMunicipioNavigation.Nombre ?? "") != (this.CodigoMunicipioNavigation.provincias.Nombre ?? ""))
|
||||
{
|
||||
return this.Direccion + " " + this.CodigoPostal + " " + this.CodigoMunicipioNavigation.Nombre + " (" + this.CodigoMunicipioNavigation.provincias.Nombre + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Direccion + " " + this.CodigoPostal + " " + this.CodigoMunicipioNavigation.Nombre;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Direccion.NothingAVacio();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
319
bdGrupoSanchoToro/extensiones/facturas.cs
Normal file
319
bdGrupoSanchoToro/extensiones/facturas.cs
Normal file
@@ -0,0 +1,319 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.VisualBasic;
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
using Newtonsoft.Json;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class facturas
|
||||
{
|
||||
[NotMapped]
|
||||
public virtual string RazonSocialEmpresa
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSerieFacturaNavigation == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idSerieFacturaNavigation.idEmpresaNavigation.RazonSocial;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string DomicilioEmpresa
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSerieFacturaNavigation == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idSerieFacturaNavigation.idEmpresaNavigation.Domicilio;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string PoblacionEmpresa
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSerieFacturaNavigation == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idSerieFacturaNavigation.idEmpresaNavigation.Poblacion;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string CIFEmpresa
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSerieFacturaNavigation == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idSerieFacturaNavigation.idEmpresaNavigation.CIF;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual int? idSerieFactura_Nulable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSerieFactura == 0)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idSerieFactura;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
this.idSerieFactura = value.Value;
|
||||
}
|
||||
// this.OnPropertyChanged("idSerieFactura_Nulable");
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual int? idCliente_Nulable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idCliente == 0)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idCliente;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
this.idCliente = value.Value;
|
||||
}
|
||||
// this.OnPropertyChanged("idCliente_Nulable");
|
||||
}
|
||||
}
|
||||
//[NotMapped]
|
||||
//public virtual double ImportePagado
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (this.movimientoscaja.Any())
|
||||
// {
|
||||
// return this.movimientoscaja.Sum(x => x.Importe);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 0d;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//[NotMapped]
|
||||
//public virtual DateTime? FechaPago
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (ImportePendiente == 0d & this.movimientoscaja.Any())
|
||||
// {
|
||||
// return this.movimientoscaja.OrderByDescending(x => x.Fecha).First().Fecha;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
[NotMapped]
|
||||
public virtual double ImportePendiente
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.TotalFactura - ImportePagado, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
//public event PropertyChangedEventHandler? PropertyChanged;
|
||||
//protected void OnPropertyChanged([CallerMemberName] string name = null)
|
||||
//{
|
||||
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
//}
|
||||
|
||||
|
||||
public void EstableceNumeroFactura(bdGrupoSanchoToro.dbcontext.GrupoSanchoToroContext bd)
|
||||
{
|
||||
seriesfacturas sf = this.idSerieFacturaNavigation;
|
||||
var ts = (bdGrupoSanchoToro.db.seriesfacturas.TipoSerieFacturaEnum)sf.Tipo;
|
||||
if (ts != bdGrupoSanchoToro.db.seriesfacturas.TipoSerieFacturaEnum.EMITIDA_POR_CLIENTE)
|
||||
{
|
||||
string serie = sf.Serie;
|
||||
if (ts == seriesfacturas.TipoSerieFacturaEnum.AUTOMÁTICA_CON_AÑO) serie += (this.FechaFactura.Year % 100).ToString();
|
||||
serie += "/";
|
||||
string sNumeroFactura;
|
||||
var bdtmp = tscGrupoSanchoToro.NuevoContexto();
|
||||
var uf = bdtmp.facturas.Where(x => x.idSerieFactura == sf.idSerieFactura && x.NumeroFactura.StartsWith(serie)).OrderByDescending(x => x.NumeroFactura).FirstOrDefault();
|
||||
int nf = 0;
|
||||
if (uf != null) nf = int.Parse(uf.NumeroFactura.Split("/")[1]);
|
||||
do
|
||||
{
|
||||
nf += 1;
|
||||
sNumeroFactura = serie + nf.ToString().PadLeft(sf.NumeroDigitos, '0');
|
||||
}
|
||||
while (bdtmp.facturas.Any(X => X.NumeroFactura == sNumeroFactura && X.idSerieFactura == sf.idSerieFactura));
|
||||
this.NumeroFactura = sNumeroFactura;
|
||||
}
|
||||
}
|
||||
public virtual string ListaNumeroRecibos
|
||||
{
|
||||
get
|
||||
{
|
||||
string sLista = "";
|
||||
var mvs = this.movimientoscaja.OrderBy(x => x.Fecha).ThenBy(x => x.idMovimiento).ToList();
|
||||
foreach (var m in mvs)
|
||||
sLista += m.NumeroRecibo + Environment.NewLine;
|
||||
return sLista;
|
||||
}
|
||||
}
|
||||
public virtual string ListaFechaPagoRecibos
|
||||
{
|
||||
get
|
||||
{
|
||||
string sLista = "";
|
||||
var mvs = this.movimientoscaja.OrderBy(x => x.Fecha).ThenBy(x => x.idMovimiento).ToList();
|
||||
foreach (var m in mvs)
|
||||
sLista += m.Fecha.ToString("dd/MM/yyyy") + Environment.NewLine;
|
||||
return sLista;
|
||||
}
|
||||
}
|
||||
public virtual string ListaFormaPago
|
||||
{
|
||||
get
|
||||
{
|
||||
string sLista = "";
|
||||
var mvs = this.movimientoscaja.OrderBy(x => x.Fecha).ThenBy(x => x.idMovimiento).ToList();
|
||||
foreach (var m in mvs)
|
||||
sLista += m.idCajaNavigation.Descripcion + Environment.NewLine;
|
||||
return sLista;
|
||||
}
|
||||
}
|
||||
public string ListaImporteRecibos
|
||||
{
|
||||
get
|
||||
{
|
||||
string sLista = "";
|
||||
var mvs = this.movimientoscaja.OrderBy(x => x.Fecha).ThenBy(x => x.idMovimiento).ToList();
|
||||
foreach (var m in mvs)
|
||||
sLista += m.Importe.ToString("c2") + Environment.NewLine;
|
||||
return sLista;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[NotMapped] public virtual bool Marca_TMP { get; set; }
|
||||
[NotMapped] public virtual string? NIF_TMP { get; set; }
|
||||
[NotMapped] public virtual string? Obra_TMP { get; set; }
|
||||
[NotMapped] public virtual string? RazonSocial_TMP { get; set; }
|
||||
[NotMapped] public virtual string? Email_TMP { get; set; }
|
||||
[NotMapped] public virtual string? Email2_TMP { get; set; }
|
||||
[NotMapped] public virtual bool EnviarEmail_TMP { get; set; }
|
||||
|
||||
#region Eventos
|
||||
[NotMapped]
|
||||
public string ProvinciaEvento
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idEvento == null || this.idEventoNavigation.CodigoMunicipioNavigation == null) return "";
|
||||
else
|
||||
return this.idEventoNavigation.CodigoMunicipioNavigation.CodigoProvinciaNavigation.Nombre;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public string PoblacionEvento
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idEvento == null || this.idEventoNavigation.CodigoMunicipioNavigation == null) return "";
|
||||
else
|
||||
return this.idEventoNavigation.CodigoMunicipioNavigation.Nombre;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public string DireccionEvento
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idEvento == null) return "";
|
||||
else
|
||||
return this.idEventoNavigation.DireccionCompleta;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
public static void GuardandoCambios(bdGrupoSanchoToro.dbcontext.GrupoSanchoToroContext bd, string Aplicacion, bool SuperUsuario = false)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
|
||||
// var bdtmp = tscGrupoSanchoToro.NuevoContexto();
|
||||
// var os = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Serialize };
|
||||
// var fras = bd.ChangeTracker.Entries().Where(x => x.State == Microsoft.EntityFrameworkCore.EntityState.Modified && x.Metadata.GetTableName() == "facturas");
|
||||
// foreach (var e in fras)
|
||||
// {
|
||||
// var f = (facturas)e.Entity;
|
||||
// var reant = bdtmp.facturas.First(x => x.idFactura == f.idFactura);
|
||||
// var lr = bdGrupoSanchoToro.db.logs.GeneraLog(bdtmp, "FACTURAS", Aplicacion, reant.idFactura, null, "REGISTRO_COMPLETO", JsonConvert.SerializeObject(reant, os), SuperUsuario);
|
||||
// foreach (var it in f.detallesfacturas)
|
||||
// {
|
||||
// bdGrupoSanchoToro.db.logs.GeneraLog(bdtmp, "DETALLESFACTURAS", Aplicacion, reant.idFactura, lr, "REGISTRO_COMPLETO", JsonConvert.SerializeObject(it, os), SuperUsuario);
|
||||
// }
|
||||
// foreach (var it in f.movimientoscaja)
|
||||
// {
|
||||
// bdGrupoSanchoToro.db.logs.GeneraLog(bdtmp, "MOVIMIENTOSCAJA", Aplicacion, reant.idFactura, lr, "REGISTRO_COMPLETO", JsonConvert.SerializeObject(it, os), SuperUsuario);
|
||||
// }
|
||||
// foreach (var it in f.documentosfacturas)
|
||||
// {
|
||||
// bdGrupoSanchoToro.db.logs.GeneraLog(bdtmp, "DOCUMENTOSFACTURAS", Aplicacion, reant.idFactura, lr, "REGISTRO_COMPLETO", JsonConvert.SerializeObject(reant, os), SuperUsuario);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// Debug.WriteLine(ex.Message);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
91
bdGrupoSanchoToro/extensiones/facturasrecibidas.cs
Normal file
91
bdGrupoSanchoToro/extensiones/facturasrecibidas.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
[NotMapped]
|
||||
public partial class facturasrecibidas:INotifyPropertyChanged
|
||||
{
|
||||
[NotMapped]
|
||||
public virtual int NumeroDocumentos
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.documentosfacturasrecibidas.Count();
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual int? idProveedor_Nulable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idProveedor == 0)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idProveedor;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
this.idProveedor = value.Value;
|
||||
}
|
||||
this.OnPropertyChanged("idProveedor_Nulable");
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual double ImportePendiente
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.TotalFactura - this.ImportePagado, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
private string _FicheroAdjuntoTMP;
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
protected void OnPropertyChanged([CallerMemberName] string name = "")
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual string FicheroAdjuntoTMP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idFicheroNavigation is not null)
|
||||
{
|
||||
_FicheroAdjuntoTMP = this.idFicheroNavigation.NombreFichero;
|
||||
return _FicheroAdjuntoTMP;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
if (this.idFicheroNavigation is not null)
|
||||
{
|
||||
this.idFicheroNavigation = null;
|
||||
}
|
||||
}
|
||||
_FicheroAdjuntoTMP = value;
|
||||
this.OnPropertyChanged("FicheroAdjuntoTMP");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
10
bdGrupoSanchoToro/extensiones/fiestas.cs
Normal file
10
bdGrupoSanchoToro/extensiones/fiestas.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class fiestas
|
||||
{
|
||||
public static List<DateOnly> ListadoFiestas;
|
||||
}
|
||||
}
|
||||
13
bdGrupoSanchoToro/extensiones/formulas.cs
Normal file
13
bdGrupoSanchoToro/extensiones/formulas.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class formulas
|
||||
{
|
||||
public enum TipoFormulaEnum : int
|
||||
{
|
||||
CÁLCULO_POR_PRODUCTO = 0,
|
||||
CÁLCULO_POR_BLOQUE = 1
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
26
bdGrupoSanchoToro/extensiones/logs.cs
Normal file
26
bdGrupoSanchoToro/extensiones/logs.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class logs
|
||||
{
|
||||
public static int GeneraLog(tscGrupoSanchoToro bd, string Tabla , string aplicacion, int id, int? idrelacionado, string Tipo, string Log, bool SuperUsuario)
|
||||
{
|
||||
var nl = new logs();
|
||||
nl.Aplicacion = aplicacion;
|
||||
nl.Tabla = Tabla;
|
||||
nl.Log = Log;
|
||||
nl.id = id;
|
||||
nl.idRelacionado = idrelacionado;
|
||||
nl.ip = bd.ip;
|
||||
nl.FechaHora= tsEFCore8.Extensiones.DbContextExtensions.AhoraMySql(bd);
|
||||
nl.Tipo = Tipo;
|
||||
nl.Usuario = bdGrupoSanchoToro.db.Utilidades.Usuario;
|
||||
nl.idTimeStamp = (double)DateTime.Now.Ticks;
|
||||
nl.VersionPrograma = bdGrupoSanchoToro.db.Utilidades.VersionPrograma;
|
||||
nl.SuperUsuario = SuperUsuario;
|
||||
bd.logs.Add(nl);
|
||||
bd.SaveChanges();
|
||||
return nl.idLog;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
66
bdGrupoSanchoToro/extensiones/movimientosbancarios.cs
Normal file
66
bdGrupoSanchoToro/extensiones/movimientosbancarios.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class movimientosbancarios
|
||||
{
|
||||
private bool? _Conciliado;
|
||||
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public virtual bool Conciliado
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Conciliado.HasValue)
|
||||
{
|
||||
return (bool)_Conciliado;
|
||||
}
|
||||
else if (ConciliacionActual_TMP is not null)
|
||||
{
|
||||
if (ConciliacionActual_TMP.idConciliacion is var arg1 && this.idConciliacion is { } arg2 && arg1 != arg2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Conciliado = value;
|
||||
if (value)
|
||||
{
|
||||
this.idConciliacionNavigation = ConciliacionActual_TMP;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.idConciliacion = default(int?);
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped] public virtual conciliacionesbancarias? ConciliacionActual_TMP { get; set; }
|
||||
public string ConciliadoEn
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((bool)(ConciliacionActual_TMP is not null && this.idConciliacion.HasValue && (ConciliacionActual_TMP.idConciliacion is var arg3 && this.idConciliacion is { } arg4 ? arg4 != arg3 : (bool?)null).GetValueOrDefault()))
|
||||
{
|
||||
return "Nº Conc.: " + this.idConciliacion + " (" + this.idConciliacionNavigation.Anno.ToString() + "-" + this.idConciliacionNavigation.Mes.ToString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
492
bdGrupoSanchoToro/extensiones/movimientoscaja.cs
Normal file
492
bdGrupoSanchoToro/extensiones/movimientoscaja.cs
Normal file
@@ -0,0 +1,492 @@
|
||||
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 Microsoft.VisualBasic.CompilerServices;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class movimientoscaja:INotifyPropertyChanged
|
||||
{
|
||||
|
||||
public string FacturaYFecha
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idFacturaNavigation is not null)
|
||||
{
|
||||
return this.idFacturaNavigation.NumeroFactura + " (" + this.idFacturaNavigation.FechaFactura.ToString("dd-MM-yyyy") + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
public DateTime? FechaCierre
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idMovimientoCierreNavigation is not null)
|
||||
{
|
||||
return this.idMovimientoCierreNavigation.Fecha;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Impresion
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoMovimientoEnum)this.Tipo)
|
||||
{
|
||||
case TipoMovimientoEnum.RECIBO_CLIENTE:
|
||||
{
|
||||
return "Imprimir Recibo";
|
||||
}
|
||||
case TipoMovimientoEnum.CIERRE_CAJA:
|
||||
{
|
||||
return "Imprimir Cierre";
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Clase
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoMovimientoEnum)this.Tipo)
|
||||
{
|
||||
case TipoMovimientoEnum.RECIBO_CLIENTE:
|
||||
{
|
||||
if (this.idFacturaNavigation is null)
|
||||
{
|
||||
return "*DESCONOCIDO*";
|
||||
}
|
||||
else if (this.idFacturaNavigation.TotalIVA != 0d)
|
||||
{
|
||||
return "A";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "B";
|
||||
}
|
||||
}
|
||||
case TipoMovimientoEnum.FIANZA:
|
||||
{
|
||||
return "A";
|
||||
}
|
||||
case TipoMovimientoEnum.RECIBO_PROVEEDOR:
|
||||
{
|
||||
return "A";
|
||||
}
|
||||
case TipoMovimientoEnum.OTROS_GASTOS_O_INGRESOS:
|
||||
{
|
||||
return "B";
|
||||
}
|
||||
case TipoMovimientoEnum.CIERRE_CAJA:
|
||||
{
|
||||
return "CIERRE CAJA";
|
||||
}
|
||||
case TipoMovimientoEnum.REGULARIZACION_CAJA:
|
||||
{
|
||||
return "REGULARIZACION_CAJA"; // TipoMovimientoEnum.TRASPASO_DE_OTRA_CAJA
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return "TRASPASOS";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual double ImporteNegativo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Importe * (double)-1;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Importe = value * -1;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public string RazonSocial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idFactura.HasValue)
|
||||
{
|
||||
return this.idFacturaNavigation.idClienteNavigation.RazonSocial;
|
||||
}
|
||||
else if (this.idFacturaRecibida.HasValue)
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.idProveedorNavigation.RazonSocial;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual int? idEntidad
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (this.idFactura.HasValue)
|
||||
{
|
||||
return this.idFacturaNavigation.idCliente;
|
||||
}
|
||||
else if (this.idFacturaRecibida.HasValue)
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.idProveedor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string ReferenciaDocumento
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (this.idFactura.HasValue)
|
||||
{
|
||||
return !string.IsNullOrEmpty(this.idFacturaNavigation.NumeroFactura.NothingAVacio()) ? this.idFacturaNavigation.NumeroFactura : this.idFacturaNavigation.idFactura.ToString();
|
||||
}
|
||||
else if (this.idFacturaRecibida.HasValue)
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.NumeroFactura;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual DateOnly? FechaDocumento
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (this.idFactura.HasValue)
|
||||
{
|
||||
return this.idFacturaNavigation.FechaFactura;
|
||||
}
|
||||
else if (this.idFacturaRecibida.HasValue)
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.FechaFactura;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual string DescripcionTipoMovimiento
|
||||
{
|
||||
get
|
||||
{
|
||||
TipoMovimientoEnum tip = (TipoMovimientoEnum)this.Tipo;
|
||||
return tip.ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual int? idCaja_Nulable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idCaja == 0)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idCaja;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
this.idCaja = value.Value;
|
||||
}
|
||||
this.OnPropertyChanged("idCaja_Nulable");
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual ICollection<movimientoscaja> MovimientosDelCierre
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InverseidMovimientoCierreNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual string ClienteOProveedor
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoMovimientoEnum)this.Tipo)
|
||||
{
|
||||
case TipoMovimientoEnum.RECIBO_CLIENTE:
|
||||
{
|
||||
return this.idFacturaNavigation.idClienteNavigation.RazonSocial;
|
||||
}
|
||||
|
||||
case TipoMovimientoEnum.RECIBO_PROVEEDOR:
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.idProveedorNavigation.RazonSocial;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string Descripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoMovimientoEnum)this.Tipo)
|
||||
{
|
||||
case TipoMovimientoEnum.RECIBO_CLIENTE:
|
||||
{
|
||||
return "Recibo a " + this.idFacturaNavigation.idClienteNavigation.RazonSocial + " Nº " + this.NumeroRecibo;
|
||||
}
|
||||
|
||||
case TipoMovimientoEnum.RECIBO_PROVEEDOR:
|
||||
{
|
||||
return "Pago a " + this.idFacturaRecibidaNavigation.idProveedorNavigation.RazonSocial + " Fra: " + this.idFacturaRecibidaNavigation.NumeroFactura;
|
||||
}
|
||||
case TipoMovimientoEnum.OTROS_GASTOS_O_INGRESOS:
|
||||
{
|
||||
if (this.Importe > 0d)
|
||||
{
|
||||
return "Ingreso: " + this.Observaciones;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Gasto: " + this.Observaciones;
|
||||
}
|
||||
}
|
||||
case TipoMovimientoEnum.REGULARIZACION_CAJA:
|
||||
{
|
||||
return "Regularización de Caja"; // TipoMovimientoEnum.TRASPASO_DE_OTRA_CAJA
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return this.Observaciones;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual double ImporteCerrado
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InverseidMovimientoCierreNavigation.Sum(x => x.Importe);
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual double SaldoDespuesCierre
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.SaldoAntesCierre + ImporteCerrado;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual double ImporteEntradasMovimientosCerrados
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InverseidMovimientoCierreNavigation.Where(x => x.Importe > 0d).Sum(x => x.Importe);
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual double ImporteSalidasMovimientosCerrados
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InverseidMovimientoCierreNavigation.Where(x => x.Importe < 0d).Sum(x => x.Importe) * -1;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string NumeroReciboTMP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idMovimiento == 0)
|
||||
{
|
||||
return "« AUTOMÁTICO »";
|
||||
}
|
||||
else if (string.IsNullOrEmpty(this.NumeroRecibo.NothingAVacio()))
|
||||
{
|
||||
return this.idMovimiento.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.NumeroRecibo;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void EstableceNumeroRecibo()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.NumeroRecibo.NothingAVacio()))
|
||||
{
|
||||
var ur = this.idFacturaNavigation.movimientoscaja.ToList().Where(x => x.NumeroRecibo.NothingAVacio().Contains(".")).OrderByDescending(x => x.NumeroRecibo).FirstOrDefault();
|
||||
int NuevoRec = 1;
|
||||
if (ur is not null)
|
||||
NuevoRec = Conversions.ToInteger(ur.NumeroRecibo.Split('.')[1]) + 1;
|
||||
this.NumeroRecibo = this.idFacturaNavigation.NumeroFactura + "." + NuevoRec.ToString().PadLeft(3, '0');
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual DateTime? FechaConciliacion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idConciliacionNavigation is not null)
|
||||
{
|
||||
return this.Fecha;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool? _Conciliado;
|
||||
[ NotMapped]public virtual bool Conciliado
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Conciliado.HasValue)
|
||||
{
|
||||
return (bool)_Conciliado;
|
||||
}
|
||||
else if (ConciliacionActual_TMP is not null)
|
||||
{
|
||||
if (ConciliacionActual_TMP.idConciliacion is var arg1 && this.idConciliacion is { } arg2 && arg1 != arg2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Conciliado = value;
|
||||
if (value)
|
||||
{
|
||||
this.idConciliacionNavigation = ConciliacionActual_TMP;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.idConciliacion = default(int?);
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped] public virtual conciliacionesbancarias ConciliacionActual_TMP { get; set; }
|
||||
// Public ReadOnly Property ConciliadoEn As String
|
||||
// Get
|
||||
// If ConciliacionActual_TMP IsNot Nothing AndAlso Me.idConciliacion.HasValue AndAlso Me.idConciliacion <> ConciliacionActual_TMP.idConciliacion Then
|
||||
// Return "Nº Conc.: " & Me.idConciliacion & " (" & Me.conciliacionesbancarias.Año.ToString & "-" & Me.conciliacionesbancarias.Mes.ToString & ")"
|
||||
// Else
|
||||
// Return ""
|
||||
// End If
|
||||
// End Get
|
||||
// End Property
|
||||
private string _FicheroAdjuntoTMP;
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
[NotMapped] public virtual string FicheroAdjuntoTMP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idFicheroNavigation is not null)
|
||||
{
|
||||
_FicheroAdjuntoTMP = this.idFicheroNavigation.NombreFichero;
|
||||
return _FicheroAdjuntoTMP;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
if (this.idFicheroNavigation is not null)
|
||||
{
|
||||
this.idFicheroNavigation = null;
|
||||
}
|
||||
}
|
||||
_FicheroAdjuntoTMP = value;
|
||||
this.OnPropertyChanged("FicheroAdjuntoTMP");
|
||||
}
|
||||
}
|
||||
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
}
|
||||
|
||||
public enum TipoMovimientoEnum
|
||||
{
|
||||
RECIBO_CLIENTE = 0,
|
||||
FIANZA = 1,
|
||||
RECIBO_PROVEEDOR = 2,
|
||||
TRASPASO_CAJA = 3,
|
||||
OTROS_GASTOS_O_INGRESOS = 4,
|
||||
REGULARIZACION_CAJA = 8,
|
||||
CIERRE_CAJA = 9
|
||||
}
|
||||
}
|
||||
252
bdGrupoSanchoToro/extensiones/municipios.cs
Normal file
252
bdGrupoSanchoToro/extensiones/municipios.cs
Normal file
@@ -0,0 +1,252 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
|
||||
public partial class municipios
|
||||
{
|
||||
public provincias? provincias
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.CodigoProvinciaNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<municipios> ListaPoblaciones { get; set; }
|
||||
public string PoblacionYProvincia
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((this.Nombre ?? "") == (this.provincias.Nombre ?? ""))
|
||||
{
|
||||
return this.Nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Nombre + " (" + this.provincias.Nombre + ")";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
public static string ObtienePoblacion(string CodigoPoblacion)
|
||||
{
|
||||
if (ListaPoblaciones is null)
|
||||
{
|
||||
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
ListaPoblaciones = bd.municipios.Include(x=> x.CodigoProvinciaNavigation).ToList();
|
||||
}
|
||||
if (ListaPoblaciones.Any(x => (x.CodigoMunicipio ?? "") == (CodigoPoblacion ?? "")))
|
||||
{
|
||||
return ListaPoblaciones.First(x => (x.CodigoMunicipio ?? "") == (CodigoPoblacion ?? "")).Nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public static string ObtieneProvincia(string CodigoPoblacion)
|
||||
{
|
||||
if (ListaPoblaciones is null)
|
||||
{
|
||||
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
ListaPoblaciones = bd.municipios.Include(x => x.CodigoProvinciaNavigation).ToList();
|
||||
}
|
||||
if (ListaPoblaciones.Any(x => (x.CodigoMunicipio ?? "") == (CodigoPoblacion ?? "")))
|
||||
{
|
||||
return ListaPoblaciones.First(x => (x.CodigoMunicipio ?? "") == (CodigoPoblacion ?? "")).provincias.Nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public static List<municipios> ObtieneListaPoblaciones()
|
||||
{
|
||||
if (ListaPoblaciones is null)
|
||||
{
|
||||
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
ListaPoblaciones = bd.municipios.Include(x => x.CodigoProvinciaNavigation).OrderBy(x => x.Nombre).ToList();
|
||||
}
|
||||
return ListaPoblaciones;
|
||||
}
|
||||
|
||||
public static string ObtieneCodigoMunicipioMasCoincidente( tscGrupoSanchoToro bd, string CodigoPostal, string Poblacion)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Poblacion.NothingAVacio() == "")
|
||||
return "";
|
||||
else
|
||||
{
|
||||
var municipios = bd.codigospostales.Where(x => x.CodigoPostal == CodigoPostal & x.CodigoMunicipioNavigation.Nombre == Poblacion).ToList();
|
||||
if (municipios.Count == 1)
|
||||
return municipios[0].CodigoMunicipio;
|
||||
else if (CodigoPostal.Length == 5)
|
||||
{
|
||||
string codigoprovincia = CodigoPostal.Substring(0, 2);
|
||||
municipios = bd.municipios.Where(x => x.CodigoProvincia == codigoprovincia).SelectMany(x => x.codigospostales).ToList();
|
||||
int IndiceMasCoincidente = 0;
|
||||
int Puntuacion = 0;
|
||||
if (municipios.Count == 0)
|
||||
return "";
|
||||
else
|
||||
for (var i = 0; i <= municipios.Count - 1; i++)
|
||||
{
|
||||
// Dim Porcentaje As Double = 0
|
||||
int puntuaciontmp = ComparaPalabras(municipios[i].CodigoMunicipioNavigation.Nombre, Poblacion);
|
||||
if (i == 0 || Puntuacion < puntuaciontmp)
|
||||
{
|
||||
IndiceMasCoincidente = i;
|
||||
Puntuacion = puntuaciontmp;
|
||||
}
|
||||
}
|
||||
if (Puntuacion == 100)
|
||||
{
|
||||
CrearNuevoCodigoPostal(CodigoPostal, municipios[IndiceMasCoincidente].CodigoMunicipio);
|
||||
return municipios[IndiceMasCoincidente].CodigoMunicipio;
|
||||
}
|
||||
else
|
||||
return CrearNuevoMunicipio(CodigoPostal, Poblacion);
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
throw new Exception(EX.Message, EX);
|
||||
}
|
||||
}
|
||||
public static string ObtieneCodigoMunicipioMasCoincidente(tscGrupoSanchoToro bd,List<codigospostales> CodigosPostales, List<municipios> LMunicipios, string CodigoPostal, string Poblacion)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<codigospostales> municipios = bd.codigospostales.Where(x => x.CodigoPostal == CodigoPostal).ToList();
|
||||
if (municipios.Count == 1)
|
||||
return municipios[0].CodigoMunicipio;
|
||||
else
|
||||
{
|
||||
if (municipios.Count == 0 && CodigoPostal.Length == 5)
|
||||
{
|
||||
var codigoprovincia = CodigoPostal.Substring(0, 2);
|
||||
municipios = LMunicipios.Where(x => x.CodigoProvincia == codigoprovincia).SelectMany(x => x.codigospostales).ToList();
|
||||
}
|
||||
if (bd.codigospostales.Any(x => x.CodigoPostal == CodigoPostal & x.CodigoMunicipioNavigation.Nombre == Poblacion))
|
||||
return CodigosPostales.First(x => x.CodigoPostal == CodigoPostal & x.CodigoMunicipioNavigation.Nombre == Poblacion).CodigoMunicipio;
|
||||
else
|
||||
{
|
||||
int IndiceMasCoincidente = 0;
|
||||
int Puntuacion = 0;
|
||||
if (municipios.Count == 0)
|
||||
return "";
|
||||
else
|
||||
for (var i = 0; i <= municipios.Count - 1; i++)
|
||||
{
|
||||
var puntuaciontmp = ComparaPalabras(municipios[i].CodigoMunicipioNavigation.Nombre, Poblacion);
|
||||
if (i == 0 || Puntuacion < puntuaciontmp)
|
||||
{
|
||||
IndiceMasCoincidente = i;
|
||||
Puntuacion = puntuaciontmp;
|
||||
}
|
||||
}
|
||||
if (Puntuacion > 49)
|
||||
return municipios[IndiceMasCoincidente].CodigoMunicipio;
|
||||
else
|
||||
return CrearNuevoMunicipio(CodigoPostal, Poblacion);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
throw new Exception(EX.Message, EX);
|
||||
}
|
||||
}
|
||||
private static string CrearNuevoMunicipio(string CodigoPostal, string Municipio)
|
||||
{
|
||||
if (Municipio.NothingAVacio() == "")
|
||||
return "";
|
||||
else
|
||||
{
|
||||
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
// municipios nm = new municipios();
|
||||
string codpro = CodigoPostal.Substring(0, 2);
|
||||
municipios ultmun = bd.municipios.Where(x => x.CodigoProvincia == codpro).OrderByDescending(x => x.CodigoMunicipio).First();
|
||||
char Letra;
|
||||
int Numero = 0;
|
||||
if ("0123456789".Contains(ultmun.CodigoMunicipio.Substring(2, 1)))
|
||||
{
|
||||
Letra = 'A';
|
||||
Numero = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Letra = char.Parse(ultmun.CodigoMunicipio.Substring(2, 1));
|
||||
Numero = int.Parse(ultmun.CodigoMunicipio.Substring(3)) + 1;
|
||||
if (Numero > 99)
|
||||
{
|
||||
Letra = Strings.ChrW(Strings.AscW(Letra) + 1);
|
||||
Numero = 0;
|
||||
}
|
||||
}
|
||||
string Nombre = Municipio;
|
||||
string CodigoMunicipio = codpro + Letra + Numero.ToString().PadLeft(2, char.Parse("0"));
|
||||
int rmun = bd.Database.ExecuteSqlRaw("INSERT INTO municipios (`CodigoMunicipio`, `CodigoProvincia`, `Nombre`) VALUES ('" + codpro + "','" + CodigoMunicipio + "','" + Nombre + "')");
|
||||
int rcp = bd.Database.ExecuteSqlRaw("INSERT INTO codigospostales (`CodigoMunicipio`, `CodigoPostal`) VALUES ('" + CodigoMunicipio + "','" + CodigoPostal +"')");
|
||||
return CodigoMunicipio;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void CrearNuevoCodigoPostal(string CodigoPostal, string CodigoMunicipio)
|
||||
{
|
||||
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
if (bd.codigospostales.Any(x => x.CodigoMunicipio == CodigoMunicipio & x.CodigoPostal == CodigoPostal) == false)
|
||||
{
|
||||
int rcp = bd.Database.ExecuteSqlRaw("INSERT INTO codigospostales (`CodigoMunicipio`, `CodigoPostal`, `Nombre`) VALUES ('" + CodigoMunicipio + "','" + CodigoPostal + "')");
|
||||
}
|
||||
}
|
||||
|
||||
private static int ComparaPalabras(string Cadena1, string Cadena2)
|
||||
{
|
||||
try
|
||||
{
|
||||
Cadena1 = Cadena1.ToLower().Replace("á", "a").Replace("é", "e").Replace("í", "i").Replace("ó", "o").Replace("ú", "u").Replace("Ñ", "ñ").Replace("(", " ").Replace(")", " ").Replace("\"", "").Replace("-", " ").Replace(",",string.Empty).Trim();
|
||||
Cadena2 = Cadena2.ToLower().Replace("á", "a").Replace("é", "e").Replace("í", "i").Replace("ó", "o").Replace("ú", "u").Replace("Ñ", "ñ").Replace("(", " ").Replace(")", " ").Replace("\"", "").Replace("-", " ").Replace(",", string.Empty).Trim();
|
||||
var Cadenas1 = Cadena1.Split(" ").Where(X => X != "");
|
||||
var Cadenas2 = Cadena2.Split(" ").Where(X => X != "");
|
||||
int Coincidente = 0;
|
||||
foreach (var c in Cadenas1)
|
||||
{
|
||||
if (Cadenas2.Contains(c))
|
||||
Coincidente += 1;
|
||||
}
|
||||
foreach (var c in Cadenas2)
|
||||
{
|
||||
if (Cadenas1.Contains(c))
|
||||
Coincidente += 1;
|
||||
}
|
||||
return (Coincidente * 100 / (int)(Cadenas1.Count() + Cadenas2.Count()));
|
||||
}
|
||||
// Return Coincidente
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
50
bdGrupoSanchoToro/extensiones/productos.cs
Normal file
50
bdGrupoSanchoToro/extensiones/productos.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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 productos
|
||||
{
|
||||
|
||||
[NotMapped]
|
||||
public bool Descatalogado
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.FechaBaja.HasValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (this.FechaBaja.HasValue == false)
|
||||
this.FechaBaja = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.FechaBaja = default(DateTime?);
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public string DescripcionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((TipoProductoEnum)this.Tipo).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
|
||||
public enum TipoProductoEnum
|
||||
{
|
||||
PRODUCTO = 0,
|
||||
SERVICIO = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
24
bdGrupoSanchoToro/extensiones/seriesfacturas.cs
Normal file
24
bdGrupoSanchoToro/extensiones/seriesfacturas.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class seriesfacturas
|
||||
{
|
||||
|
||||
public string DescripcionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((TipoSerieFacturaEnum)this.Tipo).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
public enum TipoSerieFacturaEnum
|
||||
{
|
||||
AUTOMÁTICA_CON_AÑO = 0,
|
||||
AUTOMÁTICA_SIN_AÑO = 1,
|
||||
EMITIDA_POR_CLIENTE = 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
31
bdGrupoSanchoToro/extensiones/stocks.cs
Normal file
31
bdGrupoSanchoToro/extensiones/stocks.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class stocks
|
||||
{
|
||||
|
||||
public string Almacen
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idAlmacenNavigation.Descripcion;
|
||||
}
|
||||
}
|
||||
public string TipoAlmacen
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idAlmacenNavigation.DescripcionTipo;
|
||||
}
|
||||
}
|
||||
public string Producto
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idProductoNavigation.Descripcion;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user