int CompareLendByDatePlannedEndAscending(ListViewItem a, ListViewItem b) { MyLendList first = (MyLendList)a.Content; MyLendList second = (MyLendList)b.Content; DateTime firstDate; DateTime secondDate; if (first.LendPlannedEnd.CompareTo("") != 0) { firstDate = Convert.ToDateTime(first.LendPlannedEnd); } else { firstDate = DateTime.MinValue; } if (second.LendPlannedEnd.CompareTo("") != 0) { secondDate = Convert.ToDateTime(second.LendPlannedEnd); } else { secondDate = DateTime.MinValue; } return(DateTime.Compare(firstDate, secondDate)); }
int CompareLendByDateReservationDescending(ListViewItem a, ListViewItem b) { MyLendList first = (MyLendList)a.Content; MyLendList second = (MyLendList)b.Content; DateTime firstDate; DateTime secondDate; if (first.ReservationDate.CompareTo("") != 0) { firstDate = Convert.ToDateTime(first.ReservationDate); } else { firstDate = DateTime.MinValue; } if (second.ReservationDate.CompareTo("") != 0) { secondDate = Convert.ToDateTime(second.ReservationDate); } else { secondDate = DateTime.MinValue; } return(DateTime.Compare(secondDate, firstDate)); }
int CompareCarDescending(ListViewItem a, ListViewItem b) { MyLendList first = (MyLendList)a.Content; MyLendList second = (MyLendList)b.Content; return(String.Compare(second.Vehicle, first.Vehicle)); }
int CompareLendByIdDescending(ListViewItem a, ListViewItem b) { MyLendList first = (MyLendList)a.Content; MyLendList second = (MyLendList)b.Content; return(second.LendId.CompareTo(first.LendId)); }
private void Zglos_usterke(object sender, RoutedEventArgs e) { ListViewItem selected = (ListViewItem)ListViewMyLends.SelectedItem; if (selected != null) { MyLendList selectedObj = (MyLendList)selected.Content; int selectedId = selectedObj.LendId - 1; var db = new AEiI_2020_BD2_Drynda_FlotaEntities(); Lend lendChange = null; var lend = (from lendd in db.Lends where lendd.id == selectedId select lendd).FirstOrDefault(); if (lend != null) { lendChange = lend; } if (lendChange.lendDate > DateTime.Now.Date || lendChange.returnDate < lendChange.lendDate.Date) //usterkę można zgłosic w tym oknie dla rozpoczętych wypozyczeń { MessageBox.Show("Wypożyczenie nie zaczeło się!", "Komunikat"); return; } var car = (from carr in db.Cars where carr.id == lendChange.carId select carr).FirstOrDefault(); if (car != null) { ZglosUsterke zglosUsterke = new ZglosUsterke(car, 2); System.Windows.Window glowneOkno = System.Windows.Application.Current.MainWindow; glowneOkno.DataContext = zglosUsterke; return; } } else { MessageBox.Show("Nie wybrano samochodu!", "Komunikat"); } }
private void Statystyki_Wypozyczenia(object sender, RoutedEventArgs e) { ListViewItem selected = (ListViewItem)ListViewMyLends.SelectedItem; if (selected != null) { MyLendList selectedObj = (MyLendList)selected.Content; int selectedId = selectedObj.LendId - 1; var db = new AEiI_2020_BD2_Drynda_FlotaEntities(); Lend lendChange = null; var lend = (from lendd in db.Lends where lendd.id == selectedId select lendd).FirstOrDefault(); if (lend != null) { lendChange = lend; } if (lendChange.lendDate > DateTime.Now.Date || lendChange.returnDate <= lendChange.lendDate.Date) { MessageBox.Show("Wypożyczenie nie zaczeło się!", "Komunikat"); } else { System.Windows.Window glowneOkno = System.Windows.Application.Current.MainWindow; glowneOkno.DataContext = new StatystykiWypozyczenia(lendChange, false); } } else { MessageBox.Show("Niczego nie wybrano !", "Komunikat"); } }
private void Zakoncz_Wypozyczenie(object sender, RoutedEventArgs e) { ListViewItem selected = (ListViewItem)ListViewMyLends.SelectedItem; if (selected != null) { MyLendList selectedObj = (MyLendList)selected.Content; int selectedId = selectedObj.LendId - 1; var db = new AEiI_2020_BD2_Drynda_FlotaEntities(); Lend lendChange = null; var lend = (from lendd in db.Lends where lendd.id == selectedId select lendd).FirstOrDefault(); if (lend != null) { lendChange = lend; } if (lendChange.returnDate <= DateTime.Now || lendChange.Reservation.ended == true) { MessageBox.Show("Wypożyczenie się zakończyło!", "Komunikat"); } else if (lendChange.lendDate > DateTime.Now) { MessageBox.Show("Wypożyczenie się jeszcze\nnie rozpoczeło!", "Komunikat"); } else { DialogResult result = MessageBox.Show("Czy chcesz zakonczyc wypożyczenie ?" , "Komunikat", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { lendChange.returnDate = DateTime.Now.Date; lendChange.comments += "Zakończono przez zakończenie\nwypożyczenia przez pracownika " + Logowanie.actualUser.id + ") " + Logowanie.actualUser.firstName + " " + Logowanie.actualUser.lastName + " - " + DateTime.Now.ToString() + "\n"; // var reservations = db.Reservations; var reservation = (from reserv in db.Reservations where lendChange.id == reserv.lendId select reserv).FirstOrDefault(); reservation.ended = true; db.SaveChanges(); ListViewMyLends.ItemsSource = null; items.Clear(); UpdateView(); } else if (result == DialogResult.No) { } } } else { MessageBox.Show("Nic nie wybrano !", "Komunikat"); } }