private sbyte mySqlUpdateMedication()
		{
			DBConnection dbCon = MySqlHelper.dbCon;

			ArrayList response = dbCon.selectQuery(
			string.Format("SELECT update_medication('{0}', '{1}', '{2}', '{3}')",
						  MedicationPoolWindow.SelectedMedication.Id,
						  MySqlFunctions.EscapeString(medicationNameTextBox.Text),
						  MySqlFunctions.EscapeString(strengthTextBox.Text),
						  routeComboBox.SelectedIndex.ToString()));

			MySqlHelper.disconnect();

			if ((sbyte)(response[0] as ArrayList)[0] == 0)
				MessageBox.Show("Medication not updated.", "Update Error", MessageBoxButton.OK, MessageBoxImage.Error);
			//update selected medication and refresh med pool
			else
			{
				MedicationPoolWindow.SelectedMedication.Name = medicationNameTextBox.Text;
				MedicationPoolWindow.SelectedMedication.Strength = strengthTextBox.Text;
				MedicationPoolWindow.SelectedMedication.Route = routeComboBox.SelectedIndex;
				Medication.refreshMedicationPool();
			}

			return (sbyte)(response[0] as ArrayList)[0];
		}
		private long mySqlAddNewMedication()
		{
			DBConnection dbCon = MySqlHelper.dbCon;

			ArrayList response = dbCon.selectQuery(
			string.Format("SELECT add_medication('{0}', '{1}', '{2}', '{3}')",
						  "NULL",
						  MySqlFunctions.EscapeString(medicationNameTextBox.Text),
						  MySqlFunctions.EscapeString(strengthTextBox.Text),
						  routeComboBox.SelectedIndex.ToString()));

			MySqlHelper.disconnect();

			long newId = (long)(response[0] as ArrayList)[0];

			if (newId == 0)
				MessageBox.Show("Medication not saved.", "Save Error", MessageBoxButton.OK, MessageBoxImage.Error);
			//set selected medication and refresh med pool
			else
			{
				MedicationPoolWindow.SelectedMedication = Medication.fromMySqlMedication(newId);
				Medication.refreshMedicationPool();
			}

			return (long)(response[0] as ArrayList)[0];
		}
Beispiel #3
0
		public MedicationPoolWindow()
		{
			this.InitializeComponent();
			Owner = MainWindow.Instance;
			medicationPoolListView.DataContext = Medication.MedicationPool;
			Medication.refreshMedicationPool();            

			this.Closing += MedicationPoolWindow_Closing;
		}
Beispiel #4
0
		private void deleteButton_Click(object sender, RoutedEventArgs e)
		{
			if (MessageBoxResult.No == MessageBox.Show("Are you sure you want to delete this medication?",
													   "Confirmation", MessageBoxButton.YesNo,
													   MessageBoxImage.Warning)) return;
			if (MySqlHelper.connect() == false) return;

			if (MySqlHelper.dbCon.deleteQuery("DELETE FROM tblMedication WHERE id=" +
											  (medicationPoolListView.SelectedItem as Medication).Id) == false)
				MessageBox.Show("Delete is not possible.\nMedication is referenced by other records in the database.",
								"Delete Error", MessageBoxButton.OK, MessageBoxImage.Error);
			else Medication.refreshMedicationPool();

			MySqlHelper.disconnect();
		}
Beispiel #5
0
		private void newButton_Click(object sender, RoutedEventArgs e)
		{
			Medication.refreshMedicationPool();
			//implicitly sets new mode
			MedicationEditorWindow.EmptyInstance.ShowDialog();
		}
		private void addButton_Click(object sender, RoutedEventArgs e)
		{
			SelectedDose = null;
			Medication.refreshMedicationPool();
			MedicationPoolWindow.Instance.ShowDialog();
		}