📄 telephoneform.aspx.cs
字号:
//文件名:TelephoneForm.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_TelephoneForm : System.Web.UI.Page
{
private static DataTable MyTelephoneTable = new DataTable();
private static int MyID = 0;
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("B2") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
if (!IsPostBack)
{
//创建无连接的数据表
DataColumn[] MyKey = new DataColumn[1];
MyTelephoneTable = new DataTable("话费入账");
DataColumn MyColumn = new DataColumn();
MyColumn.DataType = System.Type.GetType("System.Int16");
MyColumn.ColumnName = "自编号";
MyTelephoneTable.Columns.Add(MyColumn);
MyKey[0] = MyColumn;
MyTelephoneTable.PrimaryKey = MyKey;
MyTelephoneTable.Columns.Add("入住编号", System.Type.GetType("System.String"));
MyTelephoneTable.Columns.Add("话费编号", System.Type.GetType("System.String"));
MyTelephoneTable.Columns.Add("通话时间", System.Type.GetType("System.DateTime"));
MyTelephoneTable.Columns.Add("类别", System.Type.GetType("System.String"));
MyTelephoneTable.Columns.Add("金额", System.Type.GetType("System.Double"));
MyTelephoneTable.Columns.Add("说明", System.Type.GetType("System.String"));
MyTelephoneTable.Columns.Add("记账时间", System.Type.GetType("System.DateTime"));
MyTelephoneTable.Columns.Add("操作人员", System.Type.GetType("System.String"));
this.TextBox1.Text = DateTime.Now.ToShortDateString();
}
this.Page.Title = "当前位置:消费管理->旅客话费登记";
this.GridView1.DataSource = MyTelephoneTable;
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();
MyTelephoneTable.Rows.Clear();
this.GridView1.DataBind();
MyID = 0;
}
protected void Button1_Click(object sender, EventArgs e)
{//向临时数据表中新增话费信息
MyID = MyID + 1;
DataRow MyRow = MyTelephoneTable.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;
MyTelephoneTable.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(MyTelephoneTable);
MyTelephoneTable.Rows.Clear();
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
Button4_Click(null, null);
}
public DataTable MyTable
{//设置要传递到打印页的数据表
get
{
return MyTelephoneTable;
}
}
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/TelephonePrint.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -