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

📄 dzzx.cs

📁 这是本人学习语言来第一次写的程序
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// 
			this.oleDbDeleteCommand1.CommandText = @"DELETE FROM dzxxb WHERE (编号 = ?) AND (ICQ = ? OR ? IS NULL AND ICQ IS NULL) AND (OICQ = ? OR ? IS NULL AND OICQ IS NULL) AND (单位 = ? OR ? IS NULL AND 单位 IS NULL) AND (姓名 = ?) AND (性别 = ?) AND (手机 = ? OR ? IS NULL AND 手机 IS NULL) AND (电子邮箱 = ? OR ? IS NULL AND 电子邮箱 IS NULL)";
			this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_编号", System.Data.OleDb.OleDbType.VarWChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "编号", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ICQ", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ICQ", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ICQ1", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ICQ", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_OICQ", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "OICQ", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_OICQ1", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "OICQ", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_单位", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_单位1", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_姓名", System.Data.OleDb.OleDbType.VarWChar, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_性别", System.Data.OleDb.OleDbType.VarWChar, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性别", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_手机", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "手机", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_手机1", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "手机", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_电子邮箱", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "电子邮箱", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_电子邮箱1", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "电子邮箱", System.Data.DataRowVersion.Original, null));
			// 
			// oleDbConnection1
			// 
			this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Registry Path=;Data Source="".\tsglxt.mdb"";Jet OLEDB:System database=;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=Admin;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:Database Locking Mode=1;Jet OLEDB:SFP=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:Global Partial Bulk Ops=2;Mode=Share Deny None;Extended Properties=;Jet OLEDB:Engine Type=5";
			// 
			// oleDbInsertCommand1
			// 
			this.oleDbInsertCommand1.CommandText = "INSERT INTO dzxxb(ICQ, OICQ, 编号, 单位, 电子邮箱, 手机, 姓名, 性别) VALUES (?, ?, ?, ?, ?, ?, " +
				"?, ?)";
			this.oleDbInsertCommand1.Connection = this.oleDbConnection1;
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ICQ", System.Data.OleDb.OleDbType.VarWChar, 20, "ICQ"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("OICQ", System.Data.OleDb.OleDbType.VarWChar, 20, "OICQ"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("编号", System.Data.OleDb.OleDbType.VarWChar, 10, "编号"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("单位", System.Data.OleDb.OleDbType.VarWChar, 30, "单位"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("电子邮箱", System.Data.OleDb.OleDbType.VarWChar, 30, "电子邮箱"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("手机", System.Data.OleDb.OleDbType.VarWChar, 20, "手机"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("姓名", System.Data.OleDb.OleDbType.VarWChar, 5, "姓名"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("性别", System.Data.OleDb.OleDbType.VarWChar, 1, "性别"));
			// 
			// oleDbSelectCommand1
			// 
			this.oleDbSelectCommand1.CommandText = "SELECT ICQ, OICQ, 编号, 单位, 电子邮箱, 手机, 姓名, 性别 FROM dzxxb";
			this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
			// 
			// oleDbUpdateCommand1
			// 
			this.oleDbUpdateCommand1.CommandText = @"UPDATE dzxxb SET ICQ = ?, OICQ = ?, 编号 = ?, 单位 = ?, 电子邮箱 = ?, 手机 = ?, 姓名 = ?, 性别 = ? WHERE (编号 = ?) AND (ICQ = ? OR ? IS NULL AND ICQ IS NULL) AND (OICQ = ? OR ? IS NULL AND OICQ IS NULL) AND (单位 = ? OR ? IS NULL AND 单位 IS NULL) AND (姓名 = ?) AND (性别 = ?) AND (手机 = ? OR ? IS NULL AND 手机 IS NULL) AND (电子邮箱 = ? OR ? IS NULL AND 电子邮箱 IS NULL)";
			this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ICQ", System.Data.OleDb.OleDbType.VarWChar, 20, "ICQ"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("OICQ", System.Data.OleDb.OleDbType.VarWChar, 20, "OICQ"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("编号", System.Data.OleDb.OleDbType.VarWChar, 10, "编号"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("单位", System.Data.OleDb.OleDbType.VarWChar, 30, "单位"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("电子邮箱", System.Data.OleDb.OleDbType.VarWChar, 30, "电子邮箱"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("手机", System.Data.OleDb.OleDbType.VarWChar, 20, "手机"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("姓名", System.Data.OleDb.OleDbType.VarWChar, 5, "姓名"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("性别", System.Data.OleDb.OleDbType.VarWChar, 1, "性别"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_编号", System.Data.OleDb.OleDbType.VarWChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "编号", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ICQ", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ICQ", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ICQ1", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ICQ", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_OICQ", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "OICQ", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_OICQ1", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "OICQ", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_单位", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_单位1", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_姓名", System.Data.OleDb.OleDbType.VarWChar, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_性别", System.Data.OleDb.OleDbType.VarWChar, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性别", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_手机", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "手机", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_手机1", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "手机", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_电子邮箱", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "电子邮箱", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_电子邮箱1", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "电子邮箱", System.Data.DataRowVersion.Original, null));
			// 
			// dzzx
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(800, 542);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "dzzx";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "读者注消";
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			string ComStr="";
			try
			{
				System.Data.OleDb.OleDbCommand MySelect = this.oleDbConnection1.CreateCommand();
				if( this.textBox1.Text != "")
				{
					ComStr="SELECT * FROM dzxxb WHERE 编号='"+this.textBox1.Text+"'";
				}
				else
				{
					if(this.textBox2.Text != "")
					{
						if( ComStr == "")
						{
							ComStr="SELECT * FROM dzxxb WHERE 姓名='"+this.textBox2.Text+"'";
						}
						else
						{
							ComStr+=" AND 姓名='"+this.textBox2.Text+"'";
						}
					}
					if(this.textBox3.Text != "")
					{
						if(ComStr == "")
						{
							ComStr="SELECT * FROM dzxxb WHERE 手机='"+this.textBox3.Text+"'";
						}
						else
						{
							ComStr+=" AND 手机='"+this.textBox3.Text+"'";
						}
					}
					if(ComStr=="")
					{
						MessageBox.Show("无查询条件,默认查找所有记录.","查找提示: ",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
						ComStr="SELECT * FROM dzxxb";
					}
				}
				MySelect.CommandText=ComStr;
				this.oleDbDataAdapter1.SelectCommand=MySelect;
				this.dataSet21.Clear();
				this.oleDbConnection1.Open();
				this.oleDbDataAdapter1.Fill(dataSet21,"dzxxb");
				this.oleDbConnection1.Close();
			}
			catch(Exception Exc)
			{
				MessageBox.Show(Exc.Message);
				this.oleDbConnection1.Close();
			}
		}

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

		private void button3_Click(object sender, System.EventArgs e)
		{
			try
			{
				System.Data.OleDb.OleDbCommand MySelect = this.oleDbConnection1.CreateCommand();
				MySelect.CommandText="SELECT * FROM dzxxb";
				this.oleDbDataAdapter1.SelectCommand=MySelect;
				this.dataSet21.Clear();
				this.oleDbConnection1.Open();
				this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");
				this.oleDbConnection1.Close();
			}
			catch(Exception Exc)
			{
				MessageBox.Show(Exc.Message);
				this.oleDbConnection1.Close();
			}
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			try
			{
				int ReN = this.dataGrid1.CurrentRowIndex;
				if(ReN == -1)
				{
					MessageBox.Show("当前没有记录可以删除!!!","删除提示:",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
				else
				{
					string BH=dataSet21.Tables["dzxxb"].Rows[ReN]["编号"].ToString();
					System.Data.OleDb.OleDbCommand MyDel=this.oleDbConnection1.CreateCommand();
					MyDel.CommandText="DELETE * FROM dzxxb WHERE 编号='"+BH+"'";
					this.oleDbDataAdapter1.DeleteCommand=MyDel;
					if(MessageBox.Show("删除是不可恢复的,真的要删除吗?","删除提示:",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation) == DialogResult.Yes)
					{
						this.oleDbConnection1.Open();
						MyDel.ExecuteNonQuery();
						this.oleDbConnection1.Close();
						button3_Click(null,null);
					}
				}
			}
			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.button1.Focused || this.textBox1.Focused || this.textBox2.Focused || this.textBox3.Focused)
					{
						button1_Click(null,null);
					}
					if(this.button2.Focused)
					{
						button2_Click(null,null);
					}
					if(this.button3.Focused)
					{
						button3_Click(null,null);
					}
					if(this.button4.Focused)
					{
						this.Close();
					}
					break;
				case 38:
				case 37:
					if(this.textBox3.Focused)
					{
						this.textBox2.Focus();
					}
					else
					{
						if(this.textBox2.Focused)
						{
							this.textBox1.Focus();
						}
						else
						{
							if(this.textBox1.Focused)
							{
								this.textBox3.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.textBox1.Focus();
							}
						}
					}
					break;
			}
		}

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

		private void dataGrid1_DoubleClick(object sender, System.EventArgs e)
		{
			button2_Click(null,null);
		}
	}
}

⌨️ 快捷键说明

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