VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frm_dt_rk
BorderStyle = 1 'Fixed Single
Caption = "地圖入庫管理"
ClientHeight = 2475
ClientLeft = 45
ClientTop = 330
ClientWidth = 5625
Icon = "frm_dt_rk.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2475
ScaleWidth = 5625
StartUpPosition = 1 '所有者中心
Begin VB.ComboBox Combo3
Height = 300
Left = 90
Style = 2 'Dropdown List
TabIndex = 13
Top = 2025
Visible = 0 'False
Width = 1230
End
Begin VB.CommandButton Command2
Caption = "關閉(&C)"
Height = 375
Left = 4305
TabIndex = 4
Top = 2025
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "確定(&E)"
Height = 375
Left = 2925
TabIndex = 3
Top = 2025
Width = 1215
End
Begin VB.Frame Frame1
Caption = "地圖入庫"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1860
Left = 135
TabIndex = 0
Top = 90
Width = 5385
Begin VB.ComboBox Combo1
Appearance = 0 'Flat
Height = 300
ItemData = "frm_dt_rk.frx":3452
Left = 1035
List = "frm_dt_rk.frx":3454
Style = 2 'Dropdown List
TabIndex = 12
Top = 360
Width = 4155
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 270
Index = 0
Left = 1035
MaxLength = 5
TabIndex = 8
Top = 1305
Width = 675
End
Begin VB.ComboBox Combo2
Appearance = 0 'Flat
Height = 300
Left = 1035
Locked = -1 'True
Style = 1 'Simple Combo
TabIndex = 1
Text = "Combo2"
Top = 825
Width = 1320
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 270
Index = 2
Left = 3555
Locked = -1 'True
TabIndex = 2
Top = 1305
Width = 960
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 315
Left = 3555
TabIndex = 9
Top = 795
Width = 1635
_ExtentX = 2884
_ExtentY = 556
_Version = 393216
Format = 24576000
CurrentDate = 37630
End
Begin VB.Label label1
AutoSize = -1 'True
Caption = "入庫時間:"
Height = 180
Index = 2
Left = 2700
TabIndex = 11
Top = 855
Width = 810
End
Begin VB.Label label1
AutoSize = -1 'True
Caption = "入庫數量:"
Height = 180
Index = 3
Left = 180
TabIndex = 10
Top = 1350
Width = 810
End
Begin VB.Label label1
AutoSize = -1 'True
Caption = "經 辦 人:"
Height = 180
Index = 4
Left = 2700
TabIndex = 7
Top = 1335
Width = 810
End
Begin VB.Label label1
AutoSize = -1 'True
Caption = "地圖規格:"
Height = 180
Index = 1
Left = 180
TabIndex = 6
Top = 885
Width = 810
End
Begin VB.Label label1
AutoSize = -1 'True
Caption = "地圖名稱:"
Height = 180
Index = 0
Left = 180
TabIndex = 5
Top = 420
Width = 810
End
End
End
Attribute VB_Name = "frm_dt_rk"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim adoPrimaryRS As Recordset
Dim adoPrimaryRS1 As Recordset
Dim adoPrimaryRS2 As Recordset
Dim db As Connection
Private Sub Combo1_Click()
Combo2.ListIndex = Combo1.ListIndex
Combo3.ListIndex = Combo1.ListIndex
End Sub
Private Sub Command1_Click()
On Error GoTo err_31:
If Val(Text1(0).Text) <> 0 Then
Set adoPrimaryRS1 = New Recordset
adoPrimaryRS1.Open "select * from s_rkjl ", db, adOpenStatic, adLockOptimistic
With adoPrimaryRS1
.AddNew
adoPrimaryRS1("地圖名稱") = Combo1.Text
adoPrimaryRS1("規格") = Combo2.Text
adoPrimaryRS1("入庫數") = Val(Text1(0).Text)
adoPrimaryRS1("經辦人") = Text1(2).Text
adoPrimaryRS1("入庫時間") = DTPicker1.Value
.Update
End With
kcl = Val(Text1(0).Text)
Set adoPrimaryRS2 = New Recordset
adoPrimaryRS2.Open "select 編號,地圖名稱,庫存數 from jb where 編號='" & Combo3.Text & "'", db, adOpenStatic, adLockOptimistic
If adoPrimaryRS2.RecordCount = 1 Then
With adoPrimaryRS2
kcl = adoPrimaryRS2("庫存數") + Val(Text1(0).Text)
adoPrimaryRS2("庫存數") = kcl
.Update
End With
Else
With adoPrimaryRS2
.AddNew
adoPrimaryRS2("地圖名稱") = Combo1.Text
adoPrimaryRS2("編號") = Combo3.Text
adoPrimaryRS2("庫存數") = Val(Text1(0).Text)
.Update
End With
End If
MsgBox Combo1.Text & "庫存數為" & kcl, vbExclamation
Else
MsgBox "入庫數量不能為0", vbInformation, "重新輸入"
End If
Exit Sub
err_31:
adoPrimaryRS1.CancelUpdate
adoPrimaryRS2.CancelUpdate
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error GoTo err_32:
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & fullpath("mdb\mapdata.lbl")
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "select 地圖名稱,比例尺,地圖類型,編號 from m_dt order by 編號", db, adOpenStatic, adLockOptimistic
With adoPrimaryRS
For i = 0 To .RecordCount - 1
Combo1.AddItem adoPrimaryRS("地圖名稱"), i
Combo2.AddItem adoPrimaryRS("比例尺") & adoPrimaryRS("地圖類型"), i
Combo3.AddItem adoPrimaryRS("編號"), i
.MoveNext
Next i
Combo1.ListIndex = 0
Text1(2).Text = gz_user
End With
Exit Sub
err_32:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 0 Then
strValid = "0123456789"
If KeyAscii > 26 Then
If InStr(strValid, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End If
End If
End Sub