Example #1
0
 public static DAL.Bewegung LesenID(Int64 bewegungID)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Bewegung.Include("Artikel") where record.BewegungId == bewegungID select record).FirstOrDefault());
     }
 }
Example #2
0
 public static List <DAL.Bewegung> LesenAttributWie(String suchbegriff)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Bewegung.Include("Artikel") where record.Firma.Contains(suchbegriff) select record).ToList());
     }
 }
Example #3
0
 public static List <DAL.Bewegung> LesenAlle()
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Bewegung.Include("Artikel") select record).ToList());
     }
 }
Example #4
0
 public static DAL.Artikel LesenID(Int64 artikelId)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Artikel where record.ArtikelId == artikelId select record).FirstOrDefault());
     }
 }
Example #5
0
 public static List <DAL.Artikel> LesenAttributWie(String suchbegriff)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Artikel where record.Bezeichnung.Contains(suchbegriff) select record).ToList());
     }
 }
Example #6
0
 public static List <DAL.Bewegung> LesenFremdschluesselGleich(DAL.Artikel suchschluessel)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Bewegung.Include("Artikel") where record.Artikel.ArtikelId == suchschluessel.ArtikelId select record).ToList());
     }
 }
 public static List <DAL.Passwort> LesenAttributWie(String suchbegriff)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Passwort.Include("Kategorie") where record.Zielsystem.Contains(suchbegriff) select record).ToList());
     }
 }
Example #8
0
 public static List <DAL.Reservation> LesenFremdschluesselGleich(DAL.Platz suchschluessel)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Reservation.Include("Platz") where record.Platz.PlatzId == suchschluessel.PlatzId select record).ToList());
     }
 }
Example #9
0
 public static List <DAL.Kategorie> LesenAlle()
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Kategorie select record).ToList());
     }
 }
Example #10
0
 public static List <DAL.Kategorie> LesenAttributGleich(String suchbegriff)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Kategorie where record.Name == suchbegriff select record).ToList());
     }
 }
Example #11
0
 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);
     }
 }
Example #12
0
 public static List <DAL.Reservation> LesenAttributWie(String suchbegriff)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Reservation.Include("Platz") where record.Spielername.Contains(suchbegriff) select record).ToList());
     }
 }
Example #13
0
 public static DAL.Passwort LesenID(Int64 passwortId)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Passwort.Include("Kategorie") where record.PasswortId == passwortId select record).FirstOrDefault());
     }
 }
Example #14
0
 public static List <DAL.Passwort> LesenAlle()
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Passwort.Include("Kategorie") select record).ToList());
     }
 }
Example #15
0
 public static DAL.Platz LesenID(Int64 platzId)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Platz where record.PlatzId == platzId select record).FirstOrDefault());
     }
 }
Example #16
0
        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();
                }
            }
        }
Example #17
0
 public static List <DAL.Platz> LesenAttributWie(String suchbegriff)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Platz where record.Name.Contains(suchbegriff) select record).ToList());
     }
 }
Example #18
0
 public static List <DAL.Artikel> LesenAlle()
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Artikel select record).ToList());
     }
 }
Example #19
0
 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);
     }
 }
Example #20
0
 public static List <DAL.Passwort> LesenAttributGleich(String suchbegriff)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Passwort.Include("Kategorie") where record.Login == suchbegriff select record).ToList());
     }
 }
Example #21
0
 public static DAL.Reservation LesenID(Int64 reservationId)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Reservation.Include("Platz") where record.ReservationId == reservationId select record).FirstOrDefault());
     }
 }
Example #22
0
 public static List <DAL.Reservation> LesenAlle()
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Reservation.Include("Platz") select record).ToList());
     }
 }
Example #23
0
 public static List <DAL.Passwort> LesenFremdschluesselGleich(DAL.Kategorie suchschluessel)
 {
     using (var context = new DAL.Context())
     {
         return((from record in context.Passwort.Include("Kategorie") where record.Kategorie.KategorieId == suchschluessel.KategorieId select record).ToList());
     }
 }
Example #24
0
 public static void Aktualisieren(DAL.Passwort passwort)
 {
     using (var context = new DAL.Context())
     {
         context.Entry(passwort).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #25
0
 public static void Loeschen(DAL.Platz platz)
 {
     using (var context = new DAL.Context())
     {
         context.Platz.Remove(platz);
         context.SaveChanges();
     }
 }
Example #26
0
 public static void Aktualisieren(DAL.Kategorie kategorie)
 {
     using (var context = new DAL.Context())
     {
         context.Entry(kategorie).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #27
0
 public static void Loeschen(DAL.Kategorie kategorie)
 {
     using (var context = new DAL.Context())
     {
         context.Kategorie.Remove(kategorie);
         context.SaveChanges();
     }
 }
Example #28
0
 public static void Loeschen(DAL.Bewegung bewegung)
 {
     using (var context = new DAL.Context())
     {
         context.Bewegung.Remove(bewegung);
         context.SaveChanges();
     }
 }
Example #29
0
 public static void Loeschen(DAL.Artikel artikel)
 {
     using (var context = new DAL.Context())
     {
         context.Artikel.Remove(artikel);
         context.SaveChanges();
     }
 }
Example #30
0
 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();
     }
 }
        internal void obtenerNumeroOC()
        {
            DAL.Context db = new DAL.Context();
            this.numeroOC = 1;

            foreach (OrdenDeCompraGeneral OC in db.ordenesDeCompra.Where(s => s.añoOC == this.añoOC && s.tipo == this.tipo).ToList())
            {
                if (OC.numeroOC >= this.numeroOC)
                {
                    this.numeroOC = OC.numeroOC + 1;
                }
            }
        }
        internal void obtenerID()
        {
            DAL.Context db = new DAL.Context();
            this.datosEntregaOrdenCompraGeneralID = 0;

            foreach (datosEntregaOrdenCompraGeneral OC in db.datosEntega.ToList())
            {
                if (OC.datosEntregaOrdenCompraGeneralID >= this.datosEntregaOrdenCompraGeneralID)
                {
                    this.datosEntregaOrdenCompraGeneralID = OC.datosEntregaOrdenCompraGeneralID + 1;
                }
            }
        }
        internal void obtenerID()
        {
            DAL.Context db = new DAL.Context();
            this.DetalleEntregaOrdenCompraGeneralID = 0;

            foreach (DetalleEntregaOrdenCompraGeneral OC in db.detalleEntregaOCG.ToList())
            {
                if (OC.DetalleEntregaOrdenCompraGeneralID >= this.DetalleEntregaOrdenCompraGeneralID)
                {
                    this.DetalleEntregaOrdenCompraGeneralID = OC.DetalleEntregaOrdenCompraGeneralID + 1;
                }
            }
        }
        internal void obtenerID()
        {
            DAL.Context db = new DAL.Context();
            this.DetalleOrdenCompraID = 1;

            foreach (DetalleOrdenCompra OC in db.detalleOrdenCompra.ToList())
            {
                if (OC.DetalleOrdenCompraID >= this.DetalleOrdenCompraID)
                {
                    this.DetalleOrdenCompraID = OC.DetalleOrdenCompraID + 1;
                }
            }
        }
        internal void obtenerID()
        {
            DAL.Context db = new DAL.Context();
            this.OrdenDeCompraGeneralID = 0;

            foreach (OrdenDeCompraGeneral OC in db.ordenesDeCompra.ToList())
            {
                if (OC.OrdenDeCompraGeneralID >= this.OrdenDeCompraGeneralID)
                {
                    this.OrdenDeCompraGeneralID = OC.OrdenDeCompraGeneralID + 1;
                }
            }
        }
Example #36
0
        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();
        }
Example #37
0
        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++;                 
            }                       
        }