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 登录页面 : Form 15 { 16 public 登录页面() 17 { 18 InitializeComponent(); 19 } 20 21 private void textBox2_TextChanged(object sender, EventArgs e) 22 { 23 this.textBox2.PasswordChar = '*'; 24 } 25 26 private void button1_Click(object sender, EventArgs e) 27 { 28 string sql = "server=.;database=Community system;Integrated Security=true;"; 29 sqlConnection conn = new sqlConnection(sql);//数据库连接 30 conn.open();//打开数据库 31 string username = this.textBox1.Text; 32 string password = this.textBox2.Text; 33 if (username.Equals("") || password.Equals(""))//用户名或密码为空 34 { 35 MessageBox.Show("用户名或密码不能为空"); 36 } 37 else//用户名或密码不为空 38 { 39 //到数据库中验证 40 //string str = "Select * from userphone where usename='" + username + "' and pwd='" + password + "'"; 41 //在数据库中查看 42 //sqlCommand cmd = new sqlCommand(str, conn); 43 //cmd.CommandType = CommandType.Text; 44 //sqlDataReader sdr; 45 //sdr = cmd.ExecuteReader(); 46 if (radioButton1.Checked==true) 47 { 48 string str = "Select * from Adphone where Adname='" + username + "' and pwd='" + password + "'"; 49 sqlCommand cmd = new sqlCommand(str, conn); 50 cmd.CommandType = CommandType.Text; 51 sqlDataReader sdr; 52 sdr = cmd.ExecuteReader(); 53 if (sdr.Read()) 54 { 55 admin a = new admin(); 56 a.Show(); 57 } 58 else 59 { 60 MessageBox.Show("账号或密码不正确"); 61 } 62 } 63 if (radioButton2.Checked==true) 64 { 65 string str = "Select * from userphone where usename='" + username + "' and pwd='" + password + "'"; 66 sqlCommand cmd = new sqlCommand(str, conn); 67 cmd.CommandType = CommandType.Text; 68 sqlDataReader sdr; 69 sdr = cmd.ExecuteReader(); 70 if (sdr.Read()) 71 { 72 user u = new user(); 73 u.Show(); 74 } 75 else 76 { 77 MessageBox.Show("账号或密码不正确"); 78 } 79 } 80 /*if (sdr.Read()) 81 { 82 MessageBox.Show("登录成功"); 83 }*/ 84 85 } 86 } 87 88 private void button2_Click(object sender, EventArgs e) 89 { 90 register res = new register(); 91 res.Show(); 92 } 93 94 private void button3_Click(object sender, EventArgs e) 95 { 96 checkpwd check = new checkpwd(); 97 check.Show(); 98 } 99 } 100 }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。