?? 部品管理.frm
字號:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form 部品管理
Caption = "部品管理"
ClientHeight = 11010
ClientLeft = 60
ClientTop = 450
ClientWidth = 15240
Icon = "部品管理.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 11010
ScaleWidth = 15240
StartUpPosition = 3 '窗口缺省
WindowState = 2 'Maximized
Begin VB.CommandButton view
Caption = "所有部品"
Height = 375
Left = 12240
TabIndex = 12
Top = 9840
Width = 855
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 240
Top = 10080
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command3
Caption = "退 出"
Height = 375
Left = 14040
TabIndex = 11
Top = 9840
Width = 855
End
Begin VB.Frame Frame2
Caption = "導入狀態"
Height = 1935
Left = 7800
TabIndex = 3
Top = 7800
Width = 7335
Begin VB.Label Label6
Caption = "錯誤部品個數:"
Height = 375
Left = 360
TabIndex = 9
Top = 960
Width = 1575
End
Begin VB.Label Label5
Caption = "導入新部品個數:"
Height = 375
Left = 360
TabIndex = 8
Top = 480
Width = 1695
End
End
Begin VB.Frame Frame1
Caption = "導入文件"
Height = 1935
Left = 120
TabIndex = 2
Top = 7800
Width = 7575
Begin VB.CommandButton inputbutton
Caption = "導 入"
Height = 375
Left = 6480
TabIndex = 10
Top = 1080
Width = 855
End
Begin VB.CommandButton findbutton
Caption = "瀏 覽"
Height = 375
Left = 6480
TabIndex = 5
Top = 240
Width = 855
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 375
Left = 240
TabIndex = 4
Top = 240
Width = 6015
End
Begin VB.Label Label4
Caption = "文件名稱:"
Height = 615
Left = 360
TabIndex = 7
Top = 1200
Width = 6015
End
Begin VB.Label Label3
Caption = "文件大小:"
Height = 255
Left = 360
TabIndex = 6
Top = 840
Width = 6015
End
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid partinGrid
Height = 7695
Left = 0
TabIndex = 1
Top = 0
Width = 15255
_ExtentX = 26908
_ExtentY = 13573
_Version = 393216
_NumberOfBands = 1
_Band(0).Cols = 2
End
Begin VB.PictureBox StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
ScaleHeight = 315
ScaleWidth = 15180
TabIndex = 0
Top = 10635
Width = 15240
End
End
Attribute VB_Name = "部品管理"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim xlscn As New ADODB.Connection 'excel表格的連接
Dim xlsrs As New ADODB.Recordset 'excel表格的記錄
Dim xlsfile As String
Dim xlsfilename As String
Dim xlsfilesize As String
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub findbutton_Click()
'將 Cancel 設置成 True。
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
CommonDialog1.ShowOpen
xlsfile = CommonDialog1.FileName
If Trim(xlsfile) <> Empty Then
Text1.Text = xlsfile
xlsfilename = Dir(xlsfile)
xlsfilesize = FileLen(xlsfile)
Label3.Caption = "文件大小: " & xlsfilesize & " Byte " & Format(xlsfilesize / 2 ^ 20, "0.00") & " M "
Label4.Caption = "文件名稱: " & xlsfilename
End If
ErrHandler:
'用戶按了“取消”按鈕。
Exit Sub
End Sub
Private Sub Form_Load()
MakeCenter 部品管理
Dim partname As String
partname = "part"
partrs.open partname, cn, adOpenKeyset, adLockPessimistic
End Sub
Private Sub Form_Unload(Cancel As Integer)
partrs.Close
Unload Me
End Sub
Private Sub inputbutton_Click()
Dim selpart As New ADODB.Recordset
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlssheet As String
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.open(xlsfile)
xlApp.Visible = False
xlssheet = xlBook.Worksheets(1).Name
xlBook.Close (True) '關閉工作簿
xlApp.Quit '結束EXCEL對象
Set xlApp = Nothing '釋放xlApp對象
If Trim(xlsfile) <> Empty Then
inputbutton.Enabled = False
xlscn.open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & xlsfile & ";Extended Properties='Excel 8.0;HDR=Yes'"
xlsrs.open "select * from[" & xlssheet & "$] ", xlscn, adOpenKeyset, adLockOptimistic
' xlsrs.open "select * from xlssheet ", xlscn, adOpenKeyset, adLockOptimistic"
If xlsrs.EOF = True Then '判斷是否為空
MsgBox "EXCEL表格空白", vbInformation + vbOKOnly, "數據導入"
Exit Sub
End If
xlsrs.MoveFirst
Do Until xlsrs.EOF
If xlsrs.Fields(1) <> Empty Then
Set selpart = cn.Execute("SELECT 部品番號 FROM part WHERE 部品番號 =" & "'" & xlsrs.Fields(1) & "'")
If selpart.EOF Then '部品番號不在數據庫內
With partrs
.AddNew
.Fields("階層") = xlsrs.Fields(0)
.Fields("部品番號") = xlsrs.Fields(1)
.Fields("部品名稱") = xlsrs.Fields(2)
.Fields("圖號") = xlsrs.Fields(3)
.Fields("規格") = xlsrs.Fields(4)
.Fields("數量") = xlsrs.Fields(5)
.Fields("單位") = xlsrs.Fields(6)
.Fields("備注") = xlsrs.Fields(7)
.Update
End With
End If
selpart.Close
End If
xlsrs.MoveNext
Loop
Call xlsloadin.InipartGrid(partinGrid)
Call xlsloadin.ShowpartData(partrs, partinGrid)
xlsrs.Close
xlscn.Close
Set xlsrs = Nothing
Set xlscn = Nothing
inputbutton.Enabled = True
End If
End Sub
Private Sub view_Click()
Call xlsloadin.InipartGrid(partinGrid)
Call xlsloadin.ShowpartData(partrs, partinGrid)
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -