Esempio n. 1
0
        private void RefreshTab1Fields()
        {
            if (lastMedicationId != -1)
            {
                //update
                var medication = AdministratorController.GetMedication(lastMedicationId);

                textBox4.Text        = medication.Id.ToString();
                textBox5.Text        = medication.Name;
                textBox6.Text        = medication.Manufacturer;
                textBox7.Text        = medication.Ingredients;
                numericUpDown1.Value = medication.Price;
                numericUpDown2.Value = medication.Stock;
            }
            else
            {
                //new

                textBox4.Text        = "";
                textBox5.Text        = "";
                textBox6.Text        = "";
                textBox7.Text        = "";
                numericUpDown1.Value = 0;
                numericUpDown2.Value = 0;
            }
        }
        public void TestAddMedicationAndSaveOrder()
        {
            var user = AdministratorController.AddOrUpdateUser(0, "user", "name", "password", UserType.Chemist);

            var medication =
                AdministratorController.AddOrUpdateMedication(0, "medication", "manufacturer", "a,b,c", 10, 10);

            Assert.True(medication.Id != 0);

            medication = AdministratorController.GetMedication(medication.Id);

            Dictionary <int, int> contents = new Dictionary <int, int>()
            {
                { medication.Id, 9 }
            };

            var invoice = RegularUserController.SaveOrder(user.Id, "client", contents);

            medication = RegularUserController.GetMedication(medication.Id);

            Assert.True(invoice.Id != 0);
            Assert.True(invoice.Issuer.Id == user.Id);
            Assert.True(medication.Stock == 1);
            Assert.True(invoice.Medications.Count == 1);
        }
        public void TestDeleteMedication()
        {
            var medication =
                AdministratorController.AddOrUpdateMedication(0, "medication", "manufacturer", "a,b,c", 10, 10);

            AdministratorController.DeleteMedication(medication.Id);

            Assert.Throws <InvalidOperationException>(() => AdministratorController.GetMedication(medication.Id));
        }
Esempio n. 4
0
        private void button10_Click(object sender, EventArgs e)
        {
            Medication m = new Medication();

            if (lastMedicationId != -1)
            {
                m = AdministratorController.GetMedication(lastMedicationId);
            }
            else
            {
                m.Ingredients = textBox7.Text;
            }

            IngredientsView form = new IngredientsView(m.Ingredients);

            form.ShowDialog();

            textBox7.Text = form.ingredients;
        }