《学生公寓管理系统》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
浙江工贸职业技术学院学生公寓管理系统信息传媒分院软件100119号朱明涛第1章 目录目录i第1章引言11.1编写目的11.2背景1第2章需求分析22.1项目概述22.2功能需求22.3性能要求2第3章概要设计43.1数据库设计4第1章页70 第1章引言1.1编写目的本文档对《学生公寓管理系统》做了全面细致的用户需求分析,明确梭要开发的软件应具有的功能、性能与界面,清楚地了解用户的需求,并在此基础上进一步提出概要设计说明和完成后续设计与开发工作。1.2背景随着近几年国家队高等教育的重视度逐年提高,在全国范围内掀起了一场高校扩张的热潮,全国各地高等院校纷纷扩大规模,扩大招生名额以及数量。高校的扩张与扩招的形式固然喜人,可随之而来带来不少问题,其中在学生宿舍管理方面更显现出明显的问题。随之学校的扩招,每一年新生数量都在逐渐上升,学生的住宿情况已经成为全国各地各所高校面临的首要问题。为了解决以上问题,各高校纷纷斥资兴建全新的多功能学生公寓楼,学生住宿的硬件条件得到大幅提升,可是软件条件——学生公寓管理系统则还是前进缓慢,甚至止步不前。很多学校由于学生公寓管理系统与学生住宿的硬件条件不配套,是的其应有的功能没有得到发挥,造成资源浪费。有点学校由于现有的学生公寓管理系统效率过于低下,被迫用大量的人力对学生宿舍进行管理,这在现如今能源和人力资源都大幅紧缺的当今环境,并不是长久之计。为了解决子类问题,更好的高效率的管理学生公寓,所以开发了学生公寓管理系统,它的高效、稳定、易操作性定会成为今后各高校学生公寓管理机构的首选工具盒助手。页70 第1章需求分析1.1项目概述学生公寓管理系统包括学生基本信息管理、学生入住管理、故障维修管理、学生离校管理等。1.2功能需求(1)学生基本信息管理:包括学生基本信息的添加、查询、修改、删除。(2)学生入住管理:管理员能为新添加的学生安排寝室,当学生登陆查询个人信息时能够查看自己所分配到的寝室。(3)故障维修管理:学生能添加故障申报信息,维修人员能够及时查看并进行维修工作。(4)学生离校管理:学生登陆后能修改是否离校状态,从而管理员能效率的统计离校人数及相关个人信息。1.3性能要求(1)精度本体统主要在本地运行,鉴于目前的Internet的速度已经非常快,所以在传送方面没有特殊的要求,一般的Internet均可以稳定的运行。(2)时间特性要求该软件用于公寓管理。其主要功能是查询学生住寝情况页70 。一般情况下,无论是客户端和管理端,当用户登录,进行任何操作的时候,系统应该及时的进行反应,反应的时间都不超过5秒。(3)灵活性该软件是在MicrosoftVisualStudio2008上开发的,对于运行环境主要为WindowsXP等Windows系统,所以在运行环境灵活性方面可能不是非常的出色。本软件支持Windows可视化图形操作,可视化功能较强,提供精确人性化的查询和模糊查询,自定义报表和屏幕显示同步进行,支持图形与表格相结合等。第1章页70 第1章概要设计1.1数据库设计(1)实体属性定义:学生基本信息(学号、姓名、性别、班级编号、联系电话)床位(床位编号、学号、寝室幢号、寝室号、床号)班级(班级编号、系别号、班级名)系别(系别号、系别名)离校状态(学号、离校状态)故障报修(报修单号、寝室号、故障信息、报修时间)用户(学号、密码、权限号)权限(权限号、权限)(2)数据表关系图:页70 (1)数据表:XueSheng_Tab(学生表):列名数据类型宽度为空性说明IDvarchar15学号,外键xingmingvarchar20姓名xingbievarchar2√性别banjiIDvarchar6√班级编号,外键lianxidianhuavarchar20学生联系电话photoimage√学生照片chushengriqidata√出生日期shenfenzhengIDvarchar18√身份证号BanJi_Tab(班级表):列名数据类型宽度为空性说明banjiIDvarchar6班级编号,主键banjivarchar20班级名xibieIDint系别号,外键XiBie_Tab(系别表)列名数据类型宽度为空性说明xibieIDint系别号,主键xibievarchar20系别名页70 ChuangWei_Tab(床位表):列名数据类型宽度为空性说明chuangweiIDvarchar5床位编号,主键IDvarchar15√学号,外键qingshizhuangvarchar2寝室幢号qinshiIDint寝室号chuangweiint床位号cengshuint楼层号LiXiao_Tab(离线状态表):列名数据类型宽度为空性说明IDvarchar15学号,外键lixiaozhuangtaivarchar20离校状态GuZhang_Tab(故障申报表):列名数据类型宽度为空性说明guzangIDint故障单号,主键IDvarchar15外键guzhangxinxivarchar50故障信息shenbaoshijiandate申报时间guzhangqinshivarchar5故障寝室号QuanXian_Tab(权限表):列名数据类型宽度为空性说明页70 quanxianIDint权限号,主键quanxianvarchar10权限YongHu_Tab(用户表):列名数据类型宽度为空性说明IDvarchar15学号即账号,主键mimavarchar20密码quanxianIDint权限号,外键1.1页70 1.1界面设计1.主界面代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingGongYuGuanLi.Student;usingGongYuGuanLi.Bug;namespaceGongYuGuanLi{publicpartialclassMainInterface:Form{privateStringID,name,quanxian,zt;publicMainInterface(){InitializeComponent();timer1.Enabled=true;页70 timer1.Interval=1000;}publicvoidsetMessage(Stringid,Stringnm,Stringqx,Stringztt)//从登陆窗口获取信息{quanxian=qx;ID=id;name=nm;zt=ztt;toolStripStatusLabelUser.Text=quanxian+":"+name;toolStripStatusLabelZhuangTai.Text="状态:"+zt;if(zt!="在校"){离校ToolStripMenuItem1.Image=在校ToolStripMenuItem1.Image;在校ToolStripMenuItem1.Image=null;}}privatevoidtimer1_Tick(objectsender,EventArgse)//显示时间{toolStripStatusLabelTime.Text="现在时间:"+DateTime.Now.Year+"-"+DateTime.Now.Month+"-"+DateTime.Now.Day+""+DateTime.Now.ToLongTimeString();}privatevoidMainInterface_Load(objectsender,EventArgse){loginlg=newlogin();lg.Mi=this;this.Hide();lg.ShowDialog();}privatevoidtoolStripMenuItem2_Click(objectsender,EventArgs页70 e)//退出事件{this.Close();}privatevoid注销ToolStripMenuItem_Click(objectsender,EventArgse)//注销事件{loginlg=newlogin();lg.Mi=this;this.Hide();lg.ShowDialog();}privatevoidtoolStripMenuItem1_Click(objectsender,EventArgse){EditPasswordep=newEditPassword(ID,this);ep.ShowDialog();}privatevoidtoolStripMenuItem6_Click(objectsender,EventArgse){AddStudentaddS=newAddStudent(this);addS.ShowDialog();}privatevoidtoolStripMenuItem4_Click(objectsender,EventArgse){StudentInformationsi=newStudentInformation(ID,this);si.ShowDialog();}privatevoid修改个人信息ToolStripMenuItem_Click(objectsender,EventArgse){AllStudentalls=newAllStudent(this,ID);alls.ShowDialog();}privatevoid在校ToolStripMenuItem1_Click(objectsender,EventArgs页70 e){if(zt!="在校"){StudentManagestuM=newStudentManage();stuM.EditZT(ID,1);zt="在校";toolStripStatusLabelZhuangTai.Text="状态:"+zt;在校ToolStripMenuItem1.Image=离校ToolStripMenuItem1.Image;离校ToolStripMenuItem1.Image=null;}}privatevoid离校ToolStripMenuItem1_Click(objectsender,EventArgse){if(zt!="离校"){StudentManagestuM=newStudentManage();stuM.EditZT(ID,2);zt="离校";toolStripStatusLabelZhuangTai.Text="状态:"+zt;离校ToolStripMenuItem1.Image=在校ToolStripMenuItem1.Image;在校ToolStripMenuItem1.Image=null;}}privatevoidtoolStripMenuItem5_Click(objectsender,EventArgse){QinShiXinXiqsxx=newQinShiXinXi(ID,this);qsxx.ShowDialog();页70 }privatevoid故障申报ToolStripMenuItem_Click(objectsender,EventArgse){AddBugab=newAddBug(ID,this);ab.ShowDialog();}privatevoid查看故障信息ToolStripMenuItem_Click(objectsender,EventArgse){AllBugallb=newAllBug(ID,this,quanxian);allb.ShowDialog();}privatevoid公寓管理帮助ToolStripMenuItem_Click(objectsender,EventArgse){stringreportPath=Application.StartupPath.Substring(0,Application.StartupPath.Substring(0,Application.StartupPath.LastIndexOf("\")).LastIndexOf("\"));reportPath+=@"Help.CHM";System.Diagnostics.Process.Start(reportPath);}privatevoidtoolStripMenuItem7_Click(objectsender,EventArgse){AddXiBieaxb=newAddXiBie(this);axb.ShowDialog();}}}页70 1.登录界面代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namespaceGongYuGuanLi{publicpartialclasslogin:Form{privateMainInterfacemi;privateboollog=true;publicMainInterfaceMi{get{returnmi;}set{mi=value;}}publiclogin(){InitializeComponent();//查询数据库,添加权限itemSqlConnectionconn=newSqlConnection("Data页70 Source=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");SqlCommandcmd=newSqlCommand("SELECTquanxianFROMdbo.QuanXian_Tab",conn);try{conn.Open();SqlDataReadersr=cmd.ExecuteReader();while(sr.Read()){comboQuanXian.Items.Add(String.Format("{0}",sr[0]));}conn.Close();sr.Close();}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");}finally{conn.Dispose();cmd.Dispose();}comboQuanXian.SelectedIndex=0;}privatevoidtextPwd_TextChanged(objectsender,EventArgse)//密码长度监控提示{if(textPwd.Text.Length<6||textPwd.Text.Length>18){label4.Text="密码长度:6-18位";}else{label4.Text="";}}页70 privatevoidbuttonLogin_Click(objectsender,EventArgse)//登录按钮事件{SqlConnectionconn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");if(textUser.Text.Trim()!=""&&textPwd.Text.Trim()!=""&&textPwd.Text.Length>=6&&textPwd.Text.Length<=18)//判断是否为空,或者格式错误{SqlCommandcmd=newSqlCommand();try{cmd.CommandText="SELECTdbo.XueSheng_Tab.ID,dbo.XueSheng_Tab.xingming,dbo.QuanXian_Tab.quanxian,dbo.LiXiao_Tab.lixiaozhuangtaiFROMdbo.LiXiao_TabINNERJOINdbo.XueSheng_TabONdbo.LiXiao_Tab.ID=dbo.XueSheng_Tab.IDINNERJOINdbo.YongHu_TabONdbo.XueSheng_Tab.ID=dbo.YongHu_Tab.IDINNERJOINdbo.QuanXian_TabONdbo.YongHu_Tab.quanxianID=dbo.QuanXian_Tab.quanxianIDWHERE(dbo.XueSheng_Tab.ID=@id)AND(dbo.QuanXian_Tab.quanxianID=@quanxianid)AND(dbo.YongHu_Tab.mima=@pwd)";cmd.Parameters.Add("@id",SqlDbType.VarChar);cmd.Parameters.Add("@quanxianid",SqlDbType.Int);cmd.Parameters.Add("@pwd",SqlDbType.VarChar);cmd.Parameters["@id"].Value=textUser.Text.Trim();cmd.Parameters["@quanxianid"].Value=comboQuanXian.SelectedIndex+1;cmd.Parameters["@pwd"].Value=textPwd.Text.Trim();conn.Open();cmd.Connection=conn;SqlDataReadermyreader=cmd.ExecuteReader();if(myreader.Read()){页70 mi.setMessage(String.Format("{0}",myreader[0]),String.Format("{0}",myreader[1]),String.Format("{0}",myreader[2]),String.Format("{0}",myreader[3]));log=false;this.Close();mi.Show();}else{MessageBox.Show("用户名、密码或者权限错误!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);}conn.Close();myreader.Close();}catch(Exceptionex){MessageBox.Show(ex.Message.ToString(),"系统提示");}finally{conn.Dispose();cmd.Dispose();}}else{MessageBox.Show("有未填项或格式错误!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);if(textPwd.Text.Trim()==""){textPwd.Focus();}else{textUser.Focus();}}}privatevoidtextUser_KeyDown(objectsender,KeyEventArgse){if(e.KeyCode==Keys.Down||e.KeyCode==Keys.Enter){页70 textPwd.Focus();}}privatevoidtextPwd_KeyDown(objectsender,KeyEventArgse){if(e.KeyCode==Keys.Up){textUser.Focus();}if(e.KeyCode==Keys.Enter){buttonLogin_Click(sender,e);}}privatevoidlogin_FormClosing(objectsender,FormClosingEventArgse){if(log){Application.Exit();}}}}1.个人信息页70 代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data.SqlClient;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;namespaceGongYuGuanLi.Student{publicpartialclassStudentInformation:Form{privateMainInterfacemi;privateAllStudentalls;privateStudentIstudent;//用于储存学生信息的类//picFillstr记录照片路径,bjID记录班级编号用于存储数据库privateStringpicFillstr="",bjID="";privateboolSFZflag=false,TELflag=true,pic=false,GLY=false;privateStudentManagestudentM=newStudentManage();publicStudentInformation(Stringid,MainInterfacemm){InitializeComponent();mi=mm;student=studentM.selectStudent(id);//获得当前用户的信息if(student==null){MessageBox.Show("无相关信息");}else{ShowStudentInformation();}AllEnabledFalse();}publicStudentInformation(Stringid,AllStudentass,boolquanxian)页70 {InitializeComponent();alls=ass;GLY=quanxian;student=studentM.selectStudent(id);//获得当前用户的信息if(student==null){MessageBox.Show("无相关信息");}else{ShowStudentInformation();}AllEnabledTrue();textBoxName.Enabled=true;comboBoxSex.Visible=true;buttonEditS.Text="修改";this.Text=student.Name+"的个人信息";comboBoxXiBie.Items.Clear();comboBoxXiBie.Items.Add("==请选择==");comboBoxXiBie.SelectedIndex=0;comboBoxBanJi.Items.Clear();comboBoxBanJi.Items.Add("==请选择==");comboBoxBanJi.SelectedIndex=0;SqlConnectionconn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");SqlCommandcmd=newSqlCommand("SELECT[xibie]FROM[GongYuGuanLi].[dbo].[XiBie_Tab]",conn);try{conn.Open();SqlDataReadersr=cmd.ExecuteReader();while(sr.Read()){comboBoxXiBie.Items.Add(String.Format("{0}",sr[0]));}页70 conn.Close();sr.Close();}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");}finally{conn.Dispose();cmd.Dispose();}}privatevoidShowStudentInformation()//显示学生信息{textBoxID.Text=student.Id;textBoxName.Text=student.Name;labelSex.Text=student.Sex;if(student.Sex=="男"){comboBoxSex.SelectedIndex=0;}else{comboBoxSex.SelectedIndex=1;}if(student.Chushengriqi!=""){dateTimePicker1.Text=student.Chushengriqi;}if(student.BanjiID==null){comboBoxXiBie.SelectedIndex=0;comboBoxBanJi.SelectedIndex=0;labelBanJiID.Text="未填班级信息";}else{comboBoxXiBie.Items.Clear();comboBoxXiBie.Items.Add(student.Xibie);comboBoxXiBie.SelectedIndex=0;comboBoxBanJi.Items.Clear();comboBoxBanJi.Items.Add(student.Banji);comboBoxBanJi.SelectedIndex=0;labelBanJiID.Text=student.BanjiID;页70 }if(student.Shenfenzheng!=""){textBoxShenFZ.Text=student.Shenfenzheng;SFZflag=true;}textBoxTel.Text=student.Tel;if(student.Photo!=null){MemoryStreammysm=newMemoryStream(student.Photo);Bitmapbmpt=newBitmap(mysm);pictureBox1.Image=bmpt;pic=true;}}privatevoidAllEnabledFalse()//关闭所有控件,进入不可编辑状态{buttonAddPhoto.Enabled=false;textBoxShenFZ.Enabled=false;textBoxTel.Enabled=false;comboBoxBanJi.Enabled=false;comboBoxXiBie.Enabled=false;dateTimePicker1.Enabled=false;}privatevoidAllEnabledTrue()//激活所有控件,进入编辑状态{buttonAddPhoto.Enabled=true;textBoxShenFZ.Enabled=true;textBoxTel.Enabled=true;comboBoxBanJi.Enabled=true;comboBoxXiBie.Enabled=true;dateTimePicker1.Enabled=true;}privatevoidbuttonCancel_Click(objectsender,EventArgse)//关闭按钮{页70 if(buttonCancel.Text.Trim()=="关闭"){this.Close();if(GLY){alls.Show();}else{mi.Show();}}else{if(student==null){MessageBox.Show("无相关信息");}else{ShowStudentInformation();}AllEnabledFalse();buttonCancel.Text="关闭";}}privatevoidbuttonEditS_Click(objectsender,EventArgse)//编辑按钮{if(GLY){if(labelBanJiID.Text.Trim()!=""&&textBoxShenFZ.Text.Trim()!=""&&SFZflag&&TELflag)//判断是否有空或格式错误{StudentIstu=student;stu.Name=textBoxName.Text.Trim();if(comboBoxSex.SelectedIndex==0){stu.Sex="男";}页70 else{stu.Sex="女";}stu.BanjiID=labelBanJiID.Text.Trim();if(textBoxTel.Text.Trim()!=""){stu.Tel=textBoxTel.Text.Trim();}else{stu.Tel=null;}if(picFillstr==""||pic){stu.Photo=student.Photo;pic=true;}else{try{FileStreamfs=newFileStream(picFillstr,FileMode.Open);intlength=(int)(fs.Length);BinaryReaderbr=newBinaryReader(fs);stu.Photo=br.ReadBytes(length);pic=true;}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");pic=false;}}stu.Chushengriqi=dateTimePicker1.Text;stu.Shenfenzheng=textBoxShenFZ.Text.Trim();if(studentM.EditStudent(stu)&&pic){MessageBox.Show("编辑成功!");this.Close();alls.dataviewClear();alls.Show();}else{MessageBox.Show("修改失败!");ShowStudentInformation();}页70 }else{MessageBox.Show("班级、身份证号不能为空或填写错误!","系统提示");}}else{if(buttonEditS.Text.Trim()=="编辑")//若是编辑,则激活控件进入编辑模式;若是确定,则进行数据修改{buttonEditS.Text="确定";buttonCancel.Text="取消";AllEnabledTrue();comboBoxXiBie.Items.Clear();comboBoxXiBie.Items.Add("==请选择==");comboBoxXiBie.SelectedIndex=0;comboBoxBanJi.Items.Clear();comboBoxBanJi.Items.Add("==请选择==");comboBoxBanJi.SelectedIndex=0;SqlConnectionconn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");SqlCommandcmd=newSqlCommand("SELECT[xibie]FROM[GongYuGuanLi].[dbo].[XiBie_Tab]",conn);try{conn.Open();SqlDataReadersr=cmd.ExecuteReader();while(sr.Read()){comboBoxXiBie.Items.Add(String.Format("{0}",sr[0]));}conn.Close();页70 sr.Close();}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");}finally{conn.Dispose();cmd.Dispose();}}else{if(bjID!=""&&textBoxShenFZ.Text.Trim()!=""&&SFZflag&&TELflag)//判断是否有空或格式错误{StudentIstu=student;stu.BanjiID=labelBanJiID.Text.Trim();if(textBoxTel.Text.Trim()!=""){stu.Tel=textBoxTel.Text.Trim();}else{stu.Tel=null;}if(picFillstr==""||pic){stu.Photo=null;pic=true;}else{try{FileStreamfs=newFileStream(picFillstr,FileMode.Open);intlength=(int)(fs.Length);BinaryReaderbr=newBinaryReader(fs);stu.Photo=br.ReadBytes(length);pic=true;}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");页70 pic=false;}}stu.Chushengriqi=dateTimePicker1.Text;stu.Shenfenzheng=textBoxShenFZ.Text.Trim();if(studentM.EditStudent(stu)&&pic){MessageBox.Show("编辑成功!");student=studentM.selectStudent(stu.Id);AllEnabledFalse();ShowStudentInformation();buttonEditS.Text="编辑";buttonCancel.Text="关闭";}else{MessageBox.Show("修改失败!");ShowStudentInformation();}}else{MessageBox.Show("班级、身份证号不能为空或填写错误!","系统提示");}}}}privatevoidbuttonAddPhoto_Click(objectsender,EventArgse)//添加照片按钮{OpenFileDialogmyOpenFileDialog=newOpenFileDialog();myOpenFileDialog.Filter="图像文件(*.JPG)|*.JPG|BMP(*.bmp)|*.bmp|所有文件(*.*)|*.*";页70 if(myOpenFileDialog.ShowDialog()==DialogResult.OK){picFillstr=myOpenFileDialog.FileName;pictureBox1.ImageLocation=picFillstr;}}privatevoidtextBoxShenFZ_KeyPress(objectsender,KeyPressEventArgse)//控制身份证处只能输入数字{if((e.KeyChar<48||e.KeyChar>57)&&e.KeyChar!=8){e.Handled=true;}if(textBoxShenFZ.Text.Length!=17){labelSFZ.Text="身份证号长度为18位";SFZflag=false;}else{labelSFZ.Text="";SFZflag=true;}}privatevoidtextBoxTel_KeyPress(objectsender,KeyPressEventArgse)//控制联系电话处只能输入数字{if((e.KeyChar<48||e.KeyChar>57)&&e.KeyChar!=8){e.Handled=true;}if(textBoxTel.Text.Length>19){labelTEL.Text="超出存储长度!";TELflag=false;}else{labelTEL.Text="";TELflag=true;}}privatevoidcomboBoxXiBie_SelectedIndexChanged(objectsender,EventArgse)//系别下拉选项改变时,进行班级数据查询,添加班级下拉选项{if(comboBoxXiBie.Enabled){if(comboBoxXiBie.SelectedIndex!=0){bjID=comboBoxXiBie.SelectedIndex.ToString();labelBanJiID.Text="";comboBoxBanJi.Items.Clear();页70 comboBoxBanJi.Items.Add("==请选择==");comboBoxBanJi.SelectedIndex=0;SqlConnectionconn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");SqlCommandcmd=newSqlCommand("SELECTbanjiFROMdbo.BanJi_TabWHERE(xibieID="+bjID+")",conn);try{conn.Open();SqlDataReadersr=cmd.ExecuteReader();while(sr.Read()){comboBoxBanJi.Items.Add(String.Format("{0}",sr[0]));}conn.Close();sr.Close();}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");}finally{conn.Dispose();cmd.Dispose();}}}}privatevoidcomboBoxBanJi_SelectedIndexChanged(objectsender,EventArgse)//班级下拉选项改变时,将班级编号显示出来{if(comboBoxBanJi.Enabled){if(comboBoxBanJi.SelectedIndex!=0){bjID=bjID+0+comboBoxBanJi.SelectedIndex;页70 labelBanJiID.Text=bjID;}}}}}1.添加用户代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namespaceGongYuGuanLi{publicpartialclassAddStudent:Form{privateboolflag=false;privateMainInterfacemi;publicAddStudent(MainInterfacemm){InitializeComponent();页70 comboBoxSex.SelectedIndex=0;mi=mm;SqlConnectionconn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");SqlCommandcmd=newSqlCommand("SELECTquanxianFROMdbo.QuanXian_Tab",conn);try{conn.Open();SqlDataReadersr=cmd.ExecuteReader();while(sr.Read()){comboBoxQx.Items.Add(String.Format("{0}",sr[0]));}conn.Close();sr.Close();}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");}finally{conn.Dispose();cmd.Dispose();}comboBoxQx.SelectedIndex=1;}privatevoidtextBoxPwd_TextChanged(objectsender,EventArgse){if(textBoxPwd.Text.Length<6||textBoxPwd.Text.Length>18){label7.Text="密码长度为6-18";}else{label7.Text="";}页70 }privatevoidbuttonClear_Click(objectsender,EventArgse)//清空按钮{textBoxID.Text="";textBoxName.Text="";comboBoxSex.SelectedIndex=0;textBoxPwd.Text="";textBoxPwd2.Text="";textBoxTel.Text="";}privatevoidbuttonCencel_Click(objectsender,EventArgse){this.Close();mi.Show();}privatevoidbutton1_Click(objectsender,EventArgse)//检测ID按钮{StudentManagestudentM=newStudentManage();if(studentM.checkID(textBoxID.Text.Trim())){label9.Text="该ID可用";textBoxName.Focus();}else{label9.Text="该ID已存在";textBoxID.Focus();}}privatevoidbuttonAdd_Click(objectsender,EventArgse)//添加按钮{StudentManagestudentM=newStudentManage();页70 if(textBoxID.Text.Trim()!=""&&textBoxName.Text.Trim()!=""&&textBoxPwd.Text.Trim()!=""&&textBoxPwd2.Text.Trim()!=""&&textBoxTel.Text.Trim()!=""&&textBoxTel.Text.Length<=20&&flag)//判断是否有空或格式错误{if(studentM.checkID(textBoxID.Text.Trim()))//判断ID是否已存在{Stringsex;if(comboBoxSex.SelectedIndex==0){sex="男";}else{sex="女";}studentM.addUser(textBoxID.Text.Trim(),textBoxName.Text.Trim(),sex,textBoxPwd.Text.Trim(),comboBoxQx.SelectedIndex+1,textBoxTel.Text.Trim());//添加方法MessageBox.Show("添加成功");this.Close();mi.Show();}else{label9.Text="该ID已存在";}}else{MessageBox.Show("不能为空或其中存在格式错误!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);}}privatevoidtextBoxPwd2_TextChanged(objectsender,EventArgse)页70 {if(textBoxPwd2.Text.Length<6||textBoxPwd2.Text.Length>18){label8.Text="密码长度为6-18";flag=false;}else{if(textBoxPwd.Text.Trim()!=textBoxPwd2.Text.Trim()){label8.Text="两次输入的密码不同";flag=false;}else{label8.Text="";flag=true;}}}privatevoidtextBoxTel_TextChanged(objectsender,EventArgse){if(textBoxTel.Text.Length>20){label11.Text="超出存储长度";}else{label11.Text="";}}}}1.添加系别代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;页70 usingSystem.Text;usingSystem.Windows.Forms;namespaceGongYuGuanLi.Student{publicpartialclassAddXiBie:Form{privateMainInterfacemi;privatebooltetflag=false;publicAddXiBie(MainInterfacemm){InitializeComponent();mi=mm;}privatevoidtextXiBie_TextChanged(objectsender,EventArgse){if(textXiBie.Text.Length<4||textXiBie.Text.Length>20){label2.Text="长度为4-20位";tetflag=false;}else{label2.Text="";tetflag=true;}}privatevoidbuttonCencel_Click(objectsender,EventArgse){this.Close();mi.Show();}privatevoidbuttonAdd_Click(objectsender,EventArgse){if(tetflag&&textXiBie.Text.Trim()!=""){StudentManagestudentM=newStudentManage();if(studentM.addXiBie(textXiBie.Text.Trim())){页70 MessageBox.Show("添加成功!","系统提示");this.Close();mi.Show();}else{MessageBox.Show("添加失败!","系统提示");textXiBie.Text="";}}else{MessageBox.Show("不能为空或长度不标准!","系统提示");}}}}1.修改密码代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;页70 usingSystem.Text;usingSystem.Windows.Forms;namespaceGongYuGuanLi{publicpartialclassEditPassword:Form{privateboolflag=false;privateStringID;privateMainInterfacemi;publicEditPassword(Stringidd,MainInterfacemm)//构造方法,获取用户ID,主界面对象{InitializeComponent();ID=idd;mi=mm;}privatevoidtextBoxOPwd_TextChanged(objectsender,EventArgse)//检测密码长度是否在6-18位以内{if(textBoxOPwd.Text.Length<6||textBoxOPwd.Text.Length>18){label4.Text="密码长度为6-18";}else{label4.Text="";}}privatevoidtextBoxOPwd_KeyDown(objectsender,KeyEventArgse){if(e.KeyCode==Keys.Enter){textBoxNPwd.Focus();}}页70 privatevoidtextBoxNPwd_TextChanged(objectsender,EventArgse)//检测密码长度是否在6-18位以内{if(textBoxNPwd.Text.Length<6||textBoxNPwd.Text.Length>18){label5.Text="密码长度为6-18";flag=false;}else{label5.Text="";flag=true;}}privatevoidtextBoxNPwd_KeyDown(objectsender,KeyEventArgse){if(e.KeyCode==Keys.Enter){textBoxNPwd2.Focus();}}privatevoidtextBoxNPwd2_TextChanged(objectsender,EventArgse)//检测密码长度是否在6-18位以内,并判断两次输入密码是否相同{if(textBoxNPwd2.Text.Length<6||textBoxNPwd2.Text.Length>18){label6.Text="密码长度为6-18";flag=false;}else{if(textBoxNPwd.Text.Trim()!=textBoxNPwd2.Text.Trim()){label6.Text="两次输入的密码不同";flag=false;}else{label6.Text="";flag=true;}}}privatevoidtextBoxNPwd2_KeyDown(objectsender,KeyEventArgse){if(e.KeyCode==Keys.Enter){页70 buttonEdit_Click(sender,e);}}privatevoidbuttonClear_Click(objectsender,EventArgse){textBoxOPwd.Text="";textBoxNPwd.Text="";textBoxNPwd2.Text="";}privatevoidbuttonEdit_Click(objectsender,EventArgse)//修改密码{StudentManagestudentM=newStudentManage();if(flag&&textBoxOPwd.Text.Trim()!=""&&textBoxNPwd.Text.Trim()!=""&&textBoxNPwd2.Text.Trim()!=""){if(studentM.checkOldPwd(ID,textBoxOPwd.Text.Trim()))//检测旧密码是否正确{flag=studentM.editPwd(ID,textBoxNPwd.Text.Trim());//修改密码if(flag){MessageBox.Show("密码修改成功!");this.Close();mi.Show();}else{textBoxNPwd.Focus();}}else{MessageBox.Show("旧密码错误!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);textBoxOPwd.Focus();}}else{页70 MessageBox.Show("不能为空或格式错误!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);textBoxOPwd.Focus();}}privatevoidbuttonCancel_Click(objectsender,EventArgse){this.Close();mi.Show();}}}1.住寝信息代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingGongYuGuanLi.Student;usingSystem.Data.SqlClient;namespaceGongYuGuanLi.Student页70 {publicpartialclassQinShiXinXi:Form{privateStringid;privateMainInterfacemi;privateAllStudentalls;privateStringQSLou="",QSCeng="",QSID="",QSChuang="";privateboolAllStu=false;publicQinShiXinXi(Stringidd,MainInterfacemm){InitializeComponent();id=idd;groupBox1.Text="ID:"+id;mi=mm;}publicQinShiXinXi(Stringidd,AllStudentass){InitializeComponent();id=idd;groupBox1.Text="ID:"+id;alls=ass;comboBoxQinShiLou.Enabled=true;comboBoxQSCeng.Enabled=true;comboBoxQSHao.Enabled=true;comboBoxQSChuangWei.Enabled=true;buttonEditQS.Enabled=true;AllStu=true;}privatevoidshowXinXi(){SqlConnectionconn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");SqlCommandcmd=newSqlCommand("SELECT[chuangweiID],[qinshizhuang],[cengshu],[qinshiID],[chuangwei]FROM[GongYuGuanLi].[dbo].[ChuangWei_Tab]WHEREID='"+id+"'",conn);try{conn.Open();SqlDataReaderreader=cmd.ExecuteReader();页70 if(reader.Read()){label6.Text=String.Format("{0}",reader[0]);comboBoxQinShiLou.SelectedIndex=QinShiLou(String.Format("{0}",reader[1]));comboBoxQSCeng.SelectedIndex=(int)(reader[2]);comboBoxQSHao.Items.Add(String.Format("{0}",reader[3]));comboBoxQSHao.SelectedIndex=2;comboBoxQSChuangWei.Items.Add(String.Format("{0}",reader[4]));comboBoxQSChuangWei.SelectedIndex=2;}else{label6.Text="未安排寝室";comboBoxQinShiLou.SelectedIndex=6;comboBoxQSCeng.SelectedIndex=0;comboBoxQSHao.SelectedIndex=0;comboBoxQSChuangWei.SelectedIndex=0;}reader.Close();reader.Dispose();}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");}finally{conn.Close();cmd.Dispose();conn.Dispose();}}privateintQinShiLou(Stringlou){switch(lou){case"A":return0;break;case"B":return1;break;页70 case"C":return2;break;case"D":return3;break;case"E":return4;break;case"F":return5;break;default:return6;break;}}privateStringQinShiLou(intlou){switch(lou){case0:return"A";break;case1:return"B";break;case2:return"C";break;case3:return"D";break;case4:return"E";break;case5:return"F";break;default:return"";break;}}privatevoidbuttonCencel_Click(objectsender,EventArgse){this.Close();if(AllStu){alls.Show();}else{mi.Show();}}privatevoidQinShiXinXi_Load(objectsender,EventArgse){showXinXi();}privatevoidcomboBoxQinShiLou_SelectedIndexChanged(objectsender,EventArgse){if(AllStu){QSLou=QinShiLou(comboBoxQinShiLou.SelectedIndex);label6.Text="";页70 if(QSLou!="==请选择=="&&QSCeng!="==请选择=="&&QSLou!=""&&QSCeng!=""){SqlConnectionconn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");SqlCommandcmd=newSqlCommand("SELECTdistinct[qinshiID]FROM[GongYuGuanLi].[dbo].[ChuangWei_Tab]WHERE[qinshizhuang]='"+QSLou+"'AND[cengshu]="+QSCeng,conn);try{conn.Open();SqlDataReadersr=cmd.ExecuteReader();comboBoxQSHao.Items.Clear();comboBoxQSHao.Items.Add("==请选择==");while(sr.Read()){comboBoxQSHao.Items.Add(String.Format("{0}",sr[0]));}conn.Close();sr.Close();}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");}finally{conn.Dispose();cmd.Dispose();}comboBoxQSHao.SelectedIndex=0;}}}privatevoidcomboBoxQSCeng_SelectedIndexChanged(objectsender,EventArgse){页70 if(AllStu){QSCeng=""+comboBoxQSCeng.SelectedIndex;label6.Text="";if(QSLou!="==请选择=="&&QSCeng!="==请选择=="&&QSLou!=""&&QSCeng!=""){SqlConnectionconn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");SqlCommandcmd=newSqlCommand("SELECTdistinct[qinshiID]FROM[GongYuGuanLi].[dbo].[ChuangWei_Tab]WHERE[qinshizhuang]='"+QSLou+"'AND[cengshu]="+QSCeng,conn);try{conn.Open();SqlDataReadersr=cmd.ExecuteReader();comboBoxQSHao.Items.Clear();comboBoxQSHao.Items.Add("==请选择==");while(sr.Read()){comboBoxQSHao.Items.Add(String.Format("{0}",sr[0]));}conn.Close();sr.Close();}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");}finally{conn.Dispose();cmd.Dispose();}comboBoxQSHao.SelectedIndex=0;}}}页70 privatevoidcomboBoxQSHao_SelectedIndexChanged(objectsender,EventArgse){if(AllStu){QSID=comboBoxQSHao.SelectedItem.ToString();label6.Text="";if(QSLou!="==请选择=="&&QSCeng!="==请选择=="&&QSID!="==请选择=="&&QSLou!=""&&QSCeng!=""&&QSID!=""){SqlConnectionconn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");SqlCommandcmd=newSqlCommand("SELECT[chuangwei]FROM[GongYuGuanLi].[dbo].[ChuangWei_Tab]WHERE[qinshizhuang]='"+QSLou+"'AND[cengshu]="+QSCeng+"AND[qinshiID]="+QSID,conn);try{conn.Open();SqlDataReadersr=cmd.ExecuteReader();comboBoxQSChuangWei.Items.Clear();comboBoxQSChuangWei.Items.Add("==请选择==");while(sr.Read()){comboBoxQSChuangWei.Items.Add(String.Format("{0}",sr[0]));}conn.Close();sr.Close();}catch(Exceptionex){MessageBox.Show(ex.Message,"系统提示");}finally{conn.Dispose();页70 cmd.Dispose();}comboBoxQSChuangWei.SelectedIndex=0;}}}privatevoidcomboBoxQSChuangWei_SelectedIndexChanged(objectsender,EventArgse){if(AllStu){QSChuang=comboBoxQSChuangWei.SelectedItem.ToString();if(QSChuang!="==请选择=="&&QSChuang!="=请重选楼层="){label6.Text=QSLou+QSID+QSChuang;}}}privatevoidbuttonEditQS_Click(objectsender,EventArgse){StudentManagestuM=newStudentManage();if(stuM.checkChuangWei(label6.Text.Trim())){if(stuM.EditQS(id,label6.Text.Trim())){MessageBox.Show("修改成功!","系统提示");this.Close();alls.Show();alls.dataviewClear();}else{MessageBox.Show("修改失败!","系统提示");}}页70 else{MessageBox.Show("该床位已有人!","系统提示");}}}}1.学生信息查询代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Drawing;usingSystem.Data.SqlClient;usingSystem.IO;namespaceGongYuGuanLi.Student{publicpartialclassAllStudent:Form{privateMainInterfacemi;页70 privateSqlDataAdapterda1,da2,da3;privateStringselectID="",ID="";privateintselectindex;privateDataSetmyDS=newDataSet();privateSqlConnectionconn;privateStudentManagestudentM=newStudentManage();privateDataViewdv;publicAllStudent(MainInterfacemm,Stringidd){InitializeComponent();mi=mm;ID=idd;dv=newDataView();conn=newSqlConnection("DataSource=UREY-PC;InitialCatalog=GongYuGuanLi;IntegratedSecurity=True");}privatevoiddrawTree(){treeView1.BeginUpdate();treeView1.Nodes.Clear();TreeNodeTnode=newTreeNode("系别",0,0);Tnode.ImageIndex=0;Tnode.SelectedImageIndex=3;treeView1.Nodes.Add(Tnode);DataTabledtXiBie,dtBanJi,dtXueSheng;dtXiBie=myDS.Tables["xibie"];dtBanJi=myDS.Tables["banji"];dtXueSheng=myDS.Tables["xuesheng"];foreach(DataRowrowindtXiBie.Rows){TreeNodetnXibie=newTreeNode(row["xibie"].ToString(),1,2);tnXibie.ImageIndex=1;tnXibie.SelectedImageIndex=3;treeView1.Nodes[0].Nodes.Add(tnXibie);DataRow[]order=dtBanJi.Select("xibie='"+row["xibie"]+"'","banji");foreach(DataRowrowOrderinorder){TreeNodetnOrder=new页70 TreeNode(rowOrder["banji"].ToString(),3,4);tnOrder.ImageIndex=2;tnOrder.SelectedImageIndex=3;tnXibie.Nodes.Add(tnOrder);}}treeView1.EndUpdate();}privatevoidAllStudent_Load(objectsender,EventArgse){buttonSEdit.Enabled=false;buttonDelete.Enabled=false;buttonQinShi.Enabled=false;radioButtonIDJQSelect.Checked=true;radioButtonXMJQSelect.Checked=true;conn.Open();da1=newSqlDataAdapter("SELECT*FROMdbo.XiBie_Tab",conn);da2=newSqlDataAdapter("SELECT*FROMdbo.View_BanJi",conn);da3=newSqlDataAdapter("SELECT*FROMdbo.View_XueSheng",conn);da1.Fill(myDS,"xibie");da2.Fill(myDS,"banji");da3.Fill(myDS,"xuesheng");drawTree();this.Cursor=Cursors.Arrow;}privatevoidtreeView1_AfterSelect(objectsender,TreeViewEventArgse){this.Cursor=Cursors.WaitCursor;dataGridView1.DataSource=null;myDS.Tables["xuesheng"].Clear();da3.Fill(myDS.Tables["xuesheng"]);dv.RowFilter="";TreeNodetn=treeView1.SelectedNode;if(tn.ImageIndex==0){dv.Table=myDS.Tables["xuesheng"];}elseif(tn.ImageIndex==1)页70 {dv.Table=myDS.Tables["xuesheng"];dv.RowFilter="系名='"+tn.Text+"'";}elseif(tn.ImageIndex==2){dv.Table=myDS.Tables["xuesheng"];dv.RowFilter="班级='"+tn.Text+"'";}selectID="";buttonSEdit.Enabled=false;buttonDelete.Enabled=false;buttonQinShi.Enabled=false;dataGridView1.DataSource=dv;this.Cursor=Cursors.Arrow;}privatevoiddataGridView1_CellClick(objectsender,DataGridViewCellEventArgse){selectID=dataGridView1.CurrentRow.Cells[0].Value.ToString();selectindex=dataGridView1.CurrentRow.Index;if(selectID!=""){if(buttonSEdit.Enabled==false){buttonSEdit.Enabled=true;buttonDelete.Enabled=true;buttonQinShi.Enabled=true;}}else{buttonSEdit.Enabled=false;buttonDelete.Enabled=false;buttonQinShi.Enabled=false;}}privatevoidbuttonIDSelect_Click(objectsender,EventArgse){页70 if(textBoxID.Text.Trim()!=""){this.Cursor=Cursors.WaitCursor;dataGridView1.DataSource=null;myDS.Tables["xuesheng"].Clear();da3.Fill(myDS.Tables["xuesheng"]);dv.RowFilter="";if(radioButtonIDJQSelect.Checked){dv.Table=myDS.Tables["xuesheng"];dv.RowFilter="学号='"+textBoxID.Text.Trim()+"'";}else{dv.Table=myDS.Tables["xuesheng"];dv.RowFilter="学号like'%"+textBoxID.Text.Trim()+"%'";}dataGridView1.DataSource=dv;this.Cursor=Cursors.Arrow;}else{MessageBox.Show("不能为空!","系统提示");}}privatevoidbuttonXMSelect_Click(objectsender,EventArgse){if(textBoxXM.Text.Trim()!=""){this.Cursor=Cursors.WaitCursor;dataGridView1.DataSource=null;myDS.Tables["xuesheng"].Clear();da3.Fill(myDS.Tables["xuesheng"]);dv.RowFilter="";if(radioButtonXMJQSelect.Checked){dv.Table=myDS.Tables["xuesheng"];dv.RowFilter="姓名='"+textBoxXM.Text.Trim()+"'";页70 }else{dv.Table=myDS.Tables["xuesheng"];dv.RowFilter="姓名like'%"+textBoxXM.Text.Trim()+"%'";}dataGridView1.DataSource=dv;this.Cursor=Cursors.Arrow;}else{MessageBox.Show("不能为空!","系统提示");}}privatevoidAllStudent_FormClosing(objectsender,FormClosingEventArgse){conn.Close();conn.Dispose();myDS.Dispose();}privatevoidbuttonDelete_Click(objectsender,EventArgse){if(selectID!=ID){if(studentM.deleteStudent(selectID)){MessageBox.Show("删除成功!","系统提示");this.Cursor=Cursors.WaitCursor;dv.Table.Rows.RemoveAt(selectindex);dataGridView1.DataSource=dv;this.Cursor=Cursors.Arrow;}}else{MessageBox.Show("不能删除当前用户!","系统提示");页70 }}publicvoiddataviewClear(){dataGridView1.DataSource=null;selectID="";selectindex=0;buttonDelete.Enabled=false;buttonQinShi.Enabled=false;buttonSEdit.Enabled=false;drawTree();}privatevoidbuttonSEdit_Click(objectsender,EventArgse){StudentInformationsi=newStudentInformation(selectID,this,true);si.ShowDialog();}privatevoidbuttonQinShi_Click(objectsender,EventArgse){QinShiXinXiqsxx=newQinShiXinXi(selectID,this);qsxx.ShowDialog();}privatevoidbutton1_Click(objectsender,EventArgse){if(dataGridView1.Rows.Count>=1){StringtempStr="";StreammyStream;SaveFileDialogsaveFileDialog1=newSaveFileDialog();saveFileDialog1.Filter="Excel文件(*.xls)|*.xls";saveFileDialog1.FilterIndex=2;saveFileDialog1.RestoreDirectory=true;if(saveFileDialog1.ShowDialog()==DialogResult.OK){if((myStream=saveFileDialog1.OpenFile())!=null){StreamWritersw=newStreamWriter(myStream,System.Text.Encoding.GetEncoding("gb2312"));页70 Stringstr="";try{for(inti=0;i
此文档下载收益归作者所有