frmBooktype1.frm
资源名称:图书馆管理系统11.rar [点击查看]
上传用户:wang_li173
上传日期:2007-06-22
资源大小:43k
文件大小:7k
源码类别:
系统设计方案
开发平台:
Visual Basic
- VERSION 5.00
- Begin VB.Form frmBooktype1
- Caption = "书籍类别"
- ClientHeight = 3804
- ClientLeft = 48
- ClientTop = 348
- ClientWidth = 3108
- LinkTopic = "Form1"
- ScaleHeight = 3804
- ScaleWidth = 3108
- StartUpPosition = 2 'CenterScreen
- Begin VB.CommandButton cmdSave
- Caption = "保存 (&S)"
- Height = 375
- Left = 240
- TabIndex = 9
- Top = 3240
- Width = 1215
- End
- Begin VB.CommandButton cmdExit
- Caption = "返回 (&X)"
- Height = 375
- Left = 1560
- TabIndex = 8
- Top = 3240
- Width = 1215
- End
- Begin VB.Frame Frame1
- Caption = "书籍类别:"
- Height = 2892
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 2772
- Begin VB.TextBox txtItem
- Height = 1080
- Index = 3
- Left = 240
- MaxLength = 20
- TabIndex = 10
- Top = 1680
- Width = 2292
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 2
- Left = 1320
- MaxLength = 20
- TabIndex = 3
- Top = 1080
- Width = 1212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 1
- Left = 1320
- MaxLength = 20
- TabIndex = 2
- Top = 720
- Width = 1212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 0
- Left = 1320
- MaxLength = 8
- TabIndex = 1
- Top = 360
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "关键词:"
- Height = 255
- Index = 16
- Left = 240
- TabIndex = 7
- Top = 1080
- Width = 975
- End
- Begin VB.Label Label2
- Caption = "类别名称:"
- Height = 255
- Index = 1
- Left = 240
- TabIndex = 6
- Top = 720
- Width = 975
- End
- Begin VB.Label Label2
- Caption = "类别编号:"
- Height = 255
- Index = 0
- Left = 240
- TabIndex = 5
- Top = 360
- Width = 975
- End
- Begin VB.Label Label2
- Caption = "备注信息:"
- Height = 252
- Index = 7
- Left = 240
- TabIndex = 4
- Top = 1440
- Width = 972
- End
- End
- End
- Attribute VB_Name = "frmBooktype1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- '是否改动过记录,ture为改过
- Dim mblChange As Boolean
- Dim mrc As ADODB.Recordset
- Public txtSQL As String
- Private Sub cmdExit_Click()
- If mblChange And cmdSave.Enabled Then
- If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
- '保存
- Call cmdSave_Click
- End If
- End If
- Unload Me
- End Sub
- Private Sub cmdSave_Click()
- Dim intCount As Integer
- Dim sMeg As String
- Dim MsgText As String
- For intCount = 0 To 3
- If Trim(txtItem(intCount) & " ") = "" Then
- Select Case intCount
- Case 0
- sMeg = "类别编号"
- Case 1
- sMeg = "类别名称"
- Case 2
- sMeg = "关键词"
- Case 3
- sMeg = "备注信息"
- End Select
- sMeg = sMeg & "不能为空!"
- MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
- txtItem(intCount).SetFocus
- Exit Sub
- End If
- Next intCount
- '添加判断是否有相同的ID记录
- If gintBTmode = 1 Then
- txtSQL = "select * from booktype where booktypeno = '" & Trim(txtItem(0)) & "'"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- If mrc.EOF = False Then
- MsgBox "已经存在此类别编号的记录!", vbOKOnly + vbExclamation, "警告"
- txtItem(0).SetFocus
- Exit Sub
- End If
- mrc.Close
- End If
- '判断是否有相同内容的记录
- txtSQL = "select * from booktype where booktypeno <>'" & Trim(txtItem(0)) & "' and typename='" & Trim(txtItem(1)) & "'"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- If mrc.EOF = False Then
- MsgBox "已经存在相同书籍类别的记录!", vbOKOnly + vbExclamation, "警告"
- txtItem(1).SetFocus
- Exit Sub
- End If
- '先删除已有记录
- If gintBTmode = 2 Then
- txtSQL = "delete from booktype where booktypeno ='" & Trim(txtItem(0)) & "'"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- End If
- '再加入新记录
- txtSQL = "select * from booktype"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- mrc.AddNew
- For intCount = 0 To 3
- mrc.Fields(intCount) = Trim(txtItem(intCount))
- Next intCount
- mrc.Update
- mrc.Close
- If gintBTmode = 1 Then
- MsgBox "添加记录成功!", vbOKOnly + vbExclamation, "添加记录"
- For intCount = 0 To 3
- txtItem(intCount) = ""
- Next intCount
- mblChange = False
- If flagBTedit Then
- Unload frmBooktype
- frmBooktype.txtSQL = "select * from booktype"
- frmBooktype.Show
- End If
- ElseIf gintBTmode = 2 Then
- Unload Me
- If flagBTedit Then
- Unload frmBooktype
- End If
- frmBooktype.txtSQL = "select * from booktype"
- frmBooktype.Show
- End If
- End Sub
- Private Sub Form_Load()
- Dim intCount As Integer
- Dim MsgText As String
- Dim i As Integer
- If gintBTmode = 1 Then
- Me.Caption = Me.Caption & "添加"
- ElseIf gintBTmode = 2 Then
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- If mrc.EOF = False Then
- With mrc
- For intCount = 0 To 3
- txtItem(intCount) = .Fields(intCount)
- Next intCount
- End With
- txtItem(0).Enabled = False
- End If
- Me.Caption = Me.Caption & "修改"
- End If
- mblChange = False
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- gintBTmode = 0
- End Sub
- Private Sub txtItem_Change(Index As Integer)
- '有变化设置gblchange
- mblChange = True
- End Sub
- Private Sub txtItem_GotFocus(Index As Integer)
- txtItem(Index).SelStart = 0
- txtItem(Index).SelLength = Len(txtItem(Index))
- End Sub
- Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
- EnterToTab KeyCode
- End Sub