📄 frmaddbook.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmaddbook
Caption = "添加新书"
ClientHeight = 6120
ClientLeft = 60
ClientTop = 345
ClientWidth = 9225
ControlBox = 0 'False
LinkTopic = "Form1"
ScaleHeight = 6120
ScaleWidth = 9225
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "关 闭"
Height = 375
Left = 7440
TabIndex = 21
Top = 5640
Width = 1335
End
Begin VB.Frame Frame2
Height = 2415
Left = 240
TabIndex = 19
Top = 3000
Width = 8655
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "frmaddbook.frx":0000
Height = 2055
Left = 120
TabIndex = 20
Top = 240
Width = 8415
_ExtentX = 14843
_ExtentY = 3625
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Begin MSAdodcLib.Adodc Adodc2
Height = 495
Left = 240
Top = 5520
Visible = 0 'False
Width = 1935
_ExtentX = 3413
_ExtentY = 873
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=BOOK;Data Source=MRSX05"
OLEDBString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=BOOK;Data Source=MRSX05"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from addnewbook"
Caption = "Adodc2"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.TextBox Text4
Height = 270
Left = 1680
TabIndex = 17
Top = 1560
Width = 2295
End
Begin MSAdodcLib.Adodc Adodc1
Height = 450
Left = 2280
Top = 5520
Visible = 0 'False
Width = 1935
_ExtentX = 3413
_ExtentY = 794
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=BOOK;Data Source=MRSX05"
OLEDBString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=BOOK;Data Source=MRSX05"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from lbtb"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "删 除"
Height = 375
Left = 6000
TabIndex = 16
Top = 5640
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "保 存"
Height = 375
Left = 4560
TabIndex = 15
Top = 5640
Width = 1455
End
Begin VB.Frame Frame1
Caption = "书籍信息"
Height = 2655
Left = 120
TabIndex = 0
Top = 240
Width = 8655
Begin VB.TextBox Text7
Height = 270
Left = 1560
TabIndex = 23
Top = 2280
Width = 2295
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 255
Left = 1560
TabIndex = 14
Top = 1800
Width = 2295
_ExtentX = 4048
_ExtentY = 450
_Version = 393216
Format = 24707073
CurrentDate = 38309
End
Begin VB.TextBox Text6
Height = 270
Left = 5400
TabIndex = 13
Top = 1800
Width = 2295
End
Begin VB.TextBox Text5
Height = 270
Left = 5400
TabIndex = 12
Top = 1320
Width = 2295
End
Begin VB.TextBox Text3
Height = 270
Left = 5400
TabIndex = 11
Top = 840
Width = 2295
End
Begin VB.ComboBox Combo1
Height = 300
Left = 5400
TabIndex = 10
Top = 360
Width = 2295
End
Begin VB.TextBox Text2
Height = 270
Left = 1560
TabIndex = 9
Top = 840
Width = 2295
End
Begin VB.TextBox Text1
Height = 270
Left = 1560
TabIndex = 8
Top = 345
Width = 2295
End
Begin VB.Label Label9
Caption = "规定天数:"
Height = 255
Left = 600
TabIndex = 22
Top = 2280
Width = 975
End
Begin VB.Label Label7
Caption = "登记日期:"
Height = 255
Left = 600
TabIndex = 18
Top = 1800
Width = 975
End
Begin VB.Label Label8
Caption = "书籍价格:"
Height = 255
Left = 4320
TabIndex = 7
Top = 1800
Width = 975
End
Begin VB.Label Label6
Caption = "作者姓名:"
Height = 255
Left = 4320
TabIndex = 6
Top = 1320
Width = 975
End
Begin VB.Label Label5
Caption = "出 版 社:"
Height = 255
Left = 600
TabIndex = 5
Top = 1320
Width = 975
End
Begin VB.Label Label4
Caption = "书籍名称:"
Height = 255
Left = 4320
TabIndex = 4
Top = 800
Width = 975
End
Begin VB.Label Label3
Caption = "类别编号:"
Height = 255
Left = 600
TabIndex = 3
Top = 800
Width = 975
End
Begin VB.Label Label2
Caption = "书籍类别:"
Height = 255
Left = 4320
TabIndex = 2
Top = 360
Width = 975
End
Begin VB.Label Label1
Caption = "书籍编号:"
Height = 255
Left = 600
TabIndex = 1
Top = 360
Width = 975
End
End
End
Attribute VB_Name = "frmaddbook"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cn1 As ADODB.Connection
Dim rs1 As ADODB.Recordset
Private Sub Combo1_Click()
Adodc1.RecordSource = "select * from lbtb where 书籍类别='" & Trim(Combo1.Text) & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Text2.Text = Adodc1.Recordset.Fields(0)
Text7.Text = Adodc1.Recordset.Fields(2)
End If
End Sub
Private Sub Command1_Click()
Dim tj, i As String
i = MsgBox("是否修记此条记录!", vbYesNo + vbOKOnly, "提示")
If i = vbYes Then
tj = "insert into addnewbook values('" & Text1 & "','" & Combo1 & "','" & Text2 & "','" & Text3 & "','" & Text4 & "','" & Text5 & "','" & DTPicker1 & "','" & Text6 & "','" & Text7 & "')"
cn.Execute (tj)
clear
DataGrid1.Refresh
Adodc2.Refresh
Else
Adodc2.Recordset.CancelUpdate
End If
End Sub
Private Sub Command2_Click()
Adodc2.Recordset.Delete
MsgBox "删除成功!", vbOKOnly
DataGrid1.Refresh
Adodc2.Refresh
End Sub
Private Sub Command3_Click()
Me.Hide
End Sub
Private Sub Form_Load()
Dim i As Integer
Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=BOOK;Data Source=MRSX05"
Set rs = New ADODB.Recordset
rs.Open "lbtb", cn, adOpenStatic, adLockOptimistic, adCmdTable
Set cn1 = New ADODB.Connection
cn1.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=BOOK;Data Source=MRSX05"
Set rs1 = New ADODB.Recordset
rs1.Open "addnewbook", cn, adOpenStatic, adLockOptimistic, adCmdTable
rec = rs.RecordCount
ReDim Asc(rec - 1)
rs.MoveFirst
For i = 1 To rec
Combo1.AddItem rs.Fields("书籍类别")
Asc(i - 1) = Val(rs.Fields(2))
rs.MoveNext
If rs.EOF Then Exit For
Next
Text2.Enabled = False
End Sub
Private Sub Text1_LostFocus()
Adodc1.RecordSource = "select * from addnewbook where 书籍编号='" & Trim(Text1.Text) & "'"
Adodc1.Refresh
On Error Resume Next
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "书籍编号已经存在,请换其它编号!", vbOKOnly, "提示"
Text1.Text = ""
Text1.SetFocus
End If
End Sub
Sub clear()
Text1.Text = ""
Combo1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -