附录(图书管理系统程序代码)
图书馆管理系统设计附带源代码
毕业设计_图书管理系统一、数据库设计数据库设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代码完整版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版)图书管理系统源代码
图书管理系统源代码(一)程序代码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。
图书管理系统程序代码
#include<fstream〉#include<iostream〉#include<stdlib.h〉#include〈ctime〉#include<cmath>#include〈termios.h〉#include <sstream〉#include<string。
h〉#include<assert.h〉//改变字体颜色#define NONE "\033[m"#define RED "\033[0;32;31m”#define GREEN ”\033[0;32;32m”#define BLUE "\033[0;32;34m”#define YELLOW ”\033[1;33m”#define LIGHT_RED ”\033[1;31m”#define LIGHT_GREEN "\033[1;32m"#define LIGHT_BLUE "\033[1;34m”/*程序导读:1。
程序中对书的操作,可通过书名,编号来进行,flag=0按书名来操作,flag=1按书编号来操作2.程序中对用户的操作,也可通过姓名,用户ID号或编号两种方式来进行,flag=0按姓名来操作,flag=1按用户ID号或编号来操作3。
本程序分5个部分,具体已标识如(1)图书管理。
.*/using namespace std;class Book{public:string book_name;string book_num;//编号string book_pre;//出版社string book_aut;//作者int book_con;//这样的书还有几本int book_mux;//这样的书总共有几本public:Book(){book_con=0;book_mux=0;}void show_book();};/****************************************(1)图书管理*******************************************/void Book::show_book(){cout<〈"书名:”<〈book_name<〈endl;cout〈〈”出版社:"〈<book_pre〈〈endl;cout<<”此书的作者:"〈<book_aut〈<endl;cout〈<”ISBN编号:”<〈book_num<〈endl;cout<<"此书共有"〈<book_mux<<”本”〈〈endl;cout<<”还有"<<book_con〈〈”本书未借出!"〈<endl;}class BookNode{public:Book book;BookNode *next;};BookNode *headbook=NULL;class BookManage{public:int totolbook;public:BookManage(){totolbook=0;}void addbook();void delbook(string s,int num,int flag);void findbook(string s,int flag);//查询图书};void BookManage::addbook(){string h;cout〈〈"添加输入0,退出输入—1"<〈endl;cin>>h;if(h==”-1”)return;else if(h=="0”)while(1){if(h==”-1”)break;else if(h==”0”){string na,nu,p1,aut;int con;BookNode *p=new BookNode;cout<<”请输入书名:"〈〈endl;cin〉>na;p—〉book.book_name=na;cout<〈"请输入ISBN编号:”<<endl;cin>〉nu;p->book。
图书管理系统的C#代码完整版
C#代码清单共1个项目,包含5个类。
项目: librarysystem类:主类代码:namespace librarysystem{ PublicationISBN = PublicationISBN;= PublicationName;= PublicationAuthor;= PublicationType;= PublicationStatus;}}}读者类代码:namespace librarysystem{ 询图书");("2.借书服务");("3.还书服务");("4.新出版物入库");("5.录入新读者");("6.查询读者的借阅信息");("7.退出管理系统");("-------------------------------------------------------------------");bool flag;do{flag = false;("请选择:");string key = ();switch (key){case"1":("请输入需要查询图书的书名:");ShowPubInfo();break;case"2":("请输入您的姓名:");();ShowBorrowInfo();("请输入您的姓名:");();ShowReturnInfo();break;case"4":("请按照提示逐步输入需要入库出版物的信息……");ShowAddPublications();break;case"5":("请按照提示逐步输入新注册读者的信息……");ShowAddReaders();break;case"6":("请输入您的姓名: ");();ShowRedPubInfo;break;case"7":flag = false;break;default:("无此业务,是否重新选择(y/n)");string answer = ();if (answer != "y"){flag = false;}else{flag = true;}break;}} while (flag);}/*显示查询到的出版物信息*/public void ShowPubInfo(){if ()){("您要查询的出版物信息:");("-------------------------------------------------------------------"); ("编号: " + ("出版物名字: " + ("出版物作者: " + ("出版物类型: " + if {("出版物状态:在架,可借");else{("出版物状态:未在架,不可借");}("-------------------------------------------------------------------"); ("");("");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();();}else{("结束");}}else{("抱歉,未找到该图书!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();();();}else{("结束");}}}/*显示借阅操作结果*/public void ShowBorrowInfo(){if{("恭喜,借阅成功!");ShowRedPubInfo;}{("抱歉,借阅失败!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();}else{("结束");}}}/*显示归还操作结果*/public void ShowReturnInfo(){if{("恭喜,归还成功!");ShowRedPubInfo;}else{("抱歉,归还失败!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();}else{("结束");}}}public void ShowRedPubInfo(Readers red){("当前你的借阅信息如下:");("--------------------------------------------------------------------"); ("编号: " + ;("姓名: " + ;("性别: " + ;("主修专业: " + ;("已借图书: ");for (int{if [i] != ""){(" "+[i]);}}("");("--------------------------------------------------------------------"); ("");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();}else{("结束");}}/*显示新出版物入库的信息*/public void ShowAddPublications(){pub = new Publications();("请输入出版物的编号: ");=();("请输入出版物的名称: ");= ();("请输入出版物的编者: ");= ();("请输入出版物的类型: ");= ();= true;(pub);("新出版物入库成功!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();();}else{("结束");}}/*显示新读者注册的信息*/public void ShowAddReaders(){red = new Readers();("请输入新注册读者的编号: "); = ();("请输入新注册读者的姓名: "); = ();("请输入新注册读者的性别: "); = ();("请输入新注册读者的院系: "); = ();("请输入新注册读者的专业: "); = ();for(int i=0;i<10;i++){[i]="";}(red);("新读者注册成功!");("是否办理其他业务(y/n) ");string answer = ();if (answer == "y"){ShowMainMenu();();();}else{("结束");}}}}。
图书管理系统模板(附代码)
课程设计报告 图书管理系统的 设计与实现系 名:电子通信与软件工程系 专 业:计算机科学与技术指导教师:二○一三 年 十二 月装订线 中山大学南方学院目录第1章可行性分析 (1)1.1经济可行性 (1)1.2技术可行性 (1)第2章需求分析 (2)2.1 图书管理系统开发的目的 (2)2.2 图书管理系统开发的背景 (2)2.3 图书管理系统开发任务概述 (2)2.4 系统(或用户)的特点 (2)2.5 假定和约束 (3)2.6 软件功能说明 (3)2.7 对功能的一般性规定 (5)2.8 运行环境规定 (6)2.9支撑软件 (6)2.10 接口 (6)第3章总体设计 (7)3.1系统设计 (7)3.2结构设计 (11)3.2.1模块描述 (11)3.2.2系统角色设计 (13)3.3接口设计 (14)3.3.1用户界面设计规则 (14)3.3.2内部接口设计 (14)3.3.3外部接口设计 (14)3.3.4出错处理设计 (14)3.3.5系统维护设计 (14)第4章详细设计 (15)4.1 数据库设计 (15)4.1.1数据库概念结构设计 (15)4.1.2数据库逻辑结构设计 (15)4.2.1程序界面 (15)4.3 服务器模块 (19)4.3.1程序界面 (19)4.3.2功能说明 (19)4.4改进计划 (19)4.5支持软件 (20)4.6使用说明 (20)4.7出错和恢复 (20)4.8版权说明 (22)4.8.1开发团队 (22)4.8.2版权信息 (22)4.8.3版权信息 (22)第5章编码与测试 (23)5.1 编码阶段 (23)5.1.1 连接数据库代码 (23)5.1.2 登录代码 (23)5.1.3 注册代码 (25)5.1.4 违规处理代码 (26)5.2 软件测试报告 (26)5.2.1 引言 (26)5.2.2 测试步骤 (26)5.2.3 测试结果 (27)参考文献 (28)开发心得体会 (29)第1章可行性分析1.1经济可行性自21世纪开始,随着信息技术的飞速发展,越来越多的信息进入人们的生活,普通的人工技术记录已经难以满足人们的正常需求,这便出现了计算机记录管理信息。
图书管理系统代码(C语言)
图书管理系统代码(c语言)#include〈stdio. h>#include〈stdlib・ h>#include〈string・ h>struct book{int num;char bname[50];char wname[20];char press[50^;char sort[50]:int time;float price;struct book *next;};struct book *creatbook() ; //创建链表struct book * addbook (structbook *head) ; //添加图书int yanzheng(struct book *head, int m) ; //验证新添加的图书编码是否已存在void deletebook (struct book *head) ; //删除图书void fprint (struct book *head) : //将链表写入文件struct book *load() ; // 从文件中读取信息并建成链表void print_book(struct book *head) : //将链表信息输出void chaxun(struct book *head) ; //查询图书信息void num_chaxun(struct book *head) ; //按图书编号查询图书void wname_chaxun(struct book *head) ; //按作者名查询图书voidsort_chaxun(struct book *head) ; //按类另lj查询图书void time_chaxun(structbook *head) ; //按出版时间查询图书void bname_chaxun(struct book *head); //按图书名査询图书void xiugai (struct book *head); //修改图书信息void paixu(struct book *head) ; //对图书进行排序void num_paixu(struct book ♦head); 〃按图书编号排序void time_paixu(struct book *head) ; //按图书出版时间排序void price_paixu(struct book *head): //按图书价格排序void bname_paixu(struct book *head) ; //按图书名排序void wname_paixu(struct book *head) ; //按作者名排序int main()int choice, n, x, y=l, c, cl=123456;char a, d, b[10], bl[10]="201102520116";struct book *head=NULL;while(y){system("cis");printf ("\n\n\n\n\n\n\n");printf (z ********** 欢迎光临**********\n\n,z);printf (,z ********************** 图书信息管理系统printf C\n\n');printf C ™=_1—用户登录=_==\十);二二二二二二二二二二二二0-退出系统二二二二二二二二二二二\『);printf Cprintf f请输入您的选择「);scanf (,z%d,z, &n);printf("\n");getchar ();switch(n) {case 0:y 二0;break;case 1:printf C请输入您的用户名:〃);gets(b);printf C\n");printf C请输入您的密码:“);scanf("%d", &c);printf("\n");if(strcmp(b, bl)!=0 |c!=cl){printf C验证失败,请重新输入!\n〃);scanf &d);getchar ();system("cls");}else {printf ("验证通过!请按Enter键进入!\n"); scanf("%c", &d);getchar ();x二1;while(x){ system("cis");printf C --------------------- \n"); printff *图书信息管理系统*\n 〃); printf C --------------------- \n\rT); • I • '.I"■、』•-1"• I • '.I" ■、』•-1"■、/• I • '.I" ■、』•-1"■、/• I • '.I" ■、』•-1"■、/• I • '.I" ■、』•-1" ■、/ • I • '.I" \ \1 •viw vaw vVw vTw vVwvaw vgW viw vaw vVw vTw vVwvaw vgW viw vaw vVw vTw vVwvaw vgW viw vaw vVw vTw vVwvaw vgW viw vaw vVw vTw vVw vaw vgW viw vaw vVw vTw viw »Tw 、『(、『]•、.• \ \ 1 • viw viw vaw vTw viw viw viw viw vTW viwvaw vaw viw viw viw viw vTW viw vaw vaw viw viw viw viw vTW viw vaw vaw viw viw viw viw vTW viw vaw vaw viw viw viw viw vTW viw vaw vaw viw »Tw•”f.・•工・•」・• —I" ■、尸■、■•■、丿•工・•」・• —I"■、尸■、■•■、丿•工・•」・• —I"■、尸■、■•■、丿•工・•」・• —I" ■、尸■、■• ■、丿•工・•」・• —I"■、尸■、■• ■、丿•工・•」・• —I"■、,\ \1 •VBW VIW VIW VSW VBW VCW VIW VIW VIW VIW VBW VBW vYw VIW VIW VIW VIW VBW VBW vYwVIW VIW VIW VIW VBW VBW vYw V IW VIW VIW VIW VBW VBW vYwVIW VIW VIW VIW VBW VIW»Tw 、『(、[]• (_•・.l ・■、』•工・•丄• •」•• •丄••丄• •■l ・■、』•工・•丄• •」•• •丄••丄• •■1・■、』•工・•丄• •」•• •丄• •丄• •■1・■、』•工・•丄••」•• •丄••丄• •■1・■、』•工・•丄• •」•• •丄• •丄•■、』•工・•丄• •」.• \ \ 1 •v^w viw vaw vTw vawv^w viw vaw vaw vawv^w viw vaw vaw vawv^w viw vaw vaw vawv^w viw vaw vaw vawv^w viw vaw viw ^«w | I 、了]printf C 请输入所选择的序号:〃); scanf("%d", &choice); getchar (); system("cls"); switch(choice) case 0: x=0;break; case 1: head=load(); if (head=NULL) {printf C 文件为空,请先录入数据! \n 〃); getchar (); break; } else {head=addbook(head); printf ("添加成功! \n");printff 是否将新信息保存到文件?(y/n)\n 〃); scanf&a);printf (”II 1-添加图书 2-删除图书I\n\n");printf (" II 3-图书列表 4-图书排序 I \n\rT); printf (“II 3-查询图书 6-修改图书 I \n\rT); printf (“ II 7-录入数据 0-退岀系统 I \n\rT);printf Cprintf (”printf ("printf (”getchar ();switch(a){case , n,:break;case ' y‘ :fprint(head);printf ("保存成功! \n");getchar ();break;}break;}case 2:head=load();if (head=NULL) {printf C文件为空,请先录入数据! \n〃);getchar ();break;}else{deletebook(head);getchar ();break;}break;case 3:head=load();辻(head==NULL){printf ("文件为空,请先录入数据!\n");getchar ();break;}else{print_book(head);getchar ();break;}case 4:head二load ();辻(head==NULL) {printf ("文件为空,请先录入数据! \『);getchar ();break;}else{paixu (head);getchar ();}break;case 5:head二load ();辻(head==NULL){printf ("文件为空,请先录入数据!\n");getchar ();break;}else{chaxun(head);getchar ();}break;case 6:head=load();辻(head二二NULL){printf C文件为空,请先录入数据!\n");getchar ();break;}else {xiugai(head);getchar ();break;}break;case 7:printf (〃注意:输入图书编码为0时结束! \rT);head=creatbook ();printf r是否将输入的信息保存到文件以覆盖文件中已存在的信息?(y/n)\n");getchar ();scanf (“%c", &a);getchar ();switch(a){case ' n :break;case ' y‘ :fprint(head);printf ("保存成功! \n");getchar ();break;}break;default:printff您的输入有误,请重新输入! \n〃);getchar ();break;}}}break;default:printf("您的输入有误!请重新输入!\n〃);getchar ();break;}}}//录入数据并形成链表struct book *creatbook() {struct book *head, *tail, *p;int num, time, n;char bname[50], wname[20], press[50],sort[50];float price; int size=sizeof(struct book): head二tail二NULL; printfC请输入图书编号:〃);scanf&num);printff请输入图书名:〃);scanfbname);getchar ();printff请输入作者名:〃);scanf wname);getchar ();printfC请输入出版社:“);scanfpress);getchar ();printfC请输入类别:“);scanf (〃%s: sort);getchar ();printfC请输入出版时间:“);scanf&time);getchar ();printf ("请输入价格:");scanf("%f", &price);getchar ();while(l) {p= (struct book *)malloc(size);p->num=num;strcpy(p->bname, bname);strcpy(p->wname, wname);strcpy(p->press,press);strcpy(p->sort, sort);p->time二time;p->price=price;p->next二NULL;if (head=NULL)head二p;elsetail-〉next二p;tail=p;do{printff请输入图书编号:〃);scanf&num);n=yanzheng(head, num);辻(n=0)break;elseprintff您输入的编号已存在,请重新输入! \n〃); }while(1);if(num==0) break;else printfC请输入图书名:〃);scanfbname);getchar ();printff请输入作者名:〃);scanf wname);getchar ();printff请输入出版社:“);scanfpress);getchar ();printfC请输入类别:");scanfsort);getchar ();printfC请输入出版时间:”); scanf ("%d", &time);getchar ();printf ("请输入价格:”);scanf("%f", &price);getchar ();}}return head;}〃插入结点,并且插入后仍按一定顺序struct book *addbook (struct book *head) struct book *ptr, *pl, *p2, *p;char bname[50], wname[20], press[50_, sort[50];int size=sizeof(struct book):int num, time, n=l:float price;do{printff请输入图书编号:“);scanf&num);n=yanzheng(head, num);if (n=0)break;elseprintf (〃您输入的编号已存在,请重新输入! \n〃);}while(1);printf C请输入图书名:〃);scanfbname);getchar ();printf r请输入作者名:〃);scanf wname);getchar ();printf C请输入出版社:〃);scanfpress);getchar ();printfC请输入类别:〃);scanf(〃%s〃, sort);getchar ();printfC请输入出版时间:“);scanf &time);getchar ();printf ("请输入价格:”);scanf("%f", &price);getchar ();p= (struct book *)malloc(size);p->num=num;strcpy (p~>bname, bname);strcpy(p->wname, wname);strcpy (p->press, press);strcpy (p->sort, sort);p->time=time;p->price=price;p2=head;Ptr=p;while((ptr->num>p2->num)&&(p2-〉next!=NULL)){pl二p2;p2二p2-〉next;}if(ptr->num<=p2->num){if (head=p2)head二ptr;else {pl->next=ptr;p->next=p2;}}else {p2->next=ptr;p->next二NULL;}return head;}//验证添加的图书编号是否已存在int yanzheng(struct book *head, int m) {struct book *p;p=head;while(p!=NULL){if (p-'nunFp)break;p=p->next;}辻(p二二NULL)return 0;elsereturn 1;}//将新链表写入文件中void fprint (struct book *head){FILE *f p;char ch二'1’ ;struct book *pl;if ((fp 二 f open ("fl. txt", "w"))=NULL) {printf (,z File open error!\n z/):exit(0);}fputc(ch, fp);for(pl二head;pl;pl二pl->next) {fprintf (fp,,z%d %s %s %s %s %d %f\n,z, pl->num, pl->bname, pl->wname, pl->press,pl-〉sort,pl-〉time, pl-〉price);}fclose (fp);}//从文件中读取图书信息struct book *load()FILE *fp;char ch;struct book *head,*tail,*pl:head二tail二NULL;if ((fp 二 f open ("fl. txt", "r"))=NULL) {printf (,z File open error!\n z/):exit(O);}ch=fgetc (fp);辻(ch='l'){while(!feof(fp)) {pl=(struct book *)malloc(sizeof(struct book)):fscanf (fp, z,%d%s%s%s%s%d%f\n, &pl->num, pl->bname, pl->wname, pl- >press,pl-〉sort, &pl-〉time, &pl->price);辻(head二二NULL)head=pl;elsetail->next=pl;tail=pl;}tail-〉next二NULL;fclose (fp);return head;}elsereturn NULL;}〃将整个链表的信息输出void print_book(struct book *head) {struct book *ptr;辻(head=NULL) {printf ("\n 没有信息!\n");return;}printf r图书信息列表如下\n);printf C============================+)printfC编号图书名作者名出版社类别出版时间价格\n〃);for(ptr=head;ptr;ptr=ptr->next)printf (,z %d %s %s %s %s %d%・ 2f\n z/, ptr->num, ptr->bname, ptr->wname, ptr-〉press, ptr-〉sort, ptr->time, ptr-〉price);}printf CW);}//删除图书信息void deletebook(struct book *head) {int a;char b, ch二'1’ ;struct book *pl,*p2;FILE *fp;printff请输入要删除的图书编号:〃);scanf&a);pl=head;if (pl->num~a&&pl->next==NULL) { //对于文件中只有一组数据printfC是否清空文件!(y/n)\『);getchar ();scanf&b);getchar ();switch (b) {case ' n :break;case ' y‘ :if ((fp 二 f open ("fl. txt", "w"))=NULL) {printf (,z File open error!\n z,):exit(O);}fclose (fp);printf C文件已清空! \rT);}}else {while (pl->num!二a&&pl-〉next!二NULL) {p2二pl;pl=pl->next;}if (pl->next=NULL) {if (pl->num==a){p2-〉next二NULL;printfC是否确定从文件中彻底删除该图书?(y/n)\n,z); getchar ();scanf&b);switch (b) {case ' n :break;case ' y‘ :fprint(head);printf ("删除成功!\n");getchar ();break;}}else {printf (〃没有找到要删除的数据! \『);getchar ();}}else if(pl==head) {head=pl~>next:printf("是否确定从文件中彻底删除该图书?(y/n)\n"); getchar (); scanf &b);switch(b){case ' n :break;case ' y‘ :fprint (head);PrintfC 删除成功!\n〃);getchar ():break;}}else{p2-〉next二pl->next;printf("是否确定从文件中彻底删除该图书?(y/n)\n"); getchar ();scanf ("%c", &b);switch (b) { case ' n': break;case ' y,:fprint(head);printf ("删除成功!\n");getchar ();break;}}}}〃图书查询void chaxun(struct book *head) {int a;printf(”============================\n)printf C ** 1-按图书编号查询2-按图书名查询和<\『);printf (,z ** 3-按图书类别查询4-按作者名查询和<\n〃);printf C ** 5-按出版时间査询0-退出查询**\n");printf C============================\n );printf C请输入所选择的编号:〃);scanf&a);getchar ();switch(a){case 0:break;case 1:num_chaxun(head); break;case 2:bname_chaxun(head); break;case 3:sort_chaxun(head); break;case 4:wname_chaxun(head); break;case 5:t ime_chaxun(head); break;default:printf ("您的输入有误! \n"); break;}//按编号查询图书信息void num_chaxun(struct book *head){int a;struct book *p;printff请选择您要查询的图书编号:〃); scanf&a);getchar ();p二head;while(p!=NULL){if (p->num==a)break;p=p->next;}辻(p二二NULL){printfC没有找到该编号的图书!\n〃);}else {printfC你所查询的图书信息如下\n〃); printf C二二二\『);printfC * *编号图书名作者名岀版社类别岀版时间}价格**\n9 ;printf("** %d %s %s %s %s %d %. 2fp->num, p->bname, p->wname, p->press, p->sort, p->time, p->price); printf C=\n〃);}}〃按图书名查询图书信息void bname_chaxun(struct book *head) {char a[50];int flag=0;struct book *p;printf (〃请选择您要查询的图书名:〃);gets (a);p=head;while(p!=NULL){if (strcmp(p->bname, a)==0){flag=l;break;p=p->next; }}辻(flag=O) {printff没有找到该图书名的图书!\n〃);}else {printf(〃你所查询的图书信息如下\n〃);printf C二二二\『);printf (〃桂编号图书名作者名出版社类别出版时间价格桂\n〃);while(p!=NULL){if(strcmp(p->bname, a)==0){printf("** %d %s %s %s %s %d %. 2f**\n,z, p->num, p->bname, p->wname, p->press, p->sort, p->time, p->price); }p=p->next;}printf C}===\n,z); }〃按作者名查询图书信息void wname_chaxun(struct book *head) { char a[50];int flag^O;struct book *p;printff请选择您要查询的图书作者名:〃); gets (a);p二head;while(p!=NULL){if (strcmp (p->wname, a) ==0) {flag=l;break;}p=p->next;}if(flag=0) {printff没有找到该图书名的图书!\n〃);}printf Celse {printfC你所查询的图书信息如下\n〃);printf C=\n〃);printfC **编号图书名作者名出版社类别出版时间价格while(p!=NULL){if (strcmp (p->wname, a) ==0) {printf("** %d %s %s %s %s %d %. 2fp->num, p->bname, p->wname, p->press, p->sort, p->time, p->price); flag=l;}p=p->next;}printf C=\n〃);}}〃按图书类别查询图书信息void sort_chaxun(struct book *head) {char a[50];int flag=0;struct book *p;printf C请选择您要查询的图书类别:〃);gets (a);p=head;while(p!=NULL){if(strcmp(p->sort, a)==0) {flag=l;break;}p二p->next;}辻(flag=O) {printff没有找到该图书名的图书!\n〃);}else {printf ("你所查询的图书信息如下\n〃);printf C=\『);printf (,z **编号图书名作者名出版社类别出版时间价格杯\n"); while(p!=NULL){if(strcmp(p->sort, a)==0) {printf C** %d %s %s %s %s %d %. 2f**\n,z, p->num, p->bname, p->wname, p->press, p->sort, p->time, p->price); flag=l;}p=p->next;}printf C=\『);}}〃按图书出版时间查询图书信息void time^chaxun(struct book *head) {int a,flag=0;struct book *p;printf r请选择您要查询的图书出版时间:〃);scanf("%d", &a);getchar ();p=head;while(p!=NULL){if (p->time==a) {flag=l;}break; }p=p->next;}if(flag=O) {printff没有找到该图书名的图书!\n〃);}else {printff你所查询的图书信息如下\n〃);printf(”=\n");printf (〃桂编号图书名作者名出版社类别出版时间价格while(p!=NULL){if(p->time==a){printf("** %d %s %s %s %s %d %. 2fp->num, p->bname, p->wname, p->press, p-〉sort, p->time, p-〉price);flag=l;}p二p-〉next;printf("}=\n");}}//修改图书信息void xiugai(struct book *head) {int a, b;char c;struct book *p;printfC请输入要修改的图书编号:〃);scanf&a);p=head;while(p!=NULL){if (p->num==a)break;p=p->next;}if(p二二NULL){printfC没有找到该编号的图书!\n〃); getchar ();}else {printf CW);printf r ** 1-编号2-图书名3-作者名printf C ** 4-出版社5-类别6-出版时间*水\n");printf C ** 7-价格8-修改全部0-放弃修改**\n");printf C============================\n");printf C请选择你要修改的信息编号:〃);scanf&b);getchar ();switch (b) {case 1:printf r请输入新编号:“);scanf&p->num);printf ("修改成功! \n");getchar ();break;case 2:printf r请输入新图书名:“);gets (p->bname);printf ("修改成功! \n");break;case 3:printff请输入新作者名:“);gets(p->wname);printf ("修改成功!\n"); break;case 4:printf r请输入新出版社:”);gets(p->press);printf ("修改成功! \n"); break;case 5:printf r请输入新类别:”);gets(p->sort);printf ("修改成功! \n"); break;case 6:printf r请输入新出版时间:“); scanf&p~>time);printf ("修改成功!\n"); getchar ();break;case 7:printf r请输入新价格:“); scanf ("%f", &p->price); printf ("修改成功! \n");getchar ();break;case 8:printf r请输入新图书编号:“);scanf&p->num);printf C请输入新图书名:“);scanf p->bname);getchar ();printf C请输入新作者名:“);scanf p->wname);getchar ();printf r请输入新出版社:”);scanfp->press);getchar ();printf r请输入新类别:“);scanf(〃%s: p->sort);getchar ();printf r请输入新出版时间:“);scanf&p->time);getchar ();printf r请输入新价格:〃);scanf ("%f", &p->price);getchar ();printf ("修改成功! \n");getchar ();break;case 0:break;default :printf C您的输入有误! \n");break;}printf C是否将修改后的信息保存到文件中?(y/n)\rT); scanf&c):getchar ();switch (c) {case ' n :break;case ,y‘ :fprint(head);printf ("保存成功!\n");getchar ();break;}}}〃图书排序void paixu(struct book *head) {int a;printf(”\ 〃 \\ > .----------------------------------------------------------------------- \n 丿, printf r ** 1-按图书编号排序2-按出版时间排序**\n");printf C ** 3-按图书价格排序4-按图书名排序**\n z/);printf C ** 5-按作者名排序0-取消排序操作材\n");printf (”___________________________________________________________________ \〃\ . \AX / f printf C请输入您选择的编号:〃);scanf("%d", &a);getchar ();switch(a){case 0:break;case 1:num_paixu(head); break;case 2:time_paixu(head);break;case 3:price_paixu(head);break;case 4:bname_paixu(head);break;case 5:wname_paixu(head);break;default:printf C您的输入有误! \n");break;}}〃按图书编号排序void num_paixu(struct book *head) {struct book *a[1000], *p, *pl, *temp; int i, k, index, n=0;for(p=head;p;p=p->next)n++;。
图书管理系统_毕业设计论文_详细附录
附录1.系统用户登陆表单定义保存允许用户最大登陆次数和当前登陆次数的变量PROCEDURE loadpublic nMaxLogTimes&&定义一个全局变量保存允许的最大登录次数nMaxLogTimes=3 &&设置最大允许的登录次数public nLogTimes&&定义一个全局变量保存当前登录次数nLogTimes=0 &&设置登录次数的初始值ENDPROC实现登录信息验证PROCEDURE Command1.Click*首先检查是否超过允许的最多登录次数nLogTimes=nLogTimes+1 &&当前登录次数加1if nLogTimes>nMaxLogTimes*在超过允许的最多登录次数时显示提示信息,并关闭登录对话框cstr="你已超过允许的最多登录次数,登录对话框将关闭"messagebox(cstr,16,"用户登录验证") &&显示提示thisform.release &&关闭登录对话框else*在允许的最多登录次数范围内,首先获得用户输入的登录信息cName=alltrim(thisform.txtName.value)cPassword=alltrim(thisform.txtPassword.value)*检验用户名是否存在locate for alltrim(编号)==cnameif not found()messagebox("用户名输入错误!",16,"用户登录验证")thisform.txtName.selstart=0thisform.txtName.sellength=len(cName)thisform.txtName.setfocusreturnendif*在用户名正确时,检查口令是否正确if alltrim(口令)==cPassword*显示登录信息通过验证的信息messagebox("登录成功!",64,"用户登录验证")thisform.release &&关闭登录对话框*保存当前用户信息,下列变量在系统主文件中定义capp_currentuser=cnamecapp_currentpwd=cpasswordcapp_currentpop=权限lapp_Logon=.T. &&lapp_Logon设置为.T.表示登录成功 elsemessagebox("口令输入错误!",16,"用户登录验证")thisform.txtPassword.value=""thisform.txtPassword.setfocusendifendifENDPROC实现取消登录功能PROCEDURE Command2.Clicknr=messagebox("你选择了退出登录,是否退出?",68,"用户登录")if nr=6thisform.release &&关闭登录对话框表单endifENDPROC在登录对话框关闭时执行清理操作PROCEDURE Unload*从内存释放保存允许的最大登录次数和当前登录次数的变量RELEASE nMaxLogTimes,nLogTimesclear events &&清除事件循环ENDPROC表示当前日期的功能PROCEDURE Initthisform.txtdate.value=date()ENDPROC2.创建记录导航条类首记录PROCEDURE cmdTop.Click*在当前表中有记录时才执行改变当前记录操作if reccount()>0go top &&使第一条记录成为当前记录endifthisform.refresh &&刷新表单,显示当前记录数据ENDPROC前一记录PROCEDURE CmdPre.Click*在当前表中有记录时才执行改变当前记录操作if reccount()>0skip -1 &&使前一个记录成为当前记录if bof()go top &&如果记录指针指向文件开头,则使第一个记录成为当前记录endifendifthisform.refresh &&刷新表单,显示当前记录数据ENDPROC后一记录PROCEDURE cmdNext.Click*在当前表中有记录时才执行改变当前记录操作if reccount()>0skip &&使后一个记录成为当前记录if eof()go bottom &&如果记录指针指向文件末尾,则使最后一个记录成为当前记录 endifendifthisform.refresh &&刷新表单,显示当前记录数据ENDPROC尾记录PROCEDURE cmdBottom.Click*在当前表中有记录时才执行改变当前记录操作if reccount()>0go bottom &&使最后一个记录成为当前记录endifthisform.refresh &&刷新表单,显示当前记录数据DENPROCmynavigatorde的初始化事件过程PROCEDURE InitThisform,mynavigator1.cmdTop.clickENDPROC3.实现系统用户数据管理功能实现添加记录功能PROCEDURE cmdAdd.Click*取消各个文本框数据绑定属性,在保存后再恢复thisform.txt编号.controlsource=""thisform.txt编号.value=""thisform.txt口令.controlsource=""thisform.txt口令.value=""thisform.txt权限.controlsource=""thisform.txt权限.value=""*取消文本框的只读属性thisform.txt编号.readonly=.f.thisform.txt口令.readonly=.f.thisform.isadding=.T. &&设置添加状态标志thisform.caption="系统用户数据管理-[添加]" &&修改表单标题thisform.mynavigator1.enabled=.f. &&禁用记录导航条thisform.cmdadd.enabled=.f. &&禁用添加按钮thisform.cmdedit.enabled=.f. &&禁用修改按钮thisform.cmddelete.enabled=.f. &&禁用删除按钮thisform.cmdexit.enabled=.f. &&禁用退出按钮ENDPROC实现修改记录功能PROCEDURE cmdEdit.Clickif reccount()<1return &&在无记录时直接返回endif*取消各个文本框数据绑定属性,在保存后再恢复thisform.txt编号.controlsource=""thisform.txt口令.controlsource=""thisform.txt权限.controlsource=""thisform.iseditting=.T. &&设置修改状态标志thisform.caption="系统用户数据管理-[修改]" &&修改表单标题thisform.mynavigator1.enabled=.f. &&禁用记录导航条thisform.cmdadd.enabled=.f. &&禁用添加按钮thisform.cmdedit.enabled=.f. &&禁用修改按钮thisform.cmddelete.enabled=.f. &&禁用删除按钮thisform.cmdexit.enabled=.f. &&禁用退出按钮*取消文本框的只读属性thisform.txt编号.readonly=.f.thisform.txt口令.readonly=.f.thisform.txt权限.readonly=.f.ENDPROC实现退出添加或修改状态功能PROCEDURE cmdEsc.Click*退出当前修改或添加状态if thisform.isadding or thisform.isedittingnRecno=recno() &&记录当前记录编号*恢复各个文本框数据绑定属性thisform.txt编号.controlsource="sysuserdata.编号"thisform.txt口令.controlsource="sysuserdata.口令"thisform.txt权限.controlsource="sysuserdata.权限"go nrecnothisform.refresh*清除编辑和添加状态标记thisform.iseditting=.f.*恢复文本框的只读属性thisform.txt编号.readonly=.t.thisform.txt口令.readonly=.t.thisform.txt权限.readonly=.t.thisform.caption="系统用户数据管理-[浏览]" &&修改表单标题thisform.mynavigator1.enabled=.t. &&重新启用记录导航条thisform.cmdexit.enabled=.t. &&重新启用退出按钮thisform.cmdadd.enabled=.t. &&重新启用添加按钮thisform.cmdedit.enabled=.t. &&重新启用修改按钮thisform.cmddelete.enabled=.t. &&重新启用删除按钮endifENDPROC实现保存记录功能PROCEDURE cmdSave.Click*判断当前是否处于添加或编辑状态if not (thisform.isadding or thisform.iseditting)return &&在不处于添加或编辑状态时不执行保存操作endif*执行保存记录操作,首先获得输入cNum=alltrim(thisform.txt编号.value)cPwd=alltrim(thisform.txt口令.value)cPop=alltrim(thisform.txt权限.value)if empty(cNum) &&验证编号是否为空messagebox("编号不能为空!",16,"系统用户数据管理")thisform.txt编号.value=""thisform.txt编号.setfocusreturnendifif empty(cpwd) &&验证口令是否为空messagebox("口令不能为空!",16,"系统用户数据管理")thisform.txt口令.value=""thisform.txt口令.setfocusreturnendifif not (cpop==chr(48) or cpop==chr(49)) &&验证权限代码是否有效messagebox("权限代码只能为0或1!",16,"系统用户数据管理")thisform.txt权限.setfocusreturnendif*定义一个变量用于表示编号是否被使用*检查添加的编号是否已被使用nRecno=recno() &&记录当前记录编号locate for 编号==cNumif found()if thisform.isaddingmessagebox("编号:"+cnum+"已被使用!",16,"系统用户数据管理")thisform.txt编号.setfocusreturnelseif nrecno<>recno()messagebox("编号:"+cnum+"已被使用!",16,"系统用户数据管理")thisform.txt编号.setfocusreturnendifendifendif*将通过验证的数据保存到sysuserdata表if thisform.isaddinginsert into sysuserdata (编号,口令,权限) values (cnum,cpwd,cpop)elsereplace 编号with cnum, 口令with cpwd, 权限with cpop RECORD nrecno endif*恢复各个文本框数据绑定属性thisform.txt编号.controlsource="sysuserdata.编号"thisform.txt口令.controlsource="sysuserdata.口令"thisform.txt权限.controlsource="sysuserdata.权限"*恢复文本框的只读属性thisform.txt编号.readonly=.t.thisform.txt口令.readonly=.t.thisform.txt权限.readonly=.t.*使新添加的记录或被修改记录成为当前记录if thisform.isaddinggo bottomelsego nrecnoendifthisform.refresh*清除编辑和添加状态标记thisform.isadding=.f.thisform.iseditting=.f.thisform.caption="系统用户数据管理-[浏览]" &&修改表单标题thisform.mynavigator1.enabled=.t. &&重新启用记录导航条thisform.cmdexit.enabled=.t. &&重新启用退出按钮thisform.cmdadd.enabled=.t. &&重新启用添加按钮thisform.cmdedit.enabled=.t. &&重新启用修改按钮thisform.cmddelete.enabled=.t. &&重新启用删除按钮messagebox("数据保存成功",64,"系统用户数据管理")ENDPROC实现删除记录功能PROCEDURE cmdDelete.Clickif reccount()<1return &&在无记录时直接返回endifif messagebox("是否删除当前记录",36,"系统用户数据管理")=6 &&选择删除记录nrecno=recno() &&记录当前记录编号delete &&对记录作删除标记pack &&彻底删除当前记录*使被删除记录的下一条记录成为当前记录if reccount()<=1go topelseif nrecno=reccount()+1go bottomelsego nrecnoendifendifthisform.refreshendifENDPROC实现关闭表单功能PROCEDURE cmdExit.Clickif messagebox("是否退出系统用户数据管理?",36,"系统用户数据管理")=6thisform.release &&关闭系统用户数据管理表单endifENDPROC4.实现当前用户口令修改功能实现表单初始化PROCEDURE Iint*显示用户编号thisform.txtNum.value=capp_currentuser*显示用户口令select sysuserdatalocate for alltrim(编号)=capp_currentuserthisform.txtOldPwd.value=口令ENDPROC实现清除口令功能PROCEDURE cmdClear.Click*清除新口令thisform.txtnewpwd1.value=""thisform.txtnewpwd2.value=""ENDPROC实现保存新口令功能PROCEDURE cmdSave.Click*检查两次输入的口令是否相同with thisformIF .txtnewpwd1.value<>.txtnewpwd2.valuemessagebox("两次输入的新口令不相同",16,"口令修改").txtnewpwd1.setfocusreturnendif*获得输入的新口令cpwd=alltrim(.txtnewpwd1.text)*修改口令select sysuserdatareplace 口令with cpwd while 编号=capp_currentusercapp_currentpwd=cpwdmessagebox("口令修改成功",64,"口令修改").txtoldpwd.value=cpwd.txtnewpwd1.value="".txtnewpwd2.value=""endwithENDPROC实现关闭表单功能PROCEDURE cmdExit.Clickif messagebox("是否退出口令修改?",36,"口令修改")=6thisform.release &&关闭口令修改表单endifENDPROC5.实现读者类型管理功能初始化表单PROCEDURE Iint*打开读者类型表readertypeuse data\readertype*在表单中显示原来的读者类型数据*显示特殊读者类型数据go topthisform.text2.value=借书量thisform.text3.value=借书期thisform.text4.value=有效期*显示馆员类型数据skipthisform.text6.value=借书量thisform.text7.value=借书期thisform.text8.value=有效期*显示教师类型数据skipthisform.text10.value=借书量thisform.text11.value=借书期thisform.text12.value=有效期*显示学生类型数据skipthisform.text14.value=借书量thisform.text15.value=借书期thisform.text16.value=有效期ENDPROC实现保存功能PROCEDURE command1.Clickwith thisformif reccount()=0*保存特殊读者类型数据insert into readertype (类号,借书量,借书期,有效期);values ("0",.text2.value,.text3.value,.text4.value)*保存馆员类型数据insert into readertype (类号,借书量,借书期,有效期);values ("1",.text6.value,.text7.value,.text8.value)*保存教师类型数据insert into readertype (类号,借书量,借书期,有效期);values ("2",.text10.value,.text11.value,.text12.value)*保存学生类型数据insert into readertype (类号,借书量,借书期,有效期);values ("3",.text14.value,.text15.value,.text16.value)else*保存特殊读者类型数据replace 借书量with .text2.value,借书期with .text3.value,有效期with .text4.value;for 类号=="0"*保存馆员类型数据replace 借书量with .text6.value,借书期with .text7.value,有效期with .text8.value;for 类号=="1"*保存教师类型数据replace 借书量with .text10.value,借书期with .text11.value,有效期with .text12.value;for 类号=="2"*保存学生类型数据replace 借书量with .text14.value,借书期with .text15.value,有效期with .text16.value;for 类号=="3"endifendwithmessagebox("数据保存成功",64,"读者类型管理")ENDPROC实现关闭表单功能PROCEDURE command1.Clickif messagebox("是否退出读者类型管理?",36,"读者类型管理")=6thisform.release &&关闭读者类型管理表单endifENDPROC6.实现读者数据管理功能实现添加记录功能PROCEDURE command1.Click*取消各个文本框数据绑定属性,在保存后再恢复thisform.txt证号.controlsource=""thisform.txt证号.value=""thisform.txt类号.controlsource=""thisform.txt类号.value=""thisform.txt姓名.controlsource=""thisform.txt姓名.value=""thisform.txt部门.controlsource=""thisform.txt部门.value=""thisform.txt时间.controlsource=""thisform.txt时间.value=""*取消文本框的只读属性thisform.txt证号.readonly=.F.thisform.txt类号.readonly=.F.thisform.txt姓名.readonly=.F.thisform.txt部门.readonly=.F.thisform.txt时间.readonly=.F.*设置默认的类号和办证时间thisform.txt类号.value="3"thisform.txt时间.value=date()thisform.isadding=.T. &&设置添加状态标志thisform.caption="读者数据管理-[添加]" &&修改表单标题thisform.mynavigator1.enabled=.f. &&禁用记录导航条thisform.cmdadd.enabled=.f. &&禁用添加按钮thisform.cmdedit.enabled=.f. &&禁用修改按钮thisform.cmddelete.enabled=.f. &&禁用删除按钮thisform.cmdexit.enabled=.f. &&禁用退出按钮ENDPROC实现修改记录功能PROCEDURE command5.Clickif reccount()<1return &&在无记录时直接返回endif*取消各个文本框数据绑定属性,在保存后再恢复thisform.txt证号.controlsource=""thisform.txt类号.controlsource=""thisform.txt姓名.controlsource=""thisform.txt部门.controlsource=""thisform.txt时间.controlsource=""thisform.iseditting=.T. &&设置修改状态标志thisform.caption="读者数据管理-[浏览]" &&修改表单标题thisform.mynavigator1.enabled=.f. &&禁用记录导航条thisform.cmdadd.enabled=.f. &&禁用添加按钮thisform.cmdedit.enabled=.f. &&禁用修改按钮thisform.cmddelete.enabled=.f. &&禁用删除按钮thisform.cmdexit.enabled=.f. &&禁用退出按钮*取消文本框的只读属性thisform.txt证号.readonly=.F.thisform.txt类号.readonly=.F.thisform.txt姓名.readonly=.F.thisform.txt部门.readonly=.F.thisform.txt时间.readonly=.F.ENDPROC实现退出添加或修改状态功能PROCEDURE command3.Click*退出当前修改或添加状态if thisform.isadding or thisform.isedittingnRecno=recno() &&记录当前记录编号*恢复各个文本框数据绑定属性thisform.txt证号.controlsource="readerdata.证号"thisform.txt类号.controlsource="readerdata.类号"thisform.txt姓名.controlsource="readerdata.姓名"thisform.txt部门.controlsource="readerdata.部门"thisform.txt时间.controlsource="readerdata.时间"go nrecnothisform.refresh*清除编辑和添加状态标记thisform.isadding=.f.thisform.iseditting=.f.*恢复文本框的只读属性thisform.txt证号.readonly=.T.thisform.txt类号.readonly=.T.thisform.txt姓名.readonly=.T.thisform.txt部门.readonly=.T.thisform.txt时间.readonly=.T.thisform.caption="系统用户数据管理-[浏览]" &&修改表单标题thisform.mynavigator1.enabled=.t. &&重新启用记录导航条thisform.cmdexit.enabled=.t. &&重新启用退出按钮thisform.cmdadd.enabled=.t. &&重新启用添加按钮thisform.cmdedit.enabled=.t. &&重新启用修改按钮thisform.cmddelete.enabled=.t. &&重新启用删除按钮endifENDPROC实现保存功能PROCEDURE command4.Click*判断当前是否处于添加或编辑状态if not (thisform.isadding or thisform.iseditting)return &&在不处于添加或编辑状态时不执行保存操作endif*执行保存记录操作,首先获得输入cNum=alltrim(thisform.txt证号.value)cType=alltrim(thisform.txt类号.value)cName=alltrim(thisform.txt姓名.value)cDept=alltrim(thisform.txt部门.value)dDate=thisform.txt时间.valueif empty(cName) &&验证姓名是否为空messagebox("姓名不能为空!",16,"读者数据管理")thisform.txt姓名.value=""thisform.txt姓名.setfocusreturnendifif empty(cDept) &&验证部门是否为空messagebox("部门不能为空!",16,"读者数据管理")thisform.txt部门.value=""thisform.txt部门.setfocusreturnendif*检验部门中的读者姓名是否重复nRecno=recno() &&记录当前记录编号if thisform.isaddinglocate for alltrim(姓名)==cName and alltrim(部门)==cDeptif found()messagebox("姓名:<"+cName+">在<"+cDept+">中与第"+;alltrim(str(recno()))+"条记录重复!",16,"读者数据管理") thisform.txt部门.setfocusgo nRecnoreturnendifelselocate for alltrim(姓名)==cName and alltrim(部门)==cDeptdo while not eof()if found() and nrecno<>recno()messagebox("姓名:<"+cName+">在<"+cDept+">中与第"+;alltrim(str(recno()))+"条记录重复!",16,"读者数据管理") thisform.txt部门.setfocusgo nRecnoreturnendifcontinueenddoendif*检查证号是否已被使用locate for 证号==cNumif found()if thisform.isaddingmessagebox("证号:"+cNum+"已被使用,与第"+;alltrim(str(recno()))+"条记录重复!",16,"读者数据管理") thisform.txt证号.setfocusgo nRecnoreturnelseif nrecno<>recno()messagebox("证号:"+cNum+"已被使用与第"+;alltrim(str(recno()))+"条记录重复!",16,"读者数据管理") thisform.txt证号.setfocusgo nRecnoreturnendifendifendif*检查类号是否有效if not(cType="0" or cType="1" or cType="2" or cType="3")messagebox("类号:只能是0、1、2或3!",16,"读者数据管理")thisform.txt类号.setfocusreturnendif*将通过验证的数据保存到readerdata表if thisform.isaddinginsert into readerdata (姓名,部门,证号,类号,时间) ;values (cnum,cpwd,cDate)elsereplace 姓名with cName,部门with cDept,证号with cNum,;类号with cType,时间with dDate RECORD nrecnoendif*恢复各个文本框数据绑定属性thisform.txt证号.controlsource="readerdata.证号"thisform.txt类号.controlsource="readerdata.类号"thisform.txt姓名.controlsource="readerdata.姓名"thisform.txt部门.controlsource="readerdata.部门"thisform.txt时间.controlsource="readerdata.时间"*清除编辑和添加状态标记thisform.isadding=.f.thisform.iseditting=.f.*恢复文本框的只读属性thisform.txt证号.readonly=.T.thisform.txt类号.readonly=.T.thisform.txt姓名.readonly=.T.thisform.txt部门.readonly=.T.thisform.txt时间.readonly=.T.thisform.caption="系统用户数据管理-[浏览]" &&修改表单标题thisform.mynavigator1.enabled=.t. &&重新启用记录导航条thisform.cmdexit.enabled=.t. &&重新启用退出按钮thisform.cmdadd.enabled=.t. &&重新启用添加按钮thisform.cmdedit.enabled=.t. &&重新启用修改按钮thisform.cmddelete.enabled=.t. &&重新启用删除按钮*使新添加的记录或被修改记录成为当前记录if thisform.isaddinggo bottomelsego nrecnoendifthisform.refreshmessagebox("数据保存成功",64,"读者数据管理")ENDPROC实现删除记录功能PROCEDURE command2.Clickif reccount()<1return &&在无记录时直接返回endifif messagebox("是否删除当前记录",36,"读者数据管理")=6 &&选择删除记录nrecno=recno() &&记录当前记录编号delete &&对记录作删除标记pack &&彻底删除当前记录*使被删除记录的下一条记录成为当前记录if reccount()<=1go topelseif nrecno=reccount()+1go bottomelsego nrecnoendifendifthisform.refreshendifENDPROC实现关闭表单功能PROCEDURE command6.Clickif messagebox("是否退出读者数据管理?",36,"读者数据管理")=6thisform.release &&关闭读者数据管理表单endifENDPROC7.实现图书征定管理功能现添加记录功能PROCEDURE command1.Click*取消各个文本框数据绑定属性,在保存后再恢复thisform.txt书名.controlsource=""thisform.txt书名.value=""thisform.txt作者.controlsource=""thisform.txt作者.value=""thisform.txt出版社.controlsource=""thisform.txt出版社.value=""thisform.txt出版日期.controlsource=""thisform.txt数量.controlsource=""thisform.txt征订日期.controlsource=""*取消文本框的只读属性thisform.txt书名.readonly=.F.thisform.txt作者.readonly=.F.thisform.txt出版社.readonly=.F.thisform.txt出版日期.readonly=.F.thisform.txt数量.readonly=.F.thisform.txt征订日期.readonly=.F.*设置默认的数量和日期thisform.txt出版日期.value=date()thisform.txt数量.value=100thisform.txt征订日期.value=date()thisform.isadding=.T. &&设置添加状态标志thisform.caption="征订数据管理-[添加]" &&修改表单标题thisform.mynavigator1.enabled=.f. &&禁用记录导航条thisform.cmdadd.enabled=.f. &&禁用添加按钮thisform.cmdedit.enabled=.f. &&禁用修改按钮thisform.cmddelete.enabled=.f. &&禁用删除按钮thisform.cmdexit.enabled=.f. &&禁用退出按钮ENDPROC实现修改记录功能PROCEDURE command5.Clickif reccount()<1return &&在无记录时直接返回endif*取消各个文本框数据绑定属性,在保存后再恢复thisform.txt书名.controlsource=""thisform.txt作者.controlsource=""thisform.txt出版社.controlsource=""thisform.txt出版日期.controlsource=""thisform.txt数量.controlsource=""thisform.txt征订日期.controlsource=""*取消文本框的只读属性thisform.txt书名.readonly=.F.thisform.txt作者.readonly=.F.thisform.txt出版社.readonly=.F.thisform.txt出版日期.readonly=.F.thisform.txt数量.readonly=.F.thisform.txt征订日期.readonly=.F.thisform.iseditting=.T. &&设置修改状态标志thisform.caption="征订数据管理-[修改]" &&修改表单标题thisform.mynavigator1.enabled=.f. &&禁用记录导航条thisform.cmdadd.enabled=.f. &&禁用添加按钮thisform.cmdedit.enabled=.f. &&禁用修改按钮thisform.cmddelete.enabled=.f. &&禁用删除按钮thisform.cmdexit.enabled=.f. &&禁用退出按钮ENDPROC实现退出添加或修改状态功能PROCEDURE command3.Click*退出当前修改或添加状态if thisform.isadding or thisform.isedittingnRecno=recno() &&记录当前记录编号*恢复各个文本框数据绑定属性thisform.txt书名.controlsource="rebookdata.书名"thisform.txt作者.controlsource="rebookdata.作者"thisform.txt出版社.controlsource="rebookdata.出版社"thisform.txt出版日期.controlsource="rebookdata.出版日期"thisform.txt数量.controlsource="rebookdata.数量"thisform.txt征订日期.controlsource="rebookdata.征订日期"go nrecnothisform.refresh*清除编辑和添加状态标记thisform.isadding=.f.thisform.iseditting=.f.*恢复文本框的只读属性thisform.txt书名.readonly=.T.thisform.txt作者.readonly=.T.thisform.txt出版社.readonly=.T.thisform.txt出版日期.readonly=.T.thisform.txt数量.readonly=.F.thisform.txt征订日期.readonly=.T.thisform.caption="征订数据管理-[浏览]" &&修改表单标题thisform.mynavigator1.enabled=.t. &&重新启用记录导航条thisform.cmdexit.enabled=.t. &&重新启用退出按钮thisform.cmdadd.enabled=.t. &&重新启用添加按钮thisform.cmdedit.enabled=.t. &&重新启用修改按钮thisform.cmddelete.enabled=.t. &&重新启用删除按钮endifENDPROC实现保存功能PROCEDURE command4.Click*判断当前是否处于添加或编辑状态if not (thisform.isadding or thisform.iseditting)return &&在不处于添加或编辑状态时不执行保存操作*执行保存记录操作,首先获得输入cName=alltrim(thisform.txt书名.value)cWriter=alltrim(thisform.txt作者.value)cPB=alltrim(thisform.txt出版社.value)dPd=thisform.txt出版日期.valuenSum=thisform.txt数量.valuedBd=thisform.txt征订日期.valueif empty(cName) &&验证书名是否为空messagebox("书名不能为空!",16,"征订数据管理 ")thisform.txt书名.value=""thisform.txt书名.setfocusreturnendifif empty(cWriter) &&验证作者是否为空messagebox("作者不能为空!",16,"征订数据管理 ")thisform.txt作者.value=""thisform.txt作者.setfocusreturnendif*检验书名和作者是否重复nRecno=recno() &&记录当前记录编号if thisform.isaddinglocate for alltrim(书名)==cName and alltrim(作者)==cWriterif found()messagebox("书名:<"+cName+">与<"+cWriter+">中与第"+;alltrim(str(recno()))+"条记录重复!",16,"征订数据管理 ") thisform.txt作者.setfocusgo nRecnoreturnendifelselocate for alltrim(书名)==cName and alltrim(作者)==cWriterdo while not eof()if found() and nrecno<>recno()messagebox("书名:<"+cName+">与<"+cWriter+">中与第"+;alltrim(str(recno()))+"条记录重复!",16,"征订数据管理 ") thisform.txt作者.setfocusgo nRecnoreturnendifcontinueendif*检查数量是否有效if nSum=0messagebox("征订数量不能为0!",16,"征订数据管理 ")thisform.txt数量.setfocusreturnendif*将通过验证的数据保存到readerdata表if thisform.isaddinginsert into rebookdata (书名,作者,出版社,出版日期,数量,征订日期) ;values (cName,cWriter,cPB,dPd,nSum,dBd)elsereplace 书名with cName,作者with cWriter,出版社with cPB,;出版日期with dPd,数量with nSum,征订日期with dBd RECORD nrecno endif*恢复各个文本框数据绑定属性thisform.txt书名.controlsource="rebookdata.书名"thisform.txt作者.controlsource="rebookdata.作者"thisform.txt出版社.controlsource="rebookdata.出版社"thisform.txt出版日期.controlsource="rebookdata.出版日期"thisform.txt数量.controlsource="rebookdata.数量"thisform.txt征订日期.controlsource="rebookdata.征订日期"*清除编辑和添加状态标记thisform.isadding=.f.thisform.iseditting=.f.*恢复文本框的只读属性thisform.txt书名.readonly=.T.thisform.txt作者.readonly=.T.thisform.txt出版社.readonly=.T.thisform.txt出版日期.readonly=.T.thisform.txt数量.readonly=.F.thisform.txt征订日期.readonly=.T.thisform.caption="征订数据管理-[浏览]" &&修改表单标题thisform.mynavigator1.enabled=.t. &&重新启用记录导航条thisform.cmdexit.enabled=.t. &&重新启用退出按钮thisform.cmdadd.enabled=.t. &&重新启用添加按钮thisform.cmdedit.enabled=.t. &&重新启用修改按钮thisform.cmddelete.enabled=.t. &&重新启用删除按钮*使新添加的记录或被修改记录成为当前记录if thisform.isaddingelsego nrecnoendifthisform.refreshmessagebox("数据保存成功",64,"征订数据管理")ENDPROC实现删除记录功能PROCEDURE command2.Clickif reccount()<1return &&在无记录时直接返回endifif messagebox("是否删除当前记录",36,"征订数据管理")=6 &&选择删除记录nrecno=recno() &&记录当前记录编号delete &&对记录作删除标记pack &&彻底删除当前记录*使被删除记录的下一条记录成为当前记录if reccount()<=1go topelseif nrecno=reccount()+1go bottomelsego nrecnoendifendifthisform.refreshendifENDPROC实现报表预览功能PROCEDURE command7.Click*预览征订数据报表report form reports\rebookdatareport previewENDPROC实现打印表单功能PROCEDURE command8.Click*打印征订数据报表if messagebox("是否打印征订数据报表?",36,"征订数据管理")=6report form reports\rebookdatareport.frx noconsole to printendifENDPROC实现关闭表单功能PROCEDURE command2.Clickif messagebox("是否退出征订数据管理?",36,"征订数据管理")=6thisform.release &&关闭征订数据管理表单endifENDPROC8.实现新书编目管理功能实现添加记录功能PROCEDURE command1.Click*取消各个文本框数据绑定属性,在保存后再恢复thisform.txt书名.controlsource=""thisform.txt书名.value=""thisform.txt索书号.controlsource=""thisform.txt索书号.value=""thisform.txt作者.controlsource=""thisform.txt作者.value=""thisform.txt出版社.controlsource=""thisform.txt出版社.value=""thisform.txt内容简介.controlsource=""thisform.txt内容简介.value=""thisform.txt关键词.controlsource=""thisform.txt关键词.value=""thisform.txt条码.controlsource=""thisform.txt条码.value=""thisform.txt字数.controlsource=""thisform.txt字数.value=""thisform.txt页数.controlsource=""thisform.txt页数.value=""thisform.txt出版日期.controlsource=""thisform.txt出版日期.value=""*取消文本框的只读属性thisform.txt书名.readonly=.F.thisform.txt索书号.readonly=.F.thisform.txt作者.readonly=.F.thisform.txt出版社.readonly=.F.thisform.txt内容简介.readonly=.F.thisform.txt关键词.readonly=.F.thisform.txt条码.readonly=.F.thisform.txt字数.readonly=.F.thisform.txt页数.readonly=.F.thisform.txt出版日期.readonly=.F.thisform.isadding=.T. &&设置添加状态标志thisform.caption="新书编目管理-[添加]" &&修改表单标题thisform.mynavigator1.enabled=.f. &&禁用记录导航条thisform.cmdadd.enabled=.f. &&禁用添加按钮thisform.cmdedit.enabled=.f. &&禁用修改按钮thisform.cmddelete.enabled=.f. &&禁用删除按钮thisform.cmdexit.enabled=.f. &&禁用退出按钮ENDPROC实现修改记录功能PROCEDURE command5.Clickif reccount()<1return &&在无记录时直接返回endif*取消各个文本框数据绑定属性,在保存后再恢复thisform.txt书名.controlsource=""thisform.txt索书号.controlsource=""thisform.txt作者.controlsource=""thisform.txt出版社.controlsource=""thisform.txt内容简介.controlsource=""thisform.txt关键词.controlsource=""thisform.txt条码.controlsource=""thisform.txt字数.controlsource=""thisform.txt页数.controlsource=""thisform.txt出版日期.controlsource=""*取消文本框的只读属性thisform.txt书名.readonly=.F.thisform.txt索书号.readonly=.F.thisform.txt作者.readonly=.F.thisform.txt出版社.readonly=.F.thisform.txt内容简介.readonly=.F.thisform.txt关键词.readonly=.F.thisform.txt条码.readonly=.F.thisform.txt字数.readonly=.F.thisform.txt页数.readonly=.F.thisform.txt出版日期.readonly=.F.thisform.iseditting=.T. &&设置修改状态标志thisform.caption="新书编目管理-[修改]" &&修改表单标题thisform.mynavigator1.enabled=.f. &&禁用记录导航条thisform.cmdadd.enabled=.f. &&禁用添加按钮thisform.cmdedit.enabled=.f. &&禁用修改按钮thisform.cmddelete.enabled=.f. &&禁用删除按钮thisform.cmdexit.enabled=.f. &&禁用退出按钮ENDPROC实现退出添加或修改状态功能PROCEDURE command3.Click*退出当前修改或添加状态if thisform.isadding or thisform.isedittingnRecno=recno() &&记录当前记录编号*恢复各个文本框数据绑定属性*取消各个文本框数据绑定属性,在保存后再恢复thisform.txt书名.controlsource="newbookbibli.书名"thisform.txt索书号.controlsource="newbookbibli.索书号"thisform.txt作者.controlsource="newbookbibli.作者"thisform.txt出版社.controlsource="newbookbibli.出版社"thisform.txt内容简介.controlsource="newbookbibli.内容简介"thisform.txt关键词.controlsource="newbookbibli.关键词"thisform.txt条码.controlsource="newbookbibli.条码"thisform.txt字数.controlsource="newbookbibli.字数"thisform.txt页数.controlsource="newbookbibli.页数"thisform.txt出版日期.controlsource="newbookbibli.出版日期"go nrecnothisform.refresh*取消文本框的只读属性thisform.txt书名.readonly=.T.thisform.txt索书号.readonly=.T.thisform.txt作者.readonly=.T.thisform.txt出版社.readonly=.T.thisform.txt内容简介.readonly=.T.thisform.txt关键词.readonly=.T.thisform.txt条码.readonly=.T.thisform.txt字数.readonly=.T.thisform.txt页数.readonly=.T.thisform.txt出版日期.readonly=.T.*清除编辑和添加状态标记thisform.isadding=.f.thisform.iseditting=.f.thisform.caption="新书书目管理-[浏览]" &&修改表单标题thisform.mynavigator1.enabled=.t. &&重新启用记录导航条 thisform.cmdexit.enabled=.t. &&重新启用退出按钮 thisform.cmdadd.enabled=.t. &&重新启用添加按钮 thisform.cmdedit.enabled=.t. &&重新启用修改按钮 thisform.cmddelete.enabled=.t. &&重新启用删除按钮endifENDPROC实现保存功能PROCEDURE command4.Click。
图书管理系统(源代码)
#include"stdio.h"#include"stdlib.h"#include"string.h"#define MENU_ADMIN_COUNT 2#define MENU_SEARCH_BOOK_COUNT 6 #define MENU_USER_COUNT 7#define BOOK_FILE "books.dat"#define USER_FILE "user.dat"#define MAX_BOOK_NAME 20#define MAX_PUBLISHER 20#define MAX_DATE 10#define MAX_AUTHOR 20#define MAX_ISBN 20typedef struct _book_info{ char book_name[MAX_BOOK_NAME]; char author[MAX_AUTHOR];char publisher[MAX_PUBLISHER];char pub_date[MAX_DA TE];char ISBN[MAX_ISBN];int pages;}book_info;typedef struct _book{ book_info bi;struct _book* next;}book;#define MAX_USERNAME 10#define MAX_PASSWORD 10typedef enum _USER_TYPE{ADMIN=0,USER}USER_TYPE;typedef struct _user_info{char username[MAX_USERNAME];char password[MAX_PASSWORD]; USER_TYPE user_type;}user_info;typedef struct _user{ user_info ui;struct _user* next;}user;void init_user();void load_users();USER_TYPE login();void add_user();void search_user();void save_users();void clear_users();void save_users_to_file();user* get_last_user();user* get_previous_user(user* p);user* find_user(char* name);void show_user(user_info* info);void input_user(user_info* info);void delete_user(user* p);void update_user(user* p);void init_book();void load_books();void add_book();void view_book();void delete_book();void save_books();void clear_books();void search_book_by_name();void search_book_by_author();void search_book_by_publisher();void search_book_by_pubdate();void search_book_by_isbn();int findstr(char *source,char *str);void save_books_to_file();book* get_last_book();book* get_previous_book(book* p);void input_book(book_info* info);void show_book(book_info* info);void show_admin_menu();void show_search_book_menu();void show_user_menu();void admin_exit();void user_exit();book *first_book=NULL;user* first_user=NULL;char menu_title[]="=========================================\n" "| 图书管理系统|\n""+---------------------------------------+\n";char menu_admin[]="| |\n" "| (1)图书管理|\n" "| (2)用户管理|\n" "| (3)退出系统|\n" "+---------------------------------------+\n";char admin_menu1[]="-----------------------------------------\n""| 图书管理|\n" "----------------------------------------|\n""| <1>新增图书|\n" "| <2>浏览图书|\n" "| <3>查找图书|\n" "| <4>删除图书|\n" "| <5>保存图书|\n" "| <0>返回主菜单|\n" "-----------------------------------------\n";char admin_menu2[]="----------------------------------------\n"" 用户管理|\n" "----------------------------------------|\n""| <1>新增用户|\n" "| <2>查找用户|\n" "| <3>保存用户|\n" "| <0>返回主菜单|\n" "|---------------------------------------|\n";void(*menu1_fun[])()={add_book,view_book,show_search_book_menu,delete_book,save_books,};void(*menu2_func[])()={add_user,search_user,save_users,};char menu_admin_search_book[]="| 查找图书:|\n" "| <1>按书名查找|\n" "| <2>按作者查找|\n" "| <3>按出版社查找|\n" "| <4>按出版日期查找|\n" "| <5>按国际标准书号(ISBN)查找|\n" "| <0>返回主菜单|\n" "+--------------------------------------+\n";void (*admin_search_book_func[])()={search_book_by_name,search_book_by_author,search_book_by_publisher,search_book_by_pubdate,search_book_by_isbn,};char menu_user[]="| <1>浏览图书|\n" "| <2>按书名查找图书|\n" "| <3>按作者查找图书|\n" "| <4>按出版社查找图书|\n" "| <5>按出版日期查找图书|\n" "| <6>按国际标准书号(ISBN)查找图书|\n" "| <0>退出系统|\n" "+--------------------------------------+\n";void (*user_func[])()={view_book,search_book_by_name,search_book_by_author,search_book_by_publisher,search_book_by_pubdate,search_book_by_isbn,user_exit};void add_book(){ char try_again='Y';book *p=NULL;book *new_book=NULL;while(try_again=='Y' || try_again=='y'){ new_book=(book*)malloc(sizeof(book));memset(new_book,0,sizeof(book));new_book->next=NULL;printf(">新增图书...\n");input_book(&(new_book->bi));p=get_last_book();if(p==NULL){ first_book=new_book;}else{ p->next=new_book;}printf(">继续添加图书吗?(y or n):");getchar();try_again=getchar();}}void view_book(){ book *p=NULL;char input='Y';int count=0;while(input=='y' || input=='Y'){ count=0;p=first_book;printf("+---------------------------------------+\n");printf("| 书名| 作者|\n");printf("+---------------------------------------+\n");while(p!=NULL){ printf("|%20s|%20s|\n",p->bi.book_name,p->bi.author);printf("+-------------------------------------+\n");count++;if(count==5){ count=0;printf(">显示下一页吗?(y or n):");getchar();input=getchar();if(input!='y' && input!='Y'){ break;}}p=p->next;}printf(">再次浏览图书吗?(y or n):");getchar();input=getchar();}}void search_book_by_name(){ book *p=NULL;char s[MAX_BOOK_NAME]={0};char input='Y';int count=0;int i=0;printf(">查找图书...\n");while(input=='Y' || input=='y'){ count=0;p=first_book;memset(s,0,MAX_BOOK_NAME);printf(">请输入书名(最大长度为%d):",MAX_BOOK_NAME);scanf("%s",s);while(p!=NULL){ if(findstr(p->bi.book_name,s)!=-1){ show_book(&(p->bi));count++;}p=p->next;}if(count==0){ printf(">没有找到图书%s。
图书馆管理系统完整代码
<body> <table border="0" width="751" height="62" align="center"> <tbody><tr> <td> <img border="0" src="Images/banner.png" width="1300" height="200"></td></tr> </tbody></table><br><table border="0" width="1300" height="76"> <tbody><tr> <td align="right"> <a href="queryBook.jsp">图书检索</a></td> <td align="center"> <a href="login.jsp">用户登陆</a></td> <td><a href="logon.jsp">用户注册</a></td></tr>
</tbody></table><br></body> </html>
图书馆管理系统代码
图书馆管理系统代码#include#define DEBUG 0//宏定义决定测试代码是否编译0为不编译⾮0则编译const char book_path[20] = "books.txt";const char reader_path[20] = "readers.txt";//⽂件读写声明void read_from_files_to_vector();void write_all_to_files();#if DEBUGvoid scan_readers() {for(reader &s:readers) {wcout << s;}}#endifint main(){//完成操作后需要在控制台按5中退出才会保存到⽂件wcin.imbue(china);wcout.imbue(china);read_from_files_to_vector();#if DEBUGcout <<"size of readers = "<< readers.size() << endl;cout <<"size of books = "<< books.size() << endl;scan_book();scan_readers();#endifstring password = "123456"; //密码已改cout <<"------------欢迎使⽤中南⼤学⽹络在线图书系统------------"< //这⾥可以添加你们⼩组的名单或⼀些装饰的字符cout <<"--------------------请选择登录⽅式--------------------"<< endl; cout <<" 1 管理员登陆2读者登陆"<< endl;int a;cin >> a;cleanScreen();if (a == 1){string str;for (int j = 0; j <= 4; j++){cout <<"请输⼊管理密码,你有"<< (4-j) <<"次机会"<< endl; cin >> str;if (password == str){break;}else cout <<"密码错误!请重新输⼊"<< endl;if (j == 4)return 0;}cleanScreen();cout <<"-------------欢迎来到图书管理系统-------------"<< endl; cout <<"成功登陆!你有以下操作可供选择"<< endl;cout << endl;//操作循环cout <<" 1 浏览图书信息"<< endl;cout <<" 2 图书信息修改"<< endl;cout <<" 3 图书信息添加"<< endl;cout <<" 4 图书信息删除"<< endl;cout <<" 5 保存信息并退出系统"<< endl;cout <<"--------------请选择操作选项编号--------------"<< endl; int b;cin >> b;cleanScreen();while (b != 5) {switch (b){case 1:scan_book(); break;case 2:modify_book(); break;case 3:add_book(); break;case 4:delete_book(); break;default:cout <<"输⼊错误,请重新输⼊"; break;}cout << endl;cout <<"---------------请进⾏下⼀次操作---------------"<< endl; cout <<" 1 浏览图书信息"<< endl;cout <<" 2 图书信息修改"<< endl;cout <<" 3 图书信息添加"<< endl;cout <<" 4 图书信息删除"<< endl;cout <<" 5 退出系统"<< endl;cout <<"--------------请选择操作选项编号--------------"<< endl; cin >> b;cleanScreen();}write_all_to_files();return 0;}else if (a == 2){int readerIndex = 0; //记录读者下标//输⼊学号登陆cout <<"--------------请输⼊学号--------------"<< endl;wchar_t studentnumber[20];for (int m = 0; m <= 9; m++){cout <<"请输⼊学号,你有"<< (9-m) <<"次机会"<< endl; wcin >> studentnumber;int t;for (t = 0; t < readers.size(); t++){if (wcscmp(studentnumber, readers[t].cardnum) == 0){readerIndex = t;break;}}//判断跳出循环原因if (t < readers.size())break;else{cout <<"登录账号不存在,请重新输⼊学号"<< endl;continue;}if (m == 9)return 0;}cleanScreen();cout <<"------------欢迎来到读者⾃助系统------------"<< endl;wcout << L"欢迎你,"<< readers[readerIndex].name << L"!你有以下操作可供选择"<< endl; cout << endl;//操作循环cout <<" 1 图书浏览"<< endl;cout <<" 2 图书查询"<< endl;cout <<" 3 图书借阅"<< endl;cout <<" 4 图书返还"<< endl;cout <<" 5 退出系统"<< endl;cout <<"---------------请选择操作选项--------------"<< endl;int c;cin >> c;cleanScreen();while (c != 5){switch (c){case 1:scan_book(); break;case 2:search_book(); break;case 3:borrow_book(readerIndex); break;case 4:return_book(readerIndex); break;default:cout <<"输⼊错误!请重新输⼊"<< endl; break;}cout << endl;cout <<"--------------请进⾏下⼀次操作--------------"<< endl;cout <<" 1 图书浏览"<< endl;cout <<" 2 图书查询"<< endl;cout <<" 3 图书借阅"<< endl;cout <<" 4 图书返还"<< endl;cout <<" 5 退出系统"<< endl;cout <<"---------------请选择操作选项---------------"<< endl;cin >> c;cleanScreen();}write_all_to_files();return 0;}return 0;}//main 函数结束//写⼊/读取⽂件void write_all_to_files(){wofstream outfile;outfile.imbue(locale("chs"));//写⼊书本⽂件outfile.open(book_path);outfile << books.size() << '\n';for (int i = 0; i < books.size(); i++){outfile << books[i];}outfile.close();outfile.clear();//写⼊读者⽂件,由于程序中没有针对读者的删改(备⽤,将0改为1后即可编译这段代码) #if 0 outfile.open(path::reader_path);outfile << readers.size() << '\n';for (int i = 0; i < readers.size(); i++){outfile << readers[i];}outfile.close();#endifreturn;}void read_from_files_to_vector(){wifstream infile;infile.imbue(locale("chs"));//⽤于设置读写中⽂book bb;reader rr;//在程序⽬录下没有相应⽂件时创建空⽂件(备⽤,将0改为1后即可编译这段代码) #if 0 wofstream creat_if_no;creat_if_no.imbue(locale("chs"));creat_if_no.open(book_path,ios::_Noreplace);creat_if_no.close();creat_if_no.clear();creat_if_no.open(reader_path, ios::_Noreplace);creat_if_no.close();creat_if_no.clear();#endif//读取书本数据infile.open(book_path);int size = 0;infile >> size;while (!infile.eof() && size != 0){infile >> bb;books.push_back(bb);size--;}infile.close();infile.clear();//读取读者数据infile.open(reader_path);infile >> size;while (!infile.eof() && size != 0){infile >> rr;readers.push_back(rr);size--;}infile.close();return;}#include "classes.h"locale china("chs");//use china character/*void printout_book(book &b){cout << b.id << '\n'<< b.title << '\n'<< b.firstauthor << '\n'<< b.publisher <<'\n'<< b.birthday << '\n'<< b.location << '\n'<< b.price << '\n'<< b.number << endl;}*///这个函数我⽤重载运算符<< 的函数代替了//对应全局变量的定义vector books;vector readers;//book重载操作符函数定义wistream& operator >> (wistream& in, book &b) { cout <<"请输⼊书号"<< endl;cout <<"请输⼊书名"<< endl;in >> b.title;cout <<"请输⼊作者名"<< endl;in >> b.firstauthor;cout <<"请输⼊出版社"<< endl;in >> b.publisher;cout <<"请输⼊印刷⽇期(年⽉)"<< endl;in >> b.birthday;cout <<"请输⼊所属类别"<< endl;in >> b.location;cout <<"请输⼊价格"<< endl;in >> b.price;cout <<"请输⼊数量"<< endl;in >> b.number;return in;}wostream& operator<<(wostream& out, book &b){out << b.id << ' '<< b.title << ' '<< b.firstauthor << ' '<< b.publisher << ' '<< b.birthday.year << ' '<< b.birthday.month << ' '<< b.location << ' '<< b.price << ' '<< b.number << endl;return out;}wifstream& operator >> (wifstream& in, book &b){in >> b.id >> b.title >> b.firstauthor>> b.publisher >> b.birthday.year >> b.birthday.month >> b.location >> b.price >> b.number;{out << b.id << ' '<< b.title << ' '<< b.firstauthor << ' '<< b.publisher << ' '<< b.birthday << ' '<< b.location << ' '<< b.price << ' '<< b.number << '\n';return out;}//reader重载操作符函数定义wistream& operator >> (wistream& in, reader &r){//由于没有对reader的操作,这个函数尚未被使⽤cout <<"请输⼊读者姓名"<< endl;in >> /doc/3dc30ba0fbb069dc5022aaea998fcc22bdd14356.html ; cout <<"请输⼊性别(男为0,⼥为1)"<< endl;cout <<"请输⼊卡号"<< endl;in >> r.cardnum;cout <<"请输⼊学位(学⼠为0,硕⼠为1,博⼠为2)"<< endl;in >> r.e;r.already = 0; //已借书本数默认为0return in;}wostream& operator<<(wostream& out, reader &r){out << r.cardnum << ' ';out << /doc/3dc30ba0fbb069dc5022aaea998fcc22bdd14356.html << ' '; out << r.s << ' ';out << r.e << ' ';out << r.already << endl;{in >> r.cardnum >> /doc/3dc30ba0fbb069dc5022aaea998fcc22bdd14356.html >> r.s >> r.e >> r.already;return in;}wofstream& operator<<(wofstream& out, reader &r){out << r.cardnum << ' '<< /doc/3dc30ba0fbb069dc5022aaea998fcc22bdd14356.html << ' '<< r.s << ' '<< r.e << ' '<< r.already << '\n';return out;}//main函数中调⽤定义void scan_book() //建⽴浏览函数{for (int i = 0; i < books.size(); i++){wcout << books[i];}}void search_book() //建⽴搜索函数{cout <<"************你有以下查询⽅式可供选择************"<< endl; cout <<" 1 按书名查询"<< endl;cout <<" 2 按编号查询"<< endl;cout <<" 3 按作者查询"<< endl;cout <<"************请选择查询⽅式************"<< endl;cin >> g;switch (g){case 1:{wchar_t name[20];cout <<"************请输⼊书名************"<< endl; wcin >> name;for (int r = 0; r < books.size(); r++){if (wcscmp(books[r].title, name) == 0){wcout << books[r];return;}}cout <<"查⽆此书"<< endl;return;break;}case 2:{int str;cout <<"************请输⼊图书编号************"<< endl; cin >> str;for (int l = 0; l < books.size(); l++){if (books[l].id == str){wcout << books[l];return;}}cout <<"查⽆此书"<< endl;return;break;}case 3:wchar_t auth[10];cout <<"************请输⼊图书作者************"<< endl;wcin >> auth;for (int p = 0; p < books.size(); p++){if (wcscmp(books[p].firstauthor, auth) == 0){wcout << books[p];return;}}cout <<"查⽆此书"<< endl;return;break;}default:{cout <<"查⽆此书"<< endl;return;}}}//实现逻辑有问题,⽆法建⽴书-借书⼈的对应关系void borrow_book(int t) //建⽴借书函数{if (readers[t].already >= 5){cout <<"抱歉,你的借书数已满,不可再借"<< endl;return;}int log;cout <<"************请输⼊要借出图书的登陆号************"<< endl; wcin >> log;for (int i = 0; i < books.size(); ++i){if (log == books[i].id){if (books[i].number > 0){int y;cout <<"确认借出书籍吗?确认请输⼊1 取消请输⼊0"<< endl;cin >> y;if (y == 1){cout <<"借阅成功!";--(books[i].number);++(readers[t].already);return;}else return;}else{cout <<"图书已借完"<< endl;return;}}}cout <<"图书不存在!"<< endl;return;}void return_book(int t) //建⽴还书函数{int log;cout <<"************请输⼊要归还的图书的登陆号************"<< endl; wcin >> log;for (int i = 0; i < books.size(); i++){if (log == books[i].id){cout <<"图书归还成功"<< endl;++books[i].number;--readers[t].already;return;}}cout <<"图书不存在于本图书馆⽆需归还!"<< endl;return;}void modify_book() //建⽴修改函数{int log;cout <<"************请输⼊要修改的图书编号************"<< endl; wcin >> log;for (int i = 0; i < books.size(); i++){if (log == books[i].id){cout <<"需修改图书信息如下"<< endl;wcout << books[i];cout <<"************请输⼊修改后的信息************"<< endl; wcin >> books[i];return;}}cout <<"图书不存在⽆法修改"<< endl;return;}void delete_book(){int log;cout <<"************请输⼊要删除的图书编号************"<< endl; cin >> log;//迭代器实现删除指定图书vector::iterator itor2;for (vector::iterator iter = books.begin(); iter != books.end(); ){if (log == iter->id){cout <<"将删除的图书信息如下"<< endl;wcout << *iter;int sure = 0;cout <<"确定删除?(1确定,0取消)"<< endl;cin >> sure;if (sure == 0)return;//开始在内存中删除itor2 = iter;books.erase(itor2);cout <<"编号为"<< log <<"的图书已删除"<< endl; return;}elseiter++;}cout <<"图书不存在⽆法删除"<< endl;return;}void add_book(){book new_book;cout <<"************请输⼊新图书信息************"<< endl; wcin >> new_book;books.push_back(new_book);return;}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 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。