第七次作业+梦飞扬
2015-12-14 20:51
381 查看
在第六次的基础上:
增加:
1、用代码实现对数据库的增删改查操作,以此来实现用户的注册。
2、新建一个报修表,名字为repair_info,列有用户名、报修类型、报修地点、报修内容,报修日期和时间、用户报修次数等,列名自己起。
3、在报修界面中,当用户点击“报修”按钮时,软件会把用户报修的信息写入数据库中,更新报修次数,同时会清空相应的文本框,软件还要
检查所有文本框是否为空,空的话提示报修失败。
[b]代码实现:[/b]
[b]from1:[/b]
from2:
from3:
数据库:
:
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214201540443-234668484.png)
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214201555552-204677359.png)
代码实现:
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214202149693-472843800.png)
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214202704084-769076468.png)
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214202202584-2097311050.png)
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214202214756-740396509.png)
PSP消耗:
团队总结:
本次团队在上一次的作业中,做了增量,通过团队合作,需要的是交流,只有交流多了,才能进步的多,多动手,在出错中改进,多做,才知道问题所在,在团队里,学会学习,我记得老师说,大学要学会学习的能力,学会查资料;我们团队需要多学习!希望跟上大家的步伐!
工作分配
队长:赵文涛
杨栗:查资料 1分;
娄豪:PSP消耗统计 1分;
李宁:总结 1分;
姚震:测试 1分;
肖雪峰:代码复审 1分;
赵文涛:代码、复查、数据库、思路、界面设计 5分;
增加:
1、用代码实现对数据库的增删改查操作,以此来实现用户的注册。
2、新建一个报修表,名字为repair_info,列有用户名、报修类型、报修地点、报修内容,报修日期和时间、用户报修次数等,列名自己起。
3、在报修界面中,当用户点击“报修”按钮时,软件会把用户报修的信息写入数据库中,更新报修次数,同时会清空相应的文本框,软件还要
检查所有文本框是否为空,空的话提示报修失败。
[b]代码实现:[/b]
[b]from1:[/b]
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 登录 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string ConnStr = "Data Source=.;Initial Catalog=repair;Integrated Security=True"; SqlConnection conn = new SqlConnection(); public static string name; private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "" && textBox2.Text != "") { kailu(); name = textBox1.Text; string com = "select count(*) from user_info where userName='" + name + "' "; SqlCommand comm = new SqlCommand(com, conn); int a = (int)comm.ExecuteScalar(); if (a == 0) { label3.Text = "用户名不存在!"; textBox1.Clear(); textBox2.Clear(); } else { string corrStr = "select count(*) from user_info where userName='" + textBox1.Text + "' and passWord='" + textBox2.Text + "'"; SqlCommand con = new SqlCommand(corrStr, conn); int tt = (int)con.ExecuteScalar(); if (tt == 0) { label3.Text = "您输入的密码有错误,请重新输入!"; textBox2.Clear(); } else { label3.Text="恭喜你,登录成功了!"; Form2 foa = new Form2(); foa.ShowDialog(); } } } else { MessageBox.Show("请输入用户名和密码!"); } } private void kailu() { try { conn = new SqlConnection(ConnStr); conn.Open(); } catch (Exception ex) { label3.Text="数据库连接失败" + ex.ToString(); } } private void button2_Click(object sender, EventArgs e) { Form3 form = new Form3(); form.ShowDialog(); } } }
from2:
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 登录 { public partial class Form2 : Form { public Form2() { InitializeComponent(); } string ConnStr = "Data Source=.;Initial Catalog=repair;Integrated Security=True"; SqlConnection conn = new SqlConnection(); private void Form2_Load(object sender, EventArgs e) { label1.Text = "欢迎你" + Form1.name; } private void button1_Click(object sender, EventArgs e) { conn = new SqlConnection(ConnStr); string updarta = "Update user_info set passWord='" + textBox3.Text.Trim() + "' where userName='" + textBox1.Text.Trim() + "'"; SqlCommand comm = new SqlCommand(updarta, conn); conn.Open(); int a = comm.ExecuteNonQuery(); if (a > 0) { MessageBox.Show("修改成功!"); } else { MessageBox.Show("修改失败!"); } conn.Close(); } private void button2_Click(object sender, EventArgs e) { conn = new SqlConnection(ConnStr); string comstr = "insert into repair_info(usernaem,class1,addss,nierong,nowdate,cishu) values('"+textBox2.Text+"','"+textBox4.Text+"','"+textBox5.Text+"','"+textBox6.Text+"','"+textBox7.Text+"','"+textBox8.Text+"')"; SqlCommand comm = new SqlCommand(comstr, conn); conn.Open(); if (textBox2.Text != "") { int a = comm.ExecuteNonQuery(); if (a > 0) { MessageBox.Show("报修成功!"); } else { MessageBox.Show("报修失败!"); } } string commstr = "select usernaem,class1,addss,nierong,nowdate,cishu from repair_info"; SqlDataAdapter das = new SqlDataAdapter(commstr, conn); DataSet ds = new DataSet(); DataTable td = new DataTable(); das.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; conn.Close(); } private void button3_Click(object sender, EventArgs e) { conn = new SqlConnection(ConnStr); string updarta = "Update repair_info set cishu='" + textBox8.Text.Trim() + "' where usernaem='" + textBox2.Text.Trim() + "'"; SqlCommand comm = new SqlCommand(updarta, conn); conn.Open(); int a = comm.ExecuteNonQuery(); if (a > 0) { MessageBox.Show("再次报修成功!"); } else { MessageBox.Show("再次报修失败!"); } conn.Close(); } private void button4_Click(object sender, EventArgs e) { conn = new SqlConnection(ConnStr); string updarta = "delete form repair_info where usernaem='" + textBox2.Text.Trim() + "'"; SqlCommand comm = new SqlCommand(updarta, conn); conn.Open(); int a = comm.ExecuteNonQuery(); if (a > 0) { MessageBox.Show("完成保修成功!"); } else { MessageBox.Show("完成报修失败!"); } conn.Close(); } } }
from3:
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 登录 { public partial class Form3 : Form { public Form3() { InitializeComponent(); } string ConnStr = "Data Source=.;Initial Catalog=repair;Integrated Security=True"; SqlConnection conn = new SqlConnection(); private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "" && textBox2.Text != "") { conn = new SqlConnection(ConnStr); string comstr = @"insert into user_info(userName,passWord) values('" + textBox1.Text + "','" + textBox2.Text + "')"; SqlCommand comm = new SqlCommand(comstr, conn); conn.Open(); int a = comm.ExecuteNonQuery(); if (a > 0) { MessageBox.Show("注册成功!"); } else { MessageBox.Show("注册失败!"); } } else { if (textBox1.Text != "") { MessageBox.Show("密码不能为空!"); } else { MessageBox.Show("用户名不能为空!"); } } conn.Close(); } private void button2_Click(object sender, EventArgs e) { conn = new SqlConnection(ConnStr); string delstr = "delete from user_info where userName='"+textBox1.Text.Trim()+"'"; SqlCommand comm = new SqlCommand(delstr,conn); conn.Open(); int a = comm.ExecuteNonQuery(); if (a > 0) { MessageBox.Show("注销成功!"); } else { MessageBox.Show("注销失败哦!"); } conn.Close(); } } }
数据库:
:
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214201540443-234668484.png)
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214201555552-204677359.png)
代码实现:
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214202149693-472843800.png)
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214202704084-769076468.png)
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214202202584-2097311050.png)
![](http://images2015.cnblogs.com/blog/813287/201512/813287-20151214202214756-740396509.png)
PSP消耗:
psp | Personal Software Process Stages | Time(h) |
planning | .计划 | 5 |
.Estimate | .估计这个任务需要多长时间 | 4 |
Development | .开发 | 40 |
.Analysis | .需求分析 | 3 |
.Design Spec | .生成设计文档 | 2 |
.Design Review | .设计复审 | 4 |
• Coding Standard | .代码规范 | 2 |
• Design | .具体设计 | 15 |
• Coding | .具体编码 | 4 |
• Code Review | .代码复审 | 3 |
• Text | .测试 | 3 |
Reporting | .报告 | 4 |
• Test Report | .测试报告 | 3 |
• Size Measurement | .计算工作量 | 0.5 |
• Postmortem&Process Improvement Plan | .事后总结并提出改进计划 | 4 |
本次团队在上一次的作业中,做了增量,通过团队合作,需要的是交流,只有交流多了,才能进步的多,多动手,在出错中改进,多做,才知道问题所在,在团队里,学会学习,我记得老师说,大学要学会学习的能力,学会查资料;我们团队需要多学习!希望跟上大家的步伐!
工作分配
队长:赵文涛
杨栗:查资料 1分;
娄豪:PSP消耗统计 1分;
李宁:总结 1分;
姚震:测试 1分;
肖雪峰:代码复审 1分;
赵文涛:代码、复查、数据库、思路、界面设计 5分;
相关文章推荐
- instanceof 运算符
- 九度oj 1181 升序链表
- eclipse 连接到数据库
- Linux下Kafka单机安装配置方法(图文)
- MySQL存储引擎
- 随笔一
- Android: 在UI线程更新UI的几种方式
- Hibernate工程的手动创建
- BZOJ1036: [ZJOI2008]树的统计Count
- 关于tableView中的细节
- IOS开发之深拷贝与浅拷贝(mutableCopy与Copy)详解
- leetcode -- Divide Two Integers -- 重点,技巧
- 欧拉回路或通路路径输出(Fleury算法)
- 二分查找
- 黑马程序员——Java语言的环境搭建
- Codeforces #218 (Div. 2) Fox Dividing Cheese
- 使用Hyper-V PowerShell
- quartz定时器任务调度实现
- There are no resources that can be added or removed from the server.
- 菜鸟总结(1)