Traditional Culture Encyclopedia - Hotel reservation - A hotel management system is built using C#.NET and SQL. I want to use BUTTON colors to visually reflect the status of hotel rooms. How should I write the code?

A hotel management system is built using C#.NET and SQL. I want to use BUTTON colors to visually reflect the status of hotel rooms. How should I write the code?

Make a corresponding relationship between the button and the room, and then change the background color of the button according to the status retrieved from the database

struct BtnRoom

{

p>

public Button button;

public string value;

public bool state;

public BtnRoom(Button btn, string room)

{

button = btn;

value = room;

state = false;

}

}

BtnRoom[] btnroom = { new BtnRoom(this.Button0, "r3008"), new BtnRoom(Button1, "r3008"), new BtnRoom(Button2, "r3008"), new BtnRoom(Button3, "r3008"), new BtnRoom(Button4, "r3008"), new BtnRoom(Button5, "r3008") };

//Replace the following with the statement to get the room status from the database , just set it according to the status

for (int i = 0; i < 6; i++)

{

if (i % 2 == 0)

{

btnroom[i].state = true;

btnroom[i].button.BackColor = Color.Green;

}

}