资源描述:
《图书管理系统源码(C#版)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、登录界面:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namespacebook{publicpartialclasslogin:Form{publicstringpassword;//用来存储密码publi
2、clogin(){InitializeComponent();}privatevoidbutton2_Click(objectsender,EventArgse){Application.Exit();}privateboolyanzhengshuru(){password=textBox3.Text;if(Typename.Text.Trim()==""){MessageBox.Show("请选择登录类型","登录提示",MessageBoxButtons.OK,MessageBoxIcon.Informatio
3、n);Typename.Focus();returnfalse;}elseif(loginid.Text.Trim()==""){MessageBox.Show("请输入用户名","登录提示",MessageBoxButtons.OK,MessageBoxIcon.Information);loginid.Focus();returnfalse;}elseif(password==""){MessageBox.Show("请输入密码","登录提示",MessageBoxButtons.OK,MessageBoxIc
4、on.Information);textBox3.Focus();returnfalse;}else{returntrue;}}privatevoidbutton1_Click(objectsender,EventArgse){userhelper.adminid=loginid.Text;//用户账号password=textBox3.Text;//用户密码if(yanzhengshuru()){if(Typename.Text.Trim()=="管理员"){stringsql=string.Format("Se
5、lectcount(*)fromadminwhereadminId='{0}'andadminpass='{1}'",loginid.Text,password);try{SqlCommandcommand=newSqlCommand(sql,Dbhelper.connection);Dbhelper.connection.Open();intcount=(int)command.ExecuteScalar();if(count<1){MessageBox.Show("用户或密码不存在!");//result=fa
6、lse;}else{adminadmin=newadmin();admin.Show();}}catch(Exceptionex){MessageBox.Show("操作数据库出错!");Console.WriteLine(ex.Message);}finally{Dbhelper.connection.Close();}}if(Typename.Text.Trim()=="借阅者"){userhelper.readerid=Convert.ToString(loginid.Text);stringsql=stri
7、ng.Format("Selectcount(*)fromreaderwherereaderId='{0}'andreaderpass='{1}'",userhelper.readerid,textBox3.Text);try{//创建Command对象SqlCommandcommand=newSqlCommand(sql,Dbhelper.connection);//打开数据库连接Dbhelper.connection.Open();//验证是否为合法用户intcount=(int)command.Execute
8、Scalar();if(count<1){MessageBox.Show("用户或密码不存在!");//result=false;}else{readerreader=newreader();reader.Show();}}catch(Exceptionex){MessageBox.Show("操作数据库出错!");Console.WriteLine(ex.