20260129 - 01

This commit is contained in:
2026-01-29 13:04:08 +01:00
parent a222729a6a
commit e043d4bdee
39 changed files with 7528 additions and 67 deletions

View File

@@ -0,0 +1,57 @@

using bdGrupoSanchoToro.db;
using Microsoft.VisualBasic;
using System.Linq.Dynamic.Core;
namespace bdGrupoSanchoToro.Importaciones
{
public class ImportaFAMILIAS
{
public static void Importar(byte[] Fichero)
{
try
{
var bd = tscGrupoSanchoToro.NuevoContexto();
var ds = new XSD.FAMILIAS();
ds.ReadXml(new System.IO.MemoryStream(Fichero));
int Ultimalinea = ds.Tables["Datos"].Rows.Count;
var lf = bd.familias.ToList();
var fams = ds.Tables["Datos"].Rows.Cast<XSD.FAMILIAS.DatosRow>().ToList();
foreach (XSD.FAMILIAS.DatosRow fam in fams)
{
try
{
bdGrupoSanchoToro.db.familias f = lf.FirstOrDefault(x => x.Codigo == fam.FACOD);
if (f == null)
{
f = new familias()
{
Codigo = fam.FACOD
};
lf.Add(f);
bd.familias.Add(f);
}
f.Descripcion = fam.FADES;
f.CuentaContableCompra = fam.FACCC;
f.CuentaContableVenta = fam.FACCV;
f.CuentaContableVentaAlquiler = fam.FACCVA;
f.CuentaContableCompraAlquiler = fam.FACCCA;
bd.SaveChanges();
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
}
}