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

📄 dzzc.cs

📁 这是本人学习语言来第一次写的程序
💻 CS
📖 第 1 页 / 共 3 页
字号:

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

		private void button2_Click(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.textBox1.Focus();
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			try
			{
				System.Data.OleDb.OleDbCommand MySelect = this.oleDbConnection1.CreateCommand();
				MySelect.CommandText="SELECT * FROM dzxxb WHERE 编号='"+this.textBox1.Text+"'";
				this.oleDbDataAdapter1.SelectCommand=MySelect;

				if(this.textBox1.Text=="")
				{
					MessageBox.Show("编号不能为空,请输入编号!","输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
					this.textBox1.Focus();
				}
				else
				{
					if(this.textBox2.Text=="")
					{
						MessageBox.Show("姓名不能为空,请输入姓名!","输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
						this.textBox2.Focus();
					}
					else
					{
						this.oleDbConnection1.Open();
						int If=this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");
						this.oleDbConnection1.Close();
						if(If!=0)
						{
							MessageBox.Show("该编号已经存在,请输入另外编号!","输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
							this.textBox1.Focus();
						}
						else
						{
							string xb;
							if(this.radioButton1.Checked)
								xb="男";
							else
								xb="女";

							System.Data.OleDb.OleDbCommand MyInsert = this.oleDbConnection1.CreateCommand();
							MyInsert.CommandText="INSERT INTO dzxxb (编号,姓名,性别,单位,手机,电子邮箱,ICQ,OICQ) VALUES ('"+this.textBox1.Text+"','"+this.textBox2.Text+"','"+xb+"','"+this.textBox3.Text+"','"+this.textBox4.Text+"','"+this.textBox5.Text+"','"+this.textBox6.Text+"','"+this.textBox7.Text+"')";
							this.oleDbDataAdapter1.InsertCommand=MyInsert;
							this.oleDbConnection1.Open();
							MyInsert.ExecuteNonQuery();
							this.oleDbConnection1.Close();

							MessageBox.Show("读者注册成功!!!","员工添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
							this.textBox1.Text="";
							this.textBox2.Text="";
							this.textBox3.Text="";
							this.textBox4.Text="";
							this.textBox5.Text="";
							this.textBox6.Text="";
							this.textBox7.Text="";
							this.textBox1.Focus();
						}
					}
				}
			}
			catch(Exception Exc)
			{
				MessageBox.Show(Exc.Message);
				this.oleDbConnection1.Close();
			}
		}

		private void textBox3_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			switch((int)e.KeyCode)
			{
				case 27:
					this.Close();
					break;
				case 13:
					if(this.button2.Focused)
					{
						button2_Click(null,null);
					}
					else
					{
						if(this.button3.Focused)
						{
							this.Close();
						}
						else
						{
							this.button1_Click(null,null);
						}
					}
					break;
				case 38:
				case 37:
					if(this.textBox7.Focused)
					{
						this.textBox6.Focus();
					}
					else
					{
						if(this.textBox6.Focused)
						{
							this.textBox5.Focus();
						}
						else
						{
							if(this.textBox5.Focused)
							{
								this.textBox4.Focus();
							}
							else
							{
								if(this.textBox4.Focused)
								{
									this.textBox3.Focus();
								}
								else
								{
									if(this.textBox3.Focused)
									{
										this.textBox2.Focus();
									}
									else
									{
										if(this.textBox2.Focused)
										{
											this.textBox1.Focus();
										}
										else
										{
											if(this.textBox1.Focused)
											{
												this.textBox7.Focus();
											}
										}
									}
								}
							}
						}
					}
					break;
				case 40:
				case 39:
					if(this.textBox1.Focused)
					{
						this.textBox2.Focus();
					}
					else
					{
						if(this.textBox2.Focused)
						{
							this.textBox3.Focus();
						}
						else
						{
							if(this.textBox3.Focused)
							{
								this.textBox4.Focus();
							}
							else
							{
								if(this.textBox4.Focused)
								{
									this.textBox5.Focus();
								}
								else
								{
									if(this.textBox5.Focused)
									{
										this.textBox6.Focus();
									}
									else
									{
										if(this.textBox6.Focused)
										{
											this.textBox7.Focus();
										}
										else
										{
											if(this.textBox7.Focused)
											{
												this.textBox1.Focus();
											}
										}
									}
								}
							}
						}
					}
					break;
			}
		}

		private void textBox4_TextChanged(object sender, System.EventArgs e)
		{
			string s="";
			for(int i=0;i<textBox4.Text.Length;i++)
				if(Char.IsDigit(textBox4.Text[i])==true)
					s=s+textBox4.Text[i].ToString();
			textBox4.Text=s;
			textBox4.SelectionStart=textBox4.Text.Length;
		}

		private void textBox6_TextChanged(object sender, System.EventArgs e)
		{
			string s="";
			for(int i=0;i<textBox6.Text.Length;i++)
				if(Char.IsDigit(textBox6.Text[i])==true)
					s=s+textBox6.Text[i].ToString();
			textBox6.Text=s;
			textBox6.SelectionStart=textBox6.Text.Length;
		}

		private void textBox7_TextChanged(object sender, System.EventArgs e)
		{
			string s="";
			for(int i=0;i<textBox7.Text.Length;i++)
				if(Char.IsDigit(textBox7.Text[i])==true)
					s=s+textBox7.Text[i].ToString();
			textBox7.Text=s;
			textBox7.SelectionStart=textBox7.Text.Length;
		}
	}
}

⌨️ 快捷键说明

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