📄 selectdate.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class reservation : System.Web.UI.Page
{
//private int test;
private ReservationOperater oper;
public reservation()
{
oper = new ReservationOperater();
oper.initDB();
}
protected void Page_Load(object sender, EventArgs e)
{
FindAvailableRoom();
for (int i = Table1.Rows.Count; i > 1; i--)
{
string room = Table1.Rows[i - 1].Cells[0].Text;
if (ViewState[room] != null && (bool)ViewState[room] == true)
{
((CheckBox)(Table1.Rows[i - 1].Cells[3]).Controls[0]).Checked = true;
}
}
}
/// <summary>
/// 获取定的房间列表
/// </summary>
/// <returns></returns>
public ArrayList getRoomList()
{
ArrayList roomlist=new ArrayList();
int count = Table1.Rows.Count-1;
if (count == 0)
return null;
for (int i = count; i > 0; i--)
{
if (((CheckBox)Table1.Rows[i].Cells[3].Controls[0]).Checked == true)
{
roomlist.Add(Table1.Rows[i].Cells[0].Text);
}
}
return roomlist;
}
/// <summary>
/// 选离开日期
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Calendar2_SelectionChanged(object sender, EventArgs e)
{
//test = 100;
DateTime endday=Calendar2.SelectedDate;
TextBox5.Text =endday.Year+"-"+endday.Month+"-"+endday.Day;
TextBox7.Text = Calendar2.SelectedDate.TimeOfDay.ToString();
if (TextBox4.Text != "")
{
FindAvailableRoom();
}
}
/// <summary>
/// 寻找可用房间
/// </summary>
void FindAvailableRoom()
{
string startTime=TextBox4.Text+" "+TextBox6.Text;
string endTime=TextBox5.Text+" "+TextBox7.Text;
if (startTime == " " || endTime == " ")
return;
ArrayList availableroom = oper.GetAvailableRoom(startTime,endTime);
//只留第一行标签项目
for (int i = Table1.Rows.Count; i > 1; i--)
{
if (i > 1)
{
Table1.Rows.RemoveAt(i - 1);
}
}
foreach (HotelRoomInfo aRoom in availableroom)
{
TableRow arow = new TableRow();
Table1.Rows.Add(arow);
TableCell roomNOCell = new TableCell();
roomNOCell.Text = aRoom.roomNO.ToString();
arow.Cells.Add(roomNOCell);
TableCell roomtypeCell = new TableCell();
roomtypeCell.Text = aRoom.roomtype;
arow.Cells.Add(roomtypeCell);
TableCell priceCell = new TableCell();
priceCell.Text = aRoom.roomPrice.ToString();
arow.Cells.Add(priceCell);
TableCell checkBoxCell = new TableCell();
CheckBox thecheckbox = new CheckBox();
thecheckbox.EnableViewState = true;
thecheckbox.CheckedChanged += new EventHandler(thecheckbox_CheckedChanged);
thecheckbox.AutoPostBack = true;
thecheckbox.ToolTip = roomNOCell.Text;
checkBoxCell.Controls.Add(thecheckbox);
arow.Cells.Add(checkBoxCell);
arow.EnableViewState = true;
//form1.Controls.Add(checkBoxCell);
//Table1.Rows.Add(arow);
}
}
/// <summary>
/// 选房间
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void thecheckbox_CheckedChanged(object sender, EventArgs e)
{
CheckBox mysender = (CheckBox)sender;
if (mysender.Checked == true)
{
ViewState[mysender.ToolTip] = true;
return;
}
if (mysender.Checked == false)
{
ViewState[mysender.ToolTip] = false;
return;
}
}
/// <summary>
/// 选入住日期
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
DateTime startday = Calendar1.SelectedDate;
TextBox4.Text = startday.Year + "-" + startday.Month + "-" + startday.Day;
TextBox6.Text = Calendar1.SelectedDate.TimeOfDay.ToString();
if (TextBox5.Text !="")
{
if (TextBox4.Text != null)
{
FindAvailableRoom();
}
}
}
protected void Table1_Disposed(object sender, EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -