public void createLocationPrinter(string metroLabel, string titul, string room)
        {
            LocationID = Convert.ToInt32(metroLabel);

            using (ContextModel db = new ContextModel())
            {
                if (LocationID == 0)
                {
                    PrinterLocation printerLocation = new PrinterLocation
                    {
                        Titul = titul,
                        Room  = room
                    };
                    db.PrinterLocations.Add(printerLocation);
                }
                else
                {
                    var mpToUpdate = db.PrinterLocations.SingleOrDefault(pm => pm.LocationID == LocationID);
                    if (mpToUpdate != null)
                    {
                        mpToUpdate.Titul = titul;
                        mpToUpdate.Room  = room;
                    }
                }
                db.SaveChanges();
                load();
            }
        }
        public void deletePrinterLocation(string metroLabel)
        {
            int ID = Convert.ToInt32(metroLabel);

            using (ContextModel db = new ContextModel())
            {
                PrinterLocation printerLocation = db.PrinterLocations
                                                  .Where(p => p.LocationID == ID)
                                                  .FirstOrDefault();
                db.PrinterLocations.Remove(printerLocation);
                db.SaveChanges();
                load();
            }
        }
Пример #3
0
 /// <summary>
 /// Printer information constructor
 /// </summary>
 public PrinterInfo()
 {
     this.PrinterName     = "";
     this.PrinterLocation = PrinterLocation.local;
 }