⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hotelleave.cs

📁 酒店管理系统采用C#和SQL Server 数据库实现 适合一般小酒店的管理
💻 CS
📖 第 1 页 / 共 2 页
字号:
			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 + -