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

📄 hsgl.cs

📁 这是本人学习语言来第一次写的程序
💻 CS
📖 第 1 页 / 共 5 页
字号:
			{
				MessageBox.Show(Exc.Message);
				this.oleDbConnection1.Close();
			}
		}

		public void textBox2_Leave(object sender, System.EventArgs e)
		{
			this.labeltssm.Text="";
			this.labeltszz.Text="";
			this.labeltsjg.Text="";

			System.Data.OleDb.OleDbCommand MySelect = this.oleDbConnection1.CreateCommand();
			MySelect.CommandText="SELECT * FROM tsxxb WHERE 编号='"+this.textBox2.Text+"'";
			this.oleDbDataAdapter2.SelectCommand=MySelect;
			this.dataSet21.Clear();

			try
			{
				this.oleDbConnection1.Open();
				int If=this.oleDbDataAdapter2.Fill(this.dataSet21,"tsxxb");
				this.oleDbConnection1.Close();

				if(If==0)
				{
					TS=true;
				}
				else
				{
					TS=false;
					this.labeltssm.Text=dataSet21.Tables["tsxxb"].Rows[0]["书名"].ToString();
					this.labeltszz.Text=dataSet21.Tables["tsxxb"].Rows[0]["作者"].ToString();
					this.labeltsjg.Text=dataSet21.Tables["tsxxb"].Rows[0]["价格"].ToString();
				}
			}
			catch(Exception Exc)
			{
				MessageBox.Show(Exc.Message);
				this.oleDbConnection1.Close();
			}
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void textBox2_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			switch((int)e.KeyCode)
			{
				case 27:
					this.Close();
					break;
				case 13:
					if(this.button1.Focused || this.textBox1.Focused || this.textBox2.Focused)
					{
						button1_Click(null,null);
					}
					if(this.button2.Focused)
					{
						this.Close();
					}
					break;
				case 38:
				case 37:
					if(this.button2.Focused)
					{
						this.button1.Focus();
					}
					else
					{
						if(this.button1.Focused)
						{
							this.textBox2.Focus();
						}
						else
						{
							if(this.textBox2.Focused)
							{
								this.textBox1.Focus();
							}
							else
							{
								if(this.textBox1.Focused)
								{
									this.button2.Focus();
								}
							}
						}
					}
					break;
				case 40:
				case 39:
					if(this.button2.Focused)
					{
						this.textBox1.Focus();
					}
					else
					{
						if(this.textBox1.Focused)
						{
							this.textBox2.Focus();
						}
						else
						{
							if(this.textBox2.Focused)
							{
								this.button1.Focus();
							}
							else
							{
								if(this.button1.Focused)
								{
									this.button2.Focus();
								}
							}
						}
					}
					break;
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			if(DZ)
			{
				MessageBox.Show("该读者不存在,不能还书!!!","还书提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
				this.textBox1.Focus();
			}
			else
			{
				if(TS)
				{
					MessageBox.Show("该图书不存在,不能还书!!!","还书提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
					this.textBox2.Focus();
				}
				else
				{
					try
					{
						System.Data.OleDb.OleDbCommand MySelect=this.oleDbConnection1.CreateCommand();
						MySelect.CommandText="SELECT * FROM jsxxb WHERE 读者编号='"+this.textBox1.Text+"' AND 图书编号='"+this.textBox2.Text+"'";
						this.oleDbDataAdapter3.SelectCommand=MySelect;
						this.dataSet21.Clear();

						this.oleDbConnection1.Open();
						int R=this.oleDbDataAdapter3.Fill(dataSet21,"jsxxb");
						this.oleDbConnection1.Close();

						if(R==0)
						{
							MessageBox.Show("该读者没有借这本书,无法完成还书操作!","还书提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
						}
						else
						{
							string BH=dataSet21.Tables["jsxxb"].Rows[0]["编号"].ToString();

							System.Data.OleDb.OleDbCommand MyDel=this.oleDbConnection1.CreateCommand();
							System.Data.OleDb.OleDbCommand MyUpdate = this.oleDbConnection1.CreateCommand();

							MyUpdate.CommandText="UPDATE tsxxb SET 在库数=在库数+1 WHERE 编号='"+this.textBox2.Text+"'";
							MyDel.CommandText="DELETE * FROM jsxxb WHERE 编号=" + BH;

							this.oleDbDataAdapter3.DeleteCommand=MyDel;
							this.oleDbDataAdapter2.UpdateCommand=MyUpdate;

							this.oleDbConnection1.Open();
							MyDel.ExecuteNonQuery();
							MyUpdate.ExecuteNonQuery();
							this.oleDbConnection1.Close();


							MessageBox.Show("该读者还书成功!","还书提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);
                            this.textBox2.Focus();
						}
					}
					catch(Exception Exc)
					{
						MessageBox.Show(Exc.Message);
						this.oleDbConnection1.Close();
					}
					JSXX();
				}
			}
		}

		public void SetForm1(Form1 v)
		{
			this.F=v;
		}

		private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if(e.KeyChar==63)
				textBox2_DoubleClick(null,null);
		}

		private void textBox2_DoubleClick(object sender, System.EventArgs e)
		{
			smcx3 MySmcx=new smcx3();
			MySmcx.MdiParent=F;
			MySmcx.CXBH(this);
			MySmcx.Show();
		}
	}
}

⌨️ 快捷键说明

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