?? 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 + -