📄 frmcarwxlr.frm
字号:
Width = 585
End
Begin VB.Label Label9
Caption = "数量:"
Height = 240
Left = 3240
TabIndex = 14
Top = 1110
Width = 585
End
Begin VB.Label Label8
Caption = "数量:"
Height = 240
Left = 3240
TabIndex = 12
Top = 690
Width = 585
End
Begin VB.Label Label7
Caption = "备注:"
Height = 270
Left = 4515
TabIndex = 6
Top = 1080
Width = 990
End
Begin VB.Label Label6
Caption = "共计费用:"
Height = 270
Left = 4515
TabIndex = 5
Top = 645
Width = 990
End
Begin VB.Label Label5
Caption = "维修日期:"
Height = 270
Left = 4515
TabIndex = 4
Top = 225
Width = 990
End
Begin VB.Label Label3
Caption = "更换零件2:"
Height = 270
Left = 180
TabIndex = 3
Top = 1080
Width = 1170
End
Begin VB.Label Label2
Caption = "更换零件1:"
Height = 270
Left = 210
TabIndex = 2
Top = 650
Width = 1170
End
Begin VB.Label Label1
Caption = "车牌号码:"
Height = 270
Left = 210
TabIndex = 1
Top = 225
Width = 990
End
End
End
Attribute VB_Name = "frmcarWXlr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Private Sub cmdAdd_Click()
Unlockctl
DTPicker1.Value = Format(Now, "yyyy-mm-dd")
Text1 = "": Tc1 = ""
Tc2 = "": Tc3 = ""
Text5 = "": Text6 = ""
TextDTP = "": Combo1.Text = ""
Combo2.Text = "": Combo3.Text = ""
Text1.SetFocus
cmdOk.Enabled = False: cmdCancel.Enabled = True
cmdUpdate.Enabled = False: cmdDelete.Enabled = False
Combo1.Visible = True: Adodc1.Enabled = False
cmdT.Enabled = True
i = 1
End Sub
Private Sub cmdCancel_Click()
On Error Resume Next '当没有添加数据的时候 处理异常
Adodc1.Recordset.CancelUpdate
Adodc1.Refresh
Lockctl
cmdOk.Enabled = False: cmdCancel.Enabled = False
cmdAdd.Enabled = True: cmdUpdate.Enabled = True
cmdDelete.Enabled = True: Adodc1.Enabled = True
cmdT.Enabled = False
End Sub
Private Sub cmdDelete_Click()
If MsgBox("您确实要删除记录吗?", vbOKCancel, "系统提示") = vbOK Then
'adoCon.Execute ("delete from 车辆维修表 where 车牌号码='" & Text1 & "'")
On Error Resume Next
Adodc1.Recordset.Delete
MsgBox " 记录已删除!", , "系统提示"
Adodc1.Refresh
End If
End Sub
Private Sub cmdExit_Click()
MDIForm1.StatusBar1.Panels(1).Text = ""
Unload Me
End Sub
Private Sub cmdFind_Click()
Dim str As String
str = InputBox$("输入你要查询的车牌号码:", "系统提示")
If str = "" Then Exit Sub
Adodc1.RecordSource = "select * from 车辆维修表 where 车牌号码='" + str + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Text1.Text = Adodc1.Recordset.Fields(0)
Combo1.Text = Adodc1.Recordset.Fields(1)
Tc1.Text = Adodc1.Recordset.Fields(2)
Combo2.Text = Adodc1.Recordset.Fields(3)
Tc2.Text = Adodc1.Recordset.Fields(4)
Combo3.Text = Adodc1.Recordset.Fields(5)
Tc3.Text = Adodc1.Recordset.Fields(6)
DTPicker1.Value = Adodc1.Recordset.Fields(7)
Text5.Text = Adodc1.Recordset.Fields(8)
Text6.Text = Adodc1.Recordset.Fields(9)
cmdUpdate.Enabled = True
cmdDelete.Enabled = True
Else
MsgBox "没有你需要的信息!", , "系统提示"
cmdUpdate.Enabled = False
cmdDelete.Enabled = False
End If
End Sub
Private Sub cmdOk_Click()
Select Case i
Case 1
If Text1 = "" Then
MsgBox "车牌号码不能为空", , "系统提示"
Text1.SetFocus
Exit Sub
End If
adoCon.Execute ("insert into 车辆维修表 values ('" & Text1 & "','" & Combo1.Text & "','" & Tc1.Text & "','" & Combo2.Text & "','" & Tc2.Text & "','" & Combo3.Text & "','" & Tc3.Text & "','" & DTPicker1.Value & "','" & Text5.Text & "','" & Text6.Text & "')")
MsgBox "记录添加成功!", , "系统提示"
Adodc1.Refresh
Case 2
' adoCon.Execute ("update 车辆维修表 set 更换零件1='" & Combo1 & "',零件1数量='" & Tc1.Text & "',更换零件2='" & Combo2 & "',零件2数量='" & Tc2.Text & "',更换零件3='" & Combo3.Text & "', 零件3数量='" & Tc3.Text & "',维修日期='" & DTPicker1.Value & "',共计费用='" & Text5.Text & "',备注='" & Text6.Text & "' where 车牌号码='" & Text1 & "'")
On Error Resume Next
Adodc1.Recordset.Update
MsgBox "记录修改成功!", , "系统提示"
Adodc1.Refresh
End Select
Lockctl
cmdOk.Enabled = False: cmdCancel.Enabled = False
cmdAdd.Enabled = True: cmdUpdate.Enabled = True
cmdDelete.Enabled = True: Adodc1.Enabled = True
cmdT.Enabled = False
End Sub
Private Sub cmdT_Click()
Dim c1, c2, c3 As Integer
On Error Resume Next
Adodc2.RecordSource = "select 单价 from 零件表 where 零件名='" & Combo1.Text & "'"
Adodc2.Refresh
c1 = Val(Adodc2.Recordset.Fields(0)) * Val(Tc1.Text)
Adodc2.RecordSource = "select 单价 from 零件表 where 零件名='" & Combo2.Text & "'"
Adodc2.Refresh
c2 = Val(Adodc2.Recordset.Fields(0)) * Val(Tc2.Text)
Adodc2.RecordSource = "select 单价 from 零件表 where 零件名='" & Combo3.Text & "'"
Adodc2.Refresh
c3 = Val(Adodc2.Recordset.Fields(0)) * Val(Tc3.Text)
Text5.Text = c1 + c2 + c3
cmdOk.Enabled = True
End Sub
Private Sub cmdUpdate_Click()
Unlockctl
i = 2
cmdOk.Enabled = True: cmdCancel.Enabled = True
cmdAdd.Enabled = False: cmdDelete.Enabled = False
Adodc1.Enabled = False: Text1.Enabled = False
cmdT.Enabled = True
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
End Sub
Private Sub Combo3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Tc3.SetFocus
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Tc1.SetFocus
End Sub
Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Tc2.SetFocus
End Sub
Private Sub Combo3_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
End Sub
Private Sub Command1_Click(Index As Integer)
On Error Resume Next
Select Case Index
Case 0
Adodc1.Recordset.MoveFirst
Case 1
If Adodc1.Recordset.BOF = False Then
Adodc1.Recordset.MovePrevious
Else
MsgBox "向前已经没有记录了!", , "系统提示"
End If
Case 2
If Adodc1.Recordset.EOF = False Then
Adodc1.Recordset.MoveNext
Else
MsgBox "向后已经没有记录了!", , "系统提示"
End If
Case 3
Adodc1.Recordset.MoveLast
End Select
Text1.Text = Adodc1.Recordset.Fields(0)
Combo1.Text = Adodc1.Recordset.Fields(1)
Tc1.Text = Adodc1.Recordset.Fields(2)
Combo2.Text = Adodc1.Recordset.Fields(3)
Tc2.Text = Adodc1.Recordset.Fields(4)
Combo3.Text = Adodc1.Recordset.Fields(5)
Tc3.Text = Adodc1.Recordset.Fields(6)
DTPicker1.Value = Adodc1.Recordset.Fields(7)
Text5.Text = Adodc1.Recordset.Fields(8)
Text6.Text = Adodc1.Recordset.Fields(9)
End Sub
Private Sub Form_Load()
frmcarWXlr.Width = 8490
frmcarWXlr.Height = 3150
Adodc1.RecordSource = "select * from 车辆维修表"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then DTPicker1.Value = Adodc1.Recordset.Fields("维修日期").Value
Adodc2.RecordSource = "select * from 零件表"
Adodc2.Refresh
For i = 0 To Adodc2.Recordset.RecordCount - 1
Combo1.AddItem Adodc2.Recordset.Fields(0).Value
Combo2.AddItem Adodc2.Recordset.Fields(0).Value
Combo3.AddItem Adodc2.Recordset.Fields(0).Value
Adodc2.Recordset.MoveNext
Next
If Adodc1.Recordset.RecordCount = 0 Then Exit Sub
Combo1.Text = Adodc1.Recordset.Fields(2)
Combo2.Text = Adodc1.Recordset.Fields(4)
Combo3.Text = Adodc1.Recordset.Fields(6)
cmdT.Enabled = False
End Sub
Private Sub Lockctl()
Text1.Enabled = False: Combo1.Enabled = False
Combo2.Enabled = False: Combo3.Enabled = False
Tc1.Enabled = False: Tc2.Enabled = False
Text5.Enabled = False: Text6.Enabled = False
DTPicker1.Enabled = False: Tc3.Enabled = False
End Sub
Private Sub Unlockctl()
Text1.Enabled = True: Combo1.Enabled = True
Combo2.Enabled = True: Combo3.Enabled = True
Tc1.Enabled = True: Tc2.Enabled = True
Tc3.Enabled = True: Text6.Enabled = True
DTPicker1.Enabled = True
End Sub
Private Sub Tc1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Tc1.Text = "" Then
If Combo1.Text <> "" Then
MsgBox "请添加零件数量", , "系统提示"
Exit Sub
End If
End If
Combo2.SetFocus
End If
End Sub
Private Sub Tc1_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, "0123456789." & Chr(8), True)
End Sub
Private Sub Tc2_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, "0123456789" & Chr(8), True)
End Sub
Private Sub Tc3_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, "0123456789." & Chr(8), True)
End Sub
Private Sub Tc2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Tc2.Text = "" Then
If Combo2.Text <> "" Then
MsgBox "请添加零件数量", , "系统提示"
Exit Sub
End If
End If
Combo3.SetFocus
End If
End Sub
Private Sub Tc3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Tc3.Text = "" Then
If Combo3.Text <> "" Then
MsgBox "请添加零件数量", , "系统提示"
Exit Sub
End If
End If
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Text1.Text = "" Then
MsgBox "车牌号码不能为空!", , "系统提示"
Text1.SetFocus
Exit Sub
End If
Combo1.SetFocus
End If
End Sub
Private Sub Text1_LostFocus()
If Text1.Text = "" Then Exit Sub
Dim rss As New ADODB.Recordset
Set rss = adoCon.Execute("select * from 车辆档案 where 车牌号码='" & Text1.Text & "'")
If rss.EOF Then
MsgBox "这辆车不属于本公司的!", , "系统提示"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
rss.Close
Dim rss1 As New ADODB.Recordset
Set rss1 = adoCon.Execute("select * from 车辆异动表 where 车牌号码='" & Text1.Text & "'")
If rss1.EOF Then
Else
MsgBox "该车为异动车辆!", , "系统提示"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
rss1.Close
Dim rss2 As New ADODB.Recordset
Set rss2 = adoCon.Execute("select * from 车辆报废表 where 车牌号码='" & Text1.Text & "'")
If rss2.EOF Then
Else
MsgBox "该车已经报废,不能维修!", , "系统提示"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
rss2.Close
End Sub
Private Sub TextDTP_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text6.SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -