1、高校学生宿舍信息管理系统目 录1 课程设计目的2 课程设计题目描述和要求3 课程设计报告内容一、课程设计目的通过课程设计,使学生能够掌握C#语言的基本内容及程序设计的基本方法与编程技巧,使学生具有应用计算机解决实际问题的基本能力,培养学生掌握使用计算机处理问题的思维方法与途径, 培养良好的程序设计风格,使学生能够独立编制和调试各种结构的面向对象的C#语言程序。初步掌握软件开发过程的问题分析、系统设计、程序编码、测试等基本方法和技能;提高综合运用所学的理论知识和方法独立分析和解决问题的能力。完成所选设计题目,上机调试通过该程序系统所有功能;编写设计说明书,内容包括:课程设计的目的、意义;设计任务
2、;总体设计方案;软件设计(各功能模块的流程图及详细的文字说明);软件系统的使用说明;收获、体会等。二、课程设计题目描述和要求1、开发系统的功能介绍(1)系统管理窗体 系统设置信息(2)资源管理窗体 管理宿舍信息(3)学生管理窗体 管理学生住宿信息。(4)报修管理窗体 管理宿舍维修信息。(5)违规管理窗体 管理违规学生信息三、课程设计报告内容操作流程 用户注册登录操作界面系统管理-系统设置信息 资源管理-管理宿舍信息 学生管理-管理学生住宿信息报修管理管理宿舍维修信息违规管理管理违规学生信息管理违规学生信息(四)系统功能结构根据高校学生宿舍信息管理系统的特点,可将其分为:系统登录、系统注册用户,
3、主界面、系统管理界面、资源管理界面、学生管理界面等。(五)系统预览为了初步了解家庭理财系统,下面分别给出系统中的四个界面。登录页面:注册页面:主窗体页面:学生信息登记界面:学生宿舍基本信息界面(六)构建开发环境:系统开发环境:Microsoft Visual Studio 2010集成开发环境。系统开发语言:C#系统数据库:Microsoft Sqlserver2008开发运行环境:Windows XP、Vista、7系统服务运行环境:M Framework 4.0.最佳效果:1024*768。(七)数据库设计本系统采用Sqlserver2008数据库,名称为VirgoDB_StuInfo表:
4、DB_DormInfo表:(九)公共类设计在开发过程中,经常会用到一些公共的模块,如数据库的连接及操作的类,字串的处理的类等,因此,在开发系统前,首先要设计 这些公共模块,下面将介绍高校学生宿舍信息管理系统中所需要的数据库操作类,数据库操作类用来完成数据库的连接操作,以及数据库的查询,添加,删除修改操作,现将这几种操作编写到一个公共类里,可以减少代码的编写工作,有利于代码的维护。代码如下:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;usin
5、g System.Data.SqlClient;using System.Windows.Forms;namespace VirgoMis / / 此类维护数据库连接字符串和Connection对象 / class DBHelper private static SqlCommand cmd = null; private static SqlDataReader dr = null; /数据库连接字符串 /private static string connectionString = Server = HUAIHUAI-8B2819; Database = Virgo; Integrate
6、d Security = SSPI; private static string connectionString = Data Source=.;AttachDbFilename=F:学习C#网上下载新建文件夹源程序代码VirgoMisVirgo.mdf;Integrated Security=True; /数据库连接Connection对象 public static SqlConnection connection = new SqlConnection(connectionString); public DBHelper() #region 返回结果集 public static Sq
7、lDataReader GetResult(string sql) try cmd = new SqlCommand(); cmd.CommandText = sql; cmd.Connection = connection; cmd.Connection.Open(); dr = cmd.ExecuteReader(); return dr; catch (Exception ex) MessageBox.Show(ex.Message); return null; finally /dr.Close(); /cmd.Connection.Close(); #endregion #regio
8、n 对Select语句,返回int型结果集 public static int GetSqlResult(string sql) try cmd = new SqlCommand(); cmd.CommandText = sql; cmd.Connection = connection; cmd.Connection.Open(); int a = (int)cmd.ExecuteScalar(); return a; catch (Exception ex) MessageBox.Show(ex.Message); return -1; finally cmd.Connection.Clos
9、e(); #endregion #region 对Update,Insert和Delete语句,返回该命令所影响的行数 public static int GetDsqlResult(string sql) try cmd = new SqlCommand(); cmd.CommandText = sql; cmd.Connection = connection; cmd.Connection.Open(); cmd.ExecuteNonQuery(); return 1; catch (Exception ex) MessageBox.Show(ex.Message); return -1;
10、 finally cmd.Connection.Close(); #endregion (十)各界面代码及功能实现(1)登录界面:功能:登陆登陆界面代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace VirgoMis
11、public partial class Login : Form public Login() InitializeComponent(); #region 验证用户的输入,成功返回true,失败返回false private bool IsValidataInput() if (txtLoginNo.Text.Trim() = ) MessageBox.Show(请输入账号!,登陆提示,MessageBoxButtons.OK,MessageBoxIcon.Information); txtLoginNo.Focus(); return false; else if (txtLoginPw
12、d.Text = ) MessageBox.Show(请输入密码!,登陆提示,MessageBoxButtons.OK,MessageBoxIcon.Information); txtLoginPwd.Focus(); return false; else if (cboLoginType.Text = ) MessageBox.Show(请选择登陆类型!,登陆提示,MessageBoxButtons.OK,MessageBoxIcon.Information); cboLoginType.Focus(); return false; return true; #endregion #regi
13、on 验证用户是否合法 /传递用户账号、密码、登陆类型,合法返回true,不合法返回false /message参数用来记录验证失败的原因 private bool IsValidataUser(string loginNo, string loginPwd, string loginType, ref string message) string sql = String.Format(select count(*) from DB_ManageInfo where loginNo = 0 and loginPwd = 1 and loginType = 2,loginNo,loginPwd
14、,loginType); int a = DBHelper.GetSqlResult(sql); if (a 1) message = 该用户名或密码不存在!; return false; else return true; #endregion /登陆事件 private void btnLogin_Click(object sender, EventArgs e) /标识是否为合法用户 bool isValidUser = false; string message = ; if (IsValidataInput() /验证用户是否为合法用户 isValidUser = IsValidat
15、aUser(txtLoginNo.Text.Trim(),txtLoginPwd.Text,cboLoginType.Text,ref message); if (isValidUser) /记录登陆用户名和用户类型 UserHelper.loginName = txtLoginNo.Text.Trim(); UserHelper.loginType = cboLoginType.Text; /登陆类型是楼管会 if (cboLoginType.Text = 楼管会) /登陆类型是维修部 else if (cboLoginType.Text = 维修部) /登陆类型是总务处 else if (
16、cboLoginType.Text = 总务处) WFMain sfm = new WFMain(); sfm.Show(); this.Hide(); else MessageBox.Show(message,登陆提示,MessageBoxButtons.OK,MessageBoxIcon.Asterisk); private void btnCanel_Click(object sender, EventArgs e) DialogResult result = MessageBox.Show(您确定要退出吗?, 操作提示, MessageBoxButtons.OKCancel, Mess
17、ageBoxIcon.Question); if (result = DialogResult.OK) Application.Exit(); private void Login_Shown(object sender, EventArgs e) /光标焦点默认在输入账号上 txtLoginNo.Focus(); private void Login_Load(object sender, EventArgs e) private void Login_FormClosed(object sender, FormClosedEventArgs e) Application.Exit(); (
18、2)注册界面: 功能:注册。代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace VirgoMis public partial class MRegister : Form public MRegister() I
19、nitializeComponent(); private void WFRegison_Load(object sender, EventArgs e) txtLoginNo.Focus(); #region 判断是否为有效输入 private bool IsValidataInput() if (txtLoginNo.Text.Trim() = ) MessageBox.Show(请输入账号!, 注册提示, MessageBoxButtons.OK, MessageBoxIcon.Information); txtLoginNo.Focus(); return false; else if
20、 (txtLoginPwd.Text = ) MessageBox.Show(请输入密码!, 注册提示, MessageBoxButtons.OK, MessageBoxIcon.Information); txtLoginPwd.Focus(); return false; else if (DtxtLoginPwd.Text = ) MessageBox.Show(请再次确认输入密码!, 注册提示, MessageBoxButtons.OK, MessageBoxIcon.Information); DtxtLoginPwd.Focus(); return false; else if (
21、!txtLoginPwd.Text.Equals(DtxtLoginPwd.Text) MessageBox.Show(两次输入的密码不一致,请重新输入!, 注册提示, MessageBoxButtons.OK, MessageBoxIcon.Information); DtxtLoginPwd.Clear(); txtLoginPwd.Clear(); txtLoginPwd.Focus(); return false; else if (cboLoginType.Text = ) MessageBox.Show(请选择登陆类型!, 注册提示, MessageBoxButtons.OK, M
22、essageBoxIcon.Information); cboLoginType.Focus(); return false; return true; #endregion private bool IsValidataUser(string loginNo, string loginPwd, string loginType, ref string message) string sql = String.Format(select count(*) from DB_ManageInfo where loginNo = 0 and loginType = 1, loginNo, login
23、Type); int count = DBHelper.GetSqlResult(sql); if (count = 1) message = 该账号已经存在,请重新注册!; return false; else return true; private void btnEnter_Click(object sender, EventArgs e) bool isValidUser = false; string message = ; if (IsValidataInput() /验证用户是否为合法用户 isValidUser = IsValidataUser(txtLoginNo.Text
24、.Trim(), txtLoginPwd.Text, cboLoginType.Text, ref message); if (isValidUser) string sql = String.Format(insert into DB_ManageInfo(loginNo,loginPwd,loginType) values (0,1,2),txtLoginNo.Text.Trim(),txtLoginPwd.Text,cboLoginType.Text); int result = DBHelper.GetDsqlResult(sql); if (result = 1) MessageBo
25、x.Show(注册成功!, 注册提示, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); else MessageBox.Show(注册失败!, 注册提示, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); else MessageBox.Show(message,注册提示,MessageBoxButtons.OK,MessageBoxIcon.Asterisk); txtLoginNo.Clear(); txtLoginPwd.Clear(); DtxtLoginPwd.Clear(); cboLog
26、inType.SelectedIndex = -1; txtLoginNo.Focus(); private void btnExit_Click(object sender, EventArgs e) this.Close(); private void btnCanel_Click(object sender, EventArgs e) this.Close(); (3)主界面:功能:数据的显示,操作,各窗口跳转。代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using Syst
27、em.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace VirgoMis public partial class WFMain : Form public WFMain() InitializeComponent(); private T OpenUniqueMDIChildWindow(Form mdiParent) where T : Form, new() foreach (Form subForm in mdiParent.MdiChil
28、dren) if (!subForm.GetType().Equals(typeof(T) subForm.Close(); else subForm.Activate(); return subForm as T; T newForm = new T(); newForm.MdiParent = mdiParent; /newForm.FormBorderStyle = FormBorderStyle.None; /newForm.WindowState = FormWindowState.Maximized; /newForm.MaximizeBox = false; /newForm.MinimizeBox = false; newForm.StartPosition = FormStartPosition.CenterScreen; newForm.Show(); return newForm; private void WFManage_Load(object sender, EventArgs e) tsslState.Text = String.Format(0:1 登陆中,UserHelper.loginType,UserHelper.lo
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1