码迷,mamicode.com
首页 > 其他好文 > 详细

2.0注册界面

时间:2021-06-05 17:38:06      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:for   public   sql语句   eric   collect   数据库   this   注册   cut   

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Data.SqlClient;
 6 using System.Drawing;
 7 using System.Linq;
 8 using System.Text;
 9 using System.Threading.Tasks;
10 using System.Windows.Forms;
11 
12 namespace 物业管理登录页面
13 {
14     public partial class register : Form
15     {
16         public register()
17         {
18             InitializeComponent();
19         }
20 
21         private void button1_Click(object sender, EventArgs e)
22         {
23             if (textBox1.Text==""||textBox2.Text=="" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" )
24             {
25                 MessageBox.Show("每个字段都是必填字段!","提示");
26             }
27             else
28             {
29                 if (textBox3.Text!=textBox4.Text)
30                 {
31                     MessageBox.Show("两次输入的密码不同!", "提示");
32                 }
33                 else
34                 {
35                     //连接数据库
36                     string str = "server=.;database=Community system;Integrated Security=true";
37                     //创建连接对象
38                     SqlConnection conn = new SqlConnection(str);
39                     //打开数据库
40                     conn.Open();
41                     if (radioButton4.Checked == true)
42                     {
43                         //sql语句
44                         string sql = "insert into userphone values(‘" + textBox1.Text + "‘,‘" + textBox3.Text + "‘)";
45                         SqlCommand cmd = new SqlCommand(sql, conn);
46                         int x = cmd.ExecuteNonQuery();
47                         if (x > 0)
48                         {
49                             MessageBox.Show("注册成功");
50                             this.Close();
51                         }
52                         else
53                         {
54                             MessageBox.Show("注册失败");
55                         }
56                     }
57                     if (radioButton3.Checked == true)
58                     {
59                         string sql = "insert into Adphone values(‘" + textBox1.Text + "‘,‘" + textBox3.Text + "‘)";
60                         SqlCommand cmd = new SqlCommand(sql, conn);
61                         int x = cmd.ExecuteNonQuery();
62                         if (x > 0)
63                         {
64                             MessageBox.Show("注册成功");
65                             this.Close();
66                         }
67                         else
68                         {
69                             MessageBox.Show("注册失败");
70                         }
71                     }
72                 }
73             }
74         }
75 
76         private void textBox3_TextChanged(object sender, EventArgs e)
77         {
78             this.textBox3.PasswordChar = *;
79         }
80 
81         private void textBox4_TextChanged(object sender, EventArgs e)
82         {
83             this.textBox4.PasswordChar = *;
84         }
85     }
86 }

 

2.0注册界面

标签:for   public   sql语句   eric   collect   数据库   this   注册   cut   

原文地址:https://www.cnblogs.com/dz-zs0706/p/14851315.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!