⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 部品管理.frm

📁 计算机CAD图纸管理和预览
💻 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 + -