📄 bookingcheckform.aspx.cs
字号:
//文件名:BookingCheckForm.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;
using System.Globalization;
using System.Collections.Specialized;
using System.Text.RegularExpressions;
public partial class BookingManage_BookingCheckForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("C3") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
this.Button1.OnClientClick = "return confirm('请检查客人结账信息是否正确,一旦结账就无法修改,是否继续?')";
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{//获取客人用餐信息
string MyID = this.DropDownList1.SelectedValue.ToString();
string MySQL = "Select 预交订金 FROM 预订信息 WHERE 预订编号='" + MyID + "'";
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyEateryDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
DataTable MyTable = new DataTable();
SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
MyAdatper.Fill(MyTable);
this.TextBox3.Text = MyTable.Rows[0][0].ToString();
MyConnection.Close();
MySQL = "Select SUM(计费金额) FROM 用餐明细 WHERE 用餐单号 LIKE '%" +MyID + "%'";
MyConnection.Open();
SqlCommand MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = MySQL;
this.TextBox2.Text = MyCommand.ExecuteScalar().ToString();
double My实收金额 = Convert.ToDouble(this.TextBox2.Text) - Convert.ToDouble(this.TextBox3.Text) - Convert.ToDouble(this.TextBox4.Text);
this.TextBox5.Text = My实收金额.ToString();
if (MyConnection.State == ConnectionState.Open)
MyConnection.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{//登记预订用餐结账信息
if (!(Convert.ToDouble(this.TextBox2.Text) - Convert.ToDouble(this.TextBox3.Text) - Convert.ToDouble(this.TextBox4.Text) - Convert.ToDouble(this.TextBox5.Text) == 0))
return;
string MyID = this.DropDownList1.SelectedValue.ToString();
string MySQL = "Select 用餐单号 FROM 用餐信息 WHERE 用餐单号 LIKE '%" + MyID + "%'";
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyEateryDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
DataTable MyTable = new DataTable();
SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
MyAdatper.Fill(MyTable);
MyConnection.Close();
foreach (DataRow MyRow in MyTable.Rows)
{
string My用餐单号= MyRow[0].ToString();
MySQL = "Select SUM(计费金额) FROM 用餐明细 WHERE 用餐单号='" + My用餐单号 + "'";
MyConnection.Open();
SqlCommand MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = MySQL;
double My计费金额 = Convert.ToDouble(MyCommand.ExecuteScalar().ToString());
double My总用餐金额 =Convert.ToDouble(this.TextBox2.Text);
double My总实收金额 =Convert.ToDouble(this.TextBox5.Text);
Double My总预收金额 = Convert.ToDouble(this.TextBox3.Text);
double My实收金额 = My计费金额 / My总用餐金额 * (My总实收金额 + My总预收金额);
NumberFormatInfo MyNumberFormatInfo = new CultureInfo("zh-CN", false).NumberFormat;
My实收金额 =Convert.ToDouble(String.Format(My实收金额.ToString("N", MyNumberFormatInfo)));
double My折扣金额 = My计费金额 - My实收金额;
DataTable MyNewTable = new DataTable();
MySQL = "SELECT 入座台位 FROM 用餐信息 WHERE 用餐单号='" + My用餐单号 + "'";
MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
MyAdatper.Fill(MyNewTable);
MyConnection.Close();
String My台位编号 = MyNewTable.Rows[0][0].ToString();
MySQL = "Update 用餐信息 Set 用餐金额=" + My计费金额 + ",折扣金额=" + My折扣金额 + ",实收金额=" + My实收金额 + ",补充说明='" + this.TextBox6.Text + "',宾客意见='" + this.TextBox7.Text + "',当前状态='已经结账' WHERE 用餐单号='" + My用餐单号 + "';";
MySQL += "Update 台位信息 SET 当前状态='空置' WHERE 台位编号='" + My台位编号 + "';";
MySQL += "Update 预订信息 SET 当前状态='已经处理' WHERE 预订编号='" + MyID + "';";
MyConnection.Open();
MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = MySQL;
MyCommand.ExecuteNonQuery();
MyConnection.Close();
}
if (MyConnection.State == ConnectionState.Open)
MyConnection.Close();
this.SqlDataSource2.DataBind();
this.SqlDataSource1.DataBind();
this.GridView1.DataBind();
this.DropDownList1.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 Button2_Click(object sender, EventArgs e)
{//打印客人用餐结账信息
Response.Redirect("~/BookingManage/BookingCheckPrint.aspx?MyID=" + this.GridView1.SelectedRow.Cells[1].Text.ToString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -