📄 bookingregform.aspx.cs
字号:
//文件名:BookingRegForm.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;
using System.Data.SqlClient;
public partial class BookingManage_BookingRegForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("C1") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
this.Button1.OnClientClick = "return confirm('请检查预订信息是否正确,一旦新增就无法修改,是否继续?')";
this.Button2.OnClientClick = "return confirm('是否确认取消当前在表格中选择的预订信息?')";
this.TextBox1.Text ="YD"+ DateTime.Now.Year.ToString();
if (DateTime.Now.Month < 10)
this.TextBox1.Text += "0";
this.TextBox1.Text += DateTime.Now.Month.ToString();
if (DateTime.Now.Day < 10)
this.TextBox1.Text += "0";
this.TextBox1.Text += DateTime.Now.Day.ToString();
if (DateTime.Now.Hour < 10)
this.TextBox1.Text += "0";
this.TextBox1.Text += DateTime.Now.Hour.ToString();
if (DateTime.Now.Minute < 10)
this.TextBox1.Text += "0";
this.TextBox1.Text += DateTime.Now.Minute.ToString();
if (DateTime.Now.Second < 10)
this.TextBox1.Text += "0";
this.TextBox1.Text += DateTime.Now.Second.ToString();
this.TextBox2.Text = DateTime.Now.ToShortDateString();
}
protected void Button1_Click(object sender, EventArgs e)
{//新增预订
this.SqlDataSource1.Insert();
}
protected void Button2_Click(object sender, EventArgs e)
{//取消预订
string My预订编号 =this.GridView1.SelectedRow.Cells[1].Text.ToString();
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyEateryDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
string MySQL= "Update 预订信息 SET 当前状态='已经取消' WHERE 预订编号='" + My预订编号 + "';";
MyConnection.Open();
SqlCommand MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = MySQL;
MyCommand.ExecuteNonQuery();
if (MyConnection.State == ConnectionState.Open)
MyConnection.Close();
this.SqlDataSource1.DataBind();
this.GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{//在GridView控件单元格中设置短日期显示格式
if (e.Row.RowType == DataControlRowType.DataRow)
{
DateTime MyDate = DateTime.Parse(e.Row.Cells[2].Text);
e.Row.Cells[2].Text = MyDate.ToShortDateString();
MyDate = DateTime.Parse(e.Row.Cells[3].Text);
e.Row.Cells[3].Text = MyDate.ToShortDateString();
}
}
protected void Button4_Click(object sender, EventArgs e)
{//打印客人用餐预订单
Response.Redirect("~/BookingManage/BookingRegPrint.aspx?MyID=" + this.GridView1.SelectedRow.Cells[1].Text.ToString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -