58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
|
|
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);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|