📄 frmbookbuy.frm
字号:
Width = 1695
End
Begin MSComCtl2.DTPicker DTPickerdgrq
Height = 255
Left = 3840
TabIndex = 5
Top = 240
Width = 1695
_ExtentX = 2990
_ExtentY = 450
_Version = 393216
Format = 25559041
CurrentDate = 39593
End
Begin VB.TextBox ddh
Height = 270
Left = 840
TabIndex = 2
Top = 240
Width = 1695
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H80000013&
BackStyle = 0 'Transparent
Caption = "*"
ForeColor = &H000000FF&
Height = 180
Index = 5
Left = 2640
TabIndex = 35
Top = 2400
Width = 90
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H80000013&
BackStyle = 0 'Transparent
Caption = "*"
ForeColor = &H000000FF&
Height = 180
Index = 4
Left = 5640
TabIndex = 34
Top = 2040
Width = 90
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H80000013&
BackStyle = 0 'Transparent
Caption = "*"
ForeColor = &H000000FF&
Height = 180
Index = 3
Left = 5640
TabIndex = 33
Top = 600
Width = 90
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H80000013&
BackStyle = 0 'Transparent
Caption = "*"
ForeColor = &H000000FF&
Height = 180
Index = 2
Left = 2640
TabIndex = 32
Top = 600
Width = 90
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H80000013&
BackStyle = 0 'Transparent
Caption = "*"
ForeColor = &H000000FF&
Height = 180
Index = 1
Left = 5640
TabIndex = 31
Top = 240
Width = 90
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H80000013&
BackStyle = 0 'Transparent
Caption = "*"
ForeColor = &H000000FF&
Height = 180
Index = 0
Left = 2640
TabIndex = 30
Top = 240
Width = 90
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "I S B N:"
Height = 180
Index = 13
Left = 3000
TabIndex = 28
Top = 2400
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "数 量:"
Height = 180
Index = 12
Left = 120
TabIndex = 26
Top = 2400
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "订购价格:"
Height = 180
Index = 11
Left = 3000
TabIndex = 24
Top = 2040
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "出版社:"
Height = 180
Index = 10
Left = 120
TabIndex = 22
Top = 2040
Width = 630
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "出版地址:"
Height = 180
Index = 9
Left = 3000
TabIndex = 20
Top = 1680
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "译 者:"
Height = 180
Index = 8
Left = 120
TabIndex = 18
Top = 1680
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "作 者:"
Height = 180
Index = 7
Left = 3000
TabIndex = 16
Top = 1320
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "类别编号:"
Height = 180
Index = 6
Left = 120
TabIndex = 14
Top = 1320
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "图书编号:"
Height = 180
Index = 5
Left = 3000
TabIndex = 12
Top = 960
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "图书类别:"
Height = 180
Index = 4
Left = 120
TabIndex = 10
Top = 960
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "图书名称:"
Height = 180
Index = 3
Left = 3000
TabIndex = 8
Top = 600
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "订购人:"
Height = 180
Index = 2
Left = 120
TabIndex = 6
Top = 600
Width = 630
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "订购日期:"
Height = 180
Index = 1
Left = 3000
TabIndex = 4
Top = 240
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "订单号:"
Height = 180
Index = 0
Left = 120
TabIndex = 1
Top = 240
Width = 630
End
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "图书订购信息"
BeginProperty Font
Name = "隶书"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 2280
TabIndex = 3
Top = 0
Width = 2700
End
End
Attribute VB_Name = "frmBooksBuy"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'****************************************************************************
' 作者:叶和平
' 名称:frmBooksBuy
' 功能:图书订购
'****************************************************************************
Private Sub cmdAdd_Click()
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from books_buy"
Dim sql2 As String
sql2 = "select * from books_buy where ddh ='" & ddh.Text & "'"
If Trim(ddh.Text) = "" Then
MsgBox "订单号不能为空!", vbOKOnly
ElseIf Trim(DTPickerdgrq.Value) = "" Then
MsgBox "订购日期不能为空!", vbOKOnly
ElseIf Trim(dgr.Text) = "" Then
MsgBox "订购人不能为空!", vbOKOnly
ElseIf Trim(tsmc.Text) = "" Then
MsgBox "图书名称不能为空!", vbOKOnly
ElseIf Trim(dgjg.Text) = "" Then
MsgBox "订购价格不能为空!", vbOKOnly
ElseIf Trim(sl.Text) = "" Then
MsgBox "数量不能为空!", vbOKOnly
Else
Set rs = ADOSQL(sql2)
If rs.EOF = False Then
MsgBox "该订单号已经存在,请核对!", vbOKOnly
rs.Close
Else
Set rs = ADOSQL(sql)
rs.AddNew '添加新纪录
rs.Fields(0) = Trim(ddh.Text)
rs.Fields(1) = Trim(DTPickerdgrq.Value)
rs.Fields(2) = Trim(dgr.Text)
rs.Fields(3) = Trim(tsmc.Text)
rs.Fields(4) = Trim(tslbcomb.Text)
rs.Fields(5) = Val(tsbh.Text)
rs.Fields(6) = Val(lbbh.Text)
rs.Fields(7) = Trim(zz.Text)
rs.Fields(8) = Trim(yz.Text)
rs.Fields(9) = Trim(cbsdz.Text)
rs.Fields(10) = Trim(cbs.Text)
rs.Fields(11) = Val(dgjg.Text)
rs.Fields(12) = Val(sl.Text)
rs.Fields(13) = Val(isbn.Text)
rs.Update
MsgBox "读者添加成功!", vbOKOnly
rs.Close
DataGrid1.Refresh
End If
End If
End Sub
Private Sub cmdCancel_Click() '退出
Unload Me
End Sub
Private Sub cmdClear_Click() '清除记录
ddh.Text = ""
DTPickerdgrq.Value = Date
dgr.Text = ""
tsmc.Text = ""
tslbcomb.Text = "请选择图书类别"
tsbh.Text = ""
lbbh.Text = ""
zz.Text = ""
yz.Text = ""
cbsdz.Text = ""
cbs.Text = ""
dgjg.Text = ""
sl.Text = ""
isbn.Text = ""
ddh.SetFocus
End Sub
Private Sub cmdDelete_Click() '删除记录
Dim rs_del As New ADODB.Recordset
Dim sql_del As String
sql_del = "select * from books_buy where ddh='" & ddh.Text & "'"
Set rs_del = ADOSQL(sql_del)
If ddh.Text = "" Then
MsgBox "请在订单号里输入要删除的订单号!"
ddh.SetFocus
Exit Sub
End If
If rs_del.EOF Then
MsgBox "该订单号已经不存在!"
Exit Sub
Else
sql_del = "delete from books_buy where ddh='" & ddh.Text & "'"
Set rs_del = ADOSQL(sql_del)
MsgBox "删除成功!"
Exit Sub
End If
rs_del.Close
DateGrid1.Refresh
Unload Me
End Sub
Private Sub Form_Load()
'为图书类别添加值
sql_lb = "select lbmc from book_category"
Set rs_lb = ADOSQL(sql_lb)
While Not rs_lb.EOF
tslbcomb.AddItem rs_lb(0)
rs_lb.MoveNext
Wend
'初始化记录
ddh.Text = ""
DTPickerdgrq.Value = Date
dgr.Text = ""
tsmc.Text = ""
tslbcomb.Text = "请选择图书类别"
tsbh.Text = ""
lbbh.Text = ""
zz.Text = ""
yz.Text = ""
cbsdz.Text = ""
cbs.Text = ""
dgjg.Text = ""
sl.Text = ""
isbn.Text = ""
'显示图书订购信息
Adodc1.RecordSource = "select * from books_buy where ddh='" & ddh.Text & "'"
'Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
DataGrid1.Refresh
End If
End Sub
'判断输入的值是否为数值
Private Sub ddh_Change()
If Not IsNumeric(ddh.Text) And ddh.Text <> "" Then
MsgBox "只能输入数值!如:000001", vbCritical + vbOKOnly, "错误"
ddh.Text = Val("")
End If
End Sub
Private Sub dgjg_Change()
If Not IsNumeric(dgjg.Text) And dgjg.Text <> "" Then
MsgBox "只能输入数值!", vbCritical + vbOKOnly, "错误"
dgjg.Text = Format(Val(""), "0.00")
End If
End Sub
Private Sub sl_Change()
If Not IsNumeric(sl.Text) And sl.Text <> "" Then
MsgBox "只能输入数值!", vbCritical + vbOKOnly, "错误"
sl.Text = Val("")
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -