private void Btn_Withdraw_med_Click(object sender, RoutedEventArgs e) { var medSelected = Dg_AllMedicines.SelectedItem; var medicine = medSelected as Medicine; App._withdrawnMedicines.Add(medicine); // adding medicine to withdrawn collection App._allMedicines.Remove(medicine); // removing medicine from allMedicines collection MyStorage.WriteXml <ObservableCollection <Medicine> >(App._withdrawnMedicines, "withdrawnMedicines.xml"); MyStorage.WriteXml <ObservableCollection <Medicine> >(App._allMedicines, "allMedicines.xml"); MessageBox.Show($"{medicine.medName} withdrawn!"); }
private void Btn_Med_Save_Click(object sender, RoutedEventArgs e) { if (Tbx_Med_sNum.Text == "" | Tbx_Med_Name.Text == "" | Tbx_Med_Strength.Text == "" | Tbx_Med_Expiry.SelectedDate == DateTime.Today | Tbx_Med_PackSize.Text == Convert.ToString("")) //checking for textboxes to be not empty { MessageBox.Show("Please fill-in all the fields first!"); } else { MyStorage.WriteXml <ObservableCollection <Donor> >(App._donors, "donors.xml"); MyStorage.WriteXml <ObservableCollection <Medicine> >(App._allMedicines, "allMedicines.xml"); Tbx_Med_sNum.IsEnabled = false; Tbx_Med_Name.IsEnabled = false; Tbx_Med_Strength.IsEnabled = false; Tbx_Med_Expiry.IsEnabled = false; Tbx_Med_PackSize.IsEnabled = false; Btn_Med_Save.IsEnabled = false; } }
private void Btn_Donor_Del_Click(object sender, RoutedEventArgs e) { Tbx_filter.Text = ""; var itm2delete = Dg_Donor.SelectedItem; if (itm2delete == null) { MessageBox.Show("Please select donor to be deleted first!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } var donor = itm2delete as Donor; var res = MessageBox.Show($"Do you really want to delete {donor.firstName} {donor.lastName}", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (res == MessageBoxResult.Yes) { App._donors.Remove(donor); MyStorage.WriteXml <ObservableCollection <Donor> >(App._donors, "donors.xml"); } }
private void Btn_Med_Del_Click_1(object sender, RoutedEventArgs e) { var dSelected = Dg_Donor.SelectedItem; if (dSelected == null) { MessageBox.Show("Please select a donor first!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } else { var med = Dg_Med_list.SelectedItem; var medicine = med as Medicine; var res = MessageBox.Show($"Do you really want to delete {medicine.medName}", "warning!", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (res == MessageBoxResult.Yes) { (dSelected as Donor).medicines.Remove(medicine); // remove medicine from donor collection App._allMedicines.Remove(medicine); // remove medicine from allMedicine collection MyStorage.WriteXml <ObservableCollection <Donor> >(App._donors, "donors.xml"); MyStorage.WriteXml <ObservableCollection <Medicine> >(App._allMedicines, "allMedicines.xml"); } } }
private void Application_Startup(object sender, StartupEventArgs e) { _donors = MyStorage.ReadXml <ObservableCollection <Donor> >("donors.xml"); if (_donors == null) { _donors = new ObservableCollection <Donor>(); } _allMedicines = MyStorage.ReadXml <ObservableCollection <Medicine> >("allMedicines.xml"); if (_allMedicines == null) { _allMedicines = new ObservableCollection <Medicine>(); } _withdrawnMedicines = MyStorage.ReadXml <ObservableCollection <Medicine> >("withdrawnMedicines.xml"); if (_withdrawnMedicines == null) { _withdrawnMedicines = new ObservableCollection <Medicine>(); } _selectedItem = new ObservableCollection <DonorDetails>(); }
private void Btn_Donor_Save_Click(object sender, RoutedEventArgs e) { var input = Tbx_cNumber.Text; var regEx = new Regex(@"(^\+[0-9]{2}\s+[0-9]{2}\s+[0-9]{8}$)|(^\+[0-9]{2}\s+[0-9]{3}\s+[0-9]{8}$)|(^\+[0-9]{2}\s+[0-9]{4}\s+[0-9]{8}$)|(^\+[0-9]{2}\s+[0-9]{5}\s+[0-9]{8}$)"); //regular expression for contact details to be taken in the format if (Tbx_fName.Text == "" | Tbx_lName.Text == "" | Tbx_gID.Text == "") // checking textbox to not be empty { MessageBox.Show("Please fill-in all the fields first!"); } else if (!regEx.IsMatch(input)) //checking redular expression to be matched with the given input { MessageBox.Show("Please Enter a valid Telephone number in the format of ", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } else { MyStorage.WriteXml <ObservableCollection <Donor> >(App._donors, "donors.xml"); Btn_Donor_Edit.IsEnabled = true; Btn_Donor_Save.IsEnabled = false; Tbx_cNumber.IsEnabled = false; Tbx_fName.IsEnabled = false; Tbx_lName.IsEnabled = false; Tbx_gID.IsEnabled = false; } }