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

📄 form3.cs

📁 图书馆管理系统为方便读者
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace 图书管理系统
{
	/// <summary>
	/// Form3 的摘要说明。
	/// </summary>
	public class Form3 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.CheckBox checkBox1;
		private System.Windows.Forms.CheckBox checkBox2;
		private System.Windows.Forms.CheckBox checkBox3;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
		private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
		private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
		private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
		private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
		private System.Data.SqlClient.SqlConnection sqlConnection1;
		private 图书管理系统.queryreader queryreader1;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		/// 
		private string cstring1;
		private string cstring2;
		private Form2  form2=new Form2 ();

		private System.ComponentModel.Container components = null;

		public Form3(Form2 form22)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
            form2=form22;
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.checkBox1 = new System.Windows.Forms.CheckBox();
			this.checkBox2 = new System.Windows.Forms.CheckBox();
			this.checkBox3 = new System.Windows.Forms.CheckBox();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.queryreader1 = new 图书管理系统.queryreader();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
			this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
			this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
			((System.ComponentModel.ISupportInitialize)(this.queryreader1)).BeginInit();
			this.SuspendLayout();
			// 
			// checkBox1
			// 
			this.checkBox1.Location = new System.Drawing.Point(16, 16);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.TabIndex = 3;
			this.checkBox1.Text = "读者编号:";
			// 
			// checkBox2
			// 
			this.checkBox2.Location = new System.Drawing.Point(16, 52);
			this.checkBox2.Name = "checkBox2";
			this.checkBox2.TabIndex = 4;
			this.checkBox2.Text = "读者姓名:";
			// 
			// checkBox3
			// 
			this.checkBox3.Location = new System.Drawing.Point(16, 88);
			this.checkBox3.Name = "checkBox3";
			this.checkBox3.TabIndex = 5;
			this.checkBox3.Text = "读者种类:";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(136, 16);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(136, 21);
			this.textBox1.TabIndex = 6;
			this.textBox1.Text = "";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(136, 52);
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(136, 21);
			this.textBox2.TabIndex = 7;
			this.textBox2.Text = "";
			// 
			// comboBox1
			// 
			this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.queryreader1, "Treaderinfo.readertype"));
			this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("SelectedItem", this.queryreader1, "Treaderinfo.readerno"));
			this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.queryreader1, "Treaderinfo.readerno"));
			this.comboBox1.DataSource = this.queryreader1;
			this.comboBox1.DisplayMember = "Treaderinfo.readertype";
			this.comboBox1.Location = new System.Drawing.Point(136, 88);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(136, 20);
			this.comboBox1.TabIndex = 8;
			this.comboBox1.ValueMember = "Treaderinfo.readerno";
			// 
			// queryreader1
			// 
			this.queryreader1.DataSetName = "queryreader";
			this.queryreader1.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(96, 128);
			this.button1.Name = "button1";
			this.button1.TabIndex = 9;
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(200, 128);
			this.button2.Name = "button2";
			this.button2.TabIndex = 10;
			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", "Treaderinfo", new System.Data.Common.DataColumnMapping[] {
																																																					 new System.Data.Common.DataColumnMapping("readertype", "readertype"),
																																																					 new System.Data.Common.DataColumnMapping("readerno", "readerno")})});
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = "DELETE FROM Treaderinfo WHERE (readerno = @Original_readerno) AND (readertype = @" +
				"Original_readertype OR @Original_readertype IS NULL AND readertype IS NULL)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_readerno", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "readerno", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_readertype", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "readertype", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "data source =222.20.54.54;initial catalog=yuan;user id=sa;password=0517;";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO Treaderinfo(readertype, readerno) VALUES (@readertype, @readerno); SE" +
				"LECT readertype, readerno FROM Treaderinfo WHERE (readerno = @readerno)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@readertype", System.Data.SqlDbType.NVarChar, 50, "readertype"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@readerno", System.Data.SqlDbType.NVarChar, 50, "readerno"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT readertype, readerno FROM Treaderinfo";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE Treaderinfo SET readertype = @readertype, readerno = @readerno WHERE (readerno = @Original_readerno) AND (readertype = @Original_readertype OR @Original_readertype IS NULL AND readertype IS NULL); SELECT readertype, readerno FROM Treaderinfo WHERE (readerno = @readerno)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@readertype", System.Data.SqlDbType.NVarChar, 50, "readertype"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@readerno", System.Data.SqlDbType.NVarChar, 50, "readerno"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_readerno", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "readerno", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_readertype", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "readertype", System.Data.DataRowVersion.Original, null));
			// 
			// Form3
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(312, 190);
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.checkBox3);
			this.Controls.Add(this.checkBox2);
			this.Controls.Add(this.checkBox1);
			this.Name = "Form3";
			this.Text = "读者信息查询";
			this.Load += new System.EventHandler(this.Form3_Load);
			((System.ComponentModel.ISupportInitialize)(this.queryreader1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void Form3_Load(object sender, System.EventArgs e)
		{
			sqlDataAdapter1.Fill (queryreader1);
			
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			textBox1.Text ="";
			textBox2.Text ="";
			this.Close ();
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			if(checkBox1.Checked ==true)
			{
				cstring1=textBox1.Text ;
			}
			if(checkBox2.Checked ==true)
			{
				cstring2=textBox2.Text ;

			}
			if(checkBox3.Checked==true)
			{
				//cmdstring+=comboBox1.SelectedItem .ToString ();
			}
			if(textBox1.Text ==""&&textBox2.Text =="")
			{
                MessageBox.Show ("查询条件不能为空!","警告!",MessageBoxButtons.OKCancel ,MessageBoxIcon.Error );
			}
			else
			{
				queryinfo query=new queryinfo (cstring1,cstring2);
				query.MdiParent =form2;
		
				query.Show ();
			}
			
		}

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

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

⌨️ 快捷键说明

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