📄 frmbasicfactoryinfo.frm
字号:
VERSION 5.00
Object = "{4932CEF1-2CAA-11D2-A165-0060081C43D9}#2.0#0"; "Actbar2.OCX"
Begin VB.Form frmBasicFactoryInfo
Caption = "加工厂信息"
ClientHeight = 6075
ClientLeft = 60
ClientTop = 345
ClientWidth = 7980
LinkTopic = "Form1"
ScaleHeight = 6075
ScaleWidth = 7980
StartUpPosition = 3 'Windows Default
Begin ActiveBar2LibraryCtl.ActiveBar2 ActiveBar21
Height = 6075
Left = 0
TabIndex = 0
Top = 0
Width = 7980
_LayoutVersion = 1
_ExtentX = 14076
_ExtentY = 10716
_DataPath = ""
Bands = "frmBasicFactoryInfo.frx":0000
Begin VB.Frame Frame1
Height = 5475
Left = 60
TabIndex = 1
Top = 540
Width = 7815
Begin VB.TextBox FactoryName
BackColor = &H00FFFFFF&
Height = 315
Left = 1440
MaxLength = 20
TabIndex = 13
Top = 795
Width = 3435
End
Begin VB.TextBox FactoryAddr
BackColor = &H00FFFFFF&
Height = 315
Left = 1440
MaxLength = 20
TabIndex = 12
Top = 2745
Width = 5895
End
Begin VB.TextBox FactoryAllName
BackColor = &H00C0C0FF&
Height = 315
Left = 1440
MaxLength = 20
TabIndex = 11
Top = 300
Width = 5955
End
Begin VB.CommandButton cmdOk
Caption = "確定 &A"
Height = 315
Left = 2340
TabIndex = 10
Top = 4980
Width = 855
End
Begin VB.CommandButton cmdClose
Caption = "關閉 &C"
Height = 315
Left = 4320
TabIndex = 9
Top = 4980
Width = 855
End
Begin VB.TextBox txtUpdateOperator
Height = 315
Left = 1440
MaxLength = 20
TabIndex = 8
Top = 4440
Width = 1815
End
Begin VB.TextBox txtUpdateDate
BackColor = &H8000000F&
Enabled = 0 'False
Height = 315
Left = 5160
TabIndex = 7
Top = 4440
Width = 2115
End
Begin VB.TextBox txtTel
Height = 315
Left = 1440
TabIndex = 6
Top = 1275
Width = 2775
End
Begin VB.TextBox txtFax
Height = 315
Left = 1440
TabIndex = 5
Top = 1770
Width = 2775
End
Begin VB.TextBox txtRemark
Height = 1035
Left = 1440
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 4
Top = 3225
Width = 5895
End
Begin VB.TextBox txtSurCharge
Height = 315
Left = 1440
TabIndex = 3
Top = 2250
Width = 1815
End
Begin VB.TextBox txtLinkman
Height = 315
Left = 5160
TabIndex = 2
Top = 2250
Width = 2115
End
Begin VB.Label Label4
Caption = "工廠全稱"
Height = 255
Left = 360
TabIndex = 23
Top = 300
Width = 1035
End
Begin VB.Label Label3
Caption = "工廠地址"
Height = 255
Index = 0
Left = 360
TabIndex = 22
Top = 2760
Width = 1035
End
Begin VB.Label Label3
Caption = "工廠簡稱"
Height = 255
Index = 2
Left = 360
TabIndex = 21
Top = 780
Width = 1035
End
Begin VB.Label Label1
Caption = "填寫人"
Height = 255
Left = 360
TabIndex = 20
Top = 4440
Width = 735
End
Begin VB.Label Label2
Caption = "填入日期"
Height = 255
Left = 3900
TabIndex = 19
Top = 4500
Width = 975
End
Begin VB.Label Label5
Caption = "電話"
Height = 255
Left = 360
TabIndex = 18
Top = 1260
Width = 795
End
Begin VB.Label Label6
Caption = "傳真"
Height = 315
Left = 360
TabIndex = 17
Top = 1740
Width = 675
End
Begin VB.Label Label7
Caption = "付加費"
Height = 255
Left = 360
TabIndex = 16
Top = 2280
Width = 795
End
Begin VB.Label Label8
Caption = "備注"
Height = 255
Left = 360
TabIndex = 15
Top = 3240
Width = 795
End
Begin VB.Label Label9
Caption = "聯繫人"
Height = 255
Left = 3900
TabIndex = 14
Top = 2280
Width = 1155
End
End
End
End
Attribute VB_Name = "frmBasicFactoryInfo"
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
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(2).Caption = "工廠簡稱"
Label4.Caption = "工廠全稱"
Label3.item(0).Caption = "工廠地址"
Label5.Caption = "電話"
Label6.Caption = "傳真"
Label7.Caption = "付加費"
Label9.Caption = "聯繫人"
Label8.Caption = "備註"
Label1.Caption = "填寫人"
Label2.Caption = "填入日期"
cmdOk.Caption = "確定 &O"
cmdClose.Caption = "關閉 &C"
Me.Caption = "加工廠信息"
End Sub
Public Sub InitInfo(strId As String)
If newItem = False Then
Dim rs As ADODB.Recordset
SystemExecuteStart Me
' 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
strSql = "select * from tBasicFactory where status=0 and FactoryAllName='" & strId & "'"
rs.Open strSql
If Not rs.EOF Then
FactoryName.Text = NullValue(rs.Fields!FactoryName)
FactoryAllName.Text = NullValue(rs.Fields!FactoryAllName)
FactoryAllName.Enabled = False
FactoryAddr = NullValue(rs.Fields!FactoryAddress)
txtTel = NullValue(rs.Fields!Tel)
txtFax = NullValue(rs.Fields!Fax)
txtLinkman = NullValue(rs.Fields!Linkman)
txtSurCharge = NullValue(rs.Fields!SurCharge)
txtRemark = NullValue(rs.Fields!Remark)
txtUpdateOperator = NullValue(rs.Fields!UpdateOperator)
txtUpdateDate = NullValue(rs.Fields!UpdateDate)
End If
rs.Close
Set rs = Nothing
SystemExecuteEnd Me
End If
Exit Sub
errLabel:
SystemExecuteEnd Me
objDatabase.DatabaseError
End Sub
Private Sub Save(Optional blModi As Boolean)
Dim strSql As String
Dim rs As ADODB.Recordset
strSql = "select * from tBasicFactory where status=0 and FactoryAllName='" & Trim$(FactoryAllName.Text) & "'"
On Error GoTo errHandle
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
Set .ActiveConnection = Cn
End With
rs.Open strSql
If FactoryAllName.Text = "" Then
MsgBox "工廠名稱不能為空!", vbCritical, "提示"
rs.Close
Set rs = Nothing
FactoryAllName.SetFocus
Exit Sub
End If
If blModi Then
If Not rs.EOF Then
MsgBox "此加工廠已存在!", vbCritical, "提示"
FactoryAllName.Text = ""
FactoryAllName.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!FactoryName = Trim$(FactoryName)
rs.Fields!FactoryAllName = Trim$(FactoryAllName.Text)
rs.Fields!FactoryAddress = Trim$(FactoryAddr.Text)
rs.Fields!Tel = Trim$(txtTel.Text)
rs.Fields!Fax = Trim$(txtFax)
rs.Fields!Linkman = Trim$(txtLinkman)
rs.Fields!SurCharge = Trim$(txtSurCharge)
rs.Fields!Remark = Trim$(txtRemark)
rs.Fields!UpdateOperator = Trim$(txtUpdateOperator.Text)
rs.Fields!UpdateDate = Now
rs.Update
MsgBox "新建成功!", vbInformation, "恭喜'"
Else
If rs.EOF Then '修改
MsgBox "没有可修改的记录!", vbExclamation, "修改"
rs.Close
Set rs = Nothing
FactoryAllName.SetFocus
Exit Sub
End If
If MsgBox("是否修改记录?", vbYesNo + vbQuestion, "修改") = vbNo Then
rs.Close
Set rs = Nothing
Exit Sub
End If
rs.Fields!FactoryName = Trim$(FactoryName)
rs.Fields!FactoryAllName = Trim$(FactoryAllName.Text)
rs.Fields!FactoryAddress = Trim$(FactoryAddr.Text)
rs.Fields!Tel = Trim$(txtTel.Text)
rs.Fields!Fax = Trim$(txtFax)
rs.Fields!Linkman = Trim$(txtLinkman)
rs.Fields!SurCharge = Trim$(txtSurCharge)
rs.Fields!Remark = Trim$(txtRemark)
rs.Fields!UpdateOperator = Trim$(txtUpdateOperator.Text)
rs.Fields!UpdateDate = Now
rs.Update
MsgBox "修改成功!", vbInformation, "恭喜"
End If
rs.Close
Set rs = Nothing
frmBasicFactory.FillMshf1 ("select * from tBasicFactory where status=0")
FactoryAllName.Enabled = True
Unload Me
Exit Sub
errHandle:
Set rs = Nothing
objDatabase.DatabaseError
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -