private void btnEventCreate_Click(object sender, RoutedEventArgs e)
        {
            if (!validateInput())
                return;
            EventHelper client = new EventHelper();
            try
            {
                DateTime startTime = dtpStart.SelectedDateTime;
                DateTime endTime = dtpEnd.SelectedDateTime;

                if (startTime.CompareTo(endTime) >= 0)
                {
                    MessageBox.Show("Invalid Date Entry, End Date Must be at a Later Date Then Start Date");
                    return;
                }

                var textRange = new TextRange(txtDesc.Document.ContentStart, txtDesc.Document.ContentEnd);
                client.CreateEvent(user, txtEventName.Text, startTime, endTime, textRange.Text, txtWebsite.Text, txtTag.Text);

                MessageBox.Show("Operation succeeded!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                client.Close();
            }
            Load_Event();
        }
Esempio n. 2
0
 private void loadDays()
 {
     EventHelper clientEvent = new EventHelper();
     DayList = clientEvent.GetDays(event_.EventID).ToList<EventDay>();
     clientEvent.Close();
     //cboSelectBookingDay.ItemsSource = DayList;
     //cboSelectBookingDay.SelectedIndex = 0;
 }
        private void lstRequestor_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstRequestor.SelectedIndex == -1)
            {
                //MessageBox.Show("Please select a booking request", "No request selected",
                //MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            EventHelper client = new EventHelper();
            AdminHelper admHelper = new AdminHelper();
            try
            {
                FacilityBookingRequest fbr = (FacilityBookingRequest)lstRequestor.SelectedItem;
                txtEventName.Text = client.GetEventName(fbr.EventID);
                txtRequestor.Text = admHelper.GetUserName(fbr.RequestorID);
                lblStartTime.Content = fbr.RequestStartDateTime.ToString("dd MMM yyyy HH:mm");
                lblEndTime.Content = fbr.RequestEndDateTime.ToString("dd MMM yyyy HH:mm");

                dgLocation.ItemsSource = fbr.RequestDetails;

                lvTimeslot.Reset();
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occured: " + ex.Message, "Error",
                    MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                client.Close();
                admHelper.Close();
            }
        }
        private void btnEventDelete_Click(object sender, RoutedEventArgs e)
        {
            if (lstEventList.SelectedIndex == -1)
                return;

            Events evnt = ((Events)lstEventList.SelectedItem);
            EventHelper client = new EventHelper();
            try
            {

                client.DeleteEvent(user, evnt);

                MessageBox.Show("Operation succeeded!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                client.Close();
            }
            Load_Event();
        }
 private void Load_Event()
 {
     EventHelper client = new EventHelper();
     List<Events> list = client.ViewOrganizerEvent(user).ToList<Events>();
     lstEventList.ItemsSource = list;
     client.Close();
     lstEventList.SelectedIndex = 0;
 }
        private void lstRequest_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (lstRequest.SelectedIndex == -1)
            {
                //MessageBox.Show("Please Select a request!", "Invalid input",
                //MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                FacilityBookingRequest fbr = (FacilityBookingRequest)lstRequest.SelectedItem;
                EventHelper client = new EventHelper();
                AdminHelper admHelper = new AdminHelper();

                txtEventName.Text = client.GetEventName(fbr.EventID);
                txtRemarks.Text = fbr.Remarks;
                txtRequestor.Text = admHelper.GetUserName(fbr.RequestorID);
                txtStatus.Text = fbr.Status.ToString();
                lblStartTime.Content = fbr.RequestStartDateTime.ToString("dd MMM yyyy HH:mm");
                lblEndTime.Content = fbr.RequestEndDateTime.ToString("dd MMM yyyy HH:mm");

                lvCurrentBooking.setSource(fbr);
                client.Close();
                admHelper.Close();
                if ((fbr.Status == BookingStatus.Pending) || (fbr.Status == BookingStatus.Approved))
                {
                    btnDrop.IsEnabled = true;
                }
                else
                {
                    btnDrop.IsEnabled = false;
                }
            }
        }
        private void loadEvents()
        {
            List<Events> elist;
            if (user.isFacilityAdmin || user.isSystemAdmin)
            {
                EventHelper client = new EventHelper();
                elist = client.ViewAllEvents(user).ToList<Events>();
                client.Close();
            }
            else
            {
                FacilityBookingsHelper client = new FacilityBookingsHelper();
                elist = client.ViewAuthorizedEventsForFacBookings(user).ToList<Events>();
                client.Close();
            }

            this.cboEventList.ItemsSource = elist;

            cboEventList.SelectedValuePath = "EventID";
            cboEventList.DisplayMemberPath = "Name";
            cboEventList.SelectedIndex = 0;
        }
        private void cboEventList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (cboEventList.SelectedIndex == -1)
            {
                return;
            }

            Events ev = (Events)cboEventList.SelectedItem;
            EventHelper clientEvent = new EventHelper();
            cboEventDay.ItemsSource = clientEvent.GetDays(ev.EventID);
            cboEventDay.SelectedIndex = 0;
            clientEvent.Close();
        }