第六次团队作业+登录界面

一、具体设计思路

 1、我做了三个界面,一个登陆界面,一个注册的界面,还有一个单独提示的,

登陆成功后,在登陆界面提示登陆成功,并跳出欢迎界面,也可以单击注册,注册新的账户;

 2、利用SQL Server 2008数据库软件创建repair数据库,创建user_info表,并先创建几个账号,密码;

 3.在登陆界面放Label和Button、TextBox控件,做好界面,本次团队作业主要是为了利用数据库,掌握数据库的应用;

二、代码实现

 1.登录界面

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 using System.Data.SqlClient;
10 
11 namespace 登录
12 {
13     public partial class Form1 : Form
14     {
15         public Form1()
16         {
17             InitializeComponent();
18         }
19         string ConnStr = "Data Source=.;Initial Catalog=repair;Integrated Security=True";
20         SqlConnection conn = new SqlConnection();
21         public static string name;
22         private void button1_Click(object sender, EventArgs e)
23         {
24            
25             if (textBox1.Text != "" && textBox2.Text != "")
26             {
27                 kailu();
28 
29                 name = textBox1.Text;
30                 string com = "select count(*) from user_info where userName='" + name + "' ";
31                 SqlCommand comm = new SqlCommand(com, conn);
32                 int a = (int)comm.ExecuteScalar();
33                 if (a == 0)
34                 {
35                     label3.Text = "用户名不存在!";
36                     textBox1.Clear();
37                     textBox2.Clear();
38 
39                 }
40                 else
41                 {
42 
43                     string corrStr = "select count(*)  from user_info where userName='" + textBox1.Text + "' and  passWord='" + textBox2.Text + "'";
44                     SqlCommand con = new SqlCommand(corrStr, conn);
45                     int tt = (int)con.ExecuteScalar();
46                     if (tt == 0)
47                     {
48                         label3.Text = "您输入的密码有错误,请重新输入!";                       
49                         textBox2.Clear();
50                     }
51                     else
52                     {
53 
54                         label3.Text="恭喜你,登录成功了!";
55                         Form2 foa = new Form2();
56                         foa.ShowDialog();
57                     }
58                 }
59 
60 
61 
62             }
63             else
64             {
65                 MessageBox.Show("请输入用户名和密码!");
66             }
67             
68             
69         }
70         private void kailu()
71         {
72            
73 
74             try
75             {
76                 conn = new SqlConnection(ConnStr);
77                 conn.Open();
78             }
79             catch (Exception ex)
80             {
81 
82                label3.Text="数据库连接失败" + ex.ToString();
83             }
84  
85         }
86 
87         private void button2_Click(object sender, EventArgs e)
88         {
89             Form3 form = new Form3();
90             form.ShowDialog();
91         }
92         }
93     }

2、提示界面

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 
10 namespace 登录
11 {
12     public partial class Form2 : Form
13     {
14         public Form2()
15         {
16             InitializeComponent();
17         }
18 
19         private void Form2_Load(object sender, EventArgs e)
20         {
21             label1.Text = "欢迎你" + Form1.name;
22         }
23     }
24 }

3、注册界面

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 
10 namespace 登录
11 {
12     public partial class Form3 : Form
13     {
14         public Form3()
15         {
16             InitializeComponent();
17         }
18 
19         private void button1_Click(object sender, EventArgs e)
20         {
21 
22             if (textBox1.Text != "" && textBox2.Text != "")
23             {
24                 MessageBox.Show("恭喜你注册成功!");
25             }
26             else
27             {
28                 if (textBox1.Text != "")
29                 {
30                     MessageBox.Show("密码不能为空!");
31                 }
32                 else
33                 {
34                     MessageBox.Show("用户名不能为空!");
35                 }
36             }
37         }
38     }
39 }

三、测试

数据库

软件实现;

四、PSP耗时分析

psp Personal Software Process Stages Time(h)
planning .计划 5
.Estimate .估计这个任务需要多长时间 4
Development .开发 50
.Analysis .需求分析 3
.Design Spec .生成设计文档 2
.Design Review .设计复审 4
• Coding Standard .代码规范 2
 • Design .具体设计 10
 • Coding .具体编码 4
• Code Review .代码复审 3
 • Text .测试 3
Reporting .报告 4
• Test Report .测试报告 3
• Size Measurement .计算工作量 0.5
 • Postmortem&Process Improvement Plan .事后总结并提出改进计划 4

五、团队总结:
    
这次的作业有点类似于以前在ASP.NET中练习的题,所以思路是有的,没做感觉挺简单的,具体实现却出问题的时候很多,所以只有动手做才知道问题所在,经常动手做题才是正确的思路,单单想是不够的,在团队合作中,交流是很重要的,所以要互相沟通,才能发现问题,解决问题,要发表自己的意见、这才是团队合作,分工明确,知道自己应该怎么做才知道促进团队效率。

六、工作分配

    队长:赵文涛

    杨栗:查资料      1分;

    娄豪:PSP消耗统计 1分;

    李宁:总结        1分;

    姚震:测试        1分;

    肖雪峰:代码复审  1分;

    赵文涛:代码、复查、数据库、思路、界面设计  5分;

原文地址:https://www.cnblogs.com/zwt0626/p/5021600.html