图书管理系统源代码

合集下载

图书管理系统程序源代码

图书管理系统程序源代码

源程序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。

图书馆管理系统源代码

图书馆管理系统源代码

以我给的标题写原创文档,最低1200字,要求以Markdown文本格式输出,不要带图片和AI、人工智能、Markdown、GPT等关键词,标题为:图书馆管理系统源代码# 图书馆管理系统源代码## 一、引言图书馆作为一个重要的知识资源和学术场所,对于学生和研究人员具有重要意义。

为了更好地管理图书馆资源和提供服务,图书馆管理系统应运而生。

本文将介绍图书馆管理系统的源代码设计和实现。

## 二、系统功能需求### 1. 登录功能- 提供管理员和用户登录功能- 管理员可进行图书管理、借阅管理等操作- 用户可查询图书信息、借阅情况等### 2. 图书管理- 添加新书籍信息- 修改或删除现有书籍信息- 查询图书信息,包括书名、作者、出版社等### 3. 借阅管理- 用户借阅图书- 用户归还图书- 管理员监管借阅情况### 4. 查询功能- 用户可以根据条件查询图书信息- 管理员可以查询借阅情况、用户信息等## 三、系统设计### 1. 数据库设计- 数据库包括图书信息表、用户信息表、借阅记录表等- 表之间建立关联,保证数据一致性和完整性### 2. 源代码结构```- books- README.md- book.js- bookRouter.js- users- README.md- user.js- userRouter.js- borrows- README.md- borrow.js- borrowRouter.js- index.js```### 3. 源代码逻辑- 使用Node.js构建后端服务- 使用Express框架处理路由和请求- 使用MongoDB作为数据库存储## 四、系统实现### 1. 登录功能```javascript// 用户登录router.post('/login', (req, res) => {// 处理登录逻辑});// 管理员登录router.post('/admin/login', (req, res) => { // 处理管理员登录逻辑});```### 2. 图书管理```javascript// 添加新书籍router.post('/addBook', (req, res) => {// 处理添加书籍逻辑});// 修改书籍信息router.put('/updateBook/:id', (req, res) => {// 处理修改书籍信息逻辑});// 删除书籍router.delete('/deleteBook/:id', (req, res) => {// 处理删除书籍逻辑});```### 3. 借阅管理```javascript// 用户借阅图书router.post('/borrowBook', (req, res) => {// 处理借阅图书逻辑});// 用户归还图书router.put('/returnBook/:id', (req, res) => {// 处理归还图书逻辑});```## 五、总结通过本文介绍,读者可以了解图书馆管理系统源代码的设计和实现逻辑。

图书管理系统源代码

图书管理系统源代码
{
char tsname[60];
char tsbh[6];
char xm[10];
char tel[13];
char sfc[20];
int tssl;
int tsyj;
}js[n];
void main()
{
load();
help: //帮助系统
system("time /t");
system("color 2f");
printf("\t\t ");
printf("\n\t\t\t欢迎使用本系统: << %s >> ",user1);
system("time /t");
printf("\n");
printf("\t\t\t◢※※※※※※※※※※※※※※※◣\n");
printf("\t\t\t※※※※※※※※※※※※※※※※※\n");
printf("\t\t\t※ ※\n");
printf("\t\t\t※ ◎ (1) 图 书 查 询 ★ ※\n"); //有没有书名和书的总量
first1 = time(NULL); /* Gets system time */
system("cls");
system("date /t");
system("time /t");
system("color 47");
printf("\n");

vb图书管理系统源代码

vb图书管理系统源代码

Borbook:Public sqltxt As StringPublic rno As String '保存读者借书证号Public bno As String '保存读者图书编号Public xm As String '保存读者姓名Public dw As String '保存读者单位Public rs As ADODB.RecordsetPrivate Sub Comm1_Click()rno = Trim(Text1(0).Text)If rno = "" ThenMsgBox "借书证号不能为空,请输入", vbOKOnly, "信息提示"Comm2.Enabled = FalseElsesqltxt = "select * from reader where 借书证号='" + rno + "'"Set rs = exesql(sqltxt)If rs.RecordCount = 0 ThenMsgBox "该读者未登记,不能借书", vbOKOnly, "信息提示"Comm2.Enabled = FalseElseText2(0).Text = rs.Fields("姓名")Text2(1).Text = str(rs.Fields("借书总数"))Text2(2).Text = str(rs.Fields("借书总数") - rs.Fields("已借书数"))If Val(Trim(Text2(2).Text)) > 0 Thenxm = rs.Fields("姓名")dw = rs.Fields("单位")Comm2.Enabled = TrueElseMsgBox "该读者已借满图书,不能再借!", vbOKOnly, "信息提示"Comm2.Enabled = FalseEnd IfEnd IfEnd IfEnd SubPrivate Sub Comm2_Click()If Val(Trim(Text2(2).Text)) = 0 ThenMsgBox "该读者已借满图书,不能再借!", vbOKOnly, "信息提示"Comm2.Enabled = FalseExit SubEnd Ifbno = Trim(Text1(1).Text)If bno = "" ThenMsgBox "图书编号不能为空,请输入", vbOKOnly, "信息提示"Comm2.Enabled = FalseElsesqltxt = "select * from book where 图书编号='" + bno + "'"Set bs = exesql(sqltxt)If bs.RecordCount = 0 ThenMsgBox "图书编号不对旳,请重新输入", vbOKOnly, "信息提示"ElseIf bs.Fields("借否") = "借" ThenMsgBox "该图书编号相应旳图书已借出,不能再借!", vbOKOnly, "信息提示"Elsesqltxt = "select * from borrow"Set brs = exesql(sqltxt)brs.AddNewbrs.Fields("图书编号") = bnobrs.Fields("书名") = bs.Fields("书名")brs.Fields("作者") = bs.Fields("作者")brs.Fields("出版社") = bs.Fields("出版社")brs.Fields("借书证号") = rnobrs.Fields("姓名") = xmbrs.Fields("单位") = dwbrs.Fields("借书日期") = Datebrs.Updatebs.Fields("借否") = "借"bs.Updaters.Fields("已借书数") = rs.Fields("已借书数") + 1rs.UpdateText2(2).Text = str(rs.Fields("借书总数") - rs.Fields("已借书数"))End IfEnd IfEnd IfEnd SubPrivate Sub retCom_Click()Unload MeEnd SubPrivate Sub Form_Load()Comm2.Enabled = FalseEnd SubPrivate Sub DataGrid1_Click()End SubPrivate Sub Form_Load()'阐明:为什么使用recs,而不直接使用adodc1.recordset.recordcount?在调用edbook1窗体添加一种记录(拟定)后,再'返回到本表单,若不在Form_Activate()事件过程中调用adodc1.refresh进行刷新,adodc1.recordset.recordcount值'仍未增1,这样调用encomm过程时出错;若在Form_Activate()事件过程中调用adodc1.refresh进行刷新,'adodc1.recordset.recordcount值增1了,调用encomm过程时也对旳,但返回本窗体时,目前行总是第一行,显然也不行,'由于顾客在添加或修改后但愿在datagrid1中显示目前操作旳那条记录.recs = Adodc1.Recordset.RecordCountEnd SubPrivate Sub Form_Activate()DataGrid1.SetFocusCall encommEnd SubPrivate Sub Comm1_Click()flag = 1edbook1.Show vbModalEnd SubPrivate Sub Comm2_Click()flag = 2edbook1.Show vbModalEnd SubPrivate Sub Comm3_Click()If MsgBox("真旳要删除[" + Trim(Adodc1.Recordset.Fields("书名")) + "]吗?", vbYesNo, "信息提示") = vbYes ThenAdodc1.Recordset.Deleterecs = recs - 1Call encommEnd IfEnd SubPrivate Sub Comm4_Click()Unload MePrivate Sub selcmd1_Click() '拟定Dim str As Stringstr = "" '条件体现式If Trim(Text1(0).Text) <> "" ThenIf str = "" Thenstr = "图书编号='" + Trim(Text1(0).Text) + "'"Elsestr = str + " and 图书编号='" + Trim(Text1(0).Text) + "'"End IfEnd IfIf Trim(Text1(1).Text) <> "" ThenIf str = "" Thenstr = "书名='" + Trim(Text1(1).Text) + "'"Elsestr = str + " and 书名='" + Trim(Text1(1).Text) + "'"End IfEnd IfIf Trim(Text1(2).Text) <> "" ThenIf str = "" Thenstr = "作者='" + Trim(Text1(2).Text) + "'"Elsestr = str + " and 作者='" + Trim(Text1(2).Text) + "'"End IfEnd IfIf Trim(Text1(3).Text) <> "" ThenIf str = "" Thenstr = "出版社='" + Trim(Text1(3).Text) + "'"Elsestr = str + " and 出版社='" + Trim(Text1(3).Text) + "'"End IfEnd IfIf Trim(Text1(4).Text) <> "" ThenIf str = "" Thenstr = "借否='" + Trim(Text1(4).Text) + "'"Elsestr = str + " and 借否='" + Trim(Text1(4).Text) + "'"End IfEnd IfIf str <> "" ThenAdodc1.RecordSource = "select * from book where " + strAdodc1.RefreshElseAdodc1.RecordSource = "select * from book"Adodc1.RefreshEnd Ifrecs = Adodc1.Recordset.RecordCountIf recs = 0 ThenMsgBox "没有任何满足条件旳记录", vbOKOnly, "信息提示" End IfCall encommEnd SubPrivate Sub selcmd2_Click() '重置Text1(0).Text = ""Text1(1).Text = ""Text1(2).Text = ""Text1(3).Text = ""Text1(4).Text = ""End SubPrivate Sub encomm() '自定义子过程:判断Adodc1中与否存在记录If recs = 0 ThenComm2.Enabled = FalseComm3.Enabled = FalseElseComm2.Enabled = TrueComm3.Enabled = TrueEnd IfEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) Call endata(KeyAscii)End SubEdbook1:Dim rs As ADODB.RecordsetPrivate Sub Form_Load()If flag = 2 Then '修改操作Text1(0).Text = edbook.Adodc1.Recordset.Fields("图书编号") & ""Text1(1).Text = edbook.Adodc1.Recordset.Fields("分类号") & ""Text1(2).Text = edbook.Adodc1.Recordset.Fields("书名") & ""Text1(3).Text = edbook.Adodc1.Recordset.Fields("作者") & ""DataCombo1.Text = edbook.Adodc1.Recordset.Fields("出版社") & ""Text1(4).Text = edbook.Adodc1.Recordset.Fields("定价") & ""Text1(5).Text = edbook.Adodc1.Recordset.Fields("入库日期") & ""Text1(0).Enabled = FalseElse '添加操作Text1(5).Text = DateEnd IfEnd SubPrivate Sub Form_Activate()Adodc1.Refresh '数据源刷新End SubPrivate Sub Comm1_Click()If Trim(Text1(0).Text) = "" Or Trim(Text1(2).Text) = "" Or Trim(Text1(3).Text) = "" Or Trim(Text1(5).Text) = "" ThenMsgBox "加*数据项不能为空,请重新设立", vbOKOnly, "信息提示"Exit SubEnd IfIf flag = 1 Then '添加操作sqltxt = "select * from book where 图书编号='" + Trim(Text1(0).Text) + "'" '对book中记录进行判断Set rs = exesql(sqltxt)If rs.RecordCount <> 0 ThenMsgBox "存在相似旳图书编号", vbOKOnly, "信息提示"Text1(0).SetFocusrs.CloseExit SubElsers.CloseEnd Ifedbook.Adodc1.Recordset.AddNewedbook.Adodc1.Recordset.Fields("图书编号") = Trim(Text1(0).Text)edbook.Adodc1.Recordset.Fields("分类号") = Trim(Text1(1).Text)edbook.Adodc1.Recordset.Fields("书名") = Trim(Text1(2).Text)edbook.Adodc1.Recordset.Fields("作者") = Trim(Text1(3).Text)edbook.Adodc1.Recordset.Fields("出版社") = Trim(DataCombo1.Text)edbook.Adodc1.Recordset.Fields("定价") = Val(Trim(Text1(4).Text))edbook.Adodc1.Recordset.Fields("入库日期") = Format(Trim(Text1(5).Text), "yyyy-mm-dd")edbook.Adodc1.Recordset.Fields("借否") = "否"edbook.Adodc1.Recordset.Updaterecs = recs + 1Else '修改操作edbook.Adodc1.Recordset.Fields("图书编号") = Trim(Text1(0).Text)edbook.Adodc1.Recordset.Fields("分类号") = Trim(Text1(1).Text)edbook.Adodc1.Recordset.Fields("书名") = Trim(Text1(2).Text)edbook.Adodc1.Recordset.Fields("作者") = Trim(Text1(3).Text)edbook.Adodc1.Recordset.Fields("出版社") = Trim(DataCombo1.Text)edbook.Adodc1.Recordset.Fields("定价") = Val(Trim(Text1(4).Text))edbook.Adodc1.Recordset.Fields("入库日期") = Format(Trim(Text1(5).Text), "yyyy-mm-dd")edbook.Adodc1.Recordset.UpdateEnd IfUnload MeEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubPrivate Sub selcom_Click()tna = "press"cap = "出版社"edrec.Show vbModalEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)If Index = 1 ThenIf KeyAscii = 13 Thensqltxt = "select * from book where 分类号='" + Trim(Text1(1).Text) + "'" '对book中记录进行判断Set rs = exesql(sqltxt)If rs.RecordCount > 0 ThenText1(2).Text = rs.Fields("书名")Text1(3).Text = rs.Fields("作者")Text1(4).Text = rs.Fields("定价")DataCombo1.Text = rs.Fields("出版社")rs.CloseText1(5).SetFocusElseCall endata(KeyAscii)End IfEnd IfElseCall endata(KeyAscii)End IfEnd SubPrivate Sub DataCombo1_KeyPress(KeyAscii As Integer) Call endata(KeyAscii)End SubDim msg As StringPrivate Sub Form_Load()recs = Adodc1.Recordset.RecordCountEnd SubPrivate Sub Form_Activate()Call encommEnd SubPrivate Sub Comm1_Click()flag = 1edlev1.Show vbModalEnd SubPrivate Sub Comm2_Click()flag = 2edlev1.Show vbModalEnd SubPrivate Sub Comm3_Click()If MsgBox("真旳要删除[" + Trim(Adodc1.Recordset.Fields("级别")) + "]吗?", vbYesNo, "信息提示") = vbYes ThenAdodc1.Recordset.Deleterecs = recs - 1Call encommEnd IfEnd SubPrivate Sub Comm4_Click()Unload MeEnd SubPrivate Sub encomm()If recs = 0 ThenComm2.Enabled = FalseComm3.Enabled = FalseElseComm2.Enabled = TrueComm3.Enabled = TrueEnd IfEnd SubDim cond As StringPrivate Sub Form_Load()If flag = 2 ThenText1(0).Text = edlev.Adodc1.Recordset.Fields("级别")Text1(1).Text = edlev.Adodc1.Recordset.Fields("过期罚款")Text1(2).Text = edlev.Adodc1.Recordset.Fields("借书总数")Text1(3).Text = edlev.Adodc1.Recordset.Fields("借书天数")End IfEnd SubPrivate Sub Comm1_Click()If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Or Trim(Text1(2).Text) = "" Or _ Trim(Text1(3).Text) = "" ThenMsgBox "数据项不全,请重新设立", vbOKOnly, "信息提示"Text1(0).SetFocusExit SubEnd IfIf flag = 1 Then '添加操作If edlev.Adodc1.Recordset.RecordCount > 0 Then '原记录个数大于0cond = "级别='" + Trim(Text1(0).Text) + "'"edlev.Adodc1.Recordset.MoveFirst '每次从头开始查找edlev.Adodc1.Recordset.Find (cond)If Not edlev.Adodc1.Recordset.EOF() ThenMsgBox "存在完全相似旳记录", vbOKOnly, "信息提示"Text1(0).SetFocusExit SubEnd IfEnd Ifedlev.Adodc1.Recordset.AddNewedlev.Adodc1.Recordset.Fields("级别") = Trim(Text1(0).Text)edlev.Adodc1.Recordset.Fields("过期罚款") = Val(Trim(Text1(1).Text))edlev.Adodc1.Recordset.Fields("借书总数") = Val(Trim(Text1(2).Text))edlev.Adodc1.Recordset.Fields("借书天数") = Val(Trim(Text1(3).Text))edlev.Adodc1.Recordset.Updaterecs = recs + 1Else '修改操作n = edlev.Adodc1.Recordset.AbsolutePositioncond = "级别='" + Trim(Text1(0).Text) + "'"edlev.Adodc1.Recordset.MoveFirst '每次从头开始查找edlev.Adodc1.Recordset.Find (cond)If Not edlev.Adodc1.Recordset.EOF() And edlev.Adodc1.Recordset.AbsolutePosition <> n ThenMsgBox "存在完全相似旳记录", vbOKOnly, "信息提示"edlev.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置edlev.Adodc1.Recordset.Move (n - 1)Text1(0).SetFocusExit SubEnd Ifedlev.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置edlev.Adodc1.Recordset.Move (n - 1)edlev.Adodc1.Recordset.Fields("级别") = Trim(Text1(0).Text)edlev.Adodc1.Recordset.Fields("过期罚款") = Val(Trim(Text1(1).Text))edlev.Adodc1.Recordset.Fields("借书总数") = Val(Trim(Text1(2).Text))edlev.Adodc1.Recordset.Fields("借书天数") = Val(Trim(Text1(3).Text))edlev.Adodc1.Recordset.UpdateEnd IfUnload MeEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubEdreader:Private Sub DataGrid1_Click()End SubPrivate Sub Form_Load()recs = Adodc1.Recordset.RecordCountEnd SubPrivate Sub Form_Activate()DataGrid1.SetFocusCall encommEnd SubPrivate Sub Comm1_Click()flag = 1edreader1.Show vbModalEnd SubPrivate Sub Comm2_Click()flag = 2edreader1.Show vbModalEnd SubPrivate Sub Comm3_Click()If MsgBox("真旳要删除[" + Trim(Adodc1.Recordset.Fields("姓名")) + "]吗?", vbYesNo, "信息提示") = vbYes ThenAdodc1.Recordset.Deleterecs = recs - 1Call encommEnd IfEnd SubPrivate Sub Comm4_Click()Unload MeEnd SubPrivate Sub selcmd1_Click() '设立条件拟定Dim str As Stringstr = "" '条件体现式If Trim(Text1(0).Text) <> "" ThenIf str = "" Thenstr = "借书证号='" + Trim(Text1(0).Text) + "'"Elsestr = str + " and 借书证号='" + Trim(Text1(0).Text) + "'"End IfEnd IfIf Trim(Text1(1).Text) <> "" ThenIf str = "" Thenstr = "姓名='" + Trim(Text1(1).Text) + "'"Elsestr = str + " and 姓名='" + Trim(Text1(1).Text) + "'"End IfEnd IfIf Trim(Text1(2).Text) <> "" ThenIf str = "" Thenstr = "单位='" + Trim(Text1(2).Text) + "'"Elsestr = str + " and 单位='" + Trim(Text1(2).Text) + "'"End IfEnd IfIf Trim(Text1(3).Text) <> "" ThenIf str = "" Thenstr = "级别='" + Trim(Text1(3).Text) + "'"Elsestr = str + " and 级别='" + Trim(Text1(3).Text) + "'"End IfEnd IfIf Trim(Text1(4).Text) <> "" ThenIf str = "" Thenstr = "性别='" + Trim(Text1(4).Text) + "'"Elsestr = str + " and 性别='" + Trim(Text1(4).Text) + "'"End IfEnd IfIf str <> "" ThenAdodc1.RecordSource = "select * from reader where " + strAdodc1.RefreshElseAdodc1.RecordSource = "select * from reader"Adodc1.RefreshEnd Ifrecs = Adodc1.Recordset.RecordCountIf recs = 0 ThenMsgBox "没有任何满足条件旳记录", vbOKOnly, "信息提示" End IfCall encommEnd SubPrivate Sub selcmd2_Click() '设立条件重置Text1(0).Text = ""Text1(1).Text = ""Text1(2).Text = ""Text1(3).Text = ""Text1(4).Text = ""End SubPrivate Sub encomm() '自定义子过程:判断Adodc1中与否存在记录If recs = 0 ThenComm2.Enabled = FalseComm3.Enabled = FalseElseComm2.Enabled = TrueComm3.Enabled = TrueEnd IfEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) Call endata(KeyAscii)End SubEdreader1:Dim rs As ADODB.RecordsetPrivate Sub Form_Load()If flag = 2 Then '修改操作Text1(0).Text = edreader.Adodc1.Recordset.Fields("借书证号") & ""Text1(1).Text = edreader.Adodc1.Recordset.Fields("姓名") & ""If edreader.Adodc1.Recordset.Fields("性别") = "男" Thenopt1.Value = TrueElseopt2.Value = TrueEnd IfDataCombo2.Text = edreader.Adodc1.Recordset.Fields("单位") & ""DataCombo1.Text = edreader.Adodc1.Recordset.Fields("级别") & ""Text1(2).Text = edreader.Adodc1.Recordset.Fields("过期罚款") & ""Text1(3).Text = edreader.Adodc1.Recordset.Fields("借书总数") & ""Text1(4).Text = edreader.Adodc1.Recordset.Fields("借书天数") & ""Text1(5).Text = edreader.Adodc1.Recordset.Fields("登记日期") & ""Text1(0).Enabled = FalseElse '添加操作Text1(5).Text = DateEnd IfEnd SubPrivate Sub Form_Activate()Adodc1.Refresh '数据源刷新Adodc2.Refresh '数据源刷新DataCombo1.RefreshDataCombo2.RefreshEnd SubPrivate Sub Comm1_Click()If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Or Trim(Text1(5).Text) = "" Or Trim(DataCombo1.Text) = "" ThenMsgBox "加*数据项不能为空,请重新设立", vbOKOnly, "信息提示"Exit SubEnd IfIf flag = 1 Then '添加操作sqltxt = "select * from reader where 借书证号='" + Trim(Text1(0).Text) + "'" '对reader中记录进行判断Set rs = exesql(sqltxt)If rs.RecordCount <> 0 ThenMsgBox "存在相似旳借书证号", vbOKOnly, "信息提示"Text1(0).SetFocusrs.CloseExit SubElsers.CloseEnd Ifedreader.Adodc1.Recordset.AddNewedreader.Adodc1.Recordset.Fields("借书证号") = Trim(Text1(0).Text)edreader.Adodc1.Recordset.Fields("姓名") = Trim(Text1(1).Text)If opt1.Value = True Thenedreader.Adodc1.Recordset.Fields("性别") = "男"Elseedreader.Adodc1.Recordset.Fields("性别") = "女"End Ifedreader.Adodc1.Recordset.Fields("单位") = Trim(DataCombo2.Text)edreader.Adodc1.Recordset.Fields("级别") = Trim(DataCombo1.Text)edreader.Adodc1.Recordset.Fields("过期罚款") = Trim(Text1(2).Text)edreader.Adodc1.Recordset.Fields("借书总数") = Val(Trim(Text1(3).Text))edreader.Adodc1.Recordset.Fields("借书天数") = Val(Trim(Text1(4).Text))edreader.Adodc1.Recordset.Fields("已借书数") = 0edreader.Adodc1.Recordset.Fields("登记日期") = Format(Trim(Text1(5).Text), "yyyy-mm-dd")edreader.Adodc1.Recordset.Updaterecs = recs + 1Else '修改操作edreader.Adodc1.Recordset.Fields("借书证号") = Trim(Text1(0).Text)edreader.Adodc1.Recordset.Fields("姓名") = Trim(Text1(1).Text)If opt1.Value = True Thenedreader.Adodc1.Recordset.Fields("性别") = "男"Elseedreader.Adodc1.Recordset.Fields("性别") = "女"End Ifedreader.Adodc1.Recordset.Fields("单位") = Trim(DataCombo2.Text)edreader.Adodc1.Recordset.Fields("级别") = Trim(DataCombo1.Text)edreader.Adodc1.Recordset.Fields("过期罚款") = Trim(Text1(2).Text)edreader.Adodc1.Recordset.Fields("借书总数") = Val(Trim(Text1(3).Text))edreader.Adodc1.Recordset.Fields("借书天数") = Val(Trim(Text1(4).Text))edreader.Adodc1.Recordset.Fields("登记日期") = Format(Trim(Text1(5).Text), "yyyy-mm-dd")edreader.Adodc1.Recordset.Updateedreader.Adodc1.Recordset.UpdateEnd IfUnload MeEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubPrivate Sub selcom1_Click()edlev.Show vbModalEnd SubPrivate Sub selcom2_Click()tna = "depart"cap = "单位"edrec.Show vbModalEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)Call endata(KeyAscii)End SubPrivate Sub DataCombo1_LostFocus()If Adodc1.Recordset.RecordCount > 0 ThenIf Trim(DataCombo1.Text) <> "" ThenAdodc1.Recordset.MoveFirstAdodc1.Recordset.Find ("级别='" & Trim(DataCombo1.Text) & "'")Text1(2).Text = Adodc1.Recordset.Fields("过期罚款")Text1(3).Text = Adodc1.Recordset.Fields("借书总数")Text1(4).Text = Adodc1.Recordset.Fields("借书天数")End IfElseMsgBox "没有任何级别项可选,请设立", vbOKOnly, "信息提示" End IfEnd SubPrivate Sub DataCombo1_KeyPress(KeyAscii As Integer)Call endata(KeyAscii)End SubPrivate Sub DataCombo2_KeyPress(KeyAscii As Integer)endata (KeyAscii)End SubDim msg As StringPrivate Sub Form_Load()Adodc1.RecordSource = "select * from " + tnaAdodc1.Refreshrecs = Adodc1.Recordset.RecordCountDataGrid1.Columns(0).Caption = capDataGrid1.Columns(0).DataField = "fn"End SubPrivate Sub Form_Activate()Call encommEnd SubPrivate Sub Comm1_Click()flag = 1edrec1.Show vbModalEnd SubPrivate Sub Comm2_Click()flag = 2edrec1.Show vbModalEnd SubPrivate Sub Comm3_Click()If MsgBox("真旳要删除[" + Trim(Adodc1.Recordset.Fields("fn")) + "]吗?", vbYesNo, "信息提示") = vbYes ThenAdodc1.Recordset.Deleterecs = recs - 1Call encommEnd IfEnd SubPrivate Sub Comm4_Click()Adodc1.Recordset.UpdateBatchAdodc1.Recordset.CloseUnload MeEnd SubPrivate Sub encomm()If recs = 0 ThenComm2.Enabled = FalseComm3.Enabled = FalseElseComm2.Enabled = TrueComm3.Enabled = TrueEnd IfEnd SubDim cond As StringPrivate Sub Form_Load()Label1.Caption = capIf flag = 1 ThenText1.Text = ""ElseText1.Text = edrec.Adodc1.Recordset.Fields("fn")End IfEnd SubPrivate Sub Comm1_Click()If Trim(Text1.Text) = "" ThenMsgBox "数据项不能为空,请重新设立", vbOKOnly, "信息提示"Text1.SetFocusExit SubEnd IfIf flag = 1 Then '添加操作If edrec.Adodc1.Recordset.RecordCount > 0 Then '原记录个数大于0cond = "fn='" + Trim(Text1.Text) + "'"edrec.Adodc1.Recordset.MoveFirst '每次从头开始查找edrec.Adodc1.Recordset.Find (cond)If Not edrec.Adodc1.Recordset.EOF() ThenMsgBox "存在完全相似旳记录", vbOKOnly, "信息提示"Text1.SetFocusExit SubEnd IfEnd Ifedrec.Adodc1.Recordset.AddNewedrec.Adodc1.Recordset.Fields("fn") = Trim(Text1.Text)edrec.Adodc1.Recordset.Updaterecs = recs + 1Else '修改操作n = edrec.Adodc1.Recordset.AbsolutePositioncond = "fn='" + Trim(Text1.Text) + "'"edrec.Adodc1.Recordset.MoveFirst '每次从头开始查找edrec.Adodc1.Recordset.Find (cond)If Not edrec.Adodc1.Recordset.EOF() And edrec.Adodc1.Recordset.AbsolutePosition <> n ThenMsgBox "存在完全相似旳记录", vbOKOnly, "信息提示"edrec.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置edrec.Adodc1.Recordset.Move (n - 1)Text1.SetFocusExit SubEnd Ifedrec.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置edrec.Adodc1.Recordset.Move (n - 1)edrec.Adodc1.Recordset.Fields("fn") = Trim(Text1.Text)edrec.Adodc1.Recordset.UpdateEnd IfUnload MeEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubMenu:Private Sub MDIForm_Load()If Not userlevel = "系统管理员" Thenmenu21.Enabled = Falsemenu31.Enabled = Falsemenu41.Enabled = Falsemenu42.Enabled = FalseEnd IfEnd SubPrivate Sub menu11_Click()borbook.Show vbModalEnd SubPrivate Sub menu12_Click()retbook.Show vbModalEnd SubPrivate Sub menu13_Click()EndEnd SubPrivate Sub menu21_Click()edbook.Show vbModalEnd SubPrivate Sub menu22_Click()qubook.Show vbModalEnd SubPrivate Sub menu31_Click()edreader.Show vbModalEnd SubPrivate Sub menu32_Click()qureader.Show vbModalEnd SubPrivate Sub menu41_Click()setuser.Show vbModalEnd SubPrivate Sub menu42_Click()If MsgBox("本功能要清除系统中所有数据,真旳初始化吗?", vbYesNo, "确认初始化操作")= vbYes ThenCall deldata("book")Call deldata("reader")Call deldata("borrow")Call deldata("rlevel")Call deldata("depart")Call deldata("press")Call deldata("oper")MsgBox "系统初始化完毕,下次只能以1234/1234(顾客名/口令)进入本系统", vbOKOnly, "信息提示"End IfEnd SubPass:Public n As IntegerPrivate Sub Command1_Click()Dim mrc As ADODB.Recordsettxtsql = "select * from oper where 顾客名='" & _Trim$(Text1(0).Text) & "'" & " And 口令= '" & Trim$(Text1(1).Text) + "'"Set mrc = exesql(txtsql)If mrc.RecordCount = 0 Then '未找到顾客记录n = n + 1If n < 3 ThenMsgBox "没有这个顾客,继续登录", vbOKOnly + vbExclamation, "信息提示"Text1(0).Text = ""Text1(1).Text = ""Text1(0).SetFocusElseMsgBox "已登录失败三次,退出系统", vbOKOnly + vbExclamation, "信息提示"mrc.CloseUnload MeEnd IfElse '找到合法顾客记录userlevel = Trim(mrc.Fields("级别"))mrc.CloseUnload Memenu.Show '调用menu窗体End IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()n = 0 'n保存登录旳次数End SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)Call endata(KeyAscii)End SubQubook:Private Sub Comm1_Click()Dim sqltxt As StringIf Adodc1.Recordset.Fields("借否") = "借" Thenno = Trim(Adodc1.Recordset.Fields("图书编号"))sqltxt = "select * from borrow where 图书编号='" + no + "'"Set rs = exesql(sqltxt)If rs.RecordCount = 0 ThenMsgBox "该图书没有借书记录", vbOKOnly, "信息提示"ElseMsgBox "图书编号:" + no + Chr(10) + Chr(13) + _"书名:" + Trim(rs.Fields("书名")) + Chr(10) + Chr(13) + _"借书人:" + Trim(rs.Fields("姓名")) + Chr(10) + Chr(13) + _"单位:" + Trim(rs.Fields("单位")) + Chr(10) + Chr(13) + _"借书日期:" + Format(rs.Fields("借书日期"), "yyyy.mm.dd"), vbOKOnly, "查找成果"End Ifrs.CloseElseMsgBox "该书没有外借,不能显示借书人", vbOKOnly, "信息提示"End IfEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubPrivate Sub Form_Activate()Adodc1.RefreshDataGrid1.RefreshDataGrid1.SetFocusCall encommEnd SubPrivate Sub selcmd1_Click() '设立条件拟定Dim str As Stringstr = "" '条件体现式If Trim(Text1(0).Text) <> "" ThenIf str = "" Thenstr = "图书编号='" + Trim(Text1(0).Text) + "'"Elsestr = str + " and 图书编号='" + Trim(Text1(0).Text) + "'"End IfEnd IfIf Trim(Text1(1).Text) <> "" ThenIf str = "" Thenstr = "书名='" + Trim(Text1(1).Text) + "'"Elsestr = str + " and 书名='" + Trim(Text1(1).Text) + "'"End IfEnd IfIf Trim(Text1(2).Text) <> "" ThenIf str = "" Thenstr = "作者='" + Trim(Text1(2).Text) + "'"Elsestr = str + " and 作者='" + Trim(Text1(2).Text) + "'"End IfEnd IfIf Trim(Text1(3).Text) <> "" ThenIf str = "" Thenstr = "出版社='" + Trim(Text1(3).Text) + "'"Elsestr = str + " and 出版社='" + Trim(Text1(3).Text) + "'"End IfEnd IfIf Trim(Text1(4).Text) <> "" ThenIf str = "" Thenstr = "借否='" + Trim(Text1(4).Text) + "'"Elsestr = str + " and 借否='" + Trim(Text1(4).Text) + "'"End IfEnd IfIf Trim(Text1(5).Text) <> "" ThenIf str = "" Thenstr = "定价=" + Trim(Text1(5).Text)Elsestr = str + " and 定价=" + Trim(Text1(5).Text)End IfEnd IfIf str <> "" ThenAdodc1.RecordSource = "select * from book where " + strAdodc1.RefreshElseAdodc1.RecordSource = "select * from book"Adodc1.RefreshEnd IfIf Adodc1.Recordset.RecordCount = 0 ThenMsgBox "没有任何满足条件旳记录", vbOKOnly, "信息提示"。

原创c语言图书馆管理系统源代码

原创c语言图书馆管理系统源代码

原创C语言图书馆管理系统源代码介绍图书馆作为一个重要的知识储备和学习场所,必须进行有效的管理和组织。

使用C语言编写的图书馆管理系统可以帮助图书馆实现自动化的借阅、归还和管理功能。

本文将介绍一个原创的C语言图书馆管理系统的源代码。

功能概述这个图书馆管理系统具有以下核心功能: - 图书管理:包括添加图书、删除图书、查询图书等操作。

- 借阅管理:可以进行借阅操作,记录借阅者和借阅时间。

- 归还管理:可以进行归还操作,并更新图书的可借状态。

- 用户管理:管理借阅者的信息,包括添加用户、删除用户、查询用户等操作。

数据结构设计该图书馆管理系统使用了以下几种数据结构: 1. 图书(Book)结构体:包含图书的ID、书名、作者、可借状态等字段。

2. 用户(User)结构体:包含用户的ID、姓名、地址等字段。

3. 借阅记录(BorrowRecord)结构体:包含借阅者ID、图书ID、借阅时间等字段。

系统流程整个系统的流程可以分为以下几个步骤: 1. 用户打开系统,进入主菜单。

2. 用户选择不同的功能选项(如图书管理、借阅管理、用户管理等)。

3. 根据用户选择的功能,进入相应的功能界面。

4. 用户可以根据提示,输入相应的信息进行图书管理、借阅管理或用户管理操作。

5. 用户完成操作后,可以选择返回主菜单或退出系统。

代码实现以下是一个简化版的C语言图书馆管理系统的源代码:```c #include <stdio.h>// 定义结构体 struct Book { int id; char name[50]; char author[50]; int isAvailable; };struct User { int id; char name[50]; char address[100]; };struct BorrowRecord { int userId; int bookId; char borrowDate[20]; };// 函数声明 void addBook(); void deleteBook(); void searchBook(); void borrowBook(); void returnBook(); void addUser(); void deleteUser(); void searchUser();int main() { int choice;do {// 显示主菜单printf(\。

图书管理系统毕业设计源代码

图书管理系统毕业设计源代码

图书管理系统毕业设计源代码1. 简介图书管理系统是一个用于管理图书馆藏书及借阅情况的软件系统。

本文档将详细介绍图书管理系统的毕业设计源代码。

2. 源代码结构图书管理系统的源代码采用模块化的设计,分为以下几个模块: - 用户管理模块:负责管理员和读者的管理,包括用户注册、登录、修改密码等功能。

- 图书管理模块:负责图书的录入、删除、查找等功能。

- 借阅管理模块:负责借阅记录的管理,包括借书、还书、查看借阅历史等功能。

- 统计分析模块:负责统计图书馆的借阅情况、读者喜好等信息。

- 权限管理模块:负责管理不同角色的权限,例如管理员有更高的权限。

3. 技术选型•后端开发语言:采用Java语言进行开发,利用Java的面向对象和多线程的特性来实现系统的各个功能模块。

•前端开发:采用HTML、CSS和JavaScript进行前端开发,使用Bootstrap框架来实现页面的美化和响应式布局。

•数据库:采用MySQL关系数据库管理系统,存储图书馆的图书信息、用户信息及借阅记录等数据。

4. 代码实现细节4.1 用户管理模块用户管理模块的主要功能包括用户注册、登录、修改密码等。

- 用户注册:用户可以填写注册表单,并将信息提交到服务器进行注册。

服务器会将用户的信息存储到数据库中,并为用户分配一个唯一的ID。

- 用户登录:用户在登录页面输入用户名和密码,服务器会校验用户的登录信息,并根据用户的角色跳转到相应的首页。

- 修改密码:用户可以在个人信息页面修改密码,需要输入原密码和新密码。

4.2 图书管理模块图书管理模块的主要功能包括图书的录入、删除、查找等。

- 图书录入:管理员可以在后台管理页面输入图书的信息,包括书名、作者、出版社、ISBN等,并提交保存到数据库中。

- 图书删除:管理员可以根据图书的ID或其他关键字进行图书的删除操作,同时删除数据库中的对应记录。

- 图书查找:管理员和读者可以根据图书的关键字进行查找,系统会显示匹配的图书列表。

图书信息管理系统设计源代码

图书信息管理系统设计源代码

头函数名:#include<stdio.h>#include<stdlib.h>#include<string.h>/*********图书信息结构体*********//***包括登录号,书名,作者名,分类号,出版单位,出版时间,价格等***/ struct bookinf{ int num; ******************************************************登录号char bname[20];***************************************书名char wname[10];***************************************作者名char clanum[14];***************************************分类号char pubcom[10];***************************************出版单位char pubtime[10];***************************************出版时间float price;*********************************************价格};一管理员登录系统模块:(1)来到图书信息管理系统页面void index(){char input; 注释:运行时printf("\n\n\t\t\t*****************************\n"); 直接进入printf("\t\t\t 图书信息管理系统\n"); 这个页面printf("\t\t\t*****************************\n\n\n");printf(" ------------------------------------------------------------------------------\n");printf("\t<按任意键进入>\n\t");input=getchar();}(2)管理员登陆进入功能菜单页面FILE *fp;struct manage pswd;if ((fp=fopen("password.txt","r"))==NULL) {printf("\n\n\n\tCannot open file!\n\t");}else{do{printf("\n\n\t请输入管理员帐号:");scanf("%s",name);printf("\n\n\t请输入管理员密码:");scanf("%s",password);fp=fopen("password.txt","r");fread(&pswd,sizeof(struct manage),1,fp);fclose(fp);w=strcmp(pswd.manage_name,name);k=strcmp(pswd.password,password);adm_servelist();}while (w!=0||k!=0);adm_servelist();}}(3)来到功能菜单页面{void book_add();void book_view();void change();void del();void book_search();void login();void pwchange();int in; 注释:菜单列出的服务种类char input; 从1,2,3,4,5,6 do 所对应的功能进行选择{printf("\n\n\n\t--欢迎使用信息管理系统--");printf("\n\n\t1.图书信息录入\n");printf("\t2.图书信息浏览\n");printf("\t3.图书信息查询\n");printf("\t4.图书信息删除\n");printf("\t5.图书信息修改\n");printf("\t6.退出管理模式\n");printf("\n\t请选择服务种类:");scanf("%d",&in);if (in!=1&&in!=2&&in!=3&&in!=4&&in!=5&&in!=6){printf("\n\t没有这项服务~\n");printf("\t按任意键重新选择");input=getchar();}}while (in!=1&&in!=2&&in!=3&&in!=4&&in!=5&&in!=6);switch (in){case 1: book_add(); break; 注释:选择自己所需要case 2: book_view(); break; 后摁下数字键则case 3: book_search(); break; 则进入此功能页面case 4: del(); break;case 5: change();break;case 6: login(); break;}}(3)图书信息录入功能模块void book_add(){void book_add();int i=0,j;FILE *fp;char input; 注释:输入的图书信息struct bookinf books; 是通过文件进行struct bookinf book_taxis[30]; 保存的printf("\n\n\n\t---请输入图书信息---\n\n");printf("\t登录号:");scanf("%d",&books.num);printf("\n\t书名:");scanf("%s",books.bname);printf("\n\t作者名:");scanf("%s",books.wname);printf("\n\t分类号:");scanf("%s",books.clanum);printf("\n\t出版单位:");scanf("%s",books.pubcom);printf("\n\t出版时间:");scanf("%s",books.pubtime);printf("\n\t价格:");scanf("%f",&books.price);if ((fp=fopen("book.txt","r"))!=NULL){do{fread(&book_taxis[i],sizeof(struct bookinf),1,fp);i=i+1;}while(!feof(fp));fclose(fp);for (j=0;j<=i;j++)if (books.num==book_taxis[j].num){printf("\n\n\n\t对不起,这个编号已经使用过了~\n");printf("\t按任意键返回管理菜单~");input=getchar();adm_servelist();break;}}if ((fp=fopen("book.txt","r"))==NULL){fp=fopen("book.txt","w");}else{fclose(fp);fp=fopen("book.txt","a");}fwrite(&books,sizeof(struct bookinf),1,fp);fclose(fp);printf("\n\n\n\t信息输入完毕~按任意键继续\n");input=getchar();adm_servelist();}(4)图书信息浏览功能模块void book_view(){void adm_servelist();void book_view();int inp,i=0,n=0;FILE *fp;char input;struct bookinf bookview[20];if ((fp=fopen("book.txt","r"))==NULL){printf("\n\n\n\t数据尚未初始化~~\n\n\t请在管理菜单中增加图书信息~~~\n"); printf("\n\t<按任意键返回管理菜单>\n\t");input=getchar();adm_servelist();}else{do{fread(&bookview[i],sizeof(struct bookinf),1,fp);i=i+1;}while (!feof(fp));fclose(fp);do{printf("\n\t--------共有%d条记录--------",i-1);printf("\n\n\t登录号: %d\n",bookview[n].num);printf("\n\t书名: %s\n",bookview[n].bname);printf("\n\t作者名: %s\n",bookview[n].wname);printf("\n\t分类号: %s\n",bookview[n].clanum);printf("\n\t出版单位: %s\n",bookview[n].pubcom);printf("\n\t出版时间: %s\n",bookview[n].pubtime);printf("\n\t价格: %f\n",bookview[n].price);printf("\n\n\t1.上一页\t2.下一页\t3.回目录\n");printf("\n\t请选择:");scanf("%d",&inp);switch (inp){case 1:{if (n==0){printf("\n\t已到达首页\n\t按任意键重新选择");input=getchar();}else n=n-1; break;}case 2:{if (n==i-2){printf("\n\t已到达最末页\n\t按任意键重新选择");input=getchar();}else n=n+1; break;}case 3:{adm_servelist();break;}default:{printf("\n\t没有这项服务\n\t按任意键重新选择");input=getchar();}}}while (inp!=3);}}(5)图书信息修改与删除功能模块修改:void change(int x){int inp,i=0,j;void book_search();FILE *fp,*fp1;char input;struct bookinf books,book_taxis[20];do{printf("\n\n\n\t注意:您确定要修改该记录吗?\n"); printf("\n\t1.是\t2.否\n");printf("\n\t请输入:");scanf("%d",&inp);if (inp!=1&&inp!=2){printf("\n\t对不起~没有这项服务~\n");printf("\t按任意键重新选择\n\t");input=getchar();}}while (inp!=1&&inp!=2);if (inp==2)book_search();if (inp==1){printf("\n\n\n\t---请输入图书信息---\n\n");printf("\t登录号:");scanf("%d",&books.num);printf("\n\t书名:");scanf("%s",books.bname);printf("\n\t作者名:");scanf("%s",books.wname);printf("\n\t分类号:");scanf("%s",books.clanum);printf("\n\t出版单位:");scanf("%s",books.pubcom);printf("\n\t出版时间:");scanf("%s",books.pubtime);printf("\n\t价格:");scanf("%f",&books.price);if ((fp1=fopen("book.txt","r"))!=NULL){do{fread(&book_taxis[i],sizeof(struct bookinf),1,fp1);i=i+1;}while(!feof(fp1));fclose(fp1);for (j=0;j<x;j++)if (books.num==book_taxis[j].num){printf("\n\n\n\t对不起,这个编号已经使用过了~\n");printf("\t按任意键返回管理菜单~");printf("0");input=getchar();book_search();break;}for (j=x+1;j<i-2;j++)if (books.num==book_taxis[j].num){printf("\n\n\n\t对不起,这个编号已经使用过了~\n");printf("1");printf("\t按任意键返回管理菜单~");input=getchar();book_search();break;}}book_taxis[x]=books;fp=fopen("book.txt","w");for (j=0;j<i-1;j++)fwrite(&book_taxis[j],sizeof(struct bookinf),1,fp);fclose(fp);printf("\n\n\t信息修改完成!按任意键返回");input=getchar();book_search();}}S删除:void del(int y){char input;FILE *fp;int inp,i=0,j;struct bookinf book_taxis[20];void book_search();void adm_servelist();do{printf("\n\n\n\t注意:您确定要删除该记录吗?\n"); printf("\n\t1.是\t2.否\n");printf("\n\t请输入:");scanf("%d",&inp);if (inp!=1&&inp!=2){printf("\n\t对不起~没有这项服务~\n");printf("\t按任意键重新选择\n\t");input=getchar();}}while (inp!=1&&inp!=2);if (inp==2)book_search();if (inp==1){if ((fp=fopen("book.txt","r"))!=NULL){do{fread(&book_taxis[i],sizeof(struct bookinf),1,fp);i=i+1;}while(!feof(fp));fclose(fp);}if (i>2){fp=fopen("book.txt","w");for (j=0;j<y;j++)fwrite(&book_taxis[j],sizeof(struct bookinf),1,fp);fclose(fp);fp=fopen("book.txt","a");for (j=y+1;j<i-1;j++)fwrite(&book_taxis[j],sizeof(struct bookinf),1,fp);fclose(fp);}else{remove("book.txt");}printf("\n\n\t记录已删除!\n\n\t按任意键返回\n\t");input=getchar();adm_servelist();}}(6)图书信息查询功能模块void book_search(){void adm_servelist();void id_search();void wr_search();void bn_search();char input;FILE *fp;int inp;if ((fp=fopen("book.txt","r"))==NULL){printf("\n\n\n\t数据尚未初始化~~\n\n\t请在管理菜单中增加图书信息~~~\n"); printf("\n\t<按任意键返回管理菜单>\n\t");input=getchar();adm_servelist();}else{do{printf("\n\n\n\t1.按图书登录号查询\n");printf("\n\t2.按图书作者查询\n");printf("\n\t3.按图书名查询\n");printf("\n\t4.回到主菜单\n");printf("\n\n\t请选择查询类别:");scanf("%d",&inp);if (inp!=1&&inp!=2&&inp!=3&&inp!=4){printf("\n\n\t没有这项服务~\n\t按任意键重新选择~");input=getchar();}}while (inp!=1&&inp!=2&&inp!=3&&inp!=4);fclose(fp);switch (inp){case 1: id_search(); break;case 2: wr_search(); break;case 3: bn_search(); break;case 4: adm_servelist(); break;}}}。

c++图书管理系统源代码

c++图书管理系统源代码

C++图书管理系统源代码#include<iostream.h>#inClude<fstream.h>#inClude<iomanip.h>#inClude<string.h>//using namespaCe std; Const int Maxb=10000; // Const int Maxr=100; // 最多的读者Const int Maxbor=5; // 每位读者最多借五本书// ---------------------------------------------Class Book // 图书类{int tag; // 删除标记1: 已删0: 未删int no; // 图书编口. 号Char name[20]; // 书名Char author[10];//作者名Char no2[10]; //输入分类号Char dan[20]; //输入出版单位Char time[20]; //出版时间int priCe; // 价格int onshelf; // 是否在架1: 在架0: 已借publiC:Book(){}int getno(){return no;} // 获取图书编号int gettag(){return tag;} // 获取删除标记最多的图书char *getname(){return name;} // 获取书名char *getauthor(){return author;} // 获取作者名char *getno2(){return no2;} // 获取分类号char *getdan(){return dan;} //获取出版单位char *gettime(){return time;} //获取出版时间int getprice(){return price;} // 获取图书价格void setname(char na[]){strcpy(name,na);} // 设置书名void setauthor(charau[]){strcpy(author,au);} //设置作者名void setno2(char n[]){strcpy(no2,n);} //设置分类号void setdan(char d[]){strcpy(dan,d);} //设置出版单位void settime(char t[]){strcpy(time,t);} //设置出版时间voidsetprice(int p){price=p;}void delbook(){tag=1;} // 删除图书1: 已删0: 未删void addbook(int n,char*na,char*au,char*n2,char*da,char*ti,int pr)//增加图书{ tag=0;no=n;price=pr; strcpy(name,na); strcpy(author,au); strcpy(no2,n2);strcpy(dan,da);strcpy(time,ti);onshelf=1;}int borrowbook() // 借书操作{if(onshelf==1){onshelf=0;return 1;}return 0;}void retbook(){onshelf=1;} // 还书操作void disp() // 输出图书{cout<<setw(10)<<no<<setw(10)<<name<<setw(10)<<setw(10) <<author<<setw(10)<<no2<<setw(10)<<dan<<setw(10)<<time <<setw(10)<<price;if(onshelf==1)cout<<setw(10)<<" 在架";else cout<<setw(10)<<" 已借出"<<endl;}};//class BDatabase // 图书库类{int top; // 图书数量记录指针Book book[Maxb]; // 图书记录public:BDatabase() // 构造函数, 将book.txt 读到book[] 中{Book b;top=-1;fstream file("book.txt",ios::in);while(1){file.read((char*)&b,sizeof(b));if(!file)break;top++;book[top]=b;}file.close();}void clear(){top=-1;} // 全删int addbook(int n,char*na,char*au,char*n2,char*da,char*ti,int pr)//增加图书{Book *p=query(n);// 调用函数if(p==NULL){top++;book[top].addbook(n,na,au,n2,da,ti,pr);return 1;}return 0;}Book *query(int bookid) // 查找图书{for(int i=0;i<=top;i++){if(book[i].getno()==bookid&&book[i].gettag()==0)return &book[i];}return NULL;}Book *query2(int bookid,char *name)// 按书名查找图书{for(int i=0;i<=top;i++){if(strcmp(book[i].getname(),name)==0)bookid=book[i].getno();return &book[i];}}return NULL;}Book *query3(int bookid,char *author) // 按作者查找图书{ for(int i=0;i<=top;i++){ if(strcmp(book[i].getauthor(),author)==0){ bookid=book[i].getno();return &book[i];}}return NULL;}void bookdata(); // 图书库维护void disp() // 输出图书{cout<<setw(10)<<" 图书编号"<<setw(10)<<" 图书名字"<<setw(10)<<" 图书作者"<<setw(10)<<" 图书分类"<<setw(10)<<" 出版单位"<<setw(10)<<" 出版时间"vvsetw(10)vv"价格"<<setw(10)vv"借还信息"<<endl;for(int i=0;i<=top;i++){if(book[i].gettag()==0)book[i].disp();}}~BDatabase() // 析构函数, 将book[] 写入book.txt 文件中{ fstream file("book.txt",ios::out);for(int i=0;i<=top;i++){if(book[i].gettag()==0)file.write((char*)&book[i],sizeof(book[i]));}file.close();}};void BDatabase::bookdata() { int bookid; // 图书编号char bname[40]; // 图书名char bauthor[10]; // 图书作者char bno2[20]; // 图书分类char bdan[20]; // 出版单位char btime[20];//出版时间int bprice; //图书价格Book *b;int choice=1;int choice2=1;int choice3=1;while(choice!=0){cout<<"\t\t\t 图书信息维护\n"; cout<<"\t\t\t1. 添加信息\n"; cout<<"\t\t\t2. 修改信息\n"; cout<<"\t\t\t3. 删除信息\n"; cout<<"\t\t\t4. 信息查询\n"; cout<<"\t\t\t5. 显示信息\n"; cout<<"\t\t\t6. 全部删除\n";cout<<"\t\t\t0. 退出图书信息维护\n"cout<<" 请选择:" Jcin>>choice;switch(choice){case 1:{cout<<" 添加图书操作:\n";cout<<" 请输入图书编号:"; cin>>bookid;cout<<" 请输入书名:";cin>>bname;cout<<" 请输入图书作者:";cin>>bauthor;cout<<" 请输入图书分类:";cin>>bno2;cout<<" 请输入出版单位:";cin>>bdan;cout<<" 请是输入出版时间:"; cin>>btime;cout<<" 请输入图书价格:";cin>>bprice;addbook(bookid,bname,bauthor,bno2,bdan,btime,bprice); cout<<" 图书编号"<<bookid<<" 添加成功\n";break;}case 2:{cout<<" 修改图书信息操作:\n";cout<<" 请输入图书编号:"; cin>>bookid;b=query(bookid);if(b==NULL){cout<<" 图书不存在,无法修改\n";break;}cout<<" 请输入要更改的:1. 书名 2. 作者名 3. 分类 4. 出版单位 5. 出版时间6. 图书价格";cin>>choice2;switch(choice2){case 1:{cout<<" 请输入书名:";cin>>bname;b->setname(bname);cout<<" 修改书名成功\n";break;}case 2:{cout<<" 请输入作者名:";cin>>bauthor;b->setauthor(bauthor);cout<<" 修改作者名成功\n"; break;}case 3:{cout<<" 请输入分类号:";cin>>bno2; b->setno2(bno2);cout<<" 修改分类成功\n"; break;}case 4:{cout<<" 请输入出版单位:"; cin>>bdan; b->setdan(bdan);cout<<" 修改出版单位成功\n"; break; }case 5:{cout<<" 请输入出版时间:"; cin>>btime; b->settime(btime);cout<<" 修改出版时间成功\n"; break;}case 6:{cout<<" 请输入图书价格:"; cin>>bprice;b->setprice(bprice);cout<<" 修改图书价格成功\n"; break;}} break;}case 3:{cout<<" 删除图书操作:\n"; cout<<" 请输入图书编号:"; cin>>bookid; b=query(bookid);if(b==NULL){cout<<" 不存在该图书,无法删除\n";} b->delbook(); cout<<" 删除图书成功\n";break;case 4:{cout<<" 图书信息查询操作:\n";cout<<"1. 按图书编号查询 2. 按图书作者查询 3. 按图书名字查询\n"; cout<<" 请选择查询方式:";cin>>choice3;switch(choice3){case 1:{cout<<" 请输入图书编号:";cin>>bookid;b=query(bookid);if(b==NULL){cout<<" 你要查询的图书不存在\n";break;}b->disp();break;}case 2:{cout<<" 请输入图书作者:";cin>>bauthor;b=query3(bookid,bauthor);if(b==NULL){cout<<" 你要查询的图书不存在\n";break;}b->disp();break;}case 3:{cout<<" 请输入图书名:"; cin>>bname;b=query2(bookid,bname);if(b==NULL){cout<<" 你要查询的图书不存在\n";break;} b->disp(); break;}} break;}case 5:{disp();break;}case 6:{clear();break;} } } }。

图书借阅管理系统代码图书管理系统源代码

图书借阅管理系统代码图书管理系统源代码
{
printf("\n操作成功...\n");
printf("%s %s %.2lf %d %.2lf ",name[i],writter[i],yajin[i],free[i],jiage[i]);
flag[i]=1;
panding=1; //操作成功的提示
printf("已归还\n");
}
}
}
if(panding==0)
for(i=1;i<7;i++) //将原图书的各项值保存
{
free[i]=30;
jiage[i]=0.5;
}
flag[1]=0; //flag为0代表已借出,为1代表未借出
flag[2]=1;
flag[3]=1;
flag[4]=0;
flag[5]=1;
flag[6]=1;
printf("编号\t|书名\t |作者\t|押金\t|免费天数\t|收费价格\t|出租状态\n"); //制表同时输出
if(flag[i]==0)
{
printf("已借出\n"); //通过设置flag来判定是否被借出
}
else
{
printf("未借出\n");
}
}
}
void returnbooks(int score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num])
returnbooks(score,name,writter,yajin,free,jiage,flag);

图书管理系统源码(java实现)

图书管理系统源码(java实现)

【图书管理系统】【MainPro包】1.系统登录页面public class Login extends Frame {private static final long serialVersionUID = -1758475247807861408L;TextField text_user;TextField text_pass;public Login() {1 this.setTitle("登录");this.setLayout(null);//默认流式布局this.setSize(260, 170);/* 定义标签与文本框*/Label lbUser = new Label("用户名:");text_user = new TextField();Label lbPass = new Label("密码:");text_pass = new TextField();Button btn_ok = new Button("确定");Button btn_cancel = new Button("取消");lbUser.setBounds(40, 53, 60, 20);//x,y,width,heightlbPass.setBounds(40, 83, 60, 20);text_user.setBounds(100, 50, 120, 20);text_pass.setBounds(100, 80, 120, 20);btn_ok.setBounds(45, 120, 80, 25); // 确定按钮btn_cancel.setBounds(135, 120, 80, 25); // 取消按钮/* 添加标签与文本框*/add(lbUser);add(lbPass);add(text_user);add(text_pass);add(btn_ok);add(btn_cancel);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置this.setVisible(true); // 使窗体可见btn_ok.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {btn_okActionPerformed(e);//自定义确定按钮触发的实施过程}}));btn_cancel.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}}));this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);} }); }public void btn_okActionPerformed(ActionEvent e) {String user = text_user.getText();String pass = text_pass.getText();String is_admin;// 如果用户名或密码任一为空,则终止后续操作if (user.equals("")||pass.equals("")) {JOptionPane.showMessageDialog(null, "用户名或密码不能为空!");return;}try {// 核对用户名和密码String sql = "select * from user where username=" + "'" + user + "' and password=" + "'" + pass + "'";ResultSet rs = DbOp.executeQuery(sql);// 如果此用户存在,则记录其状态(否:不是管理员,是:是管理员)if (rs.next()) {is_admin = rs.getString("is_admin");} else {JOptionPane.showMessageDialog(null, "用户名或密码不正确!");return;}GlobalVar.login_user = user; // 记录登录的用户名ShowMain show = new ShowMain(); // 调用主程序// 只有管理员才能使用"基础管理"和"借阅管理"菜单show.setRights(is_admin);// 释放窗体及其全部组件的屏幕资源,即使释放登录窗体dispose(); // 释放当前窗体} catch (SQLException e1) {JOptionPane.showMessageDialog(null, "用户数据库有误!");}}}2.系统首页页面public class ShowMain extends Frame {private static final long serialVersionUID = 5003296786441785470L;MenuBar menuBar;Menu jcwh, jcwh_book, jcwh_reader;//基础维护:图书维护、读者维护Menu jywh, cxgl, xtgl;//借阅维护、查询管理、系统管理MenuItemjcwh_book_add,jcwh_book_update,jcwh_book_delete,jcwh_reader_add,jcwh_reader_update,jcwh_reader_delete;MenuItem jywh_borrow, jywh_back;MenuItem cxgl_book, cxgl_reader;MenuItem xtgl_update_pass, xtgl_exit;public void setRights(String rights) {// 如果不是管理员,则禁止用户维护图书信息和读者信息以及禁止进行借阅管理,即只能查询if (rights.equals("否")) {jywh.setEnabled(false);jcwh.setEnabled(false);}}public ShowMain() {setTitle("图书管理系统");setLayout(new BorderLayout());setSize(640, 480);menuBar = new MenuBar();jcwh = new Menu("基础维护");// 基础维护菜单jcwh_book = new Menu("图书维护");// 图书维护菜单jcwh_book_add = new MenuItem("添加");// 添加图书菜单jcwh_book_update = new MenuItem("修改");// 修改图书菜单jcwh_book_delete = new MenuItem("删除");// 删除图书菜单jcwh_reader = new Menu("读者维护");// 读者维护菜单jcwh_reader_add = new MenuItem("添加读者");// 添加读者菜单jcwh_reader_update = new MenuItem("修改读者");jcwh_reader_delete = new MenuItem("删除读者");jywh = new Menu("借阅管理");jywh_borrow = new MenuItem("借书管理");jywh_back = new MenuItem("还书管理");cxgl = new Menu("查询管理");cxgl_book = new MenuItem("图书查询");cxgl_reader = new MenuItem("读者查询");xtgl = new Menu("系统管理");xtgl_update_pass = new MenuItem("修改密码");xtgl_exit = new MenuItem("退出系统");// 添加图书菜单jcwh_book.add(jcwh_book_add);jcwh_book.add(jcwh_book_update);jcwh_book.add(jcwh_book_delete);jcwh.add(jcwh_book);jcwh_reader.add(jcwh_reader_add);jcwh_reader.add(jcwh_reader_update);jcwh_reader.add(jcwh_reader_delete);jcwh.add(jcwh_reader);jywh.add(jywh_borrow);jywh.add(jywh_back);cxgl.add(cxgl_book);cxgl.add(cxgl_reader);xtgl.add(xtgl_update_pass);xtgl.add(xtgl_exit);menuBar.add(jcwh);menuBar.add(jywh);menuBar.add(cxgl);menuBar.add(xtgl);setMenuBar(menuBar);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见jcwh_book_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("save");} });jcwh_book_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("update");} });jcwh_book_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("delete");} });jcwh_reader_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("save");} });jcwh_reader_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("update");} });jcwh_reader_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("delete");} });jywh_borrow.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Borrow();} });jywh_back.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Back();} });cxgl_book.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookQuery();} });cxgl_reader.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderQuery();} });xtgl_update_pass.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new UpdatePassword();} });xtgl_exit.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});}}3.图书管理public class BookManeger extends JFrame {private static final long serialVersionUID = 377287301994613384L;private Label lbbookid_c = new Label("图书编号");private TextField tf_bookid_c = new TextField();private Label lbbookid = new Label("图书编号");private TextField tf_bookid = new TextField();private Label lbbookname = new Label("图书名称");private TextField tf_bookname = new TextField();private Label lbbooktype = new Label("图书类别");private Choice tf_booktype = new Choice();private Label lbauthor = new Label("作者");private TextField tf_author = new TextField();private Label lbtranslator = new Label("译者");private TextField tf_translator = new TextField();private Label lbpublisher = new Label("出版社");private TextField tf_publisher = new TextField();private Label lbpublish_time = new Label("出版时间");private TextField tf_publish_time = new TextField();private Label lbprice = new Label("定价");private TextField tf_price = new TextField();private Label lbstock = new Label("库存数量");private TextField tf_stock = new TextField();private Button queryBtn = new Button("查询");private Button saveBtn = new Button("保存");private Button closeBtn = new Button("关闭");private String optionStr;BookManeger(String str) {optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid);map.put("bookname", tf_bookname);map.put("booktype", tf_booktype);map.put("author", tf_author);map.put("translator", tf_translator);map.put("publisher", tf_publisher);map.put("publish_time", tf_publish_time);map.put("price", tf_price);map.put("stock", tf_stock);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delActionPerformed(e, map);}else{i = Jcwh.btn_saveActionPerformed(e, map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "图书添加成功!";}else if(optionStr.equals("update")){showInfo = "图书修改成功!";}else if(optionStr.equals("delete")){showInfo = "图书删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});/* 关闭窗口*/this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setSize(500, 320);lbbookid.setBounds(50, 40, 50, 20); // 图书编号tf_bookid.setBounds(110, 40, 100, 20);lbbookname.setBounds(240, 40, 50, 20); // 图书名称tf_bookname.setBounds(300, 40, 100, 20);lbbooktype.setBounds(50, 80, 50, 20); // 图书类别tf_booktype.setBounds(110, 80, 100, 20);tf_booktype.add("科技");tf_booktype.add("文学");tf_booktype.add("社科");tf_booktype.add("其他");lbauthor.setBounds(240, 80, 50, 20); // 作者tf_author.setBounds(300, 80, 100, 20);lbtranslator.setBounds(50, 120, 50, 20); // 设置译者tf_translator.setBounds(110, 120, 100, 20);lbpublisher.setBounds(240, 120, 50, 20); // 出版社tf_publisher.setBounds(300, 120, 100, 20);lbpublish_time.setBounds(50, 160, 50, 20); // 出版时间tf_publish_time.setBounds(110, 160, 100, 20);lbprice.setBounds(240, 160, 50, 20); // 定价tf_price.setBounds(300, 160, 100, 20);lbstock.setBounds(50, 200, 50, 20); // 库存数量tf_stock.setBounds(110, 200, 100, 20);saveBtn.setBounds(150, 240, 80, 25); // 保存按钮closeBtn.setBounds(280, 240, 80, 25);// 关闭按钮if(str.equals("save")){setTitle("添加图书");}else if(str.equals("update")){setTitle("修改图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbbookid);add(tf_bookid);add(lbbookname);add(tf_bookname);add(lbbooktype);add(tf_booktype);add(lbauthor);add(tf_author);add(lbtranslator);add(tf_translator);add(lbpublisher);add(tf_publisher);add(lbpublish_time);add(tf_publish_time);add(lbprice);add(tf_price);add(lbstock);add(tf_stock);add(saveBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见}private void clearAllTextfield() {tf_bookid.setText("");tf_bookname.setText("");tf_author.setText("");tf_translator.setText("");tf_publisher.setText("");tf_publish_time.setText("");tf_price.setText("");tf_stock.setText("");}}4.读者管理public class ReaderManeger extends JFrame {private static final long serialVersionUID = -2399939451497711745L;Label lbreaderid_c = new Label("读者编号");TextField tf_readerid_c = new TextField();Label lbreaderid = new Label("读者编号");TextField tf_readerid = new TextField();Label lbreadername = new Label("读者姓名");TextField tf_readername = new TextField();Label lbreadertype = new Label("读者类别");Choice tf_readertype = new Choice();Label lbsex = new Label("性别");Choice tf_sex = new Choice();Label lbmax_num = new Label("可借数量");TextField tf_max_num = new TextField();Label lbdays_num = new Label("可借天数");TextField tf_days_num = new TextField();Button queryBtn = new Button("查询");Button saveBtn = new Button("保存");Button closeBtn = new Button("关闭");private String optionStr;//保存、修改、删除ReaderManeger(String str){optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid);map.put("readername", tf_readername);map.put("readertype", tf_readertype);map.put("sex", tf_sex);map.put("days_num", tf_days_num);map.put("max_num", tf_max_num);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delReaderActionPerformed(e, map);}else{i = Jcwh.btn_saveReaderActionPerformed(e,map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "读者添加成功!";}else if(optionStr.equals("update")){showInfo = "读者修改成功!";}else if(optionStr.equals("delete")){showInfo = "读者删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setTitle("添加读者信息");setSize(500, 230);lbreaderid.setBounds(50, 50, 50, 20);tf_readerid.setBounds(110, 50, 100, 20);lbreadername.setBounds(240, 50, 50, 20);tf_readername.setBounds(300, 50, 100, 20);lbreadertype.setBounds(50, 80, 50, 20);tf_readertype.setBounds(110, 80, 100, 20);tf_readertype.add("教师");tf_readertype.add("学生");tf_readertype.add("职工");lbsex.setBounds(240, 80, 50, 20);tf_sex.setBounds(300, 80, 100, 20);tf_sex.add("男");tf_sex.add("女");lbmax_num.setBounds(50, 110, 50, 20);tf_max_num.setBounds(110, 110, 100, 20);lbdays_num.setBounds(240, 110, 50, 20);tf_days_num.setBounds(300, 110, 100, 20);saveBtn.setBounds(150, 150, 80, 25);closeBtn.setBounds(280, 150, 80, 25);if(str.equals("save")){setTitle("添加读者");}else if(str.equals("update")){setTitle("修改读者");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbreaderid);add(lbreadername);add(lbreadertype);add(lbsex);add(lbmax_num);add(lbdays_num);add(tf_readerid);add(tf_readername);add(tf_max_num);add(tf_days_num);add(tf_readertype);add(tf_sex);add(saveBtn);add(closeBtn);setLocationRelativeTo(null);setVisible(true);}private void clearAllTextfield() {tf_readerid.setText("");tf_readername.setText("");tf_max_num.setText("");tf_days_num.setText("");}public static void main(String[] args) {ReaderManeger r = new ReaderManeger("update");}}5.借书public class Borrow extends Frame {private static final long serialVersionUID = -1036076990599464079L;String SepLine = "-------------------------------------------------";Label lbbookid = new Label("图书编号");Label lbreaderid = new Label("读者编号");TextField tf_bookid = new TextField();TextField tf_readerid = new TextField();Button queryBtn = new Button("查询");Label lbbookinfo = new Label(SepLine + "图书信息" + SepLine); Label lbbookname = new Label("图书名称:");Label tf_bookname = new Label("xx");Label lbauthor = new Label("作者:");Label tf_author = new Label("xx");Label lbpublisher = new Label("出版社:");Label tf_publisher = new Label("xx");Label lbpublish_time = new Label("出版时间:");Label tf_publish_time = new Label("xx");Label lbprice = new Label("定价:");Label tf_price = new Label("xx");Label lbstock = new Label("库存数量:");Label tf_stock = new Label("xx");Label lbreaderinfo = new Label(SepLine + "读者信息" + SepLine); Label lbreadername = new Label("读者姓名:");Label tf_readername = new Label("xx");Label lbreadertype = new Label("读者类型:");Label tf_readertype = new Label("xx");Label lbmax_num = new Label("最大可借数:");Label tf_max_num = new Label("xx");Label lbdays_num = new Label("最大可借天数:");Label tf_days_num = new Label("xx");Label lbborrowinfo = new Label(SepLine + "借阅信息" + SepLine); Label lbborrowednum = new Label("该读者已借图书数量:"); Label tf_borrowednum = new Label("xx");Label lbif_borrow = new Label("该读者是否可借所选图书:"); Label tf_if_borrow = new Label("xx");Label lbborrow_date = new Label("借阅日期:");Label tf_borrow_date = new Label("xx");Button borrowBtn = new Button("借出");Button closeBtn = new Button("关闭");public Borrow() {setLayout(null);setTitle("借阅图书");setSize(500, 420);this.setForeground(Color.BLACK); // 设置前景色为黑色lbbookid.setBounds(30, 40, 50, 25); // 图书编号tf_bookid.setBounds(90, 40, 90, 20);lbreaderid.setBounds(200, 40, 50, 25); // 读者编号tf_readerid.setBounds(260, 40, 90, 20);queryBtn.setBounds(370, 40, 80, 25); // 查询按钮lbbookinfo.setBounds(30, 70, 440, 25); // 图书信息提示条lbbookname.setBounds(30, 100, 60, 25); // 图书名称tf_bookname.setBounds(90, 100, 200, 25);lbauthor.setBounds(310, 100, 60, 25); // 作者tf_author.setBounds(370, 100, 90, 25);lbpublisher.setBounds(30, 125, 60, 25); // 出版社tf_publisher.setBounds(90, 125, 200, 25);lbpublish_time.setBounds(310, 125, 60, 25); // 出版时间tf_publish_time.setBounds(370, 125, 90, 25);lbprice.setBounds(30, 150, 60, 25); // 定价tf_price.setBounds(90, 150, 200, 25);lbstock.setBounds(310, 150, 60, 25); // 库存数量tf_stock.setBounds(370, 150, 90, 25);lbreaderinfo.setBounds(30, 180, 440, 25); // 读者信息提示条lbreadername.setBounds(30, 205, 60, 25); // 读者姓名tf_readername.setBounds(90, 205, 90, 25);lbreadertype.setBounds(310, 205, 60, 25); // 读者类型tf_readertype.setBounds(370, 205, 90, 25);lbmax_num.setBounds(30, 230, 75, 25); // 最大可借数tf_max_num.setBounds(105, 230, 90, 25);lbdays_num.setBounds(310, 230, 85, 25); // 最大可借天数tf_days_num.setBounds(395, 230, 70, 25);lbborrowinfo.setBounds(30, 260, 440, 25); // 借阅信息提示条lbborrowednum.setBounds(30, 285, 120, 25);// 已借图书数量tf_borrowednum.setBounds(150, 285, 50, 25);lbif_borrow.setBounds(30, 310, 145, 25); // 是否可借tf_if_borrow.setBounds(175, 310, 50, 25);lbborrow_date.setBounds(30, 335, 60, 25);// 借书日期tf_borrow_date.setBounds(90, 335, 100, 25);borrowBtn.setBounds(160, 365, 80, 25);// 借出按钮borrowBtn.setEnabled(false); // 开始时禁用借出按钮closeBtn.setBounds(260, 365, 80, 25);// 关闭按钮queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_querywActionPerformed(e); } }); borrowBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_borrowActionPerformed(e); } });closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { setForeground(Color.BLACK); dispose(); } }); this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {setForeground(Color.BLACK); // 设置前景色为黑色dispose(); // 关闭窗体}});add(lbbookid);add(lbreaderid);add(queryBtn);add(lbbookinfo);add(lbbookname);add(lbauthor);add(lbpublisher);add(lbpublish_time);add(lbprice);add(lbstock);add(lbreaderinfo);add(lbreadername);add(lbreadertype);add(lbmax_num);add(lbdays_num);add(lbborrowinfo);add(lbborrowednum);add(lbif_borrow);add(lbborrow_date);add(borrowBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见setForeground(Color.RED); // 设置前景色为红色add(tf_bookid);add(tf_readerid);add(tf_bookname);add(tf_author);add(tf_publisher);add(tf_publish_time);add(tf_price);add(tf_stock);add(tf_readername);add(tf_readertype);add(tf_max_num);add(tf_days_num);add(tf_borrowednum);add(tf_if_borrow);add(tf_borrow_date);}// 图书和读者查询private void btn_querywActionPerformed(ActionEvent e) {String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();// 如果图书编号或读者编号两者均为空,或者有一个为空,则返回if (bookid.equals("") || readerid.equals("")) {JOptionPane.showMessageDialog(null, "图书编号和读者编号均不能为空!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询图书,结果存入book对象中Book book = BookSelect.SelectBookById(bookid);if (book != null) { // 如果查询到结果,将其显示在各文本框中tf_bookname.setText(book.getBookname());tf_author.setText(book.getAuthor());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf((book.getPrice())));tf_stock.setText(String.valueOf(book.getStock()));} else {JOptionPane.showMessageDialog(null, "图书编号有误,查无此书!");init(); // 重新初始化各参数并禁止借出按钮return;}if (book.getStock() == 0) {JOptionPane.showMessageDialog(null, "图书已无库存,无法借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询读者,结果存入reader对象中Reader reader = ReaderSelect.selectReaderById(readerid);// 如果查询到结果,将其显示在各文本框中if (reader != null) {tf_readername.setText(reader.getReadername());tf_readertype.setText(reader.getReadertype());tf_max_num.setText(String.valueOf(reader.getMax_num()));tf_days_num.setText(String.valueOf(reader.getDays_num()));} else {JOptionPane.showMessageDialog(null, "读者编号有误,查无此人!");init(); // 重新初始化各参数并禁止借出按钮return;}// 查询指定读者是否已借过指定图书且未归还if (IfBorrowBack.findbook(bookid, readerid)) {JOptionPane.showMessageDialog(null, "该读者已借阅所选图书,且未归还!");init(); // 重新初始化各参数并禁止借出按钮return;}// 统计读者所借图书数量int borrowednum = statborrowednum(readerid);tf_borrowednum.setText(String.valueOf(borrowednum));// 如果读者已借图书尚未超出其允许最大借书量,则允许其继续借阅所选图书if (borrowednum < reader.getMax_num()) {tf_if_borrow.setText("是");// 创建一个简单日期格式对象,注意:MM一定要用大写SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");// 创建日期变量,其内容为当前日期Date currentdate = new Date();// 将日期按指定格式输出String borrowdate = sdf.format(currentdate);tf_borrow_date.setText(borrowdate);borrowBtn.setEnabled(true); // 使借出按钮有效} else {JOptionPane.showMessageDialog(null, "该读者借书过多,无法继续借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}}// 填写借出图书记录private void btn_borrowActionPerformed(ActionEvent e) {String sql;String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();String borrowdate = tf_borrow_date.getText();// 为borrow表增加借书记录sql = "insert into borrow (book_id,reader_id,"+ "borrow_date,if_back) values('" + bookid + "','" + readerid + "','" + borrowdate + "','否')";。

java+swing+mysql图书管理系统(附完整源代码)

java+swing+mysql图书管理系统(附完整源代码)

课程设计精品图书If理系统书生系统说明:本系统釆用eclipse开发,IDEA, eclipse, myedipse均可运行界面采用swing实现数据库:mysql.附sql代码,其余数据库可复制sql代码运行数据库连接文件mysql-connector-java-8.0.16.jar本系统的背景图片可根据自己的需求替换项目分为管理员和普通用户两种角色管理员有图书査询、图书借还、账户管理(修改密码、账户信息、借书记录)、图书管理(増加、修改、删除)的权限普通用户有图书査询、图书借还、账户管理(修改密码、借书记录)的权限项目结朴-温图书系饨>,JRE 基绽库(JavaSE-12]IS src y .[« Dao>dZl AdminDao.java>® BookDao.java><2)BorrowDao.java>I/) DB.java>El LandDao.javav SB Test>JZ) LandTest.java击View>ABorrowBookFace.java 通AccountMsgFacejava>i£\ AddBookFace.java>(2 AdminFace.java>Lfi BookAdminFace.java>® BookReturnFace.java>Si BookSearc h Fac e.java>DeleteBookFace.java>JZ) LogonFace.java>Si MainFace.java>JZl UBorrowBookFace.java><2)UpdateBookFace.java>UpdatePswFace.java>E) UserFace.java> i引用的阵y 4 datebase圍tsglsys.sql〜〜img。

图书管理系统(源代码)

图书管理系统(源代码)

#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。

图书管理系统的设计(C语言)

图书管理系统的设计(C语言)

图书管理系统设计图书管理信息包括:图书名称、图书编号、单价、作者、存在状态、借书人姓名、性别、学号等功能描述:1 .新进熟土基本信息的输入2 .图书基本信息的查询3 .对撤销图书信息的删除4 .为借书人办理注册5 .办理借书手续6 .办理换书手续要求:以文件方式存储数据,系统以菜单方式工作。

这是本人大一第二学期初 C 语言课程设计的作品,嘿嘿,本来以为已经找不到原稿了,今天无意中居然在QQ 网络硬盘中找到了当初的teta 版,发布于此,以作记念。

C 源代码如下:#include〈stdio 。

h〉#include<stdlib。

h〉#include〈string 。

h>struct book {char book_name [30];int bianhao;double price;char author[20];char state [20] ;char name[20];char sex [10];int xuehao;struct book *book_next;};struct club {char name [20];char sex[10];int xuehao;char borrow [30];struct club *club_next;};void Print_Book(struct book *head_book);/*浏览所有图书信息*/void Print_Club(struct club *head_club);/*浏览所有会员信息*/struct book *Create_New_Book();/*创建新的图书库, 图书编号输入为0 时结束*/struct book *Search_Book_bianhao(int bianhao,struct book *head_book);struct book *Search_Book_name (char *b_name,struct book *head_book);struct book *Search_Book_price (double price_h,double price_l,struct book *head_book);struct book *Insert_Book (struct book *head_book,struct book *stud_book) ;/*增加图书,逐个添加*/struct book *Delete_Book(struct book *head_book,int bianhao);/*删除图书*/struct club *Create_New_Club() ;struct club *Search_Club_xuehao(int xuehao,struct club *head_club);struct club *Search_Club_name (char *c_name,struct club *head_club);struct club *Insert_Club (struct club *head_club,struct club *stud_club);struct club *Delete_Club (struct club *head_club,int xuehao);struct book *Lent_Book (int bianhao ,int xuehao,struct book *head_book,struct club *head_club);struct book *back (int bianhao,int xuehao,struct book *head_book,struct club *head_club); int main(){struct book *head_book,*p_book;char book_name [30],name [20],author [20],sex [10];int bianhao;double price,price_h,price_l;int size_book=sizeof(struct book);int m=1,n=1,f;char *b_name,*c_name;struct club *head_club,*p_club;int xuehao;int size_club=sizeof (struct club) ;int choice;printf ("\n 欢迎您第一次进入图书管理系统!\n\n");printf("---——>[向导]————-〉[新建图书库] \n\n”) ;printf ("注意:当输入图书编号为0 时,进入下一步.\n\n");head_book=Create_New_Book();system(”cls”) ;printf("\n 欢迎您第一次进入图书管理系统!\n\n") ;printf("----—〉[向导]——---〉[新建会员库]\n\n”);printf(”注意:当输入会员学号为0 时,进入主菜单.\n\n”);head_club=Create_New_Club () ;system (”cls”);do {printf(”\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n”);printf("\n”);printf ("\t\t\t[1] :借书办理\t");printf(" [6]:还书办理\n”);printf (”\n");printf(”\t\t\t[2]:查询图书\t");printf(" [7]:查询会员\n”);printf (” \t\t\t[3]:添加图书\t");printf (" [8]:添加会员\n”);printf ("\t\t\t[4]:删除图书\t");printf (” [9] :删除会员\n") ;printf (” \t\t\t[5]:遍历图书\t");printf (” [10]:遍历会员\n\n”) ;printf ("\t\t\t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓\n\n”);printf("\t\t\t0:退出\n\n”) ;printf(”请选择〈0~10〉:”);scanf(”%d",&choice);switch(choice) {case 1:printf ("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");printf (”输入所借图书编号:\n");scanf (”%d",&bianhao);printf ("输入借书人的学号:\n”);scanf ("%d",&xuehao);head_book=Lent_Book(bianhao,xuehao,head_book,head_club);system (”cls");printf (” \n 借阅成功!\n\n");printf (”相关信息如下:\n\n");head_book=Search_Book_bianhao (bianhao,head_book);break;case 2:system ("cls”) ;printf(”\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n”); printf ("1。

图书管理系统源代码(原创)

图书管理系统源代码(原创)

#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(struct book *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); //按作者名查询图书void sort_chaxun(struct book *head); //按类别查询图书void time_chaxun(struct book *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=1,c,c1=1;char a,d,b[10],b1[10]="1";struct book *head=NULL;while(y){system("cls");printf("\n\n\n\n\n");printf(" ----------------------------------------------------------------------\n");printf(" --- ||-------------||-------图书信息管理系统--------||-----------||---\n");printf(" --- ||-------------||------- 登陆界面--------||-----------||---\n");printf(" ----------------------------------------------------------------------\n");printf("\n");printf(" ============1-进入系统===========\n");printf(" ============0-退出系统===========\n");printf(" ----------------------------------------------------------------------\n");printf(" 请输入选择:");scanf("%d",&n);printf("\n");getchar();switch(n){case 0:y=0;break;case 1:printf(" 请输入您的用户名(输入1即可):");gets(b);printf("\n");printf(" 请输入您的密码(输入1即可):");scanf("%d",&c);printf("\n");if(strcmp(b,b1)!=0||c!=c1){printf(" 验证失败,请重新输入!\n");scanf("%c",&d);getchar();system("cls");}else{printf(" 验证通过!请按Enter键进入!\n");scanf("%c",&d);getchar();x=1;while(x){system("cls");system ("color 1F");printf(" ----------------------------------------------------------------------\n\n");printf(" --- ||-------------||-------图书信息管理系统--------||-----------||---\n\n");printf(" --- ||-------------||-----------操作界面------------||-----------||---\n\n");printf(" ----------------------------------------------------------------------\n\n");printf(" ----------------------------------------------\n");printf(" ----||-----------系统菜单选项-----------||----\n");printf(" ----------------------------------------------\n");printf(" -|| 1-添加图书删除图书-2 ||-\n\n");printf(" -|| 3-图书列表图书排序-4 ||-\n\n");printf(" -|| 5-查询图书修改图书-6 ||-\n\n");printf(" -|| 7-录入数据退出系统-0 ||-\n\n");printf(" ----------------------------------------------\n");printf(" ----------------------------------------------\n\n");printf("请输入所选择的序号:");scanf("%d",&choice);getchar();system("cls");switch(choice){case 0:x=0;break;case 1:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{head=addbook(head);printf("添加成功!\n");printf("是否将新信息保存到文件?(y/n)\n");scanf("%c",&a);getchar();switch(a){case 'n':break;case 'y':fprint(head);printf("保存成功!\n");getchar();break;}break;}case 2:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{deletebook(head);getchar();break;}break;case 3:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{print_book(head);getchar();break;}case 4:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{paixu(head);getchar();}break;case 5:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{chaxun(head);getchar();}break;case 6:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{xiugai(head);getchar();break;}break;case 7:printf("注意:输入图书编码为0时结束!\n");head=creatbook();printf("是否将输入的信息保存到文件以覆盖文件中已存在的信息?(y/n)\n");getchar();scanf("%c",&a);getchar();switch(a){case '0':break;case 'y':fprint(head);printf("保存成功!\n");getchar();break;}break;default:printf("输入有误,请重新输入!\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;printf("请输入图书编号:");scanf("%d",&num);printf("请输入图书名:");scanf("%s",bname);getchar();printf("请输入作者名:");scanf("%s",wname);getchar();printf("请输入出版社:");scanf("%s",press);getchar();printf("请输入类别:");scanf("%s",sort);getchar();printf("请输入出版时间:");scanf("%d",&time);getchar();printf("请输入价格:");scanf("%f",&price);getchar();while(1){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{printf("请输入图书编号:");scanf("%d",&num);n=yanzheng(head,num);if(n==0)break;elseprintf("您输入的编号已存在,请重新输入!\n"); }while(1);if(num==0)break;else{printf("请输入图书名:");scanf("%s",bname);getchar();printf("请输入作者名:");scanf("%s",wname);getchar();printf("请输入出版社:");scanf("%s",press);getchar();printf("请输入类别:");scanf("%s",sort);getchar();printf("请输入出版时间:");scanf("%d",&time);getchar();printf("请输入价格:");scanf("%f",&price);getchar();}}return head;}//插入结点,并且插入后仍按一定顺序struct book *addbook(struct book *head){struct book *ptr,*p1,*p2,*p;char bname[50],wname[20],press[50],sort[50];int size=sizeof(struct book);int num,time,n=1;float price;do{printf("请输入图书编号:");scanf("%d",&num);n=yanzheng(head,num);if(n==0)break;elseprintf("您输入的编号已存在,请重新输入!\n");}while(1);printf("请输入图书名:");scanf("%s",bname);getchar();printf("请输入作者名:");scanf("%s",wname);getchar();printf("请输入出版社:");scanf("%s",press);getchar();printf("请输入类别:");scanf("%s",sort);getchar();printf("请输入出版时间:");scanf("%d",&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)){ p1=p2;p2=p2->next;}if(ptr->num<=p2->num){if(head==p2)head=ptr;else{p1->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->num==m)break;p=p->next;}if(p==NULL)return 0;elsereturn 1;}//将新链表写入文件中void fprint(struct book *head){FILE *fp;char ch='1';struct book *p1;if((fp=fopen("f1.txt","w"))==NULL){printf("File open error!\n");exit(0);}fputc(ch,fp);for(p1=head;p1;p1=p1->next){fprintf(fp,"%d %s %s %s %s %d %f\n",p1->num,p1->bname,p1->wname,p1->press,p1->sort ,p1->time,p1->price);}fclose(fp);}//从文件中读取图书信息struct book *load(){FILE *fp;char ch;struct book *head,*tail,*p1;head=tail=NULL;if((fp=fopen("f1.txt","r"))==NULL){printf("File open error!\n");exit(0);}ch=fgetc(fp);if(ch=='1'){while(!feof(fp)){p1=(struct book *)malloc(sizeof(struct book));fscanf(fp,"%d%s%s%s%s%d%f\n",&p1->num,p1->bname,p1->wname,p1->press,p1->sort,&p1-> time,&p1->price);if(head==NULL)head=p1;elsetail->next=p1;tail=p1;}tail->next=NULL;fclose(fp);return head;}elsereturn NULL;}//将整个链表的信息输出void print_book(struct book *head){struct book *ptr;if(head==NULL){printf("\n没有信息!\n");return;}printf(" 图书信息列表如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(ptr=head;ptr;ptr=ptr->next)printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", ptr->num,ptr->bname,ptr->wname,ptr->press,ptr->sort,ptr->time,ptr->price);printf("====================================================================== ======\n");}//删除图书信息void deletebook(struct book *head){int a;char b,ch='1';struct book *p1,*p2;FILE *fp;printf("请输入要删除的图书编号:");scanf("%d",&a);p1=head;if(p1->num==a&&p1->next==NULL){ //对于文件中只有一组数据printf("是否清空文件!(y/n)\n");getchar();scanf("%c",&b);getchar();switch(b){case 'n':break;case 'y':if((fp=fopen("f1.txt","w"))==NULL){printf("File open error!\n");exit(0);}fclose(fp);printf("文件已清空!\n");}}else{while(p1->num!=a&&p1->next!=NULL){p2=p1;p1=p1->next;}if(p1->next==NULL){if(p1->num==a){p2->next=NULL;printf("是否确定从文件中彻底删除该图书?(y/n)\n");getchar();scanf("%c",&b);switch(b){case 'n':break;case 'y':fprint(head);printf("删除成功!\n");getchar();break;}}else{printf("没有找到要删除的数据!\n");getchar();}}else if(p1==head){head=p1->next;printf("是否确定从文件中彻底删除该图书?(y/n)\n");getchar();scanf("%c",&b);switch(b){case 'n':break;case 'y':fprint(head);printf("删除成功!\n");getchar();break;}}else{p2->next=p1->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(" ** 1-按图书编号查询2-按图书名查询**\n");printf(" ** 3-按图书类别查询4-按作者名查询**\n");printf(" ** 5-按出版时间查询0-退出查询**\n");printf("==========================================================\n");printf("请输入所选择的编号:");scanf("%d",&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:time_chaxun(head);break;default:printf("您的输入有误!\n");break;}}//按编号查询图书信息void num_chaxun(struct book *head){int a;struct book *p;printf("请选择您要查询的图书编号:");scanf("%d",&a);getchar();p=head;while(p!=NULL){if(p->num==a)break;p=p->next;}if(p==NULL){printf("没有找到该编号的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);printf("====================================================================== ======\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=1;break;}p=p->next;}if(flag==0){printf("没有找到该图书名的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");while(p!=NULL){if(strcmp(p->bname,a)==0){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);}p=p->next;}printf("====================================================================== ======\n");}}//按作者名查询图书信息void wname_chaxun(struct book *head){char a[50];int flag=0;struct book *p;printf("请选择您要查询的图书作者名:");gets(a);p=head;while(p!=NULL){if(strcmp(p->wname,a)==0){flag=1;break;}p=p->next;}if(flag==0){printf("没有找到该图书名的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");while(p!=NULL){if(strcmp(p->wname,a)==0){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);flag=1;}p=p->next;}printf("============================================================================\n");}}//按图书类别查询图书信息void sort_chaxun(struct book *head){char a[50];int flag=0;struct book *p;printf("请选择您要查询的图书类别:");gets(a);p=head;while(p!=NULL){if(strcmp(p->sort,a)==0){flag=1;break;}p=p->next;}if(flag==0){printf("没有找到该图书名的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");while(p!=NULL){if(strcmp(p->sort,a)==0){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);flag=1;}p=p->next;}printf("====================================================================== ======\n");}}//按图书出版时间查询图书信息void time_chaxun(struct book *head){int a,flag=0;struct book *p;printf("请选择您要查询的图书出版时间:");scanf("%d",&a);getchar();p=head;while(p!=NULL){if(p->time==a){flag=1;break;}p=p->next;}if(flag==0){printf("没有找到该图书名的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");while(p!=NULL){if(p->time==a){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);flag=1;}p=p->next;}printf("====================================================================== ======\n");}}//修改图书信息void xiugai(struct book *head){int a,b;char c;struct book *p;printf("请输入要修改的图书编号:");scanf("%d",&a);p=head;while(p!=NULL){if(p->num==a)break;p=p->next;}if(p==NULL){printf("没有找到该编号的图书!\n");getchar();}else{printf("============================================================\n");printf(" ** 1-编号2-图书名3-作者名**\n");printf(" ** 4-出版社5-类别6-出版时间**\n");printf(" ** 7-价格8-修改全部0-放弃修改**\n");printf("============================================================\n");printf("请选择你要修改的信息编号:");scanf("%d",&b);getchar();switch(b){case 1:printf("请输入新编号:");scanf("%d",&p->num);printf("修改成功!\n");getchar();break;case 2:printf("请输入新图书名:");gets(p->bname);printf("修改成功!\n");break;case 3:printf("请输入新作者名:");gets(p->wname);printf("修改成功!\n");break;case 4:printf("请输入新出版社:");gets(p->press);printf("修改成功!\n");break;case 5:printf("请输入新类别:");gets(p->sort);printf("修改成功!\n");break;case 6:printf("请输入新出版时间:");scanf("%d",&p->time);printf("修改成功!\n");getchar();break;case 7:printf("请输入新价格:");scanf("%f",&p->price);printf("修改成功!\n");getchar();break;case 8:printf("请输入新图书编号:");scanf("%d",&p->num);printf("请输入新图书名:");scanf("%s",p->bname);getchar();printf("请输入新作者名:");scanf("%s",p->wname);getchar();printf("请输入新出版社:");scanf("%s",p->press);getchar();printf("请输入新类别:");scanf("%s",p->sort);getchar();printf("请输入新出版时间:");scanf("%d",&p->time);getchar();printf("请输入新价格:");scanf("%f",&p->price);getchar();printf("修改成功!\n");getchar();break;case 0:break;default :printf("您的输入有误!\n");break;}printf("是否将修改后的信息保存到文件中?(y/n)\n");scanf("%c",&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(" ** 1-按图书编号排序2-按出版时间排序**\n");printf(" ** 3-按图书价格排序4-按图书名排序**\n");printf(" ** 5-按作者名排序0-取消排序操作**\n");printf("================================================================\n");printf("请输入您选择的编号:");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("您的输入有误!\n");break;}}//按图书编号排序void num_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(a[i]->num<a[index]->num)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}//按出版时间排序void time_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(a[i]->time<a[index]->time)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}//按图书价格排序void price_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(a[i]->price<a[index]->price)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}//按图书名排序void bname_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(strcmp(a[index]->bname,a[i]->bname)>0)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}//按作者名排序void wname_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(strcmp(a[index]->wname,a[i]->wname)>0)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}。

图书馆管理系统数据库的连接与实现

图书馆管理系统数据库的连接与实现

三、实验步骤1、程序源代码----BaseDao.java的代码package data;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;/*** 类BaseDao用于设置连接数据库的相关信息和基本操作** @author raymond*/public class BaseDao {protected static String driver = "org.apache.derby.jdbc.ClientDriver"; // 数据库驱动(将derbyclient.jar文件加载到项目库里)protected static String url = "jdbc:derby://localhost:1527/mylibrary"; // 连接url,连接数据库之前,先要启动数据库服务器protected static String dbUser = "raymond"; // 数据库用户名protected static String dbPwd = "88888888"; // 数据库密码private static Connection conn = null;// 构造方法,创建数据库连接private BaseDao() {try {if (conn == null) {Class.forName(driver); // 加载数据库驱动conn = DriverManager.getConnection(url, dbUser, dbPwd); // 建立数据库连接}// else {//return;//}} catch (Exception e) {System.out.println(e.getMessage());}}// 执行数据库查询操作public static ResultSet executeQuery(String sql) {try {if (conn == null) {new BaseDao();}return conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDA TABLE).executeQuery(sql); // 执行数据库查询} catch (SQLException e) {System.out.println(e.getMessage());return null;}}// 执行数据库更新操作public static int executeUpdate(String sql) {try {if (conn == null) {new BaseDao();}return conn.createStatement().executeUpdate(sql); // 执行数据库更新} catch (SQLException e) {System.out.println(e.getMessage());return -1;} finally {}}public static void close() {try {conn.close();} catch (SQLException e) {System.out.println(e.getMessage());} finally {conn = null;}}}----BookDao.java的代码package data;import entity.Book;import java.sql.ResultSet;import java.util.ArrayList;import java.util.List;/*** 类BookDao用于图书查询的操作** @author raymond*/public class BookDao {//根据图书编号,获得单个图书实体public static Book selectBook(String id) {String sql = "select * from book where id='" + id + "'";ResultSet rs = BaseDao.executeQuery(sql);Book book = null;try {if (rs.next()) {book = new Book();book.setId(rs.getString("id"));book.setType(rs.getString("type"));book.setName(rs.getString("name"));book.setAuthor(rs.getString("author"));book.setTranslator(rs.getString("translator"));book.setPublisher(rs.getString("publisher"));book.setPublish_time(rs.getDate("publish_time"));book.setPrice(rs.getDouble("price"));book.setStock(rs.getInt("stock"));}} catch (Exception e) {System.out.println(e.getMessage());}BaseDao.close();return book;}//获得满足sql语句的图书实体列表public static List selectBookList(String sql) {List list = new ArrayList();ResultSet rs = BaseDao.executeQuery(sql);try {while (rs.next()) {Book book = new Book();book.setId(rs.getString("id"));book.setType(rs.getString("type"));book.setName(rs.getString("name"));book.setAuthor(rs.getString("author"));book.setTranslator(rs.getString("translator"));book.setPublisher(rs.getString("publisher"));book.setPublish_time(rs.getDate("publish_time"));book.setPrice(rs.getDouble("price"));book.setStock(rs.getInt("stock"));list.add(book);}} catch (Exception e) {System.out.println(e.getMessage());}BaseDao.close();return list;}}----BaseDao.java的代码package data;import entity.Reader;import java.sql.ResultSet;import java.util.ArrayList;import java.util.List;/*** 类BaseDao用于读者查询的操作** @author raymond*/public class ReaderDao {//根据读者编号,获得单个读者实体public static Reader selectReader(String id) {String sql = "select * from reader where id=" + id;ResultSet rs = BaseDao.executeQuery(sql);Reader reader = null;try {if (rs.next()) {reader = new Reader();reader.setId(rs.getString("id"));reader.setType(rs.getString("type"));reader.setName(rs.getString("name"));reader.setSex(rs.getString("sex"));reader.setMax_num(rs.getString("max_num"));reader.setDays_num(rs.getInt("days_num"));}} catch (Exception e) {System.out.println(e.getMessage());}BaseDao.close();return reader;}//获得满足sql语句的读者实体列表public static List selectReaderList(String sql) {List list = new ArrayList();ResultSet rs = BaseDao.executeQuery(sql);Reader reader = null;try {while (rs.next()) {reader = new Reader();reader.setId(rs.getString("id"));reader.setType(rs.getString("type"));reader.setName(rs.getString("name"));reader.setSex(rs.getString("sex"));reader.setMax_num(rs.getString("max_num"));reader.setDays_num(rs.getInt("days_num"));list.add(reader);}} catch (Exception e) {System.out.println(e.getMessage());}BaseDao.close();return list;}}2、结果显示图1 图书查询图2 用户查询图3 修改图书信息图4 更新用户信息四、实验体会在调试中遇到了几个问题:com.mysql.jdbc.Driver没导入,由于数据库账号和密码出错没找出表,在代码中表名写错。

C语言图书管理系统源代码

C语言图书管理系统源代码

#include<stdio。

h〉#include<stdlib.h〉#include〈string。

h〉struct tushu{ /*图书结构体*/ char num[10]; /*编号*/char name[20];/*书名*/char writer[20];/*作者*/char press[20];/*出版社*/char kind[20];/*类别*/double time; /*时间*/double price;/*价格*/struct tushu *next;};struct stu /*学生结构体*/ {int snum;/*学号*/char mima[10]; /*密码*/struct stu *next;};FILE *fp; /*图书文件*/FILE *fp1; /*管理员信息文件*/ FILE *fp2; /*学生信息文件*/void menu();/*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/void xmenu();/*学生主菜单(学生进入可对图书,密码进行操作)*/void gfind(); /*管理员查询(管理员可按一定的方式查询图书)*/void xfind();/*学生查询(学生可按一定的方式查询图书)*/ void secret();/*管理员权限(管理员登陆所用,输入错误次数过多自动退出)*/void sort();/*排序(管理员可按一定的方式对图书进行排序,排序完之后可选择文件进行保存)*/void fprint(struct tushu *head);/*保存(可追加的保存,如添加可用)*/void fprint_(struct tushu *head);/*保存(可覆盖保存如修改,删除,排序后用)*/void hfprint(struct tushu *head); /*还书保存(还书成功后自动保存到文件)*/void jfprint_(struct tushu *head);/*借书保存(借书成功之后自动从图书馆删除)*/struct tushu * Input(); /*图书添加(可进行图书的添加)*/struct tushu *create(); /*从文件创建链表(从文件中读出信息,建立单链表)*/void gBrowse(struct tushu *head);/*管理员浏览(对图书进行遍历)*/void xBrowse(struct tushu *head);/*学生浏览(学生对图书进行遍历)*/void count(struct tushu *head); /*统计数量(管理员可对图书进行统计)*/void Findofname(struct tushu *head); /*按书名查找*/ void Findofwriter(struct tushu *head); /*按作者查找*/void Findofkind(struct tushu *head); /*按类别查找*/void xFindofname(struct tushu *head);/*学生按书名查找*/void xFindofwriter(struct tushu *head);/*学生按作者查找*/ void xFindofkind(struct tushu *head); /*学生按类别查找*/ void Sort_time(struct tushu * head); /*按时间排序(管理员按时间对图书进行排序,排序完之后可选择文件进行保存)*/ void Sort_price(struct tushu *head); /*按价格排序*/void Sort_num(struct tushu * head);/*按编号排序*/ void Delete(struct tushu * head,char m[15]);/*按编号删除(管理员可按编号删除图书)*/void Revise(struct tushu *head);/*修改(管理员可对图书进行修改,并选择是否保存)*/void borrow(struct tushu *head); /*借书*/void huanshu(); /*还书(学生借完书之后进行还书,若没有图书则不能借)*/void gxinxi(); /*管理员信息(有管理员的账号及密码,可进行修改)*/void xmima(struct stu *head1);/*学生密码修改(学生可对自己的密码进行修改)*/struct stu *xcreate();/*从文件创建学生信息(从文件读出学生信息,建立学生链表)*/void xsecret(struct stu *head1);/*学生权限(学生登陆所用)*/void menu() /*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/{int choice,n=0;struct tushu *head;struct stu *head1,*p;char m[15];there:printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n"); printf(" ┃┃socat 图书管理系统printf(” ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n"); printf(" ┃●[0]退出系统┃\n");printf(” ┃┃\n”);prin tf(” ┃●[1]帮助┃\n");printf(” ┃┃\n”);printf(” ┃●[2]浏览图书┃\n");printf(” ┃┃\n");printf(” ┃●[3]统计图书数目┃\n”);printf(" ┃┃\n”);printf(” ┃●[4]查询┃\n”);printf(” ┃printf(” ┃●[5]添加┃\n");printf(” ┃┃\n”);printf(” ┃●[6]排序┃\n");printf(” ┃┃\n");printf(" ┃●[7]修改┃\n”);printf(” ┃┃\n");printf(" ┃●[8]删除┃\n”);printf(" ┃┃\n”);printf(" ┃●[9]修改账号及密码┃\n");printf(” ┃┃\n”);printf(” ┃●[10]学生信息printf(”┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");printf(” 请选择:”);fflush(stdin);head=create();scanf("%d”,&choice);if(choice==1){//help();printf(”没有内容!\n”);system("pause”);system(”cls”);menu();}else if(choice==2){system(”cls");if(head==NULL){printf(”没有图书,请先添加图书!\n”);system("pause");system("cls");menu();}gBrowse(head);}else if(choice==3){system(”cls");count(head);}else if(choice==4){system("cls");if(head==NULL){printf(”没有图书,请先添加图书!\n”);system("pause”);system(”cls”);menu();}gfind();}else if(choice==5){Input();}else if(choice==6){system("cls");if(head==NULL){printf(”没有图书,请先添加图书!\n”); system("pause”);system(”cls”);menu();}sort(head);}else if(choice==7){system("cls”);if(head==NULL){printf(”没有图书,请先添加图书!\n”);system("pause");system("cls”);menu();}Revise(head);}else if(choice==8){if(head==NULL){printf("没有图书,请先添加图书!\n");system(”pause");system(”cls");menu();}printf(" 请输入想要删除的图书编号:”);scanf(”%s",m);Delete(head,m);}else if(choice==9){gxinxi();else if(choice==10){system(”cls”);head1=xcreate();if(head1==NULL){printf("没有学生信息,请到xuesheng_list.txt添加!\n”); sys tem(”pause”);system(”cls”);menu();}for(p=head1;p!=NULL;p=p—>next){printf(”学生学号密码\n”);printf("%d %s\n",p->snum,p—>mima);}system(”pause”);system("cls”);menu();}else if(choice==0)system(”cls");printf(”\n\n\n\n”);printf(” ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n”);exit(0);}else{system("cls");printf(”\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ");system("pause”);system(”cls”);n++;if(n==3){printf(” \n\n\n ━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n”);printf(" ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n");system(”pause");exit(0);}goto there;}}void xmenu()/*学生主菜单(学生进入可对图书,密码进行操作)*/{struct tushu *head;struct stu *head1;int choice,n=0;there:printf(”┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");printf(” ┃┃socat 图书借阅系统┃┃\n");printf(” ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n"); printf(” ┃●[0]退出系统┃\n”);printf(” ┃printf(” ┃●[1]帮助┃\n”);printf(” ┃┃\n”);printf(” ┃●[2]浏览图书┃\n");printf(” ┃┃\n”);printf(" ┃●[3]查询┃\n”);printf(” ┃┃\n”);printf(” ┃●[4]借书┃\n");printf(” ┃┃\n”);printf(" ┃●[5]还书┃\n");printf(" ┃┃\n”);printf(” ┃●[6]修改密码printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n”); printf(" 请选择:");fflush(stdin);head=create();scanf("%d”,&choice);if(choice==1){//xhelp();printf(”没有内容!\n");system(”pa use");system(”cls”);xmenu();}else if(choice==2){system("cls");if(head==NULL){printf(”没有图书!\n");system("pause”);xmenu();}xBrowse(head);}else if(choice==3){if(head==NULL){printf(”没有图书!\n”);system(”pause”);system(”cls”);xmenu();}xfind();}else if(choice==4){if(head==NULL){printf(”没有图书!\n");system(”pause”);xmenu();}borrow(head);}else if(choice==5){huanshu(head);}else if(choice==6){system("cls”);head1=xcreate();if(head1==NULL){printf(”学生信息被清空!!\n”);system("pause");system("cls”);xmenu();}xmima(head1); ;}else if(choice==0){system("cls");printf(”\n\n\n\n”);printf(” ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n");exit(0);}else{system("cls”);printf("\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ”);system(”pause”);system(”cls”);n++;if(n==3){printf(” \n\n\n ━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n”);printf(” ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n”);system("pause”);exit(0);}goto there;}}void gfind()/*管理员查询(管理员可按一定的方式查询图书)*/{int choice,n=0;struct tushu *head;there:system(”cls”);printf(” ┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n”);printf(” ┃┃socat 图书借阅系统┃┃\n”);printf(” ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");printf(" ┃●[0]返回┃\n");printf(" ┃┃\n”);printf(" ┃●[1]按书名查找┃\n”);printf(" ┃┃\n”);printf(" ┃●[2]按作者查找┃\n”);printf(” ┃┃\n”);printf(" ┃●[3]按类别查找┃\n”);printf(" ┃┃\n”);printf(" ┃● ┃\n”);printf(”┗━━━━━━━━━━━━━━━━━━━━━━━┛\n”);printf(" 请选择:”);fflush(stdin);head=create();scanf(”%d”,&choice);if(choice==1){system(”cls");Findofname(head); }else if(choice==2){system(”cls”); Findofwriter(head); }else if(choice==3){system(”cls");Findofkind(head); }else if(choice==0){system(”cls”);menu();}else{system(”cls”);printf(”\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ”);system("pause");system(”cls");n++;if(n==3){printf(" \n\n\n ━━━━━━━━你错误次数太多,自动退出! ━━━━━━━━\n\n\n”);printf(" ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n”);system(”pause”);exit(0);}goto there;}}void xfind()/*学生查询(学生可按一定的方式查询图书)*/ {struct tushu *head;int choice,n=0;there:system("cls”);printf(” ┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n”);printf(” ┃┃socat 图书借阅系统┃┃\n”);printf(” ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");printf(” ┃●[0]返回┃\n”);printf(” ┃┃\n");printf(" ┃●[1]按书名查找┃\n”);printf(” ┃┃\n”);printf(" ┃●[2]按作者查找┃\n”);printf(" ┃┃\n");printf(” ┃●[3]按类别查找┃\n");printf(” ┃┃\n”);printf(" ┃● ┃\n");printf(”┗━━━━━━━━━━━━━━━━━━━━━━━┛\n"); printf(” 请选择:");fflush(stdin);head=create();scanf(”%d",&choice);if(choice==1){system(”cls”);xFindofname(head);}else if(choice==2){system(”cls”);xFindofwriter(head);}else if(choice==3){system("cls");xFindofkind(head);}else if(choice==0){system(”cls");xmenu();}else{system("cls");printf("\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ”);system(”pause”);system(”cls");n++;if(n==3){printf(” \n\n\n ━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n”);printf(” ━━━━━━━━感谢使用图书借阅系统━━━━━━━━\n\n\n”);system("pause”);exit(0);}goto there;}}void sort(){struct tushu *head;int choice,n=0;there:system("cls”);printf(” ┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");printf(” ┃┃socat 图书借阅系统┃┃\n");printf(" ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n”);printf(" ┃●[0]返回┃\n”);printf(” ┃┃\n");printf(” ┃●[1]按时间排序┃\n”);printf(” ┃┃\n”);printf(” ┃●[2]按价格排序┃\n");printf(" ┃┃\n”);printf(” ┃●[3]按编号排序┃\n”);printf(" ┃┃\n”);printf(” ┃●┃\n”);printf(”┗━━━━━━━━━━━━━━━━━━━━━━━┛\n”);printf(" 请选择:”);fflush(stdin);head=create();scanf("%d",&choice);if(choice==1){system("cls”); Sort_time(head);}else if(choice==2){sys tem(”cls");Sort_price(head);}else if(choice==3){system(”cls”);Sort_num(head); }else if(choice==0){system("cls”); menu();}else{system(”cls");printf("\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ”);system(”pause”);system(”cls”);n++;if(n==3){printf(” \n\n\n ━━━━━━━━你错误次数太多,自动退出! ━━━━━━━━\n\n\n”);printf(” ━━━━━━━━感谢使用图书借阅系统━━━━━━━━\n\n\n”);system("pause”);exit(0);}goto there;}}struct tushu *Input(){struct tushu *p1,*p2,*head,*ptr;char num;int x,i=0;system("cls”);p1=(struct tushu *)malloc(sizeof(struct tushu));head=p1;p1-〉price=—1;while(i!=1){printf(”请输入编号,以’#’结束\n”);scanf("%s",p1—>num);if(strcmp(p1-〉num,”#")==0)i=1;while(i!=1){printf(”请依次输入书名作者出版社类别出版时间价格\n”); scanf(”%s%s%s%s%lf%lf”,p1—>name,p1—>writer,p1—〉press,p1-〉kind,&p1-〉time,&p1—〉price);p2=p1;p1=(struct tushu *)malloc(sizeof(struct tushu));p2—〉next=p1;break;}}if(p1-〉price!=-1)p2—〉next=NULL;elsehead=NULL;system("cls”);printf("\n\n\n\t\t\t图书信息输入结束!\n\n\n”);system(”pause”);system(”cls”);printf(”\n\n\n\t\t\t是否保存图书信息?(1。

图书管理系统C#源代码

图书管理系统C#源代码

using System;using System。

Collections。

Generic;using ponentModel;using System。

Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1{public partial class Form_BuyAndSale : Form{public Form_BuyAndSale(){InitializeComponent();}SQL sql;string lastSQL = ””;public void show(){listBox1。

Items。

Clear();listBox2.Items.Clear();listBox3。

Items。

Clear();if (sql。

rows。

GetLength(0) != 0){for (int i = 0; i 〈 sql。

rows。

GetLength(0); i++){listBox1.Items。

Add(sql。

rows[i, 0].ToString());listBox2.Items.Add(sql.rows[i, 1].ToString());listBox3.Items。

Add(sql。

rows[i, 2].ToString());}}else{listBox1.Text = ”";listBox2。

Text = ””;listBox3。

Text = "”;MessageBox。

Show("无符合查询条件的结果!”, "提示”);}}private void Form_BuyAndSale_Load(object sender, EventArgs e){//将窗体的任务栏隐藏this。

FormBorderStyle = System.Windows。

图书管理系统数据库源代码

图书管理系统数据库源代码

图书管理系统数据库源代码//创建工程及设计主界面public class Main extends JFrame{private static final JDesktopPane{DESKTOP_PANE=new JDesktopPane(); //桌面窗体}public static void main(String[] args) //入口方法{try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //设置系统界面外观new BookLogin(); //登录窗口}catch(Exception ex){ex.printStackTrace();}}public static void addIFame(JInternalFrame iframe) //添加子窗体的方法{DESKTOP_PANE.add(iframe); //新增子窗体}public Main(){super(); //设置“关闭”按钮处理事件setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); //创建工具栏Toolkit tool=Toolkit,getDefaultToolkit(); //获得屏幕大小Dimension screenSize=tool.getScreenSize();setSize(800,600); //设置窗体大小setLocation((screenSize.width-getWidth())/2,(screenSize.height-getHeight())/2; //设置窗体位置setTitle("图书管理系统");//设置窗体标题JMenuBar menuBar=createMenu(); //创建菜单栏setJMenuBar(menuBar); //设置菜单栏JToolBar toolBar=createToolBar(); //创建工具栏的方法getContentPane(),add(toolBar,BorderLayout.NORTH); //设置工具栏final JLable lable=new JLable(); //创建一个标签,用来显示图片lable.setBounds(0,0,0,0); //设置窗体的大小和位置lable.setIcon(null); //窗体背景DESKTOP_PANE.addComponentListener(new ComponentAdapter())public void componentResized(final ComponentEvent e){Dimension size=e.getComponent().getSize(); //获得组建大小lable.setSize(e.getComponent().getSize()); //设置标签大小lable.setText("<html><imgwidth="+size.width+"height="+size.height+"src='"+this.getClass().getResource("/backImg.jpg")+ "'></html>");//设置标签文本,设置窗口背景}} //将标签添加到桌面窗体DESKTOP_PANE.add(lable,new Integer(Integer.MIN_VALUE));getContentPane().add(DESKTOP_PANE); //将桌面窗体添加到主窗体中}}private JToolBar createToolBar() //创建工具栏的方法{JToolBar toolBar=new JToolBar(); //初始化工具栏toolBar.setFloatable(false); //设置是否可以移动工具栏toolBar.setBorder(new BevelBorder(BevelBorder.RAIZED)); //设置边框//图书信息添加按钮JButton bookAddButton=new JButton(MenuActions.BOOK_ADD);bookAddButton.setIcon(icon); //设置按钮图标bookAddButton.setHideActionText(true); //显示提示文本toolBar.add(bookAddButton); //添加到工具栏中JButton bookModiAndDelButton=new JButton(MenuActions.BOOK_MODIFY); //图书信息修改按钮ImageIcon bookmodiicon=Icon.add("bookModiAndDeltb.jpg"); //创建图表方法bookModiAndDelButton.setIcon(bookmodiicon); //设置按钮图标bookModiAndDelButton.setHideActionText(true); //显示提示文本toolBar.add(bookModiAndDelButton); //添加到工具栏JButton bookTypeAddButton=new JButton(MenuActions.BOOKTYPE_ADD); //图书类别添加按钮ImageIcon bookTypeAddicon=Icon.add("bookTypeAddtb.jpg"); //创建图标方法bookTypeAddButton.setIcon(bookTypeAddicon); //设置按钮图标bookTypeAddButton.setHideActionText(true); //显示提示文本toolBar.add(bookTypeAddButton); //添加到工具栏JButton bookBorrowButton=new JButton(MenuActions.BORROW); //图书借阅按钮ImageIcon bookBorrowicon=Icon.add("bookBorrowtb.jpg"); //创建图标方法bookBorrowButton.setIcon(bookBorrowicon); //设置按钮图标bookBorrowButton.setHideActionText(true); //显示提示文本JButton bookOrderButton=new JButton(MenuActions.NEWBOOK_ORDER); //新书订购按钮ImageIcon bookOrdericon=Icon.add("bookOrdertb.jpg"); //创建图标方法bookOrderButton.setIcon(bookOrdericon); //设置按钮图标bookOrderButton.setHideActionText(true); //显示提示文本toolBar.add(bookOrderButton); //添加到工具栏JButton bookCheckButton=new JButton(MenuActions.NEWBOOK_CHECK); //验收新书按钮ImageIcon bookCheckicon=Icon.add("newbookChecktb.jpg"); //创建图标方法bookCheckButton.setIcon(bookCheckicon); //设置按钮图标bookCheckButton.setHideActionText(true); //显示提示文本toolBar.add(bookCheckButton); //添加到工具栏JButton readerAddButton=new JButton(MenuActions.READER_ADD); //读者信息添加按钮ImageIcon readerAddicon=Icon.add("readerAddtb.jpg"); //创建图标方法readerAddButton.setIcon(readerAddicon); //设置按钮图标readerAddButton.setHideActionText(true); //显示提示文本toolBar.add(readerAddButton); //添加到工具栏JButton readerModiAndDelButton=new JButton(MenuActions.READER_MODIFY); //读者信息修改按钮ImageIcon readerModiAndDelicon=Icon.add("readerModiAndDeltb.jpg"); //创建图标方法readerModiAndDelButton.setIcon(readerModiAndDelicon); //设置按钮图标readerModiAndDelButton.setHideActionText(true); //显示提示文本toolBar.add(readerModiAndDelButton); //添加到工具栏JButton ExitButton=new JButton(MenuActions.EXIT); //退出系统按钮ImageIcon Exiticon=Icon.add("exittb.jpg"); //创建图标方法ExitButton.setIcon(Exiticon); //设置按钮图标ExitButton.setHideActionText(true); //显示提示文本toolBar.add(ExitButton); //添加到工具栏return toolBar;}public class Business{protected static String dbUser="root"; //数据库用户名protected static String dbpwd="root"; //数据库密码private static Connection conn=null; //数据库连接对象,初值为nullpublic Business(){try{if(coon==null) //连接对象为空{Class.forName(dbClassName); //加载驱动类信息}}catch(Exception ee){ee.printStackTrace();}}public static ResultSet executeQuery(String sql) //执行查询方法{try{//如果连接对象为空,则重新调用构造方法if (conn==null){new Business();returnconn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATAB LE).executeQuery(sql);//执行查询}}catch(SQLException e){e.printStackTrace();return null; //返回null值}finally{}}public static int executeUpdata(String sql) //更新方法{try{if(conn==null){new Business(); //如果连接对象为空,则重新调用构造方法return conn.createStatement().executeUpdate(sql); //执行更新}}catch(SQLException e){e.printStackTrace();return -1;}finally}public static void close() //关闭方法{try{conn.close(); //关闭连接对象}catch(SQLException e){e.printStackTrace();}finally{conn=null; //设置连接对象为null值}}}//为数据库添加对应的类public class BookInfo{private String Book_id; //图书编号private String typeid; //类别编号private String writer; //作者private String translator; //译者private String publisher; //出版社private Date date; //出版日期private Double price; //图书单价private String getBookname; //图书名称public String getBookname(){return bookname;}public void setBookname(String bookname){this.bookname=bookname;}public Date getDate(){return date;}public void setDate(Date date){this.date=date;}public string getBook_id()return Book_id;}public void setBook_id(String Book_id) {this.Book_id=Book_id;}public Double getPrice(){return price;}public void setprice(Double price){this.price=price;}public String getPublisher(){return Publisher;}public void setPublisher(String publisher) {this.Publisher=Publisher;}public String getTranslator(){return translator;}public void setTranslator(String translator) {this.translator=translator;}public String getTypeid(){return typeid;}public void setTypeid(String typeid){this.typeid=typeid;}public String getWriter(){return writer;}public void setWriter(String writer){this.writer=writer;}public class BookType //图书列表信息类{private String id; //图书类别编号private String typeName; //图书类别名称private String days; //可解天数private String fk; //每罚款金额public String getFk(){return fk;}public void setFk(String fk){this.fk=fk;}public String getDays(){return days;}public void setDays(String days){this.days=days;}public string getId(){return id;}public void setId(String id){this.Bid=id;}public String getTypeName(){return typeName;}public void setTypeName(String typeName){this.typeName=typeName;}}public class Order //图书订单信息类{private String Book_id; //图书编号private Date date; //下单时间private String number; //图书数量private String checkAndAccept; //是否收到货private String zk; //图书折扣public String getcheckAndAccept(){return checkAndAccept;}public void setcheckAndAccept(String checkAndAccept) {this.checkAndAccept=checkAndAccept;}public Date getDate(){return date;}public void setDate(Date date){this.date=date;}public string getBook_id(){return book_id;}public void setBook_id(String book_id){this.book_id=book_id;}public String getNumber(){return number;}public void setNumber(String number){this.number=number;}public String getOperator(){return operator;}public void setOperator(String operator){this.operatorr=operator;}public String getZk(){return zk;public void setZk(String Zk){this.zk=zk;}}public class Operater{private String id; //操作员编号private String name; //操作员用户名private String grade; //操作员等级private String password; //操作员密码private String type; //出版社public String getType(){return type;}public void setType(String type){this.type=type;}public string getGrade(){return grade;}public void setGrade(String grade){this.grade=grade;}public String getId(){return id;}public void setId(String id){this.id=id;}public String getName(){return name;}public void setName(String name){=name;}public String getPassword()return password;}public void setPassword(String password){this.password=password;}}public class Borrow //书籍借阅信息类{private int id; //借阅编号private String book_id; //图书编号private String reader_id; //读者编号private String num; //借书数量private String borrowDate; //借书日期private String backDate; //应还日期private String Bookname; //图书名称public String getBookname(){return bookname;}public void setBookname(String bookname){this.bookname=bookname;}public string getBackDate(){return backDate;}public void setBackDate(String backDate){this.backDate=backDate;}public string getBorrowDate(){return borrowDate;}public void setBorrowDate(String borrowDate){this.borrowDate=borrowDate;}public String getNum(){return num;}public void setNum(String num)this.num=num;}public String getBook_id(){return book_id;}public void setBook_id(String book_id){this.book_id=book_id;}public String getReader_id(){return reader_id;}public void setReader_id(String reader_id){this.reader_id=reader_id;}public int getId(){return id;}public void setId(Int id){this.id=id;}}public class Back //图书归还信息类{private String book_id; //图书编号private String bookname; //图书名称private String operatorId; //操作员编号private String borrowDate; //图书借阅时间private String backDate; //图书归还时间private String readerName; //读者姓名private String reader_id; //读者编号private int typeId;private int id;public int getId(){return id;}public void setId(int id){this.id=id;public int getTypeId(){return typeid;}public void setTypeId(int typeid){this.typeId=typeId;}public string getBackDate(){return backDate;}public void setBackDate(String backDate) {this.backDate=backDate;}public String getBookname(){return bookname;}public void setBookname(String bookname) {this.bookname=bookname;}public string getBorrowDate(){return borrowDate;}public void setBorrowDate(String borrowDate) {this.borrowDate=borrowDate;}public String getOperatorId(){return operatorId;}public void setOperatorId(String operatorId) {this.operatorId=operatorId;}public String getBook_id(){return book_id;}public void setBook_id(String book_id)this.book_id=book_id;}public String getReader_id(){return reader_id;}public void setReader_id(String reader_id){this.reader_id=reader_id;}public String getReaderName(){return readerName;}public void setReaderName(String readerName){this.readerName=readerName;}}//系统登录模块设计public class BookLogin extends JFrame{private static final Operater Type=null; //人员类型private static Operater user; //用户名private JPasswordField password;private JTextField username;private JButton login;private JButton reset;public BookLogin(){super();final BorderLayout borderLayout=new BorderLayout(); //创建布局管理器setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置“关闭”按钮处理事件borderLayout.setVgap(10); //设置组件间的垂直关系getContentPane().setLayout(borderLayout); //使用布局管理器setTitle("图书管理系统登录") //设置窗体标题Toolkit tool=Toolkit.getDefaultToolkit(); //获得默认的工具箱Dimension screenSize=tool.getScreenSize(); //获得屏幕的大小setSize(285,194);setLocation((screenSize.width-getWidth())/2,(screenSize.height-getHeight())/2); //设置窗体位置final JPanel mainPanel=new JPanel(); //创建主面板mainPanel.setLayout(new BorderLayout()); //设置边框布局mainPanel.setBorder(new EmptyBorder(0,0,0,0)) //设置边框为0final JLabel imageLabel=new JLabel; //创建一个标签,用来显示图片ImageIcon loginIcon=Icon.add("login.jpg"); //创建一个图像图标imagelabel.setIcon(loginIcon); //设置图片imageLabel.setOpaque(true); //设置绘制其边界内的所有像素imageLabel.setBackground(Color.GREEN); //设置背景颜色imageLabel.setpreferredSize(new Dimension(260,60)); //设置标签大小mainPanel.add(imageLabel,BorderLayout.NORTH); //添加标签到主面板final JPanel centerPanel=new JPanel(); //添加一个中心面板final GridLayout gridLayout=new GridLayout(2,2); //创建网络布局管理器gridLayout.setHgap(5); //设置组件之间平行的距离gridLayout.setVgap(20); //设置组件之间垂直的距离centerPanel.setLayout(gridLayout); //使用布局管理器mainPanel.add(centerPanel); //添加到主桌面final JLabel userNamelabel=new JLabel(); //创建一个标签userNameLabel.setHorizontalAlignment(SwingConstants.CENTER); //设置对齐方式userNameLabel.setPreferredSize(new Dimension(0,0)); //设置组件大小userNameLabel.setMinimumSize(new Dimension(0,0)); //设置组件最小的大小centerPanel.add(userNameLabel); //添加到中心面板userNameLabel.setText("用户名:"); //设置标签文本username=new JTextField(20); //创建文本框username.setPreferredSize(new Dimension(0,0)); //设置组件大小centerPanel.add(username); //添加到中心面板final JLabel passwordLabel=new JLabel(); //创建一个标签passwordLabel.setHorizontalAlignment(SwingConstants.CENTER); //设置对齐方式centerPanel.add(passwordLabel); //添加到中心面板passwordLabel.setText("密码:"); //设置标签文本password=new JPasswordField(20); //创建密码框password.setDocument(new Document(6)); //设置密码长度为6password.addKeyListener(new KeyAdapter() //监听密码框{public void keyPressed(final keyEvent e) //监听键盘案件事件{if(e.getKeyCode()==10) //如果按了回车键{login.doClick(); //进行登录}}})centerPanel.add(password); //添加到中心面板final JPanel southPanel=new JPanel; //新增一个底部面板mainPanel.add(southPanel,BorderLayout.SOUTH); //添加到主面板中login=new JButton(); //创建按钮组件login.addActionListener(new BookLoginAtion()); //添加监听器login.setText("登录"); //设置按钮文本southPanel.add(login); //把按钮添加到底部面板reset.addActionListener(new BookResetAction()); //添加监听器reset.setText("重置");//设置按钮文本southPanel.add(reset); //把按钮添加到底部面板setVisible(true); //设置创建可见setResizable(false); //设置窗体不可改变大小}public static Operater getUser(){return user;}public static Operater getType(){return Type;}public static void setUser(Operater user){er=user;}}private class BookResetAction implements ActionListener{public void actionPerformed(final ActionEvent e){username.setText(""); //设置用户名输入框为空password.setText(""); //设置密码输入框为空}}private class BookLoginAction implements ActionListener{public void actionPerformed(final ActionEvent e){user=Business.check(username.getText(),new String(password.getPassword())); //调用business方法if(user.getName()!=null) //判断用户名是否为null{try{Main frame=new Main(); //创建一个主窗体frame.setVisible(true); //设置其可见}catch(Exception ex){ex.printStackTrace();}}{JOptionPane.showMessageDialog(null,"请输入正确的用户名和密码!"); //弹出提示框username.setText(""); //设置用户名输入框为空password.setText(""); //设置密码输入框为空}}}//基本信息管理模块public class ReaderAdd extends JInternalFrame //添加读者信息{public ReaderAdd(){super();setTitle("读者相关信息添加");setIconifiable(true); //设置窗体可最小化setClosable(true); //设置窗体可关闭setBounds(100,100,500,350);final JLabel logoLabel=new JLabel();ImageIcon readerAddIcon=Icon.add("readerAdd.jpg");logoLabel.setIcon(readerAddIcon);logoLabel.setOpaque(true);logoLabel.setBackground(Color.CYAN);logoLabel.setPreferredSize(new Dimension(400,60));getContentPane().add(logoLabel,BorderLayout.NORTH);final JPanel panel=new JPanel();panel.setLayout(new FlowLayout());getContentPane().add(panel);final JPanel panel_1=new JPanel();final GridLayout gridLayout=new GridLayout(0,4);gridLayout.setVgap(15);gridLayout.setHgap(15);panel_1.setLayout(gridLayout);panel_1.setPreferredSize(new Dimension(450,200));panel.add(panel_1);final JLabel label_2=new JLabel();label_2.setText("姓名:");panel_1.add(label_2);readername=new JTextField();readername.setDocument(new Document(10));panel_1.add(readername);final JLabel label_3=new JLabel();public void actionPerformed(final ActionEvent e){Check validator=new Check(); //校验类String id=read_id.getText().trim();Vector v1=new Vector();v1.clear();v1.add("reader"); //读取配置文件中相应的查询语句v1.add(id);if(l==validator.Validate(V1)) //检查是否存在该读者{JOptionPane.showMessageDialog(null,"添加失败,该读者编号已存在!");}else{Inti=Business.InsertReader(readername.getText().trim(),sex.trim(),age.getText().trim(),zjnumber.get Text().trim(),Date.valueOf(date.getText().trim()),maxnumber.getText().trim().tel.getText().trim(),Double.v alueof(keepmoney.getText().trim()),zj,zy.getText().trim(),Date.valueOf(bztime.getText().trim()),read_id.getText().trim());if(i==1){JOptionPane.showMessageDialog(null,"添加成功!");doDefaultCloseAction();}}}}class TelListener extends KeyAdapter{public void keyTyped(KeyEvent e){if(numStr.indexOf(e.getKeyChar())<0){e.consume();}}}//添加“关闭”按钮的事件监听器class CloseActionListener implements ActionListener{public void actionPerformed(final ActionEvent e){doDefaultCloseAction();}}private String[] columnNames("名称","性别","年龄","证件号码","借书证有效日期","借private String[] array=new String[]{"身份证","军人证","学生证"};String id;private Object[][] getFileStates(List list){Object[][]results=new Object[list.size()][columnNames.length];for(int i=0;i<list.size();i++){Reader reader=(Reader)list.get(i);result[i][0]=reader.getName(); //定义二维数组String sex;if(reader.getSex().equals("1")){sex="男";}else{sex="女";}results[i][1]=sex; //读取读者歌属性值results[i][2]=reader.getAge();results[i][3]=reader.getIdentityCard();results[i][4]=reader.getDate();results[i][5]=reader.getMaxNum();results[i][6]=reader.getTel();results[i][7]=reader.getKeepMoney();results[i][8]=array[reader.getZj()];results[i][9]=reader.getZy();results[i][10]=reader.getBook_id();results[i][11]=reader.getBZtime();}return results;}//图书类别管理//添加图书信息utton.addActionListener(new ActionListener(){public void actionPerformed(final ActionEvent e){if(bookTypeName.getText().length()==0){JOptionPane.showMMessageDialog(null,"图书类别文本框不可为空");return;}if(days.getText().length()==0){return;}if(!check.isNumeric(days.getText().trim())){JOptionPane.showMessageDialog(null,"可借天数必须为数字");return;}if(fakuan.getText().length()==0){JOptionPane.showMessageDialog(null,"罚款文本框不可为空");return;}if(!check.isNumeric(fakuan.getText().trim())){JOptionPane.showMessageDialog(null,"罚款必须为数字");return;}if(i==1){JOptionPane.showMessageDialog(null,"添加成功!");doDefaultCloseAction();}}});panel_6.add(button);final JButton buttonDel=new JButton();buttonDel.setText("关闭");buttonDel.addActionListener(new ActionListener(){public void actionPerformed(final ActionEvent e){doDefaultCloseAction();}});panel_6.add(buttonDel);setVisibel(true);}//修改图书类class ButtonAddListener implements ActionListener{public void actionPerformed(ActionEvent e){Object selectedItem=bookTypeModel.getSelectedItem();inti=Business.UpdatebookType(BookTypeId.getText().trim(),selectedItem.toString(),days.getText().t rim(),fk.getText().trim());if(i==1){JOptionPane.showMessageDialog(null,"修改成功");model.setDataVector(results.columnNames);table.setModel(model);}}}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
scanf("%d",&book[i].turefalse);
fp=fopen("C:\\book.txt","a+");
fwrite(&book[i],sizeof(struct book),1,fp);
fclose(fp);
}
/************************************** 一(2) 查书 ****************************************/
case '2':system_edition();break;
case '0': system("cls");window_display();window_choice();break;
}
}
/***************************************** 加书 **********************************/
window_display()
{
printf("\n");
printf(" 图书管理系统\n");
printf("\n");
printf("\n");
printf(" 1: 图书管理\n");
}
}
book_manage()
{
char manage_choice;
system("cls");
printf("\n");
printf(" 这里是图书管理板块 \n");
printf("\n");
printf("\n");
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#include<fcntl.h>
#define STACK_INIT_SIZE 10
#define OK 1
#define TRUE 1
#define FALSE 0
#define ERROR 0
struct student /*学生 的 卡号 已借的书 */
{
int carnum;
char lendbook[10];
}
student[1000];
struct book /*书的编号 书名 状态 */
printf("\n");
printf(" 请您选择 \n");
scanf("%s",&choic);
switch(choic)
{
case '1':card_add();break;
case '2':book_lend();;break;
printf(" 请您输入这本书的书名\n");
scanf("%s",&book[i].bookname);
printf(" 请您设置书的状态 1表示没有人借 0表示已经借出\n");
}
}
book_lend_return()
{
char choic;
system("cls");
printf(" 这里是图书借还板块 \n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" 请您选择 \n");
scanf("%s",&manage_choice);
switch(manage_choice)
{
case '1':book_add();;break;
{
int booknum;
char bookname[10];
int turefalse;
}book[1000];
struct card /*卡的编号 对应的学生名字 班级*/
{
int cardnum;
char studentname[10];
}
card[100];
book_add();
book_search();
int panduan();
book_change();
book_delect();
card_add();
book_lend();
book_history() ;
system_about();
system_edition();
printf(" 2:图书借还 \n");
printf(" 3: 系统帮助 \n");
printf(" 4: 退出系统 \n");
{
if(bookmum==book[i].booknum)
{ printf("您输入的编号重复 请重新输入\n");
panduan();
}
}
retu FILE *fp;
int panduan()
{
int bookmum,i=0;
FILE *fp=fopen("C:\\book.txt","a+");
scanf("%d",&bookmum);
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
int bookmum=0;
int i=0,j=0;
system("cls");
printf(" \n");
printf(" 请您输入这本书的编号\n");
bookmum=panduan();
book[i].booknum=bookmum;
book_search()
{
FILE *fp;
char bookname[10];
int i;
system("cls");
fp=fopen("C:\\book.txt","r");
printf("\n");
printf(" 请输入你要查找的书名\n");
}
/******************************************* 主界面 选项子函数 ************************************************/
window_choice()
{
char choice1;
window_display();
book_manage();
book_lend_return();
system_help();
window_choice();
system_exit();
book_return();
/****************************************** 主函数 *******************************************/
printf("\n");
printf("\n");
printf(" 1 办卡 2借书 3 还书 4 历史 0返回 \n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
{
char choice_help;
system("cls");
printf(" \n");
printf(" 这里是系统帮助板块 \n");
printf("\n");
printf("\n");
printf("\n");
scanf("%s",&choice1);
switch(choice1)
{
case '1':book_manage();break;
case '2':book_lend_return();break;
case '3':system_help();break;
case '4':system_exit();break;
void main()
{
window_display();
window_choice();
}
/******************************** 主界面 显示子函数***************************************/
相关文档
最新文档