《C#.NET程序设计》课程设计说明书-教师管理系统

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

《C#.N E T程序设计》设计说明书
教师管理系统
一、课程设计目的
通过完成从用户需求分析、数据库设计、目录结构与通用模块、管理主界面设计及各个具体管理模块设计到上机编程、调试和应用等全过程,进一步了解和掌握C#.NET程序设计技术。

二、课程设计任务与要求
1. 基本要求:
1)要求利用C#的编程思想以及组件开发原理来完成系统的设计;
2)突出C#语言与其它语言不同点(即体现C#的高级功能,如属性概念、接口、事件、委托等);
3)体现可视化编程基本思想,如系统带有菜单、工具栏、状态栏以及一些常用的高级控件。

2. 创新要求:
在基本要求达到后,可进行创新设计。

完成该系统数据库设计;实现相应信息的添加、删除、删除、查看等功能。

三、需求分析
在设计数据库结构时,应尽量可能满足用户所提出的各项要求,同时避免冗余数据的产生。

由于教师管理系统中需要采集大量的信息,包括院系信息、课程信息、教师信息、收入信息等,如果不能有效合理地组织数据表的结构以及每张表所含的字段,那么在后期进行数据整理及汇总时,将增加开发人员的工作难度和工作量。

根据教师基本信息及相关特点,可以总结出一下规律:
●一个院系包括一名或多名教师
●一名教师可以教多门课程
●每名教师都有不同的教师编码
●每名教师都有自己对应的月收入
●一个角色对应一个或多个用户
四、概要设计
1. 系统功能模块划分
2. 数据库逻辑结构设计
系统数据库名称为hanqifang,数据库中包括:(1)院系信息表[dbo.yuanxi];(2)教师表信息[dbo.jiaoshi];(3)课程信息表[dbo.kecheng].
下面列出各个表的数据结构
院系信息表
教师管理系统
院系设置
课程设置
教师设置
收入设置
添加院系
浏览院系
修改院系
添加课程
删除课程
修改课程
添加教师
修改教师
浏览教师
添加收入
修改收入
教师信息表
课程信息表
五、详细设计
主界面设计
主界面设计的作用就是显示本系统所有的功能菜单项,本且把用户经常用到的功能设计成菜单项,以方便用户操作,然后当用户单击相应的菜单项或菜单按钮时,打开对应的模块窗口。

本系统的主界面如图。

由图可知“院系”菜单下有子菜单,包括“修改”和“添加”。

主界面编码:
zhuyemian.cs
using System;
using System.Collections.Generic;
using ponentModel;
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.MdiChildren[x];
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.MdiChildren[x];
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.MdiChildren[x];
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.MdiChildren[x];
tempChild.Close();
}
a1.MdiParent = this;
a1.Show();
}
}
}
}
Jiaoshi:liulan1.cs:
using System;
using System.Collections.Generic;
using ponentModel;
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.Tables[0].DefaultView;
}
catch (Exception ex)
{
MessageBox.Show("错误:"+ ex.Message, "错误提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
finally
{
if (con.State == ConnectionState.Open)
{
con.Close();
con.Dispose();
}
}
}
}
xiugai2frmModifyDepart;
private void btnUpdate_Click(object sender, EventArgs e)
{
if (this.dataGridView1.CurrentCell != null)
{
frmModifyDepart = new xiugai2();
frmModifyDepart.Tag = this.dataGridView1[0, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim();
//frmModifyDepart.txtDName.Text = this.dgvDepartInfo[1, this.dgvDepartInfo.CurrentCell.RowIndex].Value.ToString().Trim();
//frmModifyDepart.txtDLeader.Text = this.dgvDepartInfo[2, this.dgvDepartInfo.CurrentCell.RowIndex].Value.ToString().Trim();
//frmModifyDepart.txtDReark.Text = this.dgvDepartInfo[3, 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.dataGridView1[0, 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.dataGridView1[0, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim() + "'失败!", "提示");
dr.Close();
}
else
{
dr.Close();
sql = "delete from dbo.kecheng where kechengbianma="+ this.dataGridView1[0, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim() + " and kechengbianma not in (select distinct kechengbianma from dbo.jiaoshi)";
mandText = sql;
cmd.ExecuteNonQuery();
MessageBox.Show("删除院系'"+ this.dataGridView1[0, 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 ponentModel;
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.Tables[0].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.dataGridView1.Text = this.dataGridView1[1, 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.dataGridView1[0, 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.dataGridView1[0, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim() + "'失败,请先删除与此院系相关的教师!", "提示");
dr.Close();
}
else
{
dr.Close();
sql = "delete from dbo.yuanxi where yuanxibianma="+ this.dataGridView1[0, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim() + " and yuanximingcheng not in (select yuanximingcheng from dbo.yuanxi)";
mandText = sql;
cmd.ExecuteNonQuery();
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();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}
xiugai.cs:
using System;
using System.Collections.Generic;
using ponentModel;
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 xiugai : Form
{
public xiugai()
{
InitializeComponent();
}
private void label3_Click(object sender, EventArgs e)
{
public static string strConn = "Data Source=(local);Initial Catalog=hanqifang;Integrated Security=True";
private void tnOk_Click(object sender, EventArgs e)
{
if (this.textBox1.Text.Trim() == "" || this.textBox2.Text.Trim() == "")
MessageBox.Show("请输入完整信息!", "提示", 0);
else
{
using (SqlConnection con = new SqlConnection(strConn))
{
if (con.State == ConnectionState.Closed)
{
con.Open();
};
try
{
SqlCommand cmd = new SqlCommand("select * from dbo.yuanxi where yuanximingcheng='"+ textBox2.Text.Trim() + "' and yuanxibianma<>" + this.Tag.ToString().Trim(), con);
if (cmd.ExecuteScalar() != null)
MessageBox.Show("学院名称发生重复,请重新输入!", "提示", 0);
else
{
string sql = "update dbo.yuanxi set yuanximingcheng='"+ textBox2.Text.Trim() + "' where yuanxibianma=" + this.Tag.ToString().Trim();
mandText = sql;
cmd.ExecuteNonQuery();
MessageBox.Show("学院信息修改成功!", "提示", 0);
}
}
catch (Exception ex)
{
MessageBox.Show("错误:"+ ex.Message, "错误提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
finally
{
if (con.State == ConnectionState.Open)
{
con.Close();
con.Dispose();
}
}
}
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void xiugai_Load(object sender, EventArgs e)
{
this.StartPosition = FormStartPosition.CenterParent;
this .textBox1 .Text = this.Tag.ToString().Trim();
}
}
}
tianjia.cs:
using System;
using System.Collections.Generic;
using ponentModel;
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 tianjia : Form
{
public static string strConn = "Data Source=(local);Initial Catalog=hanqifang;Integrated Security=True";
public tianjia()
{
InitializeComponent();
}
private void tianjia_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
}
private void btnOk_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim() == "" )
MessageBox.Show("请输入工种名称和描述!", "提示", 0);
else
{
using (SqlConnection con = new SqlConnection(strConn))
{
if (con.State == ConnectionState.Closed)
{
con.Open();
};
try
{
SqlCommand cmd = new SqlCommand("select * from dbo.yuanxi where yuanximingcheng='"+ textBox1.Text.Trim() + "'", con);
if (cmd.ExecuteScalar() != null)
MessageBox.Show("院系名称,请重新输入!", "提示", 0);
else
{
string sql = "insert into dbo.yuanxi (yuanximingcheng) values ('" + textBox1.Text.Trim() + "')";
mandText = sql;
cmd.ExecuteNonQuery();
MessageBox.Show("添加院系信息成功!", "提示", 0);
textBox1.Clear();
}
}
catch (Exception ex)
{
MessageBox.Show("错误:"+ ex.Message, "错误提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
finally
{
if (con.State == ConnectionState.Open)
{
con.Close();
con.Dispose();
}
}
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
运行界面:
六、课程设计总结
通过本次实验,基本掌握用C#思想来进行程序设计,知道做一个大一点的系统应该从何
的知识也结合在其中啦。

通过老师的详细讲解在一些难点地方有了更深的理解,同时也知道一些模块是可以套用的。

对类和名称有了更深入的了解。

但对于一些命名空间等还不是十分熟悉,只做了基本了解。

但还是有些欠缺,例如有些模块的功能有重复,而一些功能实现的不明确。

在做题过程中还是总犯一些小错误,在今后的编程中我会及时克服。

但总的来说自己还是有进步的,对简单的编程也有了一些信心,今后会更加努力的学习,克服这些缺点。

相关文档
最新文档