附录(图书管理系统程序代码)

合集下载

图书馆管理系统设计附带源代码

图书馆管理系统设计附带源代码

毕业设计_图书管理系统一、数据库设计数据库设CREATE DATABASE TSGLGOUSE TSGLGOCREATE TABLE Bmanage(bId varchar(10) PRIMARY KEY,bName varchar(50),--添加图书--图书编号--书名bNumber varchar(10),--书数目)GObSore varchar(50)--分类CREATE TABLE Madmin(mName varchar(10)PRIMARY KEY,mPwd varchar(25),mAge varchar(8),mSex varchar(4),mNumber varchar(15),mrole varchar(8))GO--图书员管理--图书管理员姓名--图书管理员密码--图书管理员年龄--图书管理员性别--图书管理员电话--图书管理员角色CREATE TABLE Reader(rSno varchar(10) PRIMARY KEY,rName varchar(10),rPwd varchar(25),rAge varchar(8),rSex varchar(4),rState varchar(8),rNumber varchar(15),rEmail varchar(25),--读者信息表reader--读者号--姓名--密码--年龄--性别--状态--电话号码--电子邮件rAdress varChar(50),--地址) GO rGrade varChar(15),rClass varchar(15),rRole varchar(8)--年级--班级--角色CREATE TABLE Rrecord(rSno varchar(10) PRIMARY KEY, rName varChar(10),bId varchar(10),bName varChar(50),bTime varchar(10),bBackTime varchar(10))GOCREATE TABLE SysSet(rRole varchar(8)PRIMARY KEY,rState varchar(8),Fine float(25),rDay varchar(8)--读者编号学号--读者姓名--图书编号--图书名称--借书时间--还书时间--读者角色--读者可借书数--过期罚款设置--可借书天数)二、界面截图及说明1) 登录窗口(实现管理员和馆长的登陆)3) 馆长窗口5) 新增图书窗口6) 新增管理员、查找及修改窗口7) 新增读者、查找及修改窗口8) 图书的查找及修改窗口9) 借阅窗口10)系统设置窗口三、主要代码主要代1) 登录窗口(实现管理员和馆长的登陆)登陆检查:using System;usingusing System.Linq;using System.Text;using System.Data;usingnamespace{class clsLoginCheck{public static DataTable CheckLogin(string UserId,string PWD) {{string SQLstmt="selectmName,mPwd,mRolefromMadminwheremName='"+UserId +"'andmPwd='"+PWD+"'";DataTable dt=clsGlobalVar.GetDataTable(SQLstmt);return dt;}}}}登陆:using System;usingusing ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;usingusingnamespace prjTSGL.TSGL_UI{public partial class frmLogin:Form{public frmLogin(){InitializeComponent();}private void btnLogin_Click(object sender,EventArgs e){stringstringstring type="";try{DataTable dt=clsLoginCheck.CheckLogin(strUserID,strPWD);if{MessageBox.Show("登陆失败,请重新输入!");loginpwd.Focus();return; }else{type=dt.Rows[0]["mRole"].ToString().Trim();if"馆长"){if(type=="馆长"){this.Hide();frmManager objManager=new frmManager(); objManager.Show();}else{MessageBox.Show("您没有权限!"); loginpwd.Focus();return;}}else{if(type=="管理员"){this.Hide();frmAdmin objAdmin=new frmAdmin(); objAdmin.Show();}else{MessageBox.Show("您没有权限!"); loginpwd.Focus();return;}}}}catch(Exception ex) {throw ex;}}private void btnExit_Click(object sender,EventArgs e) {this.Close();}}}2) 管理员窗口using System;usingusing ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;usingnamespace prjTSGL.TSGL_UI{public partial class frmAdmin:Form{public frmAdmin(){InitializeComponent();}private void ShowForm(Form frmToShow){this.Cursor=Cursors.WaitCursor;foreach(Form frmChild in this.MdiChildren){if(frmChild.GetType()==frmToShow.GetType()) {frmToShow.Dispose();frmChild.Activate();this.Cursor=Cursors.Default;return;}}frmToShow.MdiParent=this;frmToShow.Show();this.Cursor=Cursors.Default;}private void读者信息修改ToolStripMenuItem_Click(object sender,EventArgs e){ShowForm(new frmUpdateReader());}private void新增图书ToolStripMenuItem_Click(object sender,EventArgs e){ShowForm(new frmAddNewBook());}private void图书的查找和修改ToolStripMenuItem_Click(object sender,EventArgs e) {ShowForm(new frmUpdateBook());}private void流通管理ToolStripMenuItem_Click(object sender,EventArgs e){ShowForm(new frmBorrow());}private void帮助ToolStripMenuItem_Click(object sender,EventArgs e) {ShowForm(new frmAbout());}private void退出ToolStripMenuItem_Click(object sender,EventArgs e) {Application.Exit();}}}3) 馆长窗口using System;usingusing ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;usingnamespace prjTSGL.TSGL_UI{public partial class frmManager:Form {public frmManager(){InitializeComponent();}private void ShowForm(Form frmToShow){this.Cursor=Cursors.WaitCursor;foreach(Form frmChild in this.MdiChildren){if(frmChild.GetType()==frmToShow.GetType()){frmToShow.Dispose();frmChild.Activate();this.Cursor=Cursors.Default;return;}}frmToShow.MdiParent=this;frmToShow.Show();this.Cursor=Cursors.Default;}private void frmManager_FormClosed(object sender,FormClosedEventArgs e){Application.Exit();}private void管理员信息管理ToolStripMenuItem_Click_1(object sender,EventArgs e) {ShowForm(new frmSelectAdmin());}private void系统设置ToolStripMenuItem_Click_1(object sender,EventArgs e) {ShowForm(new frmSys());}private void关于ToolStripMenuItem_Click(object sender,EventArgs e){ShowForm(new frmAbout());}private void退出ToolStripMenuItem_Click_1(object sender,EventArgs e){Application.Exit();}}}4) 关于窗口using System;usingusing ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;usingnamespace prjTSGL.TSGL_UI{public partial class frmAbout:Form{public frmAbout(){InitializeComponent();}private void button1_Click(object sender,EventArgs e){this.Close(); }}}5) 新增图书窗口using System;usingusing ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;usingusingnamespace prjTSGL.TSGL_UI{public partial class frmAddNewBook:Form {public frmAddNewBook(){InitializeComponent();}private bool ValidatInput(){if(textBox1.Text==""){MessageBox.Show("请输入图书编号!","输入提示",MessageBoxButtons.OK, rmation);textBox1.Focus();return false;}if(textBox2.Text==""){MessageBox.Show("请输入图书名称!","输入提示",MessageBoxButtons.OK, rmation);textBox2.Focus();return false;}if(textBox3.Text==""){MessageBox.Show("请输入图书数目!","输入提示",MessageBoxButtons.OK,rmation);textBox3.Focus();return false;}if(comboBox1.Text==""){MessageBox.Show("请选择图书类别!","输入提示",MessageBoxButtons.OK, rmation);textBox3.Focus();return false;}return true;}private void btnOK_Click_1(object sender,EventArgs e){if(ValidatInput())//stringid=textBox1.Text;//stringname=textBox2.Text;//stringNumber=textBox3.Text;//stringsore=comboBox1.Text;string sql="SELECT*FROMBmanageWHEREbId='""'";DataTable dt=clsGlobalVar.GetDataTable(sql);if{string SQL="insertintoBmanage(bId,bName,bNumber,bSore)values('"+ "','"()+"','""','""')";try{bool result=clsGlobalVar.ExecSQL(SQL);if(result)MessageBox.Show("添加成功!","操作提示",MessageBoxButtons.OK, rmation);textBox1.Text="";textBox2.Text="";textBox3.Text="";comboBox1.Text="";textBox1.Focus();}else{MessageBox.Show("添加失败!","操作提示",MessageBoxButtons.OK, MessageBoxIcon.Error);}}catch(Exception ex){MessageBox.Show("操作数据库出错!","操作演示",MessageBoxButtons.OK,MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}else{MessageBox.Show("图书编号已存在!","操作提示",MessageBoxButtons.OK, rmation);textBox1.Focus();}}}private void btnCancel_Click(object sender,EventArgs e){this.Close();}}}6) 新增管理员、查找及修改窗口using System;usingusing ponentModel; using System.Data;using System.Drawing;using System.Linq;using System.Text;usingusingnamespace prjTSGL.TSGL_UI{public partial class frmSelectAdmin:Form {public frmSelectAdmin(){InitializeComponent();}string name="";string SQL="";string PWD="";string Age="";string Sex="";string Tel="";string Role="";private void SelectAdmin(){string strfilter="";string SQL="selectmNameAS用户名,mPwdAS密码,mAgeAS年龄,mSexAS性别,mNumber AS电话,mRoleAS角色fromMadmin";if(txtName.Text=="")strfilter="";elsestrfilter="wheremName='""'";try{DataTable dt=clsGlobalVar.GetDataTable(SQL+strfilter);int intIndex=0;if{MessageBox.Show("抱歉,没有您要找的用户!","结果提示", MessageBoxButtons.OK,rmation);txtName.Text=""; txtPWD.Text=""; txtAge.Text=""; cboSex.Text=""; txtTel.Text=""; cboRole.Text=""; }else{{"序号",100,HorizontalAlignment.Center);for(int{HorizontalAlignment.Center);}for(int{intIndex=intI+1;LV.Items[intI].SubItems.Add(dt.Rows[intI]["用户名"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["密码"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["年龄"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["性别"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["电话"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["角色"].ToString().Trim());}}}}//连接数据库,将数据读取出放入MadminDatacatch(Exception ex){MessageBox.Show("查询数据库出错!","提示",MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}private void btnSearch_Click(object sender,EventArgs e) {SelectAdmin();//调用函数}//实现修改功能private void btnUpdata_Click(object sender,EventArgs e){if(txtName.Text==""||cboRole.Text==""){MessageBox.Show("请选择要修改的用户!");}else{SQL="UPDATEMadminSETmName='""',mPwd='"+"',mAge='""',mSex='""',mNumber='""',mRole='""'wheremName='"+name+"'ANDmPwd='"+PWD+"'ANDmAge='"+Age+"'ANDmSex='"+Sex+"'ANDmNumber='"+Tel+"'AND mRole='"+Role+"'";try{bool result=clsGlobalVar.ExecSQL(SQL);if(result){//txtName.Text="";txtPWD.Text="";txtAge.Text="";cboSex.Text="";txtTel.Text="";cboRole.Text="";MessageBox.Show("修改已成功"); SelectAdmin();}else{MessageBox.Show("更新失败!","操作提示",MessageBoxButtons.OK, MessageBoxIcon.Error);}}catch(Exception ex){MessageBox.Show("操作数据库出错!","操作演示",MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}}private void btnExit_Click(object sender,EventArgs e){this.Close();}private void LV_SelectedIndexChanged_1(object sender,EventArgs e){}private void frmSelectAdmin_Load(object sender,EventArgs e){this.btnSearch_Click(sender,e);}private void btnAdd_Click(object sender,EventArgs e){if(txtName.Text==""||txtPWD.Text==""||txtAge.Text==""||cboSex.Text== ""||txtTel.Text==""||cboRole.Text==""){}MessageBox.Show("请至少输入用户名,密码和角色!");else{SQL="SELECTmName,mPwd,mAge,mSex,mNumber,mRolefromMadminWHEREmName='"+ "'";DataTable dt=clsGlobalVar.GetDataTable(SQL);if{SQL="INSERTINTOMadminVALUES('""','"+"','""','""','"+"','""')";if(clsGlobalVar.ExecSQL(SQL)==true){//txtName.Text="";txtPWD.Text="";txtAge.Text="";cboSex.Text="";txtTel.Text="";cboRole.Text="";MessageBox.Show("成功添加新管理员!");SelectAdmin();}else{Exception ex=new Exception();MessageBox}}else{MessageBox.Show("用户名已存在,请选择其他用户名!","结果提示",MessageBoxButtons.OK,rmation); txtName.Text="";}}}private void btnDelete_Click(object sender,EventArgs e) {。

图书管理系统的C代码完整版精编版

图书管理系统的C代码完整版精编版

图书管理系统的C代码完整版GE GROUP system office room 【GEIHUA16H-GEIHUA GEIHUA8Q8-C#代码清单共1个项目,包含5个类。

项目: librarysystem类: Program.cs Readers.cs Manage.cs Menu.cs Publications.cs 主类代码:namespace librarysystem{ ///<summary>///类名:Program///功能:项目主类///时间:2015-11-19///</summary>class Program{static void Main(string[] args){Menu meu = new Menu(); meu.ShowMainMenu();Console.ReadLine();}}}出版物类代码:namespace librarysystem{ ///<summary>///类名:Publications///功能:馆藏出版物信息///时间:2015-11-19///</summary>class Publications{/*出版物编号*/private string PublicationISBN;public string PublicationIsbn{get{return PublicationISBN; }set{PublicationISBN = value; }}/*出版物名称*/public string PublicationName;/*出版物作者或出版机构*/public string PublicationAuthor;/*出版物在架状态*/public bool PublicationStatus;/*出版物类型*/public string PublicationType;public Publications(){}public Publications(string PublicationISBN,string PublicationName,string PublicationAuthor,string PublicationType,bool PublicationStatus){this. PublicationISBN = PublicationISBN;this.PublicationName = PublicationName;this.PublicationAuthor = PublicationAuthor;this.PublicationType = PublicationType;this.PublicationStatus = PublicationStatus;}}}读者类代码:namespace librarysystem{ ///<summary>///类名:Readers///功能:已获取权限读者的信息///时间:2015-11-19///</summary>class Readers{private string ReaderID;public string ReaderId{get{return ReaderID;}set{ReaderID = value;}}public string ReaderName;public string ReaderSex;public string ReaderDepartment;public string ReaderMajor;public string[] BowPublication = new string[10]{"","","","","","","","","",""};public Readers(){}public Readers(string ReaderID, string ReaderName, string ReaderSex, string ReaderDepartment, string ReaderMajor){this.ReaderID = ReaderID;this.ReaderName = ReaderName;this.ReaderSex = ReaderSex;this.ReaderDepartment = ReaderDepartment;this.ReaderMajor = ReaderMajor;}}}管理类代码:namespace librarysystem{ ///<summary>///类名:Manage///功能:管理员执行图书管理操作///时间:2015-11-19///</summary>class Manage{public bool BorrowFlag = false;/*借阅操作成功标志*/public bool ReturnFlag = false;/*归还操作成功标志*/public Publications pub_search;/*保存查询到的出版物*/public Readers Red_valid;/*保存查询到的合法用户*//*声明馆藏出版物数组*/public Publications[] pubs=new Publications[200];/*声明注册读者数组*/public Readers[] reds=new Readers[30];/*实例化馆藏出版物对象*/public Publications pub0 = new Publications("000000","C#从入门到精通","明日科技","书籍",true);public Publications pub1 = new Publications("000001", "数值分析", "李清朗", "书籍", true);public Publications pub2 = new Publications("000002", "模式识别", "张学工", "书籍", true);public Publications pub3 = new Publications("000003", "中国国家地理", "地理科学院", "杂志", true);public Publications pub4 = new Publications("000004", "意林", "长春市文学艺术界联合会 ", "杂志", true);public Publications pub5 = new Publications("000005", "四川大学报", "四川大学", "报纸", true);public Publications pub6 = new Publications("000006", "经济学人", "伦敦经济学人报纸有限公司", "杂志", true);public Publications pub7 = new Publications("000007", "计算机网络", "谢希仁", "书籍", true);public Publications pub8 = new Publications("000008", "红楼梦", "曹雪芹", "书籍", true);public Publications pub9 = new Publications("000009", "新东方雅思培训课程", "俞敏洪", "音像制品", true);public Publications pub10 = new Publications("000010", "MATLAB实用教程", "张世杰", "音像制品", true);/*实例化已注册读者对象*/public Readers red0 = new Readers(, "李华", "男", "电子信息学院", "电子与通信工程");public Readers red1 = new Readers(, "王鹏", "男", "物理学院", "微电子学");public Readers red2 = new Readers(, "张建豪", "男", "数学学院", "现代数学分析");public Readers red3 = new Readers(, "陈莉", "女", "化学化工学院", "化学分析");public Readers red4 = new Readers(, "吴娜", "女", "医学院", "口腔医学");public Readers red5 = new Readers(, "宋雅茹", "女", "电子信息学院", "光学工程");/*初始化出版物数组*/public void PublicationsInitial(){pubs[0] = pub0;pubs[1] = pub1;pubs[2] = pub2;pubs[3] = pub3;pubs[4] = pub4;pubs[5] = pub5;pubs[6] = pub6;pubs[7] = pub7;pubs[8] = pub8;pubs[9] = pub9;pubs[10] = pub10;}/*初始化读者数组*/public void ReadersInitial() {reds[0] = red0;reds[1] = red1;reds[2] = red2;reds[3] = red3;reds[4] = red4;reds[5] = red5;}/*查询图书操作*/public bool SearchPublications(){string Pub_Name;bool SearchFlag = false;Pub_Name = Console.ReadLine();foreach (Publications pub in pubs){if (pub != null && pub.PublicationName == Pub_Name) {SearchFlag = true;pub_search = pub;}}return SearchFlag;}/*借阅图书操作*/public void Borrow(){string Red_Name;string Pub_Name;bool ReaderFlag = false;Red_Name = Console.ReadLine();foreach (Readers red in reds){if (red != null && red.ReaderName == Red_Name){ReaderFlag = true;Red_valid = red;}}if (ReaderFlag){Console.Write("请输入您需要借阅出版物的名称:");Pub_Name = Console.ReadLine();foreach (Publications pub in pubs){if (pub != null && pub.PublicationName == Pub_Name) {BorrowFlag = true;pub.PublicationStatus = false;AddToReders(pub.PublicationName, Red_valid);}}}else{Console.WriteLine("抱歉,您是非法读者,不能借阅图书"); }}/*归还图书操作*/public void Return(){string Red_Name;string Pub_Name;bool ReaderFlag = false;Red_Name = Console.ReadLine();foreach (Readers red in reds){if (red != null && red.ReaderName == Red_Name){ReaderFlag = true;Red_valid = red;}}if (ReaderFlag){Console.Write("请输入您需要归还出版物的名称:");Pub_Name = Console.ReadLine();foreach (Publications pub in pubs){if (pub != null && pub.PublicationName == Pub_Name) {for (int i = 0; i < 10;i++ ){if (Red_valid.BowPublication[i] == Pub_Name) {ReturnFlag = true;pub.PublicationStatus = true;RemoveFromReders(Pub_Name, Red_valid); }}}}}else{Console.WriteLine("抱歉,您是非法读者,无归还图书信息"); }}/*添加图书到读者*/private void AddToReders(string PublicationName, Readers red) {/*设置借阅上限为10本*/for (int i = 0; i < 10; i++){if (red != null && red.BowPublication[i]==""){red.BowPublication[i] = PublicationName;break;}}}/*从读者对象中移除图书*/private void RemoveFromReders(string PublicationName, Readers red){/*设置借阅上限为10本*/for (int i = 0; i < 10; i++){if (red != null && red.BowPublication[i] == PublicationName){red.BowPublication[i] = red.BowPublication[i+1]; }}}/*新书入库操作*/public void AddPublications(Publications pub){for (int i = 11; i < 200; i++){if(pubs[i]==null){pubs[i] = pub;}}}/*添加新读者操作*/public void AddReaders(Readers red) {for (int i = 6; i < 30; i++){if (reds[i] == null){reds[i] = red;}}}/*查询读者信息*/public void RedIndex(){string Red_Name;bool ReaderFlag = false;Red_Name = Console.ReadLine();foreach (Readers red in reds){if (red != null && red.ReaderName == Red_Name) {ReaderFlag = true;Red_valid = red;}}if (!ReaderFlag){Console.WriteLine("抱歉,您是非法读者,无法查到您的借阅信息");}}}}菜单类代码:namespace librarysystem{ ///<summary>///类名:Menu///功能:显示服务页面///时间:2015-11-19///</summary>class Menu{//创建一个具体的管理对象Manage mag = new Manage();//声明一个读者对象Readers red;//声明一个出版物对象Publications pub;public void ShowMainMenu(){mag.PublicationsInitial();mag.ReadersInitial();Console.WriteLine("欢迎使用图书管理系统V1.0");Console.WriteLine("-------------------------------------------------------------------");Console.WriteLine("1.查询图书");Console.WriteLine("2.借书服务");Console.WriteLine("3.还书服务");Console.WriteLine("4.新出版物入库");Console.WriteLine("5.录入新读者");Console.WriteLine("6.查询读者的借阅信息");Console.WriteLine("7.退出管理系统");Console.WriteLine("-------------------------------------------------------------------");bool flag;do{flag = false;Console.WriteLine("请选择:");string key = Console.ReadLine();switch (key){case"1":Console.Write("请输入需要查询图书的书名:");ShowPubInfo();break;case"2":Console.Write("请输入您的姓名:");mag.Borrow();ShowBorrowInfo();break;case"3":Console.Write("请输入您的姓名:");mag.Return();ShowReturnInfo();break;case"4":Console.WriteLine("请按照提示逐步输入需要入库出版物的信息……");ShowAddPublications();break;case"5":Console.WriteLine("请按照提示逐步输入新注册读者的信息……");ShowAddReaders();break;case"6":Console.Write("请输入您的姓名: ");mag.RedIndex();ShowRedPubInfo(mag.Red_valid);break;case"7":flag = false;break;default:Console.WriteLine("无此业务,是否重新选择(y/n)");string answer = Console.ReadLine();if (answer != "y"){flag = false;}else{flag = true;}break;}} while (flag);}/*显示查询到的出版物信息*/public void ShowPubInfo(){if (mag.SearchPublications()){Console.WriteLine("您要查询的出版物信息:");Console.WriteLine("-------------------------------------------------------------------");Console.WriteLine("编号: " +mag.pub_search.PublicationIsbn);Console.WriteLine("出版物名字: " +mag.pub_search.PublicationName);Console.WriteLine("出版物作者: " +mag.pub_search.PublicationAuthor);Console.WriteLine("出版物类型: " +mag.pub_search.PublicationType);if (mag.pub_search.PublicationStatus){Console.WriteLine("出版物状态:在架,可借");}else{Console.WriteLine("出版物状态:未在架,不可借");}Console.WriteLine("-------------------------------------------------------------------");Console.WriteLine("");Console.WriteLine("");Console.WriteLine("是否办理其他业务(y/n)");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();}else{Console.WriteLine("结束");}}else{Console.WriteLine("抱歉,未找到该图书!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();Console.WriteLine();}else{Console.WriteLine("结束");}}}/*显示借阅操作结果*/public void ShowBorrowInfo(){if (mag.BorrowFlag){Console.WriteLine("恭喜,借阅成功!"); ShowRedPubInfo(mag.Red_valid);}else{Console.WriteLine("抱歉,借阅失败!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();}else{Console.WriteLine("结束");}}}/*显示归还操作结果*/public void ShowReturnInfo(){if (mag.ReturnFlag){Console.WriteLine("恭喜,归还成功!");ShowRedPubInfo(mag.Red_valid);}else{Console.WriteLine("抱歉,归还失败!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();}else{Console.WriteLine("结束");}}}public void ShowRedPubInfo(Readers red){Console.WriteLine("当前你的借阅信息如下:");Console.WriteLine("--------------------------------------------------------------------");Console.WriteLine("编号: " + red.ReaderId);Console.WriteLine("姓名: " + red.ReaderName);Console.WriteLine("性别: " + red.ReaderSex);Console.WriteLine("所在院系: " + red.ReaderDepartment);Console.WriteLine("主修专业: " + red.ReaderMajor);Console.Write("已借图书: ");for (int{if (red.BowPublication[i] != ""){Console.Write(" "+red.BowPublication[i]);}}Console.WriteLine("");Console.WriteLine("--------------------------------------------------------------------");Console.WriteLine("");Console.WriteLine("是否办理其他业务(y/n)");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();}else{Console.WriteLine("结束");}}/*显示新出版物入库的信息*/public void ShowAddPublications(){pub = new Publications();Console.Write("请输入出版物的编号: "); pub.PublicationIsbn=Console.ReadLine();Console.Write("请输入出版物的名称: ");pub.PublicationName = Console.ReadLine();Console.Write("请输入出版物的编者: ");pub.PublicationAuthor = Console.ReadLine();Console.Write("请输入出版物的类型: ");pub.PublicationType = Console.ReadLine(); pub.PublicationStatus = true;mag.AddPublications(pub);Console.WriteLine("新出版物入库成功!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();Console.WriteLine();}else{Console.WriteLine("结束");}}/*显示新读者注册的信息*/public void ShowAddReaders(){red = new Readers();Console.Write("请输入新注册读者的编号: "); red.ReaderId = Console.ReadLine();Console.Write("请输入新注册读者的姓名: "); red.ReaderName= Console.ReadLine();Console.Write("请输入新注册读者的性别: ");red.ReaderSex = Console.ReadLine();Console.Write("请输入新注册读者的院系: "); red.ReaderDepartment = Console.ReadLine();Console.Write("请输入新注册读者的专业: "); red.ReaderMajor = Console.ReadLine();for(int i=0;i<10;i++){red.BowPublication[i]="";}mag.AddReaders(red);Console.WriteLine("新读者注册成功!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();Console.WriteLine();}else{Console.WriteLine("结束"); }}}}。

图书管理系统程序源代码

图书管理系统程序源代码

源程序1.主窗体Private Sub add_back_Click()frmbackbookinfo.ShowEnd SubPrivate Sub add_binf_Click()frmaddbookinfo.ShowEnd SubPrivate Sub add_book_style_Click()frmaddbookstyle。

ShowEnd SubPrivate Sub add_manager_Click()frmadduser.ShowEnd SubPrivate Sub add_rinf_Click() frmaddreaderinfo.ShowEnd SubPrivate Sub add_rstyle_Click()frmaddreaderstyle.ShowEnd SubPrivate Sub change_binf_Click() frmmodifybookinfo。

ShowEnd SubPrivate Sub change_book_style_Click()frmmodifybookstyle。

ShowEnd SubPrivate Sub delete_binf_Click()frmmodifybookinfo。

ShowEnd SubPrivate Sub delete_book_style_Click()frmmodifybookstyle.ShowEnd SubPrivate Sub delete_rstyle_Click()frmmodifyreaderstyle。

ShowEnd SubPrivate Sub exit_Click()EndEnd SubPrivate Sub find_binf_Click()frmfindbook。

ShowEnd SubPrivate Sub find_lend_Click()frmfindborrowinfo。

ShowEnd SubPrivate Sub find_rinf_Click()frmfindreader.ShowEnd SubPrivate Sub password_Click()frmchangepwd。

(完整word版)图书管理系统源代码

(完整word版)图书管理系统源代码

图书管理系统源代码(一)程序代码1。

主窗口界面import java.awt。

*;import java.awt。

event.*;import javax。

swing.*;import javax.swing.border.TitledBorder;import java.awt。

Font;import javax.swing。

JMenu;public class MainWindow extends JFrame implements ActionListener { private static final long serialVersionUID = 1L;static String loginName;static String loginNo;JLabel mlabel;JPanel jp=new JPanel();//建立菜单栏JMenu a=new JMenu();JMenu b=new JMenu();JMenu c=new JMenu();//建立系统管理菜单组JMenuItem aa=new JMenuItem();JMenuItem ab=new JMenuItem();JMenuItem ac=new JMenuItem();//建立读者管理菜单组JMenuItem bb=new JMenuItem();//建立书籍管理菜单组JMenuItem ca=new JMenuItem();JMenuItem cb=new JMenuItem();JMenuItem cc=new JMenuItem();JMenuItem cd=new JMenuItem();public MainWindow(){super(”图书管理系统");addWindowListener(new WindowAdapter(){System.exit(0);}});Container d=getContentPane();this。

图书管理系统(内附源代码)

图书管理系统(内附源代码)

本人是一个初学者,2个月前学习C#,学习过程中遇到过许多困难无法独立解决,现在做成了第一个系统:图书管理系统,各项功能均能顺利实现,因为知道很多初学者和我一样苦无求学之道,现在将部分主要源码上传,希望能得到高手的指点.下面就是该系统的主要功能及代码:1。

登陆界面主要代码:public partial class LoginForm:Form{public static string uacc;public static string upsw;public static string uname;public static string usex;public static string upart;public static string uright;public LoginForm(){InitializeComponent();}private void loginbtn_Click(object sender, EventArgs e){if (this。

useracctxt.Text.Trim() == ""&&this。

pswtxt.Text == "”){MessageBox。

Show("请输入您的用户名和密码!”, ”提示!”);return;}try{string sql;sql = "select * from tb_user where uacc='" + eracctxt。

Text + ”' and upsw=’" + this.pswtxt.Text + "'";OleDbDataReader dr = DBHelp.OleReader(sql);dr。

Read();if(dr.HasRows){uacc = eracctxt。

Text;upsw = this.pswtxt。

图书管理系统附录

图书管理系统附录

附录:
一、打开文件
在fstream类中,有一个成员函数open(),就是用来打开文件的,其原型是:
void open(const char* filenam e,int m ode,int access);
参数:
filename:要打开的文件名
mode:要打开文件的方式
access:打开文件的属性
打开文件的方式在类ios(是所有流式I/O类的基类)中定义,常用的值如下:
ios::app:以追加的方式打开文件
ios::ate:文件打开后定位到文件尾,ios:app就包含有此属性
ios::binary:以二进制方式打开文件,缺省的方式是文本方式。

两种方式的区别见前文ios::in:文件以输入方式打开
ios::out:文件以输出方式打开
ios::nocreate:不建立文件,所以文件不存在时打开失败
ios::noreplace:不覆盖文件,所以打开文件时如果文件存在失败
ios::trunc:如果文件存在,把文件长度设为0
二、
read()成员函数的第一个参数是一个字符指针(即char *类型),而b是一个int变量,所以在传递之前要先进行类型转换,首先取b的地址(也就是&b的作用),然后再把这个地址转换为char *类型,所以要写成(char *)&b,转换之后最终将数据存入b变量,但在使用b时,会按int类型解释i里面的数据。

而且read()成员函数的第二个参数就是用于控制最多读取多少字节的内容,像这里,它最多只会读取sizeof(b)个字节的数据,而sizeof(b)将返回b变量的字节宽度,在32位系统上,它的值是4,也就是说,这里的read()调用最多读取4个字节的数据到b变量的空间中(也就是4个字符)。

图书馆书籍管理系统说明书(附代码)

图书馆书籍管理系统说明书(附代码)

大型数据库应用课程设计课程设计说明书图书馆书籍管理系统起止日期: 2014 年 12 月 1 日至 2014 年 12 月 7 日学生姓名肖魁班级计算机1102班学号11408100214成绩指导教师(签字)计算机与通信学院2012年12月 7 日图书馆书籍管理系统一、课题的介绍和课题的任务图书馆书籍管理系统主要对图书馆中书籍进行管理,包括对书籍的添加,删除,修改,各种方式的查询等操作,用于管理员对图书馆书籍库的管理;采用Oracle作为数据库,应用了Java,Jsp,JavaScript,SQL等编程语言以及 Struts2,JDBC等等技术,另外系统采用B/S结构,MVC的设计模式进行设计,在数据库方面,多处应用了存储过程和触发器;二、课程设计的要求1、书籍的添加:通过触发器和索引,使图书的编号按照自动增长的方式进行添加,其他字段还有:书籍名称,作者,出版社,页数,藏书地址等;并且通过定义触发器,使每增加一条图书信息,在图书状态表中给其增加对应的图书状态信息;2、书籍的删除:通过存储过程来实现,如果该书的状态为已借出,就不能删除书籍,并发出提示信息;书籍的删除,通过定义before触发器,假如该书籍能够删除,就在其删除之前,删掉该书籍的状态信息;3、书籍的修改:修改除了书籍主键外的其他信息;4、书籍的查询:可根据图书的索引号进行精确查询,可以根据图书的书名,作者,出版社,藏书地址等进行模糊查询,基于系统的需求,还提供系统中以所有字段作为关键字的模糊查询;5、用户身份验证,管理员通过用户登录,输入验证信息,若经过系统验证后,若正确,则进入图书管理主页,若出现错误,则跳到登录界面,并返回相应的友好的错误提示信息;三、系统的分析和系统中数据库的分析(ER图等)1、系统设计1.1.系统概要设计-流程图系统总体设计如图1.1所示图1-1实现用户的登录,管理员登录后对图书进行书籍的添加,书籍各种方式的查询,书籍的修改,书籍的删除;1.2.系统的详细设计1.2.1.用户的登录图书管理员通过输入管理员和密码进行验证,若验证正确,则进入系统。

图书管理系统代码

图书管理系统代码

图书管理系统代码//***********************//图书馆管理系统//***********************#include<stdio.h>#include<string.h>#include<malloc.h>#define null 0#define max 65536static int n;//*********************// 图书结构体//*********************typedef struct{char num[10]; //书号char name[9]; //书名char addr[31]; //作者int Nowcounter; //现存量int Allcounter; //总库存量}datatype;datatype *x[max]; //定义两个指针数组datatype *p;//*****************************//图书功能函数列表//*****************************void redo(); //主递归函数void creatlist(datatype *x[]); //图书建立函数int menu_select(); //功能菜单函数void find(datatype *x[],int n); //查找函数void delnode(datatype *x[]); //插入函数void printlist(datatype *x[]); //显示函数void jieyue(datatype *x[],int n); //借阅函数void guihuan(datatype *x[],int n); //归还函数//*****************************//主递归函数程序//*****************************void redo(){int i=0,j,n1,k=0,flage;for( ; ;){switch( menu_select()){case 1: //选项1的实现printf("***********************\n");printf("* 图书的建立*\n");printf("***********************\n");creatlist(x);break;case 2: //选项2的实现printf("***********************\n");printf("* 新图书信息的添加*\n");printf("***********************\n");printf(" 插入的个数:");scanf("%d",&n1); //输入插入新图书的个数for(i=0;i<n1;i++){flage=0;p=(datatype *)malloc(sizeof(datatype)); //分配一个节点空间printf(" 书名: ");scanf("%s",p->name); //输入插入书的书名if(flage==0){for(j=0;j<n;j++){if(strcmp(x[j]->name,p->name) == 0 )//调用比较函数查看书名是否已知{x[j]->Allcounter++;x[j]->Nowcounter++;flage=1;}}if(flage==0){n++;printf(" 第%d 个图书数据:\n",n); //插入新的图书p=(datatype *)malloc(sizeof(datatype));x[n-1]=p;printf(" 书名:");scanf("%s",x[n-1]->name); //输入书名printf(" 编号:");scanf(" %s",x[n-1]->num); //输入书号printf(" 作者:");scanf(" %s",x[n-1]->addr); // 输入作者名printf(" 总库存量:");scanf("%d",&x[n-1]->Allcounter); //输入总库存量x[n-1]->Nowcounter=x[n-1]->Allcounter;}}}break;case 3:printf("***********************\n");printf("* 图书信息的查询*\n");printf("***********************\n");find(x,n);break;case 4:printf("************************\n");printf("* 图书信息的删除*\n");printf("************************\n");delnode(x);break;case 5:printf("************************\n");printf("* 图书信息的显示*\n");printf("************************\n");printlist(x);break;case 6:printf("************************\n");printf(" 图书的借阅\n");printf("************************\n");jieyue(x,n);break;case 7:printf("************************\n");printf(" 图书的归还\n");printf("************************\n");guihuan(x,n);break;case 0:printf("\t 谢谢使用,再见! \n");return;}}//*************************//主函数程序//*************************void main (){redo(); //调用主递归函数}//*************************//功能菜单函数//*************************int menu_select(){int i;printf(" 欢迎进入图书管理系统!\n");printf("===========================\n");printf(" 1. 图书信息的采集\n");printf(" 2. 新图书的插入\n");printf(" 3. 图书信息的查询\n");printf(" 4. 图书的删除\n");printf(" 5. 图书的显示\n");printf(" 6. 图书的借阅\n");printf(" 7. 图书的归还\n");printf(" 0. 退出管理系统\n");printf("===========================\n");printf(" 请选择0-7: ");scanf("%d",&i);while(i<0||i>7){printf("\n\t输入出错,重选0-7: ");scanf("%d",&i);}return i;}//********************************// 建立链表图书建造函数//********************************void creatlist(datatype *x[]){int i;printf(" 请输入要建立图书的个数:");scanf("%d",&n);for(i=0;i<n;i++)printf(" 第%d 个图书数据:\n",i+1);p=(datatype *)malloc(sizeof(datatype)); //分配一个节点空间x[i]=p;printf(" 书名:"); //输入图书各项内容scanf("%s",x[i]->name);printf(" 编号:");scanf(" %s",x[i]->num);printf(" 作者:");scanf(" %s",x[i]->addr);printf(" 总库存量:");scanf("%d",&x[i]->Allcounter);x[i]->Nowcounter=x[i]->Allcounter;}}//**********************************// 查找函数程序//*********************************void find(datatype *x[],int n){char num[10];char name[9];int t,i;printf("=================\n"); //输出查找方式printf(" 1.按编号查询\n");printf(" 2.按书名查询\n");printf("=================\n");printf(" 请选择: ");scanf("%d",&t); //输入选择信息if(t==1){printf(" 请输入要查找者的编号: ");scanf("%s",num); //输入书号for(i=0;i<n;i++){if(strcmp(x[i]->num,num)==0) //调用strcmp函数{printf(" 编号书名作者现库存量总库存量\n");//输出要查询书的信息printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i]->Nowcounter,x[i]->Allcounter);elsecontinue;}}else{printf(" 请输入要查询的书名: ");scanf("%s",name); // 输入书名for(i=0;i<n;i++){if(strcmp(x[i]->name,name)==0){printf("编号书名作者现库存量总库存量\n"); //输出要查询书的信息printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i ]->Nowcounter,x[i]->Allcounter);}elsecontinue;}}}//******************************//删除函数程序//******************************void delnode(datatype *x[]){char num1[10],name1[10]; //定义两个字符数组int i,j,m=1,p;printf(" 1.按编号删除\n"); //输出选择方式printf(" 2.按书名删除\n");printf(" 3.返回\n");printf(" 请选择:\n");scanf("%d",&p); //输入选择信息if(p>3||p<1){printf(" 您的输入有误,请重新输入!\n");scanf("%d",&p); //重新输入选择信息}switch(p) //实现删除程序{case 1:printf(" 输入要删除书的编号:\n");scanf(" %s",num1);for(i=0;i<n;i++){if(strcmp(x[i]->num,num1)==0) //调用strcmp函数{m=0;n--;for(j=i;j<n;j++)x[j]=x[j+1]; //将该书信息删除printf(" 该书已删除!\n");}}if(m==1)printf(" 没有这样的的图书\n");break;case 2:printf(" 输入要删除书的名字:\n");scanf("%s",&name1);for(i=0;i<n;i++){if(strcmp(x[i]->name,name1)==0) //调用strcmp函数{m=0;n--;for(j=i;j<n;j++) //将该书信息删除x[j]=x[j+1];printf(" 该书已删除!\n");}}if(m==1)printf(" 没有这样的的图书\n");break;case 3:break;}}//////////////////////////////借阅函数程序/////////////////////////void jieyue(datatype *x[],int n){int i,m=1,p;char name1[10],num1[10]; //定义两个字符数组printf(" 1.按名字借阅\n"); //输出选择方式printf(" 2.按编号借阅\n");printf(" 3.返回\n");printf(" 请选择\n");scanf("%d",&p); //输入选择信息if(p>3||p<1){printf(" 您的输入有误!\n");scanf("%d",&p); //重新输入选择信息}switch(p) //实现查询程序{case 1:printf(" 请输入你要的书的名字!\n");scanf("%s",&name1); // 输入书名for(i=0;i<n;i++){if(strcmp(x[i]->name,name1)==0) //调用strcmp函数{m=0;if(x[i]->Nowcounter!=0)x[i]->Nowcounter--;printf(" 借书成功!\n");if(x[i]->Nowcounter==0)printf(" 这本书已经没有了\n");}}if(m==1)printf(" 您要的书不存在!\n");break;case 2:printf(" 请输入你要的书的编号!\n");scanf("%s",&num1); // 输入书号for(i=0;i<n;i++){if(strcmp(x[i]->num,num1)==0) //调用strcmp函数{m=0;if(x[i]->Nowcounter!=0)x[i]->Nowcounter--; //现存书数量减1printf(" 借书成功!\n");if(x[i]->Nowcounter==0)printf(" 这本书已经没有了\n");}}if(m==1)printf(" 您要的书不存在!\n");break;case 3:break;}}////////////////////////////归还程序//////////////////////void guihuan(datatype *x[],int n){int i,q,m=1;char name1[10],num1[10]; //定义两个字符数组printf(" 1.按书名归还\n"); //输出可选择方式printf(" 2.按书号归还\n");printf(" 3.返回\n");printf(" 请选择\n");scanf("%d",&q); //输入选择信息if(q>3||q<1){printf(" 您的输入有误!\n");scanf("%d",&q); //重新输入选择信息}switch(q) //实现归还程序{case 1:printf(" 输入归还书的书名: ");scanf("%s",&name1); // 输入书名for(i=0;i<n;i++){if(strcmp(x[i]->name,name1)==0){m=0;x[i]->Nowcounter++;printf("此书归还成功!\n");printf("此书的存储情况\n");printf("编号书名作者现存量总存量\n"); printf("===============================================\n");printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i]->Nowcounter,x[i]->Allcounter);printf("===============================================\n");}if(strcmp(x[i]->name,name1)==0)continue;}if(m==1)printf("此书不是图书馆的!\n");break;case 2:printf("输入归还书的书号\n");scanf("%s",&num1); // 输入书号for(i=0;i<n;i++){if(strcmp(x[i]->num,num1)==0){m=0;x[i]->Nowcounter++; //显存书增加1printf("此书归还成功!\n");printf("此书的存储情况\n");printf("编号书名作者现存量总存量\n"); printf("==============================================\n");printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i]->Nowcounter,x[i]->Allcounter);printf("==============================================\n");}if(strcmp(x[i]->num,num1)==0) //调用strcmp 函数continue;}if(m==1)printf("此书不是图书馆的!\n");break;case 3:break;}}//**************************************第一章// 输出程序//**************************************void printlist(datatype *x[]){int i;printf("编号书名作者现存量总存量\n");//输出图书各项信息for(i=0;i<n;i++){printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i ]->Nowcounter,x[i]->Allcounter);}printf("===============================================\n");}页脚内容11。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

附录主页面(MDImain):Private Sub addbook_Click()add_book.ShowEnd SubPrivate Sub addreader_Click()add_reader.ShowEnd SubPrivate Sub adduser_Click()add_user.ShowEnd SubPrivate Sub backbook_Click()back_book.ShowEnd SubPrivate Sub borrowbook_Click()borrow_book.ShowEnd SubPrivate Sub cuibackbook_Click()cuiback_book.ShowEnd SubPrivate Sub findbook_Click()find_book.ShowEnd SubPrivate Sub findreader_Click()find_reader.ShowEnd SubPrivate Sub MDIForm_Load()End SubPrivate Sub modifybook_Click()change_book.ShowEnd SubPrivate Sub modifypwd_Click()change_pwd.ShowEnd SubPrivate Sub modifyreader_Click()change_reader.ShowEnd SubPrivate Sub delbook_Click()del_book.ShowEnd SubPrivate Sub delreder_Click()del_reader.ShowEnd SubPrivate Sub quitsys_Click()EndEnd Sub登陆(login):Option ExplicitDim cnt As Integer '记录确定次数Private Sub Command1_Click()Dim sql As StringDim rs_login As New ADODB.RecordsetIf Trim(txtuser.Text) = "" Then '判断输入的用户名是否为空MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""txtuser.SetFocusElsesql = "select * from 用户表where 用户名='" & txtuser.Text & "'"rs_login.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_login.EOF = True ThenMsgBox "没有这个用户", vbOKOnly + vbExclamation, ""txtuser.SetFocusElse '检验密码是否正确If Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) ThenuserID = txtuser.Textuserpow = rs_login.Fields(2)rs_login.CloseUnload MeMsgBox "欢迎登录到图书管理系统!", vbOKOnly + vbExclamation, ""MDImain.ShowElseMsgBox "密码不正确", vbOKOnly + vbExclamation, ""txtpwd.SetFocusEnd IfEnd IfEnd Ifcnt = cnt + 1If cnt = 3 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim connectionstring As Stringconnectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _"data source=图书管理系统.mdb"conn.Open connectionstringcnt = 0End Sub添加用户(add_user):Private Sub Command1_Click()Dim sql As StringDim rs_add As New ADODB.RecordsetIf Trim(Text1.Text) = "" ThenMsgBox "用户名不能为空", vbOKOnly + vbExclamation, ""Exit SubText1.SetFocusElsesql = "select * from 用户表"rs_add.Open sql, conn, adOpenKeyset, adLockPessimisticWhile (rs_add.EOF = False)If Trim(rs_add.Fields(0)) = Trim(Text1.T ext) ThenMsgBox "已有这个用户", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""Text2.Text = ""Text3.Text = ""Combo1.Text = ""Exit SubElsers_add.MoveNextEnd IfWendIf Trim(Text2.Text) <> Trim(Text3.Text) ThenMsgBox "两次密码不一致", vbOKOnly + vbExclamation, ""Text2.SetFocusText2.Text = ""Text3.Text = ""Exit SubElseIf Trim(Combo1.Text) <> "system" And Trim(Combo1.Text) <> "guest" Then MsgBox "请选择正确的用户权限", vbOKOnly + vbExclamation, ""Combo1.SetFocusCombo1.Text = ""Exit SubElsers_add.AddNewrs_add.Fields(0) = Text1.Textrs_add.Fields(1) = Text2.Textrs_add.Fields(2) = Combo1.Textrs_add.Updaters_add.CloseMsgBox "添加用户成功", vbOKOnly + vbExclamation, ""Unload MeEnd IfEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Combo1.AddItem "system"Combo1.AddItem "guest"If userpow = "guest" Then '权限相关Command1.Enabled = FalseCommand2.Enabled = FalseEnd IfEnd Sub添加读者(add_reader):Option ExplicitDim rs_addreader As New ADODB.RecordsetPrivate Sub Command1_Click()Dim sql As StringIf Trim(Text1.Text) = "" ThenMsgBox "借书证号不能为空", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = "" ThenMsgBox "所在单位不能为空", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Trim(Text3.Text) = "" ThenMsgBox "姓名不能为空", vbOKOnly + vbExclamation, ""Text3.SetFocusExit SubEnd IfIf Trim(Text4.Text) = "" ThenMsgBox "性别不能为空", vbOKOnly + vbExclamation, ""Text4.SetFocusExit SubEnd IfIf Trim(Text5.Text) = "" ThenMsgBox "类型不能为空", vbOKOnly + vbExclamation, ""Text5.SetFocusExit SubEnd IfIf Trim(Text6.Text) = "" ThenMsgBox "地址不能为空", vbOKOnly + vbExclamation, ""Text6.SetFocusExit SubEnd Ifsql = "select * from 读者表where 借书证号='" & Text1.T ext & "'" rs_addreader.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_addreader.EOF Thenrs_addreader.AddNewrs_addreader.Fields(0) = Trim(Text1.Text)rs_addreader.Fields(1) = Trim(Text2.Text)rs_addreader.Fields(2) = Trim(Text3.Text)rs_addreader.Fields(3) = Trim(Text4.Text)rs_addreader.Fields(4) = Trim(Text5.T ext)rs_addreader.Fields(5) = Trim(Text6.Text)rs_addreader.UpdateMsgBox "添加读者信息成功!", vbOKOnly, ""Unload MeElseMsgBox "借书证号重复!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""rs_addreader.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()If userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfEnd Sub删除读者(del_reader):Option ExplicitDim rs_reader As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_reader.CancelUpdateDataGrid1.RefreshDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmddel_Click()Dim answer As StringOn Error GoT o delerroranswer = MsgBox("确定要删除吗?", vbYesNo, "")If answer = vbYes ThenDataGrid1.AllowDelete = Truers_reader.Deleters_reader.UpdateDataGrid1.RefreshMsgBox "成功删除!", vbOKOnly + vbExclamation, ""DataGrid1.AllowDelete = Falsers_reader.UpdateDataGrid1.RefreshElseExit SubEnd Ifdelerror:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubPrivate Sub cmdquit_Click()Unload MeEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_reader.UpdateEnd Ifcmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "修改成功!", vbOKOnly + vbExclamation, ""End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoT o loaderrorsql = "select * from 读者表"rs_reader.CursorLocation = adUseClientrs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库cmdupdate.Enabled = False'设定datagrid控件属性DataGrid1.AllowAddNew = False '不可增加DataGrid1.AllowDelete = False '不可删除DataGrid1.AllowUpdate = FalseIf userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_reader'cmdcancel.Enabled = FalseExit Subloaderror:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Unload(Cancel As Integer) Set DataGrid1.DataSource = Nothingrs_reader.CloseEnd Sub修改读者(change_reader):Option ExplicitDim rs_reader As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_reader.CancelUpdateDataGrid1.RefreshDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmdquit.Enabled = Truecmdchange.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmdchange_Click()Dim answer As StringOn Error GoT o cmdchangecmdquit.Enabled = Truecmdchange.Enabled = False cmdupdate.Enabled = True cmdcancel.Enabled = TrueDataGrid1.AllowUpdate = True cmdchange:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubUnload MeEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_reader.UpdateEnd Ifcmdquit.Enabled = Truecmdchange.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "修改成功!", vbOKOnly + vbExclamation, ""End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoT o loaderrorsql = "select * from 读者表"rs_reader.CursorLocation = adUseClientrs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库cmdupdate.Enabled = False'设定datagrid控件属性DataGrid1.AllowAddNew = False '不可增加DataGrid1.AllowDelete = False '不可删除DataGrid1.AllowUpdate = FalseIf userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_reader'cmdcancel.Enabled = FalseExit Subloaderror:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Unload(Cancel As Integer)Set DataGrid1.DataSource = Nothingrs_reader.CloseEnd Sub查询读者(find_reader):Option ExplicitDim rs_findreader As New ADODB.RecordsetDim sql As StringIf Check1.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "借书证号='" & Trim(Text1.T ext & " ") & "'"Elsesql = sql & "and 借书证号='" & Trim(Text1.T ext & " ") & "'"End IfEnd IfIf Check2.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "姓名='" & Trim(Text2.T ext & " ") & "'"Elsesql = sql & "and 姓名='" & Trim(Text2.T ext & " ") & "'"End IfEnd Ifsql = "select * from 读者表where " & sqlrs_findreader.CursorLocation = adUseClientrs_findreader.Open sql, conn, adOpenKeyset, adLockPessimistic DataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_findreader'rs_findreader.CloseEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub添加图书(add_book):Option ExplicitDim rs_addbook As New ADODB.RecordsetPrivate Sub Command1_Click()Dim sql As StringIf Trim(Text1.Text) = "" ThenMsgBox "书号不能为空", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = "" ThenMsgBox "分类号不能为空", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Trim(Text3.Text) = "" ThenMsgBox "作者不能为空", vbOKOnly + vbExclamation, ""Text3.SetFocusExit SubEnd IfIf Trim(Text4.Text) = "" ThenMsgBox "出版社不能为空", vbOKOnly + vbExclamation, ""Text4.SetFocusExit SubEnd IfIf Trim(Text5.Text) = "" ThenMsgBox "单价不能为空", vbOKOnly + vbExclamation, ""Text5.SetFocusExit SubEnd Ifsql = "select * from 图书表where 书号='" & Text1.T ext & "'" rs_addbook.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_addbook.EOF Thenrs_addbook.AddNewrs_addbook.Fields(0) = Trim(Text1.Text)rs_addbook.Fields(1) = Trim(Text2.Text)rs_addbook.Fields(2) = Trim(Text3.Text)rs_addbook.Fields(3) = Trim(Text4.Text)rs_addbook.Fields(5) = Trim(Text5.Text)rs_addbook.Fields(4) = "否"rs_addbook.UpdateMsgBox "添加书籍信息成功!", vbOKOnly, ""Unload MeElseMsgBox "书号重复!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""rs_addbook.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()If userpow = "guest" Then '权限相关Command1.Enabled = FalseCommand2.Enabled = FalseEnd IfEnd Sub删除图书(del_book):Option ExplicitDim rs_book As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_book.CancelUpdateDataGrid1.RefreshDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmddel_Click()Dim answer As StringOn Error GoT o delerroranswer = MsgBox("确定要删除吗?", vbYesNo, "")If answer = vbYes ThenDataGrid1.AllowDelete = Truers_book.Deleters_book.UpdateDataGrid1.RefreshMsgBox "成功删除!", vbOKOnly + vbExclamation, ""DataGrid1.AllowDelete = FalseElseExit SubEnd Ifdelerror:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubPrivate Sub cmdquit_Click()Unload MeEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_book.UpdateEnd Ifcmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "删除成功!", vbOKOnly + vbExclamation, ""End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoT o loaderrorsql = "select * from 图书表"rs_book.CursorLocation = adUseClientrs_book.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库cmdupdate.Enabled = False'设定datagrid控件属性DataGrid1.AllowAddNew = False '不可增加DataGrid1.AllowDelete = False '不可删除DataGrid1.AllowUpdate = FalseIf userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_book'cmdcancel.Enabled = FalseExit Subloaderror:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Unload(Cancel As Integer)Set DataGrid1.DataSource = Nothingrs_book.CloseEnd Sub修改图书(change_book):Option ExplicitDim rs_book As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_book.CancelUpdateDataGrid1.RefreshDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmdchange_Click()Dim answer As StringOn Error GoT o cmdchangecmdchange.Enabled = Falsecmdupdate.Enabled = Truecmdcancel.Enabled = TrueDataGrid1.AllowUpdate = Truecmdchange:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd Ifrs_book.UpdateDataGrid1.RefreshEnd SubPrivate Sub cmdquit_Click()Unload MeEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_book.UpdateEnd Ifcmdchange.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "修改成功!", vbOKOnly + vbExclamation, ""End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoT o loaderrorsql = "select * from 图书表"rs_book.CursorLocation = adUseClientrs_book.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库'设定datagrid控件属性DataGrid1.AllowAddNew = False '不可增加DataGrid1.AllowDelete = False '不可删除DataGrid1.AllowUpdate = FalseIf userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_bookcmdcancel.Enabled = FalseExit Subloaderror:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Unload(Cancel As Integer)Set DataGrid1.DataSource = Nothingrs_book.CloseEnd Sub查询图书(find_book):Option ExplicitDim panduan As StringPrivate Sub Command1_Click()Dim rs_findbook As New ADODB.RecordsetDim sql As StringIf Check1.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "书号='" & Trim(Text1.T ext & " ") & "'"Elsesql = sql & "and 书号='" & Trim(Text1.T ext & " ") & "'"End IfEnd IfIf Check2.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "作者='" & Trim(Text2.T ext & " ") & "'"Elsesql = sql & "and 作者='" & Trim(Text2.T ext & " ") & "'"End IfEnd IfIf Check3.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "出版单位='" & Trim(Text3.T ext & " ") & "'"Elsesql = sql & "and 出版单位='" & Trim(Text3.Text & " ") & "'"End IfEnd IfIf Check4.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "分类号='" & Trim(Text4.Text & " ") & "'"Elsesql = sql & "and 分类号='" & Trim(Text4.T ext & " ") & "'"End IfEnd IfIf Trim(sql) = "" ThenMsgBox "请选择查询方式!", vbOKOnly + vbExclamationExit SubEnd Ifsql = "select * from 图书表where " & sqlrs_findbook.CursorLocation = adUseClientrs_findbook.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_findbook'rs_findbook.CloseEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer) book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark)End Sub修改密码(change(pwd):Private Sub Command1_Click()Dim rs_chang As New ADODB.RecordsetDim sql As StringIf Trim(Text1.Text) <> Trim(T ext2.Text) ThenMsgBox "密码不一致!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""Text2.Text = ""Elsesql = "select * from 用户表where 用户名='" & userID & "'"rs_chang.Open sql, conn, adOpenKeyset, adLockPessimisticrs_chang.Fields(1) = Text1.Textrs_chang.Updaters_chang.CloseMsgBox "密码修改成功", vbOKOnly + vbExclamation, ""Unload MeEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub借书(borrow_book):Option ExplicitDim cnt As Integer '记录确定次数Private Sub Command1_Click()Dim sql As StringDim sql2 As StringDim sql3 As StringDim rs_borrow1 As New ADODB.RecordsetDim rs_borrow2 As New ADODB.RecordsetDim rs_borrow3 As New ADODB.RecordsetIf Trim(Text1.Text) = "" Then '判断输入的借书证号是否为空MsgBox "借书证号不可以为空", vbOKOnly + vbExclamation, ""Text1.SetFocusElsesql = "select * from 读者表where 借书证号='" & Text1.Text & "'"rs_borrow1.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_borrow1.EOF = True ThenMsgBox "没有这个读者", vbOKOnly + vbExclamation, ""Text1.SetFocusElse '检验书号是否正确If Trim(Text2.Text) = "" ThenMsgBox "书号不可以为空!", vbOKOnly + vbExclamation, ""Elsesql2 = "select * from 图书表where 书号='" & Text2.T ext & "'"rs_borrow2.Open sql2, conn, adOpenKeyset, adLockPessimisticIf rs_borrow2.EOF = True ThenMsgBox "对不起,没有这本书!", vbOKOnly, ""Text2.Text = ""Text2.SetFocusElseIf (rs_borrow2.Fields(4)) = "是" ThenMsgBox "对不起,此书已被借出!", vbOKOnly + vbExclamation, ""Text2.Text = ""Text2.SetFocusElsesql3 = "select * from 借书表"rs_borrow3.Open sql3, conn, adOpenKeyset, adLockPessimisticrs_borrow3.AddNewrs_borrow3.Fields("书号") = Trim(T ext2.T ext)rs_borrow3.Fields("借书证号") = Trim(T ext1.Text)rs_borrow3.Fields("借书日期") = Daters_borrow2.Fields("是否借出") = "是"rs_borrow2.Updaters_borrow3.UpdateMsgBox "借书成功!", vbOKOnly, ""Text1_ChangeText2.Text = ""End IfEnd IfEnd IfEnd IfEnd Ifcnt = cnt + 1If cnt = 8 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()cnt = 0End SubPrivate Sub Text1_Change()Dim sql1 As StringDim rs_borrow1 As New Recordsetsql1 = "select * from 借书表where 借书证号='" & Text1.Text & "'"rs_borrow1.CursorLocation = adUseClientrs_borrow1.Open sql1, conn, adOpenKeyset, adLockPessimisticSet DataGrid1.DataSource = rs_borrow1DataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseEnd Sub还书(back_book):Option ExplicitDim cnt As Integer '记录确定次数Private Sub Command1_Click()Dim sql As StringDim sql2 As StringDim sql3 As StringDim answer As StringDim rs_borrow1 As New ADODB.RecordsetDim rs_borrow2 As New ADODB.RecordsetDim rs_borrow3 As New ADODB.RecordsetIf Trim(Text1.Text) = "" Then '判断输入的借书证号是否为空MsgBox "借书证号不可以为空", vbOKOnly + vbExclamation, ""Text1.SetFocusElsesql = "select * from 借书表where 借书证号='" & Text1.Text & "'"rs_borrow1.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_borrow1.EOF = True ThenMsgBox "这个读者没有借书,请检查输入是否有错误", vbOKOnly + vbExclamation, ""Text1.Text = ""Text1.SetFocusElse '检验书号是否正确sql3 = "select * from 图书表where 书号= '" & rs_borrow1.Fields(1) & "'"rs_borrow3.Open sql3, conn, adOpenKeyset, adLockPessimisticanswer = MsgBox("确定要还这本书吗?", vbYesNo, "")If answer = vbYes ThenIf rs_borrow1.Fields(3) <> "" ThenMsgBox "此书已经还了,按【确定】删除此条记录", vbOKOnly + vbExclamation, ""rs_borrow1.Deleters_borrow1.UpdateUnload MeElsers_borrow1.Fields(3) = Daters_borrow3.Fields(4) = "否"MsgBox "还书成功!", vbOKOnly, ""DataGrid1.AllowDelete = Falsers_borrow1.Updaters_borrow3.UpdateUnload MeEnd IfElseExit SubEnd IfEnd IfEnd Ifcnt = cnt + 1If cnt = 8 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()cnt = 0End SubPrivate Sub Text1_Change()Dim sql1 As StringDim rs_borrow1 As New Recordsetsql1 = "select * from 借书表where 借书证号='" & Text1.Text & "'" rs_borrow1.CursorLocation = adUseClientrs_borrow1.Open sql1, conn, adOpenKeyset, adLockPessimistic Set DataGrid1.DataSource = rs_borrow1DataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseEnd Sub。

相关文档
最新文档