Exemplo n.º 1
0
        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string first_string  = listBox1.SelectedItem.ToString();
            string second_string = string.Empty;
            string third_string  = listBox1.SelectedItem.ToString();
            string four_string   = string.Empty;


            DialogResult dialogResult = MessageBox.Show("Are you sure you want to book this room?", "Booking this Room", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=" + "C:\\Users\\" + Environment.UserName + "\\Documents\\hoteldatabase.mdf" + ";Integrated Security=True;Connect Timeout=30");

                sqlcon.Open();


                SqlCommand cmd = new SqlCommand("Select * from Rooms where Hotel = '" + comboBox1.Text.Trim() + "' and RoomNumber = '" + Roomnum + "'");


                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = sqlcon;

                SqlDataReader reader = cmd.ExecuteReader();

                reader.Read();

                ClientsInfo ClientsInfo = new ClientsInfo();
                Checkininfo Checkininfo = new Checkininfo();
                ClientsInfo.RoomID = Int32.Parse(reader[0].ToString());


                sqlcon.Close();

                ClientsInfo.textBox5.Text = monthCalendar2.SelectionStart.ToString("d/M/yyyy");
                ClientsInfo.textBox6.Text = comboBox1.Text;
                ClientsInfo.textBox7.Text = monthCalendar1.SelectionStart.ToString("d/M/yyyy");



                this.Hide();

                ClientsInfo.Show();
            }
            else if (dialogResult == DialogResult.No)
            {
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();



            updatingrooms();
            groupBox1.Visible = true;


            ClientsInfo ClientsInfo = new ClientsInfo();

            ClientsInfo.Checkin = monthCalendar1.SelectionStart.ToString("M/d/yyyy");
            date1 = monthCalendar1.SelectionStart.ToString("M/d/yyyy");
            date2 = monthCalendar2.SelectionStart.ToString("M/d/yyyy");



            ClientsInfo.Checkout = monthCalendar2.SelectionStart.ToString("M/d/yyyy");



            try
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (row.Cells[1].Value.ToString().Trim().Equals(comboBox1.Text.Trim()) && row.Cells[3].Value.ToString().Trim().Equals("1") && row.Cells[6].Value.ToString().Trim().Equals(comboBox2.Text.Trim()) && row.Cells[7].Value.ToString().Trim().Equals(numericUpDown1.Text.Trim()) && row.Cells[8].Value.ToString().Trim().Equals(numericUpDown2.Text.Trim()))
                    {
                        Roomnum = row.Cells[2].Value;
                        listBox1.Items.Add("Room Number: " + row.Cells[2].Value.ToString() + " *Price per night " + row.Cells[9].Value.ToString() + "€");
                    }
                }
            }
            catch
            {
                if (listBox1.Items.Count > 0)
                {
                    label7.Visible = true;
                    checkavailability();
                }
                else
                {
                    label7.Visible = false;
                    MessageBox.Show("No room Found");
                }
            }
        }