?? frmacc1.frm
字號:
VERSION 5.00
Begin VB.Form frmAcc1
BorderStyle = 3 'Fixed Dialog
Caption = "車輛事故信息"
ClientHeight = 5256
ClientLeft = 48
ClientTop = 336
ClientWidth = 7572
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5256
ScaleWidth = 7572
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.Frame Frame3
Caption = "備注信息"
Height = 975
Left = 240
TabIndex = 23
Top = 3720
Width = 7095
Begin VB.TextBox txtItem
Height = 615
Index = 7
Left = 240
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 9
Top = 240
Width = 6615
End
End
Begin VB.Frame Frame2
Caption = "其它信息"
Height = 3375
Left = 3840
TabIndex = 18
Top = 240
Width = 3495
Begin VB.TextBox txtItem
Height = 270
Index = 6
Left = 1200
MaxLength = 10
TabIndex = 8
Top = 2880
Width = 2055
End
Begin VB.TextBox txtItem
Height = 975
Index = 5
Left = 1200
MaxLength = 30
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 7
Top = 1800
Width = 2055
End
Begin VB.TextBox txtItem
Height = 270
Index = 3
Left = 1200
MaxLength = 15
TabIndex = 5
Top = 360
Width = 2055
End
Begin VB.TextBox txtItem
Height = 975
Index = 4
Left = 1200
MaxLength = 30
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 6
Top = 720
Width = 2055
End
Begin VB.Label Label2
Caption = "處理金額:"
Height = 255
Index = 8
Left = 240
TabIndex = 22
Top = 2880
Width = 975
End
Begin VB.Label Label2
Caption = "處理方式:"
Height = 255
Index = 7
Left = 240
TabIndex = 21
Top = 1800
Width = 975
End
Begin VB.Label Label2
Caption = "對方單位:"
Height = 255
Index = 5
Left = 240
TabIndex = 20
Top = 720
Width = 975
End
Begin VB.Label Label2
Caption = "對方車號:"
Height = 255
Index = 3
Left = 240
TabIndex = 19
Top = 360
Width = 975
End
End
Begin VB.Frame Frame1
Caption = "維修基本信息"
Height = 3375
Left = 240
TabIndex = 12
Top = 240
Width = 3495
Begin VB.ComboBox cboItem
Height = 300
Index = 1
Left = 1200
Style = 2 'Dropdown List
TabIndex = 1
Top = 720
Width = 2055
End
Begin VB.ComboBox cboItem
Height = 300
Index = 0
Left = 1200
Style = 2 'Dropdown List
TabIndex = 0
Top = 360
Width = 2055
End
Begin VB.TextBox txtItem
Height = 855
Index = 2
Left = 1200
MaxLength = 30
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 4
Top = 2400
Width = 2055
End
Begin VB.TextBox txtItem
Height = 855
Index = 1
Left = 1200
MaxLength = 30
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 3
Top = 1440
Width = 2055
End
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 1200
MaxLength = 10
TabIndex = 2
Top = 1080
Width = 2055
End
Begin VB.Label Label2
Caption = "司 機:"
Height = 255
Index = 2
Left = 240
TabIndex = 17
Top = 720
Width = 855
End
Begin VB.Label Label2
Caption = "地 點:"
Height = 255
Index = 6
Left = 240
TabIndex = 16
Top = 1440
Width = 855
End
Begin VB.Label Label2
Caption = "車 牌 號:"
Height = 255
Index = 0
Left = 240
TabIndex = 15
Top = 360
Width = 855
End
Begin VB.Label Label2
Caption = "時 間:"
Height = 255
Index = 1
Left = 240
TabIndex = 14
Top = 1080
Width = 855
End
Begin VB.Label Label2
Caption = "原 因:"
Height = 255
Index = 16
Left = 240
TabIndex = 13
Top = 2400
Width = 855
End
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 5880
TabIndex = 11
Top = 4800
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 4440
TabIndex = 10
Top = 4800
Width = 1215
End
End
Attribute VB_Name = "frmAcc1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'是否改動過記錄,ture為改過
Dim mblChange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String
Dim MsgText As String
Private Sub cmdExit_Click()
If mblChange And cmdSave.Enabled Then
If MsgBox("保存當前記錄的變化嗎?", vbOKCancel + vbExclamation, "警告") = vbOK Then
'保存
Call cmdSave_Click
End If
End If
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
If Trim(txtItem(0) & " ") = "" Then
sMeg = "時間不能為空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
If Trim(txtItem(1) & " ") = "" Then
sMeg = "地點不能為空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(1).SetFocus
Exit Sub
End If
If Trim(txtItem(0) & "") <> "" Then
If Not IsDate(txtItem(0)) Then
MsgBox "時間應輸入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
Else
txtItem(0) = Format(txtItem(0), "yyyy-mm-dd")
End If
End If
'添加判斷是否有相同的ID記錄
If gintaMode = 1 Then
txtSQL = "select * from accident where sgid='" & Trim(cboItem(0)) & "' and sgdate='" & Format(txtItem(0), "yyyy-mm-dd") & "' and sgplace='" & Trim(txtItem(1)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已經存在此事故記錄!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
mrc.Close
End If
'先刪除已有記錄
txtSQL = "delete from accident where sgid='" & Trim(cboItem(0)) & "' and sgdate='" & Format(txtItem(0), "yyyy-mm-dd") & "' and sgplace='" & Trim(txtItem(1)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新記錄
txtSQL = "select * from accident"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = Trim(cboItem(0))
mrc.Fields(1) = Trim(cboItem(1))
For intCount = 0 To 7
mrc.Fields(intCount + 2) = Trim(txtItem(intCount))
Next intCount
mrc.Update
mrc.Close
If gintaMode = 1 Then
For intCount = 0 To 7
txtItem(intCount) = ""
Next intCount
mblChange = False
ElseIf gintaMode = 2 Then
Unload Me
If flagaEdit Then
Unload frmAcc
End If
frmAcc.txtSQL = "select sgid,sgdate,sgplace,sgreason,sgdriver,sgopp_dept,sgopp_id,sgmode,sgvalue,sgmemo from accident "
frmAcc.Show
End If
End Sub
Private Sub Form_Load()
Dim intCount As Integer
If gintaMode = 1 Then
Me.Caption = Me.Caption & "添加"
'初始化車牌號
txtSQL = "select DISTINCT sjname from driver"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If Not mrc.EOF Then
Do While Not mrc.EOF
cboItem(1).AddItem Trim(mrc!sjname)
mrc.MoveNext
Loop
cboItem(1).ListIndex = 0
Else
MsgBox "請先建立司機檔案!", vbOKOnly + vbExclamation, "警告"
cmdSave.Enabled = False
Exit Sub
End If
mrc.Close
'初始化車牌號
txtSQL = "select DISTINCT clid from vehicle"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If Not mrc.EOF Then
Do While Not mrc.EOF
cboItem(0).AddItem Trim(mrc!clid)
mrc.MoveNext
Loop
cboItem(0).ListIndex = 0
Else
MsgBox "請先建立車輛檔案!", vbOKOnly + vbExclamation, "警告"
cmdSave.Enabled = False
Exit Sub
End If
mrc.Close
ElseIf gintaMode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
cboItem(0).AddItem .Fields(0)
cboItem(0).ListIndex = 0
cboItem(1).AddItem .Fields(1)
cboItem(1) = .Fields(1)
For intCount = 0 To 7
If Trim(.Fields(intCount + 2) & " ") <> "" Then
txtItem(intCount) = .Fields(intCount + 2)
End If
Next intCount
txtItem(0).Enabled = False
txtItem(1).Enabled = False
End With
End If
Me.Caption = Me.Caption & "修改"
mrc.Close
End If
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintaMode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
'有變化設置gblchange
mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
Private Sub txtItem_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 6 Then
'MsgBox KeyCode
'對鍵入字符進行控制
'txtQuantity(Index).Locked = False
'小數點只允許輸入一次
If KeyAscii = 190 Then
If InStr(Trim(txtItem(Index)), ".") = 0 Then
If Len(Trim(txtItem(Index))) > 0 Then
txtItem(Index).Locked = False
Else
txtItem(Index).Locked = True
End If
Else
txtItem(Index).Locked = True
End If
Exit Sub
End If
'非數字不能輸入
If KeyAscii > 57 Or KeyAscii < 48 Then
txtItem(Index).Locked = True
Else
txtItem(Index).Locked = False
End If
'允許Backspace
If KeyAscii = 8 Then
txtItem(Index).Locked = False
End If
'Delete鍵
If KeyAscii = 46 Then
txtItem(Index).Locked = False
End If
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -