2.0注册界面
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 }
每一个成功的背后都有一段不为人知的故事