📄 frmbuybook.frm
字号:
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 615
Left = 0
TabIndex = 17
Top = 0
Width = 10395
_ExtentX = 18336
_ExtentY = 1085
ButtonWidth = 1138
ButtonHeight = 926
Appearance = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 10
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "首记录"
Key = "btnFirst"
ImageIndex = 1
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "上记录"
Key = "btnBefore"
ImageIndex = 2
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "下记录"
Key = "btnNext"
ImageIndex = 3
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "尾记录"
Key = "btnLast"
ImageIndex = 4
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "新增"
Key = "btnNew"
ImageIndex = 5
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "修改"
Key = "btnModify"
ImageIndex = 6
EndProperty
BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "删除"
Key = "btnDelete"
ImageIndex = 7
EndProperty
BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Caption = "保存"
Key = "btnSave"
ImageIndex = 8
EndProperty
BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Caption = "取消"
Key = "btnCancel"
ImageIndex = 9
EndProperty
BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "退出"
Key = "btnExit"
ImageIndex = 10
EndProperty
EndProperty
Begin MSComctlLib.ImageList ImageList1
Left = 7440
Top = 0
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 10
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":0457
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":0569
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":067B
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":078D
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":089F
Key = ""
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":09B1
Key = ""
EndProperty
BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":0AC3
Key = ""
EndProperty
BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":0BD5
Key = ""
EndProperty
BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":0CE7
Key = ""
EndProperty
BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmBuyBook.frx":0DF9
Key = ""
EndProperty
EndProperty
End
End
Begin VB.Label Label7
Caption = "说明:填写的的征订记录保存在""图书征订""表中,""是否验收""字段为0(false),单击【提交征订】按钮,调用""sf_图书征订""存储过程处理"
Height = 1335
Left = 8520
TabIndex = 30
Top = 4560
Width = 1815
End
Begin VB.Label Label6
Caption = "图书名称"
Height = 255
Left = 4800
TabIndex = 26
Top = 4440
Width = 735
End
Begin VB.Label Label5
Caption = "图书编号"
Height = 255
Left = 1920
TabIndex = 25
Top = 4440
Width = 855
End
Begin VB.Label Label4
Caption = "征订编号"
Height = 255
Left = 120
TabIndex = 24
Top = 4440
Width = 855
End
Begin VB.Label Label8
Caption = "订购者"
Height = 255
Left = 7320
TabIndex = 23
Top = 4440
Width = 975
End
Begin VB.Label Label9
Caption = "操作员"
Height = 255
Left = 120
TabIndex = 22
Top = 5160
Width = 975
End
Begin VB.Label Label10
Caption = "订购数量"
Height = 255
Left = 2040
TabIndex = 21
Top = 5160
Width = 855
End
Begin VB.Label Label11
Caption = "订购单价"
Height = 255
Left = 3720
TabIndex = 20
Top = 5160
Width = 975
End
Begin VB.Label Label12
Caption = "订购日期"
Height = 255
Left = 5400
TabIndex = 19
Top = 5160
Width = 855
End
Begin VB.Label Label17
Caption = "订购者联系方式"
Height = 255
Left = 6960
TabIndex = 18
Top = 5160
Width = 1455
End
End
Attribute VB_Name = "frmBuyBook"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private bAdd As Boolean
Private Sub LoadData()
Dim strFilter As String
Dim db As New DataBases
Dim rs As Recordset
If Len(Trim(txbOne.Text)) = 0 Then
If Len(Trim(txbTwo.Text)) = 0 Then
If Len(Trim(txbThree.Text)) = 0 Then
strFilter = ""
Else
strFilter = "and 图书名称 like '"
strFilter = strFilter + Trim(txbThree.Text) + "%'"
End If
Else
strFilter = "and 图书编号 like '"
strFilter = strFilter + Trim(txbTwo.Text) + "%'"
If Len(Trim(txbThree.Text)) <> 0 Then
strFilter = strFilter + " and 图书名称 like '"
strFilter = strFilter + Trim(txbThree.Text) + "%'"
End If
End If
Else
strFilter = "where 征订编号 like '"
strFilter = strFilter + Trim(txbOne.Text) + "%'"
If Len(Trim(txbTwo.Text)) <> 0 Then
strFilter = strFilter + " and 图书编号 like '"
strFilter = strFilter + Trim(txbTwo.Text) + "%'"
If Len(Trim(txbThree.Text)) <> 0 Then
strFilter = strFilter + " and 图书名称 like '"
strFilter = strFilter + Trim(txbThree.Text) + "%'"
End If
Else
If Len(Trim(txbThree.Text)) <> 0 Then
strFilter = strFilter + " and 图书名称 like '"
strFilter = strFilter + Trim(txbThree.Text) + "%'"
End If
End If
End If
Set rs = db.RunSelectSQLUpdatable("select * from 图书征订 where 是否验收=0 " + strFilter)
'根据查询条件重新填充DataGrid
Set Adodc1.Recordset = rs
LoadBookName
End Sub
Public Sub LoadBookName()
Dim db As New DataBases
Dim rs As Recordset
Set rs = db.RunSelectSQL("select 书名 from 图书信息 where 编号='" + Trim(txbBookNumber.Text) + "'")
If rs.RecordCount > 0 Then
Me.txbBookName.Text = rs("书名")
End If
End Sub
Private Sub btnOpen_Click()
Dim frm As New frmSelectBook
frm.Show vbModal
End Sub
Private Sub btnSearch_Click()
LoadData
End Sub
Private Sub btnSubmit_Click()
'执行sf_图书征订存储过程
Dim db As New DataBases
db.RunSelectSQL ("exec sf_图书征订")
db.CloseConn
'重新加载数据并显示
LoadData
End Sub
Private Sub Form_Load()
Dim db As New DataBases
Adodc1.ConnectionString = db.sConn
LoadData
SetTextBoxState (False)
End Sub
Private Sub SetToolBarState(ByVal bState As Boolean)
'设置Button的是否能够单击
Toolbar1.Buttons("btnFirst").Enabled = bState
Toolbar1.Buttons("btnBefore").Enabled = bState
Toolbar1.Buttons("btnNext").Enabled = bState
Toolbar1.Buttons("btnLast").Enabled = bState
Toolbar1.Buttons("btnNew").Enabled = bState
Toolbar1.Buttons("btnModify").Enabled = bState
Toolbar1.Buttons("btnDelete").Enabled = bState
Toolbar1.Buttons("btnSave").Enabled = Not bState
Toolbar1.Buttons("btnCancel").Enabled = Not bState
grdDataGrid.Enabled = bState
End Sub
Private Sub SetTextBoxState(ByVal bState As Boolean)
Me.txbNumber.Enabled = bState
Me.txbBookNumber.Enabled = bState
Me.btnOpen.Enabled = bState
Me.txbSubscriber.Enabled = bState
Me.txbWorker.Enabled = bState
Me.txbCount.Enabled = bState
Me.txbPrice.Enabled = bState
Me.txbDate.Enabled = bState
Me.txbContact.Enabled = bState
Me.grdDataGrid.Enabled = Not bState
End Sub
Private Sub Clear()
Dim db As New DataBases
Dim strID As String
Dim strT As String
Dim strSQL As String
Dim rs As Recordset
strSQL = "select max(征订编号) as MaxID from 图书征订"
Set rs = db.RunSelectSQL(strSQL)
If rs.RecordCount <> 0 Then
strT = ""
strID = CStr(CInt(rs(0) + 1))
For i = Len(strID) To 6
strT = strT + "0"
Next i
txbNumber.Text = strT + strID
Else
txbNumber.Text = "0000001"
End If
Me.txbBookNumber.Text = ""
Me.txbSubscriber.Text = ""
Me.txbWorker.Text = ""
Me.txbCount.Text = ""
Me.txbPrice.Text = 0
Me.txbDate.Text = ""
Me.txbContact.Text = ""
Me.txbBookName.Text = ""
End Sub
Private Sub SaveForUpdate()
Adodc1.Recordset.UpdateBatch
End Sub
Private Sub DeleteData()
Adodc1.Recordset.Delete adAffectCurrent
Adodc1.Recordset.UpdateBatch adAffectAll
End Sub
Private Sub SaveForAdd()
Dim db As New DataBases
Dim strSQL As String
strSQL = "insert into 图书征订(征订编号, 图书编号, 订购者, 订购数量, 订购单价, 订购日期, 订购者联系方式, 操作员, 是否验收) values ('"
strSQL = strSQL + Trim(txbNumber.Text) + "','"
strSQL = strSQL + Trim(txbBookNumber.Text) + "','"
strSQL = strSQL + Trim(txbSubscriber.Text) + "','"
strSQL = strSQL + Trim(txbCount.Text) + "',"
strSQL = strSQL + Trim(txbPrice.Text) + ",'"
strSQL = strSQL + Trim(txbDate.Text) + "','"
strSQL = strSQL + Trim(txbContact.Text) + "','"
strSQL = strSQL + Trim(txbWorker.Text) + "',0)"
db.RunSelectSQL (strSQL)
End Sub
Private Sub grdDataGrid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
LoadBookName
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If StrComp(Button.Key, "btnFirst") = 0 Then
Adodc1.Recordset.MoveFirst
ElseIf StrComp(Button.Key, "btnBefore") = 0 Then
Adodc1.Recordset.MovePrevious
ElseIf StrComp(Button.Key, "btnNext") = 0 Then
Adodc1.Recordset.MoveNext
ElseIf StrComp(Button.Key, "btnLast") = 0 Then
Adodc1.Recordset.MoveLast
ElseIf StrComp(Button.Key, "btnNew") = 0 Then
bAdd = True
Adodc1.Recordset.AddNew
SetTextBoxState (True)
SetToolBarState (False)
Clear
ElseIf StrComp(Button.Key, "btnModify") = 0 Then
bAdd = False
SetTextBoxState (True)
SetToolBarState (False)
ElseIf StrComp(Button.Key, "btnDelete") = 0 Then
If MsgBox("确定要删除吗?", vbYesNo) = vbYes Then
DeleteData
End If
ElseIf StrComp(Button.Key, "btnSave") = 0 Then
SetTextBoxState (False)
SetToolBarState (True)
If bAdd = True Then
'为新增数据保存
SaveForAdd
' Adodc1.Recordset.CancelUpdate
Adodc1.Recordset.Requery
Else
'为更新数据保存
SaveForUpdate
End If
ElseIf StrComp(Button.Key, "btnCancel") = 0 Then
Adodc1.Recordset.Requery
SetTextBoxState (False)
SetToolBarState (True)
ElseIf StrComp(Button.Key, "btnExit") = 0 Then
Hide
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -