Imports adbc.dbbase

Public Class AddEpole_jDung
    '//아래의 한글 변수들은 뷰설정창에서 설정이 가능한 필드다
    Dim 전줄값복사기본값 As String = _
    "A1,A2,A3,B1,B2,B3,지점명"
    Dim 한글필드기본값 As String = _
    "지점명"
    Dim 다음줄필드기본값 As String = "지점명"

    Dim ViewTag As String = "view_jdung"
    Dim WithEvents DT As ireaDataSet.Detail_DeungDataTable
    Dim Desc As String
    Dim Wt As Work_Type
    Dim Sorted As ESorted = ESorted.NULL
    Dim NewData As Boolean = False

#Region "NEW Function"
    Public Sub New(ByVal maxid As Integer, ByVal Wtype As Short, ByVal Desc1 As String)
        ' 이 호출은 Windows Form 디자이너에 필요합니다.
        InitializeComponent()
        Dim INI As New ACC.MyINI(My.Application.Info.DirectoryPath & "\epole.ini")
        Me.h_date.Enabled = True
        Me.h_name.Enabled = True
        Me.h_bigo.Enabled = True
        Me.h_id.Enabled = False
        Me.h_dan.Enabled = True
        Me.Text = Desc1 & " 입력(신규작업)"
        Me.h_name.Text = INI.Read("main", "lastkname1") 'InputBox("거래처명을 입력하세요", "신규입력-거래처명", "해광기획")
        Me.h_dan.Text = "0" 'InputBox("수량별 단가를 입력하세요", "신규입력-단가", "0")
        Me.h_id.Text = maxid
        Me.h_bigo.Text = Desc1 & " 제작(" & Format(Now, "MM") & "-" & Format(Now, "dd") & ")"
        Me.h_date.Text = Format(Now, "yyyy/MM/dd")
        Me.Desc = Desc1
        Wt = Wtype
        NewData = True
    End Sub
    Public Sub New(ByVal v_id As String, ByVal V_DATE As String, ByVal V_NAME As String, ByVal V_BIGO As String, ByVal V_DAN As String, ByVal Wtype As Short, ByVal Desc1 As String)
        ' 이 호출은 Windows Form 디자이너에 필요합니다.
        InitializeComponent()

        Me.h_date.Text = V_DATE
        Me.h_name.Text = V_NAME
        Me.h_bigo.Text = V_BIGO
        Me.h_dan.Text = V_DAN
        Me.h_id.Text = v_id
        Me.h_date.Enabled = False
        Me.h_name.Enabled = False
        Me.h_bigo.Enabled = False
        Me.h_id.Enabled = False
        Me.h_id.Enabled = False
        Me.Text = Desc1 & " 입력"
        Me.Desc = Desc1
        Wt = Wtype
        NewData = False
    End Sub
#End Region

#Region "자주사용하지않음"
    Private Sub NewRowAddToDataTable(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs)
        Dim NEwrow As DataRow = e.Row
        Dim Newid As Integer = CInt(Me.Get_NewNumber)
        NEwrow("rowid") = System.Guid.NewGuid
        NEwrow("관리ID") = CInt(Me.h_id.Text)
        NEwrow("번호") = Newid
        NEwrow("출력") = True
        NEwrow("정렬번호") = "1" & Format(Newid, "0000") & "1000"
    End Sub

    Private Sub AddEpole_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Me.CHk_Modify()
        MakeList.bt_find.PerformClick()
    End Sub
    Private Sub AddEpole_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.view1.ASetting_Load(False, ViewTag)

        Me.view1.AViewSetting_Load(전줄값복사기본값, 한글필드기본값, 다음줄필드기본값, ViewTag)
        Me.view1.ACheckBox_ColIndex = Me.view1.Column2("선택").Index
        Me.view1.ANextRow_ColIndex = Me.view1.Column2(Me.view1.다음줄필드명).Index
        Me.view1.Font = New Font(ViewFont.FontName, ViewFont.FontSize, Me.Font.Style)   '//글자정보 불러오기
        Me.bn.Font = New Font(MenuFont.FontName, MenuFont.FontSize, Me.Font.Style)   '//글자정보 불러오기
        Me.ToolStrip1.Font = New Font(MenuFont.FontName, MenuFont.FontSize, Me.Font.Style)   '//글자정보 불러오기
        Me.StatusStrip1.Font = New Font(MenuFont.FontName, MenuFont.FontSize, Me.Font.Style)   '//글자정보 불러오기
        DT = Me.ds.Detail_Deung : AddHandler DT.TableNewRow, AddressOf NewRowAddToDataTable
        Me.SETTOOLTIP()
        ''''''''데이터보여주기
        Display_Data()
    End Sub

    Private Sub SETTOOLTIP()
        Dim TMSG As New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("오른쪽 클릭시 기타메뉴가 표시됩니다")
        TMSG.AppendLine()
        TMSG.AppendLine("<단축키 : ENTER:다음칸 , SHIFT+TAB:이전칸>")
        TMSG.AppendLine("<단축키 : DELETE:현재칸 지우기 , SHIFT+DELETE 현재줄 삭제>")
        TMSG.AppendLine("<단축키 : F2:현재칸지우고 편집>")
        TMSG.AppendLine("<단축키 : SPACE-BAR/F3:현재칸 편집>")
        TMSG.AppendLine("<단축키 : CTRL + 마우스휠 : 화면크기를 조절합니다>")
        TMSG.AppendLine()
        Me.ToolTip1.SetToolTip(Me.view1, TMSG.ToString)

    End Sub
    Private Sub SetFarPoint()
        ' Me.view1.AEnterToNextItem()
        Me.view1.DataSource = Me.bs
    End Sub

    Private Function Get_NewNumber() As Integer
        Dim maxCnt As Integer = 0
        For i As Integer = 0 To Me.view1_Sheet1.RowCount - 1
            If Me.view1_Sheet1.Cells(i, 2).Value > maxCnt Then maxCnt = Me.view1_Sheet1.Cells(i, 2).Value
        Next
        Return maxCnt + 1
    End Function
    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Me.bt_commit.PerformClick() '//저장할게잇으면 다 저장한다.
        Dim A As New XLSImport(Me.ds, Me.h_id.Text, Wt)
        A.ShowDialog()
        Me.CHk_Modify(False)
        Me.Display_Data()
    End Sub
    Private Sub Check_Sorted()
        If Me.Sorted = ESorted.NULL Then  '//아직 검색이된건지 확인안해봣다
            Me.Sorted = ESorted.No
            For i As Short = 0 To IIf(Me.DT.Rows.Count > 10, 10, Me.DT.Rows.Count - 1)
                If NVL(DT.Rows(i)("정렬번호")) <> "" AndAlso NVL(DT.Rows(i)("정렬번호")) <> "히히히000000000" AndAlso NVL(DT.Rows(i)("정렬번호")) <> "히" Then '//데이터가있다면
                    Me.Sorted = ESorted.YES
                    Exit For
                End If
            Next
        End If
    End Sub
    Private Sub Make_Index()
        Work_Form("인덱스를 생성하고 있습니다")
        Form_Work.ProgressBar1.Minimum = 0
        Form_Work.ProgressBar1.Maximum = Me.DT.Rows.Count
        Dim Num As Short
        For i As Integer = 0 To Me.DT.Rows.Count - 1
            Form_Work.pval = i
            Num = Me.DT.Rows(i)("번호")
            Me.DT.Rows(i)("정렬번호") = "1" & Format(Num, "0000") & "1000"
        Next
        Form_Work.Close()  '//작업창 닫기
        Me.Sorted = ESorted.YES
    End Sub
    Private Sub bt_insertrow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_insertrow.Click
        ' Me.view1.AInsertNewRow()    '//번호문제도있다.
        '//현재줄 바로위에 한줄을삽입한다.
        '//새로운ID는 전줄의ID+1 이며
        Me.bs.EndEdit()

        '//위에서부터 5개또는 마지막까지 이게 정렬된데이터인지 확인합니다.
        If Me.Sorted = ESorted.NULL Then Check_Sorted()
        If Me.Sorted = ESorted.No Then Make_Index() '//인덱스를 생성한다.

        Dim NR As ireaDataSet.Detail_DeungRow = Me.DT.NewDetail_DeungRow   '//삽입은 현재줄 위에 삽입하는것이다. 현재줄의 인덱스번호가 숫자형태라면 정렬이안된데이터다
        Dim 정렬번호 As String = bs.Current("정렬번호")
        Dim N정렬번호 As String
        If IsNumeric(정렬번호) AndAlso 정렬번호.Length >= 8 Then  '//숫자라면 인덱스정렬법이다.
            Dim MN As String = 정렬번호.Substring(0, 5)
            Dim SN As Short = 정렬번호.Substring(5)
            'NR.번호 = bs.Current("번호") - 1 '//번호는 -1하고
            'If NR.번호 < 1 Then NR.번호 = 0
            N정렬번호 = MN & Format(SN - 1, "0000") '//현재 일련번호에 -을 해서 넣느다.  이부분 변경하자..변경한이름이 있을경우 해당위로의 숫자를 -1해야한다.

            '//새로우 정렬번호랑 같은것들은 -1해준다.
            For Each DR As DataRow In Me.DT.Select("정렬번호 like '" & MN & "%' and 정렬번호 <= '" & N정렬번호 & "'")
                MN = DR("정렬번호").Substring(0, 5)
                SN = DR("정렬번호").Substring(5)
                DR("정렬번호") = MN & Format(SN - 1, "0000")   '//원래번호-1해준다.
            Next
            '//
            NR.정렬번호 = N정렬번호
            Dim AR As Integer = Me.view1.ActiveSheet.ActiveRowIndex
            Me.DT.AddDetail_DeungRow(NR)
            Me.view1.ActiveSheet.ActiveRowIndex = AR
        Else   '//전주번호정렬법이다 이것은 정렬이 별도로 존재한다.
            MsgBox("번호형식으로 정렬되어있는 데이터입니다" & "이데이터는 [한줄삽입]이 되지않습니다.", MsgBoxStyle.Information, "확인")
            Me.bt_addrow.PerformClick()   '//한줄추가화럴ㅇ()
        End If
    End Sub
    Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_addrow.Click
        'Me.view1.AAddNewRow()
        Me.bs.AddNew()
    End Sub

    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_commit.Click
        '//언바운드된 열을 여기서 바운드시켜분다.
        'Me.view1.Attach_Ubound(3)
        Me.bs.EndEdit()

        If bs.Count > 0 Then
            Dim Drv As DataRowView
            Drv = bs.Item(bs.Count - 1)
            If NVL(Drv("고객번호1"), "") = "" AndAlso NVL(Drv("고객번호2"), "") = "" AndAlso NVL(Drv("고객번호3"), "") = "" AndAlso _
             NVL(Drv("관리번호1"), "") = "" AndAlso NVL(Drv("관리번호2"), "") = "" AndAlso NVL(Drv("관리번호3"), "") = "" Then
                Drv.Delete()
            End If
        End If

        If Not Me.ds.HasChanges Then
            NOTICE("변경된 데이터가 없습니다", Me.lb_msg)
            Return
        End If
        Me.bt_find.PerformClick()
    End Sub
    Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_cancel.Click
        Me.bs.EndEdit()
        If Me.ds.HasChanges Then
            Me.ds.RejectChanges()
            NOTICE("변경된 내용이 취소되었습니다.", Me.lb_msg)
        Else
            NOTICE("변경내역이 없습니다", Me.lb_msg)
        End If
    End Sub
    Private Sub olStripMenuItem1tripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles olStripMenuItem1.Click
        Me.view1.ASelect()
    End Sub

    Private Sub lStripMenuItem2ipMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lStripMenuItem2.Click
        Me.view1.AUnselect()
    End Sub

    Private Sub gfsdlStripMenuItem2MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gfsdlStripMenuItem2.Click
        Me.view1.AReverse()
    End Sub
    Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
        If Me.view1.ActiveSheet.Rows.Count > 0 Then
            Me.view1.ActiveSheet.ActiveRow.Remove()
            NOTICE("현재줄이 삭제되었습니다", Me.lb_msg)
        Else
            MsgBox("더이상 삭제할 줄이 없습니다")
        End If
    End Sub

    Private Sub view1_Arin_Before_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles view1.Arin_Before_KeyDown

        Select Case e.KeyCode
            Case Keys.F
                If e.Control Then Me.bt_findview.PerformClick()
            Case Keys.Insert '//삽입
                Me.bt_insertrow.PerformClick()

            Case Keys.Enter
                e.Handled = True
                e.SuppressKeyPress = False

                With Me.view1.ActiveSheet
                    '//전줄값 복사할게 있으면복사한다.
                    If Array.IndexOf(Me.view1.전줄값복사, .ActiveColumn.Label) >= 0 AndAlso .ActiveCell.Text = "" Then
                        .ActiveCell.Text = .Cells(IIf(.ActiveRowIndex > 0, .ActiveRowIndex - 1, 0), .ActiveColumnIndex).Text
                    End If

                    '//사용자가 직접 라벨명을 이용해서 전줄값을 복사하고자할떄 사용한다.
                    Select Case .ActiveColumn.Label

                    End Select
                End With
        End Select
    End Sub
    Private Sub view1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles view1.KeyDown

    End Sub

    Private Sub oolStripMenuItemipMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles oolStripMenuItem.Click
        Me.ToolStripButton2.PerformClick()
    End Sub

    Private Sub ToolStripButton5_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
        Me.Close()
    End Sub
    Private Sub BtsavecolsizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_colsize.Click
        Me.view1.ASetting_Save(False, Me.ViewTag)
    End Sub
    Private Sub bt_chkdel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_chkdel.Click
        For i As Integer = Me.view1.ActiveSheet.RowCount - 1 To 0 Step -1
            If Me.view1.ActiveSheet.Cells(i, Me.view1.ACheckBox_ColIndex).Value = True Then Me.view1.ActiveSheet.Rows(i).Remove()
        Next
    End Sub
    Private Sub out_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles out.Click
        If Check_auth() = False Then
            MsgBox("임시사용자는 내보내기를 할 수 없습니다", MsgBoxStyle.Information, "확인")
            Return
        End If
        Me.view1.Excel_Save(Me.Desc & "내보내기.xls")
    End Sub
    Private Sub servoolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_findview.Click
        Dim Frow, Fcol As Integer
        Me.view1.Search(Me.view1.ActiveSheetIndex, InputBox("선택된 열에서 검색할 문자를 입력하세요.", "검색문자를 입력하세요"), False, False, False, True, True, False, False, 0, 0, Frow, Fcol)
        If Frow >= 0 AndAlso Fcol >= 0 Then '//검색됫다면
            Me.view1.ActiveSheet.SetActiveCell(Frow, Fcol)
            SendKeys.Send("{ENTER}")
        End If
    End Sub
    Private Sub cm_RenewNum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cm_RenewNum.Click
        ReNum(Me.DT, "번호", Me.pbar)
    End Sub
    Private Sub vripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbt_vselall.Click
        For Each A As DataRow In Me.DT.Rows
            A("출력") = True
        Next
    End Sub
    Private Sub cbt_vusell_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbt_vusell.Click
        For Each A As DataRow In Me.DT.Rows
            A("출력") = False
        Next
    End Sub
    Private Sub cbt_vselrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbt_vselrev.Click
        For Each A As DataRow In Me.DT.Rows
            A("출력") = Not A("출력")
        Next
    End Sub

    Private Sub AddEpoleJJ_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Validated
        Me.view1.Focus()
        Me.view1.Focus()
    End Sub
    Private Sub bt_find_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_find.Click
        CHk_Modify()
        Display_Data()
    End Sub

    Private Sub mbt_viewSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mbt_viewSetup.Click
        Dim Frm As New Frm_ViewSetup(Me.view1.전줄값복사, Me.view1.한글필드, Me.view1.다음줄필드명, Me.view1.기본스타일인덱스)
        If Frm.ShowDialog = Windows.Forms.DialogResult.OK Then
            Me.view1.AViewSetting_Save(Frm.tb_nulltext.Text, Frm.tb_hangul.Text, Frm.tb_nextrow.Text, Frm.tb_defstyleidx.Text, Me.ViewTag)
            Me.view1.AViewSetting_Load(Me.전줄값복사기본값, Me.한글필드기본값, Me.다음줄필드기본값, Me.ViewTag)
            Me.view1.ACheckBox_ColIndex = Me.view1.Column2("선택").Index
            Me.view1.ANextRow_ColIndex = Me.view1.Column2(Me.view1.다음줄필드명).Index
            MsgBox("뷰설정이 저장되었습니다", MsgBoxStyle.Information, "확인")
        End If
    End Sub
#End Region

    Private Sub CHk_Modify(Optional ByVal prompt As Boolean = True)
        Me.bs.EndEdit()
        If bs.Count > 0 Then
            Dim Drv As DataRowView
            Drv = bs.Item(bs.Count - 1)
            If NVL(Drv("고객번호1"), "") = "" AndAlso NVL(Drv("고객번호2"), "") = "" AndAlso NVL(Drv("고객번호3"), "") = "" AndAlso _
             NVL(Drv("관리번호1"), "") = "" AndAlso NVL(Drv("관리번호2"), "") = "" AndAlso NVL(Drv("관리번호3"), "") = "" Then
                Drv.Delete()
            End If
        End If
        If Not Me.ds.HasChanges Then
            NOTICE("변경된 내용이 없습니다", Me.lb_msg)
            Return
        End If

        If prompt Then
            If MsgBox("변경된 데이터를 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "저장확인") <> MsgBoxResult.Ok Then Return
        End If

        Try
            Me.ta.Update(Me.ds.Detail_Deung)   '//Commit insert/update/delete
            Me.DT.AcceptChanges()    '//Set All Green

            Try
                Dim SQl As String = "insert into 전주관리(id,날짜,거래처명,비고,총수량,단가,금액,번호찰구분) values(:1,:2,:3,:4,:5,:6,:7,:8)"
                If Me.ta.Connection.State <> ConnectionState.Open Then Me.ta.Connection.Open()
                Dim Cmd As New OleDbCommand(SQl, Me.ta.Connection)
                Cmd.Parameters.Add(":1", OleDbType.Integer).Value = Val(Me.h_id.Text)
                Cmd.Parameters.Add(":2", OleDbType.Date).Value = IIf(Me.h_date.Text.Trim = "", DBNull.Value, Me.h_date.Text.Trim)
                Cmd.Parameters.Add(":3", OleDbType.VarChar).Value = Me.h_name.Text
                Cmd.Parameters.Add(":4", OleDbType.VarChar).Value = Me.h_bigo.Text
                Cmd.Parameters.Add(":5", OleDbType.Integer).Value = Me.DT.Rows.Count 'Me.view1_Sheet1.RowCount
                Cmd.Parameters.Add(":6", OleDbType.Integer).Value = Val(Me.h_dan.Text)
                Cmd.Parameters.Add(":7", OleDbType.Currency).Value = Val(Me.h_dan.Text) * Me.view1_Sheet1.RowCount
                Cmd.Parameters.Add(":8", OleDbType.Currency).Value = Wt
                Cmd.ExecuteNonQuery()
            Catch ex As Exception
                Dim SQl As String = "update 전주관리 set 날짜=:2,거래처명=:3,비고=:4,총수량=:5,단가=:6,금액=:7,번호찰구분=:8 where id=:1"
                If Me.ta.Connection.State <> ConnectionState.Open Then Me.ta.Connection.Open()
                Dim Cmd As New OleDbCommand(SQl, Me.ta.Connection)
                Cmd.Parameters.Add(":2", OleDbType.Date).Value = IIf(Me.h_date.Text.Trim = "", DBNull.Value, Me.h_date.Text.Trim)
                Cmd.Parameters.Add(":3", OleDbType.VarChar).Value = Me.h_name.Text
                Cmd.Parameters.Add(":4", OleDbType.VarChar).Value = Me.h_bigo.Text
                Cmd.Parameters.Add(":5", OleDbType.Integer).Value = Me.DT.Rows.Count
                Cmd.Parameters.Add(":6", OleDbType.Integer).Value = Val(Me.h_dan.Text)
                Cmd.Parameters.Add(":7", OleDbType.Currency).Value = Val(Me.h_dan.Text) * Me.view1_Sheet1.RowCount
                Cmd.Parameters.Add(":8", OleDbType.Currency).Value = Wt
                Cmd.Parameters.Add(":1", OleDbType.Integer).Value = Val(Me.h_id.Text)
                Cmd.ExecuteNonQuery()
            Finally
                'MakeList.bt_find.PerformClick()
                'Display_Data(True)
                Dim INI As New MyINI(My.Application.Info.DirectoryPath & "\epole.ini")
                INI.Write("main", "lastkname1", Me.h_name.Text)
                NOTICE("저장되었습니다", Me.lb_msg)
                My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
                'MakeList.Display_Data() '//이건 bt_find 에서 재호출된다.
            End Try

        Catch ex As Exception
            MsgBox("데이터베이스 업데이트중 오류가 발생했습니다" & vbCrLf & vbCrLf & ex.ToString, MsgBoxStyle.Critical, "ERROR-")
            Me.ds.Detail_tongsin.RejectChanges()
            NOTICE("저장 실패!", Me.lb_msg)
        Finally
            view1.ActiveSheet.GetDataView(True) '//화면을 갱신한다.
        End Try
    End Sub
    Private Sub Display_Data(Optional ByVal AutoSort As Boolean = False)   '//뷰에데이터를 표시한다.
        Me.bs.Sort = "정렬번호,번호"   '//정렬된것들은 정렬된채로 보여준다.
        If NewData Then
            ta.DeleteQuery(Me.h_id.Text)
            NewData = False
        End If
        Me.ta.Fill(Me.ds.Detail_Deung, Me.h_id.Text)   '//관리id를 통해서 데이터를 채운다.
        SetFarPoint()  '//여기서 파포인트를 바인딩 소스와 연결시킨다(바인딩 소스는 테이블에 연결되어있다)
        If Me.DT.Rows.Count <= 0 Then
            NOTICE("데이터가 존재하지 않습니다", Color.Red, Me.lb_msg)
            Me.bt_addrow.PerformClick()  '//1개줄 자동증가
            Return
        End If
        NOTICE(Me.view1.ActiveSheet.RowCount & "개의 데이터가 검색되었습니다", Me.lb_msg)
    End Sub
    Private Sub ToolStripButton2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
        Me.bs.EndEdit()
        If Me.view1.Cells("출력").Value = False Then
            MsgBox("현재 선택된 줄은 출력이 되지않도록 설정되어있습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If
        'If UserInfo.Type = E_AuthType.Demo Then
        '    MsgBox("현재 권한은 임시사용자입니다" & vbCrLf & "이 메세지는 임시사용자만 출력됩니다", MsgBoxStyle.Information, "확인")
        'End If
        Dim Aa As New Cls_Jdung.PrintForm(Me.DT, IIf(Admin, True, False), Me.view1.기본스타일인덱스, CType(Me.bs.Current, DataRowView))
        Aa.Show()

    End Sub
    Private Sub bt_dchk3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_DUPCHK1.Click
        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        If Check_auth() = False Then
            MsgBox("임시사용자는 사용할 수 없습니다", MsgBoxStyle.Information, "확인")
            Return
        End If

        Dim 원본() As Short = New Short() {3, 4, 5} ', 대상 As String 'New System.Text.StringBuilder
        Dim fcnt As ArrayList

        Me.pbar.Value = 0
        Me.pbar.Minimum = 0
        Me.pbar.Maximum = Me.view1.ActiveSheet.RowCount

        NOTICE("중복되는 데이터를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.view1.ADupCheck(0, Me.view1.ActiveSheet.RowCount - 1, 원본, 원본, Me.view1.ColIndex2("선택"))
        NOTICE("중복검사 완료(" & fcnt.Count & "개의 데이터를 찾았습니다)", Me.lb_msg)
    End Sub

    Private Sub BT_DUPCHK2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_DUPCHK2.Click
        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        If Check_auth() = False Then
            MsgBox("임시사용자는 사용할 수 없습니다", MsgBoxStyle.Information, "확인")
            Return
        End If

        Dim 원본() As Short = New Short() {6, 7, 8} ', 대상 As String 'New System.Text.StringBuilder
        Dim fcnt As ArrayList

        Me.pbar.Value = 0
        Me.pbar.Minimum = 0
        Me.pbar.Maximum = Me.view1.ActiveSheet.RowCount

        NOTICE("중복되는 데이터를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.view1.ADupCheck(0, Me.view1.ActiveSheet.RowCount - 1, 원본, 원본, Me.view1.ColIndex2("선택"))
        NOTICE("중복검사 완료(" & fcnt.Count & "개의 데이터를 찾았습니다)", Me.lb_msg)
    End Sub

    Private Sub BT_DUPCHK3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_DUPCHK3.Click
        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        If Check_auth() = False Then
            MsgBox("임시사용자는 사용할 수 없습니다", MsgBoxStyle.Information, "확인")
            Return
        End If

        Dim 원본() As Short = New Short() {3, 4, 5, 6, 7, 8} ', 대상 As String 'New System.Text.StringBuilder
        Dim fcnt As ArrayList

        Me.pbar.Value = 0
        Me.pbar.Minimum = 0
        Me.pbar.Maximum = Me.view1.ActiveSheet.RowCount

        NOTICE("중복되는 데이터를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.view1.ADupCheck(0, Me.view1.ActiveSheet.RowCount - 1, 원본, 원본, Me.view1.ColIndex2("선택"))
        NOTICE("중복검사 완료(" & fcnt.Count & "개의 데이터를 찾았습니다)", Me.lb_msg)
    End Sub

    Private Sub ToolStripButton3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
        Me.out.PerformClick()
    End Sub


    Private Sub ToolStripMenuItem23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem23.Click
        If MsgBox("모든 정렬키를 삭제하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return
        Work_Form("모든 정렬키를 삭제합니다.")
        Form_Work.ProgressBar1.Minimum = 0
        Form_Work.ProgressBar1.Maximum = Me.DT.Rows.Count
        'Dim Num As Short
        For i As Integer = 0 To Me.DT.Rows.Count - 1
            Form_Work.pval = i
            'Num = Me.DT.Rows(i)("번호")
            Me.DT.Rows(i)("정렬번호") = ""
        Next
        Me.Sorted = ESorted.No
        Form_Work.Close()  '//작업창 닫기
    End Sub

    Private Sub ToolStripMenuItem24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem24.Click
        '//없는 데이터만 재생성
        If MsgBox("비어있는 정렬키만생성하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return
        Work_Form("비어있는 정렬키를 생성합니다.")
        Form_Work.ProgressBar1.Minimum = 0
        Form_Work.ProgressBar1.Maximum = Me.DT.Rows.Count
        Dim Num As Short
        For i As Integer = 0 To Me.DT.Rows.Count - 1
            Form_Work.pval = i
            If NVL(DT.Rows(i)("정렬번호"), "") = "" Then
                Num = Me.DT.Rows(i)("번호")
                Me.DT.Rows(i)("정렬번호") = "1" & Format(Num, "0000") & "1000"
            End If
        Next
        Me.Sorted = ESorted.YES
        Form_Work.Close()  '//작업창 닫기
    End Sub

    Private Sub ToolStripMenuItem25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem25.Click
        If MsgBox("모든 정렬키를 삭제하고 다시 생성하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return
        '//없는 데이터만 재생성
        Work_Form("모든 정렬키를 생성합니다.")
        Form_Work.ProgressBar1.Minimum = 0
        Form_Work.ProgressBar1.Maximum = Me.DT.Rows.Count
        Dim Num As Short
        For i As Integer = 0 To Me.DT.Rows.Count - 1
            Form_Work.pval = i
            Num = Me.DT.Rows(i)("번호")
            Me.DT.Rows(i)("정렬번호") = "1" & Format(Num, "0000") & "1000"
        Next
        Me.Sorted = ESorted.YES
        Form_Work.Close()  '//작업창 닫기
    End Sub
End Class