public static Int64 Erstellen(DAL.Reservation reservation) { if (reservation.Spielername == null || reservation.Spielername == "") { reservation.Spielername = "leer"; } if (reservation.Startzeit == null) { reservation.Startzeit = DateTime.MinValue; } if (reservation.Endzeit == null) { reservation.Endzeit = DateTime.MinValue; } using (var context = new DAL.Context()) { context.Reservation.Add(reservation); //TODO Check ob mit null möglich, sonst throw Ex if (reservation.Platz != null) { context.Platz.Attach(reservation.Platz); } context.SaveChanges(); return(reservation.ReservationId); } }
public static void Aktualisieren(DAL.Passwort passwort) { using (var context = new DAL.Context()) { context.Entry(passwort).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } using (var context = new DAL.Context()) { var password = context.Passwort .Include(i => i.Kategorie) .FirstOrDefault(i => i.PasswortId == passwort.PasswortId); var category = context.Kategorie .FirstOrDefault(i => i.KategorieId == passwort.Kategorie.KategorieId); if (category != null) { context.Entry(password.Kategorie).State = EntityState.Modified; context.Entry(password).State = EntityState.Modified; password.Kategorie = category; context.SaveChanges(); } } }
public static Int64 Erstellen(DAL.Passwort passwort) { if (passwort.Login == null || passwort.Login == "") { passwort.Login = "******"; } if (passwort.Zielsystem == null || passwort.Zielsystem == "") { passwort.Zielsystem = "leer"; } if (passwort.PSW == null || passwort.PSW == "") { passwort.PSW = "leer"; } // if (classA.TextAttribut == null) throw new Exception("Null ist ungültig"); if (passwort.Eingabedatum == null) { passwort.Eingabedatum = DateTime.MinValue; } if (passwort.Ablaufdatum == null) { passwort.Ablaufdatum = DateTime.MinValue; } using (var context = new DAL.Context()) { context.Passwort.Add(passwort); if (passwort.Kategorie != null) { context.Kategorie.Attach(passwort.Kategorie); } context.SaveChanges(); return(passwort.PasswortId); } }
public static void Aktualisieren(DAL.Kategorie kategorie) { using (var context = new DAL.Context()) { context.Entry(kategorie).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public static void Loeschen(DAL.Platz platz) { using (var context = new DAL.Context()) { context.Platz.Remove(platz); context.SaveChanges(); } }
public static void Loeschen(DAL.Bewegung bewegung) { using (var context = new DAL.Context()) { context.Bewegung.Remove(bewegung); context.SaveChanges(); } }
public static void Aktualisieren(DAL.Passwort passwort) { using (var context = new DAL.Context()) { context.Entry(passwort).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public static void Loeschen(DAL.Kategorie kategorie) { using (var context = new DAL.Context()) { context.Kategorie.Remove(kategorie); context.SaveChanges(); } }
public static void Loeschen(DAL.Artikel artikel) { using (var context = new DAL.Context()) { context.Artikel.Remove(artikel); context.SaveChanges(); } }
public static void Loeschen(DAL.Passwort passwort) { using (var context = new DAL.Context()) { var itemtoRemove = context.Passwort.FirstOrDefault(p => p.PasswortId == passwort.PasswortId); context.Passwort.Remove(itemtoRemove); context.SaveChanges(); } }
public static void Loeschen(DAL.Reservation reservation) { using (var context = new DAL.Context()) { context.Reservation.Attach(reservation); context.Reservation.Remove(reservation); context.SaveChanges(); } }
public static void Aktualisieren(DAL.Artikel artikel) { using (var context = new DAL.Context()) { //TODO null Checks? context.Entry(artikel).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public static void Loeschen(DAL.Kategorie kategorie) { using (var context = new DAL.Context()) { var itemtoRemove = context.Kategorie.FirstOrDefault(k => k.KategorieId == kategorie.KategorieId); context.Kategorie.Remove(itemtoRemove); context.SaveChanges(); } }
public static void Loeschen(DAL.Passwort passwort) { using (var context = new DAL.Context()) { context.Entry(passwort).State = System.Data.Entity.EntityState.Deleted; context.Passwort.Remove(passwort); context.SaveChanges(); } }
public static void LoeschenById(long id) { using (var context = new DAL.Context()) { var pw = context.Passwort.FirstOrDefault(i => i.PasswortId == id); if (pw != null) { context.Passwort.Remove(pw); context.SaveChanges(); } } }
public static void LoeschenById(long id) { using (var context = new DAL.Context()) { var category = context.Kategorie.FirstOrDefault(i => i.KategorieId == id); if (category != null) { context.Kategorie.Remove(category); context.SaveChanges(); } } }
public static Int64 Erstellen(DAL.Artikel artikel) { if (artikel.Bezeichnung == null || artikel.Bezeichnung == "") { artikel.Bezeichnung = "leer"; } using (var context = new DAL.Context()) { context.Artikel.Add(artikel); context.SaveChanges(); return(artikel.ArtikelId); } }
public static Int64 Erstellen(DAL.Kategorie kategorie) { if (kategorie.Name == null || kategorie.Name == "") { kategorie.Name = "leer"; } using (var context = new DAL.Context()) { context.Kategorie.Add(kategorie); context.SaveChanges(); return(kategorie.KategorieId); } }
public static Int64 Erstellen(DAL.Platz platz) { if (platz.Name == null || platz.Name == "") { platz.Name = "leer"; } using (var context = new DAL.Context()) { context.Platz.Add(platz); context.SaveChanges(); return(platz.PlatzId); } }
public static Int64 Erstellen(DAL.Bewegung bewegung) { if (bewegung.Firma == null || bewegung.Firma == "") { bewegung.Firma = "leer"; } if (bewegung.Datum == null) { bewegung.Datum = DateTime.MinValue; } using (var context = new DAL.Context()) { context.Bewegung.Add(bewegung); //TODO Check ob mit null möglich, sonst throw Ex if (bewegung.Artikel != null) { context.Artikel.Attach(bewegung.Artikel); } context.SaveChanges(); return(bewegung.BewegungId); } }
private void importarMaestros() { string fileLocation = Server.MapPath("~/Content/stock.xls"); string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\""; excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; OleDbConnection excelConnection = new OleDbConnection(excelConnectionString); string nombreHoja = "registro$"; string strSQL = "SELECT * FROM [" + nombreHoja + "]"; OleDbDataAdapter da = new OleDbDataAdapter(strSQL, excelConnection); DataSet ds = new DataSet(); da.Fill(ds); int i = 992; RentaMaq.DAL.Context db = new DAL.Context(); while (i<=1116) { Maestro maestro = new Maestro(); DateTime fecha = Formateador.fechaStringToDateTime(Convert.ToString(ds.Tables[0].Rows[i].ItemArray[0])); string numeroParte = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[1]); string descripcion = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[2]); string unidad = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[3]); string entrada = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[4]); string salida = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[5]); string proveedor = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[6]); string preciounitario = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[7]); string preciototal = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[8]); string entregado = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[9]); string afi = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[10]); string observaciones = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[11]); double cantidadEntrante = 0; double cantidadSaliente = 0; if (entrada.Equals("")) { cantidadSaliente = Convert.ToDouble(salida); } else { cantidadEntrante = Convert.ToDouble(entrada); } int precioUnitario = 0; int precioTotal = 0; if (!preciounitario.Equals("")) { precioUnitario = Convert.ToInt32(preciounitario.Replace(",","")); } if (!preciototal.Equals("")) { precioTotal = Convert.ToInt32(Math.Floor(double.Parse(preciototal.Replace(",", "")))); } if (proveedor.Equals("")) { proveedor = "0"; } else { if (proveedor.Trim().Equals("SALFA")) { proveedor = "18"; } else { Proveedor proveedorBuscar = db.Proveedores.Where(s => s.nombreProveedor.Contains(proveedor.Trim())).ToList()[0]; proveedor = proveedorBuscar.ProveedorID.ToString(); } } Producto producto = db.Productos.SingleOrDefault(s => s.numeroDeParte == numeroParte && s.descripcion == descripcion); maestro.fecha = fecha; if (producto != null) { maestro.ProductoID = Convert.ToString(producto.ProductoID); } else { producto = db.Productos.SingleOrDefault(s => s.numeroDeParte == numeroParte); if (producto != null) { maestro.ProductoID = Convert.ToString(producto.ProductoID); } else { //INGRESAR PRODUCTO Producto nuevoProducto = new Producto(); nuevoProducto.numeroDeParte = numeroParte; nuevoProducto.idBodega = 1; nuevoProducto.descripcion = descripcion; nuevoProducto.unidadDeMedida = unidad; db.Productos.Add(nuevoProducto); db.SaveChanges(); maestro.ProductoID = nuevoProducto.ProductoID.ToString(); } } maestro.descripcionProducto = descripcion; maestro.cantidadEntrante = cantidadEntrante; maestro.cantidadSaliente = cantidadSaliente; maestro.proveedor = proveedor; maestro.valorUnitario = precioUnitario; maestro.valorTotal = precioTotal; maestro.entragadoA = entregado; maestro.afiEquipo = afi; maestro.observaciones = observaciones; i++; db.Maestros.Add(maestro); } db.SaveChanges(); }
private void importarProductos(){ string fileLocation = Server.MapPath("~/Content/stock.xls"); string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\""; excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; OleDbConnection excelConnection = new OleDbConnection(excelConnectionString); string nombreHoja = "materiales$"; string strSQL = "SELECT * FROM [" + nombreHoja + "]"; OleDbDataAdapter da = new OleDbDataAdapter(strSQL, excelConnection); DataSet ds = new DataSet(); da.Fill(ds); int i = 0; RentaMaq.DAL.Context db = new DAL.Context(); string total = ""; while (i<858) { string numpart= Convert.ToString(ds.Tables[0].Rows[i].ItemArray[0]); string desc = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[1]); string unidad = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[2]); string precio = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[3]); double stock_min=0; if(!Convert.ToString(ds.Tables[0].Rows[i].ItemArray[4]).Equals("")){ stock_min= Convert.ToDouble(Convert.ToString(ds.Tables[0].Rows[i].ItemArray[4])); } double stock_act = Convert.ToDouble(Convert.ToString(ds.Tables[0].Rows[i].ItemArray[5])); try { Producto productoBuscar = db.Productos.SingleOrDefault(s => s.numeroDeParte == numpart && s.descripcion==desc); if (Object.ReferenceEquals(null, productoBuscar)) { //INGRESAR productoBuscar = db.Productos.SingleOrDefault(s => s.numeroDeParte == numpart); if (Object.ReferenceEquals(null, productoBuscar)) { Producto producto = new Producto(); producto.numeroDeParte = numpart; producto.descripcion = desc; producto.unidadDeMedida = unidad; producto.stockMinimo = stock_min; producto.stockActual = stock_act; db.Productos.Add(producto); db.SaveChanges(); } else { productoBuscar.descripcion = desc; productoBuscar.stockActual = stock_act; productoBuscar.stockMinimo = stock_min; db.Entry(productoBuscar).State = EntityState.Modified; db.SaveChanges(); } } else { //actualizar productoBuscar.descripcion = desc; productoBuscar.stockActual = stock_act; productoBuscar.stockMinimo = stock_min; db.Entry(productoBuscar).State = EntityState.Modified; db.SaveChanges(); } } catch (Exception e) { total = total+"/n" +numpart; } i++; } }
private void importarMaestros() { string fileLocation = Server.MapPath("~/Content/stock.xls"); string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\""; excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; OleDbConnection excelConnection = new OleDbConnection(excelConnectionString); string nombreHoja = "registro$"; string strSQL = "SELECT * FROM [" + nombreHoja + "]"; OleDbDataAdapter da = new OleDbDataAdapter(strSQL, excelConnection); DataSet ds = new DataSet(); da.Fill(ds); int i = 992; RentaMaq.DAL.Context db = new DAL.Context(); while (i <= 1116) { Maestro maestro = new Maestro(); DateTime fecha = Formateador.fechaStringToDateTime(Convert.ToString(ds.Tables[0].Rows[i].ItemArray[0])); string numeroParte = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[1]); string descripcion = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[2]); string unidad = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[3]); string entrada = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[4]); string salida = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[5]); string proveedor = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[6]); string preciounitario = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[7]); string preciototal = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[8]); string entregado = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[9]); string afi = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[10]); string observaciones = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[11]); double cantidadEntrante = 0; double cantidadSaliente = 0; if (entrada.Equals("")) { cantidadSaliente = Convert.ToDouble(salida); } else { cantidadEntrante = Convert.ToDouble(entrada); } int precioUnitario = 0; int precioTotal = 0; if (!preciounitario.Equals("")) { precioUnitario = Convert.ToInt32(preciounitario.Replace(",", "")); } if (!preciototal.Equals("")) { precioTotal = Convert.ToInt32(Math.Floor(double.Parse(preciototal.Replace(",", "")))); } if (proveedor.Equals("")) { proveedor = "0"; } else { if (proveedor.Trim().Equals("SALFA")) { proveedor = "18"; } else { Proveedor proveedorBuscar = db.Proveedores.Where(s => s.nombreProveedor.Contains(proveedor.Trim())).ToList()[0]; proveedor = proveedorBuscar.ProveedorID.ToString(); } } Producto producto = db.Productos.SingleOrDefault(s => s.numeroDeParte == numeroParte && s.descripcion == descripcion); maestro.fecha = fecha; if (producto != null) { maestro.ProductoID = Convert.ToString(producto.ProductoID); } else { producto = db.Productos.SingleOrDefault(s => s.numeroDeParte == numeroParte); if (producto != null) { maestro.ProductoID = Convert.ToString(producto.ProductoID); } else { //INGRESAR PRODUCTO Producto nuevoProducto = new Producto(); nuevoProducto.numeroDeParte = numeroParte; nuevoProducto.idBodega = 1; nuevoProducto.descripcion = descripcion; nuevoProducto.unidadDeMedida = unidad; db.Productos.Add(nuevoProducto); db.SaveChanges(); maestro.ProductoID = nuevoProducto.ProductoID.ToString(); } } maestro.descripcionProducto = descripcion; maestro.cantidadEntrante = cantidadEntrante; maestro.cantidadSaliente = cantidadSaliente; maestro.proveedor = proveedor; maestro.valorUnitario = precioUnitario; maestro.valorTotal = precioTotal; maestro.entragadoA = entregado; maestro.afiEquipo = afi; maestro.observaciones = observaciones; i++; db.Maestros.Add(maestro); } db.SaveChanges(); }
private void importarProductos() { string fileLocation = Server.MapPath("~/Content/stock.xls"); string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\""; excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; OleDbConnection excelConnection = new OleDbConnection(excelConnectionString); string nombreHoja = "materiales$"; string strSQL = "SELECT * FROM [" + nombreHoja + "]"; OleDbDataAdapter da = new OleDbDataAdapter(strSQL, excelConnection); DataSet ds = new DataSet(); da.Fill(ds); int i = 0; RentaMaq.DAL.Context db = new DAL.Context(); string total = ""; while (i < 858) { string numpart = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[0]); string desc = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[1]); string unidad = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[2]); string precio = Convert.ToString(ds.Tables[0].Rows[i].ItemArray[3]); double stock_min = 0; if (!Convert.ToString(ds.Tables[0].Rows[i].ItemArray[4]).Equals("")) { stock_min = Convert.ToDouble(Convert.ToString(ds.Tables[0].Rows[i].ItemArray[4])); } double stock_act = Convert.ToDouble(Convert.ToString(ds.Tables[0].Rows[i].ItemArray[5])); try { Producto productoBuscar = db.Productos.SingleOrDefault(s => s.numeroDeParte == numpart && s.descripcion == desc); if (Object.ReferenceEquals(null, productoBuscar)) { //INGRESAR productoBuscar = db.Productos.SingleOrDefault(s => s.numeroDeParte == numpart); if (Object.ReferenceEquals(null, productoBuscar)) { Producto producto = new Producto(); producto.numeroDeParte = numpart; producto.descripcion = desc; producto.unidadDeMedida = unidad; producto.stockMinimo = stock_min; producto.stockActual = stock_act; db.Productos.Add(producto); db.SaveChanges(); } else { productoBuscar.descripcion = desc; productoBuscar.stockActual = stock_act; productoBuscar.stockMinimo = stock_min; db.Entry(productoBuscar).State = EntityState.Modified; db.SaveChanges(); } } else { //actualizar productoBuscar.descripcion = desc; productoBuscar.stockActual = stock_act; productoBuscar.stockMinimo = stock_min; db.Entry(productoBuscar).State = EntityState.Modified; db.SaveChanges(); } } catch (Exception e) { total = total + "/n" + numpart; } i++; } }