📄 checkform.aspx.cs
字号:
//文件名:CheckForm.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 EatingManage_CheckForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("B3") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
this.Button2.OnClientClick = "return confirm('请检查客人结账信息是否正确,一旦结账就无法修改,是否继续?')";
if (!IsPostBack)
{
this.TextBox1.Text = DateTime.Now.ToShortDateString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{//统计客人用餐信息
string MySQL="Select SUM(计费金额) FROM 用餐明细 WHERE 用餐单号='"+this.DropDownList2.SelectedValue.ToString()+"'";
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyEateryDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlCommand MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = MySQL;
this.TextBox2.Text = MyCommand.ExecuteScalar().ToString();
this.TextBox4.Text = MyCommand.ExecuteScalar().ToString();
if (MyConnection.State == ConnectionState.Open)
MyConnection.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{//登记用餐结账信息
if (!(Convert.ToDouble(this.TextBox2.Text) - Convert.ToDouble(this.TextBox3.Text) - Convert.ToDouble(this.TextBox4.Text) == 0))
return;
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyEateryDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
DataTable MyTable = new DataTable();
string MySQL = "SELECT 入座台位 FROM 用餐信息 WHERE 用餐单号='" + this.DropDownList2.SelectedValue.ToString() + "'";
SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
MyAdatper.Fill(MyTable);
String My台位编号 = MyTable.Rows[0][0].ToString();
MySQL = "Update 用餐信息 Set 用餐金额="+this.TextBox2.Text+",折扣金额="+this.TextBox3.Text+",实收金额="+this.TextBox4.Text+",补充说明='"+this.TextBox5.Text+"',宾客意见='"+this.TextBox6.Text+"',当前状态='已经结账' WHERE 用餐单号='" + this.DropDownList2.SelectedValue.ToString() + "';";
MySQL += "Update 台位信息 SET 当前状态='空置' WHERE 台位编号='" + My台位编号 + "';";
MyConnection.Open();
SqlCommand MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = MySQL;
MyCommand.ExecuteNonQuery();
if (MyConnection.State == ConnectionState.Open)
MyConnection.Close();
this.SqlDataSource2.DataBind();
this.DropDownList2.DataBind();
this.SqlDataSource3.DataBind();
this.GridView1.DataBind();
}
protected void Button3_Click(object sender, EventArgs e)
{//打印客人用餐结账信息
Response.Redirect("~/EatingManage/CheckPrint.aspx?MyID=" + this.GridView1.SelectedRow.Cells[1].Text.ToString());
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{//在GridView控件单元格中设置短日期显示格式
if (e.Row.RowType == DataControlRowType.DataRow)
{
DateTime MyDate = DateTime.Parse(e.Row.Cells[4].Text);
e.Row.Cells[4].Text = MyDate.ToShortDateString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -