很好的图书管理系统设计
部分源代码: Private Sub Command1_Click() Dim sql As String Dim param As ADODB.Parameter Dim cmd As ADODB.Command Set cmd = New ADODB.Command Set param = New ADODB.Parameter sql = "select * from book where [图书编码]= ? " If Command1.Caption = "添加记录" Then Command1.Caption = "确 定" Command2.Enabled = False '屏蔽删除、修改、下一记录、上一记录按钮,避免出现数据库错误 Command3.Enabled = False Command4.Enabled = False cmdmodify.Enabled = False rst.AddNew Else If Text1.Text = "" Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "图书编号不能为空!" Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" Exit Sub End If With param .Direction = adParamInput .Type = adBSTR .Size = 8 .Value = Text1.Text End With cmd.Parameters.Append param cmd.CommandText = sql cmd.CommandType = adCmdText Set cmd.ActiveConnection = con Set rst1 = cmd.Execute If rst1.RecordCount > 0 Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "此书号已经存在!" rst.Cancel Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True cmdmodify.Enabled = True Command1.Caption = "添加记录" Command2.Enabled = True Exit Sub End If rst.Update Command2.Enabled = True '数据库更新结束后才可以点击其他几个按钮 Command3.Enabled = True Command4.Enabled = True cmdmodify.Enabled = True Command1.Caption = "添加记录" End If End Sub 修改图书记录操作 Private Sub cmdmodify_Click() '修改记录按钮 Dim sqlstr As String Dim rst1 As New ADODB.Recordset Dim param As ADODB.Parameter Dim cmd As ADODB.Command Set cmd = New ADODB.Command Set param = New ADODB.Parameter sqlstr = "select * from book where [图书编码]= '" & Trim(Text1.Text) & "'" With param .Direction = adParamInput .Type = adBSTR .Size = 8 .Value = Text1.Text End With cmd.Parameters.Append param cmd.CommandText = sqlstr cmd.CommandType = adCmdText Set cmd.ActiveConnection = con Set rst1 = cmd.Execute If rst1.RecordCount > 0 Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "此书号已经存在!" rst.Cancel Exit Sub End If rst.Update frmMsg.Show frmMsg.info.Visible = True frmMsg.Text1.Text = "修改成功!" End Sub 添加职工信息 Private Sub Command1_Click() '添加记录 Dim sql As String Dim param As ADODB.Parameter Dim cmd As ADODB.Command Set cmd = New ADODB.Command Set param = New ADODB.Parameter sql = "select * from worker where [工号]= ? " If Command1.Caption = "添加记录" Then Command1.Caption = "确 定" Command2.Enabled = False Command3.Enabled = False Command4.Enabled = False rst.AddNew Else If Text1.Text = "" Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "职工编号不能为空!" Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" Exit Sub End If With param .Direction = adParamInput .Type = adBSTR .Size = 8 .Value = Text1.Text End With cmd.Parameters.Append param cmd.CommandText = sql cmd.CommandType = adCmdText Set cmd.ActiveConnection = con Set rst1 = cmd.Execute '检测职工编号是否存在防止主键冲突 If rst1.RecordCount > 0 Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "此职工编号已经存在!" rst.Cancel Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" Exit Sub End If rst.Update Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" End If End Sub
- 1
- 粉丝: 0
- 资源: 2
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Node-Red语音识别节点microphone
- YOLOv6-main.zip
- 【Unity 3D 模型资源包】Stylized Viking Hut 快速创建维京风格环境或建筑
- 鸿蒙HarmonyOS端云一体化开发实践视频.zip
- 5号任浩宇,创新创业作业.docx
- 【Unity对话和任务管理插件】Dialogue and Quests 灵活的对话系统,轻松创建对话
- k8s命令详细教程大大是的
- 基于Java的运动赛事管理系统
- 【Unity 资源管理插件】Asset Inventory 2 高效组织、搜索、管理各种资源,提高工作效率
- 【 Unity网格优化插件】MeshFusion Pro: Ultimate Optimization Tool 优化 3D 模