📄 depositform.aspx.cs
字号:
//文件名:DepositForm.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 RoomManage_DepositForm : System.Web.UI.Page
{
private string My入住编号;
private double My累计补交押金 = 0;
private double My店内消费 = 0;
private double My电话费 = 0;
private double My用餐费 = 0;
private double My住宿费 = 0;
private double My费用总额 = 0;
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("A6") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
this.Page.Title = "当前位置:客房管理->旅客补交押金";
this.Button3.OnClientClick = "return confirm('请检查旅客押金补交信息是否正确,一旦保存就无法修改,是否继续?')";
}
protected void Button1_Click(object sender, EventArgs e)
{//查询旅客的费用信息
My累计补交押金 = 0;
My店内消费 = 0;
My电话费 = 0;
My用餐费 = 0;
My住宿费 = 0;
My费用总额 = 0;
this.TextBox5.Text = "";
this.TextBox3.Text = "";
this.TextBox4.Text = "";
this.TextBox1.Text = "";
this.TextBox2.Text = "";
this.TextBox7.Text = "";
this.TextBox6.Text = "";
this.My入住编号 = this.DropDownList2.SelectedValue.ToString();
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHotelDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
string MySQL = "Select SUM(预收押金) From 客房入住单 Where 入住编号='" + this.My入住编号 + "'";
SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
this.TextBox5.Text = MyCommand.ExecuteScalar().ToString();
MySQL = "Select SUM(金额) From 话费入账 Where 入住编号='" + this.My入住编号 + "'";
MyCommand = new SqlCommand(MySQL, MyConnection);
this.TextBox3.Text = MyCommand.ExecuteScalar().ToString();
MySQL = "Select SUM(金额) From 餐费入账 Where 入住编号='" + this.My入住编号 + "'";
MyCommand = new SqlCommand(MySQL, MyConnection);
this.TextBox4.Text = MyCommand.ExecuteScalar().ToString();
MySQL = "Select SUM(消费数量*折扣价格) From 消费入账 Where 入住编号='" + this.My入住编号 + "'";
MyCommand = new SqlCommand(MySQL, MyConnection);
this.TextBox1.Text = MyCommand.ExecuteScalar().ToString();
MySQL = "Select 折扣价格,入住日期,住宿人数 From 客房入住单 Where 入住编号='" + this.My入住编号 + "'";
DataTable MyNewTable = new DataTable();
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyAdapter.Fill(MyNewTable);
string My折扣价格 = MyNewTable.Rows[0][0].ToString();
DateTime My入住日期 = (DateTime)MyNewTable.Rows[0][1];
int MyYear = Convert.ToInt16(this.TextBox9.Text);
int MyMonth = Convert.ToInt16(this.TextBox10.Text);
int MyDay = Convert.ToInt16(this.TextBox11.Text);
DateTime MyEndDate=new DateTime(MyYear,MyMonth,MyDay);
TimeSpan MySpan = MyEndDate.Subtract(My入住日期);
int My住宿人数 = Convert.ToInt16(MyNewTable.Rows[0][2].ToString());
My住宿费 = Convert.ToDouble(My折扣价格) * Math.Round(MySpan.TotalDays, 0) * My住宿人数;
this.TextBox2.Text = My住宿费.ToString();
if (this.TextBox1.Text.Length > 1)
My店内消费 = Convert.ToDouble(this.TextBox1.Text);
if (this.TextBox3.Text.Length > 1)
My电话费 = Convert.ToDouble(this.TextBox3.Text);
if (this.TextBox4.Text.Length > 1)
My用餐费 = Convert.ToDouble(this.TextBox4.Text);
My费用总额 = My住宿费 + My电话费 + My用餐费 + My店内消费;
this.TextBox6.Text = My费用总额.ToString();
double My补交押金 = My费用总额 - Convert.ToDouble(this.TextBox5.Text);
this.TextBox7.Text = My补交押金.ToString();
MySQL = "Select 入住编号,证件名称,证件号码,入住日期,离开日期 From 客房入住单 Where 入住编号='" + this.My入住编号 + "'";
DataTable MyGuestTable = new DataTable();
SqlDataAdapter MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter.Fill(MyGuestTable);
this.GridView1.DataSource = MyGuestTable;
this.GridView1.DataBind();
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
}
public String MyPrint入住编号
{//设置要传递到打印页的数据
get
{
return this.DropDownList2.SelectedValue.ToString();
}
}
public String MyPrint入住房号
{//设置要传递到打印页的数据
get
{
return this.DropDownList1.SelectedValue.ToString();
}
}
public String MyPrint客人姓名
{//设置要传递到打印页的数据
get
{
return this.DropDownList2.SelectedItem.ToString();
}
}
public String MyPrint累交押金
{//设置要传递到打印页的数据
get
{
return this.TextBox5.Text +"+"+ this.TextBox7.Text;
}
}
public String MyPrint店内消费
{//设置要传递到打印页的数据
get
{
return this.TextBox1.Text;
}
}
public String MyPrint住宿费
{//设置要传递到打印页的数据
get
{
return this.TextBox2.Text;
}
}
public String MyPrint电话费
{//设置要传递到打印页的数据
get
{
return this.TextBox3.Text;
}
}
public String MyPrint用餐费
{//设置要传递到打印页的数据
get
{
return this.TextBox4.Text;
}
}
public String MyPrint费用总额
{//设置要传递到打印页的数据
get
{
return this.TextBox6.Text;
}
}
protected void Button2_Click(object sender, EventArgs e)
{//打印旅客押金补交信息
My累计补交押金 = Convert.ToDouble(this.TextBox5.Text) + Convert.ToDouble(this.TextBox7.Text);
Server.Transfer("~/RoomManage/DepositPrint.aspx");
}
protected void Button3_Click(object sender, EventArgs e)
{//保存旅客押金补交信息
this.My累计补交押金 = Convert.ToInt16(this.TextBox5.Text) + Convert.ToInt16(this.TextBox7.Text);
String MySQLConnectionString =ConfigurationManager.ConnectionStrings["MyHotelDBConnectionString"].ConnectionString;
string MySQL = "Update 客房入住单 Set 预收押金=" + this.My累计补交押金.ToString() + " ,登记说明='" + this.TextBox8.Text + "' WHERE 入住编号='" + this.DropDownList2.SelectedValue.ToString() + "'";
this.My累计补交押金 = 0;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
MyCommand.ExecuteNonQuery();
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
Button1_Click(null, null);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -