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 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); }
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); }