public static void GenerateRandomReplacementsInDatabase(Database database)
        {
            if (database.medBase.Count() > 0)
            {
                int                 index   = rnd.Next(database.medBase.Count());
                Medicine            med     = database[index].Copy();
                ReplacementsCreator creator = new ReplacementsCreator();

                int count = rnd.Next(5);
                for (int i = 0; i < count; i++)
                {
                    Medicine rMed = database.medBase[rnd.Next(database.medBase.Count())];

                    if (database[index] != rMed && med.replacements.IndexOf(rMed) < 0)
                    {
                        med.replacements.Add(rMed);
                        creator.medToAdd.Add(rMed);
                    }
                }

                database.EditMedicine(med, index, creator);
            }
        }
Exemple #2
0
 public MedicineEventArgs(Medicine medicine_)
 {
     newMedicine = medicine_;
     oldMedicine = new Medicine();
     log         = new List <string>();
 }
Exemple #3
0
 public MedicineEventArgs(Medicine oldMedicine_, Medicine newMedicine_)
 {
     oldMedicine = oldMedicine_;
     newMedicine = newMedicine_;
     log         = new List <string>();
 }
 public void EditMedicine(Medicine med, int index, ReplacementsCreator NewReplacements)
 {
     log.OnChangeEventLog(new MedicineEventArgs(medBase[index], med));
     medBase[index].Copy(med);
     NewReplacements.Update(medBase[index]);
 }
 public void EditMedicine(Medicine med, int index)
 {
     log.OnChangeEventLog(new MedicineEventArgs(medBase[index], med));
     medBase[index].Copy(med);
 }
 public void AddMedicine(Medicine medicine, ReplacementsCreator NewReplacements)
 {
     medBase.Add(medicine);
     NewReplacements.Update(medicine);
     log.OnAddEventLog(new MedicineEventArgs(medicine));
 }
 public void AddMedicine(Medicine medicine)
 {
     medBase.Add(medicine);
     log.OnAddEventLog(new MedicineEventArgs(medicine));
 }