Exemple #1
0
        private void roomsearchbutton_Click(object sender, EventArgs e)
        {
            if (roomsearchcomboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select your search type");
            }
            else
            {
                if (roomsearchtextBox.Text == "")
                {
                    MessageBox.Show("Please type your search");
                }
                else
                {
                    if (roomsearchcomboBox.SelectedItem.ToString() == "Roomno")
                    {
                        roomdataGridView.DataSource = null;
                        roomdataGridView.Rows.Clear();
                        List <Room> rlist = da.getRoomByRoomno(roomsearchtextBox.Text);
                        if (rlist.Count != 0)
                        {
                            foreach (var item in rlist)
                            {
                                roomdataGridView.Rows.Add(item.Roomno, item.RoomType, item.RoomCost, item.RoomStatus);
                            }
                        }
                        else
                        {
                            MessageBox.Show("No results found");
                        }
                    }
                    else if (roomsearchcomboBox.SelectedItem.ToString() == "Roomtype")
                    {
                        roomdataGridView.DataSource = null;
                        roomdataGridView.Rows.Clear();
                        List <Room> rlist = da.getRoomByRoomtype(roomsearchtextBox.Text);
                        if (rlist.Count != 0)
                        {
                            foreach (var item in rlist)
                            {
                                roomdataGridView.Rows.Add(item.Roomno, item.RoomType, item.RoomCost, item.RoomStatus);
                            }
                        }
                        else
                        {
                            MessageBox.Show("No results found");
                        }
                    }

                    else if (roomsearchcomboBox.SelectedItem.ToString() == "Roomstatus")
                    {
                        roomdataGridView.DataSource = null;
                        roomdataGridView.Rows.Clear();
                        List <Room> rlist = da.getRoomByRoomstatus(roomsearchtextBox.Text);
                        if (rlist.Count != 0)
                        {
                            foreach (var item in rlist)
                            {
                                roomdataGridView.Rows.Add(item.Roomno, item.RoomType, item.RoomCost, item.RoomStatus);
                            }
                        }
                        else
                        {
                            MessageBox.Show("No results found");
                        }
                    }

                    else if (roomsearchcomboBox.SelectedItem.ToString() == "Roomcost")
                    {
                        roomdataGridView.DataSource = null;
                        roomdataGridView.Rows.Clear();
                        List <Room> rlist = da.getRoomByRoomcost(roomsearchtextBox.Text);
                        if (rlist.Count != 0)
                        {
                            foreach (var item in rlist)
                            {
                                roomdataGridView.Rows.Add(item.Roomno, item.RoomType, item.RoomCost, item.RoomStatus);
                            }
                        }
                        else
                        {
                            MessageBox.Show("No results found");
                        }
                    }
                }
            }
        }