c#报刊订阅管理系统(数据库课程设计报告)_第1页
c#报刊订阅管理系统(数据库课程设计报告)_第2页
c#报刊订阅管理系统(数据库课程设计报告)_第3页
c#报刊订阅管理系统(数据库课程设计报告)_第4页
c#报刊订阅管理系统(数据库课程设计报告)_第5页
已阅读5页,还剩40页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

课 程 设 计 课程设计名称: 数据库应用系统课程设计 专 业 班 级 : 学 生 姓 名 : 马飞扬 学 号 : 指 导 教 师 : 课程设计时间: 2011-12-19 至 2011-12-30 计算机科学与技术 专业课程设计任务书 学生姓名 马飞扬 专业班级 学号 题 目 报刊订阅管理系统 课题性质 其它 课题来源 自拟课题 指导教师 同组姓名 无 主要内容 人们在部门单位中一直以来都是使用传统人工方式管理本单位 的报刊订阅,这种管理方式存在着许多缺点,而且时间一长,将产 生大量的文件和数据,难于归类整理,这对于查找、更新和维护都 带来了不少的困难。课题要求设计并实现一个报刊订阅管理系统, 能够通过计算机和数据库对本单位的报刊订阅进行管理。一个单位 可指定一个或多个管理员,普通用户注册获得一个账号后就可以订 阅报刊以及在自己的权限范围内进行相关的操作。功能应包括:登 录对角色的判断,管理员注册新用户,查看、更新报刊信息,查询、 统计订阅信息,维护数据,管理用户,普通用户修改个人信息,查 询、统计、增加订阅等模块。界面设计相对友好,方便用户的操作。 任务要求 综合运用所学的数据库基本知识,并能通过查阅相关文献材料, 独立完成该课题的设计开发工作。要求根据本课题设计出合理的数 据结构,并实现报刊订阅管理系统中,登录对角色的判断,管理员注 册新用户,管理员查看、更新报刊信息,查询、统计订阅信息,维 护数据,管理用户,普通用户修改个人信息,查询、统计、增加订 阅等功能模块。 参考文献 【1】尹志宇、郭晴 数据库原理与应用教程 清华大学出版社 2010.5 【2】 (美)厄尔曼 数据库系统基础教程 机械工业出版社 2009.8 【3】郑阿奇 sql server2005 教程 电子工业出版社 2011.2 【4】明日科技 c#开发技术大全 人民邮电出版社 2011.11 【5】 (美)米凯利斯 c#本质论 人民邮电出版社 2010.9 3 审查意见 指导教师签字: 教研室主任签字: 年 月 日 报刊订阅管理系统 1:概述 人们在部门单位中一直以来都是使用传统人工方式管理本单位的报刊订阅, 这种管理方式存在着许多缺点,譬如:效率低、保密性差,而且时间一长,将 产生大量的文件和数据,难于归类整理,这对于查找、更新和维护都带来了不 少的困难。 本学期学习了 c#、数据库以及基于 c#的 windows 应用程序开发以后,在本 次课程设计中,便利用这些知识点,实现一个报刊订阅管理系统,能够通过计 算机和数据库对本单位的报刊订阅进行管理,实现智能化管理,克服传统人工 管理方式的缺点以及弊端。在报刊订阅管理系统中,要实现:一个单位可指定 一个或多个管理员,管理员可以注册新用户,查看、更新报刊信息,查询、统 计订阅信息,系统维护,管理用户;普通用户通过注册获得一个账号后就可以 订阅报刊以及在自己的权限范围内进行查询、统计订阅以及修改个人信息等相 关的操作。功能应包括:登录对角色的判断,管理员注册新用户,管理员查看、 更新报刊信息,管理员查询、统计订阅信息,管理员维护数据、管理员管理用 户、普通用户修改个人信息、普通用户查询、统计、增加订阅等功能模块。界 面设计要相对友好,方便用户的操作。 2:需求分析 设计报刊订阅管理系统,要能够通过计算机和数据库对本单位的报刊订阅 进行管理,实现智能化管理,克服传统人工管理方式的缺点以及弊端。要实现: 一个单位可指定一个或多个管理员,管理员可以注册新用户,查看、更新报刊 信息,查询、统计订阅信息,系统维护,管理用户;普通用户通过注册获得一 个账号后就可以订阅报刊以及在自己的权限范围内进行查询、统计订阅以及修 改个人信息等相关的操作。具体功能应包括:用户登录,管理员注册用户(包 括普通用户、管理员),更新报刊(包括查看、录入、修改、删除),查询订 阅(按用户、报刊、部门),统计订阅(按用户、报刊、部门),系统维护 (备份、还原数据)、管理用户(查询、修改、删除),普通用户修改个人信 息,增加、删除、修改、查询、统计订阅信息等功能模块。界面设计要相对友 好,方便用户的操作。系统流程图如图 1: 图 1: 用户登录 管理员 普通用户 注册用户 更新报刊 查询订阅 统计订阅 系统维护 管理用户 个人信息 增加订阅 查询订阅 统计订阅 查询、修 改 普用用户、管理员 查看、录入、修改、删除 按用户、报刊、部门 按用户、报刊、部门 备份、还原数据 查询、修改、删除 5 3:概念结构设计 在报刊订阅管理系统中,共涉及到 3 个实体:报刊、部门、用户。用户包 括普通用户、管理员,每个用户都唯一属于一个部门,每个部门可包括多个用 户,它们是多对一的关系。普通用户可以订阅多份报刊,一份报刊可被多个用 户订阅,属于多对多的关系。E-R 图如图 2。 图 2: 报刊 部门 用户 普通用户 报刊编号 管理员 。 。 。 分类名称 订 阅 部门编号 部门名称 属 于 用户账号 。 。 。 身份证号 用户账号 用 户 账 号 报 刊 编 号 7 4:逻辑结构设计 设计数据库共有 7 个关系模式,分别为: 用户(用户账号,姓名,密码,用户类别)用户账号为主键,决定因素为主键 自身或包含主键,满足 BC 范式。 普通用户 1(用户账号,联系电话,联系地址,部门编号)用户账号为主键, 部门编号为外键,决定因素为主键自身或包含主键,满足 BC 范式。 普通用户 2(用户账号,身份证号)用户账号为主键,决定因素为主键自身或 包含主键,满足 BC 范式。 部门(部门编号,部门名称)部门编号为主键,决定因素为主键自身或包含主 键,满足 BC 范式。 报刊信息(报刊编号,报刊名称,出版报社,出版周期,季度报价,内容介绍, 分类编号)报刊编号为主键,分类编号为外键,决定因素为主键自身或包含主 键,满足 BC 范式。 报刊类别(分类编号,分类名称)分类编号为主键,决定因素为主键自身或包 含主键,满足 BC 范式。 订单(用户编号,报刊编号,订阅份数,订阅月数)用户编号、报刊编号为主 键,决定因素为主键自身或包含主键,满足 BC 范式。 5:源代码及系统截图 源代码: (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.IO; using System.Data.SqlClient; namespace newspaperorder public partial class login : Form private int childFormNumber = 0; public login() InitializeComponent(); private void ShowNewForm(object sender, EventArgs e) Form childForm = new Form(); childForm.MdiParent = this; childForm.Text = “Window “ + childFormNumber+; childForm.Show(); private void OpenFile(object sender, EventArgs e) OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = “Text Files (*.txt)|*.txt|All Files (*.*)|*.*“; if (openFileDialog.ShowDialog(this) = DialogResult.OK) string FileName = openFileDialog.FileName; private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); saveFileDialog.Filter = “Text Files (*.txt)|*.txt|All Files (*.*)|*.*“; if (saveFileDialog.ShowDialog(this) = DialogResult.OK) string FileName = saveFileDialog.FileName; 9 private void ExitToolsStripMenuItem_Click(object sender, EventArgs e) this.Close(); private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.Cascade); private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.TileVertical); private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.TileHorizontal); private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.ArrangeIcons); private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e) foreach (Form childForm in MdiChildren) childForm.Close(); private void button2_Click(object sender, EventArgs e) this.textBox1.Clear(); this.textBox2.Clear(); private void notifyicon1_click(object sender, System.Windows.Forms.MouseEventArgs e) if (e.Button = System.Windows.Forms.MouseButtons.Right) if (this != null private void button1_Click(object sender, EventArgs e) string usernum = null;usernum=this.textBox1.Text.ToString(); string userpass = null;userpass=this.textBox2.Text.ToString(); if (usernum.Equals(“) | userpass.Equals(“) MessageBox.Show(“请?输?入?账?号?和密码?“); else string strCon = “server=(local);Integrated Security=true;database=newspaperorder;uid=sa;pwd=111111“; SqlConnection MyCon = new SqlConnection(strCon); try MyCon.Open(); string sql = “select * from 用?户 where 用?户账?号?=“ + usernum + “ and 密码?=“ + userpass + “ “; SqlCommand MyCommand = new SqlCommand(sql, MyCon); SqlDataReader mydatareader = MyCommand.ExecuteReader(); if (mydatareader.HasRows) mydatareader.Read(); string power = mydatareader.GetString(3); if (power.StartsWith(“管理员“) this.Hide(); this.admin = new adminform(usernum); if (power.StartsWith(“普?通 用?户“) this.Hide(); mon = new commonform(usernum); else 11 MessageBox.Show(“账?号?或密码?不?正y确?“); MyCon.Close(); catch (Exception e1) MessageBox.Show(e1.Message); private void toolStripMenuItem1_Click(object sender, EventArgs e) this.Dispose(); (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 newspaperorder public partial class adminform : Form private int childFormNumber = 0; public adminform(string usernum) this.Visible = true; this.usernum = usernum; InitializeComponent(); private void ShowNewForm(object sender, EventArgs e) Form childForm = new Form(); childForm.MdiParent = this; childForm.Text = “Window “ + childFormNumber+; childForm.Show(); private void OpenFile(object sender, EventArgs e) OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = “Text Files (*.txt)|*.txt|All Files (*.*)|*.*“; if (openFileDialog.ShowDialog(this) = DialogResult.OK) string FileName = openFileDialog.FileName; private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); saveFileDialog.Filter = “Text Files (*.txt)|*.txt|All Files (*.*)|*.*“; if (saveFileDialog.ShowDialog(this) = DialogResult.OK) string FileName = saveFileDialog.FileName; private void ExitToolsStripMenuItem_Click(object sender, EventArgs e) this.Close(); private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.Cascade); private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.TileVertical); private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.TileHorizontal); 13 private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.ArrangeIcons); private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e) foreach (Form childForm in MdiChildren) childForm.Close(); private void toolStripMenuItem5_Click(object sender, EventArgs e) if (this.userselect1 = null) this.userselect1 = new userselect(); this.userselect1.TopMost = true; else if (this.userselect1.WindowState = FormWindowState.Minimized) this.userselect1.WindowState = FormWindowState.Normal; this.userselect1.display(); this.userselect1.TopMost = true; this.userselect1.Show(); private void 管理员ToolStripMenuItem_Click(object sender, EventArgs e) if (this.add1 = null) this.add1 = new addadmin(); this.add1.TopMost = true; else this.add1.Show(); this.add1.TopMost = true; private void 普?通 用?户ToolStripMenuItem_Click(object sender, EventArgs e) if (this.add2 = null) this.add2 = new addcommon(); this.add2.TopMost = true; else this.add2.Show(); this.add2.TopMost = true; private void toolStripMenuItem3_Click(object sender, EventArgs e) if (this.addnewspaper1 = null) this.addnewspaper1 = new addnewspaper(); this.addnewspaper1.TopMost = true; else this.addnewspaper1.Show(); this.addnewspaper1.TopMost = true; private void toolStripMenuItem6_Click(object sender, EventArgs e) if (this.newspaperselect1 = null) this.newspaperselect1 = new newspaperselect(); this.newspaperselect1.TopMost = true; else if (this.newspaperselect1.WindowState = FormWindowState.Minimized) this.newspaperselect1.WindowState = FormWindowState.Normal; 15 this.newspaperselect1.display(); this.newspaperselect1.Show(); this.newspaperselect1.TopMost = true; private void toolStripMenuItem7_Click(object sender, EventArgs e) if (this.departselect1 = null) this.departselect1 = new departselect(); this.departselect1.TopMost = true; else if (this.departselect1.WindowState = FormWindowState.Minimized) this.departselect1.WindowState = FormWindowState.Normal; this.departselect1.display(); this.departselect1.Show(); this.departselect1.TopMost = true; private void 按恪用?户ToolStripMenuItem_Click(object sender, EventArgs e) if (this.countuser1 = null) this.countuser1 = new countuser(); this.countuser1.TopMost = true; else this.countuser1.display(); this.countuser1.Show(); this.countuser1.TopMost = true; private void 按恪报馈刊ToolStripMenuItem_Click(object sender, EventArgs e) if (this.countnewspaper1 = null) this.countnewspaper1 = new countnewspaper(); this.countnewspaper1.TopMost = true; else this.countnewspaper1.display(); this.countnewspaper1.Show(); this.countnewspaper1.TopMost = true; private void 按恪部?门?ToolStripMenuItem_Click(object sender, EventArgs e) if (this.countdepart1 = null) this.countdepart1 = new countdepart(); this.countdepart1.TopMost = true; else this.countdepart1.display(); this.countdepart1.Show(); this.countdepart1.TopMost = true; private void ToolStripMenuItem_Click(object sender, EventArgs e) string strCon = “server=(local);Integrated Security=true;database=newspaperorder;uid=sa;pwd=111111“; SqlConnection MyCon = new SqlConnection(strCon); try MyCon.Open(); string sql = “backup database newspaperorder to disk=G:databasedata2newspaperbackup.Bak with init“; SqlCommand MyCommand = new SqlCommand(sql, MyCon); MyCommand.ExecuteNonQuery(); MyCon.Close(); MessageBox.Show(“已?成功|备?份 数簓据Y库a!“); catch (Exception e1) MessageBox.Show(e1.Message); private void 数簓据Y恢?复ToolStripMenuItem_Click(object sender, EventArgs e) 17 string strCon = “server=(local);Integrated Security=true;database=newspaperorder;uid=sa;pwd=111111“; SqlConnection MyCon = new SqlConnection(strCon); try MyCon.Open(); string sql = “use master restore database newspaperorder from disk=G:databasedata2newspaperbackup.Bak with replace“; SqlCommand MyCommand = new SqlCommand(sql, MyCon); MyCommand.ExecuteNonQuery(); MyCon.Close(); MessageBox.Show(“已?成功|恢?复数簓据Y库a!“); catch (Exception e1) MessageBox.Show(e1.Message); private void toolStripMenuItem9_Click(object sender, EventArgs e) if (this.adminalter1= null) this.adminalter1 = new adminalter(this.usernum); this.adminalter1.TopMost = true; else this.adminalter1.Show(); this.adminalter1.TopMost = true; private void toolStripMenuItem11_Click(object sender, EventArgs e) if (this.adminscannewspaper1 = null) this.adminscannewspaper1 = new adminscannewspaper(); this.adminscannewspaper1.TopMost = true; else this.adminscannewspaper1.display(); this.adminscannewspaper1.Show(); this.adminscannewspaper1.TopMost = true; private void toolStripMenuItem12_Click(object sender, EventArgs e) if (this.admindelnewspaper1 = null) this.admindelnewspaper1 = new admindelnewspaper(); this.admindelnewspaper1.TopMost = true; else this.admindelnewspaper1.Show(); this.admindelnewspaper1.TopMost = true; (3)普通用户界面的逻辑实现 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 newspaperorder public partial class commonform : Form private int childFormNumber = 0; public commonform(string usernum) this.usernum = usernum; this.Visible = true; InitializeComponent(); private void ShowNewForm(object sender, EventArgs e) Form childForm = new Form(); childForm.MdiParent = this; 19 childForm.Text = “Window “ + childFormNumber+; childForm.Show(); private void OpenFile(object sender, EventArgs e) OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = “Text Files (*.txt)|*.txt|All Files (*.*)|*.*“; if (openFileDialog.ShowDialog(this) = DialogResult.OK) string FileName = openFileDialog.FileName; private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); saveFileDialog.Filter = “Text Files (*.txt)|*.txt|All Files (*.*)|*.*“; if (saveFileDialog.ShowDialog(this) = DialogResult.OK) string FileName = saveFileDialog.FileName; private void ExitToolsStripMenuItem_Click(object sender, EventArgs e) this.Close(); private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.Cascade); private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.TileVertical); private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.TileHorizontal); private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.ArrangeIcons); private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e) foreach (Form childForm in MdiChildren) childForm.Close(); private void toolStripMenuItem3_Click(object sender, EventArgs e) if (this.alter1 = null) this.alter1 = new commonalter(this.usernum); this.alter1.TopMost = true; else this.alter1.Show(); this.alter1.TopMost = true; private void toolStripMenuItem5_Click(object sender, EventArgs e) if (this.addnewspaper1 = null) this.addnewspaper1 = new commonaddnewspaper(this.usernum); this.addnewspaper1.TopMost = true; else this.addnewspaper1.display(); this.addnewspaper1.Show(); this.addnewspaper1.TopMost = true; 21 private void toolStripMenuItem7_Click(object sender, EventArgs e) if (monselect1 = null) monselect1 = new commonselect(this.usernum); monselect1.TopMost = true; else monselect1.Show(); monselect1.TopMost = true; private void toolStripMenuItem9_Click(object sender, EventArgs e) string strCon = “server=(local);Integrated Security=true;database=newspaperorder;uid=sa;pwd=111111“; SqlConnection MyCon = new SqlConnection(strCon); try MyCon.Open(); string sql = “select count(*) as 种?类?sum(订?阅?份 数簓) as 份 数簓 from 订?单蹋?where 用?户编括号?=“ +this.usernum+ “; SqlCommand MyCommand = new SqlCommand(sql, MyCon); SqlDataReader myreader = MyCommand.ExecuteReader(); myreader.Read(); if (!myreader.IsDBNull(1) string count1 = myreader.GetInt32(0).ToString(); string count2 = myreader.GetInt32(1).ToString(); MessageBox.Show(“您订?阅?了?:阰“ + count1 + “种?报馈刊 共2“ + count2 + “份“); else MessageBox.Show(“您没?有瓺订?阅?!“); MyCon.Close(); catch (Exception e1) MessageBox.Show(e1.Message); (4)管理员注册用户(管理员) private void button1_Click(object sender, EventArgs e) string usernum = this.textBox1.Text.ToString(); string username = this.textBox2.Text.ToString(); string userpass = this.textBox3.Text.ToString(); string usertype = this.textBox4.Text.ToString(); if (usernum.Equals(“) | userpass.Equals(“)|username.Equals(“) MessageBox.Show(“请?输?入?账?号?信?息!?“); else string strCon = “server=(local);Integrated Security=true;database=newspaperorder;uid=sa;pwd=111111“; SqlConnection MyCon = new SqlConnection(strCon); try MyCon.Open(); string sql =“insert into 用?户(用?户账?号?,姓?名?,密码?,用?户类 别纄) values(“ + usernum + “,“ + username + “,“ + userpass + “,“ + usertype + “) “; SqlCommand MyCommand = new SqlCommand(sql, MyCon); MyCommand.ExecuteNonQuery(); MessageBox.Show(“已?正y确注痢册管理员信?息!?“); catch (Exception e1) MessageBox.Show(e1.Message); (5)管理员注册用户(普通用户) private void button1_Click(object sender, EventArgs e) string usernum = this.textBox1.Text.ToString(); string userid = this.textBox2.Text.ToString(); string userphone = this.textBox3.Text.ToString(); string useraddress = this.textBox4.Text.ToString(); string userdepartnum = this.textBox5.Text.ToString(); string userpass = this.textBox6.Text.ToString(); string username = this.textBox7.Text.ToString();string usertype=“普?通 用?户“; if (usernum.Equals(“) | userid.Equals(“) | userphone.Equals(“) | useraddre

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论