protected void calculateRateButton_Click(object sender, EventArgs e)
{
//declare variables and retrieve user inputs
int nbPeopleInt;
string roomTypeString;
int nbNightsInt;
nbNightsInt = int.Parse(nbNightsTextBox.Text);
nbPeopleInt = int.Parse(nbPeopleDropDownList.Text);
roomTypeString = roomTypeDropDownList.Text;
int totalFareInt = calculateRoomBooking(roomTypeString, nbPeopleInt, nbNightsInt);
}
private int calculateRoomBooking(string RoomType, int nbNights, int nbPeople)
{
int totalFareInt = 0;
int dailyRateInt = 0;
// set daily rate based on selected room type
switch (RoomType)
{
case "Standard":
dailyRateInt = 100;
break;
case "Superior":
dailyRateInt = 150;
break;
case "Luxury":
dailyRateInt = 175;
break;
}
// calculation of booking rate
totalFareInt = dailyRateInt * nbNightsInt + 10 * (nbPeopleInt - 1) * nbNightsInt;
// display booking rate
totalRateTextBox.Text = totalFareInt.ToString();
}
protected void roomDetailsButton_Click(object sender, ImageClickEventArgs e)
{
// go to room details page
Response.Redirect("RoomDetails.aspx");
}
但是,它总是说 dailyRateInt, nbNightsInt, nbPeopleInt 没有用这一行定义:
totalFareInt = dailyRateInt * nbNightsInt + 10 * (nbPeopleInt - 1) * nbNightsInt;
但是我确实在上面定义了它们,你们可以看到
请帮忙