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

📄 selstuinfo.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;
using System.IO;



namespace 学生信息管理
{
	/// <summary>
	/// SelStuinfo 的摘要说明。
	/// 查看学员信息
	/// </summary>
	public class SelStuinfo : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox grpStuinfo;
		private System.Windows.Forms.ListView lvwStuinfo;
		private System.Windows.Forms.GroupBox grpBox;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button btnMoreStuinfo;
		private System.Windows.Forms.Button btnDelStuinfo;
		private System.Windows.Forms.Button btnUpdateStuinfo;
		private System.ComponentModel.IContainer components;
		public DataSet ds = null;
		private OleDbDataAdapter adapter = null;
		private System.Windows.Forms.ImageList imgObj;
		private DBManagers db = new DBManagers();
		private ShowMoreStuinfo smsformss = null;
		private System.Windows.Forms.Button btnSelectAll;
		private System.Windows.Forms.Button btnSelectAllFan;
		private System.Windows.Forms.ContextMenu contentMnu;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.MenuItem menuItem7;
		private System.Windows.Forms.MenuItem menuItem8;
		private System.Windows.Forms.ImageList imgLargeobj;
		

	

		public SelStuinfo()
		{
			//
			// 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.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SelStuinfo));
			this.grpStuinfo = new System.Windows.Forms.GroupBox();
			this.lvwStuinfo = new System.Windows.Forms.ListView();
			this.contentMnu = new System.Windows.Forms.ContextMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.menuItem7 = new System.Windows.Forms.MenuItem();
			this.imgObj = new System.Windows.Forms.ImageList(this.components);
			this.grpBox = new System.Windows.Forms.GroupBox();
			this.btnSelectAllFan = new System.Windows.Forms.Button();
			this.btnSelectAll = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.button1 = new System.Windows.Forms.Button();
			this.btnMoreStuinfo = new System.Windows.Forms.Button();
			this.btnDelStuinfo = new System.Windows.Forms.Button();
			this.btnUpdateStuinfo = new System.Windows.Forms.Button();
			this.imgLargeobj = new System.Windows.Forms.ImageList(this.components);
			this.grpStuinfo.SuspendLayout();
			this.grpBox.SuspendLayout();
			this.SuspendLayout();
			// 
			// grpStuinfo
			// 
			this.grpStuinfo.Controls.Add(this.lvwStuinfo);
			this.grpStuinfo.Location = new System.Drawing.Point(8, 8);
			this.grpStuinfo.Name = "grpStuinfo";
			this.grpStuinfo.Size = new System.Drawing.Size(1000, 488);
			this.grpStuinfo.TabIndex = 0;
			this.grpStuinfo.TabStop = false;
			this.grpStuinfo.Text = "学生详细信息";
			// 
			// lvwStuinfo
			// 
			this.lvwStuinfo.CheckBoxes = true;
			this.lvwStuinfo.ContextMenu = this.contentMnu;
			this.lvwStuinfo.GridLines = true;
			this.lvwStuinfo.HoverSelection = true;
			this.lvwStuinfo.Location = new System.Drawing.Point(8, 16);
			this.lvwStuinfo.Name = "lvwStuinfo";
			this.lvwStuinfo.Size = new System.Drawing.Size(984, 464);
			this.lvwStuinfo.SmallImageList = this.imgObj;
			this.lvwStuinfo.TabIndex = 0;
			this.lvwStuinfo.View = System.Windows.Forms.View.Details;
			this.lvwStuinfo.DoubleClick += new System.EventHandler(this.lvwStuinfo_DoubleClick);
			// 
			// contentMnu
			// 
			this.contentMnu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					   this.menuItem1,
																					   this.menuItem8,
																					   this.menuItem6,
																					   this.menuItem2,
																					   this.menuItem3,
																					   this.menuItem5,
																					   this.menuItem4,
																					   this.menuItem7});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.Text = "全选(&A)";
			this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 1;
			this.menuItem8.Text = "刷新全部(&R)";
			this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 2;
			this.menuItem6.Text = "-";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 3;
			this.menuItem2.Text = "添加学员信息";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 4;
			this.menuItem3.Text = "删除学员信息";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 5;
			this.menuItem5.Text = "查询学员信息";
			this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 6;
			this.menuItem4.Text = "修改学员信息";
			this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
			// 
			// menuItem7
			// 
			this.menuItem7.Index = 7;
			this.menuItem7.Text = "-";
			// 
			// imgObj
			// 
			this.imgObj.ImageSize = new System.Drawing.Size(16, 16);
			this.imgObj.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgObj.ImageStream")));
			this.imgObj.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// grpBox
			// 
			this.grpBox.Controls.Add(this.btnSelectAllFan);
			this.grpBox.Controls.Add(this.btnSelectAll);
			this.grpBox.Controls.Add(this.button2);
			this.grpBox.Controls.Add(this.button1);
			this.grpBox.Controls.Add(this.btnMoreStuinfo);
			this.grpBox.Controls.Add(this.btnDelStuinfo);
			this.grpBox.Controls.Add(this.btnUpdateStuinfo);
			this.grpBox.Location = new System.Drawing.Point(8, 496);
			this.grpBox.Name = "grpBox";
			this.grpBox.Size = new System.Drawing.Size(1000, 56);
			this.grpBox.TabIndex = 1;
			this.grpBox.TabStop = false;
			this.grpBox.Enter += new System.EventHandler(this.grpBox_Enter);
			// 
			// btnSelectAllFan
			// 
			this.btnSelectAllFan.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnSelectAllFan.Location = new System.Drawing.Point(184, 16);
			this.btnSelectAllFan.Name = "btnSelectAllFan";
			this.btnSelectAllFan.Size = new System.Drawing.Size(64, 32);
			this.btnSelectAllFan.TabIndex = 48;
			this.btnSelectAllFan.Text = "反选";
			this.btnSelectAllFan.Visible = false;
			this.btnSelectAllFan.Click += new System.EventHandler(this.btnSelectAllFan_Click);
			// 
			// btnSelectAll
			// 
			this.btnSelectAll.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnSelectAll.Location = new System.Drawing.Point(96, 16);
			this.btnSelectAll.Name = "btnSelectAll";
			this.btnSelectAll.Size = new System.Drawing.Size(64, 32);
			this.btnSelectAll.TabIndex = 47;
			this.btnSelectAll.Text = "全选";
			this.btnSelectAll.Click += new System.EventHandler(this.btnSelectAll_Click);
			// 
			// button2
			// 
			this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.button2.Location = new System.Drawing.Point(768, 16);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(104, 32);
			this.button2.TabIndex = 46;
			this.button2.Text = "自定义查询";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button1
			// 
			this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.button1.Location = new System.Drawing.Point(648, 16);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(104, 32);
			this.button1.TabIndex = 45;
			this.button1.Text = "自定义显示风格";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// btnMoreStuinfo
			// 
			this.btnMoreStuinfo.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnMoreStuinfo.Location = new System.Drawing.Point(504, 16);
			this.btnMoreStuinfo.Name = "btnMoreStuinfo";
			this.btnMoreStuinfo.Size = new System.Drawing.Size(128, 32);
			this.btnMoreStuinfo.TabIndex = 44;
			this.btnMoreStuinfo.Text = "查看学员详细信息";
			this.btnMoreStuinfo.Click += new System.EventHandler(this.btnMoreStuinfo_Click);
			// 
			// btnDelStuinfo
			// 
			this.btnDelStuinfo.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnDelStuinfo.Location = new System.Drawing.Point(384, 16);
			this.btnDelStuinfo.Name = "btnDelStuinfo";
			this.btnDelStuinfo.Size = new System.Drawing.Size(104, 32);
			this.btnDelStuinfo.TabIndex = 43;
			this.btnDelStuinfo.Text = "删除学员信息";
			this.btnDelStuinfo.Click += new System.EventHandler(this.btnDelStuinfo_Click);
			// 
			// btnUpdateStuinfo
			// 
			this.btnUpdateStuinfo.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnUpdateStuinfo.Location = new System.Drawing.Point(264, 16);
			this.btnUpdateStuinfo.Name = "btnUpdateStuinfo";
			this.btnUpdateStuinfo.Size = new System.Drawing.Size(104, 32);
			this.btnUpdateStuinfo.TabIndex = 42;
			this.btnUpdateStuinfo.Text = "更新学员信息";
			this.btnUpdateStuinfo.Click += new System.EventHandler(this.btnUpdateStuinfo_Click);
			// 
			// imgLargeobj
			// 
			this.imgLargeobj.ImageSize = new System.Drawing.Size(100, 100);
			this.imgLargeobj.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgLargeobj.ImageStream")));
			this.imgLargeobj.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// SelStuinfo
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(1016, 560);
			this.Controls.Add(this.grpBox);
			this.Controls.Add(this.grpStuinfo);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "SelStuinfo";
			this.Text = "查询学员信息";
			this.Load += new System.EventHandler(this.SelStuinfo_Load);
			this.grpStuinfo.ResumeLayout(false);
			this.grpBox.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		public ListView LvwStuInfo
		{
			get{return this.lvwStuinfo;}
			set{this.lvwStuinfo = value;}
		}


		//初始化信息将数据表的信息显示到ListView
		public void SelStuinfo_Load(object sender, System.EventArgs e)
		{
			
			this.lvwStuinfo.Columns.Clear();
			this.lvwStuinfo.Items.Clear();
			//连接数据库
			db.Server = "Microsoft.Jet.OLEDB.4.0";
			db.Database = ((FormMain)this.MdiParent).environmentpath+"\\StuInfoMgr.mdb";

			db.createConn();
			db.openConn();
			
			
			if(this.ds == null)
			{
				this.ds = new DataSet("StuInfoMgr");

				this.adapter = new OleDbDataAdapter();
				this.adapter.SelectCommand = new OleDbCommand("select * from stuinfo",db.Conn);

				try
				{
					this.adapter.Fill(this.ds,"stuinfo");
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.Message);
					Console.WriteLine(ex);
				}				
			}		
			

			//关闭连接
			db.closeConn();


			//从数据集中取数据放到listview中			
			
			this.lvwStuinfo.Columns.Add("学号",200,System.Windows.Forms.HorizontalAlignment.Left);
			this.lvwStuinfo.Columns.Add("姓名",100,System.Windows.Forms.HorizontalAlignment.Left);
			this.lvwStuinfo.Columns.Add("性别",100,System.Windows.Forms.HorizontalAlignment.Left);
			this.lvwStuinfo.Columns.Add("身份证号码",200,System.Windows.Forms.HorizontalAlignment.Left);
			this.lvwStuinfo.Columns.Add("民族",100,System.Windows.Forms.HorizontalAlignment.Left);
			this.lvwStuinfo.Columns.Add("最高学历",100,System.Windows.Forms.HorizontalAlignment.Left);
			this.lvwStuinfo.Columns.Add("籍贯",100,System.Windows.Forms.HorizontalAlignment.Left);
			this.lvwStuinfo.Columns.Add("家庭住址",200,System.Windows.Forms.HorizontalAlignment.Left);
			
			
			int count = 0;

			foreach(DataRow dr in this.ds.Tables["stuinfo"].Rows)
			{
				
				ListViewItem lvi = new ListViewItem();
				lvi.ImageIndex = 2;
				lvi.Text = dr[0].ToString();
				lvi.Font = new Font("宋体",10);
				
				
				if(count%2 == 0)
				{
					lvi.BackColor = Color.Pink; //设置BackColor
				}

				for(int i=1;i<=7;i++)
				{
					lvi.SubItems.Add(dr[i].ToString());
				}
                
				this.lvwStuinfo.Items.Add(lvi);
				count++;
			}




			
		}

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

		//双击查看详细信息
		private void lvwStuinfo_DoubleClick(object sender, System.EventArgs e)
		{
			((FormMain)this.MdiParent).Status.Text = "状态:查看学员详细信息";
			ShowMoreStuinfo smsform = new ShowMoreStuinfo();
			smsform.Text = "查看学员信息";

			smsform.Stu_Id.Enabled = false;
			smsform.Stu_Name.Enabled = false;
			smsform.Stu_Idcard.Enabled = false;
			smsform.Stu_Race.Enabled = false;
			smsform.Stu_educational.Enabled = false;
			smsform.Stu_NativePlace.Enabled = false;
			smsform.Stu_Address.Enabled = false;
			smsform.Stu_FixTel.Enabled =false;
			smsform.Stu_TelPhone.Enabled = false;
			smsform.Stu_Love.Enabled = false;
			smsform.Stu_Special.Enabled = false;
			smsform.Stu_Marks.Enabled =false;
			smsform.Stu_Male.Enabled = false;
			smsform.Stu_Female.Enabled = false;
			
			
			smsform.Addinfo.Text = "查看学员信息";
			smsform.Addinfo.Enabled = false;
			smsform.Reset.Enabled = false;
			smsform.OpenPhoto.Enabled = false;


			//添加数据
			foreach(DataRow dr in this.ds.Tables["stuinfo"].Rows)
			{
				if(dr[0].ToString().Equals(this.lvwStuinfo.SelectedItems[0].Text))
				{
					smsform.Stu_Id.Text = dr[0].ToString();
					smsform.Stu_Name.Text = dr[1].ToString();
					if(dr[2].ToString().Equals("男"))
					{
						smsform.Stu_Male.Checked = true;
					}
					else
					{
						smsform.Stu_Female.Checked = true;
					}

					smsform.Stu_Idcard.Text = dr[3].ToString();
					smsform.Stu_Race.Items.Clear();
					smsform.Stu_Race.Items.Add(dr[4].ToString());

					smsform.Stu_educational.Items.Clear();
					smsform.Stu_educational.Items.Add(dr[5].ToString());

					smsform.Stu_NativePlace.Text = dr[6].ToString();
					smsform.Stu_Address.Text = dr[7].ToString();	
					smsform.Stu_FixTel.Text = dr[8].ToString();
					smsform.Stu_TelPhone.Text = dr[9].ToString();
					smsform.Stu_Love.Items.Clear();
					smsform.Stu_Love.Items.Add(dr[10].ToString());
					smsform.Stu_Special.Items.Clear();
					smsform.Stu_Special.Items.Add(dr[11].ToString());				
					
					smsform.Stu_Photo.Image = Image.FromFile(((FormMain)this.MdiParent).environmentpath+"\\"+dr[12].ToString());
					
					
				    smsform.Stu_Marks.Text = dr[13].ToString();
					smsform.Update();
					
				}
			}

			smsform.MdiParent = this.MdiParent;
			smsform.Show();
		}


		//查看学员详细信息
		private void btnMoreStuinfo_Click(object sender, System.EventArgs e)
		{
			if(this.lvwStuinfo.SelectedItems.Count != 0)
			{
				((FormMain)this.MdiParent).Status.Text = "状态:查看学员详细信息";
				lvwStuinfo_DoubleClick(sender,e);
			}
			else
			{
				MessageBox.Show("请选择你要查看的学员编号!");
				return;
			}			
		}

		//更新学员信息
		public void btnUpdateStuinfo_Click(object sender, System.EventArgs e)
		{
			if(this.lvwStuinfo.CheckedItems.Count == 0)
			{
				MessageBox.Show("请选择你要更新的行!");
				return;
			}

			((FormMain)this.MdiParent).Status.Text = "状态:更新学员信息";

			smsformss = new ShowMoreStuinfo();
			smsformss.Text = "更新学员信息";

			smsformss.Stu_Id.Enabled = false;	
			smsformss.OpenPhoto.Enabled = false;
			
			smsformss.Addinfo.Text = "更新学员信息";			


			//添加数据
			foreach(DataRow dr in this.ds.Tables["stuinfo"].Rows)
			{
				if(dr[0].ToString().Equals(this.lvwStuinfo.CheckedItems[0].Text))
				{
					smsformss.Stu_Id.Text = dr[0].ToString();
					smsformss.Stu_Name.Text = dr[1].ToString();
					if(dr[2].ToString().Equals("男"))

⌨️ 快捷键说明

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