20260129 - 01
This commit is contained in:
57
bdGrupoSanchoToro/Importaciones/ImportaFAMILIAS.cs
Normal file
57
bdGrupoSanchoToro/Importaciones/ImportaFAMILIAS.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user