'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''' 2007-10-01 : 소스개발자 : 아린(tindevil.nate.com)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Class AddEpole
    '  Dim NeedIndexSort As Boolean = False
    Dim WithEvents DT As ireaDataSet.jjutableDataTable
    Dim Sorted As ESorted = ESorted.NULL
    'Dim viewTag As String = "jjun"
    Dim IsNew As Boolean = False

    Private Sub NewRowAddToDataTable(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) Handles DT.TableNewRow '//New Row Add & Setting Default Data
        Dim NewId As Integer = CInt(Me.Get_NewNumber)
        Dim NEwrow As DataRow = e.Row
        NEwrow("rowid") = System.Guid.NewGuid
        NEwrow("관리ID") = CInt(Me.h_id.Text)
        NEwrow("번호") = NewId
        NEwrow("출력") = True
        '  NEwrow("정렬번호") = "test"

        If Me.Sorted = ESorted.CANT Then
            NEwrow("정렬번호") = "히" & "1" & NewId.ToString("00000") & "1000"
        Else
            NEwrow("정렬번호") = "1" & NewId.ToString("00000") & "1000"
        End If
    End Sub

    'Dim SaveFlag As Boolean = False        
    Public Sub New(ByVal maxid As Integer)    ' QR추가

        ' 이 호출은 Windows Form 디자이너에 필요합니다.
        InitializeComponent()

        Dim INI As New MyINI2(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.h_si.Enabled = True
        'Me.h_hom.Enabled = True
        'Me.h_kwan.Enabled = True
        'Me.h_kwan1.Enabled = True
        'Me.h_kwan2.Enabled = True
        Me.Text = "가공(일반) 입력(신규작업)"
        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 = "가공(일반)번호찰제작(" & Format(Now, "MM") & "-" & Format(Now, "dd") & ")"
        Me.h_date.Text = Format(Now, "yyyy/MM/dd")
        Me.IsNew = 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 V_si As String, ByVal V_hom As String, ByVal V_kwan As String, ByVal V_kwan1 As String, ByVal V_kwan2 As String)

        ' 이 호출은 Windows Form 디자이너에 필요합니다.    'QR추가
        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_si.Text = V_si
        'Me.h_hom.Text = V_hom
        'Me.h_kwan.Text = V_kwan
        'Me.h_kwan1.Text = V_kwan1
        'Me.h_kwan2.Text = V_kwan2
        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 = "가공(일반) 입력"
        IsNew = False
    End Sub

    Private Sub AddEpole_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        bs.EndEdit()
        If bs.Count > 0 Then
            Dim Drv As DataRowView
            Drv = bs.Item(bs.Count - 1)
            If NVL(Drv("관리구"), "") = "" AndAlso NVL(Drv("전주번호"), "") = "" AndAlso NVL(Drv("선로명"), "") = "" AndAlso _
             NVL(Drv("번호1"), "") = "" AndAlso NVL(Drv("번호2"), "") = "" AndAlso NVL(Drv("번호3"), "") = "" AndAlso NVL(Drv("번호4"), "") = "" Then
                Drv.Delete()
            End If
        End If

        Me.CHk_Modify()

        '//펑션키값 넣기
        Dim INI As New MyINI2(My.Application.Info.DirectoryPath & "\" & Me.Name & "_static.ini")
        INI.Write("key", "f1", tbf1.Text)
        INI.Write("key", "f2", tbf2.Text)
        INI.Write("key", "f3", tbf3.Text)
        INI.Write("key", "f4", tbf4.Text)
        INI.Write("key", "f5", tbf5.Text)
        INI.Write("key", "f6", tbf6.Text)
        INI.Write("key", "f7", tbf7.Text)
        INI.Write("key", "f8", tbf8.Text)

        Frm_Main.bt_find.PerformClick()    '//빠져나가면서 목록의 검색버튼을 누르게한다.(저장된 내용이 바로보이게 한다)
        'If Me.SaveFlag Then Me.DialogResult = Windows.Forms.DialogResult.OK '//saveflag 가 셋트되어잇으면 결과를 ok라 한다.
    End Sub

    Private Sub AddEpole_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.F1 Then
            If e.Control AndAlso e.Shift Then
                If MsgBox("열너비를 초기화하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
                    fp.ColSize_Init()
                End If
            End If
        End If
    End Sub

    Private Sub AddEpole_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.fp.ASetting_Load(False)
        Me.fp.한글필드 = New String() {"선로명A", "선로명B", "시공자", "감독자", "비고", "점검일자"}

        Me.bt_dupchk2.Visible = IsPro

        'Me.view1.AEnterToNextItem(False)
        'Me.JjutableTableAdapter1.Connection.ConnectionString = ConString

        Me.fp.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)   '//글자정보 불러오기
        Me.SETTOOLTIP()

        '//펑션키값 넣기
        Dim INI As New MyINI2(My.Application.Info.DirectoryPath & "\" & Me.Name & "_static.ini")
        tbf1.Text = INI.Read("key", "f1")
        tbf2.Text = INI.Read("key", "f2")
        tbf3.Text = INI.Read("key", "f3")
        tbf4.Text = INI.Read("key", "f4")
        tbf5.Text = INI.Read("key", "f5")
        tbf6.Text = INI.Read("key", "f6")
        tbf7.Text = INI.Read("key", "f7")
        tbf8.Text = INI.Read("key", "f8")


        DT = Me.IreaDataSet1.jjutable

        Me.Show()
        Me.fp.ACheckBox_ColIndex = Me.fp.ActiveSheet.Columns("선택").Index
        'MsgBox(Me.view1.ACheckBox_ColIndex)
        'Me.Refresh() Me.ta.Fill(Me.IreaDataSet1.jjutable, Me.h_id.Text)   '//관리id를 통해서 데이터를 채운다.
        If Me.IsNew Then  '//현재id와같은 데이터는 모두삭제를 하게한다.
            Dim Cmd As New OleDbCommand("delete from  전주세부  where 관리id=" & Me.h_id.Text, Me.ta.Connection)
            If Cmd.Connection.State <> ConnectionState.Open Then Cmd.Connection.Open()
            Cmd.ExecuteNonQuery()
            Me.IsNew = False
        End If
        Display_Data() ''''''''데이터보여주기

        'If Me.view1.ActiveSheet.RowCount <= 0 Then
        '    If MsgBox("데이터가 존재하지않습니다" & vbCrLf & "엑셀파일로부터 데이터를 가져옵니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "파일가져오기") = MsgBoxResult.Ok Then
        '        Me.bt_import.PerformClick()
        '    Else
        '        Me.bt_insertrow.PerformClick()
        '    End If
        'End If
    End Sub
    Private Sub SETTOOLTIP()
        Dim TMSG As New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("오른쪽 클릭시 기타메뉴가 표시됩니다")
        TMSG.AppendLine()
        TMSG.AppendLine("<단축키 : ENTER:다음칸 , SHIFT+TAB:이전칸 , ALT+ENTER:윗칸복사>")
        TMSG.AppendLine("<단축키 : DELETE:현재칸 지우기 , SHIFT+DELETE 현재줄 삭제>")
        TMSG.AppendLine("<단축키 : F2:현재칸지우고 편집>")
        TMSG.AppendLine("<단축키 : SPACE-BAR/F3:현재칸 편집>")
        TMSG.AppendLine("<단축키 : CTRL + 마우스휠 : 화면크기를 조절합니다>")
        TMSG.AppendLine()
        Me.ToolTip1.SetToolTip(Me.fp, TMSG.ToString)

        'TMSG = New System.Text.StringBuilder()
        'TMSG.AppendLine()
        'TMSG.AppendLine("검색문자의 우선순위 : 숫자->영문자->한글")
        'TMSG.AppendLine("    ->0  은 000 보다 우선순위가 높습니다.")
        'Me.bt_findmenu.ToolTipText = "데이터베이스의 내용을 다시 불러옵니다" & vbCrLf & "번호정렬은 우측의 ▼ 를 클릭하세요"

    End Sub

    Private Sub SetFarPoint()
        'Me.view1.AEnterToNextItem(False)   '//에디트모드에서는 enter 를 사용하지 않게한다.
        Me.fp.DataSource = Me.bs

        'Dim A As FarPoint.Win.Spread.CellType.TextCellType = Me.view1.ActiveSheet.Columns(2).CellType
        'A.CharacterCasing = CharacterCasing.Upper
        'Me.view1.ActiveSheet.Columns(2).CellType = A
        'Me.view1.ActiveSheet.Columns(3).CellType = A
        'Me.view1.ActiveSheet.Columns(4).CellType = A
        'Me.view1.ActiveSheet.Columns(5).CellType = A
        'Me.view1.ActiveSheet.Columns(6).CellType = A
        'Me.view1.ActiveSheet.Columns(7).CellType = A
        'Me.view1.ActiveSheet.Columns(8).CellType = A
        'Me.view1.ActiveSheet.Columns(9).CellType = A
        'Me.view1.ActiveSheet.Columns(10).CellType = A
        'Me.view1.ActiveSheet.Columns(11).CellType = A
        'Me.view1.ActiveSheet.Columns(12).CellType = A
        ''A.CharacterSet = FarPoint.Win.Spread.CellType.CharacterSet.Numeric
        'A = Me.view1.ActiveSheet.Columns(13).CellType
        'A.CharacterSet = FarPoint.Win.Spread.CellType.CharacterSet.Numeric

        'Me.view1.ActiveSheet.Columns(23).DataField = "정렬번호"
        ''  Me.view1.ActiveSheet.Columns(22).DataField = "선택"


    End Sub

    ''' <summary>
    ''' 신규추가시 번호를 생성해줍니다(현존최대넘버+1)
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function Get_NewNumber() As Integer
        Dim maxCnt As Integer = 0
        For i As Integer = 0 To Me.fp_Sheet1.RowCount - 1
            If Me.fp_Sheet1.Cells(i, 1).Value > maxCnt Then maxCnt = Me.fp_Sheet1.Cells(i, 1).Value
        Next
        Return maxCnt + 1
    End Function

    Private Sub CHk_Modify(Optional ByVal prompt As Boolean = True)
        Me.bs.EndEdit()
        If Not Me.IreaDataSet1.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.IreaDataSet1.jjutable)   '//Commit insert/update/delete     '''QR코드
            Me.IreaDataSet1.jjutable.AcceptChanges()    '//Set All Green

            Try
                'Dim SQl As String = "insert into 전주관리(id,날짜,거래처명,비고,총수량,단가,금액,번호찰구분,시공자,홈페이지,관리,관리1,관리2) values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,0)"
                Dim SQl As String = "insert into 전주관리(id,날짜,거래처명,비고,총수량,단가,금액,번호찰구분) values(:1,:2,:3,:4,:5,:6,:7,0)"
                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.IreaDataSet1.jjutable.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.fp_Sheet1.RowCount
                'Cmd.Parameters.Add(":8", OleDbType.VarChar).Value = Me.h_si.Text
                'Cmd.Parameters.Add(":9", OleDbType.VarChar).Value = Me.h_hom.Text
                'Cmd.Parameters.Add(":10", OleDbType.VarChar).Value = Me.h_kwan.Text
                'Cmd.Parameters.Add(":11", OleDbType.VarChar).Value = Me.h_kwan1.Text
                'Cmd.Parameters.Add(":12", OleDbType.VarChar).Value = Me.h_kwan2.Text
                Cmd.ExecuteNonQuery()
            Catch ex As Exception

                '         Dim SQl As String = "update 전주관리 set 날짜=:2,거래처명=:3,비고=:4,총수량=:5,단가=:6,금액=:7,시공자=:8,홈페이지=:9,관리=:10,관리1=:11,관리2=:12,번호찰구분=0 where id=:1"
                Dim SQl As String = "update 전주관리 set 날짜=:2,거래처명=:3,비고=:4,총수량=:5,단가=:6,금액=:7,번호찰구분=0 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.IreaDataSet1.jjutable.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.fp_Sheet1.RowCount
                '          Cmd.Parameters.Add(":8", OleDbType.VarChar).Value = Me.h_si.Text
                '         Cmd.Parameters.Add(":9", OleDbType.VarChar).Value = Me.h_hom.Text
                '        Cmd.Parameters.Add(":10", OleDbType.VarChar).Value = Me.h_kwan.Text
                '       Cmd.Parameters.Add(":11", OleDbType.VarChar).Value = Me.h_kwan1.Text
                '      Cmd.Parameters.Add(":12", OleDbType.VarChar).Value = Me.h_kwan2.Text
                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 MyINI2(My.Application.Info.DirectoryPath & "\epole.ini")
                INI.Write("main", "lastkname1", Me.h_name.Text)
                NOTICE("저장되었습니다", Me.lb_msg)
                My.Computer.Audio.Play(My.Application.Info.DirectoryPath & "\sound\notify.wav", AudioPlayMode.Background)
                'MakeList.Display_Data() '//이건 bt_find 에서 재호출된다.
            End Try

        Catch ex As Exception
            MsgBox("데이터베이스 업데이트중 오류가 발생했습니다" & vbCrLf & vbCrLf & ex.ToString, MsgBoxStyle.Critical, "ERROR-")
            Me.IreaDataSet1.jjutable.RejectChanges()
            NOTICE("저장 실패!", Color.Red, Me.lb_msg)
        Finally
            fp.ActiveSheet.GetDataView(True) '//화면을 갱신한다.
        End Try

        'Me.SaveFlag = True
        Me.bs.EndEdit()

    End Sub


    Private Sub Display_Data(Optional ByVal AutoSort As Boolean = False)   '//뷰에데이터를 표시한다.

        Me.bs.Sort = "정렬번호,번호"   '//정렬된것들은 정렬된채로 보여준다.
        Me.ta.Fill(Me.IreaDataSet1.jjutable, Me.h_id.Text)   '//관리id를 통해서 데이터를 채운다.
        SetFarPoint()  '//여기서 파포인트를 바인딩 소스와 연결시킨다(바인딩 소스는 테이블에 연결되어있다)
        If Me.IreaDataSet1.jjutable.Rows.Count <= 0 Then
            Me.bt_addrow.PerformClick()
            NOTICE("데이터가 존재하지 않습니다", Color.Red, Me.lb_msg)
            Return
        End If

        NOTICE(Me.fp.ActiveSheet.RowCount & "개의 데이터가 검색되었습니다", Me.lb_msg)
    End Sub


    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_import.Click   '//엑셀불러오기
        Me.bt_commit.PerformClick() '//저장할게잇으면 다 저장한다.
        Me.fp.SuspendLayout()
        Dim A As New XLSImport(Me.IreaDataSet1, Me.h_id.Text, 0)
        A.ShowDialog()
        Me.CHk_Modify(False)
        Me.Display_Data(False)
        Me.fp.ResumeLayout()
    End Sub


    Private Sub dupcheckoldnumoolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Dim fcnt As Integer = 0
        Dim A() As Short = New Short() {Me.fp.ActiveSheet.Columns("구관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("구전산화번호").Index}
        NOTICE("중복되는 [구 전산화번호가 같은 경우]를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.fp.ADupCheck2(0, Me.fp.ActiveSheet.RowCount - 1, A, A, Me.fp.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[구 전산화번호가 같은 경우] 중복검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)

    End Sub

    Private Sub check2ipMenuItemem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles check2ipMenuItem.Click
        Dim fcnt As Integer = 0
        Dim A() As Short = New Short() {Me.fp.ActiveSheet.Columns("구선로명").Index, _
                                               Me.fp.ActiveSheet.Columns("구전주번호").Index}


        NOTICE("중복되는 [구 선로명, 전주번호가 같은 경우]를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.fp.ADupCheck2(0, Me.fp.ActiveSheet.RowCount - 1, A, A, Me.fp.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[구 선로명, 전주번호가 같은 경우] 중복검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)
    End Sub

    Private Sub dupchksunloolStripMenuItemuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dupchksunloolStripMenuItem.Click
        Dim fcnt As Integer = 0
        Dim A() As Short = New Short() {Me.fp.ActiveSheet.Columns("선로명").Index, _
                                               Me.fp.ActiveSheet.Columns("번호1").Index, _
                                               Me.fp.ActiveSheet.Columns("번호2").Index, _
                                               Me.fp.ActiveSheet.Columns("번호3").Index, _
                                               Me.fp.ActiveSheet.Columns("번호4").Index, _
                                               Me.fp.ActiveSheet.Columns("번호5").Index}

        NOTICE("중복되는 [신 선로명,전주번호가 같은 경우]를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.fp.ADupCheck2(0, Me.fp.ActiveSheet.RowCount - 1, A, A, Me.fp.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[신 선로명,전주번호가 같은 경우] 중복검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)

    End Sub


    Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_addrow.Click '//한줄추가
        If Me.Sorted = ESorted.NULL Then Check_Sorted()

        bs.AddNew()
        fp.ActiveSheet.SetActiveCell(fp.ActiveSheet.RowCount, fp.AFirstColumn_Index) '//첫위치로 변경한다.

        'Me.view1.AAddNewRow()
        'SendKeys.Send("{ENTER}")
        'Me.view1.ActiveSheet.Rows.Add(Me.view1.ActiveSheet.RowCount, 1)
        ' Me.view1.ActiveSheet.SetActiveCell(Me.view1.ActiveSheet.RowCount, 1)

        'Dim NewRowIndex As Integer = Me.view1.NewRowsU() '//언바운드 열 하나 추가

        ''MsgBox(NewRowIndex)

        'With Me.view1.ActiveSheet
        '    .Cells(NewRowIndex, 0).Value = CInt(Me.h_id.Text)
        '    .Cells(NewRowIndex, 1).Value = CInt(Me.Get_NewNumber)
        '    '.Cells(NewRowIndex, 23).Value = "히히히" & Format(NewRowIndex, "000000")
        '    .ActiveRowIndex = NewRowIndex
        '    .SetActiveCell(NewRowIndex, Me.view1.FIRST_FOCUSINDEX)
        '    SendKeys.Send("{ENTER}")
        '    'Me.view1.ActiveSheet.AddRowToDataSource(NewRowIndex, True)
        'End With

    End Sub

    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_commit.Click
        'Me.view1.Attach_Ubound(2)  '//언바운드된 열을 여기서 바운드시켜분다.
        Me.bs.EndEdit()  '//편집중인 데이터는 모두 마킹

        If bs.Count > 0 Then
            Dim Drv As DataRowView
            Drv = bs.Item(bs.Count - 1)
            If NVL(Drv("관리구"), "") = "" AndAlso NVL(Drv("전주번호"), "") = "" AndAlso NVL(Drv("선로명"), "") = "" AndAlso _
             NVL(Drv("번호1"), "") = "" AndAlso NVL(Drv("번호2"), "") = "" AndAlso NVL(Drv("번호3"), "") = "" AndAlso NVL(Drv("번호4"), "") = "" Then
                Drv.Delete()
            End If
        End If


        If Not Me.IreaDataSet1.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.view1.Attach_Ubound(2)
        Me.bs.EndEdit()

        If Me.IreaDataSet1.HasChanges Then
            Me.IreaDataSet1.RejectChanges()
            NOTICE("변경된 내용이 취소되었습니다.", Me.lb_msg)
        Else
            NOTICE("변경내역이 없습니다", Me.lb_msg)
        End If
    End Sub


    Private Sub grsdfipMMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grsdfipMenuItem.Click
        For Each dr As DataRow In Me.IreaDataSet1.jjutable.Rows
            dr("인입") = True
        Next
        'Me.view1.ItemCheck_Select(22)
    End Sub

    Private Sub olStripMenipMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gsfoolStripMenuItem.Click
        For Each dr As DataRow In Me.IreaDataSet1.jjutable.Rows
            dr("인입") = False
        Next
        'Me.view1.ItemCheck_Unselect(22)

    End Sub

    Private Sub gdflStripMeipMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gdflStripMenuItem.Click
        For Each dr As DataRow In Me.IreaDataSet1.jjutable.Rows
            dr("인입") = Not NVL(dr("인입"), False)
        Next
        'Me.view1.ItemCheck_Reverse(22)
    End Sub

    Private Sub dStripMenutripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gfsdStripMenuItem.Click
        For Each dr As DataRow In Me.IreaDataSet1.jjutable.Rows
            dr("기입") = True
        Next
        'Me.view1.ItemCheck_Select(23)

    End Sub

    Private Sub lStripMenuItipMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fdlStripMenuItem1.Click
        For Each dr As DataRow In Me.IreaDataSet1.jjutable.Rows
            dr("기입") = False
        Next
    End Sub

    Private Sub ttripMenuItipMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gttripMenuItem1.Click
        For Each dr As DataRow In Me.IreaDataSet1.jjutable.Rows
            dr("기입") = Not NVL(dr("기입"), False)
        Next
    End Sub

    Private Sub view1_Arin_AddLog(ByVal sender As Object, ByVal msg As String) Handles fp.Arin_AddLog
        If Admin Then Log.Show()
        If Admin Then Log.RichTextBox1.AppendText(msg & vbCrLf)
    End Sub

    Private Sub view1_EditModeOff(ByVal sender As Object, ByVal e As System.EventArgs) Handles fp.EditModeOff   '//편집종료시

    End Sub

    Private Sub sdStripMenuItemMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gfsdStripMenuItem1.Click
        Me.fp.ASelect(Me.fp.ACheckBox_ColIndex)
    End Sub

    Private Sub folStripMenuItuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gsdfolStripMenuItem2.Click
        Me.fp.AUnselect(Me.fp.ACheckBox_ColIndex)
    End Sub

    Private Sub gwsolStripMenuIteStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gwsolStripMenuItem2.Click
        Me.fp.AReverse(Me.fp.ACheckBox_ColIndex)
    End Sub

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

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

        If (e.KeyCode = Keys.F10) Then
            e.Handled = True
            e.SuppressKeyPress = True
        End If

        view1_Arin_AddLog(sender, "원래뷰에서의 keydown 열번호=" & Me.fp.ActiveSheet.ActiveColumnIndex)
    End Sub


    Private Sub view1_DragFillBlockCompleted(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.DragFillBlockCompletedEventArgs) Handles fp.DragFillBlockCompleted

        For i As Integer = e.RowBegin To e.RowBegin + e.NumberToCopy
            ' Dim ds As DataSet = FpSpread1.Sheets(0).DataSource
            Me.IreaDataSet1.jjutable.Rows(fp.Sheets(0).GetModelRowFromViewRow(i)).EndEdit()
        Next

    End Sub

    Private Sub view1_Change(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.ChangeEventArgs) Handles fp.Change
        '//선택에 체크된것을 색상을 바꿔준다.

        If e.Column = Me.fp.ACheckBox_ColIndex AndAlso Me.fp.ActiveSheet.Cells(e.Row, Me.fp.ACheckBox_ColIndex).Value = True Then   '//선택
            Me.fp.ActiveSheet.Rows(e.Row).BackColor = Color.LightGreen
        Else
            Me.fp.ActiveSheet.Rows(e.Row).BackColor = Color.White
        End If
    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, "00000") & "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.jjutableRow = Me.DT.NewjjutableRow   '//삽입은 현재줄 위에 삽입하는것이다. 현재줄의 인덱스번호가 숫자형태라면 정렬이안된데이터다
        Dim 정렬번호 As String = bs.Current("정렬번호")
        Dim N정렬번호 As String
        If Not Me.Sorted = ESorted.CANT AndAlso IsNumeric(정렬번호) AndAlso 정렬번호.Length >= 8 Then  '//숫자라면 인덱스정렬법이다.
            Dim MN As String = 정렬번호.Substring(0, 6)
            Dim SN As Short = 정렬번호.Substring(6)
            '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, 6)
                SN = DR("정렬번호").Substring(6)
                DR("정렬번호") = MN & Format(SN - 1, "0000")   '//원래번호-1해준다.
            Next
            '//
            NR.정렬번호 = N정렬번호

            Dim AR As Integer = Me.fp.ActiveSheet.ActiveRowIndex
            Me.DT.AddjjutableRow(NR)
            Me.fp.ActiveSheet.ActiveRowIndex = AR

        Else   '//전주번호정렬법이다 이것은 정렬이 별도로 존재한다.
            MsgBox("번호형식으로 정렬되어있는 데이터입니다" & vbCrLf & "이데이터는 [한줄삽입]이 되지않습니다.", MsgBoxStyle.Information, "확인")
            Me.Sorted = ESorted.CANT
            'Me.bt_addrow.PerformClick()   '//한줄추가화럴ㅇ()
        End If
    End Sub

    Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.Text = Me.fp.ActiveSheet.ActiveRowIndex & "/" & Me.fp.ActiveSheet.ActiveColumnIndex
    End Sub



    Private Sub view1_EnterCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EnterCellEventArgs) Handles fp.EnterCell
        Select Case Me.fp.ActiveSheet.ActiveColumn.Label.ToUpper

            Case "D/L명"

                NOTICE("2줄일경우에는  좌,나선;우,나선  형태로 입력하세요", Color.Blue, Me.lb_msg)
        End Select
    End Sub



    Private Sub ToolStripButton3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
        Process.Start(HomePage)
    End Sub


    Private Sub gfsdolStripMenuItempMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gfsdolStripMenuItem.Click
        For i As Integer = Me.fp.ActiveSheet.RowCount - 1 To 0 Step -1
            If Me.fp.ActiveSheet.Cells(i, Me.fp.ACheckBox_ColIndex).Value = True Then Me.fp.ActiveSheet.Rows(i).Remove()
        Next

        'For Each Dr As ireaDataSet.jjutableRow In Me.IreaDataSet1.jjutable.Rows
        ' If Dr.선택 Then Dr.Delete()
        ' Next

        'For Each A As FarPoint.Win.Spread.Row In Me.view1.ActiveSheet.Rows
        ' With Me.view1.ActiveSheet
        ' If .Cells(A.Index, 22).Value = True Then    '//선택되어잇으면 해당 줄을 삭제한다
        ' .Rows(A.Index).Remove()
        ' End If
        ' End With
        ' Next
    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 bt_save_all_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_save_all.Click
        Dim a As New SaveFileDialog
        a.Filter = "엑셀 워크시트파일(*.XLS)|*.XLS"
        a.FilterIndex = 0
        a.Title = "[모든데이터내보내기] 저장할 엑셀 파일을 지정하세요"

        If a.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then
            Dim msg As New System.Text.StringBuilder

            '//데이터는 정상(컬럼이 없음)
            'Me.fp.SaveExcel(a.FileName)
            ' Me.fp.SaveExcel(a.FileName, FarPoint.Excel.ExcelSaveFlags.SaveAsViewed)

            '//컬럼이 2줄나오면서 실제 데이터2줄도 짤림
            Me.fp.SaveExcel(a.FileName, FarPoint.Excel.ExcelSaveFlags.SaveAsViewed)
            ' Me.fp.SaveExcel(a.FileName, FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders)
            '  Me.fp.SaveExcel(a.FileName, FarPoint.Excel.ExcelSaveFlags.SaveBothCustomRowAndColumnHeaders)

            msg.AppendLine("내보내진 파일은 기본값으로 [시트보호]가 되어있습니다")
            msg.AppendLine()
            msg.AppendLine()
            msg.AppendLine("[시트보호] 상태에서는 시트를 편집할 수 없습니다")
            msg.AppendLine()
            msg.AppendLine("[시트보호]를 해제하려면  해당파일을 엑셀에서 불러온후")
            msg.AppendLine("[도구]-[보호]-[시트보호해제]를 클릭하세요")
            MsgBox(msg.ToString, MsgBoxStyle.Information, "시트보호")
        End If
    End Sub

    Private Sub bt_save_current_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_save_current.Click
        Dim a As New SaveFileDialog
        a.Filter = "엑셀 워크시트파일(*.XLS)|*.XLS"
        a.FilterIndex = 0
        a.Title = "[현재데이터내보내기] 저장할 엑셀 파일을 지정하세요"
        If a.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then
            Dim msg As New System.Text.StringBuilder
            Me.fp.SaveExcel(a.FileName, FarPoint.Excel.ExcelSaveFlags.SaveAsFiltered)
            msg.AppendLine("내보내진 파일은 기본값으로 [시트보호]가 되어있습니다")
            msg.AppendLine()
            msg.AppendLine()
            msg.AppendLine("[시트보호] 상태에서는 시트를 편집할 수 없습니다")
            msg.AppendLine()
            msg.AppendLine("[시트보호]를 해제하려면  해당파일을 엑셀에서 불러온후")
            msg.AppendLine("[도구]-[보호]-[시트보호해제]를 클릭하세요")
            MsgBox(msg.ToString, MsgBoxStyle.Information, "시트보호")
        End If
    End Sub

    Private Sub allsavedataMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles allsavedata.Click
        Me.bt_save_all.PerformClick()

    End Sub

    Private Sub currentsavedataoolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles currentsavedata.Click
        Me.bt_save_current.PerformClick()
    End Sub

    Private Sub ToolStripButton6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.fp.Focus()
        Me.fp.ActiveSheet.SetActiveCell(1, 5)

    End Sub

    Private Sub AddEpole_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Validated
        Me.fp.Focus()
        Me.fp.Focus()
    End Sub

    Private Sub ToolStripButton6_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_datasort.Click
        If MsgBox("전주번호순으로 데이터가 정렬됩니다" & vbCrLf & vbCrLf & "계속하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return

        Dim 번호 As String
        Dim 번호B, 번호b2 As System.Text.StringBuilder
        Me.pbar.Minimum = 0
        Me.pbar.Maximum = Me.IreaDataSet1.jjutable.Rows.Count - 1
        Me.pbar.Value = 0
        Dim Cidx As Int16 = 0
        Dim Carray As ArrayList
        For Each dr As ireaDataSet.jjutableRow In Me.IreaDataSet1.jjutable.Rows
            번호 = (dr.번호1 & dr.번호2 & dr.번호3 & dr.번호4 & dr.번호5)
            If 번호 <> "" Then  '// 123H1R1R2H3
                Cidx = 0
                번호B = New System.Text.StringBuilder
                번호b2 = New System.Text.StringBuilder
                Carray = New ArrayList
                For Each C As Char In 번호.ToCharArray
                    If Char.IsLetter(C) Then
                        Carray.Add(C) '//문자위치와 문자를 저장한다.
                        번호B.Append("@")   '//문자는 @로 변환한다.
                    Else
                        번호B.Append(C) '//숫자는 바로 저장해버린다.
                    End If
                    Cidx += 1
                Next
                '// 123@1@1@2@3
                For Each 번호s As String In 번호B.ToString.Split("@")
                    번호b2.Append(Format(Val(번호s), "000").ToString & "@")   '/3자리로바꾼후 문자열을 붙인다
                Next
                번호b2.Remove(번호b2.Length - 1, 1) '//쓰레기제거
                번호 = 번호b2.ToString '//123@001@001@002@003

                For Each c As Char In Carray  '//문자와 위치가 있다
                    Cidx = 번호.IndexOf("@")
                    If Cidx <> -1 Then 번호 = 번호.Substring(0, Cidx) & c & 번호.Substring(Cidx + 1)
                Next

                If dr.인쇄 = False Then
                    번호 = CStr(번호.ToUpper.Replace("K", "C")).Replace("G", "C") & "A"
                Else
                    번호 = CStr(번호.ToUpper.Replace("K", "C")).Replace("G", "C") & "B"
                End If

                번호 = 번호.Replace("H", "@")
                '//H계산식 : 바로앞번호를 1빼고 H??? 를 0000 으로 변경
                '//H는 본주보다 먼저와야하고 H끼리서로 정렬되어야 한다.
                'If 번호.IndexOf("H") <> -1 Then  '//H가있다는것이다 H는 바로앞과H를 0으로 바꾼다.
                '    Dim 전문자 As String = 번호.Substring(0, 번호.IndexOf("H") - 3)
                '    Dim 앞번호 As Short = 번호.Substring(번호.IndexOf("H") - 3, 3)
                '    Dim 후문자 As String = 번호.Substring(번호.IndexOf("H") + 4)
                '    '번호 = 전문자 & Format(앞번호 - 1, "000") & "ZZZ" & 후문자
                '    번호 = 전문자 & Format(앞번호 - 1, "000") & "ZZZ" & 번호.Substring(번호.IndexOf("H") + 1) & 후문자
                'End If
                'If 번호.IndexOf("H") <> -1 Then GoTo LBL_H
                dr.정렬번호 = dr.선로명 & 번호
                If Me.pbar.Value < Me.pbar.Maximum Then Me.pbar.Value += 1
            Else   '//번호에 아무것도 없는경우
                dr.정렬번호 = dr.선로명 & "0"                    'If SORTNULL Then dr.정렬번호 = dr.선로명 & "0"
            End If
        Next
        NOTICE("정렬이 완료되었습니다", Me.lb_msg)
    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 MenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles findtextlStripMenuItem.Click
        Dim Frow, Fcol As Integer
        Me.fp.Search(Me.fp.ActiveSheetIndex, InputBox("선택된 열에서 검색할 문자를 입력하세요."), False, False, False, True, True, False, False, 0, 0, Frow, Fcol)
        If Frow >= 0 AndAlso Fcol >= 0 Then '//검색됫다면
            Me.fp.ActiveSheet.SetActiveCell(Frow, Fcol)
            SendKeys.Send("{ENTER}")
        End If
    End Sub

    Private Sub cm_viewoldnum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cm_viewoldnum.Click
        Me.fp.ActiveSheet.Columns(4).Width = 80
        Me.fp.ActiveSheet.Columns(5).Width = 80
    End Sub

    Private Sub M_OLDSUNNUM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub M_ONUMEQN_NUM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles M_ONUMEQN_NUM.Click
        Dim fcnt As Integer = 0
        Dim A() As Short = New Short() {Me.fp.ActiveSheet.Columns("구관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("구전산화번호").Index, _
                                               Me.fp.ActiveSheet.Columns("구선로명").Index, _
                                               Me.fp.ActiveSheet.Columns("구전주번호").Index}

        Dim B() As Short = New Short() {Me.fp.ActiveSheet.Columns("관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("전산화번호").Index, _
                                               Me.fp.ActiveSheet.Columns("선로명").Index, _
                                               Me.fp.ActiveSheet.Columns("번호1").Index, _
                                               Me.fp.ActiveSheet.Columns("번호2").Index, _
                                               Me.fp.ActiveSheet.Columns("번호3").Index, _
                                               Me.fp.ActiveSheet.Columns("번호4").Index, _
                                               Me.fp.ActiveSheet.Columns("번호5").Index}

        NOTICE("중복되는 [1. 구,신 전산화번호및 선로명,전주번호가 모두 일치하는 경우]를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.fp.AdupCheckSR(0, Me.fp.ActiveSheet.RowCount - 1, A, B, Me.fp.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[1. 구,신 전산화번호및 선로명,전주번호가 모두 일치하는 경우] 중복검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)

    End Sub

    Private Sub ONUMNNUM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ONUMNNUM.Click
        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        Dim 원본, 대상 As String 'New System.Text.StringBuilder
        Dim fcnt As Integer = 0

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

        NOTICE("중복되는 [구전주번호] = [신전주번호]를 찾는중입니다...", Me.lb_msg)
        Me.Invalidate()
        For Each A As FarPoint.Win.Spread.Row In Me.fp.ActiveSheet.Rows
            원본 = Me.fp.ActiveSheet.Cells(A.Index, 9).Value & Me.fp.ActiveSheet.Cells(A.Index, 10).Value & Me.fp.ActiveSheet.Cells(A.Index, 11).Value & _
                     Me.fp.ActiveSheet.Cells(A.Index, 12).Value & Me.fp.ActiveSheet.Cells(A.Index, 13).Value
            대상 = Me.fp.ActiveSheet.Cells(A.Index, 5).Value

            If 원본.ToString <> "" Then
                If 원본.ToString = 대상.ToString Then
                    fcnt += 1
                    Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ACheckBox_ColIndex).Value = True
                    'Me.view1.ActiveSheet.Cells(B.Index, Me.view1.ACheckBox_ColIndex).Value = True
                End If
            End If
            If Me.pbar.Value < Me.pbar.Maximum Then Me.pbar.Value += 1
            Me.Invalidate()
        Next
        NOTICE("[구전주번호] = [신전주번호] 중복검사 완료(" & fcnt & "개의 데이터를 찾았습니다)", Me.lb_msg)
    End Sub

    Private Sub cm_checkjisunju_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cm_checkjisunju.Click
        '//지선주 열번호 21 번.
        Dim A As New System.Text.StringBuilder("현재 체크된 지선주를 무시하고 새로 검색합니다")
        A.AppendLine()
        A.AppendLine("계속하시겠습니까?(완료후 취소가능)")
        If MsgBox(A.ToString, MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return

        Me.pbar.Minimum = 0
        Me.pbar.Value = 0
        Me.pbar.Maximum = Me.IreaDataSet1.jjutable.Count

        Dim JN As String
        For Each Dr As DataRow In Me.IreaDataSet1.jjutable.Rows
            pbar.Value += 1
            JN = Dr("번호1") & Dr("번호2") & Dr("번호3") & Dr("번호4") & Dr("번호5")
            If JN.IndexOf("G") > -1 OrElse JN.IndexOf("K") > -1 Then
                Dr("인쇄") = True
            Else
                Dr("인쇄") = False
            End If
        Next
    End Sub

    Private Sub cm_RenewNum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cm_RenewNum.Click
        ReNum(Me.IreaDataSet1.jjutable, "번호", 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.IreaDataSet1.jjutable.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.IreaDataSet1.jjutable.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.IreaDataSet1.jjutable.Rows
            A("출력") = Not A("출력")
        Next
    End Sub


    Private Sub cmbt_hnum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbt_hnum.Click
        Dim DT As ireaDataSet.jjutableDataTable

        DT = Me.IreaDataSet1.jjutable.Copy  '//테이블을 카피했다.

        Dim 전주번호 As String
        Dim 구전주 As String
        For Each Dr As ireaDataSet.jjutableRow In DT.Rows
            '//현테이블의 모든 로우로부터 전주번호에 H잇는놈만 찾아서 테이블을 구성한다.
            전주번호 = CStr(Dr.번호1 & Dr.번호2 & Dr.번호3 & Dr.번호4 & Dr.번호5).ToUpper
            구전주 = CStr(Dr.구전주번호).ToUpper
            If 전주번호.IndexOf("H") < 0 AndAlso 구전주.IndexOf("H") < 0 Then Dr.Delete()
            MsgBox(구전주)

        Next
        DT.AcceptChanges()

        Me.fp.DataSource = DT
        Dim a As New SaveFileDialog
        a.Filter = "엑셀 워크시트파일(*.XLS)|*.XLS"
        a.FilterIndex = 0
        a.Title = "[모든데이터내보내기] 저장할 엑셀 파일을 지정하세요"
        a.FileName = "H포함목록.xls"

        If a.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then
            Dim msg As New System.Text.StringBuilder
            Me.fp.SaveExcel(a.FileName, FarPoint.Excel.ExcelSaveFlags.SaveAsViewed)
            msg.AppendLine("내보내진 파일은 기본값으로 [시트보호]가 되어있습니다")
            msg.AppendLine()
            msg.AppendLine()
            msg.AppendLine("[시트보호] 상태에서는 시트를 편집할 수 없습니다")
            msg.AppendLine()
            msg.AppendLine("[시트보호]를 해제하려면  해당파일을 엑셀에서 불러온후")
            msg.AppendLine("[도구]-[보호]-[시트보호해제]를 클릭하세요")
            MsgBox(msg.ToString, MsgBoxStyle.Information, "시트보호")
        End If

        Me.fp.DataSource = Me.bs

    End Sub

    Private Sub CmbtnhnumToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbtnhnumToolStripMenuItem.Click
        Dim DT As ireaDataSet.jjutableDataTable

        DT = Me.IreaDataSet1.jjutable.Copy  '//테이블을 카피했다.

        Dim 전주번호 As String
        Dim 구전주 As String
        For Each Dr As ireaDataSet.jjutableRow In DT.Rows
            '//현테이블의 모든 로우로부터 전주번호에 H잇는놈만 찾아서 테이블을 구성한다.
            전주번호 = CStr(Dr.번호1 & Dr.번호2 & Dr.번호3 & Dr.번호4 & Dr.번호5).ToUpper
            구전주 = CStr(Dr.구전주번호).ToUpper

            If 전주번호.IndexOf("H") >= 0 OrElse 구전주.IndexOf("H") >= 0 Then Dr.Delete()
        Next
        DT.AcceptChanges()

        Me.fp.DataSource = DT
        Dim a As New SaveFileDialog
        a.Filter = "엑셀 워크시트파일(*.XLS)|*.XLS"
        a.FilterIndex = 0
        a.Title = "[모든데이터내보내기] 저장할 엑셀 파일을 지정하세요"
        a.FileName = "H비포함목록.xls"

        If a.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then
            Dim msg As New System.Text.StringBuilder
            Me.fp.SaveExcel(a.FileName, FarPoint.Excel.ExcelSaveFlags.SaveAsViewed)
            msg.AppendLine("내보내진 파일은 기본값으로 [시트보호]가 되어있습니다")
            msg.AppendLine()
            msg.AppendLine()
            msg.AppendLine("[시트보호] 상태에서는 시트를 편집할 수 없습니다")
            msg.AppendLine()
            msg.AppendLine("[시트보호]를 해제하려면  해당파일을 엑셀에서 불러온후")
            msg.AppendLine("[도구]-[보호]-[시트보호해제]를 클릭하세요")
            MsgBox(msg.ToString, MsgBoxStyle.Information, "시트보호")
        End If

        Me.fp.DataSource = Me.bs
    End Sub

    Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click
        Me.bt_print.PerformClick()
    End Sub

    Private Sub bt_print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_print.Click

        Me.bs.EndEdit()
        If Me.fp.Cells("출력").Value = False Then
            MsgBox("현재 선택된 줄은 출력이 되지않도록 설정되어있습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If
        Dim A As New printform(Me.IreaDataSet1.jjutable, CType(Me.bs.Current, DataRowView)) 'Me.view1.ActiveSheet.ActiveRowIndex)
        If Admin Then
            A.Show()

        Else
            A.ShowDialog()

        End If
    End Sub

    Private Sub bt_2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_2.Click
        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        Dim 원본, 대상 As String 'New System.Text.StringBuilder
        Dim fcnt As Integer = 0

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

        NOTICE("[구,신 선로명,전주번호가 다른경우(전주번호에서 'H' 가 있는경우)]를 찾는중입니다...", Me.lb_msg)
        Me.Invalidate()
        For Each A As FarPoint.Win.Spread.Row In Me.fp.ActiveSheet.Rows

            원본 = Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("구선로명").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("구전주번호").Index).Text
            대상 = Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("선로명").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호1").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호2").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호3").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호4").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호5").Index).Text

            If (원본.ToUpper.IndexOf("H") >= 0 OrElse 대상.ToUpper.IndexOf("H") >= 0) AndAlso 원본.ToString <> "" Then '//번호에 H가있고
                If 원본.ToString <> 대상.ToString Then '//서로다른경우
                    fcnt += 1
                    Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ACheckBox_ColIndex).Value = True
                End If
            End If
            If Me.pbar.Value < Me.pbar.Maximum Then Me.pbar.Value += 1
            Me.Invalidate()
        Next
        NOTICE("[구,신 선로명,전주번호가 다른경우(전주번호에서 'H' 가 있는경우)] 검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)

    End Sub

    Private Sub bt_3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_3.Click
        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        Dim 원본, 대상 As String 'New System.Text.StringBuilder
        Dim fcnt As Integer = 0

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

        NOTICE("[구,신 선로명,전주번호가 다른경우(전주번호에서 'H' 가 없는경우)]를 찾는중입니다...", Me.lb_msg)
        Me.Invalidate()
        For Each A As FarPoint.Win.Spread.Row In Me.fp.ActiveSheet.Rows

            원본 = Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("구선로명").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("구전주번호").Index).Text
            대상 = Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("선로명").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호1").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호2").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호3").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호4").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호5").Index).Text

            If 원본.ToString <> "" AndAlso 원본.ToUpper.IndexOf("H") = -1 AndAlso 대상.ToUpper.IndexOf("H") = -1 Then '//둘다 번호에 번호에 H가없고
                If 원본.ToString <> 대상.ToString Then '//서로다른경우
                    fcnt += 1
                    Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ACheckBox_ColIndex).Value = True
                End If
            End If
            If Me.pbar.Value < Me.pbar.Maximum Then Me.pbar.Value += 1
            Me.Invalidate()
        Next
        NOTICE("[구,신 선로명,전주번호가 다른경우(전주번호에서 'H' 가 없는경우)] 검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)
    End Sub

    Private Sub bt_20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_20.Click
        Dim fcnt As Integer = 0
        Dim A() As Short = New Short() {Me.fp.ActiveSheet.Columns("구관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("구전산화번호").Index}

        Dim B() As Short = New Short() {Me.fp.ActiveSheet.Columns("관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("전산화번호").Index}

        NOTICE("[구,신 전산화번호가 다른 경우]를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.fp.ADupCheckSr_inBlank(0, Me.fp.ActiveSheet.RowCount - 1, A, B, Me.fp.ACheckBox_ColIndex, Me.pbar, False)
        NOTICE("[구,신 전산화번호가 다른 경우] 검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)
    End Sub

    Private Sub view1_CellClick(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.CellClickEventArgs) Handles fp.CellClick

    End Sub

    Private Sub bt_dup_8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim 지선1, 지선2 As String
        Dim fcnt As Integer = 0
        Dim bA() As Short = New Short() {Me.fp.ActiveSheet.Columns("구선로명").Index, _
                                               Me.fp.ActiveSheet.Columns("구전주번호").Index}

        NOTICE("중복되는 [구 선로명, 전주번호가 같은 경우 : 지선주미포함]를 찾는중입니다...", Me.lb_msg)

        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        Dim 원본, 대상 As String 'New System.Text.StringBuilder

        If Not pbar Is Nothing Then
            pbar.Value = 0
            pbar.Minimum = 0
            pbar.Maximum = Me.fp.ActiveSheet.RowCount - 1
        End If

        For A As Integer = 0 To Me.fp.ActiveSheet.RowCount - 1
            원본 = ""
            지선1 = ""

            For Each T As Short In bA
                원본 &= Me.fp.ActiveSheet.Cells(A, T).Value
            Next
            지선1 = Me.fp.ActiveSheet.Cells(A, Me.fp.ActiveSheet.Columns("지선").Index).Text

            If 원본.Trim.ToString <> "" AndAlso 지선1.ToUpper = "FALSE" Then
                For B As Integer = 0 To Me.fp.ActiveSheet.RowCount - 1
                    지선2 = ""
                    If A <> B Then   '//같은라인은 피하고 그렇지 않은 라인의 번호를 확인한다.
                        대상 = ""
                        For Each T As Short In bA
                            대상 &= Me.fp.ActiveSheet.Cells(B, T).Value
                        Next
                        지선2 = Me.fp.ActiveSheet.Cells(B, Me.fp.ActiveSheet.Columns("지선").Index).Text
                        '//원본이나 대상이 지선주가 아니여야한다.
                        '//지선주유무는 컬럼태그 지선 으로 되어있다.
                        If 지선2.ToUpper = "FALSE" AndAlso 원본.Trim.ToString = 대상.Trim.ToString Then  '//지선주일경우에는 뺸다.
                            fcnt += 1
                            Me.fp.ActiveSheet.Cells(A, Me.fp.ACheckBox_ColIndex).Value = True
                            Me.fp.ActiveSheet.Cells(B, Me.fp.ACheckBox_ColIndex).Value = True

                        End If
                    End If
                Next
            End If
            If pbar.Value < pbar.Maximum Then pbar.Value += 1
            Me.Invalidate()
        Next
        'fcnt = Me.view1.중복검사2(0, Me.view1.ActiveSheet.RowCount - 1, A, A, Me.view1.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[구 선로명, 전주번호가 같은 경우 :  지선주미포함] 중복검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)
    End Sub

    Private Sub bt_savecolsize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_savecolsize.Click
        Me.fp.ASetting_Save(False)
    End Sub

    Private Sub view1_LeaveCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.LeaveCellEventArgs) Handles fp.LeaveCell
        Select Case Me.fp.ActiveColumn.Label.ToUpper
            Case "장척"
                Dim Drv As DataRowView = Me.bs.Current
                If Me.fp.ActiveSheet.Cells(e.Row, e.Column).Text <> "" Then
                    Drv("기입") = False
                Else
                    Drv("기입") = True
                End If

        End Select
    End Sub

    Private Sub view1_Arin_Before_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles fp.Arin_Before_KeyDown
        ' view1_Arin_AddLog(sender, "원래뷰에서의 before_keydown 열번호=" & Me.view1.ActiveSheet.ActiveColumnIndex)
        Select Case e.KeyCode
            Case Keys.Insert '//삽입
                Me.bt_insertrow.PerformClick()
            Case Keys.F5
                e.Handled = True
                e.SuppressKeyPress = True
                If tbf1.Text <> "" Then
                    If fp_Sheet1.ActiveColumn.DataField = "시공년월" Then
                        If Not IsNumeric(tbf1.Text) Then
                            MsgBox("숫자값만 입력할 수 있습니다", MsgBoxStyle.Critical, "확인")
                        Else
                            fp_Sheet1.ActiveCell.Value = CInt(tbf1.Text.Trim())
                        End If
                    Else
                        fp_Sheet1.ActiveCell.Value = tbf1.Text.Trim()
                    End If
                End If
            Case Keys.F6
                e.Handled = True
                e.SuppressKeyPress = True
                If tbf2.Text <> "" Then
                    If fp_Sheet1.ActiveColumn.DataField = "시공년월" Then
                        If Not IsNumeric(tbf2.Text) Then
                            MsgBox("숫자값만 입력할 수 있습니다", MsgBoxStyle.Critical, "확인")
                        Else
                            fp_Sheet1.ActiveCell.Value = CInt(tbf2.Text.Trim())
                        End If
                    Else
                        fp_Sheet1.ActiveCell.Text = tbf2.Text.Trim()
                    End If
                End If
            Case Keys.F7
                e.Handled = True
                e.SuppressKeyPress = True
                If tbf3.Text <> "" Then
                    If fp_Sheet1.ActiveColumn.DataField = "시공년월" Then
                        If Not IsNumeric(tbf3.Text) Then
                            MsgBox("숫자값만 입력할 수 있습니다", MsgBoxStyle.Critical, "확인")
                        Else
                            fp_Sheet1.ActiveCell.Value = CInt(tbf3.Text.Trim())
                        End If
                    Else
                        fp_Sheet1.ActiveCell.Text = tbf3.Text.Trim()
                    End If
                End If
            Case Keys.F8
                e.Handled = True
                e.SuppressKeyPress = True
                If tbf4.Text <> "" Then
                    If fp_Sheet1.ActiveColumn.DataField = "시공년월" Then
                        If Not IsNumeric(tbf4.Text) Then
                            MsgBox("숫자값만 입력할 수 있습니다", MsgBoxStyle.Critical, "확인")
                        Else
                            fp_Sheet1.ActiveCell.Value = CInt(tbf4.Text.Trim())
                        End If
                    Else
                        fp_Sheet1.ActiveCell.Text = tbf4.Text.Trim()
                    End If
                End If
            Case Keys.F9
                e.Handled = True
                e.SuppressKeyPress = True
                If tbf5.Text <> "" Then
                    If fp_Sheet1.ActiveColumn.DataField = "시공년월" Then
                        If Not IsNumeric(tbf5.Text) Then
                            MsgBox("숫자값만 입력할 수 있습니다", MsgBoxStyle.Critical, "확인")
                        Else
                            fp_Sheet1.ActiveCell.Value = CInt(tbf5.Text.Trim())
                        End If
                    Else
                        fp_Sheet1.ActiveCell.Text = tbf5.Text.Trim()
                    End If
                End If
            Case Keys.F10
                e.Handled = True
                e.SuppressKeyPress = True
                If tbf6.Text <> "" Then
                    If fp_Sheet1.ActiveColumn.DataField = "시공년월" Then
                        If Not IsNumeric(tbf6.Text) Then
                            MsgBox("숫자값만 입력할 수 있습니다", MsgBoxStyle.Critical, "확인")
                        Else
                            fp_Sheet1.ActiveCell.Value = CInt(tbf6.Text.Trim())
                        End If
                    Else
                        fp_Sheet1.ActiveCell.Text = tbf6.Text.Trim()
                    End If
                End If
            Case Keys.F11
                e.Handled = True
                e.SuppressKeyPress = True
                If tbf7.Text <> "" Then
                    If fp_Sheet1.ActiveColumn.DataField = "시공년월" Then
                        If Not IsNumeric(tbf7.Text) Then
                            MsgBox("숫자값만 입력할 수 있습니다", MsgBoxStyle.Critical, "확인")
                        Else
                            fp_Sheet1.ActiveCell.Value = CInt(tbf7.Text.Trim())
                        End If
                    Else
                        fp_Sheet1.ActiveCell.Text = tbf7.Text.Trim()
                    End If
                End If
            Case Keys.F12
                e.Handled = True
                e.SuppressKeyPress = True
                If tbf8.Text <> "" Then
                    If fp_Sheet1.ActiveColumn.DataField = "시공년월" Then
                        If Not IsNumeric(tbf8.Text) Then
                            MsgBox("숫자값만 입력할 수 있습니다", MsgBoxStyle.Critical, "확인")
                        Else
                            fp_Sheet1.ActiveCell.Value = CInt(tbf8.Text.Trim())
                        End If
                    Else
                        fp_Sheet1.ActiveCell.Text = tbf8.Text.Trim()
                    End If
                End If
            Case Keys.Enter '/마지막줄에 마지막 열이엿으면 bt_insertrow
                With Me.fp.ActiveSheet
                    '  Me.Text = .ActiveRowIndex & "/" & .ActiveColumnIndex
                    Select Case .ActiveColumn.Label.ToUpper
                        Case "관리구A", "관리구B", "번호A", "번호B", "선로명A", "선로명B", "시공년월", "시공자", "감독자", "점검일자", "D/L명"
                            If .ActiveCell.Text = "" AndAlso .ActiveRowIndex >= 1 Then
                                .ActiveCell.Text = .Cells(.ActiveRowIndex - 1, .ActiveColumnIndex).Text
                            End If
                        Case "장척"   '//장척
                            If .ActiveCell.Text = "" Then
                                Dim Pnum As String = (.Cells(IIf(.ActiveRowIndex > 0, .ActiveRowIndex - 1, 0), .ActiveColumnIndex).Text)
                                .ActiveCell.Text = Pnum
                                '//장척을 복사했을대다 b06 06 등을 검사한다
                                Select Case Pnum.ToUpper
                                    Case "B06", "B6", "06"
                                        Me.fp.Cells2("인입").Value = True
                                        Me.fp.Cells2("기입").Value = False
                                    Case Else
                                        Me.fp.Cells2("인입").Value = False
                                        Me.fp.Cells2("기입").Value = False
                                End Select

                            End If
                        Case "A1"  '//전주번호1(선로명이 같으면 이 데이터 복사)
                            '//먼저 현재줄의 위치가 1이상이어야 윗줄 복사를 할수있다.
                            '//그리고 현재셀에 값이 없어야한다.
                            If .ActiveCell.Text = "" AndAlso .ActiveRowIndex >= 1 Then
                                If .Cells(.ActiveRowIndex, Me.fp.ColIndex2("선로명B")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("선로명B")).Text Then '//전줄의 선로명과 같다면
                                    .ActiveCell.Text = .Cells(.ActiveRowIndex - 1, .ActiveColumnIndex).Text
                                    If .ActiveCell.Text = "지선주" Then Me.fp.Cells2("지선").Value = True
                                End If
                            End If
                        Case "A2"  '//번호2
                            If .ActiveCell.Text = "" AndAlso .ActiveRowIndex >= 1 Then '//선로명,전주번호1이 같다면 2번 복사
                                If .Cells(.ActiveRowIndex, Me.fp.ColIndex2("선로명B")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("선로명B")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A1")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A1")).Text Then
                                    .ActiveCell.Text = .Cells(.ActiveRowIndex - 1, .ActiveColumnIndex).Text
                                End If
                            End If
                        Case "A3"  '//번호3
                            If .ActiveCell.Text = "" AndAlso .ActiveRowIndex >= 1 Then '//선로명,전주번호1이 같다면 2번 복사
                                If .Cells(.ActiveRowIndex, Me.fp.ColIndex2("선로명B")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("선로명B")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A1")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A1")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A2")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A2")).Text Then
                                    .ActiveCell.Text = .Cells(.ActiveRowIndex - 1, .ActiveColumnIndex).Text
                                End If
                            End If
                        Case "A4"  '//번호4
                            If .ActiveCell.Text = "" AndAlso .ActiveRowIndex >= 1 Then '//선로명,전주번호1이 같다면 2번 복사
                                If .Cells(.ActiveRowIndex, Me.fp.ColIndex2("선로명B")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("선로명B")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A1")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A1")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A2")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A2")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A3")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A3")).Text Then
                                    .ActiveCell.Text = .Cells(.ActiveRowIndex - 1, .ActiveColumnIndex).Text
                                End If
                            End If
                        Case "A5"  '//번호5
                            If .ActiveCell.Text = "" AndAlso .ActiveRowIndex >= 1 Then '//선로명,전주번호1이 같다면 2번 복사
                                If .Cells(.ActiveRowIndex, Me.fp.ColIndex2("선로명B")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("선로명B")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A1")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A1")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A2")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A2")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A3")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A3")).Text AndAlso _
                                   .Cells(.ActiveRowIndex, Me.fp.ColIndex2("A4")).Text = .Cells(.ActiveRowIndex - 1, Me.fp.ColIndex2("A4")).Text Then
                                    .ActiveCell.Text = .Cells(.ActiveRowIndex - 1, .ActiveColumnIndex).Text
                                End If
                            End If
                    End Select
                End With

                'If Me.view1.ActiveSheet.ActiveRowIndex = Me.view1.ActiveSheet.RowCount - 1 Then '//마지막줄에
                '    If Me.view1.ANextRow_ColIndex = Me.view1.ActiveSheet.ActiveColumnIndex Then '//다음줄로가아햘 경우라면
                '        Me.bt_addrow.PerformClick()
                '        Me.view1.ActiveSheet.SetActiveCell(Me.view1.ActiveSheet.RowCount - 1, Me.view1.AFirstColumn_Index)
                '        e.Handled = True
                '    ElseIf Me.view1.ActiveSheet.ActiveColumnIndex = Me.view1.ActiveSheet.ColumnCount - 1 Then   '//마지막열이라면
                '        Me.bt_addrow.PerformClick()
                '        Me.view1.ActiveSheet.SetActiveCell(Me.view1.ActiveSheet.RowCount - 1, Me.view1.AFirstColumn_Index)
                '        e.Handled = True
                '    End If
                'End If

        End Select
    End Sub

    Private Sub view1_Arin_Before_EditModeOff(ByVal sender As Object, ByVal e As System.EventArgs) Handles fp.Arin_Before_EditModeOff
        ' Me.view1_Arin_AddLog(sender, "원래뷰의 befoer_editmodeoff")
        With Me.fp.ActiveSheet
            Select Case .ActiveColumn.Label.ToUpper
                Case "장척" '장척일경우 
                    If .ActiveCell.Text.Length = 1 Then .ActiveCell.Text = "0" & .ActiveCell.Text '//1자리는 앞에 0을 채워준다.
                    Select Case .ActiveCell.Text.ToString.ToUpper
                        Case "B06", "B6", "06", "6"
                            Me.fp.Cells2("인입").Value = True    '//인입
                            Me.fp.Cells2("기입").Value = False    '//기입
                        Case ""   '3월6일 다시 부활
                            Me.fp.Cells2("기입").Value = True
                            Me.fp.Cells2("인입").Value = False
                        Case Else
                            Me.fp.Cells2("인입").Value = False
                            Me.fp.Cells2("기입").Value = False
                    End Select
                Case "A1" '//전주번호1
                    If .ActiveCell.Text = "지선주" OrElse .ActiveCell.Text = "지선" Then Me.fp.Cells2("지선").Value = True '//지선주활성화

                Case "D/L명"   '//dl
                    If .ActiveCell.Value <> "" Then
                        If .ActiveCell.Value.ToString.IndexOf(";") = -1 Then '//d/l 없이 다른게 입력되면 앞에 d/l을 붙여준다.
                            .ActiveCell.Value = "D/L;" & .ActiveCell.Value.ToString
                        End If
                    End If
            End Select
        End With
    End Sub

    Private Sub bt_datasort_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles bt_datasort.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Right Then
            If MsgBox("정렬데이터를 모두 삭제하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
                For Each dr As ireaDataSet.jjutableRow In Me.IreaDataSet1.jjutable.Rows
                    dr.정렬번호 = ""
                Next
                NOTICE("정렬데이터가 초기화되었습니다.", Me.lb_msg)
            End If
        End If
    End Sub

    Private Sub bt_11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_11.Click
        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        Dim 원본, 대상 As String 'New System.Text.StringBuilder
        Dim fcnt As Integer = 0

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

        NOTICE("[구,신 선로명,전주번호가 다른경우]를 찾는중입니다...", Me.lb_msg)
        Me.Invalidate()
        For Each A As FarPoint.Win.Spread.Row In Me.fp.ActiveSheet.Rows

            원본 = Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("구선로명").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("구전주번호").Index).Text
            대상 = Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("선로명").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호1").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호2").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호3").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호4").Index).Text & _
                     Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ActiveSheet.Columns("번호5").Index).Text

            If 원본.ToString <> "" Then '//둘다 번호에 번호에 H가없고
                If 원본.ToString <> 대상.ToString Then '//서로다른경우
                    fcnt += 1
                    Me.fp.ActiveSheet.Cells(A.Index, Me.fp.ACheckBox_ColIndex).Value = True
                End If
            End If
            If Me.pbar.Value < Me.pbar.Maximum Then Me.pbar.Value += 1
            Me.Invalidate()
        Next
        NOTICE("[구,신 선로명,전주번호가 다른경우] 검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)
    End Sub

    Private Sub bt_201_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_201.Click
        Dim fcnt As Integer = 0
        Dim A() As Short = New Short() {Me.fp.ActiveSheet.Columns("구관리구").Index,
                                               Me.fp.ActiveSheet.Columns("구전산화번호").Index}

        Dim B() As Short = New Short() {Me.fp.ActiveSheet.Columns("관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("전산화번호").Index}

        NOTICE("[구,신 전산화번호가 같은 경우]를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.fp.AdupCheckSR(0, Me.fp.ActiveSheet.RowCount - 1, A, B, Me.fp.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[구,신 전산화번호가 같은 경우] 검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)


    End Sub

    Private Sub ToolStripMenuItem17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ToolStripMenuItem18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


    End Sub

    Private Sub ToolStripMenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem11.Click
        Dim fcnt As Integer = 0
        Dim A() As Short = New Short() {Me.fp.ActiveSheet.Columns("관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("전산화번호").Index}

        NOTICE("중복되는 [신 전산화번호가 같은 경우]를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.fp.ADupCheck2(0, Me.fp.ActiveSheet.RowCount - 1, A, A, Me.fp.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[신 전산화번호가 같은 경우] 중복검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)
    End Sub

    Private Sub ToolStripMenuItem10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem10.Click
        Dim 지선1, 지선2 As String
        Dim fcnt As Integer = 0
        Dim ba() As Short = New Short() {Me.fp.ActiveSheet.Columns("선로명").Index, _
                                             Me.fp.ActiveSheet.Columns("번호1").Index, _
                                             Me.fp.ActiveSheet.Columns("번호2").Index, _
                                             Me.fp.ActiveSheet.Columns("번호3").Index, _
                                             Me.fp.ActiveSheet.Columns("번호4").Index, _
                                             Me.fp.ActiveSheet.Columns("번호5").Index}

        NOTICE("중복되는 [신 선로명,전주번호가 같은 경우 : 지선주미포함]를 찾는중입니다...", Me.lb_msg)

        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        Dim 원본, 대상 As String 'New System.Text.StringBuilder

        If Not pbar Is Nothing Then
            pbar.Value = 0
            pbar.Minimum = 0
            pbar.Maximum = Me.fp.ActiveSheet.RowCount - 1
        End If

        For A As Integer = 0 To Me.fp.ActiveSheet.RowCount - 1
            원본 = ""
            지선1 = ""

            For Each T As Short In ba
                원본 &= Me.fp.ActiveSheet.Cells(A, T).Value
            Next
            지선1 = Me.fp.ActiveSheet.Cells(A, Me.fp.ActiveSheet.Columns("지선").Index).Text

            If 원본.Trim.ToString <> "" AndAlso 지선1.ToUpper = "FALSE" Then
                For B As Integer = 0 To Me.fp.ActiveSheet.RowCount - 1
                    지선2 = ""
                    If A <> B Then   '//같은라인은 피하고 그렇지 않은 라인의 번호를 확인한다.
                        대상 = ""
                        For Each T As Short In ba
                            대상 &= Me.fp.ActiveSheet.Cells(B, T).Value
                        Next
                        지선2 = Me.fp.ActiveSheet.Cells(B, Me.fp.ActiveSheet.Columns("지선").Index).Text
                        '//원본이나 대상이 지선주가 아니여야한다.
                        '//지선주유무는 컬럼태그 지선 으로 되어있다.
                        If 지선2.ToUpper = "FALSE" AndAlso 원본.Trim.ToString = 대상.Trim.ToString Then  '//지선주일경우에는 뺸다.
                            fcnt += 1
                            Me.fp.ActiveSheet.Cells(A, Me.fp.ACheckBox_ColIndex).Value = True
                            Me.fp.ActiveSheet.Cells(B, Me.fp.ACheckBox_ColIndex).Value = True
                        End If
                    End If
                Next
            End If
            If pbar.Value < pbar.Maximum Then pbar.Value += 1
            If (pbar.Value Mod 100) = 0 Then My.Application.DoEvents()

            Me.Invalidate()
        Next
        'fcnt = Me.view1.중복검사2(0, Me.view1.ActiveSheet.RowCount - 1, A, A, Me.view1.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[신 선로명,전주번호가 같은 경우 :  지선주미포함] 중복검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)
    End Sub

    Private Sub ToolStripMenuItem12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem12.Click

        Dim fcnt As Integer = 0
        Dim A() As Short = New Short() {Me.fp.ActiveSheet.Columns("구관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("구전산화번호").Index}
        NOTICE("중복되는 [구 전산화번호가 같은 경우]를 찾는중입니다...", Me.lb_msg)
        fcnt = Me.fp.ADupCheck2(0, Me.fp.ActiveSheet.RowCount - 1, A, A, Me.fp.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[구 전산화번호가 같은 경우] 중복검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)

    End Sub

    Private Sub ToolStripMenuItem13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem13.Click
        Dim 지선1, 지선2 As String
        Dim fcnt As Integer = 0
        Dim bA() As Short = New Short() {Me.fp.ActiveSheet.Columns("구선로명").Index, _
                                               Me.fp.ActiveSheet.Columns("구전주번호").Index}

        NOTICE("중복되는 [구 선로명, 전주번호가 같은 경우 : 지선주미포함]를 찾는중입니다...", Me.lb_msg)

        '''''검색방법은 1번개체부터 마지막개체까지 풀루프를 돌면서 동일한 놈을 찾는다.
        Dim 원본, 대상 As String 'New System.Text.StringBuilder

        If Not pbar Is Nothing Then
            pbar.Value = 0
            pbar.Minimum = 0
            pbar.Maximum = Me.fp.ActiveSheet.RowCount - 1
        End If

        For A As Integer = 0 To Me.fp.ActiveSheet.RowCount - 1
            원본 = ""
            지선1 = ""

            For Each T As Short In bA
                원본 &= Me.fp.ActiveSheet.Cells(A, T).Value
            Next
            지선1 = Me.fp.ActiveSheet.Cells(A, Me.fp.ActiveSheet.Columns("지선").Index).Text

            If 원본.Trim.ToString <> "" AndAlso 지선1.ToUpper = "FALSE" Then
                For B As Integer = 0 To Me.fp.ActiveSheet.RowCount - 1
                    지선2 = ""
                    If A <> B Then   '//같은라인은 피하고 그렇지 않은 라인의 번호를 확인한다.
                        대상 = ""
                        For Each T As Short In bA
                            대상 &= Me.fp.ActiveSheet.Cells(B, T).Value
                        Next
                        지선2 = Me.fp.ActiveSheet.Cells(B, Me.fp.ActiveSheet.Columns("지선").Index).Text
                        '//원본이나 대상이 지선주가 아니여야한다.
                        '//지선주유무는 컬럼태그 지선 으로 되어있다.
                        If 지선2.ToUpper = "FALSE" AndAlso 원본.Trim.ToString = 대상.Trim.ToString Then  '//지선주일경우에는 뺸다.
                            fcnt += 1
                            Me.fp.ActiveSheet.Cells(A, Me.fp.ACheckBox_ColIndex).Value = True
                            Me.fp.ActiveSheet.Cells(B, Me.fp.ACheckBox_ColIndex).Value = True

                        End If
                    End If
                Next
            End If
            If pbar.Value < pbar.Maximum Then pbar.Value += 1
            Me.Invalidate()
        Next
        'fcnt = Me.view1.중복검사2(0, Me.view1.ActiveSheet.RowCount - 1, A, A, Me.view1.ACheckBox_ColIndex, Me.pbar)
        NOTICE("[구 선로명, 전주번호가 같은 경우 :  지선주미포함] 중복검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)

    End Sub

    Private Sub ToolStripButton4_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton4.Click

    End Sub

    Private Sub ToolStripButton1_Click_1(sender As System.Object, e As System.EventArgs)
        bs.AddNew()
        '//첫위치로 변경한다.
        fp.ActiveSheet.SetActiveCell(fp.ActiveSheet.RowCount, fp.AFirstColumn_Index)

    End Sub

    Private Sub 구신전산화번호가동일한경우ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 구신전산화번호가동일한경우ToolStripMenuItem.Click
        'Dim fcnt As Integer = 0
        Dim A() As Short = New Short() {Me.fp.ActiveSheet.Columns("구관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("구전산화번호").Index}

        Dim B() As Short = New Short() {Me.fp.ActiveSheet.Columns("관리구").Index, _
                                               Me.fp.ActiveSheet.Columns("전산화번호").Index}

        NOTICE("[구,신 전산화번호가 동일한 경우(줄이 다름)]를 찾는중입니다...", Me.lb_msg)
        'fcnt = Me.view1.AdupCheckSR(0, Me.view1.ActiveSheet.RowCount - 1, A, B, Me.view1.ACheckBox_ColIndex, Me.pbar)


        Dim 원본, 대상 As String 'New System.Text.StringBuilder
        Dim fcnt As Integer = 0
        Dim Can As Boolean = False

        pbar.Value = 0
        pbar.Minimum = 0
        pbar.Maximum = Me.fp.ActiveSheet.RowCount - 1

        ''//기존선택자료를 캔슬한다.
        'For RowIndex As Integer = 0 To Me.view1.ActiveSheet.RowCount - 1
        '    Me.view1.ActiveSheet.Cells(RowIndex, Me.view1.ACheckBox_ColIndex).Value = False
        'Next

        For RowIndex As Integer = 0 To Me.fp.ActiveSheet.RowCount - 1
            원본 = ""

            '//기존선택을 모두 해제를 해준다.
            ' Me.view1.ActiveSheet.Cells(RowIndex, Me.view1.ACheckBox_ColIndex).Value = False

            '//원본의 구 전산화번호
            For Each T As Short In A
                원본 &= Me.fp.ActiveSheet.Cells(RowIndex, T).Value
            Next

            'If 원본 = "9593E421" Then
            '    Debug.WriteLine("dsf")
            'End If

            '//원본표시
            If 원본 = "" Then Continue For

            '//세부내역추가로 확인
            For RowIndex2 As Integer = 0 To Me.fp.ActiveSheet.RowCount - 1

                If RowIndex = RowIndex2 Then Continue For '//동일한 줄은 제외  170308

                대상 = ""

                '//여기는 신 전산화번호
                For Each T As Short In B
                    대상 &= Me.fp.ActiveSheet.Cells(RowIndex2, T).Value
                Next
                If 대상 = "" Then Continue For

                If 원본 = 대상 Then
                    fcnt += 1
                    Me.fp.ActiveSheet.Cells(RowIndex, Me.fp.ACheckBox_ColIndex).Value = True
                    Me.fp.ActiveSheet.Cells(RowIndex2, Me.fp.ACheckBox_ColIndex).Value = True
                End If

            Next


            If pbar.Value < pbar.Maximum Then
                pbar.Value += 1
                pbar.Refresh()
            End If
        Next

        NOTICE("[구,신 전산화번호가 동일한 경우(줄이 다름)] 검사 완료(" & fcnt & "개의 데이터가 선택되었습니다)", Me.lb_msg)
    End Sub

    Private Sub 뷰상태초기화ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 뷰상태초기화ToolStripMenuItem.Click
        For c As Integer = 1 To fp_Sheet1.ColumnCount
            fp_Sheet1.Columns(c - 1).Width = 100
        Next
        Application.DoEvents()
    End Sub
End Class