欢迎来到得力文库 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
得力文库 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    设备管理系统程序设计.docx

    • 资源ID:44033414       资源大小:1.14MB        全文页数:28页
    • 资源格式: DOCX        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    设备管理系统程序设计.docx

    C#程序设计大作业题 目: 设备管理系统 专 业: 计算机科学与技术s 学 号: 121096143 姓 名: 朱 晓 敏 完成日期: 2012/11/6 目 录1 前言22 需求分析22.1要求22.2任务22.3运行环境22.4开发工具23 概要设计与详细设计33.1系统流程图33.2数据库设计43.2.1建立数据字典43.2.2数据库详细设计44 编码与实现54.1分析54.2具体代码实现74.3界面实现165 课程设计总结24参考文献25评语及成绩01 前言设计一个设备管理系统,该系统主要针对设备管理员。系统首先要求用户登录,用户必须输入正确的用户名和密码;系统主界面包括设备查询功能及数据维护功能,设备查询功能是按一定的条件查询所需要的设备信息,数据维护主要是通过增加或删除来修改数据。2 需求分析2.1要求(1)用Csharp语言实现程序设计;(2)采用.NET开发工具来设计主窗体和子窗体等;(3)画出系统模块的流程图;(4)完成数据库的设计;(5)界面友好(良好的人机互交),程序要有注释。2.2任务(1)设计一个登陆窗体和主窗体,7个子窗体来显示相关信息;(2)管理员必须输入正确的用户名和密码,才能进入主窗体进行相关操作;(3)画出所有模块的流程图;(4)完成数据库的设计;(5)编写代码;(6)程序分析与调试。2.3运行环境(1)WINDOWS2000/XP系统(2)Visual Studio 2005编译环境2.4开发工具 C#: C#(C Sharp)是微软为NET Framework量身订做的程序语言,C#拥有C/C+的强大功能以及Visual Basic简易使用的特性,是第一个组件导向(Component-oriented)的程序语言,和C+与Java一样亦为对象导向(object-oriented)程序语言。3 概要设计与详细设计3.1系统流程图首先要有一个登录模块对登录用户进行验证,如果验证成功则进入系统的主窗体,登录主窗体之后管理员以操作所有的功能:查询、修改、增加设备信息、辅助工具、退出。开始用户名及密码选择操作类型查询设备信息修改设备信息添加设备信息删除设备信息设备信息表退出NY图3.1 系统流程图3.2数据库设计3.2.1建立数据字典在开发设备管理系统之前,分析了改系统的数据量。选择Microsoft SQL Server2005数据库存储这些信息,数据库命名为MyDevice,在数据库中创建了2个数据表用于不同的信息。1.设备管理员数据字典 名字:设备管理员表(User)描述:记录管理员的具体详细信息定义:设备管理员表=用户编号+用户名+密码 位置:设备管理数据库2.设备数据字典名字:设备信息表(equipment)描述:记录设备的具体详细信息定义:设备信息表=设备编号+设备名称+设备数量+设备价格 位置:设备管理数据库3.2.2数据库详细设计表1 User表结构列名数据类型 说明userIdint用户编号,主键,标识列,表示增量1,标识种子1UserNamenvarchar(50)用户名,非空passwordnvarchar(50)密码,非空表2 equipment表结构列名数据类型 说明idint设备编号,主键,标识列,表示增量1,标识种子1namenvarchar(50)设备名称,非空pricemoney设备名称,非空countint设备数量,非空4 编码与实现4.1分析(1)登陆界面的设计打开Visual Studio 2005,新建一个名为DeviceSystem项目,然后打开一个窗体并命名为userlogin.cs。在此窗体中添加2个标签(用户名和密码)、2个按钮(确定和取消)和2个textBox等,如图所示 图4.1 登陆窗体(2)系统主窗体的设计添加窗体并命名为frmMain.cs,在此窗体添加一个MenuStrip控件,一个 ToolStrip控件及3个按钮,一个Time控件,toolStripStatus控件并分别设置各属性,如图所示 图4.2 系统主窗体(3)子窗体的设计添加4个窗体并依此命名为frmselecName.cs、frmselecPrice.cs、frmDataMaint.cs、frmDeletedevice.cs并分别添加工具控件及设置各属性,如图所示图4.3 按名称查询窗图4.4 按价格查询窗体图4.5 数据维护窗体4.2具体代码实现1.登录窗体frmlogin.csusing System;using System.Configuration;namespace DeviceSystem private void btnYes_Click(object sender, EventArgs e) string userName = txtName.Text; string password = txtPwd.Text; string cons = ConfigurationManager.ConnectionStrings"DeviceSystem.Properties.Settings.MyDeviceConnectionString".ConnectionString; SqlConnection connection = new SqlConnection(cons); /获取用户名和密码匹配的行的数量的SQL语句 string sql=String.Format("select count(*) from User where username='0'and password='1'",userName,password); try connection.Open(); /打开数据库连接 SqlCommand command = new SqlCommand(sql,connection); /创建Command对象 int num = (int)command.ExecuteScalar(); /执行查询语句,返回匹配的行数 if (num > 0) /如果有匹配的行,则表明用户名和密码正确 MessageBox.Show("欢迎进入设备管理系统!", "登录成功", MessageBoxButtons.OK, MessageBoxIcon.Information); frmMain mainForm=new frmMain(); /创建主窗体对象 mainForm.Show(); /显示窗体 this.Visible=false; /登陆窗体隐藏 else MessageBox.Show("您输入的用户名或密码错误!", "登录失败", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation); /MessageBoxIcon.Exclamation是由三角符号组成的警惕图 catch (Exception ex) MessageBox.Show(ex.Message,"操作数据库出错啦!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); finally connection.Close(); /关闭数据库连接 private void btnCancel_Click(object sender, EventArgs e) txtName.Text = "" txtPwd.Text = "" txtName.Focus();/将光标指定在txtName上 2.主窗体frmMain.csusing System;using System.Windows.Forms;namespace DeviceSystem private void timer1_Tick(object sender, EventArgs e) DateTime dt = DateTime.Now; /获取当前时间 tssData.Text = dt.ToLongDateString() ; private void tsmExit_Click(object sender, EventArgs e) Application.Exit(); private void tsmSelecName_Click(object sender, EventArgs e) frmselecName selectname = new frmselecName(); /创建子窗体对象 selectname.MdiParent = this; /指定当前窗体为MDI父窗体 selectname.Show(); /打开子窗体 tssStatus.Text = "按名称查询" /在状态栏中显示操作内容 private void tsmSelecPrice_Click(object sender, EventArgs e) frmselecPrice selectprice = new frmselecPrice(); /创建子窗体对象 selectprice.MdiParent = this; /指定当前窗体为MDI父窗体 selectprice.Show(); /打开子窗体 tssStatus.Text = "按单价查询" /在状态栏中显示操作内容 private void tsmUpdate_Click(object sender, EventArgs e) frmDataMaint datamaint = new frmDataMaint(); /创建子窗体对象 datamaint.MdiParent = this; /指定当前窗体为MDI父窗体 datamaint.Show(); /打开子窗体 tssStatus.Text = "修改数据" /在状态栏中显示操作内容 private void tsmabout_Click(object sender, EventArgs e) frmAbout about = new frmAbout(); /创建子窗体对象 about.MdiParent = this; / /指定当前窗体为MDI父窗体 about.Show(); /打开子窗体 tssStatus.Text = "关于我们" /在状态栏中显示操作内容 private void tsmjsq_Click(object sender, EventArgs e) frmjsq jsq = new frmjsq(); /创建子窗体对象 jsq.MdiParent = this; /指定当前窗体为MDI父窗体 jsq.Show(); /打开子窗体 tssStatus.Text = "计算器" /在状态栏中显示操作内容 private void tsmdate_Click(object sender, EventArgs e) frmTime time = new frmTime(); /创建子窗体对象 time.MdiParent = this; /指定当前窗体为MDI父窗体 time.Show(); / /打开子窗体 tssStatus.Text = "万年历" /在状态栏中显示操作内容 private void tsmdel_Click(object sender, EventArgs e) frmDeletedevice delete = new frmDeletedevice(); /创建子窗体对象 delete.MdiParent = this; /指定当前窗体为MDI父窗体 delete.Show(); /打开子窗体 tssStatus.Text = "设备数据维护" /在状态栏中显示操作内容 3.子窗体frmMain.csusing System;using System.Windows.Forms;using System.Data.SqlClient;using System.Configuration;namespace DeviceSystem public frmselecName() InitializeComponent(); string cons = ConfigurationManager.ConnectionStrings"DeviceSystem.Properties.Settings.MyDeviceConnectionString".ConnectionString connection = new SqlConnection(cons); private void frmselecName_Load(object sender, EventArgs e) / TODO: 这行代码将数据加载到表“myDeviceDataSet.equipment”中。您可以根据需要移动或移除它。 this.equipmentTableAdapter.Fill(this.myDeviceDataSet.equipment); private void btnSelectName_Click(object sender, EventArgs e) string name = textBox1.Text; /按名称查询设备 string sql = String.Format("select * from equipment where name like '%0%'",name); try SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, connection); DataSet datSet = new DataSet("equipment"); dataAdapter.Fill(datSet); /设置各列的显示数据字段 dataGridView1.Columns0.DataPropertyName = "id" dataGridView1.Columns1.DataPropertyName = "name" dataGridView1.Columns2.DataPropertyName = "price" dataGridView1.Columns3.DataPropertyName = "count" dataGridView1.DataSource = datSet.Tables0; catch (Exception ex) MessageBox.Show(ex.Message, "操作数据库出错啦!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); private void button1_Click(object sender, EventArgs e) this.Close(); 4.子窗体frmselecPrice.csusing System;using System.Drawing;using System.Data.SqlClient;using System.Configuration;namespace DeviceSystem public frmselecPrice() InitializeComponent(); string cons = ConfigurationManager.ConnectionStrings"DeviceSystem.Properties.Settings.MyDeviceConnectionString".ConnectionString; connection = new SqlConnection(cons); private void btnselectPrice_Click(object sender, EventArgs e) / decimal表示十进制数 decimal price1, price2; try price1 = Convert.ToDecimal(textBox1.Text); price2 = Convert.ToDecimal(textBox2.Text); catch price1 = 0; price2 = 1000000M;/默认为最大值 if(price1>price2) /如果price1>price2,交换两者 decimal temp=price1; price1=price2; price2=temp; /按价格查询设备 string sql=String.Format("select * from equipment where price between 0 and 1",price1,price2); try SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, connection); DataSet datSet = new DataSet("equipment"); dataAdapter.Fill(datSet); /设置各列的显示数据字段 dataGridView1.Columns0.DataPropertyName = "id" dataGridView1.Columns1.DataPropertyName = "name" dataGridView1.Columns2.DataPropertyName = "price" dataGridView1.Columns3.DataPropertyName = "count" dataGridView1.DataSource = datSet.Tables0; catch (Exception ex) MessageBox.Show(ex.Message, "操作数据库出错啦!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); private void frmselecPrice_Load(object sender, EventArgs e) / TODO: 这行代码将数据加载到表“myDeviceDataSet.equipment”中。您可以根据需要移动或移除它。 this.equipmentTableAdapter.Fill(this.myDeviceDataSet.equipment); private void button1_Click(object sender, EventArgs e) this.Close(); 5.子窗体frmDataMaint.csusing System;using System.Data.SqlClient;namespace DeviceSystem private void frmDataMaint_Load(object sender, EventArgs e) / TODO: 这行代码将数据加载到表“myDeviceDataSet.equipment”中。您可以根据需要移动或移除它。 this.equipmentTableAdapter.Fill(this.myDeviceDataSet.equipment); private void btnsave_Click(object sender, EventArgs e) equipmentTableAdapter.Update(myDeviceDataSet.equipment); private void btnguanbi_Click(object sender, EventArgs e) this.Close(); private void btnrefresh_Click(object sender, EventArgs e) equipmentTableAdapter.Fill(myDeviceDataSet.equipment); 6.子窗体frmDeletedevice.csusing System;using System.Data.SqlClient;using System.Configuration;namespace DeviceSystem public partial class frmDeletedevice : Form SqlConnection con; SqlDataAdapter da; DataSet ds; SqlCommand com; public frmDeletedevice() InitializeComponent(); private void frmDeletedevice_Load(object sender, EventArgs e) BKY(); string cons = ConfigurationManager.ConnectionStrings"DeviceSystem.Properties.Settings.MyDeviceConnectionString".ConnectionString; con= new SqlConnection(cons); /绑定cbosm da = new SqlDataAdapter("select name from equipment", con); ds = new DataSet(); da.Fill(ds, "equipment"); cbosm.DataSource = ds.Tables"equipment" cbosm.DisplayMember = "name" FillDgvshebei(); private void FillDgvshebei() /绑定dgvshebei da = new SqlDataAdapter("select * from equipment", con); ds = new DataSet(); da.Fill(ds, "equipment"); dgvshebei.DataSource = ds.Tables0; private void dgvshebei_CellClick(object sender, DataGridViewCellEventArgs e) txthao.Text = Convert.ToString(dgvshebei"id", dgvshebei.CurrentCell.RowIndex.Value); txtname.Text = Convert.ToString(dgvshebei"name", dgvshebei.CurrentCell.RowIndex.Value); txtC.Text = Convert.ToString(dgvshebei"price", dgvshebei.CurrentCell.RowIndex.Value); txtD.Text = Convert.ToString(dgvshebei"count", dgvshebei.CurrentCell.RowIndex.Value); private void tsbdel_Click(object sender, EventArgs e) com = new SqlCommand("delete from equipment where id='" + txthao.Text + "'", con); if (con.State = ConnectionState.Closed) con.Open(); int i = (int)com.ExecuteNonQuery(); con.Close(); if (i > 0) FillDgvshebei(); MessageBox.Show("删除成功!"); private bool bselect() com = new SqlCommand("select count(*) from equipment where id='" + txthao.Text + "' and name='" + txtname.Text + "'", con); if (con.State = ConnectionState.Closed) con.Open(); int i = (int)com.ExecuteScalar(); con.Close(); if (i > 0) MessageBox.Show("已有这条记录!"); Clear(); return true; else return false; private void Clear() txthao.Text = "" txtname.Clear(); private void tslbaocun_Click(object sender, EventArgs e) if (txtname.Text = "" | txtC.Text = "" |

    注意事项

    本文(设备管理系统程序设计.docx)为本站会员(飞****)主动上传,得力文库 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知得力文库 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于得利文库 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

    © 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

    黑龙江省互联网违法和不良信息举报
    举报电话:0468-3380021 邮箱:hgswwxb@163.com  

    收起
    展开