Exemplo n.º 1
0
        public void checkInButton_Click(object sender, EventArgs e)
        {
            //TODO: Remove TEST
            int dropDownIndex = employeeDropDownBox.SelectedIndex;
            int dropDownValue = 0;

            try
            {
                dropDownValue = Int32.Parse(employeeDropDownBox.SelectedValue.ToString());
            }
            catch { }

            string dropDownText = employeeDropDownBox.SelectedItem.ToString();

            //Create the new attendee
            Attendee newAttendee = new Attendee();

            //Check if anything was selected
            if (employeeDropDownBox.SelectedIndex != 0 || nameTextBox.Text != "")
            {
                //Check if selected attendee is guest
                if ((dropDownIndex == 1 && nameTextBox.Text == ""))
                {
                    //Set page controls
                    EnableGuestControls();
                }
                //Check if selected attendee is guest who was an invited attendee
                else if (dropDownValue <= -2)
                {
                    // Add the Attendee based on their suggested guest name (from the invited attendees list)
                    AddAttendee(CreateAttendee(-1, room.RoomName, DateTime.Now.AddHours(1), dropDownText));
                    // Find the correct invited attendee to delete based on the ID of the attendee checking in
                    var invitedAttendeeToRemove = db.InvitedAttendees.Where(att => att.EmployeeID == dropDownValue && att.Room == room.RoomName).FirstOrDefault();
                    if (invitedAttendeeToRemove != null)
                    {
                        db.InvitedAttendees.Remove(invitedAttendeeToRemove);
                        db.SaveChanges();
                    }
                }
                //Otherwise
                else if (nameTextBox.Text != "")
                {
                    //Create the guest attendee
                    AddAttendee(CreateAttendee(-1, room.RoomName,
                                               DateTime.Now.AddHours(1), //Default meeting length 1hr
                                               nameTextBox.Text.ToString()));

                    db.SaveChanges();

                    //Set page controls
                    EnableNormalControls();
                }
                else if (dropDownIndex > 1 && dropDownValue > 0)
                {
                    //Find the employee in the Employee database
                    int employeeID         = Int32.Parse(employeeDropDownBox.SelectedValue);
                    var checkingInEmployee = db.Employees
                                             .Where(ee => ee.EmployeeID == employeeID)
                                             .FirstOrDefault();

                    //Modify Status Board entries
                    checkingInEmployee.StatusID = room.RoomStatusID;
                    checkingInEmployee.Remarks  = room.RoomName.ToString()
                                                  + (nowMeetingNameLabel.Text == "Room Available" ? "" : ": "
                                                     + nowMeetingNameLabel.Text.ToString()); //Change Status Board Remarks

                    //Convert the employee to an attendee
                    AddAttendee(CreateAttendee(checkingInEmployee.EmployeeID,
                                               room.RoomName,
                                               DateTime.Now.AddHours(1),
                                               checkingInEmployee.FirstName.ToString() + " " + checkingInEmployee.LastName.ToString()));

                    // See if the attendee was an invited employee
                    var invitedAttendeeToRemove = db.InvitedAttendees.Where(att => att.EmployeeID == dropDownValue && att.Room == room.RoomName).FirstOrDefault();
                    if (invitedAttendeeToRemove != null)
                    {
                        db.InvitedAttendees.Remove(invitedAttendeeToRemove);
                    }

                    db.SaveChanges();
                }
            }
            //Update the Attendees list on the webpage
            RunStartupRoutine();

            //LOAD Meeting List
            SyncMeetingSuggestionsInDatabase();
        }
Exemplo n.º 2
0
 public void AddAttendee(Attendee a)
 {
     db.Attendees.Add(a);
 }