diff --git a/PackingInvoiceMapper/frm_Main.vb b/PackingInvoiceMapper/frm_Main.vb index 11b5650..ed6fd3e 100644 --- a/PackingInvoiceMapper/frm_Main.vb +++ b/PackingInvoiceMapper/frm_Main.vb @@ -298,13 +298,14 @@ Public Class frm_Main 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;" + '제품 ProdCode는 1부터 시작하며, ProSet(1),LuxSet(2)는 같은 컬럼을 사용하고 있어 중복되기 때문에 2부터 조회 + DBCmd = "SELECT CAST(ProdCode AS CHAR), SalesPackingCntColNm, SalesPackingSerialColNm FROM " & applyPlistDB & " WHERE ProdCode > 1 GROUP BY ProdCode ORDER BY ProdCode asc;" If DBQueryReader(DBCmd) Then - Dim RowCount As Int16 = (sqlDataQuery.Length / 3) - 1 + Dim RowCount As Int16 = (sqlDataQuery.Length / 3) Dim dataSetCount As Int32 = 0 Dim item_data As item_info - For row = 0 To RowCount + For row = 1 To RowCount item_data.item_type = "P" For col = 0 To 2 If col = 0 Then @@ -347,6 +348,7 @@ Public Class frm_Main End If '제품 정보 조회 쿼리 생성 + 'item_product_list 에 index (2)부터 등록되어 있기에 (2)부터 조회 query_product = Nothing For i = 2 To item_product_max_index If query_product = Nothing Then @@ -359,6 +361,7 @@ Public Class frm_Main '구성품 정보 조회 쿼리 생성 query_component = Nothing For i = 0 To item_component_max_index + '구성품 중 ProdCode는 있으나 품목이 없는 경우가 있기에 NULL 체크 필요 If item_component_list(i).sales_packing_cnt_col_nm <> Nothing Then If query_component = Nothing Then query_component = "IFNULL(" & item_component_list(i).sales_packing_cnt_col_nm & ",'0')" @@ -1542,7 +1545,8 @@ Public Class frm_Main DBCmd = "SELECT " & query_component & " FROM " & applySalesDB & " WHERE PackingCode = '" & codeData & "'" If DBQueryReader(DBCmd) Then - For i = 0 To item_component_max_index 'sqlDataQuery.Length - 1 와 같음 + 'query_component로 구성품 개수만큼 조회했기에 item_component_max_index(=sqlDataQuery.Length - 1)까지 조회 + For i = 0 To item_component_max_index item_component_list(i).cnt = sqlDataQuery(i) Next @@ -1567,7 +1571,8 @@ Public Class frm_Main Private Function serialDivision() As Boolean Dim slashNum As Int16 - For i = 1 To item_product_max_index + 'item_product_list 에 index (2)부터 등록되어 있기에 (2)부터 조회 + For i = 2 To item_product_max_index If item_product_list(i).cnt > 0 Then Dim restData As String = item_product_list(i).serial slashNum = UBound(Split(restData, "/")) @@ -1831,15 +1836,15 @@ Public Class frm_Main Private Function serialPacking(codeData As String) As Boolean DBCmd = "SELECT " & query_product & " FROM " & applySalesDB & " WHERE PackingCode = '" & codeData & "'" If DBQueryReader(DBCmd) Then - Dim RowCount As Int16 = (sqlDataQuery.Length / 2) Dim dataSetCount As Int32 = 0 - For row = 2 To RowCount + 'query_product가 ProdCode = 2부터 생성되었기에 (2)부터 조회 + For i = 2 To item_product_max_index For col = 0 To 1 If col = 0 Then - item_product_list(row).serial = sqlDataQuery(dataSetCount) + item_product_list(i).serial = sqlDataQuery(dataSetCount) ElseIf col = 1 Then - item_product_list(row).cnt = sqlDataQuery(dataSetCount) + item_product_list(i).cnt = sqlDataQuery(dataSetCount) End If dataSetCount += 1 Next @@ -3432,7 +3437,7 @@ Public Class frm_Main ProdSelect(i) = Nothing Next - For i = 1 To item_product_max_index + For i = 0 To item_product_max_index item_product_list(i).cnt = 0 item_product_list(i).serial = Nothing Next