《C#.NET程序设计》课程设计说明书教师管理系统.doc
C#.NET程序设计课程设计说明书设计题目: 教师管理系统 学院、系: 软件学院 专业班级: 软升本10-4班 学生姓名: 指导教师: 成 绩: 2011 年 7 月 12 日一、课程设计目的通过完成从用户需求分析、数据库设计、目录结构与通用模块、管理主界面设计及各个具体管理模块设计到上机编程、调试和应用等全过程,进一步了解和掌握C#.NET程序设计技术。二、 课程设计任务与要求1. 基本要求:1)要求利用C#的编程思想以及组件开发原理来完成系统的设计; 2)突出C#语言与其它语言不同点(即体现C#的高级功能,如属性概念、接口、事件、委托等);3)体现可视化编程基本思想,如系统带有菜单、工具栏、状态栏以及一些常用的高级控件。2. 创新要求:在基本要求达到后,可进行创新设计。完成该系统数据库设计;实现相应信息的添加、删除、删除、查看等功能。三、需求分析在设计数据库结构时,应尽量可能满足用户所提出的各项要求,同时避免冗余数据的产生。由于教师管理系统中需要采集大量的信息,包括院系信息、课程信息、教师信息、收入信息等,如果不能有效合理地组织数据表的结构以及每张表所含的字段,那么在后期进行数据整理及汇总时,将增加开发人员的工作难度和工作量。根据教师基本信息及相关特点,可以总结出一下规律:l 一个院系包括一名或多名教师l 一名教师可以教多门课程l 每名教师都有不同的教师编码l 每名教师都有自己对应的月收入l 一个角色对应一个或多个用户四、概要设计1. 系统功能模块划分教师管理系统院系设置课程设置教师设置收入设置添加院系浏览院系修改院系添加课程删除课程修改课程添加教师修改教师浏览教师添加收入修改收入2. 数据库逻辑结构设计系统数据库名称为hanqifang,数据库中包括:(1)院系信息表dbo.yuanxi;(2)教师表信息dbo.jiaoshi;(3)课程信息表dbo.kecheng.下面列出各个表的数据结构 院系信息表字段名 类 型描 述yuanxibianmayuanximingcheng int varchar院系编码(主键)院系名称 教师信息表 字段名 类 型描 述jiaoshibianmajiaoshixingmingjiaoshixingbiejiaoshixueli yuanximingchengkechengbianmaintvarcharvarcharvarcharvarcharint教师编码(主键)教师姓名教师性别教师学历院系名称课程编码 课程信息表 字段名 类 型描 述kechengbianmakechengmingchengkechengmiaosuintvarcharvarchar课程编码(主键)课程名称课程描述五、详细设计主界面设计主界面设计的作用就是显示本系统所有的功能菜单项,本且把用户经常用到的功能设计成菜单项,以方便用户操作,然后当用户单击相应的菜单项或菜单按钮时,打开对应的模块窗口。本系统的主界面如图。由图可知“院系”菜单下有子菜单,包括“修改”和“添加”。主界面编码:zhuyemian.csusing 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 WindowsFormsApplication1hanqifang.yuanxi;/导入用于院系的命名空间using WindowsFormsApplication1hanqifang.jiaoshi;namespace WindowsFormsApplication1hanqifang public partial class zhuyemian : Form public zhuyemian() InitializeComponent(); private void zhuyemian_Load(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e) this.ttsTime.Text = "时间为:" + DateTime.Now.ToString(); tianjia a; private void b_Click(object sender, EventArgs e) if (a= null | a.IsDisposed) a = new tianjia (); for (int x = 0; x < this.MdiChildren.Length; x+) Form tempChild = (Form)this.MdiChildrenx; tempChild.Close(); a.MdiParent = this; a.Show(); liulan c; private void 浏览ToolStripMenuItem_Click(object sender, EventArgs e) if (c = null | c.IsDisposed) c = new liulan (); for (int x = 0; x < this.MdiChildren.Length; x+) Form tempChild = (Form)this.MdiChildrenx; tempChild.Close(); c.MdiParent = this; c.Show(); liulan1 c1; private void 浏览ToolStripMenuItem1_Click(object sender, EventArgs e) if (c1 = null | c1.IsDisposed) c1 = new liulan1(); for (int x = 0; x < this.MdiChildren.Length; x+) Form tempChild = (Form)this.MdiChildrenx; tempChild.Close(); c1.MdiParent = this; c1.Show(); tianjia3 a1; private void 修改ToolStripMenuItem1_Click(object sender, EventArgs e) if (a1 = null | a.IsDisposed) a1 = new tianjia3 (); for (int x = 0; x < this.MdiChildren.Length; x+) Form tempChild = (Form)this.MdiChildrenx; tempChild.Close(); a1.MdiParent = this; a1.Show(); Jiaoshi:liulan1.cs: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 WindowsFormsApplication1hanqifang.jiaoshi public partial class liulan1 : Form public liulan1() InitializeComponent(); public static string strConn = "Data Source=(local);Initial Catalog=hanqifang;Integrated Security=True" private void liulan1_Load(object sender, EventArgs e) showinf(); private void showinf() using (SqlConnection con = new SqlConnection(strConn) if (con.State = ConnectionState.Closed) con.Open(); ; try string sql = "select jiaoshibianma as 编号,jiaoshixingming as 教师姓名,jiaoshixingbie as 教师性别 from jiaoshi order by jiaoshibianma" SqlDataAdapter adp = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); ds.Clear(); adp.Fill(ds, "Job"); this.dataGridView1.DataSource = ds.Tables0.DefaultView; catch (Exception ex) MessageBox.Show("错误:" + ex.Message, "错误提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); finally if (con.State = ConnectionState.Open) con.Close(); con.Dispose(); xiugai2 frmModifyDepart; private void btnUpdate_Click(object sender, EventArgs e) if (this.dataGridView1.CurrentCell != null) frmModifyDepart = new xiugai2(); frmModifyDepart.Tag = this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim(); /frmModifyDepart.txtDName.Text = this.dgvDepartInfo1, this.dgvDepartInfo.CurrentCell.RowIndex.Value.ToString().Trim(); /frmModifyDepart.txtDLeader.Text = this.dgvDepartInfo2, this.dgvDepartInfo.CurrentCell.RowIndex.Value.ToString().Trim(); /frmModifyDepart.txtDReark.Text = this.dgvDepartInfo3, this.dgvDepartInfo.CurrentCell.RowIndex.Value.ToString().Trim(); frmModifyDepart.StartPosition = FormStartPosition.CenterParent; frmModifyDepart.ShowDialog(); if (frmModifyDepart.DialogResult = DialogResult.OK) showinf(); private void btnDelete_Click(object sender, EventArgs e) using (SqlConnection con = new SqlConnection(strConn) if (con.State = ConnectionState.Closed) con.Open(); ; try if (this.dataGridView1.CurrentCell != null) string sql = "select kechengmingcheng from dbo.kecheng wherekechengbianma =" + this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim() + " and kechengbianma not in (select distinct kechengbianma from dbo.kecheng inner join dbo.jiaoshi on dbo.kecheng.kechengbianma=dbo.jiaoshi.kechengbianma)" SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader dr; dr = cmd.ExecuteReader(); if (!dr.Read() MessageBox.Show("删除院系'" + this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim() + "'失败!", "提示"); dr.Close(); else dr.Close(); sql = "delete from dbo.kecheng where kechengbianma=" + this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim() + " and kechengbianma not in (select distinct kechengbianma from dbo.jiaoshi)" cmd.CommandText = sql; cmd.ExecuteNonQuery(); MessageBox.Show("删除院系'" + this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim() + "'成功", "提示"); catch (Exception ex) MessageBox.Show("错误:" + ex.Message, "错误提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); finally if (con.State = ConnectionState.Open) con.Close(); con.Dispose(); showinf(); private void btnExit_Click(object sender, EventArgs e) this.Close(); yuanxi liulan.cs: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 WindowsFormsApplication1hanqifang.yuanxi public partial class liulan : Form public liulan() InitializeComponent(); public static string strConn = "Data Source=(local);Initial Catalog=hanqifang;Integrated Security=True" private void liulan_Load(object sender, EventArgs e) showinf(); private void showinf() using (SqlConnection con = new SqlConnection(strConn) if (con.State = ConnectionState.Closed) con.Open(); ; try string sql = "select yuanxibianma as 编号,yuanximingcheng as 院系名称 from dbo.yuanxi order by yuanxibianma" SqlDataAdapter adp = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); ds.Clear(); adp.Fill(ds, "Job"); this.dataGridView1.DataSource = ds.Tables0.DefaultView; catch (Exception ex) MessageBox.Show("错误:" + ex.Message, "错误提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); finally if (con.State = ConnectionState.Open) con.Close(); con.Dispose(); xiugai frmModifyJob; private void btnUpdate_Click(object sender, EventArgs e) if (this.dataGridView1.CurrentCell != null) frmModifyJob = new xiugai(); frmModifyJob.Tag = this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim(); /frmModifyJob.dataGridView1.Text = this.dataGridView11, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim(); frmModifyJob.StartPosition = FormStartPosition.CenterParent; frmModifyJob.ShowDialog(); if (frmModifyJob.DialogResult = DialogResult.OK) showinf(); private void btnDelete_Click(object sender, EventArgs e) using (SqlConnection con = new SqlConnection(strConn) if (con.State = ConnectionState.Closed) con.Open(); ; try if (this.dataGridView1.CurrentCell != null) string sql = "select yuanximingcheng from dbo.yuanxi where yuanxibianma=" + this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim() + " and yuanxibianma not in (select distinct dbo.yuanxi.yuanxibianma from dbo.yuanxi inner join dbo.jiaoshi on dbo.jiaoshi.yuanximingcheng=dbo.yuanxi.yuanximingcheng)" SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader dr; dr = cmd.ExecuteReader(); if (!dr.Read() MessageBox.Show("删除院系'" + this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim() + "'失败,请先删除与此院系相关的教师!", "提示"); dr.Close(); else dr.Close(); sql = "delete from dbo.yuanxi where yuanxibianma=" + this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim() + " and yuanximingcheng not in (select yuanximingcheng from dbo.yuanxi)" cmd.CommandText = sql; cmd.ExecuteNonQuery(); MessageBox.Show("删除院系'" + this.dataGridView10, this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim() + "'成功", "提示"); catch (Exception ex) MessageBox.Show("错误:" + ex.Message, "错误提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); finally if (con.State = ConnectionState.Open)