private void dg_AttendeeSchedule_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(dg_AttendeeSchedule.Rows[e.RowIndex].Cells["AttendeeId"].Value);

            if (dg_AttendeeSchedule.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
            {
                string command = dg_AttendeeSchedule.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                if (command.ToLower() == "delete")
                {
                    try
                    {
                        if (MessageBox.Show("Do you want to delete", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            var attendees = db.Attendees.Where(rm => rm.AttendeeId == id).FirstOrDefault();
                            db.Attendees.Remove(attendees);
                            db.SaveChanges();
                            MessageBox.Show("Attendee Successfully deleted");
                            LoadAttendee();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Esempio n. 2
0
        private void dgvEvent_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(dg_Event.Rows[e.RowIndex].Cells["EventId"].Value);

            if (dg_Event.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
            {
                string command = dg_Event.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                if (command.ToLower() == "delete")
                {
                    try
                    {
                        if (MessageBox.Show("Do you want to delete", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            var Event = db.Events.Where(ev => ev.EventId == id).Include(ev => ev.AttendeeEvents).Include(ev => ev.Room).FirstOrDefault();
                            db.Events.Remove(Event);
                            db.SaveChanges();
                            MessageBox.Show("Event Successfully deleted");
                            LoadEvent();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (command.ToLower() == "edit")
                {
                    AddEvent addEvent = new AddEvent(id);
                    addEvent.Show();
                }
            }
        }
Esempio n. 3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value);

            if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
            {
                string command = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                if (command.ToLower() == "delete")
                {
                    try
                    {
                        if (MessageBox.Show("Are you sure to Delete", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            var seminar = db.Seminars.Where(ss => ss.Id == id).Include(s => s.AudiencePerSeminars).Include(s => s.PresentersPerSeminars).Include(s => s.RoomStallLocation).FirstOrDefault();
                            //db.Entry(seminar).State = EntityState.Deleted;
                            db.Seminars.Remove(seminar);
                            db.SaveChanges();
                            MessageBox.Show("Seminar Successfully deleted");
                            LoadSeminars();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (command.ToLower() == "edit")
                {
                    AddSeminar addSeminar = new AddSeminar(id);
                    addSeminar.Show();
                }
            }
        }
Esempio n. 4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (!CheckInput(txt_OldPassword))
         {
             throw new Exception("Please enter Old password");
         }
         if (!CheckInput(txt_NewPassword))
         {
             throw new Exception("Please enter New password");
         }
         var check = db.Attendees.Single(up => up.Password == txt_OldPassword.Text);
         if (check != null)
         {
             if (txt_RenewPassword.Text == txt_NewPassword.Text)
             {
                 var update = (from a in db.Attendees where a.AttendeeId == Loggeduser select a).First();
                 update.Password = txt_NewPassword.Text;
                 db.SaveChanges();
                 MessageBox.Show("Updated successfully");
             }
             else
             {
                 MessageBox.Show("Incorrect Re-Password");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (!CheckInput(txt_Name))
         {
             throw new Exception("Please enter Name");
         }
         if (!CheckInput(txt_Email))
         {
             throw new Exception("Please enter Email");
         }
         if (!CheckInput(txt_AttendDays))
         {
             throw new Exception("Please enter Attend days");
         }
         var check = db.Attendees.Single(up => up.Password == txt_ConfirmPassword.Text);
         if (check != null)
         {
             var update = (from a in db.Attendees where a.AttendeeId == Loggeduser select a).First();
             update.Email = txt_Email.Text;
             update.Name = txt_Name.Text;
             update.TypeTicket = cmb_Ticket.Text.ToString();
             update.AttendDays = Convert.ToInt32(txt_AttendDays.Text);
             db.SaveChanges();
             MessageBox.Show("Updated successfully");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (!CheckInput(txt_Email))
         {
             throw new Exception("Please enter Email");
         }
         if (!CheckInput(txt_Name))
         {
             throw new Exception("Please enter Name");
         }
         if (!CheckInput(txt_AttendDays))
         {
             throw new Exception("Please enter Attend days");
         }
         Attendee attendee = new Attendee();
         attendee.Name       = txt_Name.Text;
         attendee.Email      = txt_Email.Text;
         attendee.TypeTicket = cmb_TicketType.Text.ToString();
         attendee.Password   = "******";
         attendee.AttendDays = Convert.ToInt32(txt_AttendDays.Text);
         db.Attendees.Add(attendee);
         db.SaveChanges();
         MessageBox.Show("added successfully");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 7
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (!CheckInput(txt_Location))
         {
             throw new Exception("Please enter Location");
         }
         if (!CheckInput(txt_Capacity))
         {
             throw new Exception("Please enter Capacity");
         }
         if (!CheckInput(txt_Resources))
         {
             throw new Exception("Please enter Resources");
         }
         Room room = new Room();
         room.Location  = txt_Location.Text;
         room.Resources = txt_Resources.Text;
         room.Capacity  = Convert.ToInt32(txt_Capacity.Text);
         db.Rooms.Add(room);
         db.SaveChanges();
         MessageBox.Show("Room added successfully");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 8
0
        private void dg_Room_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(dg_Room.Rows[e.RowIndex].Cells["RoomId"].Value);

            if (dg_Room.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
            {
                string command = dg_Room.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                if (command.ToLower() == "delete")
                {
                    try
                    {
                        if (MessageBox.Show("Do you want to delete", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            var Room = db.Rooms.Where(r => r.RoomId == id).FirstOrDefault();
                            db.Rooms.Remove(Room);
                            db.SaveChanges();
                            MessageBox.Show("Room Successfully deleted");
                            LoadRoom();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (command.ToLower() == "edit")
                {
                    AddRoom addRoom = new AddRoom();
                    addRoom.Show();
                }
            }
        }
Esempio n. 9
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Sure to delete account", "Delete Account?", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                var attendee = db.Attendees.Where(a => a.AttendeeId == Loggeduser).Include(a => a.PresenterSeminars).Include(a => a.AudienceSeminars).Include(a => a.AttendeeEvents).Include(a => a.AttendeeStalls).FirstOrDefault();
                db.Attendees.Remove(attendee);
                db.SaveChanges();
                Loggeduser = 0;
                Login User = new Login();
                MessageBox.Show("Account deleted successfully");
                User.Show();
                this.Close();
            }
        }
Esempio n. 10
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         ConventionSystemContext db = new ConventionSystemContext();
         Attendee attendee          = new Attendee();
         attendee.Name         = textBox1.Text;
         attendee.Email        = textBox2.Text;
         attendee.TicketType   = textBox3.Text;
         attendee.DaysOfAttend = Convert.ToInt32(textBox4.Text);
         db.Attendees.Add(attendee);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Seminar seminar = new Seminar();

                seminar.Title           = txtTitle.Text;
                seminar.SeminarDateTime = GetSeminarStartDateTime();
                seminar.RoomSize        = Convert.ToInt32(txtRoomSize.Text);
                seminar.Duration        = Convert.ToInt32(txtDuration.Text);

                db.Seminars.Add(seminar);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Attendee attendee = new Attendee();
         attendee.Name         = txtName.Text;
         attendee.Email        = txtEmail.Text;
         attendee.Password     = txtPassword.Text;
         attendee.TicketType   = cbTicketType.SelectedItem.ToString();
         attendee.DaysOfAttend = Convert.ToInt32(txtAttendDays.Text);
         db.Attendees.Add(attendee);
         db.SaveChanges();
         MessageBox.Show("Added successfully");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btnSignup_Click(object sender, EventArgs e)
 {
     try
     {
         if (!CheckInput(txt_Email))
         {
             throw new Exception("Please enter Email");
         }
         if (!CheckInput(txt_Name))
         {
             throw new Exception("Please enter name");
         }
         if (!CheckInput(txt_Password))
         {
             throw new Exception("Please enter password");
         }
         if (!CheckInput(txt_AttendDays))
         {
             throw new Exception("Please enter attend days");
         }
         if (txt_Password.Text == txt_Repassword.Text)
         {
             Attendee attendee = new Attendee();
             attendee.Name       = txt_Name.Text;
             attendee.Email      = txt_Email.Text;
             attendee.Password   = txt_Password.Text;
             attendee.TypeTicket = cmb_TicketType.Text.ToString();
             attendee.AttendDays = Convert.ToInt32(txt_AttendDays.Text);
             db.Attendees.Add(attendee);
             db.SaveChanges();
             MessageBox.Show("Account created successfully");
         }
         else
         {
             MessageBox.Show("Incorrect Repassword");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckInputs(txtTitle))
                {
                    throw new Exception("Please enter Title");
                }
                //if (!CheckInputs(txtRoomSize))
                //{
                //    throw new Exception("Please enter Room Size");
                //}
                if (!CheckInputs(txtDuration))
                {
                    throw new Exception("Please enter Duration");
                }
                Seminar seminar;
                List <AudiencePerSeminar>   audiencePerSeminars   = new List <AudiencePerSeminar>();
                List <PresentersPerSeminar> presentersPerSeminars = new List <PresentersPerSeminar>();
                if (seminarId > 0)
                {
                    seminar               = db.Seminars.Find(seminarId);
                    audiencePerSeminars   = seminar.AudiencePerSeminars;
                    presentersPerSeminars = seminar.PresentersPerSeminars;
                }
                else
                {
                    seminar = new Seminar();
                    //audiencePerSeminars = new List<AudiencePerSeminar>();
                    //presentersPerSeminars = new List<PresentersPerSeminar>();
                    if (CheckSeminarExists(GetSeminarStartDateTime(), GetSeminarEndDateTime()))
                    {
                        throw new Exception("There is already a seminar in this time");
                    }
                }
                seminar.Title               = txtTitle.Text;
                seminar.SeminarDateTime     = GetSeminarStartDateTime();
                seminar.RoomStallLocationId = Convert.ToInt32(cbRoom.SelectedValue);
                //seminar.RoomStallLocation = db.RoomStallLocations.Find(Convert.ToInt32(cbRoom.SelectedValue));
                seminar.Duration = Convert.ToInt32(txtDuration.Text);


                foreach (int id in attendeeIds)
                {
                    AudiencePerSeminar audiencePerSeminar = new AudiencePerSeminar();
                    audiencePerSeminar.Attendee = db.Attendees.Find(id);
                    audiencePerSeminar.Seminar  = seminar;
                    var attendee = audiencePerSeminars.Where(aps => aps.AttendeeId == id).FirstOrDefault();

                    if (attendee == null)
                    {
                        audiencePerSeminars.Add(audiencePerSeminar);
                    }
                }

                foreach (int id in presenterIds)
                {
                    PresentersPerSeminar presentersPerSeminar = new PresentersPerSeminar();
                    presentersPerSeminar.Presenter = db.Attendees.Find(id);
                    presentersPerSeminar.Seminar   = seminar;
                    var presenter = presentersPerSeminars.Where(aps => aps.AttendeeId == id).FirstOrDefault();
                    if (presenter == null)
                    {
                        presentersPerSeminars.Add(presentersPerSeminar);
                    }
                }

                //if (audiencePerSeminars.Count < 1)
                //{
                //    throw new Exception("Please add Audience");
                //}
                //if (presentersPerSeminars.Count < 1)
                //{
                //    throw new Exception("Please add Presenter");
                //}

                seminar.AudiencePerSeminars = audiencePerSeminars;
                if (seminar.AudiencePerSeminars.Count > db.RoomStallLocations.Find(cbRoom.SelectedValue).Capacity)
                {
                    throw new Exception("Room Capacity is Full");
                }
                seminar.PresentersPerSeminars = presentersPerSeminars;

                if (seminarId > 0)
                {
                    db.Seminars.Attach(seminar);
                }
                else
                {
                    db.Seminars.Add(seminar);
                }
                db.SaveChanges();
                MessageBox.Show("Seminar successfully added");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnAddEvent_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckInput(txt_StallCode))
                {
                    throw new Exception("Please enter Title");
                }
                if (!CheckInput(txt_Duration))
                {
                    throw new Exception("Please enter Duration");
                }
                if (!CheckInput(txt_StallSize))
                {
                    throw new Exception("Please enter Description");
                }
                if (!CheckInput(txt_StallType))
                {
                    throw new Exception("Please enter Description");
                }
                Stall stalls;
                List <AttendeePerStall> attendeestalls = new List <AttendeePerStall>();
                if (StallId > 0)
                {
                    stalls         = db.Stalls.Find(StallId);
                    attendeestalls = stalls.AttendeeStalls;
                }
                else
                {
                    stalls = new Stall();
                    if (CheckStalls(getStallStartDateTime(), getStallEndDateTime()))
                    {
                        throw new Exception("Time is already booked for another stall");
                    }
                }
                stalls.StallCode    = txt_StallCode.Text;
                stalls.StallType    = txt_StallType.Text;
                stalls.Size         = Convert.ToInt32(txt_StallSize.Text);
                stalls.StartingTime = getStallStartDateTime();
                stalls.RoomId       = Convert.ToInt32(cmb_Room.SelectedValue);
                stalls.Duration     = Convert.ToInt32(txt_Duration.Text);

                foreach (int id in attendeeIds)
                {
                    AttendeePerStall attendeeStall = new AttendeePerStall();
                    attendeeStall.Exhibitor = db.Attendees.Find(id);
                    attendeeStall.Stall     = stalls;
                    var attendeeCheck = attendeestalls.Where(sa => sa.AttendeeId == id).FirstOrDefault();

                    if (attendeeCheck == null)
                    {
                        attendeestalls.Add(attendeeStall);
                    }
                }
                if (attendeestalls.Count < 1)
                {
                    throw new Exception("Please add Exhibitor");
                }

                stalls.AttendeeStalls = attendeestalls;
                if (Convert.ToInt32(txt_StallSize.Text) > db.Rooms.Find(cmb_Room.SelectedValue).Capacity)
                {
                    throw new Exception("Stall size cannot be greater than room capacity");
                }
                if (stalls.AttendeeStalls.Count > db.Rooms.Find(cmb_Room.SelectedValue).Capacity)
                {
                    throw new Exception("Max room capacity");
                }
                if (StallId > 0)
                {
                    db.Stalls.Attach(stalls);
                }
                else
                {
                    db.Stalls.Add(stalls);
                }
                db.SaveChanges();
                MessageBox.Show("Stall successfully added");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 16
0
        private void btnAddEvent_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckInput(txt_Title))
                {
                    throw new Exception("Please enter Title");
                }
                if (!CheckInput(txt_Duration))
                {
                    throw new Exception("Please enter Duration");
                }
                if (!CheckInput(txt_Description))
                {
                    throw new Exception("Please enter Description");
                }

                Event events;
                List <AttendeePerEvent> attendeeEvents = new List <AttendeePerEvent>();
                if (EventId > 0)
                {
                    events         = db.Events.Find(EventId);
                    attendeeEvents = events.AttendeeEvents;
                }
                else
                {
                    events = new Event();
                    if (CheckEvents(getEventStartDateTime(), getEventEndDateTime()))
                    {
                        throw new Exception("Time is already booked for another event");
                    }
                }
                events.EventTitle = txt_Title.Text;
                events.EventDate  = getEventStartDateTime();
                events.RoomId     = Convert.ToInt32(cmb_Room.SelectedValue);
                events.Duration   = Convert.ToInt32(txt_Duration.Text);


                foreach (int id in attendeeIds)
                {
                    AttendeePerEvent attendeeEvent = new AttendeePerEvent();
                    attendeeEvent.Attendee = db.Attendees.Find(id);
                    attendeeEvent.Event    = events;
                    var attendeeCheck = attendeeEvents.Where(ae => ae.AttendeeId == id).FirstOrDefault();

                    if (attendeeCheck == null)
                    {
                        attendeeEvents.Add(attendeeEvent);
                    }
                }
                if (attendeeEvents.Count < 1)
                {
                    throw new Exception("Please add Attendee");
                }

                events.AttendeeEvents = attendeeEvents;
                if (events.AttendeeEvents.Count > db.Rooms.Find(cmb_Room.SelectedValue).Capacity)
                {
                    throw new Exception("Max room capacity");
                }
                if (EventId > 0)
                {
                    db.Events.Attach(events);
                }
                else
                {
                    db.Events.Add(events);
                }
                db.SaveChanges();
                MessageBox.Show("Event successfully added");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnAddSeminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckInput(txt_Title))
                {
                    throw new Exception("Please enter Title");
                }
                if (!CheckInput(txt_Duration))
                {
                    throw new Exception("Please enter Duration");
                }
                Seminar seminar;
                List <AudiencePerSeminar>  audienceSeminars  = new List <AudiencePerSeminar>();
                List <PresenterPerSeminar> presenterSeminars = new List <PresenterPerSeminar>();
                if (seminarId > 0)
                {
                    seminar           = db.Seminars.Find(seminarId);
                    audienceSeminars  = seminar.AudienceSeminars;
                    presenterSeminars = seminar.PresenterSeminars;
                }
                else
                {
                    seminar = new Seminar();
                    if (CheckSeminar(getSeminarStartDateTime(), getSeminarEndDateTime()))
                    {
                        throw new Exception("Time is already booked for another seminar");
                    }
                }
                seminar.SeminarTitle     = txt_Title.Text;
                seminar.SeminarStartTime = getSeminarStartDateTime();
                seminar.RoomId           = Convert.ToInt32(cmb_Room.SelectedValue);
                seminar.Duration         = Convert.ToInt32(txt_Duration.Text);


                foreach (int id in attendeeIds)
                {
                    AudiencePerSeminar audienceSeminar = new AudiencePerSeminar();
                    audienceSeminar.Attendee = db.Attendees.Find(id);
                    audienceSeminar.Seminar  = seminar;
                    var attendeeCheck = audienceSeminars.Where(au => au.AttendeeId == id).FirstOrDefault();

                    if (attendeeCheck == null)
                    {
                        audienceSeminars.Add(audienceSeminar);
                    }
                }

                foreach (int id in presenterIds)
                {
                    PresenterPerSeminar presenterSeminar = new PresenterPerSeminar();
                    presenterSeminar.Presenter = db.Attendees.Find(id);
                    presenterSeminar.Seminar   = seminar;
                    var presenter = presenterSeminars.Where(pa => pa.AttendeeId == id).FirstOrDefault();
                    if (presenter == null)
                    {
                        presenterSeminars.Add(presenterSeminar);
                    }
                }
                if (audienceSeminars.Count < 1)
                {
                    throw new Exception("Please add Audience");
                }
                if (presenterSeminars.Count < 1)
                {
                    throw new Exception("Please add Presenter");
                }
                seminar.AudienceSeminars = audienceSeminars;
                if (seminar.AudienceSeminars.Count > db.Rooms.Find(cmb_Room.SelectedValue).Capacity)
                {
                    throw new Exception("Max room capacity");
                }
                seminar.PresenterSeminars = presenterSeminars;

                if (seminarId > 0)
                {
                    db.Seminars.Attach(seminar);
                }
                else
                {
                    db.Seminars.Add(seminar);
                }
                db.SaveChanges();
                MessageBox.Show("Seminar successfully added");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }