Example #1
0
        private void Back_Click(object sender, EventArgs e)
        {
            this.Hide();
            CountryRepresentativeMainMenu countryRepresentativeMainMenu = new CountryRepresentativeMainMenu(users);

            countryRepresentativeMainMenu.Show();
        }
Example #2
0
 private void Login_Click(object sender, EventArgs e)
 {
     using (var db = new Session3Entities())
     {
         var ID   = UID.Text;
         var pass = Pass.Text;
         var q    = db.Users.Where(x => x.userId == ID && x.passwd == pass).FirstOrDefault();
         if (q != null)
         {
             //Only administrators and country representatives
             //can successfully login via this screen.
             if (q.userTypeIdFK == 1)
             {
                 //When a user successfully logs in, they will be
                 //automatically re‐directed to the appropriate main menu for that type of user.
                 AdminMainMenu adminMainMenu = new AdminMainMenu(q);
                 this.Hide();
                 adminMainMenu.Show();
             }
             else
             {
                 //When a user successfully logs in, they will be
                 //automatically re‐directed to the appropriate main menu for that type of user.
                 CountryRepresentativeMainMenu countryRepresentativeMainMenu = new CountryRepresentativeMainMenu(q);
                 this.Hide();
                 countryRepresentativeMainMenu.Show();
             }
         }
         else
         {
             MessageBox.Show("Invalid User!");
         }
     }
 }
Example #3
0
        private void UpdateInfoBooking_Load(object sender, EventArgs e)
        {
            timer1.Start();
            using (var db = new Session3Entities())
            {
                var q = db.Arrivals.Where(x => x.userIdFK == users.userId).FirstOrDefault();
                if (q == null)
                {
                    MessageBox.Show("Please Book Something First!");
                    this.Hide();
                    CountryRepresentativeMainMenu countryRepresentativeMainMenu = new CountryRepresentativeMainMenu(users);
                    countryRepresentativeMainMenu.Show();
                }
                else
                {
                    var q2 = db.Hotel_Booking.Where(x => x.userIdFK == users.userId).FirstOrDefault();
                    dataGridView1.DataSource = CDTU(q2);

                    HOD.Value  = q.numberHead;
                    Dels.Text  = q.numberDelegate.ToString();
                    Comps.Text = q.numberCompetitors.ToString();
                }
            }
        }
Example #4
0
        private void book_Click(object sender, EventArgs e)
        {
            using (var db = new Session3Entities())
            {
                var q = db.Arrivals.Where(x => x.userIdFK == users.userId).FirstOrDefault();

                //If user first time creating arrivals
                if (q == null)
                {
                    Arrival arrival = new Arrival();
                    if (jul22.Checked == true)
                    {
                        arrival.arrivalDate = DateTime.Parse("22 July 2020");
                    }
                    else if (jul23.Checked == true)
                    {
                        arrival.arrivalDate = DateTime.Parse("23 July 2020");
                    }
                    else
                    {
                        MessageBox.Show("Choose Date!");
                        return;
                    }

                    arrival.userIdFK = users.userId;

                    if (time == null)
                    {
                        MessageBox.Show("You have chosen an invalid timing!");
                        return;
                    }
                    arrival.arrivalTime = time;


                    if (numericUpDown1.Value > 1)
                    {
                        MessageBox.Show("Invalid Head of Deligates!");
                        return;
                    }
                    arrival.numberHead = (int)numericUpDown1.Value;


                    try
                    {
                        arrival.numberDelegate    = int.Parse(Dels.Text);
                        arrival.numberCompetitors = int.Parse(Comps.Text);
                    }
                    catch
                    {
                        MessageBox.Show("Invalid Deligates or competitors");
                        return;
                    }
                    arrival.numberCars   = int.Parse(carHeadDel.Text);
                    arrival.number19seat = int.Parse(seat19.Text);
                    arrival.number42seat = int.Parse(seat42.Text);
                    db.Arrivals.Add(arrival);
                    try
                    {
                        db.SaveChanges();
                        MessageBox.Show("Success!");
                        this.Hide();
                        CountryRepresentativeMainMenu countryRepresentativeMainMenu = new CountryRepresentativeMainMenu(users);
                        countryRepresentativeMainMenu.Show();
                    }
                    catch (Exception es)
                    {
                        MessageBox.Show(es.ToString());
                    }
                }

                //User has created and come back to change
                else
                {
                    if (jul22.Checked == true)
                    {
                        q.arrivalDate = DateTime.Parse("22 July 2020");
                    }
                    else if (jul23.Checked == true)
                    {
                        q.arrivalDate = DateTime.Parse("23 July 2020");
                    }
                    else
                    {
                        MessageBox.Show("Choose Date!");
                        return;
                    }

                    if (time == null)
                    {
                        MessageBox.Show("You have chosen an invalid timing!");
                        return;
                    }
                    q.arrivalTime = time;


                    if (numericUpDown1.Value > 1)
                    {
                        MessageBox.Show("Invalid Head of Deligates!");
                        return;
                    }
                    q.numberHead = (int)numericUpDown1.Value;


                    try
                    {
                        q.numberDelegate    = int.Parse(Dels.Text);
                        q.numberCompetitors = int.Parse(Comps.Text);
                    }
                    catch
                    {
                        MessageBox.Show("Invalid Deligates or competitors");
                        return;
                    }
                    q.numberCars   = int.Parse(carHeadDel.Text);
                    q.number19seat = int.Parse(seat19.Text);
                    q.number42seat = int.Parse(seat42.Text);
                    try
                    {
                        db.SaveChanges();
                        MessageBox.Show("Success!");
                        this.Hide();
                        CountryRepresentativeMainMenu countryRepresentativeMainMenu = new CountryRepresentativeMainMenu(users);
                        countryRepresentativeMainMenu.Show();
                    }
                    catch (Exception es)
                    {
                        MessageBox.Show(es.ToString());
                    }
                }
            }
        }
Example #5
0
        private void update_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows[0].Cells["Rooms Required"].Value != null && dataGridView1.Rows[1].Cells["Rooms Required"].Value != null)
            {
                var singleR = dataGridView1.Rows[0].Cells["Rooms Required"].Value.ToString();
                var doubleR = dataGridView1.Rows[1].Cells["Rooms Required"].Value.ToString();
                using (var db = new Session3Entities())
                {
                    var q2 = db.Hotel_Booking.Where(x => x.userIdFK == users.userId).FirstOrDefault();
                    oldD = q2.numDoubleRoomsRequired;
                    oldS = q2.numSingleRoomsRequired;

                    if (int.Parse(singleR) <= q2.Hotel.numSingleRoomsTotal - q2.Hotel.numSingleRoomsBooked)
                    {
                        q2.numSingleRoomsRequired      = int.Parse(singleR);
                        q2.Hotel.numSingleRoomsBooked -= oldS;
                        q2.Hotel.numSingleRoomsBooked += int.Parse(singleR);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Amount of Single Rooms!");
                        return;
                    }

                    if (int.Parse(doubleR) <= q2.Hotel.numDoubleRoomsTotal - q2.Hotel.numDoubleRoomsBooked)
                    {
                        q2.numDoubleRoomsRequired      = int.Parse(doubleR);
                        q2.Hotel.numDoubleRoomsBooked -= oldD;
                        q2.Hotel.numDoubleRoomsBooked += int.Parse(doubleR);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Amount of Double Rooms!");
                        return;
                    }

                    var q = db.Arrivals.Where(x => x.userIdFK == users.userId).FirstOrDefault();

                    if (HOD.Value > 1)
                    {
                        MessageBox.Show("Invalid Head of Delegate");
                        return;
                    }
                    q.numberHead = (int)HOD.Value;
                    try
                    {
                        q.numberDelegate    = int.Parse(Dels.Text);
                        q.numberCompetitors = int.Parse(Comps.Text);
                    }
                    catch
                    {
                        MessageBox.Show("Invalid Delegates or Competitors");
                        return;
                    }

                    try
                    {
                        db.SaveChanges();
                        MessageBox.Show("Success!");
                        this.Hide();
                        CountryRepresentativeMainMenu countryRepresentativeMainMenu = new CountryRepresentativeMainMenu(users);
                        countryRepresentativeMainMenu.Show();
                    }
                    catch (Exception es)
                    {
                        MessageBox.Show(es.ToString());
                    }
                }
            }
        }