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

📄 lyzform1.cs

📁 本文介绍了一个基于Client/Server模式的高校图书管理系统的设计与实现。运用Visual Basic.Net结合Microsoft SQL Server 2000开发的登录模块主要用于验证用户
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(224, 272);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(72, 32);
			this.button3.TabIndex = 20;
			this.button3.Text = "删除";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(0, 136);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(472, 120);
			this.dataGrid1.TabIndex = 21;
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(330, 272);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(72, 32);
			this.button4.TabIndex = 22;
			this.button4.Text = "插入";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// sqlDataAdapter1
			// 
			this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
			this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
			this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
			this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									  new System.Data.Common.DataTableMapping("Table", "读者表", new System.Data.Common.DataColumnMapping[] {
																																																			 new System.Data.Common.DataColumnMapping("读者号", "读者号"),
																																																			 new System.Data.Common.DataColumnMapping("读者姓名", "读者姓名"),
																																																			 new System.Data.Common.DataColumnMapping("读者性别", "读者性别"),
																																																			 new System.Data.Common.DataColumnMapping("读者班级", "读者班级"),
																																																			 new System.Data.Common.DataColumnMapping("借阅数目", "借阅数目")})});
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 读者号, 读者姓名, 读者性别, 读者班级, 借阅数目 FROM 读者表";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO 读者表(读者号, 读者姓名, 读者性别, 读者班级, 借阅数目) VALUES (@读者号, @读者姓名, @读者性别, @读者班级, @" +
				"借阅数目); SELECT 读者号, 读者姓名, 读者性别, 读者班级, 借阅数目 FROM 读者表 WHERE (读者号 = @读者号)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@读者号", System.Data.SqlDbType.VarChar, 10, "读者号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@读者姓名", System.Data.SqlDbType.VarChar, 10, "读者姓名"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@读者性别", System.Data.SqlDbType.VarChar, 4, "读者性别"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@读者班级", System.Data.SqlDbType.VarChar, 10, "读者班级"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@借阅数目", System.Data.SqlDbType.Int, 4, "借阅数目"));
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE 读者表 SET 读者号 = @读者号, 读者姓名 = @读者姓名, 读者性别 = @读者性别, 读者班级 = @读者班级, 借阅数目 = @借阅数目 WHERE (读者号 = @Original_读者号) AND (借阅数目 = @Original_借阅数目) AND (读者姓名 = @Original_读者姓名) AND (读者性别 = @Original_读者性别) AND (读者班级 = @Original_读者班级); SELECT 读者号, 读者姓名, 读者性别, 读者班级, 借阅数目 FROM 读者表 WHERE (读者号 = @读者号)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@读者号", System.Data.SqlDbType.VarChar, 10, "读者号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@读者姓名", System.Data.SqlDbType.VarChar, 10, "读者姓名"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@读者性别", System.Data.SqlDbType.VarChar, 4, "读者性别"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@读者班级", System.Data.SqlDbType.VarChar, 10, "读者班级"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@借阅数目", System.Data.SqlDbType.Int, 4, "借阅数目"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_读者号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "读者号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_借阅数目", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "借阅数目", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_读者姓名", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "读者姓名", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_读者性别", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "读者性别", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_读者班级", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "读者班级", System.Data.DataRowVersion.Original, null));
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = "DELETE FROM 读者表 WHERE (读者号 = @Original_读者号) AND (借阅数目 = @Original_借阅数目) AND (读者姓名" +
				" = @Original_读者姓名) AND (读者性别 = @Original_读者性别) AND (读者班级 = @Original_读者班级)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_读者号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "读者号", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_借阅数目", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "借阅数目", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_读者姓名", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "读者姓名", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_读者性别", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "读者性别", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_读者班级", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "读者班级", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "data source=.;initial catalog=Library;integrated security=SSPI;persist security i" +
				"nfo=False;workstation id=S0218;packet size=4096";
			// 
			// dataSet11
			// 
			this.dataSet11.DataSetName = "DataSet1";
			this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
			this.dataSet11.Namespace = "http://www.tempuri.org/DataSet1.xsd";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(472, 309);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.button4,
																		  this.dataGrid1,
																		  this.button3,
																		  this.button2,
																		  this.button1,
																		  this.label5,
																		  this.label4,
																		  this.label3,
																		  this.label2,
																		  this.label1,
																		  this.textBox5,
																		  this.textBox4,
																		  this.textBox3,
																		  this.textBox2,
																		  this.textBox1});
			this.Name = "Form1";
			this.Text = "Form1";
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			string constr= "workstation id=S0218;packet size=4096;integrated security=SSPI;data source=;pe" +
				"rsist security info=False;initial catalog=Library";
			string sq1="select * from 读者表 where (读者号='"+textBox1.Text+"')";
			SqlConnection cn1=new SqlConnection(constr);
			SqlDataAdapter sqlDataAdapter1=new SqlDataAdapter(sq1,cn1);
			DataSet dt1=new DataSet();
			sqlDataAdapter1.Fill(dt1,"读者表");
			dataGrid1.SetDataBinding(dt1,"读者表");
		

		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			string constr= "workstation id=S0218;packet size=4096;integrated security=SSPI;data source=;pe" +
				"rsist security info=False;initial catalog=Library";
			string sq1="delete from 读者表 where (读者号='"+textBox1.Text+"')";
			SqlConnection cn1=new SqlConnection(constr);
			SqlDataAdapter sqlDataAdapter1=new SqlDataAdapter(sq1,cn1);
			DataSet dt1=new DataSet();
			sqlDataAdapter1.Fill(dt1,"读者表");
		//	dataGrid1.SetDataBinding(dt1,"读者表");
		//	sqlDataAdapter1.Update(dt1,"读者表");
		
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			string constr= "workstation id=S0218;packet size=4096;integrated security=SSPI;data source=;pe" +
				"rsist security info=False;initial catalog=Library";
			string sq1="update 读者表 set 读者姓名='"+textBox2.Text+"',读者性别='"+textBox3.Text+"',读者班级='"+textBox4.Text+"',借阅数目='"+textBox5.Text+"' where (读者号='"+textBox1.Text+"')";
			SqlConnection cn1=new SqlConnection(constr);
			SqlDataAdapter sqlDataAdapter1=new SqlDataAdapter(sq1,cn1);
			DataSet dt1=new DataSet();
			sqlDataAdapter1.Fill(dt1,"读者表");
		
		//	dataGrid1.SetDataBinding(dt1,"读者表");
			
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			string constr= "workstation id=S0218;packet size=4096;integrated security=SSPI;data source=;pe" +
				"rsist security info=False;initial catalog=Library";
			/*string sq1="insert into 读者表(readerid,readername,readersex,regdate,booknum,readerclass) values ('"+textBox1.Text+"','"+textBox2.Text+"'','"+textBox3.Text+"','"+textBox4.Text+"','"+textBox5.Text+"','"+textBox6.Text+"')";
			SqlConnection cn1=new SqlConnection(constr);**/
			string sq1="insert into 读者表(读者号,读者姓名,读者性别,读者班级,借阅数目) values ('"+textBox1.Text+"','"+textBox2.Text+"','"+textBox3.Text+"','"+textBox4.Text+"','"+textBox5.Text+"')";
			SqlConnection cn1=new SqlConnection(constr);
SqlDataAdapter sqlDataAdapter1=new SqlDataAdapter(sq1,cn1);
			DataSet dt1=new DataSet();
			//sqlDataAdapter1.Update(dt1,"读者表");
			sqlDataAdapter1.Fill(dt1,"读者表");
			
			//dataGrid1.SetDataBinding(dt1,"读者表");
			
			
		}

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

		
		
	}
}

⌨️ 快捷键说明

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