提交 58e368ce 编写于 作者: leaky114's avatar leaky114

21.12.18优化erp导入

上级 bf96e2a5
......@@ -23,16 +23,16 @@ Partial Class About
'不要使用代码编辑器修改它。
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.OKButton = New System.Windows.Forms.Button
Me.LabelVersion = New System.Windows.Forms.Label
Me.LabelCopyright = New System.Windows.Forms.Label
Me.LabelCompanyName = New System.Windows.Forms.Label
Me.LabelProductName = New System.Windows.Forms.Label
Me.TextBoxDescription = New System.Windows.Forms.TextBox
Me.PictureBox2 = New System.Windows.Forms.PictureBox
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.OKButton = New System.Windows.Forms.Button()
Me.LabelVersion = New System.Windows.Forms.Label()
Me.LabelCopyright = New System.Windows.Forms.Label()
Me.LabelCompanyName = New System.Windows.Forms.Label()
Me.LabelProductName = New System.Windows.Forms.Label()
Me.TextBoxDescription = New System.Windows.Forms.TextBox()
Me.PictureBox2 = New System.Windows.Forms.PictureBox()
Me.PictureBox1 = New System.Windows.Forms.PictureBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
CType(Me.PictureBox2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
......
......@@ -276,9 +276,11 @@ Partial Class AutoPartNumberDialog
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Cancel_Button)
Me.Controls.Add(Me.OK_Button)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "AutoPartNumberDialog"
Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "自动命名图号"
......
......@@ -158,7 +158,7 @@ Partial Class SearchCoding
Me.Button3.Text = "C"
Me.Button3.UseVisualStyleBackColor = True
'
'GetPartDialog
'SearchCoding
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
......@@ -173,13 +173,15 @@ Partial Class SearchCoding
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.ListView1)
Me.Controls.Add(Me.Cancel_Button)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "GetPartDialog"
Me.Name = "SearchCoding"
Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = " "
Me.Text = "统计质量面积"
Me.TopMost = True
Me.ResumeLayout(False)
Me.PerformLayout()
......
......@@ -137,7 +137,4 @@ Public Class SearchCoding
My.Computer.Clipboard.SetText(TextBox2.Text)
End Sub
Private Sub GetPartDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
\ No newline at end of file
......@@ -166,9 +166,11 @@ Partial Class HanFengJiSuan
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "HanFengJiSuan"
Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "焊缝计算"
Me.TopMost = True
Me.TableLayoutPanel1.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()
......
......@@ -23,14 +23,15 @@ Partial Class InventoryCoding
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.ListView1 = New System.Windows.Forms.ListView()
Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
Me.ColumnHeader3 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
Me.ColumnHeader2 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
Me.Button5 = New System.Windows.Forms.Button()
Me.Cancel_Button = New System.Windows.Forms.Button()
Me.OK_Button = New System.Windows.Forms.Button()
Me.Button1 = New System.Windows.Forms.Button()
Me.ProgressBar1 = New System.Windows.Forms.ProgressBar()
Me.Button2 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'ListView1
......@@ -38,7 +39,7 @@ Partial Class InventoryCoding
Me.ListView1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader3, Me.ColumnHeader2, Me.ColumnHeader4})
Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader3, Me.ColumnHeader2, Me.ColumnHeader1, Me.ColumnHeader4})
Me.ListView1.FullRowSelect = True
Me.ListView1.Location = New System.Drawing.Point(12, 13)
Me.ListView1.Name = "ListView1"
......@@ -48,11 +49,6 @@ Partial Class InventoryCoding
Me.ListView1.UseCompatibleStateImageBehavior = False
Me.ListView1.View = System.Windows.Forms.View.Details
'
'ColumnHeader1
'
Me.ColumnHeader1.Text = "存货编码"
Me.ColumnHeader1.Width = 100
'
'ColumnHeader3
'
Me.ColumnHeader3.Text = "规格(图号)"
......@@ -63,21 +59,16 @@ Partial Class InventoryCoding
Me.ColumnHeader2.Text = "存货名称"
Me.ColumnHeader2.Width = 120
'
'ColumnHeader1
'
Me.ColumnHeader1.Text = "存货编码"
Me.ColumnHeader1.Width = 80
'
'ColumnHeader4
'
Me.ColumnHeader4.Text = "文件"
Me.ColumnHeader4.Width = 200
'
'Button5
'
Me.Button5.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button5.Location = New System.Drawing.Point(296, 277)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(69, 33)
Me.Button5.TabIndex = 33
Me.Button5.Text = "装载"
Me.Button5.UseVisualStyleBackColor = True
'
'Cancel_Button
'
Me.Cancel_Button.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
......@@ -108,19 +99,41 @@ Partial Class InventoryCoding
Me.Button1.Text = "写入"
Me.Button1.UseVisualStyleBackColor = True
'
'ProgressBar1
'
Me.ProgressBar1.Location = New System.Drawing.Point(12, 280)
Me.ProgressBar1.Name = "ProgressBar1"
Me.ProgressBar1.Size = New System.Drawing.Size(235, 24)
Me.ProgressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous
Me.ProgressBar1.TabIndex = 35
'
'Button2
'
Me.Button2.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button2.Location = New System.Drawing.Point(296, 277)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(69, 33)
Me.Button2.TabIndex = 36
Me.Button2.Text = "装载"
'
'InventoryCoding
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(593, 322)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.ProgressBar1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.Cancel_Button)
Me.Controls.Add(Me.OK_Button)
Me.Controls.Add(Me.ListView1)
Me.MaximizeBox = False
Me.Name = "InventoryCoding"
Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "导入存货编码"
Me.TopMost = True
Me.ResumeLayout(False)
Me.PerformLayout()
......@@ -129,9 +142,10 @@ Partial Class InventoryCoding
Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader
Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader
Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader
Friend WithEvents Button5 As System.Windows.Forms.Button
Friend WithEvents Cancel_Button As System.Windows.Forms.Button
Friend WithEvents OK_Button As System.Windows.Forms.Button
Friend WithEvents ColumnHeader4 As System.Windows.Forms.ColumnHeader
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
Friend WithEvents Button2 As System.Windows.Forms.Button
End Class
......@@ -7,11 +7,14 @@ Imports Microsoft.Office.Interop
Public Class InventoryCoding
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
SetStatusBarText()
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Button2.Enabled = False
ListView1.Items.Clear()
SetStatusBarText()
If IsInventorOpenDoc() = False Then
Exit Sub
End If
......@@ -29,21 +32,32 @@ Public Class InventoryCoding
Dim oAllReferencedDocuments As DocumentsEnumerator
oAllReferencedDocuments = oAssemblyDocument.AllReferencedDocuments
With ProgressBar1
.Minimum = 0
.Maximum = oAllReferencedDocuments.Count
.Value = 0
End With
' 遍历这些文档
For Each ReferencedDocument As Document In oAllReferencedDocuments
Debug.Print(ReferencedDocument.DisplayName)
Dim oStockNumPartName As StockNumPartName
oStockNumPartName = GetPropitems(ReferencedDocument)
Dim LVI As ListViewItem
LVI = ListView1.Items.Add(oStockNumPartName.PartNum)
LVI.SubItems.Add(oStockNumPartName.StockNum)
LVI = ListView1.Items.Add(oStockNumPartName.StockNum)
LVI.SubItems.Add(oStockNumPartName.PartName)
LVI.SubItems.Add(oStockNumPartName.PartNum)
LVI.SubItems.Add(ReferencedDocument.FullDocumentName)
ProgressBar1.Value = ProgressBar1.Value + 1
Next
Button2.Enabled = True
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
......@@ -54,14 +68,18 @@ Public Class InventoryCoding
On Error Resume Next
'PartNum = FindSrtingInSheet(Excel_File_Name, StochNum, Sheet_Name, Table_Array, Col_Index_Num, 0)
OK_Button.Enabled = False
Dim excelApp As Excel.Application
excelApp = New Excel.Application
'excelApp.Visible = True
'Excel_File_Name = "E:\软件\Invenotr\Inventor编程\InventorAddIn\code\bin\最新物料编码.xls"
Excel_File_Name = "E:\软件\Invenotr\Inventor编程\InventorAddIn\code\bin\最新物料编码.xls"
Dim wb As Excel.Workbook = excelApp.Workbooks.Open(Excel_File_Name, 0, True)
Dim sht As Excel.Worksheet
sht = wb.Sheets(Sheet_Name)
sht = wb.Sheets("物料")
Dim userange As Excel.Range = Nothing
......@@ -70,23 +88,42 @@ Public Class InventoryCoding
Table_Array = Split("A,C,D,E", ",")
Dim MatchRow As Double
Dim MatchRow As Double '寻找到的行
With ProgressBar1
.Minimum = 0
.Maximum = ListView1.Items.Count
.Value = 0
End With
For Each LVI As ListViewItem In ListView1.Items
For Each a In Table_Array
userange = sht.Range(a & ":" & a)
MatchRow = 0
MatchRow = excelApp.WorksheetFunction.Match(LVI.SubItems(1).Text, userange, 0)
If MatchRow <> 0 Then
Dim FindRow As String
FindRow = "B" & MatchRow
Dim FindRowValue As String
FindRowValue = sht.Range(FindRow).Value
LVI.Text = FindRowValue
Exit For
MatchRow = excelApp.WorksheetFunction.Match(LVI.Text, userange, 0)
If MatchRow <> 0.0 Then
'当前值
Dim NowRangeValue As String = LVI.SubItems(2).Text
Dim FindRange As String '寻找的单元
Dim FindRangeValue As String '寻找的值
'FindRange = "B" & MatchRow
FindRange = Col_Index_Num & MatchRow
FindRangeValue = sht.Range(FindRange).Value
If NowRangeValue <> FindRangeValue Then
LVI.SubItems(2).Text = FindRangeValue
LVI.UseItemStyleForSubItems = False
LVI.SubItems(2).ForeColor = Drawing.Color.Red
Exit For
End If
End If
Next
ProgressBar1.Value = ProgressBar1.Value + 1
Next
'关闭文件
......@@ -100,6 +137,7 @@ Public Class InventoryCoding
System.Runtime.InteropServices.Marshal.ReleaseComObject(wb)
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp)
OK_Button.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
......@@ -108,16 +146,29 @@ Public Class InventoryCoding
Dim FullDocumentName As String
Dim oCoding As String
Button1.Enabled = False
With ProgressBar1
.Minimum = 0
.Maximum = ListView1.Items.Count
.Value = 0
End With
For Each LVI As ListViewItem In ListView1.Items
oCoding = LVI.Text
FullDocumentName = LVI.SubItems(3).Text
If oCoding <> "" Then
If LVI.SubItems(2).ForeColor = Drawing.Color.Red Then
LVI.SubItems(2).ForeColor = Drawing.Color.Black '写入后变为黑色
oCoding = LVI.SubItems(2).Text
FullDocumentName = LVI.SubItems(3).Text
oInventorDocument = ThisApplication.Documents.Open(FullDocumentName, False)
SetPropitem(oInventorDocument, "成本中心", oCoding)
End If
ProgressBar1.Value = ProgressBar1.Value + 1
Next
MsgBox("ok")
Button1.Enabled = True
End Sub
End Class
\ No newline at end of file
B'设置为一个动作,可一次撤销
......
icon/保存关闭工程图161624.ico

894 字节 | W: | H:

icon/保存关闭工程图161624.ico

894 字节 | W: | H:

icon/保存关闭工程图161624.ico
icon/保存关闭工程图161624.ico
icon/保存关闭工程图161624.ico
icon/保存关闭工程图161624.ico
  • 2-up
  • Swipe
  • Onion skin
icon/保存关闭部件161624.ico

894 字节 | W: | H:

icon/保存关闭部件161624.ico

894 字节 | W: | H:

icon/保存关闭部件161624.ico
icon/保存关闭部件161624.ico
icon/保存关闭部件161624.ico
icon/保存关闭部件161624.ico
  • 2-up
  • Swipe
  • Onion skin
icon/保存关闭部件323224.ico

3.2 KB | W: | H:

icon/保存关闭部件323224.ico

3.2 KB | W: | H:

icon/保存关闭部件323224.ico
icon/保存关闭部件323224.ico
icon/保存关闭部件323224.ico
icon/保存关闭部件323224.ico
  • 2-up
  • Swipe
  • Onion skin
icon/保存关闭零件161624.ico

894 字节 | W: | H:

icon/保存关闭零件161624.ico

894 字节 | W: | H:

icon/保存关闭零件161624.ico
icon/保存关闭零件161624.ico
icon/保存关闭零件161624.ico
icon/保存关闭零件161624.ico
  • 2-up
  • Swipe
  • Onion skin
icon/保存关闭零件323224.ico

3.2 KB | W: | H:

icon/保存关闭零件323224.ico

3.2 KB | W: | H:

icon/保存关闭零件323224.ico
icon/保存关闭零件323224.ico
icon/保存关闭零件323224.ico
icon/保存关闭零件323224.ico
  • 2-up
  • Swipe
  • Onion skin
icon/关闭工程图161624.ico

894 字节 | W: | H:

icon/关闭工程图161624.ico

894 字节 | W: | H:

icon/关闭工程图161624.ico
icon/关闭工程图161624.ico
icon/关闭工程图161624.ico
icon/关闭工程图161624.ico
  • 2-up
  • Swipe
  • Onion skin
icon/关闭工程图323224.ico

3.2 KB | W: | H:

icon/关闭工程图323224.ico

3.2 KB | W: | H:

icon/关闭工程图323224.ico
icon/关闭工程图323224.ico
icon/关闭工程图323224.ico
icon/关闭工程图323224.ico
  • 2-up
  • Swipe
  • Onion skin
icon/关闭部件161624.ico

894 字节 | W: | H:

icon/关闭部件161624.ico

894 字节 | W: | H:

icon/关闭部件161624.ico
icon/关闭部件161624.ico
icon/关闭部件161624.ico
icon/关闭部件161624.ico
  • 2-up
  • Swipe
  • Onion skin
icon/关闭部件323224.ico

3.2 KB | W: | H:

icon/关闭部件323224.ico

3.2 KB | W: | H:

icon/关闭部件323224.ico
icon/关闭部件323224.ico
icon/关闭部件323224.ico
icon/关闭部件323224.ico
  • 2-up
  • Swipe
  • Onion skin
icon/关闭零件161624.ico

894 字节 | W: | H:

icon/关闭零件161624.ico

894 字节 | W: | H:

icon/关闭零件161624.ico
icon/关闭零件161624.ico
icon/关闭零件161624.ico
icon/关闭零件161624.ico
  • 2-up
  • Swipe
  • Onion skin
icon/关闭零件323224.ico

3.2 KB | W: | H:

icon/关闭零件323224.ico

3.2 KB | W: | H:

icon/关闭零件323224.ico
icon/关闭零件323224.ico
icon/关闭零件323224.ico
icon/关闭零件323224.ico
  • 2-up
  • Swipe
  • Onion skin
icon/错.ICO

766 字节

Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册