?? hotelleave.cs
字號:
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=localhost;Integrated Security=SSPI;Database=hotelbook;";
//
// da2
//
this.da2.SelectCommand = this.sqlSelectCommand2;
this.da2.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "帳單明細", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("帳單編號", "帳單編號"),
new System.Data.Common.DataColumnMapping("入住單號", "入住單號"),
new System.Data.Common.DataColumnMapping("消費內容", "消費內容"),
new System.Data.Common.DataColumnMapping("消費金額", "消費金額"),
new System.Data.Common.DataColumnMapping("消費時間", "消費時間"),
new System.Data.Common.DataColumnMapping("備注", "備注")})});
//
// sqlSelectCommand2
//
this.sqlSelectCommand2.CommandText = "SELECT 帳單編號, 入住單號, 消費內容, 消費金額, 消費時間, 備注 FROM 帳單明細";
this.sqlSelectCommand2.Connection = this.sqlConnection1;
//
// btnCal
//
this.btnCal.Location = new System.Drawing.Point(56, 32);
this.btnCal.Name = "btnCal";
this.btnCal.Size = new System.Drawing.Size(112, 23);
this.btnCal.TabIndex = 0;
this.btnCal.Text = "計算應收款";
this.btnCal.Click += new System.EventHandler(this.btnCal_Click);
//
// btnLeave
//
this.btnLeave.Location = new System.Drawing.Point(464, 32);
this.btnLeave.Name = "btnLeave";
this.btnLeave.Size = new System.Drawing.Size(128, 23);
this.btnLeave.TabIndex = 0;
this.btnLeave.Text = "收銀結帳退房";
this.btnLeave.Click += new System.EventHandler(this.btnLeave_Click);
//
// txt4
//
this.txt4.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "入住單.應收帳款"));
this.txt4.Location = new System.Drawing.Point(192, 32);
this.txt4.Name = "txt4";
this.txt4.TabIndex = 1;
this.txt4.Text = "";
//
// cmb1
//
this.cmb1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "入住單.付款方式"));
this.cmb1.Items.AddRange(new object[] {
"現金",
"支票",
"信用卡",
"代金券",
"其他"});
this.cmb1.Location = new System.Drawing.Point(312, 32);
this.cmb1.Name = "cmb1";
this.cmb1.Size = new System.Drawing.Size(121, 20);
this.cmb1.TabIndex = 2;
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 入住單號, 預定單號, 會員編號, 抵店時間, 離店時間, 客房編號, 客房價格, 入住價格, 是否加床, 加床價格, 預收款, 早餐, 叫醒, 保" +
"密, vip, 電話等級, 特要說明, 應收帳款, 是否結帳, 結帳金額, 結帳日期, 付款方式, 入住人數 FROM 入住單 WHERE (入住單號 LIKE" +
" @Param17) AND (客房編號 LIKE @Param18)";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param17", System.Data.SqlDbType.VarChar, 36, "入住單號"));
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param18", System.Data.SqlDbType.VarChar, 12, "客房編號"));
//
// label4
//
this.label4.Location = new System.Drawing.Point(192, 17);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 15);
this.label4.TabIndex = 3;
this.label4.Text = "應付款";
//
// label5
//
this.label5.Location = new System.Drawing.Point(312, 16);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(56, 15);
this.label5.TabIndex = 3;
this.label5.Text = "支付方式";
//
// HotelLeave
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(728, 502);
this.Controls.Add(this.dataGrid2);
this.Name = "HotelLeave";
this.Text = "收銀結帳";
this.Load += new System.EventHandler(this.HotelLeave_Load);
this.Controls.SetChildIndex(this.dataGrid2, 0);
this.Controls.SetChildIndex(this.groupBox1, 0);
this.Controls.SetChildIndex(this.toolBar1, 0);
this.Controls.SetChildIndex(this.dataGrid1, 0);
this.Controls.SetChildIndex(this.groupBox2, 0);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
this.ResumeLayout(false);
} #endregion
//----------生成窗體時讀入數據-----------
private void HotelLeave_Load(object sender, System.EventArgs e)
{
da1.SelectCommand.Parameters[0].Value="%";
da1.SelectCommand.Parameters[1].Value="%";
da1.Fill(this.dataSet11);
da2.Fill(dataSet11);
if(dataSet11.入住單.Rows.Count!=0)//讀入第一個入住單的帳單明細
dataView1.RowFilter="入住單號='"+dataSet11.入住單.Rows[0]["入住單號"].ToString()+"'";
base.dataSet11=this.dataSet11;
cmOrders=(CurrencyManager) BindingContext[this.dataSet11,"入住單"];
}
//---------顯示帳單明細-------
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
//根據當前行的入住單號,檢索入住單帳單明細
int i=dataGrid1.CurrentRowIndex;
dataView1.RowFilter="入住單號='"+dataGrid1[i,0].ToString()+"'";
}
//-----------根據輸入,檢索信息---------
private void btnSearch_Click(object sender, System.EventArgs e)
{
da1.SelectCommand.Parameters[0].Value="%";
da1.SelectCommand.Parameters[1].Value="%";
if(txt1.Text.Trim()!="")
{
da1.SelectCommand.Parameters[0].Value="%"+txt1.Text.Trim()+"%";
}
if(txt2.Text.Trim()!="")
{
da1.SelectCommand.Parameters[1].Value="%"+txt2.Text.Trim()+"%";
}
dataSet11.Clear();//刷新數據集
da1.Fill(dataSet11);
da2.Fill(dataSet11);
if(dataSet11.入住單.Rows.Count==0)//如果沒有查到數據,則不顯示帳單明細
dataView1.RowFilter="入住單號=''";
else//如果查到了數據,則顯示明細
dataView1.RowFilter="入住單號='"+dataSet11.入住單.Rows[0]["入住單號"].ToString()+"'";
}
//-------------計算應付房款---------------
private void btnCal_Click(object sender, System.EventArgs e)
{
string strConn="workstation id=localhost;Integrated Security=SSPI;Database=hotelbook;";
SqlConnection cn=new SqlConnection(strConn);
cn.Open();
SqlCommand cmd=cn.CreateCommand();
int i=dataGrid1.CurrentRowIndex;
cmd.CommandText="exec sf_計算應收帳款 '"+dataGrid1[i,0].ToString()+"'";
cmd.ExecuteNonQuery();
dataSet11.Clear();//刷新數據集
da1.Fill(dataSet11);
da2.Fill(dataSet11);
cmOrders.Position = i;//移動到剛才所選的行上
this.dataGrid1.Select(cmOrders.Position); //選中當前行
this.dataGrid1.CurrentRowIndex = cmOrders.Position; //移動表頭指示圖標
cmb1.Text="現金";//默認付款方式
}
//------------收銀結帳退房---------------
private void btnLeave_Click(object sender, System.EventArgs e)
{
if(cmb1.Text.Trim()=="")//檢查支付方式的選取
{
MessageBox.Show("請選擇支付方式");
return;
}
string strConn="workstation id=localhost;Integrated Security=SSPI;Database=hotelbook;";
SqlConnection cn=new SqlConnection(strConn);
cn.Open();
SqlCommand cmd=cn.CreateCommand();
int i=dataGrid1.CurrentRowIndex;
cmd.CommandText="exec sf_收銀退房 '"+dataGrid1[i,0].ToString()+"','"+cmb1.Text.Trim()+"'";
cmd.ExecuteNonQuery();
dataSet11.Clear();//刷新數據集
da1.Fill(dataSet11);
da2.Fill(dataSet11);
}
}}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -