Imports System
Imports System.IO

Public Class MainForm

    Private order_table As String = "jomtOrderDB.jomtOrderTbl"
    Private sales_table As String = "jomtTesterDB.jomtSalesPackingTbl"
    Private order_test As String = " jomtOrderTestDB.jomtOrderTbl"
    Private sales_test As String = "jomtTesterServerDB.jomtSalesPackingTbl"
    Private PData_table As String = "jomtTesterDB.jomtProdList"
    Private CData_table As String = "jomtTesterDB.jomtComponentTbl"

    Private order_db As String = order_table
    Private sales_db As String = sales_table

    Private Enum DgvColNameList
        PackingNum
        PackingDate
        SetSerial
        SetCount
        Mask5
        Mask10
        Hairband
        Gel
        MiniGel
        Ample
        Cream
        Umb
        Fen
        Charger
        Cable
        Toner
        NonCase
        ProBlackCase
        ProBeigeCase
        ProRedCase
        ProPinkCase
        MaxBlackCase
        MaxAprCase
        MaxMintCase
        MaxBeigeCase
        MaxPurpleCase
        MaxSnakeCase
        MaxSafBKCase
        MaxSafPpCase
        MaxYellowCase
        DustBag
        SoothingGel
        BOX0
        BOX1
        BOX2
        BOX3
        BOX4
        BOX5
        BOX6
        ShopBag
        CosShopBag
        KollagenOne
        KollagenSet
        KollagenOnePp
        KollagenSetPp
        CleanWater
        TonerPad
        Hologram1
        Hologram3
        Hologram5
        Kollagen_Pe1
        Kollagen_Pe3
        Kollagen_Pe5
        ATCircleCase
        APSquareCase
        MaxPeachCase
        MassageSoothing
        Case_MAX_SMint
        MeshPouch
        FirmingAmp
        HyaluronicAmp
        nightshot
        morningshot
        casemaxwoodi
        Elicolltoner
        Elicollamp
        Elicollcream
        Elihyaltoner
        Elihyalamp
        Elihyalcream
        Dayshot
        Beautyshopbag
        Gummy
        Stickjelly
        Newyearbag
        Emsbelt
        Beltbag
        Dayshot2
        Etc
        ProFaceNum
        ProFaceCount
        ProEyeNum
        ProEyeCount
        ProBodyNum
        ProBodyCount
        LuxFaceNum
        LuxFaceCount
        LuxEyeNum
        LuxEyeCount
        LuxBodyNum
        LuxBodyCount
        MaximumNum
        MaximumCount
        AlphaSetNum
        AlphaSetCount
        AlphaFaceNum
        AlphaFaceCount
        AlphaEyeNum
        AlphaEyeCount
        AlphaBodyNum
        AlphaBodyCount
        AltoNum
        AltoCount
        EffectNum
        EffectCount
        Weight

        MAXCol
    End Enum
    Private DgvColName(DgvColNameList.MAXCol - 1) As String

    Private Enum State1_list
        PRO = 1
        LUX
        MAXIMUM
        ALPHA
        ALTO
        Effect
        Prod
        FULL
    End Enum
    Private State1_select(State1_list.FULL) As String

    Private Enum State2_Type
        SET_V1
        FACE_V2
        EYE
        BODY
    End Enum
    Private SteDual_Select(State2_Type.BODY) As String
    Private SteMAX_Select(State2_Type.FACE_V2) As String
    Private SteALTO_Select(State2_Type.SET_V1) As String
    Private SteEffect_Select(State2_Type.SET_V1) As String

    Private Enum State2_Prod
        Mask5
        Mask10
        HairBand
        Gel
        MiniGel
        Ampoule
        Cream
        Umberlla
        Fen
        Charger
        Cable
        Toner
        PROBlackCase
        PROBeigeCase
        PRORedCase
        PROPinkCase
        MAXBlackCase
        MAXAprCase
        MAXMintCase
        MAXBeigeCase
        SoothingGel
        Carton0
        Carton1
        Carton2
        Carton3
        Carton4
        Carton5
        Carton6
        Shopbag
        CosShopbag
        DustBag
        MAXPurpleCase
        PROSnakeBlackCase
        Kollagen
        KollagenSet
        Kollagen_P
        KollagenSet_P
        CleansingWater
        TonerPad
        MAXSafBKCase
        Hologram_1
        Hologram_3
        Hologram_5
        MAXSafPpCase
        MaxYellowCase
        Kollagen_Pe1
        Kollagen_Pe3
        Kollagen_Pe5
        ATCircleCase
        APSquareCase
        MaxPeachCase
        MassageSoothing
        Case_Max_SMint
        MeshPouch
        FirmingAmp
        HyaluronicAmp
        nightshot
        morningshot
        casemaxwoodi
        Elicolltoner
        Elicollamp
        Elicollcream
        Elihyaltoner
        Elihyalamp
        Elihyalcream
        Dayshot
        Beautyshopbag
        Gummy
        Stickjelly
        Newyearbag
        Emsbelt
        Beltbag
        Dayshot2
        MAXEnum
    End Enum
    Private steProd_Select(State2_Prod.MAXEnum - 1) As String

    Private Enum State3_Color
        White
        black
        Pink_V2MAX
        Black_Black
        Mint
        Purple
        Black_Gold
        Yellow
    End Enum
    Private Color_Select(State3_Color.Yellow) As String
    Private Color_Num(State3_Color.Yellow) As Int16
    Private ColorV2_Num(State3_Color.Pink_V2MAX) As Int16
    Private ColorAL_Num(State3_Color.White) As Int16

    Private Enum SerialList
        DUALSet
        PROFace
        PROEye
        PROBody
        LUXFace
        LUXEye
        LUXBody
        MAXIMUM
        ALTO
        Effect
    End Enum
    Private SerialColName(SerialList.Effect) As String

    Private Enum SearchList
        Customer
        OrderCode
        Packing_Inv
        Packing_Only
    End Enum

    Private where_text As String
    Private NoteStr As String
    Private DBCMD As String
    Private SerialStr As String
    Private where_txt As String
    Private SearchCode As String

    Private NowToday As String

    Private pack_use As Boolean = False
    Private csv_Type As Boolean = False

    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Text = "DUALSONIC SalePacking Search Data Ver 1.1.1"

        Veriable_Set()
        cbo_Release()

        NowToday = Format(Now, "yyyy-MM-dd")

        lbStDate.Text = NowToday
        lbEnDate.Text = NowToday
    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        If MsgBox("프로그램을 종료하시겠습니까?", vbExclamation + vbYesNo) = MsgBoxResult.Yes Then
            End
        End If
    End Sub

    Private Sub MainForm_Disposed(sender As Object, e As EventArgs) Handles MyBase.Disposed
        End
    End Sub

    Private Sub cbo_Release()
        cboModel.Items.Clear()
        cboModel.SelectedIndex = -1
        cboModel.Text = "선택"

        For i = 1 To State1_list.FULL
            With cboModel.Items
                .Add(State1_select(i))
            End With
        Next
    End Sub

    Private Sub Veriable_Set()
        State1_select(State1_list.PRO) = "PRO"
        State1_select(State1_list.LUX) = "LUX"
        State1_select(State1_list.MAXIMUM) = "MAXIMUM"
        State1_select(State1_list.ALPHA) = "ALPHA"
        State1_select(State1_list.ALTO) = "ALTO"
        State1_select(State1_list.Effect) = "Effect"
        State1_select(State1_list.Prod) = "구성품"
        State1_select(State1_list.FULL) = "전체"

        SteDual_Select(State2_Type.SET_V1) = "SET"
        SteDual_Select(State2_Type.FACE_V2) = "FACE"
        SteDual_Select(State2_Type.EYE) = "EYE"
        SteDual_Select(State2_Type.BODY) = "BODY"

        SteMAX_Select(State2_Type.SET_V1) = "V1"
        SteMAX_Select(State2_Type.FACE_V2) = "V2"

        SteALTO_Select(State2_Type.SET_V1) = "SET"
        SteEffect_Select(State2_Type.SET_V1) = "SET"

        Color_Select(State3_Color.White) = "White"
        Color_Select(State3_Color.black) = "Black"
        Color_Select(State3_Color.Pink_V2MAX) = "Pink"
        Color_Select(State3_Color.Black_Black) = "Black_Black"
        Color_Select(State3_Color.Mint) = "Mint"
        Color_Select(State3_Color.Purple) = "Purple"
        Color_Select(State3_Color.Black_Gold) = "Black_Gold"
        Color_Select(State3_Color.Yellow) = "YELLOW"

        Color_Num(State3_Color.White) = 0
        Color_Num(State3_Color.black) = 1
        Color_Num(State3_Color.Pink_V2MAX) = 3
        Color_Num(State3_Color.Black_Black) = 4
        Color_Num(State3_Color.Yellow) = 5
        Color_Num(State3_Color.Mint) = 7
        Color_Num(State3_Color.Purple) = 8
        Color_Num(State3_Color.Black_Gold) = 9

        ColorV2_Num(State3_Color.White) = State3_Color.White
        ColorV2_Num(State3_Color.black) = State3_Color.Purple
        ColorV2_Num(State3_Color.Pink_V2MAX) = State3_Color.Black_Gold

        ColorAL_Num(State3_Color.White) = 0

        steProd_Select(State2_Prod.Mask5) = "아쿠아 마스크"
        steProd_Select(State2_Prod.Mask10) = "리프팅 마스크"
        steProd_Select(State2_Prod.HairBand) = "헤어밴드"
        steProd_Select(State2_Prod.Gel) = "블루밍 젤"
        steProd_Select(State2_Prod.MiniGel) = "휴대용 젤"
        steProd_Select(State2_Prod.Ampoule) = "앰플"
        steProd_Select(State2_Prod.Cream) = "크림"
        steProd_Select(State2_Prod.Umberlla) = "우산"
        steProd_Select(State2_Prod.Fen) = "손풍기"
        steProd_Select(State2_Prod.Charger) = "충전기"
        steProd_Select(State2_Prod.Cable) = "충전 케이블"
        steProd_Select(State2_Prod.Toner) = "토너"
        steProd_Select(State2_Prod.PROBlackCase) = "PRO_Black 케이스"
        steProd_Select(State2_Prod.PROBeigeCase) = "PRO_Beige 케이스"
        steProd_Select(State2_Prod.PRORedCase) = "PRO_Red 케이스"
        steProd_Select(State2_Prod.PROPinkCase) = "PRO PINK 케이스"
        steProd_Select(State2_Prod.MAXBlackCase) = "MAXIMUM_Black 케이스"
        steProd_Select(State2_Prod.MAXAprCase) = "MAXIMUM_Apricot 케이스"
        steProd_Select(State2_Prod.MAXMintCase) = "MAXIMUM_Mint 케이스"
        steProd_Select(State2_Prod.MAXBeigeCase) = "MAXIMUM_Beige 케이스"
        steProd_Select(State2_Prod.MAXPurpleCase) = "MAXIMUM_Purple 케이스"
        steProd_Select(State2_Prod.PROSnakeBlackCase) = "PRO_Snake_Black 케이스"
        steProd_Select(State2_Prod.MAXSafBKCase) = "PRO_Saffiano_Black 케이스"
        steProd_Select(State2_Prod.DustBag) = "더스트백"
        steProd_Select(State2_Prod.SoothingGel) = "수딩 젤"
        steProd_Select(State2_Prod.Carton0) = "0호 박스"
        steProd_Select(State2_Prod.Carton1) = "1호 박스"
        steProd_Select(State2_Prod.Carton2) = "2호 박스"
        steProd_Select(State2_Prod.Carton3) = "3호 박스"
        steProd_Select(State2_Prod.Carton4) = "4호 박스"
        steProd_Select(State2_Prod.Carton5) = "5호 박스"
        steProd_Select(State2_Prod.Carton6) = "6호 박스"
        steProd_Select(State2_Prod.Shopbag) = "쇼핑백"
        steProd_Select(State2_Prod.CosShopbag) = "코스메틱 쇼핑백"
        steProd_Select(State2_Prod.Kollagen) = "콜라겐 젤(단품)"
        steProd_Select(State2_Prod.KollagenSet) = "콜라겐 젤(세트)"
        steProd_Select(State2_Prod.Kollagen_P) = "콜라겐 젤 퍼플(단품)"
        steProd_Select(State2_Prod.KollagenSet_P) = "콜라겐 젤 퍼플(세트)"
        steProd_Select(State2_Prod.CleansingWater) = "클렌징 워터"
        steProd_Select(State2_Prod.TonerPad) = "토너 패드"
        steProd_Select(State2_Prod.Hologram_1) = "홀로그램 젤(1 EA)"
        steProd_Select(State2_Prod.Hologram_3) = "홀로그램 젤(3 EA)"
        steProd_Select(State2_Prod.Hologram_5) = "홀로그램 젤(5 EA)"
        steProd_Select(State2_Prod.MAXSafPpCase) = "MAX_Saffiano_Purple 케이스"
        steProd_Select(State2_Prod.MaxYellowCase) = "MAX_Yellow 케이스"
        steProd_Select(State2_Prod.Kollagen_Pe1) = "콜라겐 젤 피치(1 EA)"
        steProd_Select(State2_Prod.Kollagen_Pe3) = "콜라겐 젤 피치(3 EA)"
        steProd_Select(State2_Prod.Kollagen_Pe5) = "콜라겐 젤 피치(5 EA)"
        steProd_Select(State2_Prod.ATCircleCase) = "ALTO 원형 케이스"
        steProd_Select(State2_Prod.APSquareCase) = "ALPHA 사각 케이스"
        steProd_Select(State2_Prod.MaxPeachCase) = "MAXIMUM_Peach 케이스"
        steProd_Select(State2_Prod.MassageSoothing) = "마사지 수딩젤"
        steProd_Select(State2_Prod.Case_Max_SMint) = "MAXIMUM_ShineMint 케이스"

        steProd_Select(State2_Prod.MeshPouch) = "매쉬 파우치"
        steProd_Select(State2_Prod.FirmingAmp) = "탄력앰플"
        steProd_Select(State2_Prod.HyaluronicAmp) = "하이알앰플"
        steProd_Select(State2_Prod.nightshot) = "나이트샷"
        steProd_Select(State2_Prod.morningshot) = "모닝샷"
        steProd_Select(State2_Prod.casemaxwoodi) = "맥시멈 우디 가죽케이스"
        steProd_Select(State2_Prod.Elicolltoner) = "엘릭시르 콜라겐 토너"
        steProd_Select(State2_Prod.Elicollamp) = "엘릭시르 콜라겐 앰플"
        steProd_Select(State2_Prod.Elicollcream) = "엘릭시르 콜라겐 크림"
        steProd_Select(State2_Prod.Elihyaltoner) = "엘릭시르 하이알 토너"
        steProd_Select(State2_Prod.Elihyalamp) = "엘릭시르 하이알 앰플"
        steProd_Select(State2_Prod.Elihyalcream) = "엘릭시르 하이알 크림"
        steProd_Select(State2_Prod.Dayshot) = "데이샷 14 KIT"
        steProd_Select(State2_Prod.Gummy) = "구미 젤리"
        steProd_Select(State2_Prod.Beautyshopbag) = "뷰티루틴 쇼핑백"
        steProd_Select(State2_Prod.Stickjelly) = "스틱 젤리"
        steProd_Select(State2_Prod.Newyearbag) = "신년쇼핑백"
        steProd_Select(State2_Prod.Emsbelt) = " EMS 벨트"
        steProd_Select(State2_Prod.Beltbag) = "핏업벨트 쇼핑백"
        steProd_Select(State2_Prod.Dayshot2) = "데이샷(14개입) 6개"


        SerialColName(SerialList.DUALSet) = "Main_Product_SN = "
        SerialColName(SerialList.PROFace) = "Pro_Face_Serial = "
        SerialColName(SerialList.PROEye) = "Pro_Eye_Serial = "
        SerialColName(SerialList.PROBody) = "Pro_Body_Serial = "
        SerialColName(SerialList.LUXFace) = "Lux_Face_Serial = "
        SerialColName(SerialList.LUXEye) = "Lux_Eye_Serial = "
        SerialColName(SerialList.LUXBody) = "Lux_Body_Serial = "
        SerialColName(SerialList.MAXIMUM) = "MAXIMUM_SN = "
        SerialColName(SerialList.ALTO) = "Alto_Serial = "
        SerialColName(SerialList.Effect) = "Effect_Serial = "

        DgvColName(DgvColNameList.PackingNum) = "패킹번호"
        DgvColName(DgvColNameList.PackingDate) = "패킹날짜"
        DgvColName(DgvColNameList.SetSerial) = "세트_Serial"
        DgvColName(DgvColNameList.SetCount) = "세트 수량"
        DgvColName(DgvColNameList.Mask5) = "아쿠아 마스크"
        DgvColName(DgvColNameList.Mask10) = "리프팅 마스크"
        DgvColName(DgvColNameList.Hairband) = "헤어밴드"
        DgvColName(DgvColNameList.Gel) = "블루밍 젤"
        DgvColName(DgvColNameList.MiniGel) = "미니젤"
        DgvColName(DgvColNameList.Ample) = "앰플"

        DgvColName(DgvColNameList.Cream) = "크림"
        DgvColName(DgvColNameList.Umb) = "우산"
        DgvColName(DgvColNameList.Fen) = "손풍기"
        DgvColName(DgvColNameList.Charger) = "충전기"
        DgvColName(DgvColNameList.Cable) = "케이블"
        DgvColName(DgvColNameList.Toner) = "토너"
        DgvColName(DgvColNameList.NonCase) = "케이스"
        DgvColName(DgvColNameList.ProBlackCase) = "PRO_Black 케이스"
        DgvColName(DgvColNameList.ProBeigeCase) = "PRO_Beige 케이스"
        DgvColName(DgvColNameList.ProRedCase) = "PRO_Red 케이스"

        DgvColName(DgvColNameList.ProPinkCase) = "PRO_Pink 케이스"
        DgvColName(DgvColNameList.MaxBlackCase) = "MAX_Black 케이스"
        DgvColName(DgvColNameList.MaxAprCase) = "MAX_Apr 케이스"
        DgvColName(DgvColNameList.MaxMintCase) = "MAX_Mint 케이스"
        DgvColName(DgvColNameList.MaxBeigeCase) = "MAX_Beige 케이스"
        DgvColName(DgvColNameList.MaxPurpleCase) = "MAX_Purple 케이스"
        DgvColName(DgvColNameList.MaxSnakeCase) = "MAX_뱀피 케이스"
        DgvColName(DgvColNameList.MaxSafBKCase) = "MAX_Black 사피아노 케이스"
        DgvColName(DgvColNameList.MaxSafPpCase) = "MAX_Purple 사피아노 케이스"
        DgvColName(DgvColNameList.MaxYellowCase) = "MAX_Yellow 케이스"
        DgvColName(DgvColNameList.DustBag) = "더스트백"
        DgvColName(DgvColNameList.SoothingGel) = "수딩젤"
        DgvColName(DgvColNameList.BOX0) = "0호 박스"

        DgvColName(DgvColNameList.BOX1) = "1호 박스"
        DgvColName(DgvColNameList.BOX2) = "2호 박스"
        DgvColName(DgvColNameList.BOX3) = "3호 박스"
        DgvColName(DgvColNameList.BOX4) = "4호 박스"
        DgvColName(DgvColNameList.BOX5) = "5호 박스"
        DgvColName(DgvColNameList.BOX6) = "6호 박스"
        DgvColName(DgvColNameList.ShopBag) = "기본쇼핑백"
        DgvColName(DgvColNameList.CosShopBag) = "코스메틱 쇼핑백"
        DgvColName(DgvColNameList.KollagenOne) = "콜라겐 젤(단품)"
        DgvColName(DgvColNameList.KollagenSet) = "콜라겐 젤(세트)"

        DgvColName(DgvColNameList.KollagenOnePp) = "Purple_콜라겐 젤(단품)"
        DgvColName(DgvColNameList.KollagenSetPp) = "Purple_콜라겐 젤(세트)"
        DgvColName(DgvColNameList.CleanWater) = "클렌징워터"
        DgvColName(DgvColNameList.TonerPad) = "토너패드"
        DgvColName(DgvColNameList.Hologram1) = "홀로그램 젤(1EA)"
        DgvColName(DgvColNameList.Hologram3) = "홀로그램 젤(3EA)"
        DgvColName(DgvColNameList.Hologram5) = "홀로그램 젤(5EA)"

        DgvColName(DgvColNameList.Kollagen_Pe1) = "콜라겐 젤 피치(1EA)"
        DgvColName(DgvColNameList.Kollagen_Pe3) = "콜라겐 젤 피치(3EA)"
        DgvColName(DgvColNameList.Kollagen_Pe5) = "콜라겐 젤 피치(5EA)"

        DgvColName(DgvColNameList.ATCircleCase) = "ALTO 원형 케이스"
        DgvColName(DgvColNameList.APSquareCase) = "ALPHA 사각 케이스"

        DgvColName(DgvColNameList.MaxPeachCase) = "MAX_Peach 케이스"
        DgvColName(DgvColNameList.MassageSoothing) = "마사지 수딩젤"
        DgvColName(DgvColNameList.Case_MAX_SMint) = "MAXIMUM_ShineMint 케이스"

        DgvColName(DgvColNameList.MeshPouch) = "매쉬 파우치"
        DgvColName(DgvColNameList.FirmingAmp) = "탄력앰플"
        DgvColName(DgvColNameList.HyaluronicAmp) = "하이알앰플"
        DgvColName(DgvColNameList.nightshot) = "나이트샷"
        DgvColName(DgvColNameList.morningshot) = "모닝샷"
        DgvColName(DgvColNameList.casemaxwoodi) = "맥시멈 우디가죽케이스"
        DgvColName(DgvColNameList.Elicolltoner) = "엘릭시르 콜라겐 토너"
        DgvColName(DgvColNameList.Elicollamp) = "엘릭시르 콜라겐 앰플"
        DgvColName(DgvColNameList.Elicollcream) = "엘릭시르 콜라겐 크림"
        DgvColName(DgvColNameList.Elihyaltoner) = "엘릭시르 하이알 토너"
        DgvColName(DgvColNameList.Elihyalamp) = "엘릭시르 하이알 앰플"
        DgvColName(DgvColNameList.Elihyalcream) = "엘릭시르 하이알 크림"
        DgvColName(DgvColNameList.Dayshot) = "데이샷 14KIT"
        DgvColName(DgvColNameList.Beautyshopbag) = "뷰티루틴 쇼핑백"
        DgvColName(DgvColNameList.Gummy) = "구미 젤리"
        DgvColName(DgvColNameList.Stickjelly) = "스틱 젤리"
        DgvColName(DgvColNameList.Newyearbag) = "신년쇼핑백"
        DgvColName(DgvColNameList.Emsbelt) = " EMS 벨트"
        DgvColName(DgvColNameList.Beltbag) = "핏업벨트 쇼핑백"
        DgvColName(DgvColNameList.Dayshot2) = "데이샷(14개입) 6개"

        DgvColName(DgvColNameList.Etc) = "기타"
        DgvColName(DgvColNameList.ProFaceNum) = "PRO_FACE 번호"
        DgvColName(DgvColNameList.ProFaceCount) = "PRO_FACE 수량"

        DgvColName(DgvColNameList.ProEyeNum) = "PRO_Eye 번호"
        DgvColName(DgvColNameList.ProEyeCount) = "PRO_Eye 수량"
        DgvColName(DgvColNameList.ProBodyNum) = "PRO_Body 번호"
        DgvColName(DgvColNameList.ProBodyCount) = "PRO_Body 수량"
        DgvColName(DgvColNameList.LuxFaceNum) = "LUX_FACE 번호"
        DgvColName(DgvColNameList.LuxFaceCount) = "LUX_FACE 수량"
        DgvColName(DgvColNameList.LuxEyeNum) = "LUX_EYE 번호"
        DgvColName(DgvColNameList.LuxEyeCount) = "LUX_EYE 수량"
        DgvColName(DgvColNameList.LuxBodyNum) = "LUX_BODY 번호"
        DgvColName(DgvColNameList.LuxBodyCount) = "LUX_BODY 수량"

        DgvColName(DgvColNameList.MaximumNum) = "MAXIMUM 번호"
        DgvColName(DgvColNameList.MaximumCount) = "MAXIMUM 수량"
        DgvColName(DgvColNameList.AlphaSetNum) = "ALPHA_SET 번호"
        DgvColName(DgvColNameList.AlphaSetCount) = "ALPHA_SET 수량"
        DgvColName(DgvColNameList.AlphaFaceNum) = "ALPHA_FACE 번호"
        DgvColName(DgvColNameList.AlphaFaceCount) = "ALPHA_FACE 수량"
        DgvColName(DgvColNameList.AlphaEyeNum) = "ALPHA_EYE 번호"
        DgvColName(DgvColNameList.AlphaEyeCount) = "ALPHA_EYE 수량"
        DgvColName(DgvColNameList.AlphaBodyNum) = "ALPHA_BODY 번호"
        DgvColName(DgvColNameList.AlphaBodyCount) = "ALPHA_BODY 수량"


        DgvColName(DgvColNameList.AltoNum) = "ALTO 번호"
        DgvColName(DgvColNameList.AltoCount) = "ALTO 수량"
        DgvColName(DgvColNameList.EffectNum) = "Effect 번호"
        DgvColName(DgvColNameList.EffectCount) = "Effect 수량"
        DgvColName(DgvColNameList.Weight) = "측정 무게"

    End Sub

    Private Sub btnDateCh_Click(sender As Object, e As EventArgs) Handles btnDateCh.Click
        Today_Change.ShowDialog()
    End Sub

    Private Sub cboModel_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboModel.SelectedIndexChanged
        gbType.Enabled = True
        cboType.Items.Clear()
        cboType.SelectedIndex = -1
        cboType.Text = "선택"

        If cboModel.SelectedItem = "PRO" Or cboModel.SelectedItem = "LUX" Or cboModel.SelectedItem = "ALPHA" Then

            For i = 0 To State2_Type.BODY
                With cboType.Items
                    .Add(SteDual_Select(i))
                End With
            Next

        ElseIf cboModel.SelectedItem = "MAXIMUM" Then

            For i = 0 To State2_Type.FACE_V2
                With cboType.Items
                    .Add(SteMAX_Select(i))
                End With
            Next

        ElseIf cboModel.SelectedItem = "ALTO" Then

            For i = 0 To State2_Type.SET_V1
                With cboType.Items
                    .Add(SteALTO_Select(i))
                End With
            Next

        ElseIf cboModel.SelectedItem = "Effect" Then

            For i = 0 To State2_Type.SET_V1
                With cboType.Items
                    .Add(SteEffect_Select(i))
                End With
            Next

        ElseIf cboModel.SelectedItem = "구성품" Then

            For i = 0 To State2_Prod.MAXEnum - 1
                With cboType.Items
                    .Add(steProd_Select(i))
                End With
            Next

        Else
            gbType.Enabled = False
        End If

        gbColor.Enabled = False
        cboColor.SelectedIndex = -1
        cboColor.Text = "선택"

    End Sub

    Private Sub cboType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboType.SelectedIndexChanged

        gbColor.Enabled = True
        cboColor.Items.Clear()
        cboColor.SelectedIndex = -1
        cboColor.Text = "선택"

        If cboModel.SelectedItem <> "구성품" Then
            If cboModel.SelectedItem = "PRO" Then

                For i = 0 To State3_Color.black
                    With cboColor.Items
                        .Add(Color_Select(i))
                    End With
                Next

            ElseIf cboModel.SelectedItem = "MAXIMUM" Then

                If cboType.SelectedIndex = State2_Type.SET_V1 Then
                    For i = 0 To State3_Color.Black_Gold
                        With cboColor.Items
                            .Add(Color_Select(i))
                        End With
                    Next
                Else
                    For i = 0 To ColorV2_Num.Length - 1
                        With cboColor.Items
                            .Add(Color_Select(ColorV2_Num(i)))
                        End With
                    Next
                End If
            ElseIf cboModel.SelectedItem = "ALTO" Then

                For i = 0 To State3_Color.White
                    With cboColor.Items
                        .Add(Color_Select(ColorAL_Num(i)))
                    End With
                Next

            ElseIf cboModel.SelectedItem = "Effect" Then

                For i = 0 To Color_Select.Length - 1
                    With cboColor.Items
                        .Add(Color_Select(i))
                    End With
                Next

            Else
                gbColor.Enabled = False
            End If

        Else
            gbColor.Enabled = False
        End If

    End Sub

    Private Sub rdbInv_CheckedChanged(sender As Object, e As EventArgs) Handles rdbInv.CheckedChanged
        If cboSearch.SelectedIndex = 2 Then
            If rdbInv.Checked Then
                pnInv.Enabled = True
                pnPack.Enabled = False
                txbInv.Enabled = True
                txbPack.Enabled = False

                txbPack.Text = Nothing
                txbPack.Refresh()
            End If
        Else
            lbPack.Text = "패킹번호"
            txbPack.Text = Nothing
            btnDelProd.Text = "삭제"
            txbPack.Focus()
        End If
    End Sub

    Private Sub rdbPack_CheckedChanged(sender As Object, e As EventArgs) Handles rdbPack.CheckedChanged
        If cboSearch.SelectedIndex = 2 Then
            If rdbPack.Checked Then
                pnInv.Enabled = False
                pnPack.Enabled = True
                txbInv.Text = Nothing
                txbInv.Enabled = False
                txbPack.Enabled = True
                txbInv.Refresh()
            End If
        Else
            lbPack.Text = "제품번호"
            txbPack.Text = Nothing
            btnDelProd.Text = "삭제"
            txbPack.Focus()
        End If
    End Sub

    Private Sub ckbBarcode_CheckedChanged(sender As Object, e As EventArgs) Handles ckbBarcode.CheckedChanged
        If ckbBarcode.Checked = True Then
            pnStNum.Enabled = True
            pnSteNum.Enabled = False
            txbSteNum.Text = Nothing
            txbSteDate.Text = Nothing
            txbStNum.Refresh()
            txbStNum.Focus()

        Else
            pnStNum.Enabled = False
            pnSteNum.Enabled = True
            txbSteDate.Refresh()
            txbSteNum.Refresh()
            txbStNum.Text = Nothing
        End If

    End Sub

    Private Sub cboSearch_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboSearch.SelectedIndexChanged
        Select Case cboSearch.SelectedIndex
            Case 0
                pnOpt1.Enabled = True
                pnOpt1.Visible = True

                pnOpt1.Refresh()
                txbOrder.Refresh()
                txbPhone.Refresh()

                pnOpt2.Enabled = False
                pnOpt2.Visible = False

                pnOpt3.Enabled = False
                pnOpt3.Visible = False

                txbOrder.Text = Nothing
                txbPhone.Text = Nothing

                btnDelProd.Enabled = False
                btnDelProd.Visible = False

                txbOrder.Focus()
            Case 1
                pnOpt1.Enabled = False
                pnOpt1.Visible = False

                pnOpt2.Enabled = True
                pnOpt2.Visible = True
                ckbBarcode.Checked = True

                btnDelProd.Enabled = True
                btnDelProd.Visible = True
                btnDelProd.Text = "삭  제"

                txbStNum.Refresh()
                txbSteNum.Refresh()
                txbSteDate.Refresh()

                pnOpt3.Enabled = False
                pnOpt3.Visible = False
            Case 2
                pnOpt1.Enabled = False
                pnOpt1.Visible = False

                pnOpt2.Enabled = False
                pnOpt2.Visible = False

                pnOpt3.Enabled = True
                pnOpt3.Visible = True

                txbInv.Enabled = False

                rdbInv.Text = "송장번호 검색"
                rdbInv.Checked = False
                rdbPack.Text = "패킹번호 검색"
                rdbPack.Checked = True

                txbInv.Text = Nothing
                txbPack.Text = Nothing

                btnDelProd.Enabled = True
                btnDelProd.Visible = True
                btnDelProd.Text = "삭  제"

                txbPack.Enabled = True
                lbPack.Text = "패킹번호"
                txbInv.Refresh()
                txbPack.Refresh()

                txbPack.Focus()

            Case 3
                pnOpt1.Enabled = False
                pnOpt1.Visible = False

                pnOpt2.Enabled = False
                pnOpt2.Visible = False

                pnOpt3.Enabled = True
                pnOpt3.Visible = True

                txbInv.Enabled = False

                rdbInv.Text = "패킹번호 검색"
                rdbInv.Checked = True
                rdbPack.Text = "제품번호 검색"
                rdbPack.Checked = False

                btnDelProd.Enabled = True
                btnDelProd.Visible = True
                btnDelProd.Text = "삭  제"

                txbInv.Text = Nothing
                txbPack.Text = Nothing

                txbPack.Enabled = True

                txbInv.Refresh()
                txbPack.Refresh()

                txbPack.Focus()
        End Select
    End Sub


    Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
        dgvDataSearch.Rows.Clear()
    End Sub

    Private Sub btnToday_Click(sender As Object, e As EventArgs) Handles btnToday.Click
        dgv_Setting(True)
        'today_prod("SELECT * FROM (SELECT a.Order_Code, a.Account_Name,a.Orderer_Name,a.Phone_Number,a.Address,a.Refer,a.Shipment_Date,a.Item_Code,a.Item_Name,a.Item_Count,a.Apply_Face,a.Apply_Eye,a.Invoice_Number,a.Packing_Code,a.Serial_Number,b.Weight FROM " & order_db & " AS a INNER JOIN " & sales_db & " AS b WHERE a.Packing_Code = b.PackingCode AND a.Shipment_Date = '" & Format(Now, "yyyy") & "-" & Format(Now, "MM") & "-" & Format(Now, "dd") & "') AS tb1", 16)
        today_prod("SELECT * FROM (SELECT a.Order_Code, a.Account_Name,a.Orderer_Name,a.Phone_Number,a.Address,a.Refer,a.Shipment_Date,a.Item_Code,a.Item_Name,a.Item_Count,a.Apply_Face,a.Apply_Eye,a.Invoice_Number,a.Packing_Code,a.Serial_Number,b.Weight FROM " & order_db & " AS a INNER JOIN " & sales_db & " AS b WHERE a.Packing_Code = b.PackingCode AND a.Shipment_Date = '" & NowToday & "') AS tb1", 16)
    End Sub

    Private Function today_prod(DBCmd As String, column_count As Int16) As Boolean

        Try
            Dim count As Int16 = 0
            Dim StartSwitch As Boolean = False
            Dim data_content(column_count) As String

            If DBQueryReader(DBCmd) Then
                For i = 0 To sqlDataQuery.Length - 1

                    count = i Mod column_count

                    data_content(count) = sqlDataQuery(i)

                    If count = 15 And StartSwitch = True Then
                        dgvDataSearch.Rows.Add(data_content)
                    Else
                        StartSwitch = True
                    End If
                Next
            End If

            Return False

        Catch ex As Exception
            Return True
        End Try

    End Function

    Private Sub dgv_Setting(Type As Boolean)
        dgvDataSearch.Columns.Clear()

        If Type = True Then

            dgvDataSearch.ColumnCount = 16

            dgvDataSearch.Columns(0).Name = "전표번호"
            dgvDataSearch.Columns(0).Width = 150
            dgvDataSearch.Columns(1).Name = "회사명"
            dgvDataSearch.Columns(1).Width = 150
            dgvDataSearch.Columns(2).Name = "주문자명"
            dgvDataSearch.Columns(2).Width = 150
            dgvDataSearch.Columns(3).Name = "전화번호"
            dgvDataSearch.Columns(3).Width = 150
            dgvDataSearch.Columns(4).Name = "주소"
            dgvDataSearch.Columns(4).Width = 150
            dgvDataSearch.Columns(5).Name = "참조"
            dgvDataSearch.Columns(5).Width = 150
            dgvDataSearch.Columns(6).Name = "등록일자"
            dgvDataSearch.Columns(6).Width = 150
            dgvDataSearch.Columns(7).Name = "품목코드"
            dgvDataSearch.Columns(7).Width = 150
            dgvDataSearch.Columns(8).Name = "품목명"
            dgvDataSearch.Columns(8).Width = 150
            dgvDataSearch.Columns(9).Name = "수량"
            dgvDataSearch.Columns(9).Width = 150
            dgvDataSearch.Columns(10).Name = "페이스샷"
            dgvDataSearch.Columns(10).Width = 150
            dgvDataSearch.Columns(11).Name = "눈가샷"
            dgvDataSearch.Columns(11).Width = 150
            dgvDataSearch.Columns(12).Name = "송장번호"
            dgvDataSearch.Columns(12).Width = 150
            dgvDataSearch.Columns(13).Name = "패킹번호"
            dgvDataSearch.Columns(13).Width = 150
            dgvDataSearch.Columns(14).Name = "제품 시리얼번호"
            dgvDataSearch.Columns(14).Width = 150
            dgvDataSearch.Columns(15).Name = "무게"
            dgvDataSearch.Columns(15).Width = 150

            pack_use = False
            csv_Type = False

        Else
            dgvDataSearch.ColumnCount = 15

            dgvDataSearch.Columns(0).Name = "전표번호"
            dgvDataSearch.Columns(0).Width = 150
            dgvDataSearch.Columns(1).Name = "회사명"
            dgvDataSearch.Columns(1).Width = 150
            dgvDataSearch.Columns(2).Name = "주문자명"
            dgvDataSearch.Columns(2).Width = 150
            dgvDataSearch.Columns(3).Name = "전화번호"
            dgvDataSearch.Columns(3).Width = 150
            dgvDataSearch.Columns(4).Name = "주소"
            dgvDataSearch.Columns(4).Width = 150
            dgvDataSearch.Columns(5).Name = "참조"
            dgvDataSearch.Columns(5).Width = 150
            dgvDataSearch.Columns(6).Name = "등록일자"
            dgvDataSearch.Columns(6).Width = 150
            dgvDataSearch.Columns(7).Name = "품목코드"
            dgvDataSearch.Columns(7).Width = 150
            dgvDataSearch.Columns(8).Name = "품목명"
            dgvDataSearch.Columns(8).Width = 150
            dgvDataSearch.Columns(9).Name = "수량"
            dgvDataSearch.Columns(9).Width = 150
            dgvDataSearch.Columns(10).Name = "페이스샷"
            dgvDataSearch.Columns(10).Width = 150
            dgvDataSearch.Columns(11).Name = "눈가샷"
            dgvDataSearch.Columns(11).Width = 150
            dgvDataSearch.Columns(12).Name = "송장번호"
            dgvDataSearch.Columns(12).Width = 150
            dgvDataSearch.Columns(13).Name = "패킹번호"
            dgvDataSearch.Columns(13).Width = 150
            dgvDataSearch.Columns(14).Name = "제품 시리얼번호"
            dgvDataSearch.Columns(14).Width = 150

            pack_use = False
            csv_Type = True

        End If

    End Sub

    Private Sub PackingColumns()
        dgvDataSearch.ColumnCount = DgvColNameList.MAXCol

        For i = 0 To DgvColNameList.MAXCol - 1
            dgvDataSearch.Columns(i).Name = DgvColName(i)
            dgvDataSearch.Columns(i).Width = 150
        Next

        pack_use = True
    End Sub

    Private Sub btnSearch2_Click(sender As Object, e As EventArgs) Handles btnSearch2.Click
        dgvDataSearch.Rows.Clear()
        dgv_Setting(True)

        If cboModel.SelectedItem = "전체" Then
            where_text = "SELECT * FROM (SELECT a.Order_Code, a.Account_Name,a.Orderer_Name,a.Phone_Number,a.Address,a.Refer,a.Shipment_Date,a.Item_Code,a.Item_Name,a.Item_Count,a.Apply_Face,a.Apply_Eye,a.Invoice_Number,a.Packing_Code,a.Serial_Number,b.Weight FROM " & order_db & " AS a INNER JOIN " & sales_db & " AS b WHERE a.Packing_Code = b.PackingCode AND a.Shipment_Date BETWEEN '" & lbStDate.Text & "' AND '" & lbEnDate.Text & "') AS tb1"
            If today_prod(where_text, 16) Then
                MsgBox("데이터를 불러올 수 없습니다. 다시 시도하여 주십시오.", vbExclamation)
                Exit Sub
            End If
        Else

            If cboModel.SelectedItem = "구성품" Then

                If cboType.SelectedIndex = -1 Then
                    MsgBox("검색할 구성 품목을 선택하여 주십시오.", vbExclamation)
                    Exit Sub
                End If

                If State_Arrange_Prod() Then
                    MsgBox("검색 결과가 없습니다.", vbExclamation)
                    Exit Sub
                End If

            Else
                If State_arrange() Then
                    MsgBox("검색 결과가 없습니다.", vbExclamation)
                    Exit Sub
                End If
            End If

            If where_text = "" Then
                MsgBox("등록된 데이터가 존재하지 않습니다. 데이터를 등록하여 주십시오.", vbExclamation)
                Exit Sub
            End If

            where_create()

            If today_prod(where_text, 16) Then
                MsgBox("데이터를 불러올 수 없습니다. 다시 시도하여 주십시오.", vbExclamation)
                Exit Sub
            End If
        End If
    End Sub

    Private Sub where_create()
        Dim create_where As String = ""
        Dim instr_data As String = ""

        For i = 0 To UBound(Split(where_text, ","))
            If InStr(1, where_text, ",") > 0 Then
                If create_where = "" Then
                    create_where = "tb1.Item_Code = '" & Mid(where_text, 1, InStr(1, where_text, ",") - 1) & "' or "
                Else
                    create_where = create_where & "tb1.Item_Code = '" & Mid(where_text, 1, InStr(1, where_text, ",") - 1) & "' or "
                End If

                where_text = Mid(where_text, InStr(1, where_text, ",") + 1, where_text.Length)
            Else
                If create_where = "" Then
                    create_where = "tb1.Item_Code = '" & Mid(where_text, InStr(1, where_text, ",") + 1, where_text.Length) & "'"
                Else
                    create_where = create_where & "tb1.Item_Code = '" & Mid(where_text, InStr(1, where_text, ",") + 1, where_text.Length) & "'"
                End If
            End If
        Next

        where_text = "SELECT * FROM (SELECT a.Order_Code, a.Account_Name,a.Orderer_Name,a.Phone_Number,a.Address,a.Refer,a.Shipment_Date,a.Item_Code,a.Item_Name,a.Item_Count,a.Apply_Face,a.Apply_Eye,a.Invoice_Number,a.Packing_Code,a.Serial_Number,b.Weight FROM " & order_db & " AS a INNER JOIN " & sales_db & " AS b WHERE a.Packing_Code = b.PackingCode AND a.Shipment_Date BETWEEN '" & lbStDate.Text & "' AND '" & lbEnDate.Text & "') AS tb1 WHERE " & create_where

    End Sub

    Private Function State_Arrange_Prod() As Boolean
        where_text = ""

        DBCMD = "SELECT ItemCode FROM " & CData_table & " WHERE ProdCode = '" & cboType.SelectedIndex & "'"

        If DBQueryReader(DBCMD) Then
            For i = 0 To sqlDataQuery.Length - 1
                If where_text = "" Then
                    where_text = sqlDataQuery(i)
                Else
                    where_text = where_text & "," & sqlDataQuery(i)
                End If
            Next

            Return False
        Else
            Return True
        End If
    End Function

    Private Function State_arrange() As Boolean
        Dim ColorNum As Int16
        Dim TypeNum As Int16
        Dim ModelNum As Int16
        Dim dimWhere As String

        where_text = ""

        If cboColor.SelectedIndex <> -1 And cboType.SelectedIndex <> -1 And cboModel.SelectedIndex <> -1 Then
            ModelNum = cboModel.SelectedIndex + 1
            TypeNum = cboType.SelectedIndex
            ColorNum = Color_Num(cboColor.SelectedIndex)

            dimWhere = "SELECT ItemCode FROM " & PData_table & " WHERE ModelNum = '" & ModelNum & "' AND TypeNum = '" & TypeNum & "' AND ColorNum = '" & ColorNum & "'"

        ElseIf cboColor.SelectedIndex = -1 And cboType.SelectedIndex <> -1 And cboModel.SelectedIndex <> -1 Then
            ModelNum = cboModel.SelectedIndex + 1
            TypeNum = cboType.SelectedIndex

            dimWhere = "SELECT ItemCode FROM " & PData_table & " WHERE ModelNum = '" & ModelNum & "' AND TypeNum = '" & TypeNum & "'"

        ElseIf cboColor.SelectedIndex = -1 And cboType.SelectedIndex = -1 And cboModel.SelectedIndex <> -1 Then
            ModelNum = cboModel.SelectedIndex + 1

            dimWhere = "SELECT ItemCode FROM " & PData_table & " WHERE ModelNum = '" & ModelNum & "'"

        Else
            Return True
        End If

        If DBQueryReader(dimWhere) Then
            For i = 0 To sqlDataQuery.Length - 1
                If where_text = "" Then
                    where_text = sqlDataQuery(i)
                Else
                    where_text = where_text & "," & sqlDataQuery(i)
                End If
            Next

            Return False
        Else
            Return True
        End If

    End Function

    Private Sub btnExcel_Click(sender As Object, e As EventArgs) Handles btnExcel.Click
        If dgvDataSearch.Rows.Count = 0 Then
            MsgBox("저장할 데이터가 없습니다. 데이터를 불러와 주십시오.", vbExclamation)
        Else
            If Save_CSV() Then
                MsgBox("Data Save Fail !", vbCritical)
                Exit Sub
            End If

            MsgBox("엑셀 파일 저장이 완료되었습니다.", vbInformation)
        End If

    End Sub

    Private Function Save_CSV() As Boolean

        Try
            Dim save_text As String
            Dim fileCnt As Long
            Dim runFlag As Boolean = False
            Dim syear As String = DateAndTime.Year(Now)
            Dim smonth As String = DateAndTime.Month(Now)
            Dim sday As String = DateAndTime.Day(Now)

            Dim filepath = System.AppDomain.CurrentDomain.BaseDirectory() & "Load_Data"

            If Dir(filepath, vbDirectory) = "" Then
                MkDir(filepath)
            End If

            filepath = System.AppDomain.CurrentDomain.BaseDirectory() & "Load_Data\" & syear & "_" & smonth & "_" & sday

            If Dir(filepath, vbDirectory) = "" Then
                MkDir(filepath)
            End If

            Dim firstfilename As String = filepath & "\" & syear & "_" & smonth & "_" & sday
            Dim filename As String = firstfilename & ".CSV"

            Do
                If File.Exists(filename) = True Then
                    fileCnt = fileCnt + 1
                    filename = firstfilename & "_" & fileCnt & ".CSV"
                    runFlag = False
                Else
                    runFlag = True
                End If
            Loop Until (runFlag)

            If pack_use = True Then
                save_text = "패킹번호,패킹날짜,Set_Serial,Set_개수,아쿠아 마스크,리프팅 마스크,헤어밴드,블루밍 젤,미니젤,앰플,크림,우산,손풍기,충전기,충전 케이블,토너,케이스,PRO_블랙 케이스,PRO_베이지 케이스,PRO_레드 케이스,PRO_핑크 케이스,MAX_블랙 케이스,MAX_살구 케이스,MAX_민트 케이스,MAX_베이지 케이스,MAX_퍼플 케이스,MAX_뱀피 케이스,MAX_사피아노 블랙 케이스,MAX_사피아노 퍼플 케이스,MAX_Yellow 케이스,더스트백,수딩젤,0호 박스,1호 박스,2호 박스,3호 박스,4호 박스,5호 박스,6호 박스,쇼핑백,코스메틱 쇼핑백,콜라겐 젤(단품),콜라겐 젤(세트),콜라겐 젤 퍼플(단품),콜라겐 젤 퍼플(세트),클렌징 워터,토너 패드,홀로그램 젤 1EA,홀로그램 젤 3EA, 홀로그램 젤 5EA,콜라겐 젤 피치(1EA),콜라겐 젤 피치(3EA), 콜라겐 젤 피치(5EA),ALTO_원형_케이스,ALPHA_사각_케이스,MAX_Peach 케이스,마사지 수딩젤,MAX_ShineMint 케이스,매쉬 파우치,탄력앰플,하이알앰플,나이트샷,모닝샷,데이샷,맥시멈 우디가죽케이스,스틱젤리,구미젤리,신년쇼핑백,EMS벨트,핏업벨트쇼핑백,데이샷(14개입)6개,기타,PRO_FACE_번호,PRO_FACE_개수,PRO_EYE_번호,PRO_EYE_개수,PRO_BODY_번호,PRO_BODY_개수,LUX_FACE_번호,LUX_FACE_개수,LUX_EYE_번호,LUX_EYE_개수,LUX_BODY_번호,LUX_BODY_개수,MAXIMUM_번호,MAXIMUM_개수,Alpha_Set_번호,Alpha_Set_개수,Alpha_Face_번호,Alpha_Face_개수,Alpha_Eye_번호,Alpha_Eye_개수,Alpha_Body_번호,Alpha_Body_개수,Alto_번호,Alto_개수,Effect_번호,Effect_개수,측정무게" & vbCrLf

                For i = 0 To dgvDataSearch.Rows.Count - 2
                    For cnt = 0 To dgvDataSearch.ColumnCount - 1
                        If cnt = dgvDataSearch.ColumnCount - 1 Then
                            save_text = save_text & dgvDataSearch.Rows(i).Cells(cnt).Value.ToString & vbCrLf
                        Else
                            save_text = save_text & dgvDataSearch.Rows(i).Cells(cnt).Value.ToString & ","
                        End If
                    Next
                Next
            Else
                If csv_Type = True Then
                    save_text = "전표날짜,번호,회사명,주문자명,전화번호,주소,참조,등록일자,품목코드,품목명,수량,페이스샷,눈가샷,송장번호,패킹번호,제품 시리얼번호" & vbCrLf

                    For i = 0 To dgvDataSearch.Rows.Count - 2
                        save_text = save_text + dgvDataSearch.Rows(i).Cells(0).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(1).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(2).Value & "," & dgvDataSearch.Rows(i).Cells(3).Value.ToString & ",'" & dgvDataSearch.Rows(i).Cells(4).Value.ToString & "," & Chr(34) & dgvDataSearch.Rows(i).Cells(5).Value.ToString & Chr(34) & "," & Chr(34) & dgvDataSearch.Rows(i).Cells(6).Value.ToString & Chr(34) & "," & dgvDataSearch.Rows(i).Cells(7).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(8).Value.ToString & "," & Chr(34) & dgvDataSearch.Rows(i).Cells(9).Value.ToString & Chr(34) & "," & dgvDataSearch.Rows(i).Cells(10).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(11).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(12).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(13).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(14).Value.ToString & "," & Chr(34) & dgvDataSearch.Rows(i).Cells(15).Value.ToString & Chr(34) & vbCrLf
                    Next
                Else
                    save_text = "전표번호,회사명,주문자명,전화번호,참조,등록일자,품목코드,품목명,수량,페이스샷,눈가샷,송장번호,패킹번호,제품 시리얼 번호,무게" & vbCrLf

                    For i = 0 To dgvDataSearch.Rows.Count - 2
                        Dim ProdName As String = dgvDataSearch.Rows(i).Cells(8).Value.ToString.Replace(",", "/")
                        save_text = save_text + dgvDataSearch.Rows(i).Cells(0).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(1).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(2).Value & "," & dgvDataSearch.Rows(i).Cells(3).Value.ToString & ",'" & Chr(34) & dgvDataSearch.Rows(i).Cells(5).Value.ToString & Chr(34) & "," & Chr(34) & dgvDataSearch.Rows(i).Cells(6).Value.ToString & Chr(34) & "," & dgvDataSearch.Rows(i).Cells(7).Value.ToString & "," & ProdName & "," & Chr(34) & dgvDataSearch.Rows(i).Cells(9).Value.ToString & Chr(34) & "," & dgvDataSearch.Rows(i).Cells(10).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(11).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(12).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(13).Value.ToString & "," & dgvDataSearch.Rows(i).Cells(14).Value.ToString & "," & Chr(34) & dgvDataSearch.Rows(i).Cells(15).Value.ToString & Chr(34) & vbCrLf
                    Next
                End If
            End If

            Dim objWriter As StreamWriter = New System.IO.StreamWriter(filename, True, System.Text.Encoding.UTF8)
            objWriter.WriteLine(save_text)

            objWriter.Close()

            Return False
        Catch ex As Exception
            Return True
        End Try
    End Function

    Private Sub btnStateData_Click(sender As Object, e As EventArgs) Handles btnStateData.Click
        dgv_Setting(False)
        If today_prod("SELECT * FROM (SELECT a.Order_Code, a.Account_Name,a.Orderer_Name,a.Phone_Number,a.Address,a.Refer,a.Shipment_Date,a.Item_Code,a.Item_Name,a.Item_Count,a.Apply_Face,a.Apply_Eye,a.Invoice_Number,a.Packing_Code,a.Serial_Number FROM " & order_db & " AS a WHERE a.Shipment_Date = '" & NowToday & "') AS tb1", 16) Then
            MsgBox("데이터를 불러오는 도중 오류가 발생하였습니다. 데이터를 확인하여 주십시오.", vbCritical)
        End If

        If dgvDataSearch.Rows.Count = 1 Then
            MsgBox("금일 출하 데이터가 존재하지 않습니다. 진행 후 다시 진행하여 주십시오.", vbExclamation)
        End If
    End Sub

    Private Sub btnOneSearch_Click(sender As Object, e As EventArgs) Handles btnOneSearch.Click
        where_txt = ""
        SearchCode = txbPack.Text

        dgv_Setting(True)

        If cboSearch.SelectedIndex = 0 Then
            where_txt = Order_Search()

            If where_txt = "nothing" Then
                MsgBox("고객명 혹은 전화번호를 입력하지 않았습니다. 검색하고자 하는 데이터를 입력하여 주십시오.", vbExclamation)
                Exit Sub
            End If

        ElseIf cboSearch.SelectedIndex = 1 Then
            If txbStNum.Text.Replace(" ", "") = "" And txbSteDate.Text.Replace(" ", "") = "" And txbSteNum.Text.Replace(" ", "") = "" Then
                MsgBox("정보를 입력하지 않았습니다. 정보 입력 후 검색 버튼을 눌러주세요.", vbExclamation)
                Exit Sub
            End If

            If ckbBarcode.Checked = True Then
                where_txt = "tb1.Order_Code = '" & txbStNum.Text & "'"
            Else
                where_txt = "tb1.Order_Code = 'E040221/" & txbSteDate.Text & "/" & txbSteNum.Text & "'"
            End If

        ElseIf cboSearch.SelectedIndex = 2 Then


            If txbInv.Text.Replace(" ", "") = "" And txbPack.Text.Replace(" ", "") = "" Then
                MsgBox("검색할 정보를 입력하지 않았습니다. 정보 입력 후 검색 버튼을 눌러주세요.", vbExclamation)
                Exit Sub
            End If

            If rdbInv.Checked Then
                where_txt = "tb1.Invoice_Number = '" & txbInv.Text & "'"
            Else
                where_txt = "tb1.Packing_Code = '" & txbPack.Text & "'"
            End If

        ElseIf cboSearch.SelectedIndex = 3 Then

            If txbPack.Text.Replace(" ", "") = "" Then
                MsgBox("검색할 정보를 입력하지 않았습니다. 정보 입력 후 검색 버튼을 눌러주세요.", vbExclamation)
                Exit Sub
            End If
        Else
            MsgBox("잘못된 경로입니다. 관리자에게 문의하여 주십시오.", vbCritical)
            Exit Sub
        End If

        If cboSearch.SelectedIndex < 3 Then
            If today_prod("SELECT * FROM (SELECT a.Order_Code, a.Account_Name,a.Orderer_Name,a.Phone_Number,a.Address,a.Refer,a.Shipment_Date,a.Item_Code,a.Item_Name,a.Item_Count,a.Apply_Face,a.Apply_Eye,a.Invoice_Number,a.Packing_Code,a.Serial_Number,b.Weight FROM " & order_db & " AS a INNER JOIN " & sales_db & " AS b WHERE a.Packing_Code = b.PackingCode ) AS tb1 Where " & where_txt, 16) Then
                MsgBox("데이터가 존재하지 않습니다.", vbCritical)
                Exit Sub
            End If
        Else
            If PackingData(SearchCode) Then
                MsgBox("데이터가 존재하지 않습니다.", vbCritical)
                Exit Sub
            End If
        End If

        If dgvDataSearch.Rows.Count = 1 Then
            MsgBox("데이터가 존재하지 않습니다. 입력한 데이터를 다시 확인하여 주십시오.", vbExclamation)
        End If
    End Sub

    Private Function PackingData(PackSerial As String) As Boolean
        Dim countNum As Int16
        dgvDataSearch.Rows.Clear()
        PackingColumns()
        Dim ColCount As Int16 = dgvDataSearch.ColumnCount
        Dim DataContent(ColCount) As String

        If rdbInv.Checked = True Then
            DBCMD = "SELECT PackingCode,`Data`,Main_Product_SN,Set_Cnt,Mask5Cnt,Mask10Cnt,HairBandCnt,GelCnt,MiniGelCnt,AmpleCnt,CreamCnt,UmbrellaCnt,FenCnt,ChargerCnt,CableCnt,TonerCnt,CaseCnt,Case_PRO_Black,Case_PRO_Beige,Case_PRO_Red,Case_PRO_Pink,Case_MAX_Black,Case_MAX_Apr,Case_MAX_Mint,Case_MAX_Beige,Case_MAX_Purple,Case_PRO_SnakeBlakc,Case_MAX_SafBK_Cnt,Case_MAX_SafPp_Cnt,Case_MAX_Yellow,DustBagCnt,SoothingGelCnt,Carton0_Cnt,Carton1_Cnt,Carton2_Cnt,Carton3_Cnt,Carton4_Cnt,Carton5_Cnt,Carton6_Cnt,Shopbag_Cnt,CosShopbag_Cnt,KollagenCnt,KollagenSetCnt,Kollagen_PCnt,KollagenSet_PCnt,CleansingWaterCnt,TonerPadCnt,Hologram_1Cnt,Hologram_3Cnt,Hologram_5Cnt,Kollagen_Pe1Cnt,Kollagen_Pe3Cnt,Kollagen_Pe5Cnt,ATCircleCaseCnt,APSquareCaseCnt,Case_MAX_Peach,MasSoothingCnt,Case_MAX_SMintCnt,MeshPouchCnt,FirmingAmpCnt,HyaluronicAmpCnt,nightshotcnt,morningshotcnt,casemaxwoodicnt,Elicolltonercnt,Elicollampcnt,Elicollcreamcnt,Elihyaltonercnt,Elihyalampcnt,Elihyalcreamcnt,Dayshotcnt,Beautyshopbagcnt,Stickjellycnt,Newyearbagcnt,Emsbeltcnt,Beltbagcnt,Dayshot2cnt,EtcCnt,Pro_Face_Serial,Pro_CT_FaceCnt,Pro_Eye_Serial,Pro_CT_EYE_Cnt,Pro_Body_Serial,Pro_CT_BodyCnt,Lux_Face_Serial,Lux_CT_FaceCnt,Lux_Eye_Serial,Lux_CT_EYE_Cnt,Lux_Body_Serial,Lux_CT_BodyCnt,MAXIMUM_SN,MAXIMUM_Cnt,Alpha_Set_Serial,Alpha_Set_Cnt,Alpha_Face_Serial,Alpha_Face_Cnt,Alpha_Eye_Serial,Alpha_Eye_Cnt,Alpha_Body_Serial,Alpha_Body_Cnt,Alto_Serial,Alto_Cnt,Effect_serial,Effect_cnt,Weight FROM " & sales_db & " WHERE PackingCode = '" & PackSerial & "'"
        Else
            DBCMD = "SELECT PackingCode,`Data`,Main_Product_SN,Set_Cnt,Mask5Cnt,Mask10Cnt,HairBandCnt,GelCnt,MiniGelCnt,AmpleCnt,CreamCnt,UmbrellaCnt,FenCnt,ChargerCnt,CableCnt,TonerCnt,CaseCnt,Case_PRO_Black,Case_PRO_Beige,Case_PRO_Red,Case_PRO_Pink,Case_MAX_Black,Case_MAX_Apr,Case_MAX_Mint,Case_MAX_Beige,Case_MAX_Purple,Case_PRO_SnakeBlakc,Case_MAX_SafBK_Cnt,Case_MAX_SafPp_Cnt,Case_MAX_Yellow,DustBagCnt,SoothingGelCnt,Carton0_Cnt,Carton1_Cnt,Carton2_Cnt,Carton3_Cnt,Carton4_Cnt,Carton5_Cnt,Carton6_Cnt,Shopbag_Cnt,CosShopbag_Cnt,KollagenCnt,KollagenSetCnt,Kollagen_PCnt,KollagenSet_PCnt,CleansingWaterCnt,TonerPadCnt,Hologram_1Cnt,Hologram_3Cnt,Hologram_5Cnt,Kollagen_Pe1Cnt,Kollagen_Pe3Cnt,Kollagen_Pe5Cnt,ATCircleCaseCnt,APSquareCaseCnt,Case_MAX_Peach,MasSoothingCnt,Case_MAX_SMintCnt,MeshPouchCnt,FirmingAmpCnt,HyaluronicAmpCnt,nightshotcnt,morningshotcnt,casemaxwoodicnt,Elicolltonercnt,Elicollampcnt,Elicollcreamcnt,Elihyaltonercnt,Elihyalampcnt,Elihyalcreamcnt,Dayshotcnt,Beautyshopbagcnt,Stickjellycnt,Newyearbagcnt,Emsbeltcnt,Beltbagcnt,Dayshot2cnt,EtcCnt,Pro_Face_Serial,Pro_CT_FaceCnt,Pro_Eye_Serial,Pro_CT_EYE_Cnt,Pro_Body_Serial,Pro_CT_BodyCnt,Lux_Face_Serial,Lux_CT_FaceCnt,Lux_Eye_Serial,Lux_CT_EYE_Cnt,Lux_Body_Serial,Lux_CT_BodyCnt,MAXIMUM_SN,MAXIMUM_Cnt,Alpha_Set_Serial,Alpha_Set_Cnt,Alpha_Face_Serial,Alpha_Face_Cnt,Alpha_Eye_Serial,Alpha_Eye_Cnt,Alpha_Body_Serial,Alpha_Body_Cnt,Alto_Serial,Alto_Cnt,Effect_serial,Effect_cnt,Weight FROM " & sales_db & " WHERE Main_Product_SN LIKE '%" & PackSerial & "%' OR Main_FACE_SN LIKE '%" & PackSerial & "%' OR Main_EYE_SN LIKE '%" & PackSerial & "%' OR Pro_Face_Serial LIKE '%" & PackSerial & "%' OR Pro_Eye_Serial LIKE '%" & PackSerial & "%' OR Pro_Body_Serial LIKE '%" & PackSerial & "%' OR Lux_Face_Serial LIKE '%" & PackSerial & "%' OR Lux_Eye_Serial LIKE '%" & PackSerial & "%' OR Lux_Body_Serial LIKE '%" & PackSerial & "%' OR MAXIMUM_SN LIKE '%" & PackSerial & "%' OR Alpha_Set_Serial LIKE '%" & PackSerial & "%' OR Alpha_Face_Serial LIKE '%" & PackSerial & "%' OR Alpha_Eye_Serial LIKE '%" & PackSerial & "%' OR Alpha_Body_Serial LIKE '%" & PackSerial & "%' OR Alto_Serial LIKE '%" & PackSerial & "%'OR Effect_Serial LIKE '%" & PackSerial & "%' "
        End If

        If DBQueryReader(DBCMD) Then
            For i = 0 To sqlDataQuery.Length - 1
                countNum = i Mod ColCount
                DataContent(countNum) = sqlDataQuery(i)

                If countNum = ColCount - 1 Then
                    dgvDataSearch.Rows.Add(DataContent)
                End If
            Next

            Return False
        Else
            Return True
        End If
    End Function

    Private Function Order_Search() As String
        Dim order_name, phone As String
        If txbOrder.Text.Replace(" ", "") <> "" Then
            order_name = txbOrder.Text
        Else
            order_name = Nothing
        End If

        If txbPhone.Text.Replace(" ", "") <> "" Then
            phone = txbPhone.Text
        Else
            phone = Nothing
        End If

        If order_name = Nothing And phone = Nothing Then
            Return "nothing"
        End If

        If order_name <> Nothing Then
            order_name = "tb1.Orderer_Name = '" & order_name & "'"
        End If

        If phone <> Nothing Then
            If order_name = Nothing Then
                phone = "tb1.Phone_Number = '" & phone & "'"
            Else
                phone = order_name & " AND Phone_Number = '" & phone & "'"
            End If

        Else
            phone = order_name
        End If

        Return phone

    End Function

    Private Sub txbOrder_KeyDown(sender As Object, e As KeyEventArgs) Handles txbOrder.KeyDown, txbPhone.KeyDown, txbInv.KeyDown, txbPack.KeyDown, txbOrder.KeyDown, txbPhone.KeyDown
        If e.KeyCode = Keys.Return Then
            btnOneSearch_Click(sender, e)
        End If
    End Sub

    Private Sub btnDelProd_Click(sender As Object, e As EventArgs) Handles btnDelProd.Click

        Try
            Dim DeleteType As Boolean = False '' true = 패킹 데이터에서 삭제 / false = 패킹,송장 번호에서 삭제
            NoteStr = Nothing
            Dim RowFullNum As Integer = dgvDataSearch.Rows.Count
            Dim RowNum As Integer = dgvDataSearch.SelectedCells(0).RowIndex
            dgvDataSearch.Rows(RowNum).Selected = True

            If dgvDataSearch.Rows.Count > 0 Or dgvDataSearch.SelectedCells.Count > 0 Then

                If cboSearch.SelectedIndex = SearchList.OrderCode Then
                    If MsgBox(dgvDataSearch.Rows(RowNum).Cells(0).Value & vbCrLf & "전표 데이터를 삭제하시겠습니까?", vbCritical) = MsgBoxResult.Ok Then

                        If OrderCodeDelete(RowNum) Then
                            MsgBox("삭제 완료", vbInformation)
                        Else
                            MsgBox("삭제 실패", vbCritical)
                        End If

                    End If

                ElseIf cboSearch.SelectedIndex = SearchList.Packing_Inv Then

                    If MsgBox(dgvDataSearch.Rows(RowNum).Cells(0).Value & vbCrLf & " 패킹 데이터를 삭제하시겠습니까?", vbCritical) = MsgBoxResult.Ok Then
                        DeleteType = False

                        If OrderCodeDelete(RowNum) Then
                            If PackingCodeDelete(RowNum, DeleteType) Then
                                MsgBox("삭제 완료", vbInformation)
                            Else
                                MsgBox("삭제 실패", vbCritical)
                            End If
                        Else
                            MsgBox("삭제 실패", vbCritical)
                        End If

                    End If

                ElseIf cboSearch.SelectedIndex = SearchList.Packing_Only Then
                    DeleteType = True

                    If MsgBox(dgvDataSearch.Rows(RowNum).Cells(0).Value & vbCrLf & " 패킹 데이터를 삭제하시겠습니까?", vbCritical) = MsgBoxResult.Ok Then
                        If PackingCodeDelete(RowNum, DeleteType) Then
                            MsgBox("삭제 완료", vbInformation)
                        Else
                            MsgBox("삭제 실패", vbCritical)
                        End If
                    End If

                Else
                    MsgBox("해당 기능을 사용할 수 없는 검색 항목입니다.", vbCritical)
                End If

            Else
                MsgBox("삭제할 데이터를 선택하여 주십시오.", vbExclamation)
            End If

        Catch ex As NullReferenceException
            MsgBox("존재하지 않는 값이 존재합니다. 값을 확인하여 주십시오.", vbCritical)

        Catch ex2 As Exception
            MsgBox("오류가 발생하였습니다. 데이터를 확인하여 주십시오.", vbCritical)
        End Try

    End Sub

    Private Function PackingCodeDelete(RowNum As Integer, DelType As Boolean) As Boolean
        Try
            Dim PackingNum As String = String.Empty

            If DelType = True Then
                PackingNum = dgvDataSearch.Rows(RowNum).Cells(0).Value
            Else
                PackingNum = dgvDataSearch.Rows(RowNum).Cells(16).Value
            End If

            Dim SaveData As String = PackingSerialSearch(PackingNum)

            If SaveData = "FAIL" Then
                MsgBox("저장할 데이터를 검색하는 도중 오류가 발생하였습니다.", vbCritical)
                Return False
            End If

            DBCMD = "UPDATE " & sales_db & " SET PackingCode = 'NULL_" & PackingNum & "', Main_Product_SN = NULL, Main_FACE_SN = NULL, Main_EYE_SN = NULL, Pro_Face_Serial = NULL, Pro_Eye_Serial = NULL, Pro_Body_Serial = NULL, Lux_Face_Serial = NULL, Lux_Eye_Serial = NULL, Lux_Body_Serial = NULL, MAXIMUM_SN = NULL, Alpha_Set_Serial = NULL, Alpha_Face_Serial = NULL, Alpha_Eye_Serial = NULL, Alpha_Body_Serial = NULL, Alto_Serial = NULL, Effect_Serial = NULL, note = '" & SaveData & "' WHERE PackingCode = '" & PackingNum & "'"

            If DBCommand(DBCMD) Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            MsgBox("오류 발생! :: " & ex.Message, vbCritical)
            Return False
        End Try
    End Function

    Private Function PackingSerialSearch(packingNum As String) As String
        Dim SerialValue As String = String.Empty

        DBCMD = "SELECT Main_Product_SN,Main_FACE_SN,Main_EYE_SN,Pro_Face_Serial,Pro_Eye_Serial,Pro_Body_Serial,Lux_Face_Serial,Lux_Eye_Serial,Lux_Body_Serial,MAXIMUM_SN,Alpha_Set_Serial,Alpha_Face_Serial,Alpha_Eye_Serial,Alpha_Body_Serial,Alto_Serial,Effect_Serial FROM " & sales_db & " WHERE PackingCode = '" & packingNum & "'"
        If DBQueryReader(DBCMD) Then
            For i = 0 To sqlDataQuery.Length - 1
                If SerialValue = String.Empty Then
                    SerialValue = sqlDataQuery(i)
                Else
                    SerialValue = SerialValue & "/" & sqlDataQuery(i)
                End If
            Next

            Return SerialValue
        Else
            Return "FAIL"
        End If
    End Function

    Private Function OrderCodeDelete(RowNum As Integer) As Boolean
        Try

            For i = 0 To dgvDataSearch.Rows.Count - 2
                If dgvDataSearch.Rows(i).Cells(0).Value = dgvDataSearch.Rows(RowNum).Cells(0).Value Then
                    Dim NoteSave As String = dgvDataSearch.Rows(i).Cells(12).Value & "/" & dgvDataSearch.Rows(i).Cells(13).Value & "/" & dgvDataSearch.Rows(i).Cells(14).Value & "/" & dgvDataSearch.Rows(i).Cells(15).Value

                    DBCMD = "UPDATE " & order_db & " SET Shipment_Date = NULL, Invoice_Number = NULL, Packing_Code = NULL, Serial_Number = NULL, Buy_Type = NULL, release_state = NULL, note = '" & NoteSave & "' WHERE Order_Code = '" & dgvDataSearch.Rows(i).Cells(0).Value & "' AND Item_Code = '" & dgvDataSearch.Rows(i).Cells(7).Value & "'"

                    If DBCommand(DBCMD) = False Then
                        Return False
                    End If

                End If
            Next

            Return True

        Catch ex As Exception
            MsgBox("오류 발생! :: " & ex.Message, vbCritical)
            Return False
        End Try
    End Function

    Private Sub btnpackDay_Click(sender As Object, e As EventArgs) Handles btnpackDay.Click
        Dim countNum As Int16
        dgvDataSearch.Rows.Clear()
        PackingColumns()
        Dim ColCount As Int16 = dgvDataSearch.ColumnCount
        Dim DataContent(ColCount) As String

        Dim startDate As String = lbStDate.Text                 '20241125 날짜 검색 추가
        Dim endDate As String = lbEnDate.Text                   '20241125 날짜 검색 추가

        If Not IsDate(startDate) OrElse Not IsDate(endDate) Then        '20241125 날짜 검색 추가
            MessageBox.Show("날짜를 다시 입력 해주세요")
            Return
        End If

        DBCMD = "SELECT PackingCode, Data, Main_Product_SN, Set_Cnt, Mask5Cnt, Mask10Cnt, HairBandCnt, GelCnt, MiniGelCnt, AmpleCnt, CreamCnt, UmbrellaCnt, FenCnt, ChargerCnt, CableCnt, TonerCnt, CaseCnt, Case_PRO_Black, Case_PRO_Beige, Case_PRO_Red, Case_PRO_Pink, Case_MAX_Black, Case_MAX_Apr, Case_MAX_Mint, Case_MAX_Beige, Case_MAX_Purple, Case_PRO_SnakeBlakc, Case_MAX_SafBK_Cnt, Case_MAX_SafPp_Cnt, Case_MAX_Yellow, DustBagCnt, SoothingGelCnt, Carton0_Cnt, Carton1_Cnt, Carton2_Cnt, Carton3_Cnt, Carton4_Cnt, Carton5_Cnt, Carton6_Cnt, Shopbag_Cnt, CosShopbag_Cnt, KollagenCnt, KollagenSetCnt, Kollagen_PCnt, KollagenSet_PCnt, CleansingWaterCnt, TonerPadCnt, Hologram_1Cnt, Hologram_3Cnt, Hologram_5Cnt, Kollagen_Pe1Cnt, Kollagen_Pe3Cnt, Kollagen_Pe5Cnt, ATCircleCaseCnt, APSquareCaseCnt, Case_MAX_Peach, MasSoothingCnt, Case_MAX_SMintCnt, MeshPouchCnt, FirmingAmpCnt, HyaluronicAmpCnt, nightshotcnt, morningshotcnt, casemaxwoodicnt, Elicolltonercnt, Elicollampcnt, Elicollcreamcnt,Elihyaltonercnt,Elihyalampcnt,Elihyalcreamcnt,Dayshotcnt,Beautyshopbagcnt,Gummycnt,Stickjellycnt,Newyearbagcnt,emsbeltcnt,beltbagcnt,Dayshot2cnt,EtcCnt,Pro_Face_Serial,Pro_CT_FaceCnt,Pro_Eye_Serial,Pro_CT_EYE_Cnt,Pro_Body_Serial,Pro_CT_BodyCnt,Lux_Face_Serial,Lux_CT_FaceCnt,Lux_Eye_Serial,Lux_CT_EYE_Cnt,Lux_Body_Serial,Lux_CT_BodyCnt,MAXIMUM_SN,MAXIMUM_Cnt,Alpha_Set_Serial,Alpha_Set_Cnt,Alpha_Face_Serial,Alpha_Face_Cnt,Alpha_Eye_Serial,Alpha_Eye_Cnt,Alpha_Body_Serial,Alpha_Body_Cnt,Alto_Serial,Alto_Cnt,Effect_Serial,Effect_cnt,Weight " &
           "FROM " & sales_db & " WHERE DATE_FORMAT(Data, '%Y-%m-%d') BETWEEN '" & startDate & "' AND '" & endDate & "'"                '20241125 날짜 검색 추가

        ' DBCMD = "SELECT PackingCode,`Data`,Main_Product_SN,Set_Cnt,Mask5Cnt,Mask10Cnt,HairBandCnt,GelCnt,MiniGelCnt,AmpleCnt,CreamCnt,UmbrellaCnt,FenCnt,ChargerCnt,CableCnt,TonerCnt,CaseCnt,Case_PRO_Black,Case_PRO_Beige,Case_PRO_Red,Case_PRO_Pink,Case_MAX_Black,Case_MAX_Apr,Case_MAX_Mint,Case_MAX_Beige,Case_MAX_Purple,Case_PRO_SnakeBlakc,Case_MAX_SafBK_Cnt,Case_MAX_SafPp_Cnt,Case_MAX_Yellow,DustBagCnt,SoothingGelCnt,Carton0_Cnt,Carton1_Cnt,Carton2_Cnt,Carton3_Cnt,Carton4_Cnt,Carton5_Cnt,Carton6_Cnt,Shopbag_Cnt,CosShopbag_Cnt,KollagenCnt,KollagenSetCnt,Kollagen_PCnt,KollagenSet_PCnt,CleansingWaterCnt,TonerPadCnt,Hologram_1Cnt,Hologram_3Cnt,Hologram_5Cnt,Kollagen_Pe1Cnt,Kollagen_Pe3Cnt,Kollagen_Pe5Cnt,ATCircleCaseCnt,APSquareCaseCnt,Case_MAX_Peach,MasSoothingCnt,Case_MAX_SMintCnt,MeshPouchCnt,FirmingAmpCnt,HyaluronicAmpCnt,nightshotcnt,morningshotcnt,casemaxwoodicnt,Elicolltonercnt,Elicollampcnt,Elicollcreamcnt,Elihyaltonercnt,Elihyalampcnt,Elihyalcreamcnt,,Dayshotcnt,Beautyshopbagcnt,Gummycnt,Stickjellycnt,Newyearbagcnt,emsbeltcnt,beltbagcnt,Dayshot2cnt,EtcCnt,Pro_Face_Serial,Pro_CT_FaceCnt,Pro_Eye_Serial,Pro_CT_EYE_Cnt,Pro_Body_Serial,Pro_CT_BodyCnt,Lux_Face_Serial,Lux_CT_FaceCnt,Lux_Eye_Serial,Lux_CT_EYE_Cnt,Lux_Body_Serial,Lux_CT_BodyCnt,MAXIMUM_SN,MAXIMUM_Cnt,Alpha_Set_Serial,Alpha_Set_Cnt,Alpha_Face_Serial,Alpha_Face_Cnt,Alpha_Eye_Serial,Alpha_Eye_Cnt,Alpha_Body_Serial,Alpha_Body_Cnt,Alto_Serial,Alto_Cnt,Weight FROM " & sales_db & " WHERE DATE_FORMAT(`Data`,'%Y-%m-%d') = '2024-04-22'"

        If DBQueryReader(DBCMD) Then
            For i = 0 To sqlDataQuery.Length - 1
                countNum = i Mod ColCount
                DataContent(countNum) = sqlDataQuery(i)

                If countNum = ColCount - 1 Then
                    dgvDataSearch.Rows.Add(DataContent)
                End If
            Next
        End If
    End Sub

    Private Sub lbPack_Click(sender As Object, e As EventArgs) Handles lbPack.Click

    End Sub
End Class
