示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        int CompareCarDescending(ListViewItem a, ListViewItem b)
        {
            MyLendList first  = (MyLendList)a.Content;
            MyLendList second = (MyLendList)b.Content;

            return(String.Compare(second.Vehicle, first.Vehicle));
        }
示例#4
0
        int CompareLendByIdDescending(ListViewItem a, ListViewItem b)
        {
            MyLendList first  = (MyLendList)a.Content;
            MyLendList second = (MyLendList)b.Content;

            return(second.LendId.CompareTo(first.LendId));
        }
示例#5
0
        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");
            }
        }
示例#6
0
        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");
            }
        }
示例#7
0
        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");
            }
        }