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

📄 form1.cs

📁 C#网络实例.里面有很多很实用的C#范例
💻 CS
📖 第 1 页 / 共 3 页
字号:
			// checkBox1
			// 
			this.checkBox1.Location = new System.Drawing.Point(8, 17);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.Size = new System.Drawing.Size(80, 24);
			this.checkBox1.TabIndex = 14;
			this.checkBox1.Text = "逻辑与";
			// 
			// checkBox3
			// 
			this.checkBox3.Location = new System.Drawing.Point(8, 64);
			this.checkBox3.Name = "checkBox3";
			this.checkBox3.Size = new System.Drawing.Size(80, 24);
			this.checkBox3.TabIndex = 16;
			this.checkBox3.Text = "逻辑与";
			// 
			// checkBox2
			// 
			this.checkBox2.Location = new System.Drawing.Point(8, 40);
			this.checkBox2.Name = "checkBox2";
			this.checkBox2.Size = new System.Drawing.Size(80, 24);
			this.checkBox2.TabIndex = 15;
			this.checkBox2.Text = "逻辑与";
			// 
			// checkBox5
			// 
			this.checkBox5.Location = new System.Drawing.Point(8, 112);
			this.checkBox5.Name = "checkBox5";
			this.checkBox5.Size = new System.Drawing.Size(80, 24);
			this.checkBox5.TabIndex = 18;
			this.checkBox5.Text = "逻辑与";
			// 
			// checkBox4
			// 
			this.checkBox4.Location = new System.Drawing.Point(8, 88);
			this.checkBox4.Name = "checkBox4";
			this.checkBox4.Size = new System.Drawing.Size(80, 24);
			this.checkBox4.TabIndex = 17;
			this.checkBox4.Text = "逻辑与";
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.DataSource = this.books1.TABLE1;
			this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Top;
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.RowHeaderWidth = 30;
			this.dataGrid1.Size = new System.Drawing.Size(480, 160);
			this.dataGrid1.TabIndex = 0;
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.textBox6,
																					this.checkBox6,
																					this.label6,
																					this.checkBox5,
																					this.checkBox4,
																					this.checkBox3,
																					this.checkBox2,
																					this.checkBox1,
																					this.textBox5,
																					this.textBox4,
																					this.textBox3,
																					this.textBox2,
																					this.textBox1,
																					this.label5,
																					this.label4,
																					this.label3,
																					this.label2,
																					this.label1});
			this.groupBox1.Location = new System.Drawing.Point(160, 160);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(320, 176);
			this.groupBox1.TabIndex = 1;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "查询方式";
			// 
			// textBox6
			// 
			this.textBox6.Location = new System.Drawing.Point(176, 144);
			this.textBox6.Name = "textBox6";
			this.textBox6.Size = new System.Drawing.Size(136, 21);
			this.textBox6.TabIndex = 21;
			this.textBox6.Text = "";
			// 
			// checkBox6
			// 
			this.checkBox6.Location = new System.Drawing.Point(8, 136);
			this.checkBox6.Name = "checkBox6";
			this.checkBox6.Size = new System.Drawing.Size(80, 24);
			this.checkBox6.TabIndex = 20;
			this.checkBox6.Text = "逻辑与";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(104, 144);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(64, 23);
			this.label6.TabIndex = 19;
			this.label6.Text = "ISBN:";
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(40, 216);
			this.button2.Name = "button2";
			this.button2.TabIndex = 1;
			this.button2.Text = "查询数据";
			this.button2.Click += new System.EventHandler(this.button2_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", "TABLE1", new System.Data.Common.DataColumnMapping[] {
																																																				new System.Data.Common.DataColumnMapping("ISBN", "ISBN"),
																																																				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;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = @"DELETE FROM TABLE1 WHERE (ISBN = @Original_ISBN) AND (书名 = @Original_书名 OR @Original_书名 IS NULL AND 书名 IS NULL) AND (作者 = @Original_作者 OR @Original_作者 IS NULL AND 作者 IS NULL) AND (出版日期 = @Original_出版日期 OR @Original_出版日期 IS NULL AND 出版日期 IS NULL) AND (出版社 = @Original_出版社 OR @Original_出版社 IS NULL AND 出版社 IS NULL) AND (定价 = @Original_定价 OR @Original_定价 IS NULL AND 定价 IS NULL)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ISBN", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ISBN", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_书名", System.Data.SqlDbType.VarChar, 100, 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, 100, 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, 100, 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, 100, 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, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "定价", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "data source=zhou;initial catalog=图书销售;persist security info=False;user id=sa;work" +
				"station id=ZHOU;packet size=4096";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO TABLE1(ISBN, 书名, 作者, 出版社, 出版日期, 定价) VALUES (@ISBN, @书名, @作者, @出版社, @出" +
				"版日期, @定价); SELECT ISBN, 书名, 作者, 出版社, 出版日期, 定价 FROM TABLE1 WHERE (ISBN = @ISBN)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ISBN", System.Data.SqlDbType.VarChar, 100, "ISBN"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@书名", System.Data.SqlDbType.VarChar, 100, "书名"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@作者", System.Data.SqlDbType.VarChar, 100, "作者"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出版社", System.Data.SqlDbType.VarChar, 100, "出版社"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出版日期", System.Data.SqlDbType.VarChar, 100, "出版日期"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@定价", System.Data.SqlDbType.VarChar, 100, "定价"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT ISBN, 书名, 作者, 出版社, 出版日期, 定价 FROM TABLE1";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE TABLE1 SET ISBN = @ISBN, 书名 = @书名, 作者 = @作者, 出版社 = @出版社, 出版日期 = @出版日期, 定价 = @定价 WHERE (ISBN = @Original_ISBN) AND (书名 = @Original_书名 OR @Original_书名 IS NULL AND 书名 IS NULL) AND (作者 = @Original_作者 OR @Original_作者 IS NULL AND 作者 IS NULL) AND (出版日期 = @Original_出版日期 OR @Original_出版日期 IS NULL AND 出版日期 IS NULL) AND (出版社 = @Original_出版社 OR @Original_出版社 IS NULL AND 出版社 IS NULL) AND (定价 = @Original_定价 OR @Original_定价 IS NULL AND 定价 IS NULL); SELECT ISBN, 书名, 作者, 出版社, 出版日期, 定价 FROM TABLE1 WHERE (ISBN = @ISBN)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ISBN", System.Data.SqlDbType.VarChar, 100, "ISBN"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@书名", System.Data.SqlDbType.VarChar, 100, "书名"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@作者", System.Data.SqlDbType.VarChar, 100, "作者"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出版社", System.Data.SqlDbType.VarChar, 100, "出版社"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出版日期", System.Data.SqlDbType.VarChar, 100, "出版日期"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@定价", System.Data.SqlDbType.VarChar, 100, "定价"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ISBN", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ISBN", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_书名", System.Data.SqlDbType.VarChar, 100, 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, 100, 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, 100, 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, 100, 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, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "定价", System.Data.DataRowVersion.Original, null));
			// 
			// books1
			// 
			this.books1.DataSetName = "books";
			this.books1.Locale = new System.Globalization.CultureInfo("zh-CN");
			this.books1.Namespace = "http://www.tempuri.org/books.xsd";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(480, 341);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.groupBox1,
																		  this.dataGrid1,
																		  this.button4,
																		  this.button3,
																		  this.button2,
																		  this.button1});
			this.MaximizeBox = false;
			this.Name = "Form1";
			this.Text = "图书销售服务系统";
			this.Click += new System.EventHandler(this.Form1_Click);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.books1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
				sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM TABLE1";
			sqlDataAdapter1.Fill(books1.TABLE1);



		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			string add=null;
			string query1="SELECT * FROM TABLE1 WHERE ";
			if(checkBox1.Checked)
			{
				add="书名>="+"'"+textBox1.Text+"'";
			}
			if(checkBox2.Checked)

⌨️ 快捷键说明

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