item_product_list, item_component_list ArrayList에서 배열로 변경

This commit is contained in:
KwakJooYoung 2025-12-10 16:35:53 +09:00
parent d844d01f89
commit 483056d07d
2 changed files with 59 additions and 75 deletions

View File

@ -292,7 +292,13 @@ Public Class frm_Main
apiCommand(parsingCode.item) = "Item" apiCommand(parsingCode.item) = "Item"
apiCommand(parsingCode.state) = "state" apiCommand(parsingCode.state) = "state"
DBCmd = "SELECT CAST(ProdCode AS CHAR), SalesPackingCntColNm, SalesPackingSerialColNm FROM " & applyPlistDB & " WHERE ProdCode <> 2 GROUP BY ProdCode ORDER BY ProdCode asc;" DBCmd = "SELECT MAX(ProdCode) FROM " & applyPlistDB & ";"
If DBQueryReader(DBCmd) Then
item_product_max_index = sqlDataQuery(0)
ReDim item_product_list(item_product_max_index)
End If
DBCmd = "SELECT CAST(ProdCode AS CHAR), SalesPackingCntColNm, SalesPackingSerialColNm FROM " & applyPlistDB & " 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
@ -310,10 +316,16 @@ Public Class frm_Main
End If End If
dataSetCount += 1 dataSetCount += 1
Next Next
item_product_list.Add(item_data) item_product_list(item_data.prod_code) = item_data
Next Next
End If End If
DBCmd = "SELECT MAX(ProdCode) FROM " & applyClistDB & ";"
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 " & applyClistDB & " GROUP BY ProdCode ORDER BY ProdCode asc;" DBCmd = "SELECT CAST(ProdCode AS CHAR), SalesPackingCntColNm FROM " & applyClistDB & " 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
@ -330,30 +342,34 @@ Public Class frm_Main
End If End If
dataSetCount += 1 dataSetCount += 1
Next Next
item_component_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_product_list For i = 2 To item_product_max_index
If item_data.item_type = "P" Then If query_product = Nothing Then
If query_product = Nothing Then query_product = "IFNULL(" & item_product_list(i).sales_packing_serial_col_nm & ",'NULL'), IFNULL(" & item_product_list(i).sales_packing_cnt_col_nm & ",'0')"
query_product = "'" & item_data.prod_code & "', IFNULL(" & item_data.sales_packing_serial_col_nm & ",'NULL'), IFNULL(" & item_data.sales_packing_cnt_col_nm & ",'0')" Else
Else 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')"
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')"
End If
End If End If
Next Next
'구성품 정보 조회 쿼리 생성 '구성품 정보 조회 쿼리 생성
query_component = Nothing query_component = Nothing
For Each item_data As item_info In item_component_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
@ -1439,11 +1455,11 @@ Public Class frm_Main
Dim itemCode As String = Nothing Dim itemCode As String = Nothing
Dim itemName As String = Nothing Dim itemName As String = Nothing
For Each item_data As item_info In item_component_list For i = 0 To item_component_max_index
itemCode = Nothing itemCode = Nothing
itemName = Nothing itemName = Nothing
If item_data.cnt <> 0 Then If item_component_list(i).cnt <> 0 Then
DBCmd = "SELECT ItemCode,ItemName FROM " & applyClistDB & " WHERE ProdCode = '" & item_data.prod_code & "'" DBCmd = "SELECT ItemCode,ItemName FROM " & applyClistDB & " WHERE ProdCode = '" & i & "'"
If DBQueryReader(DBCmd) Then If DBQueryReader(DBCmd) Then
For cnt = 0 To sqlDataQuery.Length - 1 For cnt = 0 To sqlDataQuery.Length - 1
@ -1471,7 +1487,7 @@ Public Class frm_Main
ReDim ChkItemSet(itemInfoList.pk_Type, firstDataNum) ReDim ChkItemSet(itemInfoList.pk_Type, firstDataNum)
ChkItemSet(itemInfoList.code, firstDataNum) = itemCode ChkItemSet(itemInfoList.code, firstDataNum) = itemCode
ChkItemSet(itemInfoList.name, firstDataNum) = itemName ChkItemSet(itemInfoList.name, firstDataNum) = itemName
ChkItemSet(itemInfoList.count, firstDataNum) = item_data.cnt ChkItemSet(itemInfoList.count, firstDataNum) = item_component_list(i).cnt
ChkItemSet(itemInfoList.face, firstDataNum) = 0 ChkItemSet(itemInfoList.face, firstDataNum) = 0
ChkItemSet(itemInfoList.eye, firstDataNum) = 0 ChkItemSet(itemInfoList.eye, firstDataNum) = 0
ChkItemSet(itemInfoList.pk_Type, firstDataNum) = 1 ChkItemSet(itemInfoList.pk_Type, firstDataNum) = 1
@ -1480,7 +1496,7 @@ Public Class frm_Main
ReDim Preserve ChkItemSet(itemInfoList.pk_Type, chkCount) ReDim Preserve ChkItemSet(itemInfoList.pk_Type, chkCount)
ChkItemSet(itemInfoList.code, chkCount) = itemCode ChkItemSet(itemInfoList.code, chkCount) = itemCode
ChkItemSet(itemInfoList.name, chkCount) = itemName ChkItemSet(itemInfoList.name, chkCount) = itemName
ChkItemSet(itemInfoList.count, chkCount) = item_data.cnt ChkItemSet(itemInfoList.count, chkCount) = item_component_list(i).cnt
ChkItemSet(itemInfoList.face, chkCount) = 0 ChkItemSet(itemInfoList.face, chkCount) = 0
ChkItemSet(itemInfoList.eye, chkCount) = 0 ChkItemSet(itemInfoList.eye, chkCount) = 0
ChkItemSet(itemInfoList.pk_Type, chkCount) = 1 ChkItemSet(itemInfoList.pk_Type, chkCount) = 1
@ -1490,7 +1506,7 @@ Public Class frm_Main
ReDim packItemSet(itemInfoList.pk_Type, firstDataNum) ReDim packItemSet(itemInfoList.pk_Type, firstDataNum)
packItemSet(itemInfoList.code, firstDataNum) = itemCode packItemSet(itemInfoList.code, firstDataNum) = itemCode
packItemSet(itemInfoList.name, firstDataNum) = itemName packItemSet(itemInfoList.name, firstDataNum) = itemName
packItemSet(itemInfoList.count, firstDataNum) = item_data.cnt packItemSet(itemInfoList.count, firstDataNum) = item_component_list(i).cnt
packItemSet(itemInfoList.face, firstDataNum) = 0 packItemSet(itemInfoList.face, firstDataNum) = 0
packItemSet(itemInfoList.eye, firstDataNum) = 0 packItemSet(itemInfoList.eye, firstDataNum) = 0
packItemSet(itemInfoList.pk_Type, firstDataNum) = 1 packItemSet(itemInfoList.pk_Type, firstDataNum) = 1
@ -1499,7 +1515,7 @@ Public Class frm_Main
ReDim Preserve packItemSet(itemInfoList.pk_Type, chkCount) ReDim Preserve packItemSet(itemInfoList.pk_Type, chkCount)
packItemSet(itemInfoList.code, chkCount) = itemCode packItemSet(itemInfoList.code, chkCount) = itemCode
packItemSet(itemInfoList.name, chkCount) = itemName packItemSet(itemInfoList.name, chkCount) = itemName
packItemSet(itemInfoList.count, chkCount) = item_data.cnt packItemSet(itemInfoList.count, chkCount) = item_component_list(i).cnt
packItemSet(itemInfoList.face, chkCount) = 0 packItemSet(itemInfoList.face, chkCount) = 0
packItemSet(itemInfoList.eye, chkCount) = 0 packItemSet(itemInfoList.eye, chkCount) = 0
packItemSet(itemInfoList.pk_Type, chkCount) = 1 packItemSet(itemInfoList.pk_Type, chkCount) = 1
@ -1526,30 +1542,8 @@ Public Class frm_Main
DBCmd = "SELECT " & query_component & " FROM " & applySalesDB & " WHERE PackingCode = '" & codeData & "'" DBCmd = "SELECT " & query_component & " FROM " & applySalesDB & " WHERE PackingCode = '" & codeData & "'"
If DBQueryReader(DBCmd) Then If DBQueryReader(DBCmd) Then
Dim RowCount As Int16 = (sqlDataQuery.Length / 2) - 1 For i = 0 To item_component_max_index '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_component_list.Count - 1
Dim item_data As item_info = item_component_list(i)
If item_data.item_type = "C" And item_data.prod_code = prod_code Then
item_data.cnt = cnt
item_component_list(i) = item_data
Exit For
End If
Next
Next Next
Return True Return True
@ -1573,10 +1567,9 @@ Public Class frm_Main
Private Function serialDivision() As Boolean Private Function serialDivision() As Boolean
Dim slashNum As Int16 Dim slashNum As Int16
For i = 1 To item_product_max_index
For Each item_data As item_info In item_product_list If item_product_list(i).cnt > 0 Then
If item_data.cnt > 0 Then Dim restData As String = item_product_list(i).serial
Dim restData As String = item_data.serial
slashNum = UBound(Split(restData, "/")) slashNum = UBound(Split(restData, "/"))
For slash = 0 To slashNum For slash = 0 To slashNum
@ -1838,33 +1831,18 @@ Public Class frm_Main
Private Function serialPacking(codeData As String) As Boolean Private Function serialPacking(codeData As String) As Boolean
DBCmd = "SELECT " & query_product & " FROM " & applySalesDB & " WHERE PackingCode = '" & codeData & "'" DBCmd = "SELECT " & query_product & " FROM " & applySalesDB & " WHERE PackingCode = '" & codeData & "'"
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
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_product_list.Count - 1
Dim item_data As item_info = item_product_list(i)
If item_data.item_type = "P" And item_data.prod_code = prod_code Then
item_data.serial = serial
item_data.cnt = cnt
item_product_list(i) = item_data
Exit For
End If
Next
Next Next
Else Else
MsgBox("패킹 시리얼 번호를 검색하는 도중 오류가 발생하였습니다.") MsgBox("패킹 시리얼 번호를 검색하는 도중 오류가 발생하였습니다.")
@ -3454,9 +3432,13 @@ Public Class frm_Main
ProdSelect(i) = Nothing ProdSelect(i) = Nothing
Next Next
For Each item_data As item_info In item_product_list For i = 1 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
For i = 0 To chkItem.Length - 1 For i = 0 To chkItem.Length - 1

View File

@ -40,10 +40,12 @@
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
Public item_product_list As New ArrayList Public item_product_list() As item_info
Public item_component_list As New ArrayList Public item_component_list() As item_info
Public item_product_max_index As Integer
Public item_component_max_index As Integer
End Module End Module