Esempio n. 1
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Car temp = (Car)carToBeDeleted.SelectedItem;

            if (temp == null)
            {
                System.Windows.MessageBox.Show("Please select car.");
                return;
            }
            int idToBeDeleted = temp.id;

            if (!ReservationCalendar.checkIfCarHasNoReservations(idToBeDeleted))
            {
                System.Windows.MessageBox.Show("Car can not be deleted because of reservations.");
                return;
            }

            CarList.deleteCarFromList(idToBeDeleted);
            System.Windows.MessageBox.Show("Car deleted!");

            Admin_ControlPanel admin_ControlPanel = new Admin_ControlPanel(Left, Top);

            admin_ControlPanel.Show();
            Close();
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            User temp = (User)userToBeDeleted.SelectedItem;

            if (temp == null)
            {
                System.Windows.MessageBox.Show("Please select user.");
                return;
            }
            int tempUserId = temp.id;

            if (!ReservationCalendar.checkIfUserHasNoReservations(tempUserId))
            {
                System.Windows.MessageBox.Show("User can not be deleted because of reservations.");
                return;
            }
            UserList.deleteUserFromList(tempUserId);
            ReservationCalendar.deleteUserPastReservations(tempUserId);
            System.Windows.MessageBox.Show("User deleted!");

            Admin_ControlPanel admin_ControlPanel = new Admin_ControlPanel(Left, Top);

            admin_ControlPanel.Show();
            Close();
        }
Esempio n. 3
0
        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            Admin_ControlPanel admin_ControlPanel = new Admin_ControlPanel(Left, Top);

            admin_ControlPanel.Show();
            Close();
        }
        private void Login_Button_Click(object sender, RoutedEventArgs e)
        {
            string inputPassword = password.Password;
            string inputUsername = username.Text;

            bool switcher = true;

            if (string.IsNullOrEmpty(inputUsername))
            {
                System.Windows.MessageBox.Show("Username box is empty");
                switcher = false;
            }
            else if (string.IsNullOrEmpty(inputPassword))
            {
                System.Windows.MessageBox.Show("Password box is empty");
                switcher = false;
            }

            if (switcher)
            {
                if (AdminList.isOnTheList(inputUsername, inputPassword))
                {
                    System.Windows.MessageBox.Show("You are successfully logged in as an admin!");
                    Admin_ControlPanel admin_ControlPanel = new Admin_ControlPanel(this.Left, this.Top);
                    admin_ControlPanel.Show();
                    Close();
                }
                else if (UserList.isOnTheList(inputUsername, inputPassword))
                {
                    CurrentlyLoggedUser.InitilizeCurrentyLoggedUser(UserList.GetId(inputUsername, inputPassword));
                    System.Windows.MessageBox.Show("You are successfully logged in as an user!");
                    User_ControlPanel user_ControlPanel = new User_ControlPanel(this.Left, this.Top);
                    user_ControlPanel.Show();
                    Close();
                }
                else
                {
                    System.Windows.MessageBox.Show("Account does not exist! Click REGISTER button in order to register.");
                }
            }
        }
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            string name           = carName.Text;
            string imageFilePath  = ImageFilePath.Text;
            string productionYear = production_year.Text;
            string horsepower     = Horsepower.Text;
            string rentPrice      = RentPrice.Text;
            string gearbox;
            string bodyType;
            string fuelType;

            if (String.IsNullOrEmpty(name))
            {
                System.Windows.MessageBox.Show("Please fill in car name box.");
                return;
            }
            if (String.IsNullOrEmpty(imageFilePath))
            {
                System.Windows.MessageBox.Show("Please fill in image file path box.");
                return;
            }
            if (String.IsNullOrEmpty(productionYear))
            {
                System.Windows.MessageBox.Show("Please fill in production year box.");
                return;
            }
            if (String.IsNullOrEmpty(horsepower))
            {
                System.Windows.MessageBox.Show("Please fill in horsepower box.");
                return;
            }
            try
            {
                gearbox = Gearbox.SelectedValue.ToString();
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Please choose gearbox type.");
                return;
            }
            try
            {
                bodyType = BodyType.SelectedValue.ToString();
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Please choose body type.");
                return;
            }
            try
            {
                fuelType = FuelType.SelectedValue.ToString();
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Please choose fuel type.");
                return;
            }
            if (String.IsNullOrEmpty(rentPrice))
            {
                System.Windows.MessageBox.Show("Please fill in rent price box.");
                return;
            }
            Car temp = new Car();

            temp.id             = CarList.getMaxIdFromBothLists() + 1;
            temp.name           = name;
            temp.imageFilePath  = imageFilePath;
            temp.productionYear = Int32.Parse(productionYear);
            temp.horsepower     = Int32.Parse(horsepower);
            temp.gearbox        = (gearbox)Enum.Parse(typeof(gearbox), gearbox);
            temp.bodyType       = (bodyType)Enum.Parse(typeof(bodyType), bodyType);
            temp.fuelType       = (fuelType)Enum.Parse(typeof(fuelType), fuelType);
            temp.rentPrice      = Int32.Parse(rentPrice);
            System.Windows.MessageBox.Show("Car added!");
            CarList.AddNewCarToList(temp);

            Admin_ControlPanel admin_ControlPanel = new Admin_ControlPanel(Left, Top);

            admin_ControlPanel.Show();
            Close();
        }