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

📄 fjxx.cs

📁 c#语音酒店管理的毕业设计 适合于初级水平的学习
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 中小型酒店管理信息系统
{
	/// <summary>
	/// kfxg 的摘要说明。
	/// </summary>
	public class fjxx : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ToolBarButton tbarBtnSave;
		private System.Windows.Forms.ToolBarButton tbarBtnDelete;
		private System.Windows.Forms.DataGrid dgrd_StockerData;
		private System.ComponentModel.IContainer components;
		private DataSet ds = new DataSet();
		private DataSet ds1 = new DataSet();
		private LinkDataBase link  = new LinkDataBase();
		private LinkDataBase link1 = new LinkDataBase();
		public fjxx()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
			string sendTableName = "jud_kfxx";
			string sendStrSQL ="select fjh as '房间编号',lxbh as '类型编号',ft as '使用状态',pz as '配置',sypz as '使用配置',yysj as '营业时间',bz as '备注' from jud_kfxx ";			
			
			ds1 = link1.SelectDataBase(sendStrSQL,sendTableName);
			this.dgrd_StockerData.DataSource = ds1;
			this.dgrd_StockerData.DataMember = "jud_kfxx";
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(fjxx));
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.tbarBtnSave = new System.Windows.Forms.ToolBarButton();
			this.tbarBtnDelete = new System.Windows.Forms.ToolBarButton();
			this.dgrd_StockerData = new System.Windows.Forms.DataGrid();
			((System.ComponentModel.ISupportInitialize)(this.dgrd_StockerData)).BeginInit();
			this.SuspendLayout();
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// toolBar1
			// 
			this.toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.tbarBtnSave,
																						this.tbarBtnDelete});
			this.toolBar1.DropDownArrows = true;
			this.toolBar1.ImageList = this.imageList1;
			this.toolBar1.Location = new System.Drawing.Point(0, 0);
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.ShowToolTips = true;
			this.toolBar1.Size = new System.Drawing.Size(720, 29);
			this.toolBar1.TabIndex = 7;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// tbarBtnSave
			// 
			this.tbarBtnSave.ImageIndex = 0;
			this.tbarBtnSave.ToolTipText = "保存修改";
			// 
			// tbarBtnDelete
			// 
			this.tbarBtnDelete.ImageIndex = 1;
			this.tbarBtnDelete.ToolTipText = "删除数据";
			// 
			// dgrd_StockerData
			// 
			this.dgrd_StockerData.AlternatingBackColor = System.Drawing.Color.GhostWhite;
			this.dgrd_StockerData.BackColor = System.Drawing.Color.GhostWhite;
			this.dgrd_StockerData.BackgroundColor = System.Drawing.Color.Lavender;
			this.dgrd_StockerData.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.dgrd_StockerData.CaptionBackColor = System.Drawing.Color.RoyalBlue;
			this.dgrd_StockerData.CaptionForeColor = System.Drawing.Color.White;
			this.dgrd_StockerData.DataMember = "";
			this.dgrd_StockerData.FlatMode = true;
			this.dgrd_StockerData.Font = new System.Drawing.Font("Tahoma", 8F);
			this.dgrd_StockerData.ForeColor = System.Drawing.Color.MidnightBlue;
			this.dgrd_StockerData.GridLineColor = System.Drawing.Color.RoyalBlue;
			this.dgrd_StockerData.HeaderBackColor = System.Drawing.Color.MidnightBlue;
			this.dgrd_StockerData.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dgrd_StockerData.HeaderForeColor = System.Drawing.Color.Lavender;
			this.dgrd_StockerData.LinkColor = System.Drawing.Color.Teal;
			this.dgrd_StockerData.Location = new System.Drawing.Point(16, 40);
			this.dgrd_StockerData.Name = "dgrd_StockerData";
			this.dgrd_StockerData.ParentRowsBackColor = System.Drawing.Color.Lavender;
			this.dgrd_StockerData.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
			this.dgrd_StockerData.SelectionBackColor = System.Drawing.Color.Teal;
			this.dgrd_StockerData.SelectionForeColor = System.Drawing.Color.PaleGreen;
			this.dgrd_StockerData.Size = new System.Drawing.Size(688, 352);
			this.dgrd_StockerData.TabIndex = 30;
			// 
			// fjxx
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(720, 421);
			this.Controls.Add(this.dgrd_StockerData);
			this.Controls.Add(this.toolBar1);
			this.Name = "fjxx";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "【房间信息】";
			((System.ComponentModel.ISupportInitialize)(this.dgrd_StockerData)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			
			string sendTableName="jud_kfxx";
			if (e.Button.ToolTipText == "保存修改")
			{
				try
				{
					
					int row = this.dgrd_StockerData.CurrentCell.RowNumber;
					//将当前所在行往下移动一行,为便于实现同步保存
					//(否则会出现修改的最后一行无法保存,因为它还处于编辑状态)
					this.dgrd_StockerData.CurrentCell = new DataGridCell(row+1,0); 
					if (this.ds1.HasChanges())
					{
						this.link1.UpdateDataBase(this.ds1.GetChanges(),sendTableName);

						MessageBox.Show("数据修改成功!","信息");
						
						string tempStrSQL ="select fjh as '房间编号',lxbh as '类型编号',ft as '使用状态',pz as '配置',sypz as '使用配置',yysj as '营业时间',bz as '备注' from jud_kfxx ";			
			
						this.link1.SelectDataBase(tempStrSQL,sendTableName);
						
					
					}
					else
					{
						MessageBox.Show("没有修改的数据!");
						return;
					}

				}
				catch(Exception ex)
				{
					MessageBox.Show("数据保存失败,请确认所有信息输入完整且正确!"+ex,"提示");
					return;
				}
			}

			if (e.Button.ToolTipText == "删除数据")
			{
				if (MessageBox.Show("确实要删除这条记录吗?","询问",MessageBoxButtons.YesNo) == DialogResult.Yes)
				{
					int intRowNumber = this.dgrd_StockerData.CurrentCell.RowNumber;
					try
					{
						DataRow workrow=this.ds1.Tables[0].Rows[intRowNumber];
						string fjh = workrow[2].ToString();
						this.ds1.Tables[0].Rows[intRowNumber].Delete();
						this.link1.UpdateDataBase(this.ds1.GetChanges(),sendTableName);
						MessageBox.Show("数据删除成功!","信息");
						string tempStrSQL ="select fjh as '房间编号',lxbh as '类型编号',ft as '使用状态',pz as '配置',sypz as '使用配置',yysj as '营业时间',bz as '备注' from jud_kfxx ";			
			
						this.link1.SelectDataBase(tempStrSQL,sendTableName);
						
					
					}
					catch(Exception ex)
					{
						MessageBox.Show("该数据不能删除!"+ex,"提示");
						string tempStrSQL ="select fjh as '房间编号',lxbh as '类型编号',ft as '使用状态',pz as '配置',sypz as '使用配置',yysj as '营业时间',bz as '备注' from jud_kfxx ";			
			
						this.link1.SelectDataBase(tempStrSQL,sendTableName);
						return;
					}
				}
			}
		}

	}
}

⌨️ 快捷键说明

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