public static void addRoom(roomInformation room)
        {
            // insert patient to database patient info table.
            string query2 = "insert into roombooking(pid,roomtype,roomno,price,startdate,enddate,status) values(@PID,@Roomtype,@Roomno,@Price,@Startdate,@Enddate,@Status)";

            modifyRoom(room, query2);
        }
        public static roomInformation getRoom(int pid)
        {
            roomInformation r = new roomInformation();
            MySqlCommand    command;
            MySqlDataReader dataReader;
            string          query = "select * from roombooking where pid=@pid";

            connection.Open();
            command = new MySqlCommand(query, connection);
            command.Parameters.AddWithValue("@pid", pid);
            dataReader = command.ExecuteReader();
            while (dataReader.Read())
            {
                r.pid       = pid;
                r.Roomtype  = (string)dataReader["roomtype"];
                r.Status    = (string)dataReader["status"];
                r.Roomno    = (int)dataReader["roomno"];
                r.Price     = (int)dataReader["price"];
                r.Startdate = (string)dataReader["startdate"];
                r.Enddate   = (string)dataReader["enddate"];
            }
            dataReader.Close();
            command.Dispose();
            connection.Close();
            return(r);
        }
        private void btnupdate_Click(object sender, EventArgs e)
        {
            roomInformation room = roomInfoFromForm();

            DatabaseHelper.updateRoom(room);
            MessageBox.Show("Patient updated successfully");
        }
        private void btnsubmit_Click(object sender, EventArgs e)
        {
            roomInformation room = roomInfoFromForm();

            DatabaseHelper.addRoom(room);


            MessageBox.Show("Room Resistered successfully");
        }
        private void btnfetch_Click(object sender, EventArgs e)
        {
            PatientInformation pi = DatabaseHelper.getPatient(Convert.ToInt32(textPID.Text));
            roomInformation    r  = DatabaseHelper.getRoom(Convert.ToInt32(textPID.Text));

            b.pid            = pi.pid;
            b.name           = pi.name;
            b.Roomno         = r.Roomno;
            b.RoomRent       = r.Price;
            textptname.Text  = b.name;
            txtroomno.Text   = Convert.ToString(b.Roomno);
            txtroomrent.Text = Convert.ToString(b.RoomRent);
        }
        private static void modifyRoom(roomInformation room, string query2)
        {
            connection.Open();

            MySqlCommand command = new MySqlCommand(query2, connection);

            Console.WriteLine("QUERY:= " + query2);

            command.Parameters.AddWithValue("@PID", room.pid);
            command.Parameters.AddWithValue("@Roomtype", room.Roomtype);
            command.Parameters.AddWithValue("@Roomno", room.Roomno);
            command.Parameters.AddWithValue("@Price", room.Price);
            command.Parameters.AddWithValue("@Startdate", room.Startdate);
            command.Parameters.AddWithValue("@Enddate", room.Enddate);
            command.Parameters.AddWithValue("@Status", room.Status);

            command.ExecuteNonQuery();
            command.Dispose();
            connection.Close();
        }
        private roomInformation roomInfoFromForm()
        {
            roomInformation room = new roomInformation();

            room.pid = Convert.ToInt32(txtpid.Text);

            room.Roomno    = Convert.ToInt32(txtroomno.Text);
            room.Price     = Convert.ToInt32(txtprice.Text);
            room.Startdate = dateTimePicker1.Text;
            room.Enddate   = dateTimePicker2.Text;

            if (rbnsharing.Checked)
            {
                room.Roomtype = rbnsharing.Text;
            }
            else if (rbnsingle.Checked)
            {
                room.Roomtype = rbnsingle.Text;
            }
            else if (rbndelux.Checked)
            {
                room.Roomtype = rbndelux.Text;
            }
            else
            {
                room.Roomtype = rbnsuite.Text;
            }

            if (radioButton1.Checked)
            {
                room.Status = radioButton1.Text;
            }
            else
            {
                room.Status = radioButton2.Text;
            }
            return(room);
        }
        private void btnfetch_Click(object sender, EventArgs e)
        {
            roomInformation r = DatabaseHelper.getRoom(Convert.ToInt32(txtpid.Text));

            switch (r.Roomtype)
            {
            case "Sharing":
                rbnsharing.Checked = true;
                break;

            case "Single":
                rbnsingle.Checked = true;
                break;

            case "Delux":
                rbndelux.Checked = true;
                break;

            case "Suite":
                rbnsuite.Checked = true;
                break;
            }
            switch (r.Status)
            {
            case "Vacant":
                radioButton1.Checked = true;
                break;

            case "Occupied":
                radioButton2.Checked = true;
                break;
            }
            txtroomno.Text = Convert.ToString(r.Roomno);

            txtprice.Text = Convert.ToString(r.Price);
        }
        public static void updateRoom(roomInformation room)
        {
            string query2 = "update roombooking set roomtype=@Roomtype,@status=status,startdate=@Startdate,enddate=@Enddate,roomno=@Roomno,price=@Price where pid=@PID";

            modifyRoom(room, query2);
        }