} //登录 private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.Hide(); body body = new body(); body.Show(); } //散客跳转到主页面
private void button1_Click(object sender, EventArgs e) { sqlcon.Open(); //string telno = textBox1.Text.Trim(); string pwd = textBox2.Text.Trim(); string cmd = "select count(*) from Guest where Gtel = '" + textBox1.Text.Trim() + "' and Gpwd = '" + textBox2.Text.Trim() + "'"; try { if (textBox1.Text != "") //输入用户名 { dfgtel = textBox1.Text; if (pwd != "") //输入密码 { SqlCommand login = new SqlCommand(cmd, sqlcon); //SqlDataReader password = login.ExecuteReader(); int ok = Convert.ToInt32(login.ExecuteScalar()); if (ok > 0) { MessageBox.Show("登录成功", "提示", MessageBoxButtons.OK); this.Hide(); body body = new body(); body.Show(); } else { MessageBox.Show("用户名或密码错误", "警告", MessageBoxButtons.OK); } } else { MessageBox.Show("密码不能为空", "提示", MessageBoxButtons.OK); } } else { MessageBox.Show("账号不能为空", "提示", MessageBoxButtons.OK); } sqlcon.Close(); } catch (Exception ex) { Console.WriteLine(ex); } } //登录