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

📄 frmroominfo.cs

📁 采用C#和SQL Server 2000开发 功能比较全面的酒店管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = @"DELETE FROM 客房信息 WHERE (客房编号 = @Original_客房编号) AND (备注 = @Original_备注 OR @Original_备注 IS NULL AND 备注 IS NULL) AND (客房描述 = @Original_客房描述 OR @Original_客房描述 IS NULL AND 客房描述 IS NULL) AND (床数 = @Original_床数 OR @Original_床数 IS NULL AND 床数 IS NULL) AND (是否可拼房 = @Original_是否可拼房 OR @Original_是否可拼房 IS NULL AND 是否可拼房 IS NULL) AND (楼层编号 = @Original_楼层编号) AND (状态 = @Original_状态 OR @Original_状态 IS NULL AND 状态 IS NULL) AND (类型编号 = @Original_类型编号) AND (额定人数 = @Original_额定人数 OR @Original_额定人数 IS NULL AND 额定人数 IS NULL)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_客房编号", System.Data.SqlDbType.VarChar, 12, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "客房编号", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_备注", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "备注", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_客房描述", System.Data.SqlDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "客房描述", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_床数", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "床数", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_是否可拼房", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "是否可拼房", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_楼层编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "楼层编号", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_状态", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "状态", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_类型编号", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "类型编号", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_额定人数", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "额定人数", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=ACER;packet size=4096;integrated security=SSPI;data source=ACER;pe" +
				"rsist security info=False;initial catalog=hotelbook";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO 客房信息(是否可拼房, 状态, 备注, 客房描述, 床数, 额定人数, 楼层编号, 类型编号, 客房编号) VALUES (@是否可拼房," +
				" @状态, @备注, @客房描述, @床数, @额定人数, @楼层编号, @类型编号, @客房编号); SELECT 是否可拼房, 状态, 备注, 客房描述, " +
				"床数, 额定人数, 楼层编号, 类型编号, 客房编号 FROM 客房信息 WHERE (客房编号 = @客房编号)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@是否可拼房", System.Data.SqlDbType.Bit, 1, "是否可拼房"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@状态", System.Data.SqlDbType.VarChar, 4, "状态"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 100, "备注"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@客房描述", System.Data.SqlDbType.VarChar, 40, "客房描述"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@床数", System.Data.SqlDbType.Int, 4, "床数"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@额定人数", System.Data.SqlDbType.Int, 4, "额定人数"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@楼层编号", System.Data.SqlDbType.Int, 4, "楼层编号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@类型编号", System.Data.SqlDbType.VarChar, 4, "类型编号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@客房编号", System.Data.SqlDbType.VarChar, 12, "客房编号"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 是否可拼房, 状态, 备注, 客房描述, 床数, 额定人数, 楼层编号, 类型编号, 客房编号 FROM 客房信息";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE 客房信息 SET 是否可拼房 = @是否可拼房, 状态 = @状态, 备注 = @备注, 客房描述 = @客房描述, 床数 = @床数, 额定人数 = @额定人数, 楼层编号 = @楼层编号, 类型编号 = @类型编号, 客房编号 = @客房编号 WHERE (客房编号 = @Original_客房编号) AND (备注 = @Original_备注 OR @Original_备注 IS NULL AND 备注 IS NULL) AND (客房描述 = @Original_客房描述 OR @Original_客房描述 IS NULL AND 客房描述 IS NULL) AND (床数 = @Original_床数 OR @Original_床数 IS NULL AND 床数 IS NULL) AND (是否可拼房 = @Original_是否可拼房 OR @Original_是否可拼房 IS NULL AND 是否可拼房 IS NULL) AND (楼层编号 = @Original_楼层编号) AND (状态 = @Original_状态 OR @Original_状态 IS NULL AND 状态 IS NULL) AND (类型编号 = @Original_类型编号) AND (额定人数 = @Original_额定人数 OR @Original_额定人数 IS NULL AND 额定人数 IS NULL); SELECT 是否可拼房, 状态, 备注, 客房描述, 床数, 额定人数, 楼层编号, 类型编号, 客房编号 FROM 客房信息 WHERE (客房编号 = @客房编号)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@是否可拼房", System.Data.SqlDbType.Bit, 1, "是否可拼房"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@状态", System.Data.SqlDbType.VarChar, 4, "状态"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 100, "备注"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@客房描述", System.Data.SqlDbType.VarChar, 40, "客房描述"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@床数", System.Data.SqlDbType.Int, 4, "床数"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@额定人数", System.Data.SqlDbType.Int, 4, "额定人数"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@楼层编号", System.Data.SqlDbType.Int, 4, "楼层编号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@类型编号", System.Data.SqlDbType.VarChar, 4, "类型编号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@客房编号", System.Data.SqlDbType.VarChar, 12, "客房编号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_客房编号", System.Data.SqlDbType.VarChar, 12, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "客房编号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_备注", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "备注", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_客房描述", System.Data.SqlDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "客房描述", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_床数", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "床数", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_是否可拼房", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "是否可拼房", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_楼层编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "楼层编号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_状态", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "状态", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_类型编号", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "类型编号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_额定人数", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "额定人数", System.Data.DataRowVersion.Original, null));
			// 
			// frmRoomInfo
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(512, 326);
			this.Controls.Add(this.GroupBox1);
			this.Name = "frmRoomInfo";
			this.Controls.SetChildIndex(this.dgdList, 0);
			this.Controls.SetChildIndex(this.GroupBox1, 0);
			((System.ComponentModel.ISupportInitialize)(this.dgdList)).EndInit();
			this.GroupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
			this.ResumeLayout(false);

		}		#endregion		public override void Prepare()
		{
			this.Text = "客房信息设置";
			Label1.Text = "客房编号";
			Label2.Text = "类型编号";
			Label3.Text = "楼层编号";
			DataBase db = new DataBase();
			DataView dv = db.RunSelectSQL("select 类型编号,类型名称 from 客房类型");
			cbbTypeCode.DataSource = dv;
			cbbTypeCode.DisplayMember = "类型名称";
			cbbTypeCode.ValueMember = "类型编号";
			dv = db.RunSelectSQL("select 楼层编号,楼层名称 from 楼层信息");
			cbbFloorCode.DataSource = dv;
			cbbFloorCode.DisplayMember = "楼层名称";
			cbbFloorCode.ValueMember = "楼层编号";
			db.Dispose();
		}
		public override void LoadData()
		{
			string strFilter;
			if ( txbOne.Text.Trim().Length == 0 )
			{
				if ( txbTwo.Text.Trim().Length == 0 )
				{
					if ( txbThree.Text.Trim().Length == 0 )
					{
						strFilter = "";
					}
					else
					{
						strFilter = "where 楼层编号 like '";
						strFilter += txbThree.Text.Trim() + "%'";
					}
				}
				else
				{
					strFilter = "where 类型编号 like '";
					strFilter += txbTwo.Text.Trim() + "%'";
					if ( txbThree.Text.Trim().Length != 0 )
					{
						strFilter += " and 楼层编号 like '";
						strFilter += txbThree.Text.Trim() + "%'";
					}
				}
			}
			strFilter = "where 客房编号 like '";
            strFilter += txbOne.Text.Trim() + "%'";
			if ( txbTwo.Text.Trim().Length != 0 )
			{
				strFilter += " and 类型编号 like '";
				strFilter += txbTwo.Text.Trim() + "%'";
				if ( txbThree.Text.Trim().Length != 0 )
				{
					strFilter += " and 楼层编号 like '";
					strFilter += txbThree.Text.Trim() + "%'";
				}
			}
			else
			{
				if ( txbThree.Text.Trim().Length != 0 )
				{
					strFilter += " and 楼层编号 like '";
                    strFilter += txbThree.Text.Trim() + "%'";
				}
			}
			// 清空dataSet11
			dataSet11.Clear();
			sqlConnection1.ConnectionString = DataBase.sConn;
			// string strSQL;
			sqlDataAdapter1.Fill( dataSet11 );
			dtData = dataSet11.Tables[ "客房信息" ];
			bmData = this.BindingContext[ dataSet11, "客房信息" ];
			if ( bmData.Count != 0 )
				bmData.Position = 0;
		}		public override void SetDataGrid()
		{
			LoadData();
			// 定义一个DataGrid表样式
			DataGridTableStyle ts = new DataGridTableStyle();
			DataGridTextBoxColumn aCol;
			int numCols = dtData.Columns.Count;
			for ( int i = 0; i < numCols; i ++ )
			{
				aCol = new DataGridTextBoxColumn();
				aCol.MappingName = dtData.Columns[ i ].ColumnName;
				aCol.HeaderText = dtData.Columns[ i ].ColumnName;
				aCol.NullText = "";
				aCol.ReadOnly = true;
				ts.GridColumnStyles.Add( aCol );
			}
			ts.AlternatingBackColor = Color.LightGray;
			ts.AllowSorting = false;
			ts.MappingName = dtData.TableName;
			dgdList.TableStyles .Clear();
			dgdList.TableStyles.Add( ts );
			DataView dv = dtData.DefaultView;
			dv.AllowNew = false;
			dv.AllowDelete = false;
			// dv.AllowEdit = false;
			// 设置数据源
			dgdList.DataSource = dv;
			bmData = this.BindingContext[ dataSet11, "客房信息" ];
			lblCount.Text = "记录数:" + dtData.Rows.Count.ToString();
		}
		public override void SetTextBoxState(bool bState)
		{
			GroupBox1.Enabled = !bState;
		}

		public override void Clear()
		{
			txbRoomCode.Text = "";
			cbbTypeCode.Text = "";
			cbbFloorCode.Text = "";
			txbRemark.Text = "";
			txbState.Text = "空房";
			txbState.ReadOnly = true;
			txbNumber.Text = "";
			txbDescribe.Text = "";
			txbBed.Text = "";
			ckbPin.Checked = true;
		}

		public override void SaveForAdd()
		{
			DataRow dr = dataSet11.Tables[ "客房信息" ].NewRow();
			try
			{
				dr[ "客房编号" ] = txbRoomCode.Text.Trim();
				dr[ "类型编号" ] = cbbTypeCode.SelectedValue.ToString().Trim();
				dr[ "楼层编号" ] = cbbFloorCode.SelectedValue.ToString().Trim();
				dr[ "额定人数" ] = txbNumber.Text.Trim();
				dr[ "床数" ] = txbBed.Text.Trim();
				dr[ "客房描述" ] = txbDescribe.Text.Trim();
				dr[ "状态" ] = txbState.Text.Trim();
				dr[ "备注" ] = txbRemark.Text.Trim();
				dr[ "是否可拼房" ] = ckbPin.Checked;
			}
			catch( Exception ex )
			{
				MessageBox.Show( "数据格式不正确!" + ex.ToString() );
				return;
			}
			try
			{
				dataSet11.Tables[ "客房信息" ].Rows.Add( dr );
				if ( dataSet11.HasChanges() )
				{
					sqlDataAdapter1.Update( dataSet11 );
				}
			}
			catch ( Exception ex )
			{
				MessageBox.Show( "数据添加失败!" + ex.ToString() );
			}
			LoadData();
			dgdList.DataSource = dtData.DefaultView;
		}		public override void DeleteData()
		{
			try
			{
				// 删除当前行的数据
				dataSet11.Tables[ "客房信息" ].Rows[ bmData.Position ].Delete();
				if ( dataSet11.HasChanges() )
				{
					// 更新dataSet11
					sqlDataAdapter1.Update( dataSet11 );
				}
			}
			catch ( Exception ex )
			{
				MessageBox.Show( "数据删除失败!" + ex.ToString() );
			}
		}
		public override void SaveForUpdate()
		{
			/*Try
			Dim row As Integer
			row = dgdList.CurrentCell.RowNumber
			dgdList.CurrentCell = _
			New DataGridCell((row + 1) Mod bmData.Count, 0)
			'判断是否有更新的数据
			If Me.DataSet11.HasChanges = True Then
				SqlDataAdapter1.Update(DataSet11)
			End If
		Catch ex As Exception
			MessageBox.Show("数据修改失败!")
		End Try */
			try
			{
				int row = dgdList.CurrentCell.RowNumber;
				dgdList.CurrentCell = new DataGridCell( ( row + 1 ) % bmData.Count, 0 );
				// 判断是否有更新的数据
				if ( dataSet11.HasChanges() )
				{
					sqlDataAdapter1.Update( dataSet11 );
				}
			}
			catch ( Exception ex )
			{
				MessageBox.Show( "数据修改失败!" + ex.ToString() );
			}
		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -