B70340 1年前
父节点
当前提交
a9327c5f56

二进制
.vs/TENDEN-MES-SYS/FileContentIndex/2042ae22-a5b7-4b1a-bc75-95515149b001.vsidx 查看文件


二进制
.vs/TENDEN-MES-SYS/FileContentIndex/2555bab9-b339-4626-8bd1-8ae350747e2c.vsidx 查看文件


二进制
.vs/TENDEN-MES-SYS/FileContentIndex/5fa39b6e-500e-4e69-8238-b776162365e9.vsidx → .vs/TENDEN-MES-SYS/FileContentIndex/3e5240b4-0324-4b0d-8712-c76b0158c93d.vsidx 查看文件


二进制
.vs/TENDEN-MES-SYS/FileContentIndex/76950f9f-445c-4124-90c1-92fa992d03de.vsidx 查看文件


二进制
.vs/TENDEN-MES-SYS/FileContentIndex/b14e6460-7a20-4e73-81f9-86d8f04b3247.vsidx 查看文件


.vs/TENDEN-MES-SYS/FileContentIndex/a1f73cb7-8d74-4679-904e-953f9935189c.vsidx → .vs/TENDEN-MES-SYS/FileContentIndex/b9ea57e6-2a46-4b8c-8e3d-5510891e7bdb.vsidx 查看文件


二进制
.vs/TENDEN-MES-SYS/v17/.suo 查看文件


+ 43
- 7
TENDEN-MES-SYS/Module/SQL_成本系統管理.vb 查看文件

@@ -304,10 +304,10 @@
304 304
     Friend Sub SQL_新增訂單控制表修改紀錄1()
305 305
         ConnOpen()
306 306
         SQL1 = "INSERT INTO " & 訂單資料表(7) & " (資料流水號, 天盾訂單號, 客戶流水號, FTYPrice, BasicPrice, Polybag, FOOTformOrPETform, Tooling, RubberBand, JHOOK, WaterResistant, 
307
-                                                               P16VAT, EXWsaving, Currency, Exchange, 年份, Quantity, 利潤表流水號, 審核) 
307
+                                                               P16VAT, EXWsaving, Currency, Exchange, 年份, Quantity, 利潤表流水號, 審核, D庸) 
308 308
                 VALUES ('" & PA & "', '" & PA1 & "', '" & PA2 & "', '" & PA3 & "', '" & PA4 & "', '" & PA5 & "', '" & PA6 & "', '" & PA7 & "', '" & PA8 & "', '" & PA9 & "', 
309 309
                         '" & PA10 & "', '" & PA11 & "', '" & PA12 & "', '" & 訂單價格利潤明細表.Currency_cb.Text & "', '" & PA13 & "', '" & PA14 & "', '" & PA15 & "', 
310
-                        '" & 利潤表流水號 & "', '" & PA17 & "')"
310
+                        '" & 利潤表流水號 & "', '" & PA17 & "', '" & PA18 & "')"
311 311
         CmdSet_For_dr()
312 312
     End Sub
313 313
     Friend Sub SQL_增加訂單控制表修改紀錄()
@@ -327,10 +327,13 @@
327 327
         SQL1 = "UPDATE " & 訂單資料表(7) & " SET  FTYPrice = '" & PA3 & "', BasicPrice = '" & PA4 & "', Polybag = '" & PA5 & "', FOOTformOrPETform = '" & PA6 & "', 
328 328
                                                   Tooling = '" & PA7 & "', RubberBand = '" & PA8 & "', JHOOK = '" & PA9 & "', WaterResistant = '" & PA10 & "', 
329 329
                                                   P16VAT = '" & PA11 & "', EXWsaving = '" & PA12 & "', Currency = '" & 訂單價格利潤明細表.Currency_cb.Text & "', 
330
-                                                  Exchange = '" & PA13 & "', 年份 = '" & PA14 & "', Quantity = '" & PA15 & "', 審核 = '" & PA16 & "' 
330
+                                                  Exchange = '" & PA13 & "', 年份 = '" & PA14 & "', Quantity = '" & PA15 & "', 審核 = '" & PA16 & "', D庸 = '" & PA18 & "'  
331 331
                         WHERE (利潤表流水號 LIKE '" & 利潤表流水號 & "')"
332 332
         CmdSet_For_dr()
333 333
     End Sub
334
+    Friend Sub SQL_修改訂單資料表2()
335
+        ConnOpen() : SQL1 = "UPDATE " & 訂單資料表(7) & " SET  D庸 = '0'  WHERE (D庸 IS NULL)" : CmdSet_For_dr()
336
+    End Sub
334 337
     '-----------------出貨銷帳明細表--------------------------------------
335 338
     Friend Sub SQL_訂單價格利潤明細表_ALL()
336 339
         列印用SQL = "WHERE (" & 訂單資料表(7) & ".年份 LIKE '" & PA25 & "' OR " & 訂單資料表(7) & ".年份 LIKE '" & PA26 & "' OR " & 訂單資料表(7) & ".年份 LIKE '" & PA27 & "') AND 
@@ -340,13 +343,13 @@
340 343
                        " & 訂單資料表(1) & ".單價, 
341 344
                        " & 訂單資料表(1) & ".總金額, " & 訂單資料表(1) & ".備註, " & 訂單資料表(1) & ".生產工廠 AS 工廠, " & 訂單資料表(1) & ".訂單種類, " & 訂單資料表(7) & ".Quantity, 
342 345
                        " & 訂單資料表(7) & ".Currency, " & 訂單資料表(7) & ".Exchange, " & 訂單資料表(7) & ".FTYPrice, (" & 訂單資料表(1) & ".單價 - " & 訂單資料表(7) & ".FTYPrice) * 
343
-                       " & 訂單資料表(7) & ".Quantity AS CommissionTTL, (" & 訂單資料表(1) & ".單價 - " & 訂單資料表(7) & ".FTYPrice) * " & 訂單資料表(7) & ".Quantity / 2 AS CommissionDarren, 
346
+                       " & 訂單資料表(7) & ".Quantity AS CommissionTTL, " & 訂單資料表(7) & ".D庸 AS CommissionDarren, 
344 347
                       (" & 訂單資料表(1) & ".單價 - " & 訂單資料表(7) & ".FTYPrice) * " & 訂單資料表(7) & ".Quantity / 2 AS CommissionTendenza, (" & 訂單資料表(1) & ".單價 - 
345 348
                        " & 訂單資料表(7) & ".FTYPrice) AS Percentage, " & 訂單資料表(7) & ".BasicPrice, " & 訂單資料表(7) & ".Polybag AS [PG/MOQ], " & 訂單資料表(7) & ".FOOTformOrPETform AS FOOTorPET, 
346 349
                        " & 訂單資料表(7) & ".Tooling, " & 訂單資料表(7) & ".RubberBand, " & 訂單資料表(7) & ".JHOOK, " & 訂單資料表(7) & ".WaterResistant, " & 訂單資料表(7) & ".P16VAT, 
347 350
                        " & 訂單資料表(7) & ".EXWsaving, " & 訂單資料表(7) & ".Quantity * " & 訂單資料表(7) & ".Tooling AS CollectedToolng, " & 訂單資料表(7) & ".年份, 
348 351
                        " & 訂單資料表(7) & ".利潤表流水號, " & 訂單資料表(1) & ".訂單數量 - " & 訂單資料表(7) & ".Quantity AS 驗證, STYLELIST.ItemNumber, " & 訂單資料表(7) & ".審核, 
349
-                       " & 訂單資料表(1) & ".客戶訂單號  
352
+                       " & 訂單資料表(1) & ".客戶訂單號
350 353
                 FROM   " & 訂單資料表(1) & " LEFT OUTER JOIN STYLELIST ON " & 訂單資料表(1) & ".形體號 = STYLELIST.ProductName RIGHT OUTER JOIN " & 訂單資料表(7) & " ON 
351 354
                        " & 訂單資料表(1) & ".資料流水號 = " & 訂單資料表(7) & ".資料流水號 " & 列印用SQL & "
352 355
                 ORDER BY " & 訂單資料表(1) & ".力威訂單號 DESC"
@@ -374,7 +377,8 @@
374 377
                           貨款銷帳明細表.訂單數 AS 實際入帳金額, 貨款銷帳明細表.EX_FTY_DATE, 貨款銷帳明細表.Maturity_Date, 
375 378
                           貨款銷帳明細表.FTY_Payment_Date, 貨款銷帳明細表.訂單數 AS 總毛利, 貨款銷帳明細表.Darren佣金, 
376 379
                           貨款銷帳明細表.Betty佣金, 貨款銷帳明細表.扣工廠手續費 AS 其他費用, 貨款銷帳明細表.訂單數 AS 公司毛利, 
377
-                          貨款銷帳明細表.Remark, QQ.客戶訂單號, 貨款銷帳明細表.已出貨 AS 異動, 貨款銷帳明細表.已出貨 AS 異動1, 貨款銷帳明細表.已出貨 AS 已比對
380
+                          貨款銷帳明細表.Remark, QQ.客戶訂單號, 貨款銷帳明細表.已出貨 AS 異動, 貨款銷帳明細表.已出貨 AS 異動1, 
381
+                          貨款銷帳明細表.已出貨 AS 已比對, 貨款銷帳明細表.已出貨 AS 模糊標註
378 382
                 FROM      貨款銷帳明細表 LEFT OUTER JOIN
379 383
                          (SELECT  客戶訂單號, 力威訂單號  FROM  " & 訂單資料表(1) & "  GROUP BY  客戶訂單號, 力威訂單號) AS QQ ON LEFT(貨款銷帳明細表.訂單號, 10) = QQ.力威訂單號
380 384
                 WHERE    (貨款銷帳明細表.年份 LIKE '" & PA25 & "')
@@ -390,7 +394,7 @@
390 394
                                           EX_FTY_DATE = N'" & PA66 & "', Maturity_Date = N'" & PA65 & "', FTY_Payment_Date = N'" & PA64 & "', Remark = N'" & PA63 & "', 
391 395
                                           Darren佣金 = N'" & PA62 & "', Betty佣金 = N'" & PA61 & "', 利息or扣款 = N'" & PA60 & "', 扣工廠手續費 = N'" & PA59 & "', 
392 396
                                           已確認 = N'" & PA58 & "', F_銀行扣款 = N'" & PA57 & "', F_文件費 = N'" & PA56 & "', F_貼標費 = N'" & PA55 & "', F_增加款 = N'" & PA54 & "', 
393
-                                          C_文件費 = N'" & PA53 & "', C_貼標費 = N'" & PA52 & "', C_利息or扣款 = N'" & PA51 & "', 已出貨 = N'" & PA50 & "'  
397
+                                          C_文件費 = N'" & PA53 & "', C_貼標費 = N'" & PA52 & "', C_利息or扣款 = N'" & PA51 & "', 已出貨 = N'" & PA50 & "', 訂單號 = '" & PA44 & "'  
394 398
                 WHERE  (流水號 LIKE '" & PA3 & "')"
395 399
         CmdSet_For_dr()
396 400
     End Sub
@@ -408,4 +412,36 @@
408 412
                             N'" & PA53 & "', N'" & PA52 & "', N'" & PA51 & "', '0')"
409 413
         CmdSet_For_dr()
410 414
     End Sub
415
+    Friend Sub SQL_模糊銷帳()
416
+        ConnOpen()
417
+        SQL1 = "SELECT  訂單號, SUM(Darren佣金) AS D庸, SUM(出貨數量) AS 出貨  FROM  貨款銷帳明細表  WHERE  (年份 LIKE '" & PA25 & "')  GROUP BY  訂單號  ORDER BY  訂單號"
418
+        CmdSet_For_DGV()
419
+    End Sub
420
+    Friend Sub SQL_模糊利潤()
421
+        ConnOpen()
422
+        SQL1 = "SELECT    " & 訂單資料表(1) & ".力威訂單號, SUM(" & 訂單資料表(7) & ".D庸) AS D庸
423
+                FROM      " & 訂單資料表(7) & " INNER JOIN
424
+                          " & 訂單資料表(1) & " ON " & 訂單資料表(7) & ".資料流水號 = " & 訂單資料表(1) & ".資料流水號
425
+                WHERE    (" & 訂單資料表(7) & ".年份 LIKE '" & PA25 & "') OR (" & 訂單資料表(7) & ".年份 LIKE '" & PA26 & "') OR
426
+                         (" & 訂單資料表(7) & ".年份 LIKE '" & PA27 & "')
427
+                GROUP BY  " & 訂單資料表(1) & ".力威訂單號  ORDER BY  " & 訂單資料表(1) & ".力威訂單號"
428
+        CmdSet_For_DGV()
429
+    End Sub
430
+    Friend Sub SQL_模糊出貨()
431
+        ConnOpen()
432
+        SQL1 = "SELECT     貨款匯入出款明細表.訂單流水號, 貨款匯入出款明細表.客戶訂單號, SUM(貨款匯入出款明細表.出貨數量) 
433
+                           AS 出貨數量, " & 訂單資料表(1) & ".力威訂單號
434
+                FROM       貨款匯入出款明細表 INNER JOIN
435
+                           " & 訂單資料表(1) & " ON 貨款匯入出款明細表.顏色 = " & 訂單資料表(1) & ".顏色 AND 
436
+                           貨款匯入出款明細表.楦型 = " & 訂單資料表(1) & ".楦型 AND 
437
+                           貨款匯入出款明細表.形體號 = " & 訂單資料表(1) & ".形體號 AND 
438
+                           貨款匯入出款明細表.訂單流水號 = " & 訂單資料表(1) & ".訂單流水號 AND 
439
+                           貨款匯入出款明細表.資料流水號 = " & 訂單資料表(1) & ".資料流水號
440
+                WHERE     (LEFT(貨款匯入出款明細表.實際離廠日, 4) LIKE '" & PA25 & "') OR
441
+                          (LEFT(貨款匯入出款明細表.實際離廠日, 4) LIKE '" & PA26 & "') OR
442
+                          (LEFT(貨款匯入出款明細表.實際離廠日, 4) LIKE '" & PA27 & "')
443
+                GROUP BY   貨款匯入出款明細表.訂單流水號, 貨款匯入出款明細表.客戶訂單號, " & 訂單資料表(1) & ".力威訂單號
444
+                ORDER BY   貨款匯入出款明細表.訂單流水號 DESC"
445
+        CmdSet_For_DGV()
446
+    End Sub
411 447
 End Module

+ 1
- 1
TENDEN-MES-SYS/Module/全域變數.vb 查看文件

@@ -3,7 +3,7 @@
3 3
     Public g_conn_type, gUserName, 版本號, Target, Target1, Target2, FTP帳號, FTP密碼, 登入人IP, AA(99), 圖片庫, SQL密碼 As String
4 4
     Public CC(99), 登入判斷 As Boolean
5 5
     '----系統版本-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
6
-    Public 版本 As String = "2023100701"
6
+    Public 版本 As String = "2023101901"
7 7
     '----系統用全域變數-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
8 8
     Public 匯率 As Double
9 9
     '----系統用全域變數----------------------------------------------------------------------------------------------------------------------------------------------------------------------

二进制
TENDEN-MES-SYS/bin/Debug/TENDEN-ERP-SYS.exe 查看文件


二进制
TENDEN-MES-SYS/bin/Debug/TENDEN-ERP-SYS.pdb 查看文件


二进制
TENDEN-MES-SYS/obj/Debug/TENDEN-ERP-SYS.exe 查看文件


二进制
TENDEN-MES-SYS/obj/Debug/TENDEN-ERP-SYS.pdb 查看文件


二进制
TENDEN-MES-SYS/obj/Debug/天盾系統.vbproj.GenerateResource.cache 查看文件


+ 135
- 45
TENDEN-MES-SYS/成本系統管理/出貨銷帳明細表.Designer.vb 查看文件

@@ -22,14 +22,20 @@ Partial Class 出貨銷帳明細表
22 22
     '請勿使用程式碼編輯器進行修改。
23 23
     <System.Diagnostics.DebuggerStepThrough()> _
24 24
     Private Sub InitializeComponent()
25
-        Dim DataGridViewCellStyle17 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
26
-        Dim DataGridViewCellStyle18 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
27
-        Dim DataGridViewCellStyle19 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
28
-        Dim DataGridViewCellStyle20 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
29
-        Dim DataGridViewCellStyle21 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
30
-        Dim DataGridViewCellStyle22 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
31
-        Dim DataGridViewCellStyle23 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
32
-        Dim DataGridViewCellStyle24 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
25
+        Dim DataGridViewCellStyle1 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
26
+        Dim DataGridViewCellStyle2 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
27
+        Dim DataGridViewCellStyle3 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
28
+        Dim DataGridViewCellStyle4 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
29
+        Dim DataGridViewCellStyle5 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
30
+        Dim DataGridViewCellStyle6 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
31
+        Dim DataGridViewCellStyle7 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
32
+        Dim DataGridViewCellStyle8 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
33
+        Dim DataGridViewCellStyle9 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
34
+        Dim DataGridViewCellStyle10 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
35
+        Dim DataGridViewCellStyle11 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
36
+        Dim DataGridViewCellStyle12 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
37
+        Dim DataGridViewCellStyle13 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
38
+        Dim DataGridViewCellStyle14 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
33 39
         Me.利潤表_dgv = New System.Windows.Forms.DataGridView()
34 40
         Me.資料庫選擇2_bt = New System.Windows.Forms.Button()
35 41
         Me.資料庫選擇1_bt = New System.Windows.Forms.Button()
@@ -67,6 +73,9 @@ Partial Class 出貨銷帳明細表
67 73
         Me.差異_上_bt = New System.Windows.Forms.Button()
68 74
         Me.比對關鍵字_bt = New System.Windows.Forms.Button()
69 75
         Me.訂單拆分_bt = New System.Windows.Forms.Button()
76
+        Me.模糊銷帳_dgv = New System.Windows.Forms.DataGridView()
77
+        Me.模糊利潤_dgv = New System.Windows.Forms.DataGridView()
78
+        Me.模糊出貨_dgv = New System.Windows.Forms.DataGridView()
70 79
         CType(Me.利潤表_dgv, System.ComponentModel.ISupportInitialize).BeginInit()
71 80
         CType(Me.訂單明細表_dgv, System.ComponentModel.ISupportInitialize).BeginInit()
72 81
         CType(Me.銷帳_dgv, System.ComponentModel.ISupportInitialize).BeginInit()
@@ -74,6 +83,9 @@ Partial Class 出貨銷帳明細表
74 83
         Me.Panel3.SuspendLayout()
75 84
         CType(Me.控制表1_dgv, System.ComponentModel.ISupportInitialize).BeginInit()
76 85
         CType(Me.控制表_dgv, System.ComponentModel.ISupportInitialize).BeginInit()
86
+        CType(Me.模糊銷帳_dgv, System.ComponentModel.ISupportInitialize).BeginInit()
87
+        CType(Me.模糊利潤_dgv, System.ComponentModel.ISupportInitialize).BeginInit()
88
+        CType(Me.模糊出貨_dgv, System.ComponentModel.ISupportInitialize).BeginInit()
77 89
         Me.SuspendLayout()
78 90
         '
79 91
         '利潤表_dgv
@@ -82,19 +94,19 @@ Partial Class 出貨銷帳明細表
82 94
             Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
83 95
         Me.利潤表_dgv.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill
84 96
         Me.利潤表_dgv.BackgroundColor = System.Drawing.Color.White
85
-        DataGridViewCellStyle17.BackColor = System.Drawing.SystemColors.Control
86
-        DataGridViewCellStyle17.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
87
-        DataGridViewCellStyle17.ForeColor = System.Drawing.SystemColors.WindowText
88
-        DataGridViewCellStyle17.SelectionBackColor = System.Drawing.SystemColors.Highlight
89
-        DataGridViewCellStyle17.SelectionForeColor = System.Drawing.SystemColors.HighlightText
90
-        DataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
91
-        Me.利潤表_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle17
97
+        DataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control
98
+        DataGridViewCellStyle1.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
99
+        DataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText
100
+        DataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight
101
+        DataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText
102
+        DataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
103
+        Me.利潤表_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle1
92 104
         Me.利潤表_dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
93 105
         Me.利潤表_dgv.Location = New System.Drawing.Point(4, 309)
94 106
         Me.利潤表_dgv.Name = "利潤表_dgv"
95 107
         Me.利潤表_dgv.RowHeadersWidth = 5
96
-        DataGridViewCellStyle18.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
97
-        Me.利潤表_dgv.RowsDefaultCellStyle = DataGridViewCellStyle18
108
+        DataGridViewCellStyle2.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
109
+        Me.利潤表_dgv.RowsDefaultCellStyle = DataGridViewCellStyle2
98 110
         Me.利潤表_dgv.RowTemplate.Height = 24
99 111
         Me.利潤表_dgv.Size = New System.Drawing.Size(1586, 176)
100 112
         Me.利潤表_dgv.TabIndex = 3
@@ -169,19 +181,19 @@ Partial Class 出貨銷帳明細表
169 181
             Or System.Windows.Forms.AnchorStyles.Left) _
170 182
             Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
171 183
         Me.銷帳_dgv.BackgroundColor = System.Drawing.Color.White
172
-        DataGridViewCellStyle19.BackColor = System.Drawing.SystemColors.Control
173
-        DataGridViewCellStyle19.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
174
-        DataGridViewCellStyle19.ForeColor = System.Drawing.SystemColors.WindowText
175
-        DataGridViewCellStyle19.SelectionBackColor = System.Drawing.SystemColors.Highlight
176
-        DataGridViewCellStyle19.SelectionForeColor = System.Drawing.SystemColors.HighlightText
177
-        DataGridViewCellStyle19.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
178
-        Me.銷帳_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle19
184
+        DataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control
185
+        DataGridViewCellStyle3.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
186
+        DataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText
187
+        DataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight
188
+        DataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText
189
+        DataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
190
+        Me.銷帳_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle3
179 191
         Me.銷帳_dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
180 192
         Me.銷帳_dgv.Location = New System.Drawing.Point(4, 35)
181 193
         Me.銷帳_dgv.Name = "銷帳_dgv"
182 194
         Me.銷帳_dgv.RowHeadersWidth = 5
183
-        DataGridViewCellStyle20.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
184
-        Me.銷帳_dgv.RowsDefaultCellStyle = DataGridViewCellStyle20
195
+        DataGridViewCellStyle4.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
196
+        Me.銷帳_dgv.RowsDefaultCellStyle = DataGridViewCellStyle4
185 197
         Me.銷帳_dgv.RowTemplate.Height = 24
186 198
         Me.銷帳_dgv.Size = New System.Drawing.Size(1586, 256)
187 199
         Me.銷帳_dgv.TabIndex = 569
@@ -353,19 +365,19 @@ Partial Class 出貨銷帳明細表
353 365
             Or System.Windows.Forms.AnchorStyles.Left) _
354 366
             Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
355 367
         Me.控制表1_dgv.BackgroundColor = System.Drawing.Color.White
356
-        DataGridViewCellStyle21.BackColor = System.Drawing.SystemColors.Control
357
-        DataGridViewCellStyle21.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
358
-        DataGridViewCellStyle21.ForeColor = System.Drawing.SystemColors.WindowText
359
-        DataGridViewCellStyle21.SelectionBackColor = System.Drawing.SystemColors.Highlight
360
-        DataGridViewCellStyle21.SelectionForeColor = System.Drawing.SystemColors.HighlightText
361
-        DataGridViewCellStyle21.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
362
-        Me.控制表1_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle21
368
+        DataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control
369
+        DataGridViewCellStyle5.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
370
+        DataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText
371
+        DataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight
372
+        DataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText
373
+        DataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
374
+        Me.控制表1_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle5
363 375
         Me.控制表1_dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
364 376
         Me.控制表1_dgv.Location = New System.Drawing.Point(2, 185)
365 377
         Me.控制表1_dgv.Name = "控制表1_dgv"
366 378
         Me.控制表1_dgv.RowHeadersWidth = 5
367
-        DataGridViewCellStyle22.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
368
-        Me.控制表1_dgv.RowsDefaultCellStyle = DataGridViewCellStyle22
379
+        DataGridViewCellStyle6.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
380
+        Me.控制表1_dgv.RowsDefaultCellStyle = DataGridViewCellStyle6
369 381
         Me.控制表1_dgv.RowTemplate.Height = 24
370 382
         Me.控制表1_dgv.Size = New System.Drawing.Size(1529, 185)
371 383
         Me.控制表1_dgv.TabIndex = 571
@@ -376,19 +388,19 @@ Partial Class 出貨銷帳明細表
376 388
             Or System.Windows.Forms.AnchorStyles.Left) _
377 389
             Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
378 390
         Me.控制表_dgv.BackgroundColor = System.Drawing.Color.White
379
-        DataGridViewCellStyle23.BackColor = System.Drawing.SystemColors.Control
380
-        DataGridViewCellStyle23.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
381
-        DataGridViewCellStyle23.ForeColor = System.Drawing.SystemColors.WindowText
382
-        DataGridViewCellStyle23.SelectionBackColor = System.Drawing.SystemColors.Highlight
383
-        DataGridViewCellStyle23.SelectionForeColor = System.Drawing.SystemColors.HighlightText
384
-        DataGridViewCellStyle23.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
385
-        Me.控制表_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle23
391
+        DataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control
392
+        DataGridViewCellStyle7.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
393
+        DataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText
394
+        DataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight
395
+        DataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText
396
+        DataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
397
+        Me.控制表_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle7
386 398
         Me.控制表_dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
387 399
         Me.控制表_dgv.Location = New System.Drawing.Point(2, 1)
388 400
         Me.控制表_dgv.Name = "控制表_dgv"
389 401
         Me.控制表_dgv.RowHeadersWidth = 5
390
-        DataGridViewCellStyle24.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
391
-        Me.控制表_dgv.RowsDefaultCellStyle = DataGridViewCellStyle24
402
+        DataGridViewCellStyle8.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
403
+        Me.控制表_dgv.RowsDefaultCellStyle = DataGridViewCellStyle8
392 404
         Me.控制表_dgv.RowTemplate.Height = 24
393 405
         Me.控制表_dgv.Size = New System.Drawing.Size(1529, 185)
394 406
         Me.控制表_dgv.TabIndex = 570
@@ -528,14 +540,85 @@ Partial Class 出貨銷帳明細表
528 540
         Me.訂單拆分_bt.Text = "訂單拆分"
529 541
         Me.訂單拆分_bt.UseVisualStyleBackColor = True
530 542
         '
543
+        '模糊銷帳_dgv
544
+        '
545
+        Me.模糊銷帳_dgv.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
546
+        Me.模糊銷帳_dgv.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill
547
+        Me.模糊銷帳_dgv.BackgroundColor = System.Drawing.Color.White
548
+        DataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Control
549
+        DataGridViewCellStyle9.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
550
+        DataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.WindowText
551
+        DataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Highlight
552
+        DataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.HighlightText
553
+        DataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
554
+        Me.模糊銷帳_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle9
555
+        Me.模糊銷帳_dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
556
+        Me.模糊銷帳_dgv.Location = New System.Drawing.Point(174, 125)
557
+        Me.模糊銷帳_dgv.Name = "模糊銷帳_dgv"
558
+        Me.模糊銷帳_dgv.RowHeadersWidth = 5
559
+        DataGridViewCellStyle10.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
560
+        Me.模糊銷帳_dgv.RowsDefaultCellStyle = DataGridViewCellStyle10
561
+        Me.模糊銷帳_dgv.RowTemplate.Height = 24
562
+        Me.模糊銷帳_dgv.Size = New System.Drawing.Size(349, 522)
563
+        Me.模糊銷帳_dgv.TabIndex = 1838
564
+        Me.模糊銷帳_dgv.Visible = False
565
+        '
566
+        '模糊利潤_dgv
567
+        '
568
+        Me.模糊利潤_dgv.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
569
+        Me.模糊利潤_dgv.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill
570
+        Me.模糊利潤_dgv.BackgroundColor = System.Drawing.Color.White
571
+        DataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control
572
+        DataGridViewCellStyle11.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
573
+        DataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText
574
+        DataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight
575
+        DataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText
576
+        DataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
577
+        Me.模糊利潤_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle11
578
+        Me.模糊利潤_dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
579
+        Me.模糊利潤_dgv.Location = New System.Drawing.Point(529, 124)
580
+        Me.模糊利潤_dgv.Name = "模糊利潤_dgv"
581
+        Me.模糊利潤_dgv.RowHeadersWidth = 5
582
+        DataGridViewCellStyle12.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
583
+        Me.模糊利潤_dgv.RowsDefaultCellStyle = DataGridViewCellStyle12
584
+        Me.模糊利潤_dgv.RowTemplate.Height = 24
585
+        Me.模糊利潤_dgv.Size = New System.Drawing.Size(349, 522)
586
+        Me.模糊利潤_dgv.TabIndex = 1839
587
+        Me.模糊利潤_dgv.Visible = False
588
+        '
589
+        '模糊出貨_dgv
590
+        '
591
+        Me.模糊出貨_dgv.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
592
+        Me.模糊出貨_dgv.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill
593
+        Me.模糊出貨_dgv.BackgroundColor = System.Drawing.Color.White
594
+        DataGridViewCellStyle13.BackColor = System.Drawing.SystemColors.Control
595
+        DataGridViewCellStyle13.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
596
+        DataGridViewCellStyle13.ForeColor = System.Drawing.SystemColors.WindowText
597
+        DataGridViewCellStyle13.SelectionBackColor = System.Drawing.SystemColors.Highlight
598
+        DataGridViewCellStyle13.SelectionForeColor = System.Drawing.SystemColors.HighlightText
599
+        DataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
600
+        Me.模糊出貨_dgv.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle13
601
+        Me.模糊出貨_dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
602
+        Me.模糊出貨_dgv.Location = New System.Drawing.Point(884, 124)
603
+        Me.模糊出貨_dgv.Name = "模糊出貨_dgv"
604
+        Me.模糊出貨_dgv.RowHeadersWidth = 5
605
+        DataGridViewCellStyle14.Font = New System.Drawing.Font("微軟正黑體", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
606
+        Me.模糊出貨_dgv.RowsDefaultCellStyle = DataGridViewCellStyle14
607
+        Me.模糊出貨_dgv.RowTemplate.Height = 24
608
+        Me.模糊出貨_dgv.Size = New System.Drawing.Size(349, 522)
609
+        Me.模糊出貨_dgv.TabIndex = 1840
610
+        Me.模糊出貨_dgv.Visible = False
611
+        '
531 612
         '出貨銷帳明細表
532 613
         '
533 614
         Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 16.0!)
534 615
         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
535 616
         Me.ClientSize = New System.Drawing.Size(1593, 679)
617
+        Me.Controls.Add(Me.模糊出貨_dgv)
618
+        Me.Controls.Add(Me.模糊利潤_dgv)
619
+        Me.Controls.Add(Me.模糊銷帳_dgv)
536 620
         Me.Controls.Add(Me.訂單拆分_bt)
537 621
         Me.Controls.Add(Me.開啟_bt)
538
-        Me.Controls.Add(Me.視窗2_pl)
539 622
         Me.Controls.Add(Me.列印_bt)
540 623
         Me.Controls.Add(Me.流水號_tb)
541 624
         Me.Controls.Add(Me.銷帳_dgv)
@@ -562,6 +645,7 @@ Partial Class 出貨銷帳明細表
562 645
         Me.Controls.Add(Me.品牌標註_lb)
563 646
         Me.Controls.Add(Me.資料庫選擇2_bt)
564 647
         Me.Controls.Add(Me.資料庫選擇1_bt)
648
+        Me.Controls.Add(Me.視窗2_pl)
565 649
         Me.Font = New System.Drawing.Font("微軟正黑體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
566 650
         Me.Margin = New System.Windows.Forms.Padding(4)
567 651
         Me.Name = "出貨銷帳明細表"
@@ -574,6 +658,9 @@ Partial Class 出貨銷帳明細表
574 658
         Me.Panel3.ResumeLayout(False)
575 659
         CType(Me.控制表1_dgv, System.ComponentModel.ISupportInitialize).EndInit()
576 660
         CType(Me.控制表_dgv, System.ComponentModel.ISupportInitialize).EndInit()
661
+        CType(Me.模糊銷帳_dgv, System.ComponentModel.ISupportInitialize).EndInit()
662
+        CType(Me.模糊利潤_dgv, System.ComponentModel.ISupportInitialize).EndInit()
663
+        CType(Me.模糊出貨_dgv, System.ComponentModel.ISupportInitialize).EndInit()
577 664
         Me.ResumeLayout(False)
578 665
         Me.PerformLayout()
579 666
 
@@ -616,4 +703,7 @@ Partial Class 出貨銷帳明細表
616 703
     Friend WithEvents 隱藏_bt As Button
617 704
     Friend WithEvents 開啟_bt As Button
618 705
     Friend WithEvents 訂單拆分_bt As Button
706
+    Friend WithEvents 模糊銷帳_dgv As DataGridView
707
+    Friend WithEvents 模糊利潤_dgv As DataGridView
708
+    Friend WithEvents 模糊出貨_dgv As DataGridView
619 709
 End Class

+ 371
- 103
TENDEN-MES-SYS/成本系統管理/出貨銷帳明細表.vb 查看文件

@@ -12,6 +12,7 @@ Public Class 出貨銷帳明細表
12 12
     Dim xlApp As Microsoft.Office.Interop.Excel.Application
13 13
     Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
14 14
     Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
15
+    Dim DF1, DF2, DF3, DF4, DF5, DF6 As Double
15 16
     Private Sub Set_訂單清單()
16 17
         Dim ds As New DataSet
17 18
         利潤表_dgv.DataSource = Nothing : ds.Clear()
@@ -96,26 +97,28 @@ Public Class 出貨銷帳明細表
96 97
             利潤表_dgv.Rows(i).Cells("單價").Value = EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) / EU(11) - EU(8)
97 98
             利潤表_dgv.Rows(i).Cells("CollectedToolng").Value = EU(9) * EU(3)
98 99
             利潤表_dgv.Rows(i).Cells("CommissionTTL").Value = ((EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) / EU(11) - EU(8)) - EU(10)) * EU(9)
99
-            利潤表_dgv.Rows(i).Cells("CommissionDarren").Value = ((EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) / EU(11) - EU(8)) - EU(10)) * EU(9) / 2
100
-            利潤表_dgv.Rows(i).Cells("CommissionTendenza").Value = ((EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) / EU(11) - EU(8)) - EU(10)) * EU(9) / 2
100
+            If EU(10) = 0 Then
101
+            Else
102
+                利潤表_dgv.Rows(i).Cells("CommissionTendenza").Value = ((EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) / EU(11) - EU(8)) - EU(10)) * EU(9) / 2
103
+            End If
101 104
             If (EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) - EU(8)) = 0 Or EU(9) = 0 Then
102 105
                 利潤表_dgv.Rows(i).Cells("Percentage").Value = 0
103 106
             Else
104 107
                 利潤表_dgv.Rows(i).Cells("Percentage").Value = ((EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) / EU(11) - EU(8)) * EU(9) - EU(10) * EU(9)) /
105
-                                                            ((EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) / EU(11) - EU(8)) * EU(9))
108
+                                                               ((EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) / EU(11) - EU(8)) * EU(9))
106 109
             End If
107 110
             利潤表_dgv.Rows(i).Cells("總金額").Value = (EU(0) + EU(1) + EU(2) + EU(3) + EU(4) + EU(5) + EU(6) + EU(7) / EU(11) - EU(8)) * EU(9)
108 111
             If 利潤表_dgv.RowCount = 0 Then : 金額加總(0) = "0.00" : Else : 金額加總(0) += 利潤表_dgv.Rows(i).Cells("總金額").Value : End If
109 112
             利潤表_dgv.Rows(i).Cells(33).Value = Strings.Left(利潤表_dgv("客戶交期", i).Value.ToString, 4)
110 113
         Next i
111
-        '5100518650
112 114
     End Sub
113 115
     Private Sub Set_出貨清單()
114 116
         Dim ds As New DataSet
115 117
         訂單明細表_dgv.DataSource = Nothing : ds.Clear()
116 118
         訂單明細表_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
117 119
         訂單明細表_dgv.ColumnHeadersHeight = 25 : 訂單明細表_dgv.AllowUserToAddRows = False : 訂單明細表_dgv.RowTemplate.Height = 20
118
-        ConnOpen() : PA = "" : PA25 = 年份_cb.Text : PA26 = CInt(PA25) - 1 : PA27 = CInt(PA25) + 1 : SQL_出貨明細表_ALL() : 列印用SQL = SQL1 : CmdSet_For_DGV()
120
+        ConnOpen() : PA = "" : PA25 = 年份_cb.Text : PA26 = CInt(PA25) - 1 : PA27 = CInt(PA25) + 1 : SQL_出貨明細表_ALL()
121
+        列印用SQL = SQL1 : CmdSet_For_DGV()
119 122
         da.Fill(ds) : 訂單明細表_dgv.DataSource = ds.Tables(0) : conn.Close()
120 123
 
121 124
         訂單明細表_dgv.Columns(0).Visible = False : 訂單明細表_dgv.Columns(1).FillWeight = 75 : 訂單明細表_dgv.Columns(2).FillWeight = 60 : 訂單明細表_dgv.Columns(3).FillWeight = 120
@@ -134,15 +137,16 @@ Public Class 出貨銷帳明細表
134 137
         訂單明細表_dgv.Columns(16).Visible = False : 訂單明細表_dgv.Columns(17).Visible = False : 訂單明細表_dgv.Columns(18).Visible = False
135 138
     End Sub
136 139
     Private Sub Set_銷帳清單()
137
-        Dim ds As New DataSet
138
-        銷帳_dgv.DataSource = Nothing : ds.Clear()
140
+        Set_模糊出貨() : Set_模糊利潤() : Set_模糊銷帳() : Dim ds As New DataSet
141
+        銷帳_dgv.DataSource = Nothing : ds.Clear() : currentRowIndex1 = -1
139 142
         銷帳_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
140 143
         銷帳_dgv.ColumnHeadersHeight = 40 : 銷帳_dgv.AllowUserToAddRows = False
141 144
         PA25 = 年份_cb.Text : If INV排序_cb.Checked = True Then : PA30 = "貨款銷帳明細表.INV DESC" : Else : PA30 = "貨款銷帳明細表.訂單號 DESC" : End If
142 145
         SQL_銷帳清單()
143 146
         da.Fill(ds) : 銷帳_dgv.DataSource = ds.Tables(0) : conn.Close()
144 147
 
145
-        銷帳_dgv.Columns(0).Visible = False : 銷帳_dgv.Columns(1).Visible = False : 銷帳_dgv.Columns(34).Visible = False : 銷帳_dgv.Columns(35).Visible = False
148
+        銷帳_dgv.Columns(0).Visible = False : 銷帳_dgv.Columns(1).Visible = False : 銷帳_dgv.Columns(34).Visible = False
149
+        銷帳_dgv.Columns(35).Visible = False
146 150
         銷帳_dgv.Columns(36).Visible = False : 銷帳_dgv.Columns(37).Visible = False
147 151
         銷帳_dgv.Columns(9).Frozen = True : 銷帳_dgv.EditMode = DataGridViewEditMode.EditOnEnter
148 152
         銷帳_dgv.Columns(6).DefaultCellStyle.Format = "#,##0" : 銷帳_dgv.Columns(7).DefaultCellStyle.Format = "#,##0"
@@ -150,49 +154,141 @@ Public Class 出貨銷帳明細表
150 154
         銷帳_dgv.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
151 155
         銷帳_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
152 156
         銷帳_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
153
-        銷帳_dgv.Columns(6).Width = 70 : 銷帳_dgv.Columns(7).Width = 70 : 銷帳_dgv.Columns(8).Width = 40 : 銷帳_dgv.Columns(9).Width = 40 : 銷帳_dgv.Columns(33).Width = 300
154
-        銷帳_dgv.Columns(35).Width = 40 : 銷帳_dgv.Columns(36).Width = 40
157
+        銷帳_dgv.Columns(6).Width = 60 : 銷帳_dgv.Columns(7).Width = 60 : 銷帳_dgv.Columns(8).Width = 40 : 銷帳_dgv.Columns(9).Width = 40 : 銷帳_dgv.Columns(33).Width = 300
158
+        銷帳_dgv.Columns(35).Width = 40 : 銷帳_dgv.Columns(36).Width = 40 : 銷帳_dgv.Columns(2).Width = 70 : 銷帳_dgv.Columns(3).Width = 40 : 銷帳_dgv.Columns(5).Width = 85
159
+        銷帳_dgv.Columns(25).Width = 90 : 銷帳_dgv.Columns(26).Width = 125 : 銷帳_dgv.Columns(27).Width = 90 : 銷帳_dgv.Columns("模糊標註").Width = 40
155 160
         For I As Integer = 2 To 9 : 銷帳_dgv.Columns(I).ReadOnly = True : Next : 銷帳_dgv.Columns(7).ReadOnly = False
156 161
         銷帳_dgv.Columns(12).ReadOnly = True : 銷帳_dgv.Columns(18).ReadOnly = True : 銷帳_dgv.Columns(20).ReadOnly = True : 銷帳_dgv.Columns(24).ReadOnly = True
157 162
         銷帳_dgv.Columns(28).ReadOnly = True : 銷帳_dgv.Columns(32).ReadOnly = True
158 163
         For I As Integer = 10 To 24
159
-            銷帳_dgv.Columns(I).DefaultCellStyle.Format = "#,##0.00"
160
-            銷帳_dgv.Columns(I).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
161
-            銷帳_dgv.Columns(I).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
162
-        Next
164
+            銷帳_dgv.Columns(I).DefaultCellStyle.Format = "#,##0.00" : 銷帳_dgv.Columns(I).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
165
+            銷帳_dgv.Columns(I).Width = 60
166
+        Next : 銷帳_dgv.Columns(18).Width = 70 : 銷帳_dgv.Columns(20).Width = 70 : 銷帳_dgv.Columns(24).Width = 70
163 167
         For I As Integer = 28 To 32
164
-            銷帳_dgv.Columns(I).DefaultCellStyle.Format = "#,##0.00"
165
-            銷帳_dgv.Columns(I).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
166
-            銷帳_dgv.Columns(I).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
168
+            銷帳_dgv.Columns(I).DefaultCellStyle.Format = "#,##0.00" : 銷帳_dgv.Columns(I).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
169
+            銷帳_dgv.Columns(I).Width = 70
167 170
         Next
168
-        For I As Integer = 0 To 銷帳_dgv.Rows.Count - 1
171
+        Dim 已完成 As Boolean = False
172
+        For I As Integer = 0 To 銷帳_dgv.Rows.Count - 1 : 已完成 = False
169 173
             銷帳_dgv(12, I).Value = 0 : 銷帳_dgv(18, I).Value = 0 : 銷帳_dgv(20, I).Value = 0 : 銷帳_dgv(24, I).Value = 0 : 銷帳_dgv(28, I).Value = 0 : 銷帳_dgv(32, I).Value = 0
170
-            銷帳_dgv(35, I).Value = False : 銷帳_dgv(36, I).Value = False : 銷帳_dgv(37, I).Value = False
174
+            銷帳_dgv(35, I).Value = False : 銷帳_dgv(36, I).Value = False : 銷帳_dgv(37, I).Value = False : 銷帳_dgv("模糊標註", I).Value = False
175
+            '--------------比對出貨明細表-------------------------------------------------------------------------------------------------------------------------------
176
+            Dim 已完成1 As Boolean = False
177
+            For II As Integer = 0 To 訂單明細表_dgv.Rows.Count - 1
178
+                If 銷帳_dgv(34, I).Value.ToString = 訂單明細表_dgv(3, II).Value.ToString Then
179
+                    If CInt(銷帳_dgv(7, I).Value.ToString) = CInt(訂單明細表_dgv(8, II).Value.ToString) Then
180
+                        銷帳_dgv(8, I).Value = True : 已完成1 = True : Exit For
181
+                    End If
182
+                End If
183
+            Next
184
+            If 已完成1 = False Then
185
+                For II As Integer = 0 To 模糊銷帳_dgv.Rows.Count - 1
186
+                    If 銷帳_dgv(5, I).Value.ToString.Replace(" ", "") = 模糊銷帳_dgv("訂單號", II).Value.ToString Then
187
+                        For X As Integer = 0 To 模糊出貨_dgv.Rows.Count - 1
188
+                            If 銷帳_dgv(5, I).Value.ToString.Replace(" ", "") = 模糊出貨_dgv("力威訂單號", X).Value.ToString Then
189
+                                If CInt(模糊銷帳_dgv(2, II).Value.ToString) = CInt(模糊出貨_dgv("出貨數量", X).Value.ToString) Then
190
+                                    銷帳_dgv(8, I).Value = True : Exit For
191
+                                End If
192
+                            End If
193
+                        Next : Exit For
194
+                    End If
195
+                Next
196
+            End If
197
+            If 銷帳_dgv(8, I).Value = False Then
198
+                For II As Integer = 2 To 7 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.White : Next
199
+                For II As Integer = 10 To 18 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.White : Next
200
+                For II As Integer = 19 To 24 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.White : Next
201
+                For II As Integer = 25 To 33 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.White : Next
202
+            Else
203
+                For II As Integer = 2 To 7 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.LightCyan : Next
204
+                For II As Integer = 10 To 18 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.Cornsilk : Next
205
+                For II As Integer = 19 To 24 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.LavenderBlush : Next
206
+                For II As Integer = 25 To 33 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.Beige : Next
207
+            End If
171 208
             '--------------比對利潤明細表-------------------------------------------------------------------------------------------------------------------------------
172 209
             For II As Integer = 0 To 利潤表_dgv.Rows.Count - 1
173 210
                 If 銷帳_dgv(5, I).Value.ToString.Replace(" ", "") = 利潤表_dgv("力威訂單號", II).Value.ToString Then
211
+                    銷帳_dgv(35, I).Value = False
212
+                    '------D傭金--------------------------------------
174 213
                     If CInt(銷帳_dgv(7, I).Value.ToString) = CInt(利潤表_dgv("數量", II).Value.ToString) Then
175 214
                         If 銷帳_dgv(29, I).Value = 0 Then
176 215
                             銷帳_dgv(29, I).Value = 利潤表_dgv(20, II).Value
177
-                        Else
178
-                            Dim DF1 As Integer = CInt(銷帳_dgv(29, I).Value) : Dim DF2 As Integer = CInt(利潤表_dgv(20, II).Value)
179
-                            If DF1 - DF2 < 2 And DF1 - DF2 > -2 Then
180
-                                銷帳_dgv(35, I).Value = False
181
-                            Else
182
-                                銷帳_dgv(35, I).Value = True
216
+                        End If
217
+                        DF1 = CDbl(銷帳_dgv(29, I).Value) : DF2 = CDbl(利潤表_dgv(20, II).Value)
218
+                        If 銷帳_dgv(29, I).Value <> 0 And 利潤表_dgv(20, II).Value <> 0 Then
219
+                            If DF1 - DF2 < 0.1 And DF1 - DF2 > -0.1 Then : Else
220
+                                銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(29).Style.BackColor = Color.LightGreen
183 221
                             End If
184
-                        End If : Exit For
222
+                        ElseIf 銷帳_dgv(29, I).Value = 0 And 利潤表_dgv(20, II).Value <> 0 Then
223
+                            銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(29).Style.BackColor = Color.LightGreen
224
+                        ElseIf 銷帳_dgv(29, I).Value <> 0 And 利潤表_dgv(20, II).Value = 0 Then
225
+                            銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(29).Style.BackColor = Color.LightGreen
226
+                        ElseIf 銷帳_dgv(29, I).Value = 0 And 利潤表_dgv(20, II).Value = 0 Then : End If
227
+
228
+                        DF3 = CDbl(銷帳_dgv(19, I).Value) : DF4 = CDbl(利潤表_dgv(10, II).Value)
229
+                        If DF3 - DF4 < 0.01 And DF3 - DF4 > -0.01 Then : Else
230
+                            銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(19).Style.BackColor = Color.LightPink
231
+                        End If
232
+
233
+                        DF5 = CDbl(銷帳_dgv(10, I).Value) : DF6 = CDbl(利潤表_dgv(18, II).Value)
234
+                        If Strings.Left(銷帳_dgv(2, I).Value.ToString, 6) = "VIONIC" Then
235
+                            If DF6 - DF5 >= 0.2 Then : 已完成 = True : Exit For : Else
236
+                                銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(10).Style.BackColor = Color.LightPink : 已完成 = True : Exit For
237
+                            End If
238
+                        ElseIf Strings.Left(銷帳_dgv(2, I).Value.ToString, 10) = "Dr.Scholls" Then
239
+                            If DF6 - DF5 >= 0.15 Then : 已完成 = True : Exit For : Else
240
+                                銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(10).Style.BackColor = Color.LightPink : 已完成 = True : Exit For
241
+                            End If
242
+                        End If
185 243
                     End If
186 244
                 End If
187 245
             Next
188
-            '--------------比對出貨明細表-------------------------------------------------------------------------------------------------------------------------------
189
-            For II As Integer = 0 To 訂單明細表_dgv.Rows.Count - 1
190
-                If 銷帳_dgv(34, I).Value.ToString = 訂單明細表_dgv(3, II).Value.ToString Then
191
-                    If CInt(銷帳_dgv(7, I).Value.ToString) = CInt(訂單明細表_dgv(8, II).Value.ToString) Then
192
-                        銷帳_dgv(8, I).Value = True : Exit For
246
+            If 已完成 = False Then
247
+                For II As Integer = 0 To 利潤表_dgv.Rows.Count - 1
248
+                    If 銷帳_dgv(5, I).Value.ToString.Replace(" ", "") = 利潤表_dgv("力威訂單號", II).Value.ToString Then
249
+                        銷帳_dgv("模糊標註", I).Value = True
250
+                        For X As Integer = 0 To 模糊銷帳_dgv.Rows.Count - 1
251
+                            If 模糊銷帳_dgv(0, X).Value.ToString.Replace(" ", "") = 銷帳_dgv(5, I).Value.ToString.Replace(" ", "") Then
252
+                                For XI As Integer = 0 To 模糊利潤_dgv.Rows.Count - 1
253
+                                    If 模糊銷帳_dgv(0, X).Value.ToString.Replace(" ", "") = 模糊利潤_dgv(0, XI).Value.ToString.Replace(" ", "") Then
254
+                                        DF1 = CDbl(模糊銷帳_dgv(1, X).Value) : DF2 = CDbl(模糊利潤_dgv(1, XI).Value)
255
+                                        If DF1 - DF2 < 0.1 And DF1 - DF2 > -0.1 Then
256
+                                            銷帳_dgv("模糊標註", I).Value = False : Exit For
257
+                                        End If
258
+                                    End If
259
+                                Next : Exit For
260
+                            End If
261
+                        Next
262
+                        If 銷帳_dgv("模糊標註", I).Value = True Then
263
+                            DF1 = CDbl(銷帳_dgv(29, I).Value) : DF2 = CDbl(利潤表_dgv(20, II).Value)
264
+                            If 銷帳_dgv(29, I).Value <> 0 And 利潤表_dgv(20, II).Value <> 0 Then
265
+                                If DF1 - DF2 < 0.1 And DF1 - DF2 > -0.1 Then : Else
266
+                                    銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(29).Style.BackColor = Color.LightGreen
267
+                                End If
268
+                            ElseIf 銷帳_dgv(29, I).Value = 0 And 利潤表_dgv(20, II).Value <> 0 Then
269
+                                銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(29).Style.BackColor = Color.LightGreen
270
+                            ElseIf 銷帳_dgv(29, I).Value <> 0 And 利潤表_dgv(20, II).Value = 0 Then
271
+                                銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(29).Style.BackColor = Color.LightGreen
272
+                            ElseIf 銷帳_dgv(29, I).Value = 0 And 利潤表_dgv(20, II).Value = 0 Then : End If
273
+                        End If
274
+                        DF3 = CDbl(銷帳_dgv(19, I).Value) : DF4 = CDbl(利潤表_dgv(10, II).Value)
275
+                        If DF3 - DF4 < 0.01 And DF3 - DF4 > -0.01 Then : Else
276
+                            銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(19).Style.BackColor = Color.LightGreen
277
+                        End If
278
+                        DF5 = CDbl(銷帳_dgv(10, I).Value) : DF6 = CDbl(利潤表_dgv(18, II).Value)
279
+                        If Strings.Left(銷帳_dgv(2, I).Value.ToString, 6) = "VIONIC" Then
280
+                            If DF6 - DF5 >= 0.2 Then : Exit For : Else
281
+                                銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(10).Style.BackColor = Color.LightGreen : Exit For
282
+                            End If
283
+                        ElseIf Strings.Left(銷帳_dgv(2, I).Value.ToString, 10) = "Dr.Scholls" Then
284
+                            If DF6 - DF5 >= 0.15 Then : Exit For : Else
285
+                                銷帳_dgv(35, I).Value = True : 銷帳_dgv.Rows(I).Cells(10).Style.BackColor = Color.LightGreen : Exit For
286
+                            End If
287
+                        End If
193 288
                     End If
194
-                End If
195
-            Next
289
+                Next
290
+            End If
291
+
196 292
             If 銷帳_dgv(8, I).Value = True Then
197 293
                 If 銷帳_dgv(11, I).Value = 0 Then
198 294
                     銷帳_dgv(12, I).Value = 銷帳_dgv(7, I).Value * 銷帳_dgv(10, I).Value
@@ -214,31 +310,38 @@ Public Class 出貨銷帳明細表
214 310
                 For II As Integer = 21 To 23 : 銷帳_dgv(II, I).ReadOnly = False : Next : For II As Integer = 25 To 27 : 銷帳_dgv(II, I).ReadOnly = False : Next
215 311
                 For II As Integer = 29 To 31 : 銷帳_dgv(II, I).ReadOnly = False : Next
216 312
             End If
217
-            '--------------色彩管理-------------------------------------------------------------------------------------------------------------------------------
218
-            If 銷帳_dgv(35, I).Value = True Then
219
-                For II As Integer = 2 To 7 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.LightPink : Next
220
-                For II As Integer = 10 To 18 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.LightPink : Next
221
-                For II As Integer = 19 To 24 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.LightPink : Next
222
-                For II As Integer = 25 To 33 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.LightPink : Next
223
-            ElseIf 銷帳_dgv(8, I).Value = False Then
224
-                For II As Integer = 2 To 7 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.White : Next
225
-                For II As Integer = 10 To 18 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.White : Next
226
-                For II As Integer = 19 To 24 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.White : Next
227
-                For II As Integer = 25 To 33 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.White : Next
228
-            Else
229
-                For II As Integer = 2 To 7 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.LightCyan : Next
230
-                For II As Integer = 10 To 18 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.Cornsilk : Next
231
-                For II As Integer = 19 To 24 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.LavenderBlush : Next
232
-                For II As Integer = 25 To 33 : 銷帳_dgv.Rows(I).Cells(II).Style.BackColor = Color.Beige : Next
233
-            End If
234 313
         Next
235 314
     End Sub
315
+    Private Sub Set_模糊銷帳()
316
+        Dim ds As New DataSet
317
+        模糊銷帳_dgv.DataSource = Nothing : ds.Clear()
318
+        模糊銷帳_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
319
+        模糊銷帳_dgv.ColumnHeadersHeight = 25 : 模糊銷帳_dgv.AllowUserToAddRows = False : 模糊銷帳_dgv.RowTemplate.Height = 20
320
+        PA25 = 年份_cb.Text : SQL_模糊銷帳()
321
+        da.Fill(ds) : 模糊銷帳_dgv.DataSource = ds.Tables(0) : conn.Close()
322
+    End Sub
323
+    Private Sub Set_模糊利潤()
324
+        Dim ds As New DataSet
325
+        模糊利潤_dgv.DataSource = Nothing : ds.Clear()
326
+        模糊利潤_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
327
+        模糊利潤_dgv.ColumnHeadersHeight = 25 : 模糊利潤_dgv.AllowUserToAddRows = False : 模糊利潤_dgv.RowTemplate.Height = 20
328
+        PA25 = 年份_cb.Text : PA26 = CInt(PA25) - 1 : PA27 = CInt(PA25) + 1 : SQL_模糊利潤()
329
+        da.Fill(ds) : 模糊利潤_dgv.DataSource = ds.Tables(0) : conn.Close()
330
+    End Sub
331
+    Private Sub Set_模糊出貨()
332
+        Dim ds As New DataSet
333
+        模糊出貨_dgv.DataSource = Nothing : ds.Clear()
334
+        模糊出貨_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
335
+        模糊出貨_dgv.ColumnHeadersHeight = 25 : 模糊出貨_dgv.AllowUserToAddRows = False : 模糊出貨_dgv.RowTemplate.Height = 20
336
+        PA25 = 年份_cb.Text : PA26 = CInt(PA25) - 1 : PA27 = CInt(PA25) + 1 : SQL_模糊出貨()
337
+        da.Fill(ds) : 模糊出貨_dgv.DataSource = ds.Tables(0) : conn.Close()
338
+    End Sub
236 339
     Private Sub 重新讀取1()
237 340
         PA25 = 年份_cb.Text : Set_訂單清單() : Set_出貨清單() : Set_銷帳清單()
238 341
     End Sub
239 342
     Private Sub 出貨銷帳明細表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
240 343
         TENDEN_MES_SYS.WindowState = 2 : 視窗2_pl.Visible = False
241
-        Me.MdiParent = TENDEN_MES_SYS : Me.WindowState = 2 : Me.AutoScroll = True : 首次開啟 = True
344
+        Me.MdiParent = TENDEN_MES_SYS : Me.WindowState = 2 : Me.AutoScroll = True : 首次開啟 = True : 模糊銷帳_dgv.Visible = False : 模糊利潤_dgv.Visible = False
242 345
         訂單資料庫選擇.ShowDialog() : If 品牌V_R判斷 = "V" Then : 品牌標註_lb.Text = "VIONIC" : Else : 品牌標註_lb.Text = "DRS/ LIF" : End If
243 346
 
244 347
         年份_cb.Text = Year(Today)
@@ -351,31 +454,111 @@ Public Class 出貨銷帳明細表
351 454
                 銷帳_dgv(12, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0 : 銷帳_dgv(18, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0
352 455
                 銷帳_dgv(20, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0 : 銷帳_dgv(24, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0
353 456
                 銷帳_dgv(28, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0 : 銷帳_dgv(32, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0
354
-
457
+                Dim 已完成 As Boolean = False
355 458
                 For II As Integer = 0 To 利潤表_dgv.Rows.Count - 1
356 459
                     If 銷帳_dgv(5, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString.Replace(" ", "") = 利潤表_dgv("力威訂單號", II).Value.ToString Then
460
+                        銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = False
357 461
                         If CInt(銷帳_dgv(7, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString) = CInt(利潤表_dgv("數量", II).Value.ToString) Then
358 462
                             If 銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0 Then
359 463
                                 銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 利潤表_dgv(20, II).Value
360
-                            Else
361
-                                Dim DF1 As Integer = CInt(銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value) : Dim DF2 As Integer = CInt(利潤表_dgv(20, II).Value)
362
-                                If DF1 - DF2 < 2 And DF1 - DF2 > -2 Then
363
-                                    銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = False
364
-                                Else
464
+                            End If
465
+                            DF1 = CDbl(銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value) : DF2 = CDbl(利潤表_dgv(20, II).Value)
466
+                            If 銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value <> 0 Then
467
+                                If DF1 - DF2 < 0.1 And DF1 - DF2 > -0.1 Then : Else
468
+                                    銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
469
+                                    銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(29).Style.BackColor = Color.LightPink
470
+                                End If
471
+                            End If
472
+                            DF3 = CDbl(銷帳_dgv(19, 銷帳_dgv.SelectedCells(0).RowIndex).Value) : DF4 = CDbl(利潤表_dgv(10, II).Value)
473
+                            If DF3 - DF4 < 0.01 And DF3 - DF4 > -0.01 Then : Else
474
+                                銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
475
+                                銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(19).Style.BackColor = Color.LightPink
476
+                            End If
477
+                            DF5 = CDbl(銷帳_dgv(10, 銷帳_dgv.SelectedCells(0).RowIndex).Value) : DF6 = CDbl(利潤表_dgv(18, II).Value)
478
+                            If Strings.Left(銷帳_dgv(2, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString, 6) = "VIONIC" Then
479
+                                If DF6 - DF5 >= 0.2 Then : 已完成 = True : Exit For : Else
365 480
                                     銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
481
+                                    銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(10).Style.BackColor = Color.LightPink : 已完成 = True : Exit For
366 482
                                 End If
367
-                            End If : Exit For
483
+                            ElseIf Strings.Left(銷帳_dgv(2, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString, 10) = "Dr.Scholls" Then
484
+                                If DF6 - DF5 >= 0.15 Then : 已完成 = True : Exit For : Else
485
+                                    銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
486
+                                    銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(10).Style.BackColor = Color.LightPink : 已完成 = True : Exit For
487
+                                End If
488
+                            End If
368 489
                         End If
369 490
                     End If
370 491
                 Next
371
-                If 銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True Then
372
-                    銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).DefaultCellStyle.BackColor = Color.LightPink
373
-                    For II As Integer = 2 To 7 : 銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(II).Style.BackColor = Color.LightPink : Next
374
-                    For II As Integer = 10 To 18 : 銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(II).Style.BackColor = Color.LightPink : Next
375
-                    For II As Integer = 19 To 24 : 銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(II).Style.BackColor = Color.LightPink : Next
376
-                    For II As Integer = 25 To 33 : 銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(II).Style.BackColor = Color.LightPink : Next
377
-                End If
492
+                If 已完成 = False Then
493
+                    For II As Integer = 0 To 利潤表_dgv.Rows.Count - 1
494
+                        If 銷帳_dgv(5, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString.Replace(" ", "") = 利潤表_dgv("力威訂單號", II).Value.ToString Then
495
+                            銷帳_dgv("模糊標註", 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
496
+                            For X As Integer = 0 To 模糊銷帳_dgv.Rows.Count - 1
497
+                                If 模糊銷帳_dgv(0, X).Value.ToString.Replace(" ", "") = 銷帳_dgv(5, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString.Replace(" ", "") Then
498
+                                    模糊銷帳_dgv(1, X).Value = 0
499
+                                    For W As Integer = 0 To 銷帳_dgv.Rows.Count - 1
500
+                                        If 銷帳_dgv(5, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString.Replace(" ", "") = 銷帳_dgv(5, W).Value.ToString.Replace(" ", "") Then
501
+                                            模糊銷帳_dgv(1, X).Value += 銷帳_dgv(29, W).Value
502
+                                        End If
503
+                                    Next
504
+                                End If : Exit For
505
+                            Next
378 506
 
507
+                            For X As Integer = 0 To 模糊銷帳_dgv.Rows.Count - 1
508
+                                If 模糊銷帳_dgv(0, X).Value.ToString.Replace(" ", "") = 銷帳_dgv(5, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString.Replace(" ", "") Then
509
+                                    模糊銷帳_dgv(1, X).Value = 0
510
+                                    For W As Integer = 0 To 銷帳_dgv.Rows.Count - 1
511
+                                        模糊銷帳_dgv(1, X).Value += 銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value
512
+                                    Next
513
+                                End If
514
+                            Next
515
+                            For X As Integer = 0 To 模糊銷帳_dgv.Rows.Count - 1
516
+                                If 模糊銷帳_dgv(0, X).Value.ToString.Replace(" ", "") = 銷帳_dgv(5, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString.Replace(" ", "") Then
517
+                                    For XI As Integer = 0 To 模糊利潤_dgv.Rows.Count - 1
518
+                                        If 模糊銷帳_dgv(0, X).Value.ToString.Replace(" ", "") = 模糊利潤_dgv(0, XI).Value.ToString.Replace(" ", "") Then
519
+                                            DF1 = CDbl(模糊銷帳_dgv(1, X).Value) : DF2 = CDbl(模糊利潤_dgv(1, XI).Value)
520
+                                            If DF1 - DF2 < 0.1 And DF1 - DF2 > -0.1 Then
521
+                                                銷帳_dgv("模糊標註", 銷帳_dgv.SelectedCells(0).RowIndex).Value = False : Exit For
522
+                                            End If
523
+                                        End If
524
+                                    Next : Exit For
525
+                                End If
526
+                            Next
527
+                            If 銷帳_dgv("模糊標註", 銷帳_dgv.SelectedCells(0).RowIndex).Value = True Then
528
+                                DF1 = CDbl(銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value) : DF2 = CDbl(利潤表_dgv(20, II).Value)
529
+                                If 銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value <> 0 And 利潤表_dgv(20, II).Value <> 0 Then
530
+                                    If DF1 - DF2 < 0.1 And DF1 - DF2 > -0.1 Then : Else
531
+                                        銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
532
+                                        銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(29).Style.BackColor = Color.LightGreen
533
+                                    End If
534
+                                ElseIf 銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0 And 利潤表_dgv(20, II).Value <> 0 Then
535
+                                    銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
536
+                                    銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(29).Style.BackColor = Color.LightGreen
537
+                                ElseIf 銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value <> 0 And 利潤表_dgv(20, II).Value = 0 Then
538
+                                    銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
539
+                                    銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(29).Style.BackColor = Color.LightGreen
540
+                                ElseIf 銷帳_dgv(29, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0 And 利潤表_dgv(20, II).Value = 0 Then : End If
541
+                            End If
542
+                            DF3 = CDbl(銷帳_dgv(19, 銷帳_dgv.SelectedCells(0).RowIndex).Value) : DF4 = CDbl(利潤表_dgv(10, II).Value)
543
+                            If DF3 - DF4 < 0.01 And DF3 - DF4 > -0.01 Then : Else
544
+                                銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
545
+                                銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(19).Style.BackColor = Color.LightGreen
546
+                            End If
547
+                            DF5 = CDbl(銷帳_dgv(10, 銷帳_dgv.SelectedCells(0).RowIndex).Value) : DF6 = CDbl(利潤表_dgv(18, II).Value)
548
+                            If Strings.Left(銷帳_dgv(2, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString, 6) = "VIONIC" Then
549
+                                If DF6 - DF5 >= 0.2 Then : Exit For : Else
550
+                                    銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
551
+                                    銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(10).Style.BackColor = Color.LightGreen : Exit For
552
+                                End If
553
+                            ElseIf Strings.Left(銷帳_dgv(2, 銷帳_dgv.SelectedCells(0).RowIndex).Value.ToString, 10) = "Dr.Scholls" Then
554
+                                If DF6 - DF5 >= 0.15 Then : Exit For : Else
555
+                                    銷帳_dgv(35, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True
556
+                                    銷帳_dgv.Rows(銷帳_dgv.SelectedCells(0).RowIndex).Cells(10).Style.BackColor = Color.LightGreen : Exit For
557
+                                End If
558
+                            End If
559
+                        End If
560
+                    Next
561
+                End If
379 562
                 If 銷帳_dgv(8, 銷帳_dgv.SelectedCells(0).RowIndex).Value = True Then
380 563
                     If 銷帳_dgv(11, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 0 Then
381 564
                         銷帳_dgv(12, 銷帳_dgv.SelectedCells(0).RowIndex).Value = 銷帳_dgv(7, 銷帳_dgv.SelectedCells(0).RowIndex).Value * 銷帳_dgv(10, 銷帳_dgv.SelectedCells(0).RowIndex).Value
@@ -424,40 +607,35 @@ Public Class 出貨銷帳明細表
424 607
             End If
425 608
         End If
426 609
     End Sub
610
+
427 611
     Private Sub 銷帳_dgv_CellContentCl(sender As Object, e As DataGridViewCellEventArgs) Handles 銷帳_dgv.CellEndEdit
428 612
         If 首次開啟 = False Then
429 613
             銷帳_dgv(12, e.RowIndex).Value = 0 : 銷帳_dgv(18, e.RowIndex).Value = 0 : 銷帳_dgv(20, e.RowIndex).Value = 0 : 銷帳_dgv(24, e.RowIndex).Value = 0
430 614
             銷帳_dgv(28, e.RowIndex).Value = 0 : 銷帳_dgv(32, e.RowIndex).Value = 0
431 615
 
616
+            '--------------比對出貨明細表-------------------------------------------------------------------------------------------------------------------------------
617
+            Dim 已完成1 As Boolean = False
432 618
             For II As Integer = 0 To 訂單明細表_dgv.Rows.Count - 1
433 619
                 If 銷帳_dgv(34, e.RowIndex).Value.ToString = 訂單明細表_dgv(3, II).Value.ToString Then
434 620
                     If CInt(銷帳_dgv(7, e.RowIndex).Value.ToString) = CInt(訂單明細表_dgv(8, II).Value.ToString) Then
435
-                        銷帳_dgv(8, e.RowIndex).Value = True : Exit For
621
+                        銷帳_dgv(8, e.RowIndex).Value = True : 已完成1 = True : Exit For
436 622
                     End If
437 623
                 End If
438 624
             Next
439
-            For II As Integer = 0 To 利潤表_dgv.Rows.Count - 1
440
-                If Strings.Left(銷帳_dgv(5, e.RowIndex).Value.ToString, 10) = 利潤表_dgv("力威訂單號", II).Value.ToString Then
441
-                    If CInt(銷帳_dgv(7, e.RowIndex).Value.ToString) = CInt(利潤表_dgv("數量", II).Value.ToString) Then
442
-                        If 銷帳_dgv(29, e.RowIndex).Value = 0 Then
443
-                            銷帳_dgv(29, e.RowIndex).Value = 利潤表_dgv(20, II).Value
444
-                        Else
445
-                            Dim DF1 As Integer = CInt(銷帳_dgv(29, e.RowIndex).Value) : Dim DF2 As Integer = CInt(利潤表_dgv(20, II).Value)
446
-                            If DF1 - DF2 < 2 And DF1 - DF2 > -2 Then
447
-                                銷帳_dgv(35, e.RowIndex).Value = False
448
-                            Else
449
-                                銷帳_dgv(35, e.RowIndex).Value = True : Exit For
625
+            If 已完成1 = False Then
626
+                For II As Integer = 0 To 模糊銷帳_dgv.Rows.Count - 1
627
+                    If 銷帳_dgv(5, e.RowIndex).Value.ToString.Replace(" ", "") = 模糊銷帳_dgv("訂單號", II).Value.ToString Then
628
+                        For X As Integer = 0 To 模糊出貨_dgv.Rows.Count - 1
629
+                            If 銷帳_dgv(5, e.RowIndex).Value.ToString.Replace(" ", "") = 模糊出貨_dgv("力威訂單號", X).Value.ToString Then
630
+                                If CInt(模糊銷帳_dgv(2, II).Value.ToString) = CInt(模糊出貨_dgv("出貨數量", X).Value.ToString) Then
631
+                                    銷帳_dgv(8, e.RowIndex).Value = True : Exit For
632
+                                End If
450 633
                             End If
451
-                        End If
634
+                        Next : Exit For
452 635
                     End If
453
-                End If
454
-            Next
455
-            If 銷帳_dgv(35, e.RowIndex).Value = True Then
456
-                For I As Integer = 2 To 7 : 銷帳_dgv.Rows(e.RowIndex).Cells(I).Style.BackColor = Color.LightPink : Next
457
-                For I As Integer = 10 To 18 : 銷帳_dgv.Rows(e.RowIndex).Cells(I).Style.BackColor = Color.LightPink : Next
458
-                For I As Integer = 19 To 24 : 銷帳_dgv.Rows(e.RowIndex).Cells(I).Style.BackColor = Color.LightPink : Next
459
-                For I As Integer = 25 To 33 : 銷帳_dgv.Rows(e.RowIndex).Cells(I).Style.BackColor = Color.LightPink : Next
460
-            ElseIf 銷帳_dgv(8, e.RowIndex).Value = False Then
636
+                Next
637
+            End If
638
+            If 銷帳_dgv(8, e.RowIndex).Value = False Then
461 639
                 For I As Integer = 2 To 7 : 銷帳_dgv.Rows(e.RowIndex).Cells(I).Style.BackColor = Color.White : Next
462 640
                 For I As Integer = 10 To 18 : 銷帳_dgv.Rows(e.RowIndex).Cells(I).Style.BackColor = Color.White : Next
463 641
                 For I As Integer = 19 To 24 : 銷帳_dgv.Rows(e.RowIndex).Cells(I).Style.BackColor = Color.White : Next
@@ -468,6 +646,97 @@ Public Class 出貨銷帳明細表
468 646
                 For I As Integer = 19 To 24 : 銷帳_dgv.Rows(e.RowIndex).Cells(I).Style.BackColor = Color.LavenderBlush : Next
469 647
                 For I As Integer = 25 To 33 : 銷帳_dgv.Rows(e.RowIndex).Cells(I).Style.BackColor = Color.Beige : Next
470 648
             End If
649
+            '--------------比對利潤明細表-------------------------------------------------------------------------------------------------------------------------------
650
+            Dim 已完成 As Boolean = False
651
+            For II As Integer = 0 To 利潤表_dgv.Rows.Count - 1
652
+                If Strings.Left(銷帳_dgv(5, e.RowIndex).Value.ToString, 10) = 利潤表_dgv("力威訂單號", II).Value.ToString Then
653
+                    銷帳_dgv(35, e.RowIndex).Value = False
654
+                    If CInt(銷帳_dgv(7, e.RowIndex).Value.ToString) = CInt(利潤表_dgv("數量", II).Value.ToString) Then
655
+                        If 銷帳_dgv(29, e.RowIndex).Value = 0 Then
656
+                            銷帳_dgv(29, e.RowIndex).Value = 利潤表_dgv(20, II).Value
657
+                        End If
658
+                        DF1 = CDbl(銷帳_dgv(29, e.RowIndex).Value) : DF2 = CDbl(利潤表_dgv(20, II).Value)
659
+                        If 銷帳_dgv(29, e.RowIndex).Value <> 0 And 利潤表_dgv(20, II).Value <> 0 Then
660
+                            If DF1 - DF2 < 0.1 And DF1 - DF2 > -0.1 Then : Else
661
+                                銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(29).Style.BackColor = Color.LightGreen
662
+                            End If
663
+                        ElseIf 銷帳_dgv(29, e.RowIndex).Value = 0 And 利潤表_dgv(20, II).Value <> 0 Then
664
+                            銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(29).Style.BackColor = Color.LightGreen
665
+                        ElseIf 銷帳_dgv(29, e.RowIndex).Value <> 0 And 利潤表_dgv(20, II).Value = 0 Then
666
+                            銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(29).Style.BackColor = Color.LightGreen
667
+                        ElseIf 銷帳_dgv(29, e.RowIndex).Value = 0 And 利潤表_dgv(20, II).Value = 0 Then : End If
668
+                        DF3 = CDbl(銷帳_dgv(19, e.RowIndex).Value) : DF4 = CDbl(利潤表_dgv(10, II).Value)
669
+                        If DF3 - DF4 < 0.01 And DF3 - DF4 > -0.01 Then : Else
670
+                            銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(19).Style.BackColor = Color.LightPink
671
+                        End If
672
+                        DF5 = CDbl(銷帳_dgv(10, e.RowIndex).Value) : DF6 = CDbl(利潤表_dgv(18, II).Value)
673
+                        If Strings.Left(銷帳_dgv(2, e.RowIndex).Value.ToString, 6) = "VIONIC" Then
674
+                            If DF6 - DF5 >= 0.2 Then : 已完成 = True : Exit For : Else
675
+                                銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(10).Style.BackColor = Color.LightPink : 已完成 = True : Exit For
676
+                            End If
677
+                        ElseIf Strings.Left(銷帳_dgv(2, e.RowIndex).Value.ToString, 10) = "Dr.Scholls" Then
678
+                            If DF6 - DF5 >= 0.15 Then : 已完成 = True : Exit For : Else
679
+                                銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(10).Style.BackColor = Color.LightPink : 已完成 = True : Exit For
680
+                            End If
681
+                        End If
682
+                    End If
683
+                End If
684
+            Next
685
+            If 已完成 = False Then
686
+                For II As Integer = 0 To 利潤表_dgv.Rows.Count - 1
687
+                    If Strings.Left(銷帳_dgv(5, e.RowIndex).Value.ToString, 10) = 利潤表_dgv("力威訂單號", II).Value.ToString Then
688
+                        銷帳_dgv("模糊標註", e.RowIndex).Value = True
689
+                        For X As Integer = 0 To 模糊銷帳_dgv.Rows.Count - 1
690
+                            If 模糊銷帳_dgv(0, X).Value.ToString.Replace(" ", "") = 銷帳_dgv(5, e.RowIndex).Value.ToString.Replace(" ", "") Then
691
+                                模糊銷帳_dgv(1, X).Value = 0
692
+                                For W As Integer = 0 To 銷帳_dgv.Rows.Count - 1
693
+                                    If 銷帳_dgv(5, e.RowIndex).Value.ToString.Replace(" ", "") = 銷帳_dgv(5, W).Value.ToString.Replace(" ", "") Then
694
+                                        模糊銷帳_dgv(1, X).Value += 銷帳_dgv(29, W).Value
695
+                                    End If
696
+                                Next : Exit For
697
+                            End If
698
+                        Next
699
+                        For X As Integer = 0 To 模糊銷帳_dgv.Rows.Count - 1
700
+                            If 模糊銷帳_dgv(0, X).Value.ToString.Replace(" ", "") = 銷帳_dgv(5, e.RowIndex).Value.ToString.Replace(" ", "") Then
701
+                                For XI As Integer = 0 To 模糊利潤_dgv.Rows.Count - 1
702
+                                    If 銷帳_dgv(5, e.RowIndex).Value.ToString.Replace(" ", "") = 模糊利潤_dgv(0, XI).Value.ToString.Replace(" ", "") Then
703
+                                        DF1 = CDbl(模糊銷帳_dgv(1, X).Value) : DF2 = CDbl(模糊利潤_dgv(1, XI).Value)
704
+                                        If DF1 - DF2 < 0.1 And DF1 - DF2 > -0.1 Then
705
+                                            銷帳_dgv("模糊標註", e.RowIndex).Value = False : Exit For
706
+                                        End If
707
+                                    End If
708
+                                Next : Exit For
709
+                            End If
710
+                        Next
711
+                        If 銷帳_dgv("模糊標註", e.RowIndex).Value = True Then
712
+                            DF1 = CDbl(銷帳_dgv(29, e.RowIndex).Value) : DF2 = CDbl(利潤表_dgv(20, II).Value)
713
+                            If 銷帳_dgv(29, e.RowIndex).Value <> 0 And 利潤表_dgv(20, II).Value <> 0 Then
714
+                                If DF1 - DF2 < 0.1 And DF1 - DF2 > -0.1 Then : Else
715
+                                    銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(29).Style.BackColor = Color.LightGreen
716
+                                End If
717
+                            ElseIf 銷帳_dgv(29, e.RowIndex).Value = 0 And 利潤表_dgv(20, II).Value <> 0 Then
718
+                                銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(29).Style.BackColor = Color.LightGreen
719
+                            ElseIf 銷帳_dgv(29, e.RowIndex).Value <> 0 And 利潤表_dgv(20, II).Value = 0 Then
720
+                                銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(29).Style.BackColor = Color.LightGreen
721
+                            ElseIf 銷帳_dgv(29, e.RowIndex).Value = 0 And 利潤表_dgv(20, II).Value = 0 Then : End If
722
+                        End If
723
+                        DF3 = CDbl(銷帳_dgv(19, e.RowIndex).Value) : DF4 = CDbl(利潤表_dgv(10, II).Value)
724
+                        If DF3 - DF4 < 0.01 And DF3 - DF4 > -0.01 Then : Else
725
+                            銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(19).Style.BackColor = Color.LightGreen
726
+                        End If
727
+                        DF5 = CDbl(銷帳_dgv(10, e.RowIndex).Value) : DF6 = CDbl(利潤表_dgv(18, II).Value)
728
+                        If Strings.Left(銷帳_dgv(2, e.RowIndex).Value.ToString, 6) = "VIONIC" Then
729
+                            If DF6 - DF5 >= 0.2 Then : Exit For : Else
730
+                                銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(10).Style.BackColor = Color.LightGreen : Exit For
731
+                            End If
732
+                        ElseIf Strings.Left(銷帳_dgv(2, e.RowIndex).Value.ToString, 10) = "Dr.Scholls" Then
733
+                            If DF6 - DF5 >= 0.15 Then : Exit For : Else
734
+                                銷帳_dgv(35, e.RowIndex).Value = True : 銷帳_dgv.Rows(e.RowIndex).Cells(10).Style.BackColor = Color.LightGreen : Exit For
735
+                            End If
736
+                        End If
737
+                    End If
738
+                Next
739
+            End If
471 740
 
472 741
             If 銷帳_dgv(8, e.RowIndex).Value = True Then
473 742
                 If 銷帳_dgv(11, e.RowIndex).Value = 0 Then
@@ -492,18 +761,16 @@ Public Class 出貨銷帳明細表
492 761
             ElseIf 控制表1_dgv.SelectedCells(0).ColumnIndex = 14 Then
493 762
                 If 控制表1_dgv.Rows(控制表1_dgv.SelectedCells(0).RowIndex).Cells(14).Value = False Then
494 763
                     控制表1_dgv.Rows(控制表1_dgv.SelectedCells(0).RowIndex).Cells(14).Value = True
495
-                    控制表1_dgv.Rows(控制表1_dgv.SelectedCells(0).RowIndex).DefaultCellStyle.BackColor = Color.LightGreen
496 764
                     控制表1_dgv.CurrentCell = 控制表1_dgv.Rows(控制表1_dgv.SelectedCells(0).RowIndex).Cells(0)
497 765
                 Else
498 766
                     控制表1_dgv.Rows(控制表1_dgv.SelectedCells(0).RowIndex).Cells(14).Value = False
499
-                    控制表1_dgv.Rows(控制表1_dgv.SelectedCells(0).RowIndex).DefaultCellStyle.BackColor = Color.White
500 767
                     控制表1_dgv.CurrentCell = 控制表1_dgv.Rows(控制表1_dgv.SelectedCells(0).RowIndex).Cells(0)
501 768
                 End If
502 769
             End If
503 770
         End If
504 771
     End Sub
505 772
     Private Sub 銷帳_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 銷帳_dgv.CellClick
506
-        If e.RowIndex = -1 Then : Else : 目前選擇項 = e.RowIndex
773
+        If e.RowIndex = -1 Then : Else : 目前選擇項 = e.RowIndex : currentRowIndex1 = e.RowIndex
507 774
             流水號_tb.Text = 銷帳_dgv.Rows(e.RowIndex).Cells(0).Value.ToString
508 775
         End If
509 776
     End Sub
@@ -511,10 +778,10 @@ Public Class 出貨銷帳明細表
511 778
         If 首次開啟 = False Then : 重新讀取1() : End If
512 779
     End Sub
513 780
     Private Sub 資料庫選擇1_bt_Click(sender As Object, e As EventArgs) Handles 資料庫選擇1_bt.Click
514
-        SQL_訂單資料表選擇_VIONIC() : 重新讀取1()
781
+        SQL_訂單資料表選擇_VIONIC() : 重新讀取1() : 品牌標註_lb.Text = "VIONIC"
515 782
     End Sub
516 783
     Private Sub 資料庫選擇2_bt_Click(sender As Object, e As EventArgs) Handles 資料庫選擇2_bt.Click
517
-        SQL_訂單資料表選擇_非VIONIC() : 重新讀取1()
784
+        SQL_訂單資料表選擇_非VIONIC() : 重新讀取1() :: 品牌標註_lb.Text = "DRS/ LIF"
518 785
     End Sub
519 786
     Private Sub INV排序_cb_Click(sender As Object, e As EventArgs) Handles INV排序_cb.Click
520 787
         INV排序_cb.Checked = True : PO排序_cb.Checked = False : If 首次開啟 = False Then : 重新讀取1() : End If
@@ -550,28 +817,28 @@ Public Class 出貨銷帳明細表
550 817
         lastFoundRowIndex = -1 : lastFoundColIndex = -1 : 查詢DGV中的關鍵字(控制表1_dgv, PO號_tb)
551 818
     End Sub
552 819
 
553
-    Private currentRowIndex As Integer = -1 ' 用于跟踪当前选定的行索引
820
+    Private currentRowIndex1 As Integer = -1 ' 用于跟踪当前选定的行索引
554 821
     Private Sub 差異_下_bt_Click(sender As Object, e As EventArgs) Handles 差異_下_bt.Click
555
-        For rowIndex As Integer = currentRowIndex + 1 To 銷帳_dgv.Rows.Count - 1        ' 从当前选定行的下一行开始搜索
822
+        For rowIndex As Integer = currentRowIndex1 + 1 To 銷帳_dgv.Rows.Count - 1        ' 从当前选定行的下一行开始搜索
556 823
             Dim cellValue As Boolean = DirectCast(銷帳_dgv.Rows(rowIndex).Cells("異動").Value, Boolean)
557 824
             Dim cellValue1 As Boolean = DirectCast(銷帳_dgv.Rows(rowIndex).Cells("異動1").Value, Boolean)
558 825
             If cellValue = True Or cellValue1 = True Then                ' 找到差异为1的数据行
559
-                銷帳_dgv.CurrentCell = 銷帳_dgv.Rows(rowIndex).Cells(29) ' 将焦点移到该行
560
-                currentRowIndex = rowIndex ' 更新当前选定的行索引
826
+                銷帳_dgv.CurrentCell = 銷帳_dgv.Rows(rowIndex).Cells(2) ' 将焦点移到该行
827
+                currentRowIndex1 = rowIndex ' 更新当前选定的行索引
561 828
                 Exit Sub
562 829
             End If
563
-        Next : MessageBox.Show("已經到達最後一筆有差異的資料。")        ' 如果没有更多的匹配项,可以显示消息或采取其他操作
830
+        Next : currentRowIndex1 = 銷帳_dgv.Rows.Count - 1 : MessageBox.Show("已經到達最後一筆有差異的資料。")        ' 如果没有更多的匹配项,可以显示消息或采取其他操作
564 831
     End Sub
565 832
     Private Sub 差異_上_bt_Click(sender As Object, e As EventArgs) Handles 差異_上_bt.Click
566
-        For rowIndex As Integer = currentRowIndex - 1 To 0 Step -1        ' 从当前选定行的上一行开始搜索
833
+        For rowIndex As Integer = currentRowIndex1 - 1 To 0 Step -1        ' 从当前选定行的上一行开始搜索
567 834
             Dim cellValue As Boolean = DirectCast(銷帳_dgv.Rows(rowIndex).Cells("異動").Value, Boolean)
568 835
             Dim cellValue1 As Boolean = DirectCast(銷帳_dgv.Rows(rowIndex).Cells("異動1").Value, Boolean)
569 836
             If cellValue = True Or cellValue1 = True Then                ' 找到差异为1的数据行
570
-                銷帳_dgv.CurrentCell = 銷帳_dgv.Rows(rowIndex).Cells(29) ' 将焦点移到该行
571
-                currentRowIndex = rowIndex ' 更新当前选定的行索引
837
+                銷帳_dgv.CurrentCell = 銷帳_dgv.Rows(rowIndex).Cells(2) ' 将焦点移到该行
838
+                currentRowIndex1 = rowIndex ' 更新当前选定的行索引
572 839
                 Exit Sub
573 840
             End If
574
-        Next : MessageBox.Show("已經到達第一筆有差異的資料。")        ' 如果没有更多的匹配项,可以显示消息或采取其他操作
841
+        Next : currentRowIndex1 = -1 : MessageBox.Show("已經到達第一筆有差異的資料。")        ' 如果没有更多的匹配项,可以显示消息或采取其他操作
575 842
     End Sub
576 843
     Private Sub 刪除_bt_Click(sender As Object, e As EventArgs) Handles 刪除_bt.Click
577 844
         If 流水號_tb.Text = "" Then : MsgBox("沒有選擇要刪除的資料!!") : Else
@@ -594,7 +861,7 @@ Public Class 出貨銷帳明細表
594 861
             Dim aa1 As MsgBoxResult = MsgBox("要存檔資料筆數為 " & 銷帳_dgv.Rows.Count & " 筆,確認後將開始執行!!  [需要時較長時間,請耐心等待統完成提示]", MsgBoxStyle.OkCancel)
595 862
             If aa1 = MsgBoxResult.Ok Then : 資料數 = 銷帳_dgv.Rows.Count
596 863
                 For i As Integer = 0 To 銷帳_dgv.Rows.Count - 1 : MyModule1.進度條()
597
-                    PA3 = 銷帳_dgv.Rows(i).Cells("流水號").Value.ToString
864
+                    PA3 = 銷帳_dgv.Rows(i).Cells("流水號").Value.ToString : PA44 = 銷帳_dgv.Rows(i).Cells("訂單號").Value.ToString.Replace(" ", "")
598 865
                     PA70 = 銷帳_dgv.Rows(i).Cells("出貨數量").Value.ToString : PA69 = 銷帳_dgv.Rows(i).Cells("FTY_PRICE").Value.ToString
599 866
                     PA68 = 銷帳_dgv.Rows(i).Cells("扣關稅or後廠價").Value.ToString : PA67 = 銷帳_dgv.Rows(i).Cells("CUST_Price").Value.ToString
600 867
                     PA66 = 銷帳_dgv.Rows(i).Cells("EX_FTY_DATE").Value.ToString : PA65 = 銷帳_dgv.Rows(i).Cells("Maturity_Date").Value.ToString
@@ -620,7 +887,8 @@ Public Class 出貨銷帳明細表
620 887
                 PA56 = 銷帳_dgv.Rows(目前選擇項).Cells("F_文件費").Value.ToString : PA55 = 銷帳_dgv.Rows(目前選擇項).Cells("F_貼標費").Value.ToString
621 888
                 PA54 = 銷帳_dgv.Rows(目前選擇項).Cells("F_增加款").Value.ToString : PA53 = 銷帳_dgv.Rows(目前選擇項).Cells("C_文件費").Value.ToString
622 889
                 PA52 = 銷帳_dgv.Rows(目前選擇項).Cells("C_貼標費").Value.ToString : PA51 = 銷帳_dgv.Rows(目前選擇項).Cells("C_利息or扣款").Value.ToString
623
-                PA50 = 銷帳_dgv.Rows(目前選擇項).Cells("已出貨").Value.ToString : SQL_銷帳清單_存檔() : MsgBox("單筆存檔完成")
890
+                PA50 = 銷帳_dgv.Rows(目前選擇項).Cells("已出貨").Value.ToString
891
+                PA44 = 銷帳_dgv.Rows(目前選擇項).Cells("訂單號").Value.ToString.Replace(" ", "") : SQL_銷帳清單_存檔() : MsgBox("單筆存檔完成")
624 892
             End If
625 893
         End If
626 894
     End Sub
@@ -797,7 +1065,7 @@ Public Class 出貨銷帳明細表
797 1065
                 If IsNothing(控制表1_dgv.Rows(i).Cells("品牌").Value) Then : PA47 = "" : Else : PA47 = 控制表1_dgv.Rows(i).Cells("品牌").Value.ToString : End If
798 1066
                 If IsNothing(控制表1_dgv.Rows(i).Cells("工廠").Value) Then : PA46 = "" : Else : PA46 = 控制表1_dgv.Rows(i).Cells("工廠").Value.ToString : End If
799 1067
                 If IsNothing(控制表1_dgv.Rows(i).Cells("INV").Value) Then : PA45 = "" : Else : PA45 = 控制表1_dgv.Rows(i).Cells("INV").Value.ToString : End If
800
-                If IsNothing(控制表1_dgv.Rows(i).Cells("訂單號").Value) Then : PA44 = "" : Else : PA44 = 控制表1_dgv.Rows(i).Cells("訂單號").Value.ToString : End If
1068
+                If IsNothing(控制表1_dgv.Rows(i).Cells("訂單號").Value) Then : PA44 = "" : Else : PA44 = 控制表1_dgv.Rows(i).Cells("訂單號").Value.ToString.Replace(" ", "") : End If
801 1069
                 If IsNothing(控制表1_dgv.Rows(i).Cells("訂單數").Value) Then : PA43 = "" : Else : PA43 = 控制表1_dgv.Rows(i).Cells("訂單數").Value.ToString : End If
802 1070
                 If IsNothing(控制表1_dgv.Rows(i).Cells("出貨數量").Value) Then : PA70 = "" : Else : PA70 = 控制表1_dgv.Rows(i).Cells("出貨數量").Value.ToString : End If
803 1071
                 If IsNothing(控制表1_dgv.Rows(i).Cells("FTY_PRICE").Value) Then : PA69 = "" : Else : PA69 = 控制表1_dgv.Rows(i).Cells("FTY_PRICE").Value.ToString : End If

+ 4
- 1
TENDEN-MES-SYS/成本系統管理/訂單價格利潤明細表.vb 查看文件

@@ -14,6 +14,7 @@ Public Class 訂單價格利潤明細表
14 14
         CmdSet_For_DGV() :: da.Fill(ds) : 利潤表_dgv.DataSource = ds.Tables(0) : conn.Close()
15 15
     End Sub
16 16
     Private Sub Set_訂單清單()
17
+        SQL_修改訂單資料表2()
17 18
         利潤表載入前設定()
18 19
         If 未建檔_cb.Checked = True Then
19 20
             Timer1.Enabled = True : 存檔_bt.Enabled = True : 刪除_bt.Enabled = False : 修改_bt.Enabled = False
@@ -420,6 +421,7 @@ Public Class 訂單價格利潤明細表
420 421
                     PA12 = 利潤表_dgv.Rows(i).Cells("EXWsaving").Value.ToString : PA13 = 利潤表_dgv.Rows(i).Cells("Exchange").Value.ToString
421 422
                     PA14 = 利潤表_dgv.Rows(i).Cells("年份").Value.ToString : PA15 = 利潤表_dgv.Rows(i).Cells("Quantity").Value.ToString
422 423
                     利潤表流水號 = 利潤表_dgv.Rows(i).Cells("利潤表流水號").Value.ToString : PA17 = 利潤表_dgv.Rows(i).Cells("審核").Value.ToString
424
+                    PA18 = 利潤表_dgv.Rows(i).Cells("CommissionDarren").Value.ToString
423 425
                     SQL_查詢最後一筆利潤表流水號()
424 426
                     If dr.Read() Then : NUM2 = Strings.Right(dr("利潤表流水號").ToString, 8) : End If : conn.Close() : NUM2 += 1
425 427
                     If NUM2 < 10 Then : 利潤表流水號 = "PR" & "0000000" & NUM2
@@ -470,7 +472,8 @@ Public Class 訂單價格利潤明細表
470 472
                 PA11 = 利潤表_dgv.Rows(i).Cells("P16VAT").Value.ToString : PA12 = 利潤表_dgv.Rows(i).Cells("EXWsaving").Value.ToString
471 473
                 PA13 = 利潤表_dgv.Rows(i).Cells("Exchange").Value.ToString : PA14 = 利潤表_dgv.Rows(i).Cells("年份").Value.ToString
472 474
                 PA15 = 利潤表_dgv.Rows(i).Cells("Quantity").Value.ToString : PA16 = 利潤表_dgv.Rows(i).Cells("審核").Value.ToString
473
-                利潤表流水號 = 利潤表_dgv.Rows(i).Cells("利潤表流水號").Value.ToString : SQL_修改訂單資料表1() : conn.Close()
475
+                利潤表流水號 = 利潤表_dgv.Rows(i).Cells("利潤表流水號").Value.ToString
476
+                PA18 = 利潤表_dgv.Rows(i).Cells("CommissionDarren").Value.ToString : SQL_修改訂單資料表1() : conn.Close()
474 477
             Next i : ProgressBar1.Value = 0 : 最終數 = 0
475 478
             MsgBox("修改完成")
476 479
             未建檔_cb.Checked = False : 已建檔_bt.Checked = True

正在加载...
取消
保存