用户需求:

1、用户可以注册,可以登录。

2、需要一个报修界面,当点击“报修”按钮时,软件会把用户报修的信息保存起来,更新报修次数,同时会清空相应的文本框,软件还要要检查所有文本框是否为空,空的话给出提示!

具体设计思路:

第一步:数据库》添加一个名为repair_info的表,此步由侯贺琦负责!
第二步:为实现用户注册,在登录界面做出改变,把之前的取消按钮改为了注册按钮,新增一个注册窗体,两个label,两个文本框,两个按钮。点击注册按钮,可以实现用户的注册。后台代码即为实现用户注册增加的一个SQL语句,以此往user_info表插入新用户记录。此步由康贺、张玉冕负责!
第三步:新增一个报修窗体,一个labUsn,用来存放登录的用户名,这个也叫做高度抽象的效果是吧,两个文本框来存放报修地点以及报修内容,一个ReportDate(DateTimePicker)控件用了存报修日期及时间,一个comboxType,用来存放报修类型。一个按钮来实现数据的插入。此步丁志愿、李锦城负责!
第四步:为了实现用户报修次数的更新,首先要看这个用户是否是第一次报修,如果是第一次报修,那么SQL语句不需要写插入次数的字段,因为数据库设置为默认为1,所以在插入数据之前做个判断就行了。如果不是第一次报修,那么就看这个用户之前共有多少条报修记录,在原来的基础上+1。此步张宇负责!
--》界面设计:找张背景图,添加文字。在线PS就行,很简单!张宇负责!

团队成员及分工

团队: Blue 团队共有六人

姓名:     学号后四位:       贡献分:

张   宇(队长)  1152          1+2=3分

侯贺琦          1027          1+1.5=2.5分

丁志愿          1011          1+0.5=1.5分

李锦城          1040          1+0.5=1.5分

张玉冕          1153                  0.7分

康   贺          1169                  0.8分

第五步:请看代码实现↓↓↓

DBConn.cs

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Data.SqlClient;
 using System.Data;

 namespace sixth
 {
     class DBConn
     {
         //连接字符串
         public static string connStr = "Data Source=ZHANGYU;Initial Catalog=repair;Integrated Security=True;Pooling=False";
         public static SqlConnection conn = new SqlConnection(connStr);
         //读取数据
         public static DataSet getData(string sqlStr)
         {
             conn.Open();
             SqlDataAdapter ada = new SqlDataAdapter(sqlStr, conn);
             DataSet ds = new DataSet();
             ds.Clear();
             ada.Fill(ds);
             conn.Close();
             return ds;
         }
         //更新数据
         public static DataSet upData(string sqlStr)
         {
             try
             {
                 conn.Open();
                 SqlCommand comm = new SqlCommand(sqlStr, conn);
                 comm.CommandType = CommandType.Text;
                 comm.ExecuteNonQuery();//执行sql语句
                 conn.Close();
             }
             catch
             {
                 conn.Close();
             }
             return null;
         }
         //判断是否更新记录
         public static bool PDData(string sqlStr)
         {
             try
             {
                 conn.Open();
                 SqlCommand comm = new SqlCommand(sqlStr, conn);
                 comm.CommandType = CommandType.Text;
                 comm.ExecuteNonQuery();//执行sql语句
                 conn.Close();
                 return true;
             }
             catch
             {
                 conn.Close();
                 return false;
             }
         }
     }
 }

FormLogin.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 sixth
 {
     public partial class FormLogin : Form
     {
         public FormLogin()
         {
             InitializeComponent();
         }
         private void btnLogin_Click(object sender, EventArgs e)
         {
             try
             {
                 if (txtUsn.Text.Trim() == "")
                 {
                     labMessage.Text ="用户名不能为空!";
                     txtUsn.Focus();//获取焦点
                     return;
                 }
                 else if (txtPwd.Text.Trim() == "")
                 {
                     labMessage.Text ="密码不能为空!";
                     txtPwd.Focus();
                     return;
                 }
                 string sqlStr = "select userName,passWord from user_info where userName='"+txtUsn.Text+"'";
                 DataSet ds = DBConn.getData(sqlStr);
                 ].Rows.Count==)
                 {
                     labMessage.Text = "用户名不存在!请重新输入";
                     txtUsn.Text = "";//文本框置空
                     txtPwd.Text = "";
                     txtUsn.Focus();
                 }
                 ].Rows[][].ToString() == txtPwd.Text.Trim())
                 {
                     FormReport frmReport = new FormReport();
                     frmReport.labUsn.Text = txtUsn.Text.Trim();
                     labMessage.Text = "恭喜您已成功登录!";
                     this.Hide();
                     frmReport.Show();
                 }
                 else
                 {
                     labMessage.Text = "密码错误!请重新输入!";
                     txtPwd.Text = "";
                     txtPwd.Focus();
                 }
             }
             catch (Exception ex)
             {
                 labMessage.Text = "登录异常:" + ex.Message;
                 txtUsn.Text = "";
                 txtPwd.Text = "";
                 txtUsn.Focus();
             }
             finally
             {
                 DBConn.conn.Close();//最重要的是要关闭数据库!
             }
         }
         private void txtPwd_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)
             {
                 btnLogin_Click(sender, e);
             }
         }
         private void btnRegist_Click(object sender, EventArgs e)
         {
             FormRegist frmRegist = new FormRegist();
             frmRegist.Show();
         }
     }
 }

FormRegist.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 sixth
 {
     public partial class FormRegist : Form
     {
         public FormRegist()
         {
             InitializeComponent();
         }
         void ClearAll()
         {
             txtUsn.Text = "";
             txtPwd.Text = "";
         }
         bool userName(string userName)
         {
             string sqlStr = "select userName from user_info where userName='" + txtUsn.Text.Trim() + "'";
             DataSet ds = DBConn.getData(sqlStr);
             ].Rows.Count == )
             {
                 return false;
             }
             return true;
         }
         private void btnCancel_Click(object sender, EventArgs e)
         {
             if (MessageBox.Show("确认取消注册?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
             {
                 this.Close();
             }
         }
         private void txtPwd_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)
             {
                 btnRegist_Click(sender, e);
             }
         }
         private void btnRegist_Click(object sender, EventArgs e)
         {
             try
             {
                 if (txtUsn.Text.Trim() == "")
                 {
                     MessageBox.Show("用户名不能为空!", "提示");
                     txtUsn.Focus();
                 }
                 else if (txtPwd.Text.Trim() == "")
                 {
                     MessageBox.Show("密码不能为空!", "提示");
                     txtPwd.Focus();
                 }
                 else if (userName(txtUsn.Text.Trim()))
                 {
                     MessageBox.Show("用户名已存在!", "提示");
                     ClearAll();
                 }
                 else
                 {
                     string sqlStr = "insert into user_info values('" + txtUsn.Text.Trim() + "','" + txtPwd.Text.Trim() + "')";
                     if (DBConn.PDData(sqlStr))
                     {
                         MessageBox.Show("用户名为:" + txtUsn.Text + "注册成功!");
                     }
                     this.Close();
                 }
             }
             catch (Exception ex)
             {
                 DBConn.conn.Close();
                 MessageBox.Show(ex.Message);
                 ClearAll();
             }
         }
     }
 }

FormReport.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 sixth
 {
     public partial class FormReport : Form
     {
         public FormReport()
         {
             InitializeComponent();
         }
         void ClearAll()
         {
             txtAddress.Text = "";
             txtContent.Text = "";
             ReportDate.Value = DateTime.Now;
             comboxType.SelectedIndex = -;
         }
         private void btnReport_Click(object sender, EventArgs e)
         {
             try
             {
                 if (txtAddress.Text.Trim() == "")
                 {
                     MessageBox.Show("报修地点不能为空", "提示");
                     txtAddress.Focus();
                     return;
                 }
                 else if (txtContent.Text.Trim() == "")
                 {
                     MessageBox.Show("报修内容不能为空", "提示");
                     txtContent.Focus();
                     return;
                 }
                 )
                 {
                     MessageBox.Show("请选择报修类型", "提示");
                     comboxType.Focus();
                     return;
                 }
                 string sqlStr1 = "select userName,repairCount from repair_info where userName='"+labUsn.Text+"'";
                 DataSet ds = DBConn.getData(sqlStr1);
                 ].Rows.Count==)//如果ds里面不存在数据,说明这个用户第一次报修,直接插入新的记录
                 {
                     string sqlStr;
                     sqlStr = "insert into repair_info(userName,repairType,repairAddress,repairContent,repairDate) values('" + labUsn.Text + "','" + comboxType.SelectedItem.ToString() + "','" + txtAddress.Text.Trim() + "','" + txtContent.Text.Trim() + "','" + ReportDate.Value.ToString() + "')";
                     DBConn.upData(sqlStr);
                     MessageBox.Show("报修成功!");
                     ClearAll();
                 }
                 else//否则的话就是repair_info表里已经有了labUsn里的这个用户。目的就是更新这个用户的报修次数,并插入新的记录
                 {
                     string sqlStr;
                     ].Rows[ds.Tables[].Rows.Count - ][].ToString();
                     sqlStr = ) + "')";
                     //更新语句:sqlStr = "update repair_info set repairType ='" + comboxType.SelectedItem.ToString() + "',repairAddress='" + txtAddress.Text.Trim() + "',repairContent='" + txtContent.Text.Trim() + "',repairDate='" + ReportDate.Value + "',repairCount='" + (int.Parse(ds.Tables[0].Rows[0][1].ToString()) + 1) + "'where userName='" + labUsn.Text + "'";
                     DBConn.upData(sqlStr);
                     MessageBox.Show("报修成功!");
                     ClearAll();
                 }
             }
             catch (Exception ex)
             {
                 DBConn.conn.Close();
                 MessageBox.Show(ex.Message);
             }
         }
         private void FormReport_FormClosing(object sender, FormClosingEventArgs e)
         {
             if (MessageBox.Show("您确认要退出吗?", "退出系统", MessageBoxButtons.OKCancel) == DialogResult.OK)
             {
                 this.Dispose();
                 Application.Exit();
             }
             else
                 e.Cancel = true;
         }
     }
 }

运行:

1.当用户名不存在时,注册一个新用户。

2.报修登记,提示报修成功。并且labUsn显示用户名。

3.因为登陆窗体为主窗体,之前Hide了,所以在最后窗体关闭的时候,终止应用程序。

PSP耗时分析:

团队编程总结:

这是这个项目的第二次完善,因为上次封装的时候,只是把连接字符串封装了,而没有把数据的读取封装,所以这次对数据库的访问和操作都封装到了DBConn类里,以便于调用!之前我们基本上没有注重界面这一块,看别人做的项目界面都设计的挺有个性哈,不知道这个重不重要,但这次我们也试着美化了一下界面。
个人总结:
张宇:个人认为--》其实次数的更新才是这次作业最麻烦的地方,本来呢我是直接用update语句来进行更新的,但是更新的话就不能插入新纪录了。并且,SQL语句特别容易写错。我原本以为要求的是要把次数放到repair_info表里的,所以还是用了insert语句。没关系,这样的话一次一次进行改进,不是更好吗,而且我们学到的东西也会更多。毕竟对待事物的方法不止一种,有的只是内容不同罢了!
侯贺琦:
队长仍分配给我们任务。我负责数据库连接这方面,仍然是我薄弱的一方面。队长说一个团队,要做好一个项目,要有十分全面的考虑以及分析。牛老师说作为一个学计算机的,不会写代码就像学音乐的不懂五线谱一样,还是要多努力敲代码的。代码是我们让计算机创造生产力的必须工具。我对他的话很信服,觉得他说的很对,所以我下面也会认真的敲代码,会多看书上的例题,多练习。接下来也会配合队长完善这个程序。还是要感谢队长,感谢他相信我让我负责数据库这一块。我相信我们的团队会完成得很出色。we are a team。we are 伐木累。

C#报修系统Ⅱ的更多相关文章

  1. PHP实现单人多人聊天源码免费分享 | 电脑报修系统

    源码清单 1. 简易版登陆式聊天源码. 2. 电脑报修轻系统源码. 3. 关注下面公众号回复“聊天”,免费获取. 聊天系统 虽然微信,QQ是即时通讯的元老.但是他们限制很多,所以很多人都想做一个自己的 ...

  2. easyUI 如何不跳转页面,只是加载替换center部分内容

    以前做的一个故障报修系统,前端框架使用easyUI框架,layout布局,center使用datagrid .点击左边树形菜单时时页面跳转,想要知道如何点击菜单时不进行页面跳转,而是只对center模 ...

  3. IText 生成简单表格(报表)doc文档 单元居中

    IText生成doc文档需要三个包:iTextAsian.jar,iText-rtf-2.1.4.jar,iText-2.1.4.jar 亲测无误,代码如下所示: import com.lowagie ...

  4. VMware 虚拟机(linux)增加根目录磁盘空间 转自

    转自 http://wenku.baidu.com/link?url=WZDgESO0oXqYfhPYOWFalZsMglS0HKtLw7t6ICRs_sJ_sfPc85RpxsqKMwqSniis0 ...

  5. 基于j2ee的程序代写MVC架构

    人力资源管理系统 完成系统静态页面设计,页面数量不少于10个,页面需用CSS进行美化,并为需要验证的信息利用JavaScript提供客户端验证.要求至少包含部门信息及部门内员工信息的添加.修改.删除和 ...

  6. VMware 虚拟机(linux)增加根目录磁盘空间

    今天查看学校的监控报修系统,不能访问了!!!系统运行很慢,用top命令查看发现内存使用率90%,用"df -h ”查看“/”目录使用率已达到80%,导致系统运行很慢.我用以下方法扩大根目录磁 ...

  7. asp.net C# 题目大全

    net001在线饰品销售系统 net002鲜花商城 net003商品销售管理系统 net004在线辅导答疑 net005土地税务管理系统 net006旅游管理 net007房产中介 net008房产信 ...

  8. 安卓 Android题目大全

    安卓001个人事务管理系统(单端) 安卓002手机订餐系统 安卓003无线点菜 安卓004酒店房间预定系统 安卓005个人相册管理系统(单端) 安卓006计算器(单端) 安卓007英语学习(单端) ...

  9. 个人作业3——个人总结(Alpha阶段)。

    一:个人总结: 陆续几周以及加上上上一周的Alpha冲刺阶段,完成了实验室故障报修系统的基础框架以及内容.这个过程苦中有乐,或许苦中寻乐更加恰当,以一个小组团队的形式来完成这个项目,我们大家就变成了一 ...

随机推荐

  1. mysql分区

    <?php /* 分区 目录 18.1. MySQL中的分区概述 18.2. 分区类型 18.2.1. RANGE分区 18.2.2. LIST分区 18.2.3. HASH分区 18.2.4. ...

  2. 安装SSD固态硬盘

    满足三个要求:开启AHCI."4K对齐".SSD初始化. 1. 开启AHCI模式 重启,进入bios,高级模式,SATA模式选择,选择AHCI. 2. 4K对齐 第3步,在分区的时 ...

  3. 友盟推送里面的Alias怎么用?可以理解成账号吗?

    友盟推送里面的Alias怎么用?可以理解成账号吗? 我们的App有自己的账号体系的,想在每次用户登陆的时候,给用户发一个欢迎消息. 看了一下友盟推送,里面有一个概念叫做Alias(别名),但是官方文档 ...

  4. Any changes made by a writer will not be seen by other users of the database until the changes have been completed

    https://en.wikipedia.org/wiki/Multiversion_concurrency_control Multiversion concurrency control (MCC ...

  5. 使用CSS将图片转换成黑白(灰色、置灰)z转

    小tip: 使用CSS将图片转换成黑白(灰色.置灰) by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxinxu.c ...

  6. 文件上传去除"Content-Disposition: form-data"

    某个项目中为了统一处理文件上传业务,创建了一个FileUpload Handle,由于上传客户端用到各种技术,当时为了方便断点续传,就直接接收请求中的文件内容(可能是分片),所以处理的不是规范的htt ...

  7. echarts入门基础,画一个饼状图

    注意:一定要自己引入echarts库 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...

  8. RDIFramework.NET ━ 9.14 数据库连接管理 ━ Web部分

    RDIFramework.NET ━ .NET快速信息化系统开发框架 9.14  数据库连接管理 -Web部分 我们经常可以看到很多软件直接把数据库连接字符串放在软件执行目录下的配置文件中,这种直接把 ...

  9. EBS安装过程报错,oracle.apps.fnd.txk.config.ProcessStateException: FileSys OS COMMAND Failed : Exit=2 See log for details.

    日志: Executing command: /test/software/12/startCD/Disk1/rapidwiz/jre/Linux_x64/1.6.0/bin/java -cp /te ...

  10. tomcat server需要重启的时刻

    1.修改了web project的任何配置文件,都需要重启tomcat 2.修改了任何java class文件,都需要重启tomcat server 3.在项目中添加了任何的文件,包括配置文件.jav ...