📄 frmbasicportinfo.frm
字号:
VERSION 5.00
Object = "{4932CEF1-2CAA-11D2-A165-0060081C43D9}#2.0#0"; "Actbar2.OCX"
Begin VB.Form frmBasicPortInfo
Caption = "港口信息"
ClientHeight = 4455
ClientLeft = 60
ClientTop = 345
ClientWidth = 3930
LinkTopic = "Form1"
ScaleHeight = 4455
ScaleWidth = 3930
StartUpPosition = 3 'Windows Default
Begin ActiveBar2LibraryCtl.ActiveBar2 ActiveBar21
Height = 4455
Left = 0
TabIndex = 0
Top = 0
Width = 3930
_LayoutVersion = 1
_ExtentX = 6932
_ExtentY = 7858
_DataPath = ""
Bands = "frmBasicPortInfo.frx":0000
Begin VB.Frame Frame1
Height = 3855
Left = 60
TabIndex = 1
Top = 540
Width = 3795
Begin VB.TextBox txtId
Height = 285
Left = 1680
TabIndex = 16
Text = "Text1"
Top = 3360
Visible = 0 'False
Width = 375
End
Begin VB.TextBox txtPortName
BackColor = &H00C0C0FF&
Height = 315
Left = 1560
MaxLength = 50
TabIndex = 9
Top = 1320
Width = 1995
End
Begin VB.CommandButton cmdOk
Caption = "確定 &A"
Height = 315
Left = 600
TabIndex = 8
Top = 3360
Width = 735
End
Begin VB.CommandButton cmdClose
Caption = "關閉 &C"
Height = 315
Left = 2220
TabIndex = 7
Top = 3360
Width = 735
End
Begin VB.TextBox txtStateName
BackColor = &H00C0C0FF&
Height = 315
Left = 1560
MaxLength = 50
TabIndex = 6
Top = 240
Width = 1995
End
Begin VB.TextBox txtePortName
BackColor = &H00FFFFFF&
Height = 315
Left = 1560
MaxLength = 50
TabIndex = 5
Top = 1860
Width = 1995
End
Begin VB.TextBox txteStateName
Height = 315
Left = 1560
MaxLength = 50
TabIndex = 4
Top = 780
Width = 1995
End
Begin VB.TextBox txtUpdateOperator
Height = 315
Left = 1560
MaxLength = 20
TabIndex = 3
Top = 2340
Width = 1995
End
Begin VB.TextBox txtUpdateDate
BackColor = &H8000000F&
Enabled = 0 'False
Height = 315
Left = 1560
TabIndex = 2
Top = 2820
Width = 1995
End
Begin VB.Label Label11
Caption = "港口名稱"
Height = 255
Left = 240
TabIndex = 15
Top = 1320
Width = 1035
End
Begin VB.Label Label3
Caption = "國家名稱"
Height = 255
Index = 4
Left = 240
TabIndex = 14
Top = 360
Width = 1035
End
Begin VB.Label Label1
Caption = "港口英文名稱"
Height = 255
Left = 240
TabIndex = 13
Top = 1860
Width = 1215
End
Begin VB.Label Label2
Caption = "國家英文名稱"
Height = 255
Left = 240
TabIndex = 12
Top = 840
Width = 1155
End
Begin VB.Label Label4
Caption = "填寫人"
Height = 315
Left = 240
TabIndex = 11
Top = 2340
Width = 1095
End
Begin VB.Label Label5
Caption = "填入日期"
Height = 315
Left = 240
TabIndex = 10
Top = 2820
Width = 1095
End
End
End
End
Attribute VB_Name = "frmBasicPortInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public newItem As Boolean 'true表示增加
Private Sub ActiveBar21_ToolClick(ByVal Tool As ActiveBar2LibraryCtl.Tool)
Select Case Tool.Name
Case "cmdSave":
Save newItem
Case "cmdCancel":
Unload Me
Case "cmdDel":
DelOperatorInf
End Select
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdOk_Click()
Save newItem
End Sub
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
InitTitle
End Sub
Private Sub InitTitle()
Label3.item(4).Caption = "國家名稱"
Label2.Caption = "國家英文名稱"
Label11.Caption = "港口名稱"
Label1.Caption = "港口英文名稱"
Label4.Caption = "填寫人"
Label5.Caption = "填入日期"
cmdOk.Caption = "確定 &A"
cmdClose.Caption = "關閉 &C"
Me.Caption = "港口信息設置"
End Sub
Private Sub DelOperatorInf()
Dim strSql As String
On Error GoTo errHandle
If MsgBox("确定要刪除?", vbQuestion + vbYesNo, "询问") = vbNo Then
Exit Sub
Else
strSql = "delete from tBasicPort where id=" & txtId
objDatabase.ExecCmd strSql
MsgBox "刪除成功!", vbInformation, "提示"
End If
frmBasicPort.FillMshf1 ("select * from tBasicPort")
Unload Me
Exit Sub
errHandle:
objDatabase.DatabaseError
End Sub
Public Sub InitInfo(strId As String)
Dim rs As ADODB.Recordset
On Error GoTo errLabel
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
Set .ActiveConnection = Cn
End With
Dim strSql As String
If newItem = False Then
strSql = "select * from tBasicPort where id=" & strId
Else
strSql = "select * from tBasicCountries where CountriesName='" & strId & "'"
End If
rs.Open strSql
If Not rs.EOF Then
If newItem = False Then
txtStateName = rs.Fields!StateName
txteStateName = rs.Fields!eStateName
txtStateName.Locked = True
txteStateName.Locked = True
txtPortName = rs.Fields!PortName
txtId = rs.Fields!ID
txtePortName = rs.Fields!ePortName
txtUpdateOperator = rs.Fields!UpdateOperator
txtUpdateDate = rs.Fields!UpdateDate
Else
txtStateName = rs.Fields!CountriesName
txteStateName = rs.Fields!eCountries
txtStateName.Locked = True
txteStateName.Locked = True
End If
End If
rs.Close
Set rs = Nothing
SystemExecuteEnd Me
Exit Sub
errLabel:
SystemExecuteEnd Me
objDatabase.DatabaseError
End Sub
Private Sub Save(Optional blModi As Boolean)
Dim rs As ADODB.Recordset
Dim strSql As String
' On Error GoTo errHandle
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
Set .ActiveConnection = Cn
End With
If txtPortName.Text = "" Then
MsgBox "港口名稱不能為空!", vbCritical, "提示"
txtPortName.SetFocus
Exit Sub
End If
If blModi Then
strSql = "select * from tBasicPort where PortName='" & Trim$(txtPortName.Text) & "'"
rs.Open strSql
If Not rs.EOF Then
MsgBox "此港口名稱已存在!", vbCritical, "提示"
txtPortName.Text = ""
txtPortName.SetFocus
rs.Close
Set rs = Nothing
Exit Sub
End If
If MsgBox("是否添加新的港口?", vbQuestion + vbYesNo, "询问") = vbNo Then
rs.Close
Set rs = Nothing
Exit Sub
End If
rs.AddNew '新建
rs.Fields!PortName = Trim$(txtPortName)
rs.Fields!StateName = Trim$(txtStateName)
rs.Fields!eStateName = Trim$(txteStateName)
rs.Fields!ePortName = Trim$(txtePortName)
rs.Fields!UpdateOperator = txtUpdateOperator
rs.Fields!UpdateDate = Now
rs.Update
MsgBox "新建成功!", vbInformation, "恭喜'"
Else
strSql = "select * from tBasicPort where id=" & txtId
rs.Open strSql
If rs.EOF Then '修改
MsgBox "没有可修改的信息!", vbExclamation, "修改"
rs.Close
Set rs = Nothing
txtPortName.SetFocus
Exit Sub
End If
If MsgBox("是否修改记录?", vbYesNo + vbQuestion, "修改") = vbNo Then
rs.Close
Set rs = Nothing
Exit Sub
End If
rs.Fields!PortName = Trim$(txtPortName)
rs.Fields!ePortName = Trim$(txtePortName)
rs.Fields!UpdateOperator = Trim$(txtUpdateOperator)
rs.Fields!UpdateDate = Now
rs.Update
MsgBox "修改成功!", vbInformation, "恭喜"
End If
rs.Close
Set rs = Nothing
frmBasicPort.FillMshf1 ("select * from tBasicPort")
Unload Me
Exit Sub
errHandle:
Set rs = Nothing
objDatabase.DatabaseError
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -