📄 eatingform.aspx.cs
字号:
//文件名:EatingForm.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 ConsumeManage_EatingForm : System.Web.UI.Page
{
private static DataTable MyEatingTable = new DataTable();
private static int MyID = 0;
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("B1") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
if (!IsPostBack)
{
//创建无连接的数据表
DataColumn[] MyKey = new DataColumn[1];
MyEatingTable = new DataTable("餐费入账");
DataColumn MyColumn = new DataColumn();
MyColumn.DataType = System.Type.GetType("System.Int16");
MyColumn.ColumnName = "自编号";
MyEatingTable.Columns.Add(MyColumn);
MyKey[0] = MyColumn;
MyEatingTable.PrimaryKey = MyKey;
MyEatingTable.Columns.Add("入住编号", System.Type.GetType("System.String"));
MyEatingTable.Columns.Add("餐费编号", System.Type.GetType("System.String"));
MyEatingTable.Columns.Add("用餐时间", System.Type.GetType("System.DateTime"));
MyEatingTable.Columns.Add("类别", System.Type.GetType("System.String"));
MyEatingTable.Columns.Add("金额", System.Type.GetType("System.Double"));
MyEatingTable.Columns.Add("说明", System.Type.GetType("System.String"));
MyEatingTable.Columns.Add("记账时间", System.Type.GetType("System.DateTime"));
MyEatingTable.Columns.Add("操作人员", System.Type.GetType("System.String"));
this.TextBox1.Text = DateTime.Now.ToShortDateString();
}
this.Page.Title = "当前位置:消费管理->旅客餐费登记";
this.GridView1.DataSource = MyEatingTable;
this.Button3.OnClientClick = "return confirm('请检查旅客餐费信息是否正确,一旦保存就无法修改,是否继续?')";
}
protected void Button4_Click(object sender, EventArgs e)
{//随机生成餐费编号
this.TextBox4.Text = System.Guid.NewGuid().ToString().ToUpper();
this.TextBox5.Text = Session["MyUserName"].ToString();
this.TextBox6.Text = DateTime.Now.ToShortDateString();
MyEatingTable.Rows.Clear();
this.GridView1.DataBind();
MyID = 0;
}
protected void Button1_Click(object sender, EventArgs e)
{//向临时数据表中新增餐费信息
MyID = MyID + 1;
DataRow MyRow = MyEatingTable.NewRow();
MyRow[0] = MyID;
MyRow["入住编号"] = this.DropDownList2.SelectedValue.ToString();
MyRow["餐费编号"] = this.TextBox4.Text;
MyRow["用餐时间"] = this.TextBox1.Text;
MyRow["类别"] = this.DropDownList3.SelectedValue.ToString();
MyRow["金额"] = this.TextBox2.Text;
MyRow["说明"] = this.TextBox3.Text;
MyRow["记账时间"] = this.TextBox6.Text;
MyRow["操作人员"] = this.TextBox5.Text;
MyEatingTable.Rows.Add(MyRow);
this.GridView1.DataBind();
}
protected void Button3_Click(object sender, EventArgs e)
{//保存旅客餐费信息
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHotelDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlBulkCopy MyBulkCopy = new SqlBulkCopy(MyConnection);
MyBulkCopy.DestinationTableName = "餐费入账";
MyBulkCopy.WriteToServer(MyEatingTable);
MyEatingTable.Rows.Clear();
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
Button4_Click(null, null);
}
public DataTable MyTable
{//设置要传递到打印页的数据表
get
{
return MyEatingTable;
}
}
public String My入住房号
{//设置要传递到打印页的入住房号
get
{
return this.DropDownList1.SelectedValue.ToString();
}
}
public String My客人姓名
{//设置要传递到打印页的客人姓名
get
{
return this.DropDownList2.SelectedItem.Text;
}
}
protected void Button2_Click(object sender, EventArgs e)
{//打印旅客餐费信息
Server.Transfer("~/ConsumeManage/EatingPrint.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -