private void RefreshTab1Fields()
        {
            if (lastId != -1)
            {
                //update
                var medication = RegularUserController.GetMedication(lastId);

                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;

                numericUpDown3.Maximum = medication.Stock;
                numericUpDown3.Value   = (cart.ContainsKey(medication.Id) ? cart[medication.Id] : 0);
            }
            else
            {
                //new

                textBox4.Text        = "";
                textBox5.Text        = "";
                textBox6.Text        = "";
                textBox7.Text        = "";
                numericUpDown1.Value = 0;
                numericUpDown2.Value = 0;
                numericUpDown3.Value = numericUpDown3.Maximum = 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);
        }
        private void RefreshTab2Fields()
        {
            listBox2.Items.Clear();
            textBox8.Clear();

            label8.Text = "Total: " + cart.Select(x => RegularUserController.GetMedication(x.Key).Price *x.Value).Sum();

            foreach (var item in cart)
            {
                var medication = RegularUserController.GetMedication(item.Key);

                listBox2.Items.Add($"{medication.Name}  -  x{item.Value}  -  ¤{item.Value * medication.Price}");
            }
        }