登录界面: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace book { public partial class login : Form { public string password; //用来存储密码 public login() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { Application.Exit(); } private bool yanzhengshuru() { password = textBox3.Text; if (Typename.Text.Trim() == "") { MessageBox.Show("请选择登录类型", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Typename.Focus(); return false; } else if (loginid.Text.Trim() == "") { MessageBox.Show("请输入用户名", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Information); loginid.Focus(); return false; } else if (password == "") { MessageBox.Show("请输入密码", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox3.Focus(); return false; } else { return true; } } private void button1_Click(object sender, EventArgs e) { userhelper.adminid= loginid.Text; //用户账号 password = textBox3.Text;//用户密码 if (yanzhengshuru()) { if (Typename.Text.Trim() == "管理员") { string sql = string.Format("Select count(*) from admin where adminId='{0}' and adminpass='{1}'", loginid.Text, password); try { SqlCommand command = new SqlCommand(sql, Dbhelper.connection); Dbhelper.connection.Open(); int count = (int)command.ExecuteScalar(); if (count < 1) { MessageBox.Show("用户或密码不存在!"); //result = false; } else { admin admin = new admin(); admin.Show(); } } catch (Exception ex) { MessageBox.Show("操作数据库出错!"); Console.WriteLine(ex.Message); } finally { Dbhelper.connection.Close(); } } if (Typename.Text.Trim() == "借阅者") { userhelper.readerid =Convert .ToString (loginid.Text); strin...