Beispiel #1
0
 public void AddNewMachine()
 {
     if (SelectedPrintShopName != null)
     {
         SelectedPrintShop      = ListOfPrintShops.Where(p => (p.Name == SelectedPrintShopName)).FirstOrDefault() as PrintShop;
         NewMachine.PrintShopId = SelectedPrintShop.Id;
         if (NewMachine != null)
         {
             MessageBox.Show("New machine added to list");
             DatabaseHelper.Insert <Machine>(NewMachine);
         }
     }
 }
Beispiel #2
0
        public void PopulateListOfMachinesNames()
        {
            SelectedPrintShop = ListOfPrintShops.Where(p => p.Name == SelectedPrintShopName).FirstOrDefault();

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            {
                if (SelectedPrintShopName == null)
                {
                    var listOfMachinesNames  = (conn.Table <Machine>().Select(p => p.Type)).ToList();
                    var listOfMachinesNumber = (conn.Table <Machine>().Select(p => p.SerialNumber)).ToList();

                    ListOfMachinesNames.Clear();
                    foreach (var machineName in listOfMachinesNames)
                    {
                        ListOfMachinesNames.Add("Type: " + machineName + " number: " + (listOfMachinesNumber[listOfMachinesNames.IndexOf(machineName)]));
                    }

                    PopulateListOfMachines(conn, listOfMachinesNumber);
                }
                else if (SelectedPrintShopName != null)
                {
                    var listOfMachinesName = conn.Table <Machine>().Where(p => p.PrintShopId == SelectedPrintShop.Id)
                                             .Select(p => p.Type).ToList();
                    var listOfMachinesNumber = conn.Table <Machine>().Where(p => p.PrintShopId == SelectedPrintShop.Id)
                                               .Select(p => p.SerialNumber).ToList();

                    ListOfMachinesNames.Clear();

                    foreach (var machineName in listOfMachinesName)
                    {
                        ListOfMachinesNames.Add("Type: " + machineName + " number: " + (listOfMachinesNumber[listOfMachinesName.IndexOf(machineName)]));
                    }

                    PopulateListOfMachines(conn, listOfMachinesNumber);
                }
            }
        }