这是 C# 程序我在这行代码中有一个问题:
我输入大于或等于 400 的=
数字它运行我输入的数字小于或等于 500=
它运行我输入介于 400 和 500 之间的数字,例如 401 到 499=
它运行我清空输入 = 错误我输入字母 = 错误
请注意,我运行的代码仅单独接受整数,它运行的代码以及不接受空输入的代码也运行
你觉得哪里不对?
int parsedValue;
if (int.Parse(txtVacate.Text) <= 400 || int.Parse(txtVacate.Text) >= 500)
MessageBox.Show("Romms provided is not vacant or does not exist at all.");
else if (txtVacate.Text == " ")
MessageBox.Show("You provide empty");
else if (!int.TryParse(txtVacate.Text, out parsedValue))
MessageBox.Show("Please provide right info");
else
{
MySqlConnection connection = null;
string hostname = "localhost";
string database = "aparece_hoteldb";
string username = "root";
string password = "";
connection = new MySqlConnection("host=" + hostname +
";database=" + database +
";username=" + username +
";password=" + password + ";");
string table = "reservations";
string query = "DELETE FROM reservations WHERE RoomNumber = " + txtVacate.Text;
connection.Open();
MySqlDataAdapter da_res = null;
DataSet ds_res = null;
ds_res = new DataSet();
da_res = new MySqlDataAdapter(query, connection);
da_res.Fill(ds_res, table);
MessageBox.Show("Room" + " " + txtVacate.Text + " " + "is now Vacant please reload!");
dataGridView2.DataSource = ds_res.Tables[table];
this.Close();