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

📄 frmmain_pt.cs

📁 因本人正在学习中
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.IO;
namespace 图书
{
	/// <summary>
	/// frmMain_pt 的摘要说明。
	/// </summary>
	public class frmMain_pt : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TabControl tabControl1;
		private System.Windows.Forms.TabPage tabPage1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button7;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox txt1;
		private System.Windows.Forms.Button button4;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.TabPage tabPage2;
		private System.Windows.Forms.Button button6;
		private System.Windows.Forms.Button button5;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox txt2;
		private System.Windows.Forms.Button button8;
		private System.Windows.Forms.DataGrid dataGrid2;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmMain_pt()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// 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.tabControl1 = new System.Windows.Forms.TabControl();
			this.tabPage1 = new System.Windows.Forms.TabPage();
			this.button2 = new System.Windows.Forms.Button();
			this.button7 = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.txt1 = new System.Windows.Forms.TextBox();
			this.button4 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.button1 = new System.Windows.Forms.Button();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.tabPage2 = new System.Windows.Forms.TabPage();
			this.button6 = new System.Windows.Forms.Button();
			this.button5 = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.txt2 = new System.Windows.Forms.TextBox();
			this.button8 = new System.Windows.Forms.Button();
			this.dataGrid2 = new System.Windows.Forms.DataGrid();
			this.tabControl1.SuspendLayout();
			this.tabPage1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.tabPage2.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).BeginInit();
			this.SuspendLayout();
			// 
			// tabControl1
			// 
			this.tabControl1.Controls.Add(this.tabPage1);
			this.tabControl1.Controls.Add(this.tabPage2);
			this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.tabControl1.Location = new System.Drawing.Point(0, 0);
			this.tabControl1.Name = "tabControl1";
			this.tabControl1.SelectedIndex = 0;
			this.tabControl1.Size = new System.Drawing.Size(544, 301);
			this.tabControl1.TabIndex = 14;
			// 
			// tabPage1
			// 
			this.tabPage1.BackColor = System.Drawing.Color.LightSkyBlue;
			this.tabPage1.Controls.Add(this.button2);
			this.tabPage1.Controls.Add(this.button7);
			this.tabPage1.Controls.Add(this.label1);
			this.tabPage1.Controls.Add(this.txt1);
			this.tabPage1.Controls.Add(this.button4);
			this.tabPage1.Controls.Add(this.button3);
			this.tabPage1.Controls.Add(this.button1);
			this.tabPage1.Controls.Add(this.dataGrid1);
			this.tabPage1.ForeColor = System.Drawing.Color.Blue;
			this.tabPage1.Location = new System.Drawing.Point(4, 21);
			this.tabPage1.Name = "tabPage1";
			this.tabPage1.Size = new System.Drawing.Size(536, 276);
			this.tabPage1.TabIndex = 0;
			this.tabPage1.Text = "读者信息";
			// 
			// button2
			// 
			this.button2.BackColor = System.Drawing.SystemColors.Control;
			this.button2.Location = new System.Drawing.Point(272, 224);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(64, 23);
			this.button2.TabIndex = 22;
			this.button2.Text = "返回";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button7
			// 
			this.button7.BackColor = System.Drawing.SystemColors.Control;
			this.button7.Location = new System.Drawing.Point(440, 224);
			this.button7.Name = "button7";
			this.button7.Size = new System.Drawing.Size(56, 23);
			this.button7.TabIndex = 21;
			this.button7.Text = "退出";
			this.button7.Click += new System.EventHandler(this.button7_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(96, 32);
			this.label1.TabIndex = 20;
			this.label1.Text = "读者编号:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txt1
			// 
			this.txt1.Location = new System.Drawing.Point(112, 16);
			this.txt1.Name = "txt1";
			this.txt1.Size = new System.Drawing.Size(104, 21);
			this.txt1.TabIndex = 19;
			this.txt1.Text = "";
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(432, 16);
			this.button4.Name = "button4";
			this.button4.TabIndex = 18;
			this.button4.Text = "还书信息表";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(328, 16);
			this.button3.Name = "button3";
			this.button3.TabIndex = 17;
			this.button3.Text = "借书信息表";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(224, 16);
			this.button1.Name = "button1";
			this.button1.TabIndex = 16;
			this.button1.Text = "读者信息表";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(96, 48);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(368, 160);
			this.dataGrid1.TabIndex = 15;
			// 
			// tabPage2
			// 
			this.tabPage2.BackColor = System.Drawing.Color.LightSkyBlue;
			this.tabPage2.Controls.Add(this.button6);
			this.tabPage2.Controls.Add(this.button5);
			this.tabPage2.Controls.Add(this.label2);
			this.tabPage2.Controls.Add(this.txt2);
			this.tabPage2.Controls.Add(this.button8);
			this.tabPage2.Controls.Add(this.dataGrid2);
			this.tabPage2.Location = new System.Drawing.Point(4, 21);
			this.tabPage2.Name = "tabPage2";
			this.tabPage2.Size = new System.Drawing.Size(536, 276);
			this.tabPage2.TabIndex = 1;
			this.tabPage2.Text = "书籍信息";
			this.tabPage2.Visible = false;
			// 
			// button6
			// 
			this.button6.BackColor = System.Drawing.SystemColors.Control;
			this.button6.Location = new System.Drawing.Point(296, 232);
			this.button6.Name = "button6";
			this.button6.Size = new System.Drawing.Size(64, 23);
			this.button6.TabIndex = 28;
			this.button6.Text = "返回";
			this.button6.Click += new System.EventHandler(this.button6_Click);
			// 
			// button5
			// 
			this.button5.BackColor = System.Drawing.SystemColors.Control;
			this.button5.Location = new System.Drawing.Point(464, 232);
			this.button5.Name = "button5";
			this.button5.Size = new System.Drawing.Size(56, 23);
			this.button5.TabIndex = 27;
			this.button5.Text = "退出";
			this.button5.Click += new System.EventHandler(this.button5_Click);
			// 
			// label2
			// 
			this.label2.ForeColor = System.Drawing.Color.Blue;
			this.label2.Location = new System.Drawing.Point(35, 19);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(96, 32);
			this.label2.TabIndex = 26;
			this.label2.Text = "书籍编号:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txt2
			// 
			this.txt2.Location = new System.Drawing.Point(131, 27);
			this.txt2.Name = "txt2";
			this.txt2.Size = new System.Drawing.Size(104, 21);
			this.txt2.TabIndex = 25;
			this.txt2.Text = "";
			// 
			// button8
			// 
			this.button8.ForeColor = System.Drawing.Color.Blue;
			this.button8.Location = new System.Drawing.Point(243, 27);
			this.button8.Name = "button8";
			this.button8.TabIndex = 22;
			this.button8.Text = "书籍信息表";
			this.button8.Click += new System.EventHandler(this.button8_Click);
			// 
			// dataGrid2
			// 
			this.dataGrid2.DataMember = "";
			this.dataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid2.Location = new System.Drawing.Point(115, 59);
			this.dataGrid2.Name = "dataGrid2";
			this.dataGrid2.Size = new System.Drawing.Size(368, 160);
			this.dataGrid2.TabIndex = 21;
			// 
			// frmMain_pt
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(544, 301);
			this.Controls.Add(this.tabControl1);
			this.Name = "frmMain_pt";
			this.Text = "图书管理系统(普通用户)";
			this.Load += new System.EventHandler(this.frmMain_pt_Load);
			this.tabControl1.ResumeLayout(false);
			this.tabPage1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.tabPage2.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

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

		private void button1_Click(object sender, System.EventArgs e)
		{
			StreamReader sr=new StreamReader("ts.ini",System.Text.Encoding.Default);
			string sn=sr.ReadLine();	
			SqlConnection sqlconn=new SqlConnection(sn);	
			sqlconn.Open();
			string 	sql="select * from dzxxb where dzbh ='"+this.txt1.Text +"'";
			
			SqlDataAdapter da=new SqlDataAdapter(sql,sqlconn);
			DataSet ds=new DataSet();
			da.Fill(ds,"tsgl");
			this.dataGrid1.DataMember="tsgl";
			this.dataGrid1.DataSource=ds;
		}

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

			string sql="select * from jsxxb where  dzbh ='"+this.txt1.Text +"'";
			StreamReader sr=new StreamReader("ts.ini",System.Text.Encoding.Default);
			string sn=sr.ReadLine();	
			SqlConnection sqlconn=new SqlConnection(sn);	
			sqlconn.Open();
			DataSet ds=new DataSet();
			SqlDataAdapter da=new SqlDataAdapter(sql,sqlconn);
			da.Fill(ds,"tsgl");
			this.dataGrid1.DataMember="tsgl";
			this.dataGrid1.DataSource=ds;
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			
			string sql="select * from hsxxb where  dzbh ='"+this.txt1.Text +"'";
			StreamReader sr=new StreamReader("ts.ini",System.Text.Encoding.Default);
			string sn=sr.ReadLine();	
			SqlConnection sqlconn=new SqlConnection(sn);	
			sqlconn.Open();
			DataSet ds=new DataSet();
			SqlDataAdapter da=new SqlDataAdapter(sql,sqlconn);
			da.Fill(ds,"tsgl");
			this.dataGrid1.DataMember="tsgl";
			this.dataGrid1.DataSource=ds;
		}

		private void button8_Click(object sender, System.EventArgs e)
		{
			string sql="";
			sql="select * from sjxxb where sjbh ='"+this.txt2.Text +"'";
			StreamReader sr=new StreamReader("ts.ini",System.Text.Encoding.Default);
			string sn=sr.ReadLine();	
			SqlConnection sqlconn=new SqlConnection(sn);	
			sqlconn.Open();
			DataSet ds=new DataSet();
			SqlDataAdapter da=new SqlDataAdapter(sql,sqlconn);
			da.Fill(ds,"tsgl");
			this.dataGrid2.DataMember="tsgl";
			this.dataGrid2.DataSource=ds;
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			Form1 f=new Form1();
			f.Show();
			this.Hide();
		}

		private void button6_Click(object sender, System.EventArgs e)
		{
			Form1 f=new Form1();
			f.Show();
			this.Hide();
		}

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

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

⌨️ 快捷键说明

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