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

📄 form1.cs

📁 学生管理系统(学生信息的管理、添加、删除、编辑
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;

namespace winform2
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.DataGrid GRDbooks;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.GroupBox groupBox4;
		private System.Windows.Forms.GroupBox groupBox5;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.ComboBox Cmbtype;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox txtSearch;
		private System.Windows.Forms.Button BtSearch;
		private System.Windows.Forms.Button BtSearchBooks;
		private System.Windows.Forms.TextBox txtSearchNumber;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.TextBox TxtName;
		private System.Windows.Forms.TextBox TxtNumber;
		private System.Windows.Forms.TextBox TxtPassword;
		private System.Windows.Forms.Button BtAdd;
		private System.Windows.Forms.Button BtDel;
		private System.Windows.Forms.Button BtEdit;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ToolBarButton Tbfirst;
		private System.Windows.Forms.ToolBarButton Tbpre;
		private System.Windows.Forms.ToolBarButton TBNext;
		private System.Windows.Forms.ToolBarButton Tblast;
		private System.Windows.Forms.ToolBarButton toolBarButton5;
		private System.Windows.Forms.ToolBarButton TBExit;
		private System.ComponentModel.IContainer components;

		DAO.Database Mydb;
		DAO.Workspace MyWs;
		String MySql;
		DAO.Recordset myrec;
		private System.Windows.Forms.ImageList imageList1;
		DAO.DBEngine de=new DAO.DBEngineClass();

		public bool OpenDb()
		{
			String dbstr;
			dbstr="D:\\lib.mdb";
			MyWs=de.Workspaces[0];
			Mydb=MyWs.OpenDatabase(dbstr,null,null,null);
			MySql="select * from tblstudents";
			myrec=Mydb.OpenRecordset(MySql,DAO.RecordsetTypeEnum.dbOpenDynaset,DAO.RecordsetOptionEnum.dbDenyWrite,DAO.LockTypeEnum.dbOptimistic);
			return true;
		}

		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();


			//
			// 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.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.GRDbooks = new System.Windows.Forms.DataGrid();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.BtSearch = new System.Windows.Forms.Button();
			this.txtSearch = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.Cmbtype = new System.Windows.Forms.ComboBox();
			this.label1 = new System.Windows.Forms.Label();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.label3 = new System.Windows.Forms.Label();
			this.txtSearchNumber = new System.Windows.Forms.TextBox();
			this.BtSearchBooks = new System.Windows.Forms.Button();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this.TxtPassword = new System.Windows.Forms.TextBox();
			this.TxtNumber = new System.Windows.Forms.TextBox();
			this.TxtName = new System.Windows.Forms.TextBox();
			this.label6 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.groupBox4 = 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.groupBox5 = new System.Windows.Forms.GroupBox();
			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.TBExit = new System.Windows.Forms.ToolBarButton();
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			((System.ComponentModel.ISupportInitialize)(this.GRDbooks)).BeginInit();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.groupBox3.SuspendLayout();
			this.groupBox4.SuspendLayout();
			this.groupBox5.SuspendLayout();
			this.SuspendLayout();
			// 
			// GRDbooks
			// 
			this.GRDbooks.DataMember = "";
			this.GRDbooks.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.GRDbooks.Location = new System.Drawing.Point(192, 464);
			this.GRDbooks.Name = "GRDbooks";
			this.GRDbooks.Size = new System.Drawing.Size(232, 176);
			this.GRDbooks.TabIndex = 0;
			this.GRDbooks.Navigate += new System.Windows.Forms.NavigateEventHandler(this.GRDbooks_Navigate);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.BtSearch);
			this.groupBox1.Controls.Add(this.txtSearch);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.Cmbtype);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Location = new System.Drawing.Point(8, 296);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(296, 144);
			this.groupBox1.TabIndex = 1;
			this.groupBox1.TabStop = false;
			// 
			// BtSearch
			// 
			this.BtSearch.Location = new System.Drawing.Point(112, 104);
			this.BtSearch.Name = "BtSearch";
			this.BtSearch.TabIndex = 4;
			this.BtSearch.Text = " 查询";
			this.BtSearch.Click += new System.EventHandler(this.BtSearch_Click);
			// 
			// txtSearch
			// 
			this.txtSearch.Location = new System.Drawing.Point(152, 48);
			this.txtSearch.Name = "txtSearch";
			this.txtSearch.Size = new System.Drawing.Size(128, 21);
			this.txtSearch.TabIndex = 3;
			this.txtSearch.Text = "";
			this.txtSearch.TextChanged += new System.EventHandler(this.txtSearch_TextChanged);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(152, 16);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(104, 24);
			this.label2.TabIndex = 2;
			this.label2.Text = "查询条件";
			// 
			// Cmbtype
			// 
			this.Cmbtype.Items.AddRange(new object[] {
														 "学号",
														 "姓名",
														 "学生总人数"});
			this.Cmbtype.Location = new System.Drawing.Point(8, 48);
			this.Cmbtype.Name = "Cmbtype";
			this.Cmbtype.Size = new System.Drawing.Size(128, 20);
			this.Cmbtype.TabIndex = 1;
			this.Cmbtype.Text = "学号";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 17);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(104, 24);
			this.label1.TabIndex = 0;
			this.label1.Text = "查询类型";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.txtSearchNumber);
			this.groupBox2.Controls.Add(this.BtSearchBooks);
			this.groupBox2.Controls.Add(this.label3);
			this.groupBox2.Location = new System.Drawing.Point(16, 456);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(152, 112);
			this.groupBox2.TabIndex = 2;
			this.groupBox2.TabStop = false;
			this.groupBox2.Enter += new System.EventHandler(this.groupBox2_Enter);
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 24);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(128, 24);
			this.label3.TabIndex = 2;
			this.label3.Text = "按学号查询";
			// 
			// txtSearchNumber
			// 
			this.txtSearchNumber.Location = new System.Drawing.Point(8, 48);
			this.txtSearchNumber.Name = "txtSearchNumber";
			this.txtSearchNumber.Size = new System.Drawing.Size(128, 21);
			this.txtSearchNumber.TabIndex = 1;
			this.txtSearchNumber.Text = "";
			// 
			// BtSearchBooks
			// 
			this.BtSearchBooks.Location = new System.Drawing.Point(8, 80);
			this.BtSearchBooks.Name = "BtSearchBooks";
			this.BtSearchBooks.Size = new System.Drawing.Size(80, 24);
			this.BtSearchBooks.TabIndex = 0;
			this.BtSearchBooks.Text = "查询";
			this.BtSearchBooks.Click += new System.EventHandler(this.BtSearchBooks_Click);
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.Add(this.TxtPassword);
			this.groupBox3.Controls.Add(this.TxtNumber);
			this.groupBox3.Controls.Add(this.TxtName);
			this.groupBox3.Controls.Add(this.label6);
			this.groupBox3.Controls.Add(this.label5);
			this.groupBox3.Controls.Add(this.label4);
			this.groupBox3.Location = new System.Drawing.Point(8, 120);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(208, 152);
			this.groupBox3.TabIndex = 3;
			this.groupBox3.TabStop = false;
			this.groupBox3.Enter += new System.EventHandler(this.groupBox3_Enter);
			// 
			// TxtPassword
			// 
			this.TxtPassword.Location = new System.Drawing.Point(88, 112);
			this.TxtPassword.Name = "TxtPassword";
			this.TxtPassword.Size = new System.Drawing.Size(104, 21);
			this.TxtPassword.TabIndex = 5;
			this.TxtPassword.Text = "";
			// 
			// TxtNumber
			// 
			this.TxtNumber.Location = new System.Drawing.Point(88, 72);
			this.TxtNumber.Name = "TxtNumber";
			this.TxtNumber.Size = new System.Drawing.Size(104, 21);
			this.TxtNumber.TabIndex = 4;
			this.TxtNumber.Text = "";
			// 
			// TxtName
			// 
			this.TxtName.Location = new System.Drawing.Point(88, 32);
			this.TxtName.Name = "TxtName";
			this.TxtName.Size = new System.Drawing.Size(104, 21);
			this.TxtName.TabIndex = 3;
			this.TxtName.Text = "";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(8, 112);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(88, 23);
			this.label6.TabIndex = 2;
			this.label6.Text = "密码";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(8, 72);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(88, 23);
			this.label5.TabIndex = 1;
			this.label5.Text = "学号";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(8, 32);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(88, 23);
			this.label4.TabIndex = 0;
			this.label4.Text = "姓名";
			// 
			// groupBox4
			// 
			this.groupBox4.Controls.Add(this.BtEdit);
			this.groupBox4.Controls.Add(this.BtDel);
			this.groupBox4.Controls.Add(this.BtAdd);
			this.groupBox4.Location = new System.Drawing.Point(224, 120);
			this.groupBox4.Name = "groupBox4";
			this.groupBox4.Size = new System.Drawing.Size(96, 152);
			this.groupBox4.TabIndex = 4;
			this.groupBox4.TabStop = false;
			// 
			// BtEdit
			// 
			this.BtEdit.Location = new System.Drawing.Point(8, 104);
			this.BtEdit.Name = "BtEdit";
			this.BtEdit.TabIndex = 2;
			this.BtEdit.Text = "编辑";

⌨️ 快捷键说明

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