Beispiel #1
0
        private void btnSelectGuest_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = (DataGridViewRow)dgvGuests.Rows[dgvGuests.SelectedCells[0].RowIndex];

            if (row.Cells[4].Value.ToString() == Globals.hotelCountry)
            {
                Guest guest = new NationalGuest();
                guest.Id        = int.Parse(row.Cells["guest_id"].Value.ToString());
                guest.FirstName = row.Cells["First Name"].Value.ToString();
                guest.LastName  = row.Cells["Last Name"].Value.ToString();
                guest.Email     = row.Cells["Email"].Value.ToString();
                this.Guest      = guest;
            }
            else
            {
                Guest guest = new InternationalGuest();
                guest.Id        = int.Parse(row.Cells["guest_id"].Value.ToString());
                guest.FirstName = row.Cells["First Name"].Value.ToString();
                guest.LastName  = row.Cells["Last Name"].Value.ToString();
                guest.Email     = row.Cells["Email"].Value.ToString();
                this.Guest      = guest;
            }
            this.Close();
            var form = new CheckinFrm(this.ReservationId, this.Guest, this.ReservationApartmentId);

            form.Show();
        }
        private void btnSelectGuest_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = (DataGridViewRow)dgvGuests.Rows[dgvGuests.SelectedCells[0].RowIndex];

            if (row.Cells[4].Value.ToString() == Globals.hotelCountry)
            {
                Guest guest = new NationalGuest();
                guest.Id        = int.Parse(row.Cells["guest_id"].Value.ToString());
                guest.FirstName = row.Cells["Name"].Value.ToString();
                guest.LastName  = row.Cells["Last Name"].Value.ToString();
                guest.Email     = row.Cells["Email"].Value.ToString();
                this.Guest      = guest;
            }
            else
            {
                Guest guest = new InternationalGuest();
                guest.Id        = int.Parse(row.Cells[0].Value.ToString());
                guest.FirstName = row.Cells["Name"].Value.ToString();
                guest.LastName  = row.Cells["Last Name"].Value.ToString();
                guest.Email     = row.Cells["Email"].Value.ToString();
                this.Guest      = guest;
            }

            MySqlConnection con = new MySqlConnection(Globals.connString);

            using (MySqlCommand cmd = new MySqlCommand("INSERT INTO _reservation_guest(guest_id, reservation_id) " +
                                                       "VALUES(@guestId, @reservationId)", con))
            {
                cmd.Parameters.Add("@guestId", MySqlDbType.Int32).Value       = this.Guest.Id;
                cmd.Parameters.Add("@reservationId", MySqlDbType.Int32).Value = this.Reservation.Id;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }
            MessageBox.Show("Guest added to reservation");
            this.Close();
        }
Beispiel #3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            // Converting to enums
            try
            {
                Countries    nationality    = (Countries)Enum.Parse(typeof(Countries), comboNationality.SelectedItem.ToString());
                Countries    issuingCountry = (Countries)Enum.Parse(typeof(Countries), comboIssuingCountry.SelectedItem.ToString());
                Occupation   occupation     = (Occupation)Enum.Parse(typeof(Occupation), comboOccupation.SelectedItem.ToString());
                DocumentType documentType   = (DocumentType)Enum.Parse(typeof(DocumentType), comboDocumentType.SelectedItem.ToString());
                IssuingBody  issuingBody    = (IssuingBody)Enum.Parse(typeof(IssuingBody), comboIssuingBody.SelectedItem.ToString());
                string       gender;
                if (radioMale.Checked)
                {
                    gender = "Male";
                }
                else
                {
                    gender = "Female";
                }

                //Check whether it is a national or international guest

                if (comboNationality.SelectedItem.ToString() == Globals.hotelCountry)
                {
                    NationalGuest guest = new NationalGuest(
                        txtFirstName.Text,
                        txtLastName.Text,
                        txtEmail.Text,
                        occupation,
                        dtpBirth.Value,
                        nationality,
                        Convert.ToInt64(txtPhone.Text),
                        Convert.ToInt64(txtDocument.Text),
                        documentType,
                        issuingBody
                        );

                    MySqlConnection con = new MySqlConnection(Globals.connString);
                    con.Open();

                    try
                    {
                        MySqlCommand cmd = new MySqlCommand("SaveNewGuest", con);
                        cmd.Parameters.Add("_first_name", MySqlDbType.VarChar, 55).Value      = guest.FirstName;
                        cmd.Parameters.Add("_last_name", MySqlDbType.VarChar, 55).Value       = guest.LastName;
                        cmd.Parameters.Add("_email", MySqlDbType.VarChar, 60).Value           = guest.Email;
                        cmd.Parameters.Add("_occupation", MySqlDbType.VarChar, 45).Value      = guest.Occupation;
                        cmd.Parameters.Add("_birth_date", MySqlDbType.Date).Value             = guest.Birthdate;
                        cmd.Parameters.Add("_nationality", MySqlDbType.VarChar, 60).Value     = Globals.hotelCountry;
                        cmd.Parameters.Add("_gender", MySqlDbType.VarChar, 6).Value           = gender;
                        cmd.Parameters.Add("_phone", MySqlDbType.VarChar, 50).Value           = guest.Phone;
                        cmd.Parameters.Add("_document", MySqlDbType.VarChar, 50).Value        = guest.Document;
                        cmd.Parameters.Add("_document_type", MySqlDbType.VarChar, 25).Value   = guest.DocumentType;
                        cmd.Parameters.Add("_issuing_body", MySqlDbType.VarChar, 45).Value    = guest.IssuingBody;
                        cmd.Parameters.Add("_issuing_country", MySqlDbType.VarChar, 60).Value = Globals.hotelCountry;
                        cmd.Parameters.Add("_is_international", MySqlDbType.Int16).Value      = 0;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.ExecuteNonQuery();

                        MessageBox.Show("Guest saved successfully!");
                        this.Close();

                        var form = new GuestListFrm();
                        form.Show();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                    con.Close();
                }
                else
                {
                    InternationalGuest guest = new InternationalGuest(
                        txtFirstName.Text,
                        txtLastName.Text,
                        txtEmail.Text,
                        occupation,
                        dtpBirth.Value,
                        nationality,
                        Convert.ToInt64(txtPhone.Text),
                        txtDocument.Text,
                        issuingCountry
                        );

                    MySqlConnection con = new MySqlConnection(Globals.connString);
                    con.Open();

                    try
                    {
                        MySqlCommand cmd = new MySqlCommand("SaveNewGuest", con);
                        cmd.Parameters.Add("_first_name", MySqlDbType.VarChar, 55).Value      = guest.FirstName;
                        cmd.Parameters.Add("_last_name", MySqlDbType.VarChar, 55).Value       = guest.LastName;
                        cmd.Parameters.Add("_email", MySqlDbType.VarChar, 60).Value           = guest.Email;
                        cmd.Parameters.Add("_occupation", MySqlDbType.VarChar, 45).Value      = guest.Occupation;
                        cmd.Parameters.Add("_birth_date", MySqlDbType.Date).Value             = guest.Birthdate;
                        cmd.Parameters.Add("_nationality", MySqlDbType.VarChar, 60).Value     = guest.Nationality;
                        cmd.Parameters.Add("_gender", MySqlDbType.VarChar, 6).Value           = gender;
                        cmd.Parameters.Add("_phone", MySqlDbType.VarChar, 50).Value           = guest.Phone;
                        cmd.Parameters.Add("_document", MySqlDbType.VarChar, 50).Value        = guest.Passport;
                        cmd.Parameters.Add("_document_type", MySqlDbType.VarChar, 25).Value   = Globals.foreignDocument;
                        cmd.Parameters.Add("_issuing_body", MySqlDbType.VarChar, 45).Value    = null;
                        cmd.Parameters.Add("_issuing_country", MySqlDbType.VarChar, 60).Value = issuingCountry;
                        cmd.Parameters.Add("_is_international", MySqlDbType.Int16).Value      = 1;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.ExecuteNonQuery();

                        MessageBox.Show("Guest saved successfully!");
                        this.Close();

                        var form = new GuestListFrm();
                        form.Show();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                    con.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }