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 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; } }
private void RefreshTab2Fields() { listBox2.Items.Clear(); foreach (var reservation in RegularUserController.GetReservationsFor(lastClientId)) { listBox2.Items.Add(reservation); } var r = RegularUserController.GetReservation(lastClientId); if (r == null) { return; } textBox7.Text = r.Id.ToString(); textBox8.Text = r.Destination; textBox9.Text = r.HotelName; numericUpDown1.Value = r.PersonCount; label13.Text = r.Details; numericUpDown2.Value = r.TotalPrice; numericUpDown3.Value = r.PaidAmount; dateTimePicker1.Value = r.FinalPaymentDate; dateTimePicker2.Value = r.ReservationDate; }
private void textBox1_TextChanged(object sender, EventArgs e) { listBox1.Items.Clear(); foreach (var client in RegularUserController.SearchClients(textBox1.Text)) { listBox1.Items.Add(client); } }
private void RefreshTab3Fields() { listBox3.Items.Clear(); foreach (var reservation in RegularUserController.GetAllMissedReservations()) { listBox3.Items.Add(reservation); } }
private void RefreshTab1List() { listBox1.Items.Clear(); foreach (var medication in RegularUserController.SearchMedication((checkBox1.Checked ? textBox1.Text : ""), (checkBox2.Checked ? textBox2.Text : ""), (checkBox3.Checked ? textBox3.Text : ""))) { listBox1.Items.Add(medication); } }
private void RefreshTab1Fields() { var u = RegularUserController.GetClient(lastClientId); textBox2.Text = u.Id.ToString(); textBox3.Text = u.Name; textBox4.Text = u.ICN; textBox5.Text = u.PNC; textBox6.Text = u.Address; }
private void button4_Click(object sender, EventArgs e) { if (dateTimePicker1.Value < DateTime.Now) { MessageBox.Show("No further changes are allowed to this reservation."); return; } RegularUserController.DeleteReservation(lastHolidayId); lastHolidayId = -1; RefreshTab2Fields(); }
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}"); } }
private void button2_Click(object sender, EventArgs e) { if (!Regex.IsMatch(textBox8.Text, @"\w\w\d{8}")) { MessageBox.Show("Invalid client identifier!"); return; } RegularUserController.SaveOrder(userId, textBox8.Text, cart); MessageBox.Show("Success!"); cart.Clear(); tabControl1.SelectedIndex = 0; RefreshTab1Fields(); }
private void button3_Click(object sender, EventArgs e) { if (dateTimePicker1.Value < DateTime.Now) { MessageBox.Show("No further changes are allowed to this reservation."); return; } if (dateTimePicker2.Value < DateTime.Now) { MessageBox.Show("Cannot set reservation day in the past."); return; } lastHolidayId = RegularUserController.SaveReservation(lastHolidayId, lastClientId, userId, textBox8.Text, textBox9.Text, (int)numericUpDown1.Value, label13.Text, (int)numericUpDown2.Value, (int)numericUpDown3.Value, dateTimePicker1.Value, dateTimePicker2.Value); RefreshTab2Fields(); }
private void button1_Click(object sender, EventArgs e) { if (!Regex.IsMatch(textBox4.Text, @"^[a-zA-Z]{2}\d{6}$")) { MessageBox.Show("PNC must be 2 letters followed by 6 digits"); return; } if (!Regex.IsMatch(textBox5.Text, @"^\d{8,12}$")) { MessageBox.Show("PNC must have 8-12 digits!"); return; } lastClientId = RegularUserController.SaveClient(lastClientId, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text); RefreshTab1Fields(); textBox1_TextChanged(null, null); }