private void simpleButtonMedicationAdd_Click(object sender, EventArgs e)
        {
            if (textBoxMedication.Text.Count() > 0)
            {
                try
                {
                    using (var context = new LorikeetAppEntities())
                    {
                        if (textBoxMedication.Text != "")
                        {
                            var medsToAdd = new MedicationName();

                            medsToAdd.MedicationName1 = textBoxMedication.Text;
                            context.MedicationNames.Add(medsToAdd);

                            context.SaveChanges();

                            Logging.AddLogEntry(staffID, Logging.ErrorCodes.Broadcast, Logging.RefreshCodes.Medication, "Medication Name - " + textBoxMedication.Text + " was added", false);

                            RefreshListBoxes();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logging.AddLogEntry(staffID, Logging.ErrorCodes.Error, Logging.RefreshCodes.None, "Medication Name - " + textBoxMedication.Text + " was not added - Error - " + ex.Message, false);
                    MessageBox.Show(ex.Message);
                }
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                using (var context = new LorikeetAppEntities())
                {
                    if (listBoxMedication.SelectedIndex != -1)
                    {
                        var medicationToRemove = listBoxMedication.SelectedItem.ToString();

                        MedicationName medicationTemp = (from d in context.MedicationNames
                                                         where d.MedicationName1 == medicationToRemove
                                                         select d).DefaultIfEmpty().First();

                        if (medicationTemp != null)
                        {
                            medicationToAdd.Add(medicationTemp);
                            medication.RemoveAt(listBoxMedication.SelectedIndex);

                            RefreshMedication();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #3
0
        public void MedicationNamesTest()
        {
            MedicationLine target = new MedicationLine();
            MedicationName name   = new MedicationName("NameTest", "InfoTest");

            target.MedicationNames.Add(name);
            Assert.AreEqual(name, target.MedicationNames[0], "NhsCui.Toolkit.Web.MedicationLine.MedicationNames was not set correctly.");
        }
Beispiel #4
0
        public void MedicationNamesTest()
        {
            MedicationNameLabel target = new MedicationNameLabel();
            MedicationName      item   = new MedicationName("Name", "Info");

            target.MedicationNames.Add(item);

            Assert.AreEqual(item, target.MedicationNames[0], "NhsCui.Toolkit.Web.MedicationNameLabel.MedicationNames was not set correctly.");
        }
Beispiel #5
0
        public void RemoveItemTest()
        {
            MedicationNameCollection target = new MedicationNameCollection();
            MedicationName           item   = new MedicationName("Name", "Info");

            target.Add(item);
            target.Remove(item);
            Assert.AreEqual <int>(0, target.Count, "MedicationName was not removed correctly");
        }
Beispiel #6
0
        public void NameTest()
        {
            MedicationName target = new MedicationName();

            string val = "AName"; // TODO: Assign to an appropriate value for the property

            target.Name = val;

            Assert.AreEqual(val, target.Name, "NhsCui.Toolkit.Web.MedicationName.Name was not set correctly.");
        }
Beispiel #7
0
        public void InformationTest()
        {
            MedicationName target = new MedicationName();

            string val = "Info";

            target.Information = val;

            Assert.AreEqual(val, target.Information, "NhsCui.Toolkit.Web.MedicationName.Information was not set correctly.");
        }
Beispiel #8
0
        public void DisplayLengthTest2()
        {
            MedicationName target = new MedicationName();

            target.Name = "TestName";

            int val = target.Name.Length;

            Assert.AreEqual(val, target.DisplayLength, "NhsCui.Toolkit.Web.MedicationName.DisplayLength was not set correctly.");
        }
Beispiel #9
0
        public void ValidateTest()
        {
            MedicationNameCollection target = new MedicationNameCollection();
            MedicationName           name   = new MedicationName("Name", "Information");
            int displayLength = name.DisplayLength;

            for (int i = 0; i < (MedicationName.MaximumDisplayLength / displayLength) + 1; i++)
            {
                target.Add(name);
            }
        }
Beispiel #10
0
        public void DisplayLengthTest()
        {
            MedicationName target = new MedicationName();

            target.Name        = "TestName";
            target.Information = "Information";

            int val = target.Name.Length + MedicationName.Separator.Length + target.Information.Length; // TODO: Assign to an appropriate value for the property

            Assert.AreEqual(val, target.DisplayLength, "NhsCui.Toolkit.Web.MedicationName.DisplayLength was not set correctly.");
        }
Beispiel #11
0
        public void InsertItemTest()
        {
            MedicationNameCollection target = new MedicationNameCollection();
            string         name             = "Name";
            string         info             = "Information";
            MedicationName item             = new MedicationName(name, info);

            target.Add(item);
            Assert.AreEqual <int>(1, target.Count, "MedicationName was not added correctly");
            Assert.AreEqual <string>(name, target[0].Name, "MedicationName was not added correctly");
            Assert.AreEqual <string>(info, target[0].Information, "MedicationName was not added correctly");
        }
Beispiel #12
0
        public void SetItemTest()
        {
            MedicationNameCollection target = new MedicationNameCollection();
            MedicationName           item   = new MedicationName("Name1", "Info1");

            target.Add(item);

            MedicationName item2 = new MedicationName("Name2", "Info2");

            target[0] = item2;
            Assert.AreEqual <MedicationName>(item2, target[0], "MedicationNameCollection setitem failed");
        }
Beispiel #13
0
        public void ConstructorTest()
        {
            string name = "AName";        // TODO: Initialize to an appropriate value

            string information = "AInfo"; // TODO: Initialize to an appropriate value

            MedicationName target = new MedicationName(name, information);

            // TODO: Implement code to verify target
            Assert.AreEqual(name, target.Name, "NhsCui.Toolkit.Web.MedicationName.Name was not set correctly.");
            Assert.AreEqual(information, target.Information, "NhsCui.Toolkit.Web.MedicationName.Information was not set correctly.");
        }
Beispiel #14
0
        public void ToStringTest()
        {
            MedicationName target = new MedicationName();

            string name = "TestName";
            string info = "TestInfo";

            target.Name        = name;
            target.Information = info;
            string expected = name + MedicationName.Separator + info;
            string actual;

            actual = target.ToString();

            Assert.AreEqual(expected, actual, "NhsCui.Toolkit.Web.MedicationName.ToString did not return the expected value.");
        }
Beispiel #15
0
        public void NotifyPropertyChangedTestName()
        {
            MedicationName target = new MedicationName();

            target.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.OnPropertyChanged);
            this.propertyChangedThreadEvent.Reset();
            string name = "NewInfo"; // TODO: Initialize to an appropriate value

            target.Name = name;
            if (!this.propertyChangedThreadEvent.WaitOne(500, false))
            {
                Assert.Fail("Property Changed event was not raised for Name Property");
            }
            else
            {
                Assert.AreEqual <string>(this.changedPropertyName, "Name");
            }
        }
Beispiel #16
0
        public void NameNullTest()
        {
            MedicationName target = new MedicationName();

            target.Name = null;
        }
Beispiel #17
0
        public bool Save()
        {
            SQLiteDatabase sqlDatabase = null;

            try
            {
                Globals dbHelp = new Globals();
                dbHelp.OpenDatabase();
                sqlDatabase = dbHelp.GetSQLiteDatabase();
                if (sqlDatabase != null)
                {
                    if (sqlDatabase.IsOpen)
                    {
                        if (IsNew)
                        {
                            Log.Info(TAG, "Save: New Medication item to Save...");
                            ContentValues values = new ContentValues();
                            values.Put("MedicationName", MedicationName.Trim());
                            values.Put("TotalDailyDosage", TotalDailyDosage);
                            ID = (int)sqlDatabase.Insert("Medication", null, values);
                            Log.Info(TAG, "Save: Successfully saved - ID - " + ID.ToString());
                            IsNew   = false;
                            IsDirty = false;
                            if (MedicationSpread != null && MedicationSpread.Count > 0)
                            {
                                foreach (var spread in MedicationSpread)
                                {
                                    spread.Save(spread.ID, ID);
                                    Log.Info(TAG, "Save (insert): Saved Medication Spread with ID - " + spread.ID.ToString());
                                }
                            }
                            if (PrescriptionType != null)
                            {
                                PrescriptionType.Save(ID);
                                Log.Info(TAG, "Save (insert): Saved Prescription Type ID - " + ID.ToString());
                            }
                        }
                        if (IsDirty)
                        {
                            Log.Info(TAG, "LoadMedicationSpreads: Exisitng Medication to Update with ID - " + ID.ToString());
                            ContentValues values = new ContentValues();
                            values.Put("MedicationName", MedicationName.Trim());
                            values.Put("TotalDailyDosage", TotalDailyDosage);
                            string whereClause = "ID = ?";
                            sqlDatabase.Update("Medication", values, whereClause, new string[] { ID.ToString() });
                            Log.Info(TAG, "Save (update): Updated Medication with ID - " + ID.ToString());
                            IsDirty = false;
                            if (MedicationSpread != null && MedicationSpread.Count > 0)
                            {
                                foreach (var spread in MedicationSpread)
                                {
                                    spread.Save(spread.ID, ID);
                                    Log.Info(TAG, "Save (update): Saved Medication Spread with ID - " + spread.ID.ToString());
                                }
                            }
                            if (PrescriptionType != null)
                            {
                                PrescriptionType.Save(ID);
                                Log.Info(TAG, "Save (Update): Saved Prescription type with ID - " + PrescriptionType.ID.ToString());
                            }
                        }
                        sqlDatabase.Close();
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception e)
            {
                Log.Error(TAG, "Save: Exception - " + e.Message);
                if (sqlDatabase != null && sqlDatabase.IsOpen)
                {
                    sqlDatabase.Close();
                }
                return(false);
            }
        }
Beispiel #18
0
        public void NameEmptyTest()
        {
            MedicationName target = new MedicationName();

            target.Name = string.Empty;
        }