item_data_list ArrayList를 item_product_list, item_component_list 배열로 변경

This commit is contained in:
KwakJooYoung 2025-12-10 17:44:14 +09:00
parent d26f2e9b25
commit 7993662370

View File

@ -24,10 +24,13 @@ Public Class frmMySqlTest
Dim prod_code As String Dim prod_code As String
Dim sales_packing_cnt_col_nm As String Dim sales_packing_cnt_col_nm As String
Dim sales_packing_serial_col_nm As String Dim sales_packing_serial_col_nm As String
Dim cnt As String Dim cnt As Integer
Dim serial As String Dim serial As String
End Structure End Structure
Private item_data_list As New ArrayList Private item_product_list() As item_info
Private item_component_list() As item_info
Public item_product_max_index As Integer
Public item_component_max_index As Integer
Private cmd As String Private cmd As String
Private dbcmd As String Private dbcmd As String
@ -116,7 +119,14 @@ Public Class frmMySqlTest
End Sub End Sub
Private Sub setItemData() Private Sub setItemData()
dbcmd = "SELECT CAST(ProdCode AS CHAR), SalesPackingCntColNm, SalesPackingSerialColNm FROM " & prod_table & " WHERE ProdCode <> 2 GROUP BY ProdCode ORDER BY ProdCode asc;" dbcmd = "SELECT CAST(MAX(ProdCode) AS CHAR) FROM " & prod_table & ";"
If DBQueryReader(dbcmd) Then
item_product_max_index = sqlDataQuery(0)
ReDim item_product_list(item_product_max_index)
End If
'제품 ProdCode는 1부터 시작하며, ProSet(1),LuxSet(2) 같은 컬럼을 사용하고 있어 중복되기 때문에 2부터 조회
dbcmd = "SELECT CAST(ProdCode AS CHAR), SalesPackingCntColNm, SalesPackingSerialColNm FROM " & prod_table & " WHERE ProdCode > 1 GROUP BY ProdCode ORDER BY ProdCode ASC;"
If DBQueryReader(dbcmd) Then If DBQueryReader(dbcmd) Then
Dim RowCount As Int16 = (sqlDataQuery.Length / 3) - 1 Dim RowCount As Int16 = (sqlDataQuery.Length / 3) - 1
Dim dataSetCount As Int32 = 0 Dim dataSetCount As Int32 = 0
@ -134,10 +144,16 @@ Public Class frmMySqlTest
End If End If
dataSetCount += 1 dataSetCount += 1
Next Next
item_data_list.Add(item_data) item_product_list(item_data.prod_code) = item_data
Next Next
End If End If
dbcmd = "SELECT CAST(MAX(ProdCode) AS CHAR) FROM " & component_table & ";"
If DBQueryReader(dbcmd) Then
item_component_max_index = sqlDataQuery(0)
ReDim item_component_list(item_component_max_index)
End If
dbcmd = "SELECT CAST(ProdCode AS CHAR), SalesPackingCntColNm FROM " & component_table & " GROUP BY ProdCode ORDER BY ProdCode asc;" dbcmd = "SELECT CAST(ProdCode AS CHAR), SalesPackingCntColNm FROM " & component_table & " GROUP BY ProdCode ORDER BY ProdCode asc;"
If DBQueryReader(dbcmd) Then If DBQueryReader(dbcmd) Then
Dim RowCount As Int16 = (sqlDataQuery.Length / 2) - 1 Dim RowCount As Int16 = (sqlDataQuery.Length / 2) - 1
@ -154,30 +170,36 @@ Public Class frmMySqlTest
End If End If
dataSetCount += 1 dataSetCount += 1
Next Next
item_data_list.Add(item_data) item_component_list(item_data.prod_code) = item_data
Next Next
End If End If
'제품 정보 조회 쿼리 생성 '제품 정보 조회 쿼리 생성
query_product = Nothing query_product = Nothing
For Each item_data As item_info In item_data_list For i = 0 To item_product_max_index
If item_data.item_type = "P" Then If item_product_list(i).sales_packing_cnt_col_nm <> Nothing Then
If query_product = Nothing Then If query_product = Nothing Then
query_product = "'" & item_data.prod_code & "', IFNULL(" & item_data.sales_packing_serial_col_nm & ",'NULL'), IFNULL(" & item_data.sales_packing_cnt_col_nm & ",'0')" query_product = "IFNULL(" & item_product_list(i).sales_packing_serial_col_nm & ",'NULL'), IFNULL(" & item_product_list(i).sales_packing_cnt_col_nm & ",'0')"
Else Else
query_product = query_product & ",'" & item_data.prod_code & "', IFNULL(" & item_data.sales_packing_serial_col_nm & ",'NULL'), IFNULL(" & item_data.sales_packing_cnt_col_nm & ",'0')" query_product = query_product & ", IFNULL(" & item_product_list(i).sales_packing_serial_col_nm & ",'NULL'), IFNULL(" & item_product_list(i).sales_packing_cnt_col_nm & ",'0')"
End If End If
End If End If
Next Next
'구성품 정보 조회 쿼리 생성 '구성품 정보 조회 쿼리 생성
query_component = Nothing query_component = Nothing
For Each item_data As item_info In item_data_list For i = 0 To item_component_max_index
If item_data.item_type = "C" Then If item_component_list(i).sales_packing_cnt_col_nm <> Nothing Then
If query_component = Nothing Then If query_component = Nothing Then
query_component = "'" & item_data.prod_code & "', IFNULL(" & item_data.sales_packing_cnt_col_nm & ",'0')" query_component = "IFNULL(" & item_component_list(i).sales_packing_cnt_col_nm & ",'0')"
Else Else
query_component = query_component & ",'" & item_data.prod_code & "', IFNULL(" & item_data.sales_packing_cnt_col_nm & ",'0')" query_component = query_component & ", IFNULL(" & item_component_list(i).sales_packing_cnt_col_nm & ",'0')"
End If
Else
If query_component = Nothing Then
query_component = "'0'"
Else
query_component = query_component & ", '0'"
End If End If
End If End If
Next Next
@ -198,9 +220,13 @@ Public Class frmMySqlTest
basic_data_select(i) = "NULL" basic_data_select(i) = "NULL"
Next Next
For Each item_data As item_info In item_data_list For i = 0 To item_product_max_index
item_data.cnt = 0 item_product_list(i).cnt = 0
item_data.serial = Nothing item_product_list(i).serial = Nothing
Next
For i = 0 To item_component_max_index
item_component_list(i).cnt = 0
Next Next
End Sub End Sub
@ -281,7 +307,6 @@ Public Class frmMySqlTest
dbcmd = "SELECT IFNULL(sale.PackingCode,'NULL') dbcmd = "SELECT IFNULL(sale.PackingCode,'NULL')
, IFNULL(sale.`Data`,'NULL') , IFNULL(sale.`Data`,'NULL')
, IFNULL(sale.note, '') , IFNULL(sale.note, '')
, IFNULL(otb.Order_Code,'NULL') , IFNULL(otb.Order_Code,'NULL')
, IFNULL(otb.Orderer_Name,'NULL') , IFNULL(otb.Orderer_Name,'NULL')
, IFNULL(otb.Phone_Number,'NULL') , IFNULL(otb.Phone_Number,'NULL')
@ -302,74 +327,36 @@ Public Class frmMySqlTest
'제품 정보 조회 '제품 정보 조회
dbcmd = "SELECT " & query_product & " FROM " & sales_db & " WHERE PackingCode = '" & packing_code & "'" dbcmd = "SELECT " & query_product & " FROM " & sales_db & " WHERE PackingCode = '" & packing_code & "'"
If DBQueryReader(dbcmd) Then If DBQueryReader(dbcmd) Then
Dim RowCount As Int16 = (sqlDataQuery.Length / 3) - 1 Dim RowCount As Int16 = (sqlDataQuery.Length / 2)
Dim dataSetCount As Int32 = 0 Dim dataSetCount As Int32 = 0
Dim prod_code As String
Dim serial As String
Dim cnt As String
For row = 0 To RowCount For row = 2 To RowCount '제품 ProdCode는 1부터 시작하며, ProSet(1),LuxSet(2) 같은 컬럼을 사용하고 있어 중복되기 때문에 ProdCode 2부터 설정
For col = 0 To 2 For col = 0 To 1
If col = 0 Then If col = 0 Then
prod_code = sqlDataQuery(dataSetCount) item_product_list(row).serial = sqlDataQuery(dataSetCount)
ElseIf col = 1 Then ElseIf col = 1 Then
serial = sqlDataQuery(dataSetCount) item_product_list(row).cnt = sqlDataQuery(dataSetCount)
ElseIf col = 2 Then
cnt = sqlDataQuery(dataSetCount)
End If End If
dataSetCount += 1 dataSetCount += 1
Next Next
For i = 0 To item_data_list.Count - 1 '모든 제품의 시리얼번호를 검색
Dim item_data As item_info = item_data_list(i) If item_product_list(row).serial <> "NULL" Then
If item_data.item_type = "P" And item_data.prod_code = prod_code Then Dim serial_array() As String = item_product_list(row).serial.Split("/")
item_data.serial = serial For j = 0 To serial_array.Length - 1
item_data.cnt = cnt If Len(serial_array(j)) <> 0 Then
item_data_list(i) = item_data all_serial_list.Add(serial_array(j))
'모든 제품의 시리얼번호를 검색
If serial <> "NULL" Then
Dim serial_array() As String = serial.Split("/")
For j = 0 To serial_array.Length - 1
If Len(serial_array(j)) <> 0 Then
all_serial_list.Add(serial_array(j))
End If
Next
End If End If
Next
Exit For End If
End If
Next
Next Next
End If End If
'구성품 정보 조회 '구성품 정보 조회
dbcmd = "SELECT " & query_component & " FROM " & sales_db & " WHERE PackingCode = '" & packing_code & "'" dbcmd = "SELECT " & query_component & " FROM " & sales_db & " WHERE PackingCode = '" & packing_code & "'"
If DBQueryReader(dbcmd) Then If DBQueryReader(dbcmd) Then
Dim RowCount As Int16 = (sqlDataQuery.Length / 2) - 1 For i = 0 To sqlDataQuery.Length - 1
Dim dataSetCount As Int32 = 0 item_component_list(i).cnt = sqlDataQuery(i)
Dim prod_code As String
Dim cnt As String
For row = 0 To RowCount
For col = 0 To 1
If col = 0 Then
prod_code = sqlDataQuery(dataSetCount)
ElseIf col = 1 Then
cnt = sqlDataQuery(dataSetCount)
End If
dataSetCount += 1
Next
For i = 0 To item_data_list.Count - 1
Dim item_data As item_info = item_data_list(i)
If item_data.item_type = "C" And item_data.prod_code = prod_code Then
item_data.cnt = cnt
item_data_list(i) = item_data
Exit For
End If
Next
Next Next
End If End If
@ -381,26 +368,19 @@ Public Class frmMySqlTest
Dim dgv_switch As Boolean Dim dgv_switch As Boolean
Try Try
For Each item_data As item_info In item_data_list For i = 0 To item_product_max_index
dgv_switch = False dgv_switch = False
item_name = Nothing item_name = Nothing
If item_data.cnt > 0 Then If item_product_list(i).cnt > 0 Then
If item_data.item_type = "P" And item_data.prod_code = "1" Or item_data.prod_code = "2" Then 'Pro_Set, Lux_Set If i = 1 Or i = 2 Then 'Pro_Set, Lux_Set
If Mid(item_data.serial, 1, 2) = "10" Then If Mid(item_product_list(i).serial, 1, 2) = "10" Then
item_name = "DUALSONIC Pro 1Set (KR)" item_name = "DUALSONIC Pro 1Set (KR)"
Else Else
item_name = "DUALSONIC Lux 1Set (KR)" item_name = "DUALSONIC Lux 1Set (KR)"
End If End If
ElseIf item_data.item_type = "P" Then
dbcmd = "SELECT ItemName FROM " & prod_db & " WHERE ProdCode = '" & item_data.prod_code & "' AND ItemName NOT LIKE '%체험%' LIMIT 1"
If DBQueryReader(dbcmd) Then
item_name = sqlDataQuery(0)
End If
Else Else
dbcmd = "SELECT ItemName FROM " & component_db & " WHERE ProdCode = '" & item_data.prod_code & "' LIMIT 1" dbcmd = "SELECT ItemName FROM " & prod_db & " WHERE ProdCode = '" & i & "' AND ItemName NOT LIKE '%체험%' LIMIT 1"
If DBQueryReader(dbcmd) Then If DBQueryReader(dbcmd) Then
item_name = sqlDataQuery(0) item_name = sqlDataQuery(0)
End If End If
@ -410,7 +390,26 @@ Public Class frmMySqlTest
End If End If
If dgv_switch = True Then If dgv_switch = True Then
dgv_pack_item.Rows.Add(item_name, item_data.cnt, item_data.serial) dgv_pack_item.Rows.Add(item_name, item_product_list(i).cnt, item_product_list(i).serial)
End If
Next
For i = 0 To item_component_max_index
dgv_switch = False
item_name = Nothing
If item_component_list(i).cnt > 0 Then
dbcmd = "SELECT ItemName FROM " & component_db & " WHERE ProdCode = '" & i & "' LIMIT 1"
If DBQueryReader(dbcmd) Then
item_name = sqlDataQuery(0)
End If
dgv_switch = True
End If
If dgv_switch = True Then
dgv_pack_item.Rows.Add(item_name, item_component_list(i).cnt, item_component_list(i).serial)
End If End If
Next Next
@ -486,18 +485,11 @@ Public Class frmMySqlTest
msg_cnt = MsgBox("패킹에 포함된 시리얼번호를 삭제하시겠습니까?", vbExclamation + vbOKCancel) msg_cnt = MsgBox("패킹에 포함된 시리얼번호를 삭제하시겠습니까?", vbExclamation + vbOKCancel)
If msg_cnt = 1 Then If msg_cnt = 1 Then
'STEP_01 : jomtTesterDB.jomtSalesPackingTbl 테이블 시리얼번호 삭제 'STEP_01 : jomtTesterDB.jomtSalesPackingTbl 테이블 시리얼번호 삭제
Dim remain_serial_data() As String Dim remain_serial_data() As String = item_product_list(product_serial_type).serial.Replace(txbPacking.Text, "").Split("/")
Dim update_serial_str As String = "" Dim update_serial_str As String = ""
Dim update_serial_cnt As UInt16 = 0 Dim update_serial_cnt As UInt16 = 0
Dim update_note_str As String = basic_data_select(basic_info.pack_note) Dim update_note_str As String = basic_data_select(basic_info.pack_note)
For Each item_data As item_info In item_data_list
If item_data.item_type = "P" And item_data.prod_code = product_serial_type Then
remain_serial_data = item_data.serial.Replace(txbPacking.Text, "").Split("/")
Exit For
End If
Next
For i = 0 To remain_serial_data.Length - 1 For i = 0 To remain_serial_data.Length - 1
If Len(remain_serial_data(i)) <> 0 Then If Len(remain_serial_data(i)) <> 0 Then
If update_serial_str = "" Then If update_serial_str = "" Then