private void Btn_Save_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(Txt_name1.Text) || String.IsNullOrEmpty(Txt_fname.Text) || String.IsNullOrEmpty(Txt_lname.Text)) { MessageBox.Show("Please fill the information"); } else { registers.Add(new register { firstName = Txt_fname.Text, lastName = Txt_lname.Text, address = Txt_address.Text, city = Txt_city.Text, email = Txt_email.Text, telefon = Txt_telefon.Text, regdate = txtDatePicker.Text }); //var pet = new pet { petname = Txt_name1.Text, petbreed = Cbo_breed1.SelectedItem.ToString(), petgender = Cbo_gender1.Text }; pets.Add(new pet { ownerName = Txt_fname.Text, petname = Txt_name1.Text, petbreed = Cbo_breed1.SelectedItem.ToString(), petgender = Cbo_gender1.Text }); Mystorage.WriteToXmlFile <ObservableCollection <register> >("registers.xml", registers); Mystorage.WriteToXmlFile <ObservableCollection <pet> >("pets.xml", pets); pets = Mystorage.ReadFromXmlFile <ObservableCollection <pet> >("pets.xml"); LBx_Pets.ItemsSource = from p in pets where p.ownerName == Txt_fname.Text select p; LBx_Owner.SelectedItem = registers; LBx_Pets.ItemsSource = pets; } }
private void btnSaveTraining_Click(object sender, RoutedEventArgs e) { for (int i = 0; i < lbx_AssignPet.Items.Count; i++) { var data = new session { petname = ((Pet_Training_App.pet)lbx_AssignPet.Items[i]).petname, sessionsname = Cbo_tclass.SelectedItem.ToString() }; sessions.Add(data); MessageBox.Show("Saved successfully."); } Mystorage.WriteToXmlFile <ObservableCollection <session> >("sessions.xml", sessions); lbx_AssignPet.Items.Clear(); }
private void LBx_Owner_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { pets = Mystorage.ReadFromXmlFile <ObservableCollection <pet> >("pets.xml"); LBx_Pets.ItemsSource = from p in pets where p.ownerName == ((Pet_Training_App.register)LBx_Owner.SelectedItem).firstName select p; var date = (from r in registers where r.firstName == ((Pet_Training_App.register)LBx_Owner.SelectedItem).firstName select r.regdate).ToList(); txtDatePicker.Text = date[0]; } catch (Exception ex) { //throw; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { registers = Mystorage.ReadFromXmlFile <ObservableCollection <register> >("registers.xml"); sessions = Mystorage.ReadFromXmlFile <ObservableCollection <session> >("sessions.xml"); attendances = Mystorage.ReadFromXmlFile <ObservableCollection <attendance> >("attendances.xml");; LBx_attendenceList.ItemsSource = attendances; //Cbo_class.ItemsSource = sessions; LBx_Owner.ItemsSource = registers; Genderfill(); Breedfill(); //Sessionfill(); Daysfill(); tclass(); petsBinding(); Statusfill(); }
private void Btn_pet_Click(object sender, RoutedEventArgs e) { try { pets.Add(new pet { ownerName = Txt_fname.Text, petname = Txt_name1.Text, petbreed = Cbo_breed1.SelectedItem.ToString(), petgender = Cbo_gender1.Text }); Mystorage.WriteToXmlFile <ObservableCollection <pet> >("pets.xml", pets); LBx_Pets.ItemsSource = from p in pets where p.ownerName == Txt_fname.Text select p; } catch (Exception ex) { MessageBox.Show("Check Your Inputs"); //throw; } // Txt_name1.Clear(); }
private void Attendence_Click(object sender, RoutedEventArgs e) { //List<string> pets = new List<string>(); List <string> lpet2 = new List <string>(); // foreach (var pet in LBx_attendance.Items) // { // pets.Add(((Pet_Training_App.session)pet).petname); //} foreach (var pet2 in LBx_attendance.SelectedItems) { lpet2.Add(((Pet_Training_App.session)pet2).petname); } foreach (var att in LBx_attendance.Items) { if (lpet2.Contains(((Pet_Training_App.session)att).petname)) { attendances.Add(new attendance { classs = Cbo_class.SelectedValue.ToString(), Date = txtAttendenceDate.Text, status = "Present", petname = ((Pet_Training_App.session)att).petname }); } else { attendances.Add(new attendance { classs = Cbo_class.SelectedValue.ToString(), Date = txtAttendenceDate.Text, status = "Absent", petname = ((Pet_Training_App.session)att).petname }); } } // //foreach (var item in mainlist) //{ // attendances.Add(new attendance { classs = Cbo_class.SelectedValue.ToString(), Date = txtAttendenceDate.Text, status = "Absent", petname = item }); //} MessageBox.Show("Attendance taken successfully"); Mystorage.WriteToXmlFile <ObservableCollection <attendance> >("attendances.xml", attendances, true); }
public void attendenceBinding() { attendances = Mystorage.ReadFromXmlFile <ObservableCollection <attendance> >("attendances.xml"); LBx_attendance.ItemsSource = attendances; }
public void petsBinding() { pets = Mystorage.ReadFromXmlFile <ObservableCollection <pet> >("pets.xml");; LBx_OwnerPets.ItemsSource = pets; }
private void Btn_Update_Click(object sender, RoutedEventArgs e) { Mystorage.WriteToXmlFile <ObservableCollection <register> >("registers.xml", registers); MessageBox.Show("Updated Successfully :)"); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Mystorage.WriteToXmlFile <ObservableCollection <register> >("registers.xml", registers); }