|
@@ -1,8 +1,24 @@
|
1
|
1
|
Imports System.Data.SqlClient
|
|
2
|
+Imports System.IO
|
|
3
|
+Imports System.IO.Ports
|
|
4
|
+Imports System.Management
|
|
5
|
+Imports System.Net
|
|
6
|
+Imports System.Net.Http
|
|
7
|
+Imports System.Text
|
|
8
|
+Imports System.Threading
|
|
9
|
+Imports Newtonsoft.Json.Linq
|
|
10
|
+Imports NPOI.OpenXmlFormats.Vml
|
2
|
11
|
Public Class 塗飾工藝管理
|
3
|
12
|
Private isFlashing As Boolean = False
|
4
|
13
|
Dim colorArray(10) As Color
|
5
|
14
|
Dim 關鍵字 As String
|
|
15
|
+ Private startPoint As Point
|
|
16
|
+ Private dragRows As List(Of DataGridViewRow)
|
|
17
|
+ Private tooltipForm As 拖曳工具提示表單
|
|
18
|
+ Dim serialPort As SerialPort : Dim readThread As Thread : Dim keepReading As Boolean = False
|
|
19
|
+ Dim 化料塗飾倉 As String = "1854401756776197120"
|
|
20
|
+ Dim 塗飾配料倉 As String = "2169520885080301568"
|
|
21
|
+
|
6
|
22
|
Private Sub Set_清單1(條件 As String)
|
7
|
23
|
Dim ds1 As New DataSet
|
8
|
24
|
處方清單_dgv.DataSource = Nothing : ds1.Clear()
|
|
@@ -29,18 +45,149 @@ Public Class 塗飾工藝管理
|
29
|
45
|
Next
|
30
|
46
|
End If
|
31
|
47
|
End Sub
|
|
48
|
+ Private Sub Set_清單()
|
|
49
|
+ Dim dt As New DataTable
|
|
50
|
+ 組批單_dgv.DataSource = Nothing
|
|
51
|
+ 組批單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
|
52
|
+ 組批單_dgv.ColumnHeadersHeight = 30 : 組批單_dgv.AllowUserToAddRows = False : 組批單_dgv.RowTemplate.Height = 20
|
|
53
|
+ 組批單_dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect
|
|
54
|
+ SQL_塗飾處方_讀取組批單()
|
|
55
|
+ cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(dt)
|
|
56
|
+ 組批單_dgv.DataSource = dt
|
|
57
|
+ For i As Integer = 0 To 組批單_dgv.Columns.Count - 1 : 組批單_dgv.Columns(i).ReadOnly = True : Next
|
|
58
|
+ 組批單_dgv.ClearSelection()
|
|
59
|
+ DGV上色依分組(組批單_dgv, 0)
|
|
60
|
+ End Sub
|
|
61
|
+ Private Sub Set_清單2(流程卡號 As String)
|
|
62
|
+ Dim ds As New DataSet
|
|
63
|
+ RFID_dgv.DataSource = Nothing : ds.Clear()
|
|
64
|
+ RFID_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
|
65
|
+ RFID_dgv.ColumnHeadersHeight = 25 : RFID_dgv.AllowUserToAddRows = False
|
|
66
|
+ SQL_訂單綁定RFID清單(流程卡號)
|
|
67
|
+ da.Fill(ds) : RFID_dgv.DataSource = ds.Tables(0) : conn.Close()
|
|
68
|
+ RFID_dgv.Columns(0).ReadOnly = True
|
|
69
|
+ End Sub
|
32
|
70
|
Private Sub Frm_01_finish_rcp_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
33
|
71
|
Me.MdiParent = FrmMDI : Me.WindowState = 2 : Me.AutoScroll = True
|
34
|
72
|
colorArray(0) = Color.FromName("Aquamarine") : colorArray(1) = Color.FromName("azure") : colorArray(2) = Color.FromName("beige")
|
35
|
73
|
colorArray(3) = Color.FromName("gainsboro") : colorArray(4) = Color.FromName("LightBlue") : colorArray(5) = Color.FromName("LightSalmon")
|
36
|
|
- FrmMDI.WindowState = FormWindowState.Maximized : 視窗1_pl.Visible = False
|
|
74
|
+ FrmMDI.WindowState = FormWindowState.Maximized : 視窗1_pl.Visible = False : 使用位置_cb.Text = "組批單"
|
|
75
|
+ 計算_dgv.AllowDrop = True
|
|
76
|
+ 金蝶加入下拉式清單("jdy/v2/bd/currency", "name", "id", 幣別_cb) : 幣別_cb.SelectedIndex = -1
|
|
77
|
+ Set_組件清單() : 組件_cb.SelectedIndex = -1
|
|
78
|
+ 指令單號_tb.Text = 取得今日銷售單號()
|
37
|
79
|
End Sub
|
38
|
80
|
Private Sub Frm_01_finish_rcp_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
|
39
|
|
- 處方清單_dgv.BringToFront() : 處方名稱_lb.Text = "" : 配料_tb.Text = "2" : Set_清單1("") : Timer1.Interval = 1000
|
|
81
|
+ 處方清單_dgv.BringToFront() : 處方名稱_lb.Text = "" : 配料_tb.Text = "2" : Set_清單1("") : Set_清單() : Timer1.Interval = 1000
|
|
82
|
+ Dim clsX1 As New LrGetMtrlDatum : Dim paramLst1 As New List(Of LrParam) : Dim param1 As New LrParam()
|
|
83
|
+ param1 = New LrParam() : param1.pKey = "page" : param1.pValue = 1 : paramLst1.Add(param1)
|
|
84
|
+ param1 = New LrParam() : param1.pKey = "page_size" : param1.pValue = 1 : paramLst1.Add(param1)
|
|
85
|
+ 金蝶加入DGV("jdy/v2/scm/inv_assemble", DataGridView1)
|
|
86
|
+ End Sub
|
|
87
|
+ Private Sub DataGridView1_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseUp
|
|
88
|
+ Dim 位置 As Integer = DataGridView1.CurrentRow.Index
|
|
89
|
+ Dim str1 As String = DataGridView1.Rows(位置).Cells("bill_no").Value.ToString
|
|
90
|
+ Set_明細(str1)
|
|
91
|
+ End Sub
|
|
92
|
+ Private Sub Frm_01_finish_rc_Closing(sender As Object, e As EventArgs) Handles MyBase.Closing
|
|
93
|
+ 停止_bt.PerformClick()
|
40
|
94
|
End Sub
|
41
|
95
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
42
|
96
|
If isFlashing Then : 模式通知_lb.Text = "修改模式" : Else : 模式通知_lb.Text = "" : End If : isFlashing = Not isFlashing
|
43
|
97
|
End Sub
|
|
98
|
+ Private Sub 啟動設備()
|
|
99
|
+ ComboBox1.Items.Clear()
|
|
100
|
+ Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_PnPEntity WHERE Name LIKE '%(COM%'")
|
|
101
|
+ For Each obj As ManagementObject In searcher.Get()
|
|
102
|
+ Dim name As String = obj("Name").ToString() : ComboBox1.Items.Add(name) ' 例如:Prolific USB-to-Serial Comm Port (COM3)
|
|
103
|
+ Next
|
|
104
|
+ If ComboBox1.Items.Count > 0 Then : ComboBox1.SelectedIndex = 0 : End If
|
|
105
|
+ 開始_bt.Enabled = True : 停止_bt.Enabled = False
|
|
106
|
+ End Sub
|
|
107
|
+ Private Sub 啟動設備_bt_Click(sender As Object, e As EventArgs) Handles 啟動設備_bt.Click
|
|
108
|
+ 啟動設備()
|
|
109
|
+ End Sub
|
|
110
|
+ Private Sub 開始_bt_Click(sender As Object, e As EventArgs) Handles 開始_bt.Click
|
|
111
|
+ Try
|
|
112
|
+ If ComboBox1.SelectedItem Is Nothing Then : MsgBox("請先選擇一個 COM Port") : Return : End If
|
|
113
|
+ Dim selectedText As String = ComboBox1.SelectedItem.ToString()
|
|
114
|
+ Dim startIdx As Integer = selectedText.LastIndexOf("(COM") ' 從字串中擷取 COM Port(例如:從 "Prolific USB-To-Serial Comm Port (COM3)" 取出 "COM3")
|
|
115
|
+ Dim endIdx As Integer = selectedText.LastIndexOf(")")
|
|
116
|
+ If startIdx = -1 OrElse endIdx = -1 OrElse endIdx <= startIdx Then : MsgBox("無法解析 COM Port 名稱") : Return : End If
|
|
117
|
+ Dim comPort As String = selectedText.Substring(startIdx + 1, endIdx - startIdx - 1) ' 取出 COM3
|
|
118
|
+ serialPort = New SerialPort(comPort, 38400, Parity.None, 8, StopBits.One)
|
|
119
|
+ serialPort.ReadTimeout = 1000 : serialPort.WriteTimeout = 1000 : serialPort.Open()
|
|
120
|
+ SendCommand("Q")
|
|
121
|
+ Dim readerId As String = ReadResponse()
|
|
122
|
+ If readerId.Trim() = "" Then : MsgBox("連線失敗選到的 COM port 不是 RFID 裝置") : serialPort.Close() : Return : End If
|
|
123
|
+ keepReading = True : readThread = New Thread(AddressOf ReadLoop) : readThread.IsBackground = True : readThread.Start()
|
|
124
|
+ 開始_bt.Enabled = False : 停止_bt.Enabled = True
|
|
125
|
+ Catch ex As Exception : MsgBox("連線失敗: " & ex.Message) : End Try
|
|
126
|
+ End Sub
|
|
127
|
+ Sub SendCommand(ByVal command As String)
|
|
128
|
+ If serialPort Is Nothing OrElse Not serialPort.IsOpen Then Return
|
|
129
|
+ Dim cmdBytes As Byte() = Encoding.ASCII.GetBytes(command) : Dim fullCmd(cmdBytes.Length + 1) As Byte
|
|
130
|
+ fullCmd(0) = &HA : Array.Copy(cmdBytes, 0, fullCmd, 1, cmdBytes.Length) : fullCmd(fullCmd.Length - 1) = &HD
|
|
131
|
+ serialPort.Write(fullCmd, 0, fullCmd.Length) : Thread.Sleep(200)
|
|
132
|
+ End Sub
|
|
133
|
+ Function ReadResponse() As String
|
|
134
|
+ Dim sb As New StringBuilder()
|
|
135
|
+ Try
|
|
136
|
+ While serialPort.BytesToRead > 0
|
|
137
|
+ Dim buf(serialPort.BytesToRead - 1) As Byte : serialPort.Read(buf, 0, buf.Length)
|
|
138
|
+ sb.Append(Encoding.ASCII.GetString(buf)) : Thread.Sleep(100)
|
|
139
|
+ End While
|
|
140
|
+ Catch : End Try : Return sb.ToString()
|
|
141
|
+ End Function
|
|
142
|
+ Sub ReadLoop()
|
|
143
|
+ Try
|
|
144
|
+ While keepReading
|
|
145
|
+ Try
|
|
146
|
+ SendCommand("Q")
|
|
147
|
+ Dim response As String = ReadResponse().Trim()
|
|
148
|
+ If response.StartsWith("Q") Then : response = response.Substring(1).Trim() : End If
|
|
149
|
+ Me.Invoke(Sub()
|
|
150
|
+ If response = "" Then : RFID_tb.Text = "未讀取到卡片" : Else : RFID_tb.Text = response : End If
|
|
151
|
+ End Sub)
|
|
152
|
+ Catch ex As Exception : End Try : Thread.Sleep(1000)
|
|
153
|
+ End While
|
|
154
|
+ Catch ex As Exception : End Try
|
|
155
|
+ End Sub
|
|
156
|
+ Private Sub 停止_bt_Close_Click(sender As Object, e As EventArgs) Handles 停止_bt.Click
|
|
157
|
+ Try
|
|
158
|
+ keepReading = False
|
|
159
|
+ If readThread IsNot Nothing AndAlso readThread.IsAlive Then ' 等最多1秒
|
|
160
|
+ If Not readThread.Join(1000) Then : readThread.Abort() : End If ' ⚠️ 避免卡住(.NET Framework 才能用)
|
|
161
|
+ End If
|
|
162
|
+ If serialPort IsNot Nothing AndAlso serialPort.IsOpen Then : serialPort.Close() : End If
|
|
163
|
+ MsgBox("已斷開連線") : RFID_tb.Text = "" : 組批號_tb.Text = "" : 開始_bt.Enabled = True : 停止_bt.Enabled = False
|
|
164
|
+ Catch ex As Exception : MsgBox("關閉失敗" & ex.Message) : End Try
|
|
165
|
+ End Sub
|
|
166
|
+ Private Sub 綁定_bt_Click(sender As Object, e As EventArgs) Handles 綁定_bt.Click
|
|
167
|
+ If RFID_tb.Text = "" Or RFID_tb.Text = "未讀取到卡片" Then : MsgBox("未讀取到卡片") : Else
|
|
168
|
+ Dim card As String = ""
|
|
169
|
+ SQL_RFID卡號查詢(RFID_tb.Text)
|
|
170
|
+ If dr.Read() Then : card = dr("流程卡號").ToString() : Else : SQL_RFID卡號新增(RFID_tb.Text) : End If : conn.Close()
|
|
171
|
+ If 組批號_tb.Text = "" Then : MsgBox("流程卡號不能為空") : Else
|
|
172
|
+ If 使用位置_cb.Text = "" Then : MsgBox("使用位置不能為空") : Else
|
|
173
|
+ SQL_組批號判斷1(組批號_tb.Text)
|
|
174
|
+ If dr.Read() Then
|
|
175
|
+ If card = "" Then
|
|
176
|
+ SQL_RFID卡號綁定(RFID_tb.Text, 組批號_tb.Text, 使用位置_cb.Text) : MsgBox("綁定成功") : Set_清單1(組批號_tb.Text)
|
|
177
|
+ Else
|
|
178
|
+ Dim result As DialogResult = MessageBox.Show("此RFID卡号已经有绑定流批次号,是否进行覆盖", "請選擇", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
|
179
|
+ If result = DialogResult.Yes Then
|
|
180
|
+ SQL_RFID卡號綁定(RFID_tb.Text, 組批號_tb.Text, 使用位置_cb.Text) : MsgBox("綁定成功") : Set_清單1(組批號_tb.Text)
|
|
181
|
+ End If
|
|
182
|
+ End If
|
|
183
|
+ Else : MsgBox("資料庫中無此批次号") : End If
|
|
184
|
+ End If
|
|
185
|
+ End If : conn.Close()
|
|
186
|
+ End If
|
|
187
|
+ End Sub
|
|
188
|
+ Private Sub 組批單_dgv_SelectionChanged(sender As Object, e As EventArgs) Handles 組批單_dgv.SelectionChanged
|
|
189
|
+ Set_清單2(組批單_dgv.Rows(組批單_dgv.CurrentCell.RowIndex).Cells("批次号").Value)
|
|
190
|
+ End Sub
|
44
|
191
|
Private Sub 處方清單_dgv_SelectionChanged(sender As Object, e As EventArgs) Handles 處方清單_dgv.SelectionChanged
|
45
|
192
|
If 處方清單_dgv.Rows(處方清單_dgv.CurrentCell.RowIndex).Cells(1).Value.ToString = "" Then : 建立日期_dtp.Value = "2025/01/01"
|
46
|
193
|
Else : 建立日期_dtp.Value = 處方清單_dgv.Rows(處方清單_dgv.CurrentCell.RowIndex).Cells(1).Value : End If
|
|
@@ -76,7 +223,7 @@ Public Class 塗飾工藝管理
|
76
|
223
|
處方_dgv.Rows(e.RowIndex).Cells("份数").Style.BackColor = Color.OrangeRed
|
77
|
224
|
Else : 處方_dgv.Rows(e.RowIndex).Cells("份数").Style.BackColor = Color.White : End If
|
78
|
225
|
End Sub
|
79
|
|
- Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles 關鍵字_tb.TextChanged
|
|
226
|
+ Private Sub 關鍵字_tb_TextChanged(sender As Object, e As EventArgs) Handles 關鍵字_tb.TextChanged
|
80
|
227
|
Set_清單1("WHERE rcp_name LIKE N'%" & 關鍵字_tb.Text & "%'")
|
81
|
228
|
End Sub
|
82
|
229
|
Private Sub 输入重量_bt_Click(sender As Object, e As EventArgs) Handles 输入重量_bt.Click
|
|
@@ -139,7 +286,7 @@ Public Class 塗飾工藝管理
|
139
|
286
|
End If
|
140
|
287
|
End If
|
141
|
288
|
For i As Integer = 0 To 計算_dgv.Columns.Count - 1 : 計算_dgv.Columns(i).ReadOnly = True : Next
|
142
|
|
- 計算_dgv.Columns(0).FillWeight = 220 : 計算_dgv.Columns(5).FillWeight = 120
|
|
289
|
+ 計算_dgv.Columns(0).FillWeight = 220 : 計算_dgv.Columns(5).FillWeight = 200
|
143
|
290
|
計算_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 計算_dgv.Columns(3).DefaultCellStyle.Format = "#,##0.00"
|
144
|
291
|
計算_dgv.Columns(4).DefaultCellStyle.Format = "#,##0.00"
|
145
|
292
|
計算_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
|
|
@@ -358,8 +505,386 @@ Public Class 塗飾工藝管理
|
358
|
505
|
For i As Integer = 0 To 主檔_dgv.Columns.Count - 1 : 主檔_dgv.Columns(i).ReadOnly = True : Next
|
359
|
506
|
主檔_dgv.ClearSelection()
|
360
|
507
|
End Sub
|
|
508
|
+ Private Sub 處方_dgv_DragEnter(sender As Object, e As DragEventArgs) Handles 處方_dgv.DragEnter
|
|
509
|
+ If e.Data.GetDataPresent(GetType(List(Of DataGridViewRow))) Then : e.Effect = DragDropEffects.Copy : Else : e.Effect = DragDropEffects.None : End If
|
|
510
|
+ End Sub
|
|
511
|
+ Private Sub 計算_dgv_DragEnter(sender As Object, e As DragEventArgs) Handles 計算_dgv.DragEnter
|
|
512
|
+ If e.Data.GetDataPresent(GetType(List(Of DataGridViewRow))) Then : e.Effect = DragDropEffects.Copy : Else : e.Effect = DragDropEffects.None : End If
|
|
513
|
+ End Sub
|
|
514
|
+ Private Sub 處方_dgv_DragDrop(sender As Object, e As DragEventArgs) Handles 處方_dgv.DragDrop
|
|
515
|
+ If e.Data.GetDataPresent(GetType(List(Of DataGridViewRow))) Then
|
|
516
|
+ Dim draggedRows = CType(e.Data.GetData(GetType(List(Of DataGridViewRow))), List(Of DataGridViewRow))
|
|
517
|
+ Dim dt As DataTable = CType(處方_dgv.DataSource, DataTable)
|
|
518
|
+ Dim input As String = InputBox("請輸入每項的『份數』或重量(kg):", "輸入重量") ' 🔹 彈出輸入框:請使用者輸入重量(以數字格式)
|
|
519
|
+ Dim weight As Decimal
|
|
520
|
+ If Not Decimal.TryParse(input, weight) OrElse weight <= 0 Then
|
|
521
|
+ MessageBox.Show("請輸入有效的數字!", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Warning) : Exit Sub
|
|
522
|
+ End If
|
|
523
|
+ For Each row In draggedRows ' 🔸 驗證每筆拖入行的庫存是否足夠(假設 庫存量 在第 5 欄 = index 5)
|
|
524
|
+ Dim stockQtyStr As String = row.Cells("庫存量").Value?.ToString() : Dim stockQty As Decimal
|
|
525
|
+ If Not Decimal.TryParse(stockQtyStr, stockQty) Then stockQty = 0
|
|
526
|
+ If weight > stockQty Then
|
|
527
|
+ Dim msg As String = "輸入數量 " & weight & " 超過庫存數量 " & stockQty & "!" & vbCrLf &
|
|
528
|
+ "品名:" & row.Cells("組批名稱").Value.ToString() & vbCrLf & "是否仍要加入?"
|
|
529
|
+ Dim result = MessageBox.Show(msg, "數量超過庫存", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
|
|
530
|
+ If result = DialogResult.Cancel Then : Exit Sub ' 🛑 取消整體插入
|
|
531
|
+ ElseIf result = DialogResult.No Then : Continue For ' ❌ 跳過這筆,繼續下一筆
|
|
532
|
+ End If ' ✅ 若為 Yes,則繼續插入
|
|
533
|
+ End If
|
|
534
|
+ Next
|
|
535
|
+ For Each row In draggedRows ' 🔹 將拖曳來的資料寫入 DataTable,同時帶入輸入的重量
|
|
536
|
+ Dim newRow As DataRow = dt.NewRow()
|
|
537
|
+ For i As Integer = 0 To Math.Min(dt.Columns.Count - 1, row.Cells.Count - 1) : newRow(i) = row.Cells(i).Value : Next
|
|
538
|
+ If dt.Columns.Contains("份数") Then : newRow("份数") = weight : End If : dt.Rows.Add(newRow) ' 🟡 寫入使用者輸入的「份數」或重量(依你欄位名調整)
|
|
539
|
+ Next
|
|
540
|
+ End If
|
|
541
|
+ End Sub
|
|
542
|
+ Private Sub 計算_dgv_DragDrop(sender As Object, e As DragEventArgs) Handles 計算_dgv.DragDrop
|
|
543
|
+ '── 確認拖曳資料型別 ──────────────────────────────────────────
|
|
544
|
+ If Not e.Data.GetDataPresent(GetType(List(Of DataGridViewRow))) Then Return
|
|
545
|
+ Dim draggedRows = CType(e.Data.GetData(GetType(List(Of DataGridViewRow))), List(Of DataGridViewRow))
|
|
546
|
+ Dim dt As DataTable = CType(計算_dgv.DataSource, DataTable)
|
|
547
|
+ If dt Is Nothing Then
|
|
548
|
+ MessageBox.Show("計算_dgv 尚未綁定資料表!", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error) : Return
|
|
549
|
+ End If
|
|
550
|
+ '── 1. 先請使用者輸入重量 ────────────────────────────────────
|
|
551
|
+ Dim prefill As String = 組批單_dgv.Rows(組批單_dgv.CurrentRow.Index).Cells("庫存量").Value?.ToString()
|
|
552
|
+ Dim input As String = InputBox("請輸入每項的『份數』或重量(kg):", "輸入重量", prefill)
|
|
553
|
+ Dim weight As Decimal
|
|
554
|
+ If Not Decimal.TryParse(input, weight) OrElse weight <= 0D Then
|
|
555
|
+ MessageBox.Show("請輸入有效的數字!", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Warning) : Exit Sub
|
|
556
|
+ End If
|
|
557
|
+ '── 2. 逐列處理拖曳資料 ────────────────────────────────────
|
|
558
|
+ For Each srcRow In draggedRows
|
|
559
|
+ '=== 2-1 取得化工代碼(先名稱、再索引 1) ===
|
|
560
|
+ Dim 化工代碼 As String
|
|
561
|
+ If srcRow.DataGridView.Columns.Contains("化工代码") Then : 化工代碼 = srcRow.Cells("化工代码").Value?.ToString() : Else : 化工代碼 = srcRow.Cells(1).Value?.ToString() : End If
|
|
562
|
+ '=== 2-2 檢查是否已存在 ===
|
|
563
|
+ Dim exists As Boolean = dt.AsEnumerable().
|
|
564
|
+ Any(Function(r) r.RowState <> DataRowState.Deleted AndAlso r.Field(Of String)("化工代码") = 化工代碼)
|
|
565
|
+ If exists Then : MessageBox.Show($"組批單 [{化工代碼}] 已加入過,無法重複加入。", "重複資料", MessageBoxButtons.OK, MessageBoxIcon.Information) : Continue For : End If
|
|
566
|
+ '=== 2-3 檢查庫存量 ===
|
|
567
|
+ Dim stockQty As Decimal = 0D : Decimal.TryParse(srcRow.Cells("庫存量").Value?.ToString(), stockQty)
|
|
568
|
+ If weight > stockQty Then
|
|
569
|
+ Dim msg = $"輸入數量 {weight} 超過庫存 {stockQty}!{vbCrLf}" &
|
|
570
|
+ $"品名:{srcRow.Cells("組批名稱").Value}{vbCrLf}是否仍要加入?"
|
|
571
|
+ Select Case MessageBox.Show(msg, "數量超過庫存", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
|
|
572
|
+ Case DialogResult.Cancel : Exit Sub ' 取消整批
|
|
573
|
+ Case DialogResult.No : Continue For ' 跳過此列
|
|
574
|
+ End Select
|
|
575
|
+ End If
|
|
576
|
+ '=== 2-4 新增資料列到 dt ===
|
|
577
|
+ Dim newRow As DataRow = dt.NewRow()
|
|
578
|
+ newRow("化工品名") = srcRow.Cells("組批名稱").Value
|
|
579
|
+ newRow("化工分类") = "组装单"
|
|
580
|
+ newRow("化工代码") = 化工代碼
|
|
581
|
+ newRow("重量 (kg)") = weight
|
|
582
|
+ newRow("总重量 (kg)") = srcRow.Cells("批次号").Value
|
|
583
|
+ ' 🔍 從總計行取得總重量與總份數
|
|
584
|
+ Dim totalRowInfo = dt.AsEnumerable().FirstOrDefault(Function(r) r.RowState <> DataRowState.Deleted AndAlso r.Field(Of String)("化工品名") = "总计")
|
|
585
|
+ Dim totalWeight As Decimal = If(totalRowInfo IsNot Nothing, totalRowInfo.Field(Of Decimal?)("重量 (kg)").GetValueOrDefault(), 0D)
|
|
586
|
+ Dim totalPortion As Decimal = If(totalRowInfo IsNot Nothing, totalRowInfo.Field(Of Decimal?)("份数").GetValueOrDefault(), 0D)
|
361
|
587
|
|
|
588
|
+ ' 🧮 換算本筆的份數(按比例)
|
|
589
|
+ Dim portion As Decimal = 1D
|
|
590
|
+ If totalWeight > 0 AndAlso totalPortion > 0 Then
|
|
591
|
+ portion = weight / (totalWeight / totalPortion)
|
|
592
|
+ End If
|
|
593
|
+ newRow("份数") = Math.Round(portion, 2)
|
|
594
|
+
|
|
595
|
+ ' ✅ 插入資料列
|
|
596
|
+ dt.Rows.InsertAt(newRow, 0)
|
|
597
|
+ Next
|
|
598
|
+ '── 1. 先移除原有總計行 ───────────────────────────────
|
|
599
|
+ Dim oldTotalRow = dt.AsEnumerable().FirstOrDefault(Function(r) r.RowState <> DataRowState.Deleted AndAlso r.Field(Of String)("化工品名") = "总计")
|
|
600
|
+ If oldTotalRow IsNot Nothing Then dt.Rows.Remove(oldTotalRow)
|
362
|
601
|
|
|
602
|
+ '── 2. 重新計算 ──────────────────────────────────────
|
|
603
|
+ Dim sumPortions As Decimal = 0D
|
|
604
|
+ Dim sumWeight As Decimal = 0D
|
|
605
|
+ For Each r As DataRow In dt.Rows
|
|
606
|
+ If r.RowState = DataRowState.Deleted Then Continue For
|
|
607
|
+ If r.Field(Of String)("化工品名") = "总计" Then Continue For
|
|
608
|
+ sumPortions += r.Field(Of Decimal?)("份数").GetValueOrDefault()
|
|
609
|
+ sumWeight += r.Field(Of Decimal?)("重量 (kg)").GetValueOrDefault()
|
|
610
|
+ Next
|
|
611
|
+
|
|
612
|
+ '── 3. 加入新的「总计」行 ──────────────────────────
|
|
613
|
+ Dim totalRow As DataRow = dt.NewRow()
|
|
614
|
+ totalRow("化工品名") = "总计"
|
|
615
|
+ totalRow("份数") = sumPortions
|
|
616
|
+ totalRow("重量 (kg)") = sumWeight
|
|
617
|
+ totalRow("总重量 (kg)") = sumWeight
|
|
618
|
+ dt.Rows.Add(totalRow)
|
|
619
|
+ '── 4. 套用紅色粗體樣式至「總計」行 ───────────────────────
|
|
620
|
+ Dim gvRow = 計算_dgv.Rows(dt.Rows.IndexOf(totalRow))
|
|
621
|
+ For Each c As DataGridViewCell In gvRow.Cells : c.Style.Font = New Font("微軟正黑體", 9, FontStyle.Bold) : c.Style.ForeColor = Color.Red : Next
|
|
622
|
+ End Sub
|
|
623
|
+ Private Sub 組批單_dgv_MouseDown(sender As Object, e As MouseEventArgs) Handles 組批單_dgv.MouseDown
|
|
624
|
+ startPoint = e.Location
|
|
625
|
+ End Sub
|
|
626
|
+ Private Sub 組批單_dgv_MouseMove(sender As Object, e As MouseEventArgs) Handles 組批單_dgv.MouseMove ' MouseMove - 開始拖曳
|
|
627
|
+ If e.Button = MouseButtons.Left Then
|
|
628
|
+ Dim dx = Math.Abs(e.X - startPoint.X)
|
|
629
|
+ Dim dy = Math.Abs(e.Y - startPoint.Y)
|
|
630
|
+ If dx >= SystemInformation.DragSize.Width OrElse dy >= SystemInformation.DragSize.Height Then
|
|
631
|
+ If 組批單_dgv.SelectedRows.Count > 0 Then
|
|
632
|
+ dragRows = 組批單_dgv.SelectedRows.Cast(Of DataGridViewRow).ToList()
|
|
633
|
+ Dim thirdColValue As String = dragRows(0).Cells(2).Value?.ToString() ' 🟡 顯示第 3 欄(index = 2)的值作為浮動提示
|
|
634
|
+ tooltipForm = New 拖曳工具提示表單() : tooltipForm.SetText("拖曳中:" & thirdColValue)
|
|
635
|
+ tooltipForm.SetPosition(Cursor.Position) : tooltipForm.Show()
|
|
636
|
+ AddHandler Me.GiveFeedback, AddressOf Form1_GiveFeedback ' 綁定事件(只有第一次綁定)
|
|
637
|
+ AddHandler Me.QueryContinueDrag, AddressOf Form1_QueryContinueDrag
|
|
638
|
+ Me.DoDragDrop(dragRows, DragDropEffects.Copy) ' 啟動拖曳
|
|
639
|
+ End If
|
|
640
|
+ End If
|
|
641
|
+ End If
|
|
642
|
+ End Sub
|
|
643
|
+ Private Sub Form1_GiveFeedback(sender As Object, e As GiveFeedbackEventArgs) ' 更新提示窗位置
|
|
644
|
+ tooltipForm?.SetPosition(Cursor.Position) : e.UseDefaultCursors = True
|
|
645
|
+ End Sub
|
|
646
|
+ Private Sub Form1_QueryContinueDrag(sender As Object, e As QueryContinueDragEventArgs) ' 拖曳結束時關閉提示窗
|
|
647
|
+ If e.Action = DragAction.Drop OrElse e.Action = DragAction.Cancel Then
|
|
648
|
+ If tooltipForm IsNot Nothing Then : tooltipForm.Close() : tooltipForm.Dispose() : tooltipForm = Nothing : End If
|
|
649
|
+ RemoveHandler Me.GiveFeedback, AddressOf Form1_GiveFeedback
|
|
650
|
+ RemoveHandler Me.QueryContinueDrag, AddressOf Form1_QueryContinueDrag
|
|
651
|
+ End If
|
|
652
|
+ End Sub
|
|
653
|
+ Private Sub 組批單_dgv_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles 組批單_dgv.CellMouseUp
|
|
654
|
+ Dim 位置 As Integer = 組批單_dgv.CurrentRow.Index
|
|
655
|
+ 'Dim str As String = 組批單_dgv.Rows(位置).Cells("片数").Value.ToString
|
|
656
|
+ Dim str1 As String = 組批單_dgv.Rows(位置).Cells("組批單号").Value.ToString
|
|
657
|
+ Set_明細(str1)
|
|
658
|
+ End Sub
|
|
659
|
+ Private Sub Set_明細(number As String)
|
|
660
|
+ 明細_dgv.DataSource = Nothing
|
|
661
|
+ 明細_dgv.Rows.Clear()
|
|
662
|
+ 明細_dgv.Columns.Clear()
|
|
663
|
+ 明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
|
664
|
+ 明細_dgv.ColumnHeadersHeight = 30
|
|
665
|
+ 明細_dgv.AllowUserToAddRows = False
|
|
666
|
+ 明細_dgv.RowTemplate.Height = 20
|
|
667
|
+
|
|
668
|
+ Dim clsX As New LrGetMtrlDatum
|
|
669
|
+ Dim paramLst11 As New List(Of LrParam)
|
|
670
|
+ paramLst11.Add(New LrParam With {.pKey = "number", .pValue = number})
|
|
671
|
+
|
|
672
|
+ Dim strJson As String = clsX.GetDatumX(gClientID, gClientSecret, gAppToken, paramLst11, "jdy/v2/scm/inv_assemble_detail")
|
|
673
|
+ Dim pageData As JObject = JObject.Parse(strJson)
|
|
674
|
+ Dim materialEntities As JArray = pageData("data")("material_entity")
|
|
675
|
+
|
|
676
|
+ ' 建立資料表來存資料
|
|
677
|
+ Dim dt As New DataTable()
|
|
678
|
+ dt.Columns.Add("品名")
|
|
679
|
+ dt.Columns.Add("商品編號")
|
|
680
|
+ dt.Columns.Add("倉庫")
|
|
681
|
+ dt.Columns.Add("批號")
|
|
682
|
+ dt.Columns.Add("數量")
|
|
683
|
+ dt.Columns.Add("類型")
|
|
684
|
+ dt.Columns.Add("順序")
|
|
685
|
+
|
|
686
|
+ ' 將每筆資料加入 DataTable
|
|
687
|
+ For Each materialEntity As JObject In materialEntities
|
|
688
|
+ Dim row As DataRow = dt.NewRow()
|
|
689
|
+ row("品名") = materialEntity("material_name").ToString()
|
|
690
|
+ row("商品編號") = materialEntity("material_number").ToString()
|
|
691
|
+ row("倉庫") = materialEntity("stock_name").ToString()
|
|
692
|
+ row("批號") = materialEntity("batch_no").ToString()
|
|
693
|
+ row("數量") = materialEntity("qty").ToString()
|
|
694
|
+ row("類型") = materialEntity("material_type").ToString()
|
|
695
|
+ row("順序") = materialEntity("seq").ToString()
|
|
696
|
+ dt.Rows.Add(row)
|
|
697
|
+ Next
|
|
698
|
+
|
|
699
|
+ ' 將資料表指定給 DataGridView 顯示
|
|
700
|
+ 明細_dgv.DataSource = dt
|
|
701
|
+ End Sub
|
|
702
|
+
|
|
703
|
+ Private Sub Set_組件清單()
|
|
704
|
+ Dim ds1 As New DataSet
|
|
705
|
+ 清單_dgv.DataSource = Nothing : ds1.Clear()
|
|
706
|
+ 清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
|
707
|
+ 清單_dgv.ColumnHeadersHeight = 30 : 清單_dgv.AllowUserToAddRows = False : 清單_dgv.RowTemplate.Height = 20
|
|
708
|
+ 清單_dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect
|
|
709
|
+ SQL_塗飾組件清單()
|
|
710
|
+ da.Fill(ds1) : 清單_dgv.DataSource = ds1.Tables(0) : conn.Close()
|
|
711
|
+
|
|
712
|
+ 組件_cb.Items.Clear()
|
|
713
|
+ For i As Integer = 0 To 清單_dgv.Rows.Count - 1
|
|
714
|
+ 組件_cb.Items.Add(清單_dgv.Rows(i).Cells("name").Value)
|
|
715
|
+ Next
|
|
716
|
+ End Sub
|
|
717
|
+ Private Sub 組件cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 組件_cb.SelectedIndexChanged
|
|
718
|
+ Dim str As String = 清單_dgv.Rows(組件_cb.SelectedIndex).Cells("name").Value
|
|
719
|
+ MessageBox.Show(str)
|
|
720
|
+ End Sub
|
|
721
|
+ Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
722
|
+ Dim 日期 As String = Strings.Format(Today(), "yyyy-MM-dd")
|
|
723
|
+ Dim clsX As New LrGetMtrlDatum : Dim MaterialEntity As New JArray()
|
|
724
|
+ Dim material1 As New JObject() : Dim material2 As New JObject() : Dim material3 As New JObject()
|
|
725
|
+ Dim index As Integer = 組件_cb.SelectedIndex
|
|
726
|
+ Dim rowCount As Integer = 計算_dgv.Rows.Count - 1
|
|
727
|
+ Dim errcode As Integer : Dim jsonResult As JObject
|
|
728
|
+ material1("material_id") = 清單_dgv.Rows(index).Cells("id").Value.ToString()
|
|
729
|
+ material1("unit_id") = 清單_dgv.Rows(index).Cells("base_unit_id").Value.ToString()
|
|
730
|
+ material1("base_unit_id") = 清單_dgv.Rows(index).Cells("base_unit_id").Value.ToString()
|
|
731
|
+ material1("pro_place") = 清單_dgv.Rows(index).Cells("producing_pace").Value.ToString()
|
|
732
|
+ material1("material_type") = "M"
|
|
733
|
+ material1("qty") = Decimal.Parse(計算_dgv.Rows(rowCount).Cells("份数").Value)
|
|
734
|
+ material1("stock_id") = 塗飾配料倉
|
|
735
|
+ material1("batch_no") = 批號_tb.Text
|
|
736
|
+ material1("base_qty") = Decimal.Parse(計算_dgv.Rows(rowCount).Cells("份数").Value)
|
|
737
|
+ material1("cost_share_percent") = 100
|
|
738
|
+
|
|
739
|
+ MaterialEntity.Add(material1)
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+ For I As Integer = 0 To 計算_dgv.Rows.Count - 2
|
|
743
|
+ Dim material As New JObject()
|
|
744
|
+ Dim name As String = 計算_dgv.Rows(I).Cells("化工品名").Value.ToString()
|
|
745
|
+ SQL_塗飾化料查詢(name)
|
|
746
|
+ If dr.Read Then
|
|
747
|
+ material("material_id") = dr("id").ToString
|
|
748
|
+ material("unit_id") = dr("base_unit_id").ToString
|
|
749
|
+ material("base_unit_id") = dr("base_unit_id").ToString
|
|
750
|
+ material("pro_place") = dr("producing_pace").ToString
|
|
751
|
+ End If : conn.Close()
|
|
752
|
+ material("material_type") = "S"
|
|
753
|
+ material("qty") = Decimal.Parse(計算_dgv.Rows(I).Cells("份数").Value)
|
|
754
|
+ If 計算_dgv.Rows(I).Cells("化工分类").Value = "组装单" Then
|
|
755
|
+ material("stock_id") = 塗飾配料倉
|
|
756
|
+ material("batch_no") = 計算_dgv.Rows(I).Cells("总重量 (kg)").Value.ToString()
|
|
757
|
+ Else
|
|
758
|
+ material("stock_id") = 化料塗飾倉
|
|
759
|
+ material("batch_no") = ""
|
|
760
|
+ End If
|
|
761
|
+ material("base_qty") = Decimal.Parse(計算_dgv.Rows(I).Cells("份数").Value)
|
|
762
|
+ material("cost_share_percent") = 0
|
|
763
|
+ MaterialEntity.Add(material)
|
|
764
|
+ Next
|
|
765
|
+
|
|
766
|
+ Dim postbody As New JObject()
|
|
767
|
+ postbody("bill_date") = DateTime.Today.ToString("yyyy-MM-dd")
|
|
768
|
+ postbody("allocate_rule") = "1"
|
|
769
|
+ postbody("bill_no") = 指令單號_tb.Text
|
|
770
|
+ postbody("currency_id") = 幣別_cb.SelectedValue.ToString()
|
|
771
|
+ postbody("material_entity") = MaterialEntity
|
|
772
|
+
|
|
773
|
+ Dim strJson As String = clsX.GetDatumX1(gClientID, gClientSecret, gAppToken, "jdy/v2/scm/inv_assemble", postbody.ToString())
|
|
774
|
+ If strJson = "" Then
|
|
775
|
+ MsgBox("匯入失敗")
|
|
776
|
+ Else
|
|
777
|
+ jsonResult = JObject.Parse(strJson)
|
|
778
|
+ errcode = jsonResult("errcode")
|
|
779
|
+ If errcode = 0 Then
|
|
780
|
+ MsgBox("匯入成功")
|
|
781
|
+ Dim id As String = 金蝶找單號之ID("jdy/v2/scm/inv_assemble", "ZZD-20250528-00006", "id") '指令單號_tb.Text
|
|
782
|
+
|
|
783
|
+ SQL_塗飾_組裝單清單寫入(日期, 指令單號_tb.Text, id, "")
|
|
784
|
+
|
|
785
|
+ Dim 名稱 As String = 清單_dgv.Rows(index).Cells("name").Value.ToString()
|
|
786
|
+ Dim 編號 As String = 清單_dgv.Rows(index).Cells("number").Value.ToString()
|
|
787
|
+ Dim 倉庫 As String = "塗飾配料倉"
|
|
788
|
+ Dim 批號 As String = 批號_tb.Text
|
|
789
|
+ Dim 數量 As String = Decimal.Parse(計算_dgv.Rows(rowCount).Cells("份数").Value).ToString()
|
|
790
|
+ SQL_塗飾_組裝單明細寫入(名稱, 編號, 倉庫, 批號, 數量, "M", 1, id)
|
|
791
|
+
|
|
792
|
+ For I As Integer = 0 To 計算_dgv.Rows.Count - 2
|
|
793
|
+ Dim material As New JObject()
|
|
794
|
+ Dim name As String = 計算_dgv.Rows(I).Cells("化工品名").Value.ToString()
|
|
795
|
+ SQL_塗飾化料查詢(name)
|
|
796
|
+ Dim 名稱1 As String = ""
|
|
797
|
+ Dim 編號1 As String = ""
|
|
798
|
+ Dim 倉庫1 As String = ""
|
|
799
|
+ Dim 批號1 As String = ""
|
|
800
|
+ If dr.Read Then
|
|
801
|
+ 名稱1 = dr("name").ToString
|
|
802
|
+ 編號1 = dr("number").ToString
|
|
803
|
+ End If : conn.Close()
|
|
804
|
+
|
|
805
|
+ Dim 數量1 As String = Decimal.Parse(計算_dgv.Rows(I).Cells("份数").Value)
|
|
806
|
+ If 計算_dgv.Rows(I).Cells("化工分类").Value = "组装单" Then
|
|
807
|
+ 倉庫1 = "塗飾配料倉"
|
|
808
|
+ 批號1 = 計算_dgv.Rows(I).Cells("总重量 (kg)").Value.ToString()
|
|
809
|
+ Else
|
|
810
|
+ 倉庫1 = "化料塗飾倉"
|
|
811
|
+ 批號1 = ""
|
|
812
|
+ End If
|
|
813
|
+ SQL_塗飾_組裝單明細寫入(名稱1, 編號1, 倉庫1, 批號1, 數量1, "S", (I + 2).ToString(), id)
|
|
814
|
+ Next : conn.Close()
|
|
815
|
+
|
|
816
|
+ Else
|
|
817
|
+ ' 匯入失敗,顯示錯誤訊息
|
|
818
|
+ MsgBox("金蝶匯入失敗:" & jsonResult("description").ToString())
|
|
819
|
+ End If
|
|
820
|
+ End If
|
|
821
|
+ End Sub
|
|
822
|
+ Public Function 取得今日銷售單號() As String
|
|
823
|
+ Dim 最新單號 As String = 金蝶找最新流水號("jdy/v2/scm/inv_assemble", "bill_no")
|
|
824
|
+ Dim 今日日期 As String = DateTime.Now.ToString("yyyyMMdd")
|
|
825
|
+ Dim 新單號 As String
|
|
826
|
+ If 最新單號.StartsWith("ZZD-" & 今日日期) Then
|
|
827
|
+ ' 從最新單號中取出後面的流水號部分
|
|
828
|
+ Dim parts As String() = 最新單號.Split("-"c)
|
|
829
|
+ If parts.Length = 3 Then
|
|
830
|
+ Dim 流水號 As Integer = Integer.Parse(parts(2))
|
|
831
|
+ 流水號 += 1
|
|
832
|
+ 新單號 = $"ZZD-{今日日期}-{流水號.ToString("00000")}"
|
|
833
|
+ Else
|
|
834
|
+ ' 格式異常,回傳從00001開始
|
|
835
|
+ 新單號 = $"ZZD-{今日日期}-00001"
|
|
836
|
+ End If
|
|
837
|
+ Else
|
|
838
|
+ ' 如果不是今天的日期,就從00001開始
|
|
839
|
+ 新單號 = $"ZZD-{今日日期}-00001"
|
|
840
|
+ End If
|
|
841
|
+ Return 新單號
|
|
842
|
+ End Function
|
|
843
|
+ Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
|
844
|
+ Dim clsX As New LrGetMtrlDatum
|
|
845
|
+ Dim postbody As New JObject()
|
|
846
|
+ postbody("entity_number") = "inv_assemble_bill"
|
|
847
|
+ postbody("operate_type") = "delete"
|
|
848
|
+ postbody("ignore_warn") = True
|
|
849
|
+
|
|
850
|
+ Dim numbers As New JArray()
|
|
851
|
+ numbers.Add(TextBox2.Text) ' 這裡填你要刪除的組裝單單號
|
|
852
|
+ postbody("numbers") = numbers
|
|
853
|
+ postbody("ids") = New JArray() ' 如果用 numbers,這裡可以給空陣列
|
|
854
|
+ Dim errcode As Integer : Dim jsonResult As JObject
|
|
855
|
+ Dim strJson As String = clsX.GetDatumX1(gClientID, gClientSecret, gAppToken, "jdy/v2/sys/common_operate", postbody.ToString())
|
|
856
|
+ If strJson = "" Then
|
|
857
|
+ MsgBox("匯入失敗")
|
|
858
|
+ Else
|
|
859
|
+ jsonResult = JObject.Parse(strJson)
|
|
860
|
+ errcode = jsonResult("errcode")
|
|
861
|
+ If errcode = 0 Then
|
|
862
|
+ MsgBox("刪除成功")
|
|
863
|
+
|
|
864
|
+ Else
|
|
865
|
+ ' 匯入失敗,顯示錯誤訊息
|
|
866
|
+ MsgBox("金蝶刪除失敗:" & jsonResult("description").ToString())
|
|
867
|
+ End If
|
|
868
|
+ End If
|
|
869
|
+
|
|
870
|
+ End Sub
|
|
871
|
+ Public Function 金蝶找單號之ID(ByRef address As String, ByRef 單號 As String, ByRef 找尋標題 As String) As String
|
|
872
|
+ Dim clsX1 As New LrGetMtrlDatum
|
|
873
|
+ Dim paramLst1 As New List(Of LrParam)
|
|
874
|
+ Dim param1 As New LrParam()
|
|
875
|
+ param1 = New LrParam() : param1.pKey = "bill_no" : param1.pValue = 單號 : paramLst1.Add(param1)
|
|
876
|
+ param1 = New LrParam() : param1.pKey = "page" : param1.pValue = 1 : paramLst1.Add(param1)
|
|
877
|
+ param1 = New LrParam() : param1.pKey = "page_size" : param1.pValue = 1 : paramLst1.Add(param1)
|
|
878
|
+ Dim strJson1 As String = clsX1.GetDatumX(gClientID, gClientSecret, gAppToken, paramLst1, address)
|
|
879
|
+ Try
|
|
880
|
+ Dim jsonData As JObject = JObject.Parse(strJson1)
|
|
881
|
+ Dim billNo As String = jsonData("data")("rows")(0)(找尋標題).ToString()
|
|
882
|
+ Return billNo
|
|
883
|
+ Catch ex As Exception
|
|
884
|
+ MessageBox.Show("解析 JSON 失敗:" & ex.Message)
|
|
885
|
+ Return ""
|
|
886
|
+ End Try
|
|
887
|
+ End Function
|
363
|
888
|
'----------------------自創視窗滑鼠拖曳功能---------------------------------------------------------------------------------------------------------
|
364
|
889
|
Dim OldX, OldY As Long : Dim drag As Boolean
|
365
|
890
|
Private Sub CanceL1_bt_Click(sender As Object, e As EventArgs) Handles CanceL1_bt.Click
|