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

📄 form1.cs

📁 这是用C#数据库编程的实例
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace 学生管理系统
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		internal System.Windows.Forms.GroupBox GroupBox1;
		internal System.Windows.Forms.Label Label3;
		internal System.Windows.Forms.Label Label2;
		internal System.Windows.Forms.Label Label1;
		internal System.Windows.Forms.TextBox TxtPassword;
		internal System.Windows.Forms.TextBox TxtName;
		internal System.Windows.Forms.TextBox TxtNumber;
		internal System.Windows.Forms.ToolBar ToolBar1;
		internal System.Windows.Forms.ToolBarButton TBfirst;
		internal System.Windows.Forms.ToolBarButton TBpre;
		internal System.Windows.Forms.ToolBarButton TBNext;
		internal System.Windows.Forms.ToolBarButton TBlast;
		internal System.Windows.Forms.ToolBarButton ToolBarButton5;
		internal System.Windows.Forms.ToolBarButton ToolBarButton6;
		internal System.Windows.Forms.ToolBarButton TBExit;
		internal System.Windows.Forms.ImageList ImageList1;
		internal System.Windows.Forms.GroupBox GroupBox2;
		internal System.Windows.Forms.Button BtEdit;
		internal System.Windows.Forms.Button BtDel;
		internal System.Windows.Forms.Button BtAdd;
		internal System.Windows.Forms.GroupBox GroupBox3;
		internal System.Windows.Forms.DataGrid GRDbooks;
		internal System.Windows.Forms.GroupBox GroupBox5;
		internal System.Windows.Forms.Button BtSearchBooks;
		internal System.Windows.Forms.TextBox txtSearchNumber;
		internal System.Windows.Forms.Label Label6;
		internal System.Windows.Forms.GroupBox GroupBox4;
		internal System.Windows.Forms.ComboBox Cmbtype;
		internal System.Windows.Forms.Button BtSearch;
		internal System.Windows.Forms.TextBox txtSearch;
		internal System.Windows.Forms.Label Label5;
		internal System.Windows.Forms.Label Label4;
		private System.ComponentModel.IContainer components;

		public Form1()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			OpenDb();
			//应用数据库连接函数,打开数据连接
			TxtNumber.Text = Myrec.Fields[0].Value.ToString();
			//显示学号
			TxtName.Text = Myrec.Fields[1].Value.ToString();
			//显示姓名
			TxtPassword.Text = Myrec.Fields[2].Value.ToString();
			//显示密码        
		}

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

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.GroupBox1 = new System.Windows.Forms.GroupBox();
			this.Label3 = new System.Windows.Forms.Label();
			this.Label2 = new System.Windows.Forms.Label();
			this.Label1 = new System.Windows.Forms.Label();
			this.TxtPassword = new System.Windows.Forms.TextBox();
			this.TxtName = new System.Windows.Forms.TextBox();
			this.TxtNumber = new System.Windows.Forms.TextBox();
			this.ToolBar1 = new System.Windows.Forms.ToolBar();
			this.TBfirst = new System.Windows.Forms.ToolBarButton();
			this.TBpre = new System.Windows.Forms.ToolBarButton();
			this.TBNext = new System.Windows.Forms.ToolBarButton();
			this.TBlast = new System.Windows.Forms.ToolBarButton();
			this.ToolBarButton5 = new System.Windows.Forms.ToolBarButton();
			this.ToolBarButton6 = new System.Windows.Forms.ToolBarButton();
			this.TBExit = new System.Windows.Forms.ToolBarButton();
			this.ImageList1 = new System.Windows.Forms.ImageList(this.components);
			this.GroupBox2 = new System.Windows.Forms.GroupBox();
			this.BtEdit = new System.Windows.Forms.Button();
			this.BtDel = new System.Windows.Forms.Button();
			this.BtAdd = new System.Windows.Forms.Button();
			this.GroupBox3 = new System.Windows.Forms.GroupBox();
			this.GRDbooks = new System.Windows.Forms.DataGrid();
			this.GroupBox5 = new System.Windows.Forms.GroupBox();
			this.BtSearchBooks = new System.Windows.Forms.Button();
			this.txtSearchNumber = new System.Windows.Forms.TextBox();
			this.Label6 = new System.Windows.Forms.Label();
			this.GroupBox4 = new System.Windows.Forms.GroupBox();
			this.Cmbtype = new System.Windows.Forms.ComboBox();
			this.BtSearch = new System.Windows.Forms.Button();
			this.txtSearch = new System.Windows.Forms.TextBox();
			this.Label5 = new System.Windows.Forms.Label();
			this.Label4 = new System.Windows.Forms.Label();
			this.GroupBox1.SuspendLayout();
			this.GroupBox2.SuspendLayout();
			this.GroupBox3.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.GRDbooks)).BeginInit();
			this.GroupBox5.SuspendLayout();
			this.GroupBox4.SuspendLayout();
			this.SuspendLayout();
			// 
			// GroupBox1
			// 
			this.GroupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.Label3,
																					this.Label2,
																					this.Label1,
																					this.TxtPassword,
																					this.TxtName,
																					this.TxtNumber});
			this.GroupBox1.Location = new System.Drawing.Point(8, 32);
			this.GroupBox1.Name = "GroupBox1";
			this.GroupBox1.Size = new System.Drawing.Size(280, 128);
			this.GroupBox1.TabIndex = 2;
			this.GroupBox1.TabStop = false;
			// 
			// Label3
			// 
			this.Label3.Location = new System.Drawing.Point(40, 88);
			this.Label3.Name = "Label3";
			this.Label3.Size = new System.Drawing.Size(64, 21);
			this.Label3.TabIndex = 1;
			this.Label3.Text = "密码";
			// 
			// Label2
			// 
			this.Label2.Location = new System.Drawing.Point(40, 60);
			this.Label2.Name = "Label2";
			this.Label2.Size = new System.Drawing.Size(64, 21);
			this.Label2.TabIndex = 1;
			this.Label2.Text = "学号";
			// 
			// Label1
			// 
			this.Label1.Location = new System.Drawing.Point(40, 32);
			this.Label1.Name = "Label1";
			this.Label1.Size = new System.Drawing.Size(64, 21);
			this.Label1.TabIndex = 1;
			this.Label1.Text = "姓名";
			// 
			// TxtPassword
			// 
			this.TxtPassword.Location = new System.Drawing.Point(144, 96);
			this.TxtPassword.Name = "TxtPassword";
			this.TxtPassword.Size = new System.Drawing.Size(104, 21);
			this.TxtPassword.TabIndex = 0;
			this.TxtPassword.Text = "";
			// 
			// TxtName
			// 
			this.TxtName.Location = new System.Drawing.Point(144, 60);
			this.TxtName.Name = "TxtName";
			this.TxtName.Size = new System.Drawing.Size(104, 21);
			this.TxtName.TabIndex = 0;
			this.TxtName.Text = "";
			// 
			// TxtNumber
			// 
			this.TxtNumber.Location = new System.Drawing.Point(144, 24);
			this.TxtNumber.Name = "TxtNumber";
			this.TxtNumber.Size = new System.Drawing.Size(104, 21);
			this.TxtNumber.TabIndex = 0;
			this.TxtNumber.Text = "";
			// 
			// ToolBar1
			// 
			this.ToolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.TBfirst,
																						this.TBpre,
																						this.TBNext,
																						this.TBlast,
																						this.ToolBarButton5,
																						this.ToolBarButton6,
																						this.TBExit});
			this.ToolBar1.DropDownArrows = true;
			this.ToolBar1.ImageList = this.ImageList1;
			this.ToolBar1.Name = "ToolBar1";
			this.ToolBar1.ShowToolTips = true;
			this.ToolBar1.Size = new System.Drawing.Size(304, 25);
			this.ToolBar1.TabIndex = 3;
			this.ToolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.ToolBar1_ButtonClick);
			// 
			// TBfirst
			// 
			this.TBfirst.ImageIndex = 0;
			// 
			// TBpre
			// 
			this.TBpre.ImageIndex = 1;
			// 
			// TBNext
			// 
			this.TBNext.ImageIndex = 2;
			// 
			// TBlast
			// 
			this.TBlast.ImageIndex = 3;
			// 
			// ToolBarButton5
			// 
			this.ToolBarButton5.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// ToolBarButton6
			// 
			this.ToolBarButton6.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// TBExit
			// 
			this.TBExit.ImageIndex = 4;
			// 
			// ImageList1
			// 
			this.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
			this.ImageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.ImageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ImageList1.ImageStream")));
			this.ImageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// GroupBox2
			// 
			this.GroupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.BtEdit,
																					this.BtDel,
																					this.BtAdd});
			this.GroupBox2.Location = new System.Drawing.Point(8, 168);
			this.GroupBox2.Name = "GroupBox2";
			this.GroupBox2.Size = new System.Drawing.Size(280, 48);
			this.GroupBox2.TabIndex = 4;
			this.GroupBox2.TabStop = false;
			// 
			// BtEdit
			// 
			this.BtEdit.Location = new System.Drawing.Point(208, 16);
			this.BtEdit.Name = "BtEdit";
			this.BtEdit.Size = new System.Drawing.Size(56, 24);
			this.BtEdit.TabIndex = 0;
			this.BtEdit.Text = "编辑";
			this.BtEdit.Click += new System.EventHandler(this.BtEdit_Click);
			// 
			// BtDel
			// 
			this.BtDel.Location = new System.Drawing.Point(112, 16);
			this.BtDel.Name = "BtDel";
			this.BtDel.Size = new System.Drawing.Size(56, 24);
			this.BtDel.TabIndex = 0;
			this.BtDel.Text = "删除";
			this.BtDel.Click += new System.EventHandler(this.BtDel_Click);
			// 
			// BtAdd
			// 
			this.BtAdd.Location = new System.Drawing.Point(16, 16);
			this.BtAdd.Name = "BtAdd";
			this.BtAdd.Size = new System.Drawing.Size(56, 24);
			this.BtAdd.TabIndex = 0;
			this.BtAdd.Text = "添加";
			this.BtAdd.Click += new System.EventHandler(this.BtAdd_Click);
			// 
			// GroupBox3
			// 
			this.GroupBox3.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.GRDbooks,
																					this.GroupBox5,
																					this.GroupBox4});
			this.GroupBox3.Location = new System.Drawing.Point(8, 224);
			this.GroupBox3.Name = "GroupBox3";
			this.GroupBox3.Size = new System.Drawing.Size(280, 248);
			this.GroupBox3.TabIndex = 5;
			this.GroupBox3.TabStop = false;
			// 
			// GRDbooks
			// 
			this.GRDbooks.DataMember = "";
			this.GRDbooks.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.GRDbooks.Location = new System.Drawing.Point(8, 128);
			this.GRDbooks.Name = "GRDbooks";
			this.GRDbooks.Size = new System.Drawing.Size(264, 104);
			this.GRDbooks.TabIndex = 2;
			// 
			// GroupBox5
			// 
			this.GroupBox5.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.BtSearchBooks,
																					this.txtSearchNumber,
																					this.Label6});
			this.GroupBox5.Location = new System.Drawing.Point(8, 72);
			this.GroupBox5.Name = "GroupBox5";
			this.GroupBox5.Size = new System.Drawing.Size(264, 48);
			this.GroupBox5.TabIndex = 1;
			this.GroupBox5.TabStop = false;
			// 
			// BtSearchBooks
			// 
			this.BtSearchBooks.Location = new System.Drawing.Point(192, 17);
			this.BtSearchBooks.Name = "BtSearchBooks";
			this.BtSearchBooks.Size = new System.Drawing.Size(56, 24);
			this.BtSearchBooks.TabIndex = 2;
			this.BtSearchBooks.Text = "查询";
			this.BtSearchBooks.Click += new System.EventHandler(this.BtSearchBooks_Click);
			// 
			// txtSearchNumber
			// 
			this.txtSearchNumber.Location = new System.Drawing.Point(96, 17);
			this.txtSearchNumber.Name = "txtSearchNumber";
			this.txtSearchNumber.Size = new System.Drawing.Size(64, 21);
			this.txtSearchNumber.TabIndex = 1;
			this.txtSearchNumber.Text = "";
			// 
			// Label6
			// 
			this.Label6.Location = new System.Drawing.Point(8, 17);
			this.Label6.Name = "Label6";
			this.Label6.Size = new System.Drawing.Size(72, 24);
			this.Label6.TabIndex = 0;
			this.Label6.Text = "按学号查询";
			// 
			// GroupBox4
			// 
			this.GroupBox4.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.Cmbtype,
																					this.BtSearch,
																					this.txtSearch,
																					this.Label5,
																					this.Label4});
			this.GroupBox4.Location = new System.Drawing.Point(8, 8);
			this.GroupBox4.Name = "GroupBox4";
			this.GroupBox4.Size = new System.Drawing.Size(264, 64);
			this.GroupBox4.TabIndex = 0;
			this.GroupBox4.TabStop = false;
			// 
			// Cmbtype
			// 
			this.Cmbtype.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.Cmbtype.DropDownWidth = 64;
			this.Cmbtype.Items.AddRange(new object[] {
														 "学号",
														 "姓名",
														 "学生总人数"});
			this.Cmbtype.Location = new System.Drawing.Point(8, 32);
			this.Cmbtype.Name = "Cmbtype";
			this.Cmbtype.Size = new System.Drawing.Size(64, 20);
			this.Cmbtype.TabIndex = 3;
			// 
			// BtSearch
			// 
			this.BtSearch.Location = new System.Drawing.Point(192, 32);
			this.BtSearch.Name = "BtSearch";
			this.BtSearch.Size = new System.Drawing.Size(56, 24);
			this.BtSearch.TabIndex = 2;
			this.BtSearch.Text = "查询";
			this.BtSearch.Click += new System.EventHandler(this.BtSearch_Click);
			// 
			// txtSearch
			// 
			this.txtSearch.Location = new System.Drawing.Point(88, 32);
			this.txtSearch.Name = "txtSearch";
			this.txtSearch.Size = new System.Drawing.Size(64, 21);
			this.txtSearch.TabIndex = 1;

⌨️ 快捷键说明

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