private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            object id_obj = ((Button)sender).CommandParameter;
            int    id;

            int.TryParse(id_obj.ToString(), out id);

            MaintenenceController.getInstance().viewUpdate(id).Show();
            load();
        }
Example #2
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (txtInformation.Text == "")
            {
                MessageBox.Show("Invalid input!");
                return;
            }

            MaintenenceController.getInstance().update(id, txtInformation.Text);
            MessageBox.Show("Success updating data!");
            Close();
        }
        private bool checkID(int id)
        {
            List <Maintenence> maintenences = MaintenenceController.getInstance().getAll();

            foreach (Maintenence m in maintenences)
            {
                if (m.AttractionRideID == id)
                {
                    return(false);
                }
            }
            return(true);
        }
        private dynamic getMaintenencesList()
        {
            List <Maintenence> maintenences = MaintenenceController.getInstance().getAll();

            var filtered = maintenences.Select(i => new
            {
                i.Id,
                Name = i.AttractionRide.Name,
                i.Information,
                i.Status
            });

            return(filtered);
        }
        private void btnFinish_Click(object sender, RoutedEventArgs e)
        {
            object id_obj = ((Button)sender).CommandParameter;
            int    id;

            int.TryParse(id_obj.ToString(), out id);

            var attr_ride   = MaintenenceController.getInstance().find(id);
            int attr_rideID = attr_ride.AttractionRide.Id;

            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                MaintenenceController.getInstance().remove(id, attr_rideID);
                MessageBox.Show("Success finish the maintenence!");
            }

            load();
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string attr_ride_name = cbMaintenence.SelectionBoxItem.ToString();
            int    attr_ride_id   = getAttr_rideID(attr_ride_name);

            if (attr_ride_name == "" || txtInformation.Text == "")
            {
                MessageBox.Show("Invalid Input!");
                return;
            }

            if (attr_ride_id == 0)
            {
                MessageBox.Show("Attraction or Ride is under maintenence!");
                return;
            }

            MaintenenceController.getInstance().add(attr_ride_id, txtInformation.Text);
            MessageBox.Show("Success add new maintenance schedule");

            reset();
            load();
        }