图书管理系统ER图-流程图-功能结构图-源代码 第12页
frmmodifyreaderstyle.Show
End Sub
3、文件名 frmaddbookstyle(frmbookstyle.frm)
功能说明:用于添加图书类别信息。
源代码:
Option Explicit
Private Sub Command1_Click()
Dim rs_bookstyle As New ADODB.Recordset
Dim sql As String
If Trim(Text1.Text) = "" Then
MsgBox "图书种类不能为空", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "种类编号不能为空", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Exit Sub
End If
sql = "select * from 图书类别 where 类别名称='" & Text1.Text & "'"
rs_bookstyle.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_bookstyle.EOF Then
rs_bookstyle.AddNew
rs_bookstyle.Fields(0) = Trim(Text1.Text)
rs_bookstyle.Fields(1) = Trim(Text2.Text)
rs_bookstyle.Update
MsgBox "添加图书类别成功!", vbOKOnly, ""
rs_bookstyle.Close
Else
MsgBox "读者类别重复!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Text1.Text = ""
rs_bookstyle.Close
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
4、文件名 frmmodifybookstyle(code)
功能说明:图书类别管理,可以修改和删除图书类别。
源代码:
Option Explicit
Dim rs_reader As New ADODB.Recordset
Private Sub cmdcancel_Click()
rs_reader.CancelUpdate
DataGrid1.Refresh
DataGrid1.AllowAddNew = False
DataGrid1.AllowUpdate = False
cmdmodify.Enabled = True
cmddel.Enabled = True
cmdcancel.Enabled = False
cmdupdate.Enabled = False
End Sub
Private Sub cmddel_Click()
Dim answer As String
On Error GoTo delerror
answer = MsgBox("确定要删除吗?", vbYesNo, "")
If answer = vbYes Then
DataGrid1.AllowDelete = True
rs_reader.Delete
rs_reader.Update
DataGrid1.Refresh
MsgBox "成功删除!", vbOKOnly + vbExclamation, ""
DataGrid1.AllowDelete = False
Else
Exit Sub
End If
delerror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub cmdmodify_Click()
Dim answer As String
On Error GoTo cmdmodify
cmddel.Enabled = False
cmdmodify.Enabled = False
cmdupdate.Enabled = True
cmdcancel.Enabled = True
DataGrid1.AllowUpdate = True
cmdmodify:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub Command5_Click()
rs_reader.Update
DataGrid1.Refresh
End Sub
Private Sub cmdupdate_Click()
If Not IsNull(DataGrid1.Bookmark) Then
rs_reader.Update
End If
cmdmodify.Enabled = True
cmddel.Enabled = True
cmdcancel.Enabled = False
cmdupdate.Enabled = False
DataGrid1.AllowUpdate = False
MsgBox "保存成功!", vbOKOnly + vbExclamation, ""
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim sql As String
On Error GoTo loaderror
sql = "select * from 图书类别"
rs_reader.CursorLocation = adUseClient
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库
cmdupdate.Enabled = False
'设定datagrid控件属性
DataGrid1.AllowAddNew = False '不可增加
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] 下一页