图书管理系统源码(C#版)_第1页
图书管理系统源码(C#版)_第2页
图书管理系统源码(C#版)_第3页
图书管理系统源码(C#版)_第4页
图书管理系统源码(C#版)_第5页
已阅读5页,还剩30页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

登录界面: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); 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, 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); /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) MessageBox.Show(输入账号与登陆账号不相同,请重新输入,提示,MessageBoxButtons.OK,MessageBoxIcon.Warning); textBox1.Text = ; textBox1.Focus(); else try string sql = string.Format(update reader set islost=0where readerid=1, 是,id); Dbhelper.connection.Open(); SqlCommand command = new SqlCommand(sql,Dbhelper.connection); int result = command.ExecuteNonQuery(); if (result 1) MessageBox.Show(修改失败); else MessageBox.Show(挂失成功); catch MessageBox.Show(error); finally Dbhelper.connection.Close(); private void toolStripButton3_Click(object sender, EventArgs e) groupBox1.Visible = false; groupBox2.Visible = true; private void toolStripButton4_Click(object sender, EventArgs e) groupBox1.Visible = true; groupBox2.Visible = false; private void button5_Click(object sender, EventArgs e) textBox2.Text = ; textBox4.Text = ; textBox5.Text = ; private void Form1_Load(object sender, EventArgs e) toolStrip1.Text = string.Format(学生:0,userhelper.readerid); private void button4_Click(object sender, EventArgs e) string id =Convert.ToString (textBox2.Text); if (id!=userhelper.readerid) MessageBox.Show(输入账号与登陆账号不相同,请重新输入,提示,MessageBoxButtons.OK,MessageBoxIcon.Warning); textBox1.Text = ; textBox1.Focus(); else if (textBox4.Text!=textBox5.Text) MessageBox.Show (两次密码输入不同); else try string sql = string.Format(update reader set readerpass=0 where readerid=1, textBox4.Text,id); Dbhelper.connection.Open(); SqlCommand command = new SqlCommand(sql,Dbhelper.connection); int result = command.ExecuteNonQuery(); if (result 1) MessageBox.Show(修改失败); else MessageBox.Show(修改成功); catch MessageBox.Show(error); finally Dbhelper.connection.Close(); private void toolStripButton6_Click(object sender, EventArgs e) addreader addreader = new addreader(); addreader = new addreader(); private void toolStripButton1_Click(object sender, EventArgs e) readsearchbook searchbook = new readsearchbook(); searchbook.Show(); private void toolStripButton2_Click(object sender, EventArgs e) borrow a = new borrow(); a.Show(); private void toolStripButton5_Click(object sender, EventArgs e) readerseacherinfo a = new readerseacherinfo(); a.Show(); private void 图书查询ToolStripMenuItem1_Click(object sender, EventArgs e) readsearchbook a = new readsearchbook(); a.Show(); this.Close(); private void 结束查询ToolStripMenuItem_Click(object sender, EventArgs e) borrow a = new borrow(); a.Show(); this.Close(); private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e) groupBox1.Visible = false; groupBox2.Visible = true; private void 挂失ToolStripMenuItem_Click(object sender, EventArgs e) groupBox1.Visible = true; groupBox2.Visible = false; private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) this.Close(); private void button2_Click(object sender, EventArgs e) Application.Exit(); 管理员界面;using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace book public partial class admin : Form public admin() InitializeComponent(); private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) this.Close(); private void admin_Load(object sender, EventArgs e) toolStrip1.Text=string.Format (管理员:登录,userhelper.adminid); private void toolStripButton4_Click(object sender, EventArgs e)/录入学生信息 addreader addreader = new addreader(); addreader.Show(); this.Close(); private void 借书信息ToolStripMenuItem_Click(object sender, EventArgs e) adminborrow a = new adminborrow(); a.Show(); private void 还书信息ToolStripMenuItem_Click(object sender, EventArgs e) adminborrow a = new adminborrow(); a.Show(); private void 添加图书ToolStripMenuItem_Click(object sender, EventArgs e) addbook a = new addbook(); a.Show(); private void 删除图书ToolStripMenuItem_Click(object sender, EventArgs e) adminearchbook a = new adminearchbook(); a.Show(); private void 查询图书ToolStripMenuItem_Click(object sender, EventArgs e) adminearchbook a = new adminearchbook(); a.Show(); private void 查询出版社信息ToolStripMenuItem_Click(object sender, EventArgs e) publisher a = new publisher(); a.Show(); this.Close(); private void 修改出版社信息ToolStripMenuItem_Click(object sender, EventArgs e) publisher a = new publisher(); a.Show(); this.Close(); private void 查询学生借阅信息ToolStripMenuItem_Click(object sender, EventArgs e) adminborrow a = new adminborrow(); a.Show(); private void toolStripButton6_Click_1(object sender, EventArgs e)/借书信息 booksborrow a = new booksborrow(); a.Show(); private void 添加ToolStripMenuItem_Click(object sender, EventArgs e) readerinfo a = new readerinfo(); a.Show(); private void 删除ToolStripMenuItem_Click(object sender, EventArgs e) deletereader a = new deletereader(); a.Show(); 添加图书信息界面: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 addbook : Form public addbook() InitializeComponent(); private void addbook_Load(object sender, EventArgs e) try string sql1 = select booktypename from booktype; SqlCommand command = new SqlCommand(sql1, Dbhelper.connection); Dbhelper.connection.Open(); SqlDataReader datareader = command.ExecuteReader(); string typename = ; while (datareader.Read() typename = (string)datareader0; comboBox2.Items.Add(typename); datareader.Close(); string sql2 = select publishername from publisher; SqlCommand command1 = new SqlCommand(sql2, Dbhelper.connection); /Dbhelper.connection.Open(); SqlDataReader datareader1 = command1.ExecuteReader(); string publishername = ; while (datareader1.Read() publishername = (string)datareader10; /MessageBox.Show(publishername); comboBox1.Items.Add(publishername); datareader1.Close(); catch MessageBox.Show(error); finally Dbhelper.connection.Close(); private void button2_Click(object sender, EventArgs e) textBox1.Text = null; textBox2.Text = null; textBox4.Text = null; comboBox2.Text = null; comboBox1.Text = null; private string typdid(string a) string id = ; string sqltypeid = string.Format(select booktypeid from booktype where booktypename=0, a); try SqlCommand command=new SqlCommand (sqltypeid,Dbhelper.connection); Dbhelper.connection.Open(); id = Convert.ToString(command.ExecuteScalar(); catch MessageBox.Show(error ); finally Dbhelper.connection.Close(); return id; private string publisheid(string a) string id = ; string sqlpublisheid = string.Format(select publisherid from publisher where publishername=0, a); try SqlCommand command = new SqlCommand(sqlpublisheid, Dbhelper.connection); Dbhelper.connection.Open(); id = Convert.ToString(command.ExecuteScalar(); catch MessageBox.Show(error ); finally Dbhelper.connection.Close(); return id; private void button1_Click(object sender, EventArgs e) string name =textBox1 .Text ; string writter=textBox2 .Text ; string publisher = comboBox1.Text; string type=comboBox2.Text; string price = textBox4.Text; /string id = textBox5.Text; string typeid = typdid(type); string publisherid = publisheid(publisher); string bianhao = textBox3.Text; try if (bianhao!=&name != &writter != & publisher!= & type != & price != ) Dbhelper.connection.Open(); string sql = string.Format(insert into book (BOOKID,bookname,bookwritter,publisherid,booktypeid,bookprice) values (0,1,2,3,4,5),bianhao, name,writter ,publisherid,typeid,price); SqlCommand commmand = new SqlCommand(sql,Dbhelper.connection ); int ab =commmand.ExecuteNonQuery(); if (ab != 0) MessageBox.Show(保存成功, 保存); else MessageBox.Show(添加失败); return; else if (name = | writter = | publisher = | type= | price= ) MessageBox .Show(请输入所有信息,错误,MessageBoxButtons .OK , MessageBoxIcon .Error ); catch /(exception ex) MessageBox.Show(操作数据库出错, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); finally Dbhelper.connection.Close(); private void button3_Click(object sender, EventArgs e) this.Close(); 添加读者信息界面: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 addreader : Form public addreader() InitializeComponent(); /退出窗口 private void button3_Click(object sender, EventArgs e

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论