《图书管理系统源码C版.doc》由会员分享,可在线阅读,更多相关《图书管理系统源码C版.doc(71页珍藏版)》请在金锄头文库上搜索。
1、登录界面: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() InitializeCom
2、ponent(); 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.
3、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
4、_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 S
5、qlCommand(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 Db
6、helper.connection.Close(); if (Typename.Text.Trim() = 借阅者) userhelper.readerid =Convert .ToString (loginid.Text); string sql = string.Format(Select count(*) from reader where readerId=0 and readerpass=1, userhelper.readerid,textBox3.Text); try / 创立 Command 对象 SqlCommand command = new SqlCommand(sql,
7、 Dbhelper.connection); / 打开数据库连接 Dbhelper.connection.Open(); / 验证与否为合法顾客 int count = (int)command.ExecuteScalar(); if (count 1) MessageBox.Show(顾客或密码不存在!); /result = false; else reader reader = new reader(); reader.Show(); catch (Exception ex) MessageBox.Show(操作数据库出错!); Console.WriteLine(ex.Message)
8、; /result = false; finally / 关闭数据库连接 Dbhelper.connection.Close(); private void login_Load(object sender, EventArgs e) 读者界面;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.Sql;using System.Data.SqlClient;namespace book public partial class reader : Form public reader() InitializeComponent(); private void button3_Click(object sender, EventArgs e) string id =Convert.ToString (textBox1.Text); if (id!=userhelper.readerid) Messag