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

📄 yddj.cs

📁 c#语音酒店管理的毕业设计 适合于初级水平的学习
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.textBox4.Text = "textBox4";
			// 
			// textBox5
			// 
			this.textBox5.Location = new System.Drawing.Point(120, 184);
			this.textBox5.Name = "textBox5";
			this.textBox5.Size = new System.Drawing.Size(72, 21);
			this.textBox5.TabIndex = 24;
			this.textBox5.Text = "textBox5";
			// 
			// textBox6
			// 
			this.textBox6.Location = new System.Drawing.Point(272, 184);
			this.textBox6.Name = "textBox6";
			this.textBox6.Size = new System.Drawing.Size(72, 21);
			this.textBox6.TabIndex = 25;
			this.textBox6.Text = "textBox6";
			// 
			// textBox7
			// 
			this.textBox7.Enabled = false;
			this.textBox7.Location = new System.Drawing.Point(440, 184);
			this.textBox7.Name = "textBox7";
			this.textBox7.Size = new System.Drawing.Size(120, 21);
			this.textBox7.TabIndex = 26;
			this.textBox7.Text = "textBox7";
			// 
			// richTextBox1
			// 
			this.richTextBox1.Location = new System.Drawing.Point(120, 216);
			this.richTextBox1.Name = "richTextBox1";
			this.richTextBox1.Size = new System.Drawing.Size(440, 48);
			this.richTextBox1.TabIndex = 27;
			this.richTextBox1.Text = "richTextBox1";
			// 
			// 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, 272);
			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, 136);
			this.dgrd_StockerData.TabIndex = 28;
			// 
			// label12
			// 
			this.label12.ForeColor = System.Drawing.Color.Brown;
			this.label12.Location = new System.Drawing.Point(520, 64);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(80, 48);
			this.label12.TabIndex = 29;
			this.label12.Text = "注意:显示的房间是房态为空闲的房间号";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(600, 216);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(75, 40);
			this.button1.TabIndex = 30;
			this.button1.Text = "添加记录";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// yddj
			// 
			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.label12);
			this.Controls.Add(this.dgrd_StockerData);
			this.Controls.Add(this.richTextBox1);
			this.Controls.Add(this.textBox7);
			this.Controls.Add(this.textBox6);
			this.Controls.Add(this.textBox5);
			this.Controls.Add(this.textBox4);
			this.Controls.Add(this.textBox3);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.dateTimePicker2);
			this.Controls.Add(this.dateTimePicker1);
			this.Controls.Add(this.listBox1);
			this.Controls.Add(this.label11);
			this.Controls.Add(this.label10);
			this.Controls.Add(this.label9);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.toolBar1);
			this.Name = "yddj";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "【预订登记】";
			this.Load += new System.EventHandler(this.yddj_Load);
			((System.ComponentModel.ISupportInitialize)(this.dgrd_StockerData)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void yddj_Load(object sender, System.EventArgs e)
		{
			this.textBox1.Text=this.textBox2.Text=this.textBox3.Text=this.textBox4.Text=this.textBox5.Text=this.textBox6.Text=this.textBox7.Text=this.richTextBox1.Text="";
			this.textBox4.Text="2";
			this.textBox5.Text="1000";
			this.textBox6.Text="1";
			if (LoginFrm.strUser=="")
			{  this.textBox7.Text="未知";}
			else
			{this.textBox7.Text=LoginFrm.strUser;}
			scfjh();
		}
		private void scfjh() //生成房间号
		{
			string sendTableName = "jud_kfxx";
			string kong="空房";
			string sendStrSQL ="select fjh from jud_kfxx where ft='"+kong+"'";
            this.ds = this.link.SelectDataBase(sendStrSQL,sendTableName);
            listBox1.DataSource = ds.Tables[sendTableName];
			listBox1.DisplayMember = "fjh";
		}
        
		private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
		
			
			
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			if (textBox1.Text=="")
			{
                textBox1.Text="无";
			}
			if (textBox3.Text=="")
			{
				textBox3.Text="无";
			}
			if(textBox2.Text=="")
			{
				MessageBox.Show("姓名不能为空!","提示");

				this.textBox2.Focus();
			}
			else
			{
               
                DateTime dt = DateTime.Now;
				DataTable ordersTable = ds1.Tables["jud_kfyd"];
				DataRow workRow = ds1.Tables["jud_kfyd"].NewRow();
				int yue =dt.Month;
				string yue1;
				if (yue<10)
				{ yue1="0"+yue.ToString();}
				else{yue1=yue.ToString();}
				int day =dt.Day;
				string day1;
				if (day<10)
				{day1="0"+day.ToString();}
				else{day1=day.ToString();}
				int hour=dt.Hour;
				int min=dt.Minute;
				int sec=dt.Second;
				string hour1;
				string min1;
				string sec1;
				if (hour<10)
				{hour1="0"+hour.ToString();}
				else{hour1=hour.ToString();}
				if (min<10)
				{min1="0"+min.ToString();}
				else{min1=min.ToString();}
				if (sec<10)
				{sec1="0"+sec.ToString();}
				else{sec1=sec.ToString();}
				string pz ="YD"+dt.Year.ToString()+yue1+day1+hour1+min1+sec1; 
				workRow[0] = pz;
				workRow[1] = textBox1.Text;
				workRow[2] = listBox1.Text;
                workRow[3] = dateTimePicker1.Text;
                workRow[4] = textBox2.Text;
				workRow[5] = textBox3.Text;
				workRow[6] = dateTimePicker2.Text;
				workRow[7] = textBox4.Text;
				workRow[8] = textBox5.Text;
				workRow[9] = textBox6.Text;
				workRow[10] = richTextBox1.Text;
				workRow[11] = textBox7.Text;
				workRow[12] = hour1+"-"+min1+"-"+sec1;
				
				ds1.Tables["jud_kfyd"].Rows.Add(workRow);
				this.textBox1.Focus();
                textBox1.Text=textBox2.Text=textBox3.Text=richTextBox1.Text="";
				
			}
		}
		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);
			listBox1.DataSource = ds.Tables[sendTableName];
			listBox1.DisplayMember = "fjh";

		}
		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			DateTime dt = DateTime.Now;
			string shijian = dt.Year.ToString()+"-"+dt.Month.ToString()+"-"+dt.Day.ToString();
			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("数据修改成功!","信息");
						
					    string tempStrSQL ="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>='"+shijian+"'";			
                        this.link1.SelectDataBase(tempStrSQL,sendTableName);
						fangtai("预订",listBox1.Text);
						scfjh();
					}
					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("数据删除成功!","信息");
						string tempStrSQL ="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>='"+shijian+"'";
						this.link1.SelectDataBase(tempStrSQL,sendTableName);
						fangtai("空房",fjh);
						scfjh();
					}
					catch(Exception ex)
					{
						MessageBox.Show("该数据不能删除!"+ex,"提示");
						string tempStrSQL ="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>='"+shijian+"'";
			
						this.link1.SelectDataBase(tempStrSQL,sendTableName);
						return;
					}
				}
			}
		}

	}
}

⌨️ 快捷键说明

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