图书管理系统 源程序代码.doc
《图书管理系统 源程序代码.doc》由会员分享,可在线阅读,更多相关《图书管理系统 源程序代码.doc(25页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1:登录窗口代码:Option ExplicitDim X As Integer 保存密码输入错误次数Public tempname As StringPrivate Sub cmdOK_Click() Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Dim strcon As String Dim sql As String Set cn = CreateObject(adodb.connection) Set rs = CreateObject(adodb.recordset) strcon = Provider=MSDASQL.1
2、;Persist Security Info=False;Data Source=图书销售系统 cn.Open strcon 游客登录 If Combo1.Text = 游客 Then 主窗体.tsgl.Visible = False 主窗体.yhgl.Visible = False 主窗体.gwtd.Visible = False 主窗体.kuc.Visible = False 主窗体.glyzc.Visible = False 主窗体.tshj.Enabled = True 主窗体.Toolbar1.Buttons(1).Visible = False 主窗体.Toolbar1.Butto
3、ns(2).Visible = False 主窗体.Toolbar1.Buttons(3).Visible = False 主窗体.Toolbar1.Buttons(4).Visible = False 主窗体.Toolbar1.Buttons(5).Visible = False Unload Me 主窗体.Show Exit Sub End If非游客用户登录If Trim(Text1.Text) = Or Trim(Text2.Text) = Then 判断user_ID不能为空 MsgBox 用户登录信息未完整填写,请重新输入! Text1.SetFocusElse If Combo1
4、.Text = 请选择权限 Then 判断登录权限不能为空 MsgBox 请选择权限, vbOKOnly + vbExclamation, 警告 Combo1.SetFocus Exit Sub ElseIf Combo1.Text = 管理员 Then 管理员登录 userleibie = 管理员 username = Text1.Text sql = select * from 管理员 where user_ID= & Trim(Text1.Text) & 由管理员表中查询是否存在 rs.Open sql, cn, adOpenKeyset, adLockPessimistic If rs
5、.EOF = True Then MsgBox 没有这个用户,请重输入!, vbOKOnly + vbExclamation, 警告 Text1.Text = Text2.Text = Text1.SetFocus Exit Sub Else 主窗体管理员权限开放 主窗体.tsgl.Enabled = True 主窗体.yhgl.Enabled = True 主窗体.tshj.Enabled = True 主窗体.gwtd.Visible = False 主窗体.kuc.Visible = True 主窗体.exit.Enabled = True 主窗体.Toolbar1.Enabled =
6、True 主窗体.Toolbar1.Buttons(4).Visible = False End If ElseIf Combo1.Text = 普通用户 Then 普通用户登录 userleibie = 普通用户 username = Text1.Text sql = select * from 普通用户 where user_ID= & Trim(Text1.Text) & rs.Open sql, cn, adOpenKeyset, adLockPessimistic If rs.EOF = True Then MsgBox 没有这个用户,请重输入!, vbOKOnly + vbExcl
7、amation, 警告 Text1.Text = Text2.Text = Text1.SetFocus Exit Sub Else 主窗体普通用户权限开放 主窗体.tsgl.Visible = False 主窗体.glygl.Visible = False 主窗体.kuc.Visible = False 主窗体.glyzc.Visible = False 主窗体.Toolbar1.Buttons(1).Visible = False 主窗体.Toolbar1.Buttons(2).Visible = False 主窗体.Toolbar1.Buttons(5).Visible = False
8、End If End IfEnd If为非游客登录提供密码认证If Trim(rs.Fields(mima) = Trim(Text2.Text) Then tempname = Trim$(rs.Fields(真实姓名) usereal = tempname 主窗体.Show Unload MeElse If X = 2 Then MsgBox 密码输入超过三次,请联系管理员!, vbOKOnly + vbExclamation, 警告 Unload Me Exit Sub End If MsgBox 密码不正确,请重输入!, vbOKOnly + vbExclamation, 警告 Tex
9、t2.SetFocus Text2.Text = X = X + 1 密码输入错误次数统计End IfEnd IfEnd SubPrivate Sub cmdCancle_Click() Unload MeEnd SubPrivate Sub Command1_Click()userzhuce.Combo1.AddItem 普通用户用户注册.ShowEnd SubPrivate Sub Form_Load()X = 0End Sub2:个人历史消费记录Dim rs_find As New ADODB.RecordsetPrivate Sub Command2_Click()Unload MeE
10、nd SubPrivate Sub Form_Load() Dim cn As ADODB.Connection Dim strcon As String Dim sql As String Set cn = CreateObject(adodb.connection) Set rs_find = CreateObject(adodb.recordset) strcon = Provider=MSDASQL.1;Persist Security Info=False;Data Source=图书销售系统 cn.Open strcon sql = select * from lishi wher
11、e 用户名 = & Trim(username) & rs_find.CursorLocation = adUseClient rs_find.Open sql, cn, adOpenKeyset, adLockPessimistic If rs_find.EOF Then MsgBox 你还没有消费记录,那么赶紧消费吧!Else DataGrid1.AllowAddNew = False DataGrid1.AllowDelete = False DataGrid1.AllowUpdate = False Set DataGrid1.DataSource = rs_find Exit Sub
12、 很重要,要与上句合用,不然,显示不出来 End If rs_find.Close End SubPrivate Sub Form_Unload(Cancel As Integer) Set DataGrid1.DataSource = Nothing rs_find.CloseEnd Sub3:购物车Option ExplicitDim rs As ADODB.RecordsetPrivate Sub Command1_Click()Dim cn As ADODB.Connection Dim strcon As String Dim yi, er, san, si, wu, liu As
13、String Dim qi, n As Integer Dim sql, sqq, sqs, ssq As String Set cn = CreateObject(adodb.connection) Set rs = CreateObject(adodb.recordset) strcon = Provider=MSDASQL.1;Persist Security Info=False;Data Source=图书销售系统 cn.Open strcon yi = Trim(DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark) er = Trim
14、(DataGrid1.Columns(1).CellValue(DataGrid1.Bookmark) san = Trim(DataGrid1.Columns(2).CellValue(DataGrid1.Bookmark) si = Trim(DataGrid1.Columns(3).CellValue(DataGrid1.Bookmark) wu = Trim(DataGrid1.Columns(4).CellValue(DataGrid1.Bookmark) liu = Trim(DataGrid1.Columns(5).CellValue(DataGrid1.Bookmark)qi
15、= Trim(DataGrid1.Columns(6).CellValue(DataGrid1.Bookmark) If Trim(yi) = Then MsgBox 请选择要购买的图书!, vbOKOnly + vbExclamationElseDataGrid1.AllowDelete = TrueDataGrid1.Refresh sqq = insert into lishi values( & & yi & & , & & er & _ & , & & san & & , & & si & & , & & wu _ & & , & & liu & & , & & qi & & )rs
16、.Open sqq, cn, adOpenKeyset, adLockPessimisticsql = select * from linshi where 图书编号= & & yi & & and & 数量= & & qi & rs.Open sql, cn, adOpenKeyset, adLockPessimisticIf rs.EOF Then MsgBox 购物车里的物品已全部购买,请继续其他消费! Unload Me Else DataGrid1.AllowDelete = True rs.Delete rs.Update DataGrid1.Refresh MsgBox 你已成功
17、购买了该图书,请继续购买其他图书!rs.Closessq = select 库存量 from book where 图书编号= & & yi & rs.Open ssq, cn, adOpenKeyset, adLockPessimisticn = Int(Trim(rs.Fields(0)rs.Closesqs = update book set 库存量= & & Int(n - shuliang) & & where 图书编号= & & yi & rs.Open sqs, cn, adOpenKeyset, adLockPessimistic End If End IfEnd SubPri
18、vate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load() Dim cn As ADODB.Connection Dim strcon As String Dim sql As String Set cn = CreateObject(adodb.connection) Set rs = CreateObject(adodb.recordset) strcon = Provider=MSDASQL.1;Persist Security Info=False;Data Source=图书销售系统 cn.Open strcon
19、sql = select * from linshi rs.CursorLocation = adUseClient rs.Open sql, cn, adOpenKeyset, adLockPessimistic If rs.EOF Then MsgBox 你还没有消费记录,那么赶紧消费吧!ElseFrame1.Caption = 欢迎 + Trim(username) + 登录!这是您的购物车! DataGrid1.AllowAddNew = False DataGrid1.AllowDelete = False DataGrid1.AllowUpdate = False Set Data
20、Grid1.DataSource = rs Exit Sub 很重要,要与上句合用,不然,显示不出来 End If End SubPrivate Sub Form_Unload(Cancel As Integer) Set DataGrid1.DataSource = Nothing rs.CloseEnd Sub4:库存Dim rs As ADODB.RecordsetPrivate Sub cmdcancel_Click()rs.CancelUpdate DataGrid1.Refresh DataGrid1.AllowAddNew = False DataGrid1.AllowUpdat
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 图书管理系统 源程序代码 图书 管理 系统 源程序 代码
限制150内