我正在使用在C#中使用带有ASP.NET的GUI的机票预订系统。
我想要的是为用户分配席位,在用户分配席位后,该席位不能再由其他人分配。我尝试使用增量来执行此操作,但不是1 + 1 = 2(这意味着要分配的下一个座位号2),而是系统给我1 + 1 = 11。我该怎么办?
为此,我有5个接口,我需要在整个运行过程中存储此分配的值。
这是我的预订按钮代码,我有2个,头等舱和经济舱。头等舱仅5个席位,经济舱仅15个席位。
我能怎么做 ?
protected void Button1_Click(object sender, EventArgs e)
{
Session["seats"] = "First Class";
if (firstseatnum > 5)
{
MessageBox.Show("Sorry, the first class seats was fully booked. Can you change to economy class?");
Response.Redirect("reservation.aspx");
}
else
{
++firstseatnum;
totalseatnum1 = Convert.ToInt32(firstseatnum+seatnum);
Response.Redirect("~/information.aspx?firstseatnum="+firstseatnum+"&seatnum="+totalseatnum1);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Session["seats"] = "Economy Class";
if (economyseatnum > 20)
{
MessageBox.Show("Sorry, the economy class seats was fully booked. Can you change to first class?");
Response.Redirect("reservation.aspx");
}
else
{
++economyseatnum;
totalseatnum2 = Convert.ToInt32(economyseatnum + seatnum);
Response.Redirect("information.aspx?economyseatnum=" + economyseatnum + "&seatnum="+totalseatnum2);
}
}
请帮助我,谢谢。
最佳答案
大概seatnum
是一个字符串。
如果是这样,请尝试
totalseatnum1 = firstseatnum + Convert.ToInt32(seatnum);
和
totalseatnum2 = economyseatnum + Convert.ToInt32(seatnum);
关于c# - 如何在页面之间传递值?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40450657/