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

📄 ydcx.cs

📁 c#语音酒店管理的毕业设计 适合于初级水平的学习
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 中小型酒店管理信息系统
{
	/// <summary>
	/// ydcx 的摘要说明。
	/// </summary>
	public class ydcx : 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.Windows.Forms.Label label1;
		private System.Windows.Forms.DateTimePicker dateTimePicker1;
		private System.Windows.Forms.DateTimePicker dateTimePicker2;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.CheckBox checkBox1;
		private System.Windows.Forms.Button button1;
		private System.ComponentModel.IContainer components;
        private bool yue=false;
		private DataSet ds = new DataSet();
		private DataSet ds1 = new DataSet();
		private LinkDataBase link = new LinkDataBase();	
		private LinkDataBase link1 = new LinkDataBase();	
		public ydcx()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
			string sendTableName = "jud_rymx";
			
			string sendStrSQL ="select ryxm from jud_rymx ";
			this.ds = this.link.SelectDataBase(sendStrSQL,sendTableName);
			comboBox1.DataSource = ds.Tables[sendTableName];
			comboBox1.DisplayMember = "ryxm";

		}

		/// <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(ydcx));
			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();
			this.label1 = new System.Windows.Forms.Label();
			this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
			this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker();
			this.label2 = new System.Windows.Forms.Label();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.checkBox1 = new System.Windows.Forms.CheckBox();
			this.button1 = new System.Windows.Forms.Button();
			((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 = 6;
			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, 142);
			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, 266);
			this.dgrd_StockerData.TabIndex = 29;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(136, 64);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(64, 16);
			this.label1.TabIndex = 30;
			this.label1.Text = "开始日期";
			// 
			// dateTimePicker1
			// 
			this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Short;
			this.dateTimePicker1.Location = new System.Drawing.Point(216, 56);
			this.dateTimePicker1.Name = "dateTimePicker1";
			this.dateTimePicker1.Size = new System.Drawing.Size(88, 21);
			this.dateTimePicker1.TabIndex = 31;
			// 
			// dateTimePicker2
			// 
			this.dateTimePicker2.Format = System.Windows.Forms.DateTimePickerFormat.Short;
			this.dateTimePicker2.Location = new System.Drawing.Point(400, 56);
			this.dateTimePicker2.Name = "dateTimePicker2";
			this.dateTimePicker2.Size = new System.Drawing.Size(96, 21);
			this.dateTimePicker2.TabIndex = 32;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(336, 56);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(56, 16);
			this.label2.TabIndex = 33;
			this.label2.Text = "结束日期";
			// 
			// comboBox1
			// 
			this.comboBox1.Enabled = false;
			this.comboBox1.Location = new System.Drawing.Point(336, 104);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(121, 20);
			this.comboBox1.TabIndex = 35;
			// 
			// checkBox1
			// 
			this.checkBox1.Location = new System.Drawing.Point(152, 104);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.Size = new System.Drawing.Size(128, 24);
			this.checkBox1.TabIndex = 36;
			this.checkBox1.Text = "选择登记服务员";
			this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(496, 104);
			this.button1.Name = "button1";
			this.button1.TabIndex = 37;
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// ydcx
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(720, 421);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.checkBox1);
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.dateTimePicker2);
			this.Controls.Add(this.dateTimePicker1);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.dgrd_StockerData);
			this.Controls.Add(this.toolBar1);
			this.Name = "ydcx";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "【预订查询】";
			this.Load += new System.EventHandler(this.ydcx_Load);
			((System.ComponentModel.ISupportInitialize)(this.dgrd_StockerData)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		

		private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
		{
			if(checkBox1.Checked == true)
			{
				comboBox1.Enabled = true;
				yue = true;
			}
			else
			{
                comboBox1.Enabled=false;
				yue = false;
			}
		}

		private void ydcx_Load(object sender, System.EventArgs e)
		{
		
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			shuju();
		}
		private void shuju()
		{
			string sendTableName = "jud_kfyd";
			string sendStrSQL ="";
			if (yue == false)
			{
				sendStrSQL ="select pzhm as '凭证号码',gzdw as '工作单位',fjh as '房间号',rq as '日期',xm as '姓名',lxdh as '联系电话',ydrq as '预定日期',ydts as '预订天数',yj as '押金',yzrs as '预订人数',bz as '备注',ydfwy as '预定服务员',sj as '时间' from jud_kfyd  where rq>='"+dateTimePicker1.Text+"' and rq<='"+dateTimePicker2.Text+"'";

			}
			else
			{
				sendStrSQL ="select pzhm as '凭证号码',gzdw as '工作单位',fjh as '房间号',rq as '日期',xm as '姓名',lxdh as '联系电话',ydrq as '预定日期',ydts as '预订天数',yj as '押金',yzrs as '预订人数',bz as '备注',ydfwy as '预定服务员',sj as '时间' from jud_kfyd  where rq>='"+dateTimePicker1.Text+"' and rq<='"+dateTimePicker2.Text+"' and ydfwy='"+comboBox1.Text+"'";

			}

			ds1 = link1.SelectDataBase(sendStrSQL,sendTableName);
			this.dgrd_StockerData.DataSource = ds1;
			this.dgrd_StockerData.DataMember = "jud_kfyd";
		}
		private void fangtai(string ft,string fjh)
		{
			//修改房屋状态
			string sendTableName = "jud_kfxx";
			
			string sendStrSQL ="update jud_kfxx set ft='"+ft+"' where fjh='"+fjh+"'";
			this.ds = this.link.SelectDataBase(sendStrSQL,sendTableName);
			

		}
		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			string sendTableName="jud_kfyd";
			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("数据修改成功!","信息");
						shuju();
                      
					}
					else
					{
						MessageBox.Show("没有修改的数据!");
						return;
					}

				}
				catch
				{
					MessageBox.Show("数据保存失败,请确认所有信息输入完整且正确!","提示");
					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("数据删除成功!","信息");
						shuju();
						fangtai("空房",fjh);
						
					}
					catch(Exception ex)
					{
						MessageBox.Show("该数据不能删除!"+ex,"提示");
						shuju();
						return;
					}
				}
			}
		}

	}
}

⌨️ 快捷键说明

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