Public Class Frm_V20091231_Nanbang
    Dim Dt As DataTable
    Dim isCopy As Boolean = False
    Dim Init As Boolean = False
    Dim SrcDrv As DataRowView
    Private Sub MdiMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MdiMain.Toggle_Menu_Color(MdiMain.E_MenuIdx.난방기기)
        '  CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me)
        '//프로필 관련

        '//공유데이터셋에 연결한다.
        Me.bs.DataSource = DSET
        Dt = DSET.tbl_nanbangkiki
        '//난방기기
        AddHandler DSET.tbl_nanbangkiki.TableNewRow, AddressOf AddNewDataRow_nanbangkiki
        '//콤보컨트롤 바인딩
        Binding_Zone()

        '//모든컨트롤의 cTrl_enter 를 추가합니다
        BindProperty(CType(Me.SplitContainer1.Panel2.Controls, Control.ControlCollection))

        Me.bsmain = Me.bs
        Me.Init = True

        Try
            Me.bsmain.Position = CEnergy.ARINCLASS.Read_LastPos_Frm(Me)
        Catch ex As Exception
            Me.bsmain.MoveFirst()
        End Try

        bs_CurrentChanged(sender, e)
        Validate_Control()
    End Sub
#Region "Control_Enter"
    Private Sub BindProperty(ByVal Ctl As Control.ControlCollection)
        For Each C As Control In Ctl
            If C.Controls.Count > 1 Then
                BindProperty(C.Controls)
            Else
                If C.GetType.ToString.ToUpper.IndexOf("MYTB") <> -1 Then
                    AddHandler CType(C, MyTb).KeyDown, AddressOf TextBOx_KeyDown
                ElseIf C.GetType.ToString.ToUpper.IndexOf("MYCMB") <> -1 Then
                    AddHandler CType(C, MyCmb).KeyDown, AddressOf Cmd_KeyDown
                End If
            End If
        Next
    End Sub

    Private Sub TextBOx_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.Enter AndAlso e.Control Then
            Try
                Dim Field As String = (CType(sender, MyTb).DataBindings.Item("text").BindingMemberInfo.BindingField)
                For Each Dr As DataRow In Dt.Select(Me.bs.Filter, "")
                    Dr(Field) = CType(sender, MyTb).Text
                Next
                Work_msg_timer("모든값이 변경되었습니다", 25)
            Catch ex As Exception

            End Try

        End If
    End Sub
    Private Sub Cmd_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.Enter AndAlso e.Control Then
            Try
                Dim Field As String = (CType(sender, MyCmb).DataBindings.Item("selectedvalue").BindingMemberInfo.BindingField)
                For Each Dr As DataRow In Dt.Select(Me.bs.Filter, "")
                    Dr(Field) = CType(sender, MyCmb).SelectedValue
                Next
                Work_msg_timer("모든값이 변경되었습니다", 25)
            Catch ex As Exception

            End Try
        End If
    End Sub
#End Region
#Region "난방기기"

    Private Sub ToolStripButton48_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_add.Click
        If Not EndEdit(Me.bs) Then Return
        Me.bs.AddNew()
        INitRow(Me.Controls)
    End Sub


    Private Sub ToolStripButton49_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_Del.Click
        Dbbase.DelCrow(Me.bs, True)
    End Sub

    Private Sub ToolStripButton51_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_cancel.Click
        If Not EndEdit(Me.bs) Then Return
        Data_Cancel(DSET.tbl_profile, Nothing)
    End Sub


    Private Sub MdiMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me, Me.bsmain.Position, True)
    End Sub

    Private Sub MdiMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Select Case e.KeyCode
            Case Keys.F12
        End Select
    End Sub

    Private Function GetMaxCode(ByVal dt As DataTable) As String
        Try
            Dim Dr As DataRow = dt.Select("", "code desc")(0)
            Return Format(CInt(Dr("code")) + 1, "0000")
        Catch ex As Exception
            Return "0001"
        End Try
    End Function

    Private Sub Cmb_DeleteVal(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.Delete Then
            CType(sender, ComboBox).SelectedValue = ""
        End If
    End Sub

    Private Sub Binding_Zone()

        '//난방기기
        Dim bs_열생산기기방식NCMB As New BindingSource(DSET, "tbl_common")
        bs_열생산기기방식NCMB.Filter = "gubun='1020'"
        bs_열생산기기방식NCMB.Sort = "code"
        Me.열생산기기방식NCMB.DataSource = bs_열생산기기방식NCMB
        열생산기기방식NCMB.DisplayMember = "name"
        열생산기기방식NCMB.ValueMember = "name"
        Me.열생산기기방식NCMB.DataBindings.Add("selectedvalue", Me.bs, "열생산기기방식")
        'AddHandler 열생산기기방식NCMB.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_사용연료NCMB As New BindingSource(DSET, "tbl_common")
        bs_사용연료NCMB.Filter = "gubun='1021'"
        bs_사용연료NCMB.Sort = "code"
        Me.사용연료NCMB.DataSource = bs_사용연료NCMB
        사용연료NCMB.DisplayMember = "name"
        사용연료NCMB.ValueMember = "name"
        Me.사용연료NCMB.DataBindings.Add("selectedvalue", Me.bs, "사용연료")
        'AddHandler 사용연료NCMB.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_운전방식NCMB As New BindingSource(DSET, "tbl_common")
        bs_운전방식NCMB.Filter = "gubun='1035'"
        bs_운전방식NCMB.Sort = "code"
        Me.운전방식NCMB.DataSource = bs_운전방식NCMB
        운전방식NCMB.DisplayMember = "name"
        운전방식NCMB.ValueMember = "name"
        Me.운전방식NCMB.DataBindings.Add("selectedvalue", Me.bs, "운전방식")
        'AddHandler 운전방식NCMB.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_보일러방식NCMB As New BindingSource(DSET, "tbl_common")
        bs_보일러방식NCMB.Filter = "gubun='1036'"
        bs_보일러방식NCMB.Sort = "code"
        Me.보일러방식NCMB.DataSource = bs_보일러방식NCMB
        보일러방식NCMB.DisplayMember = "name"
        보일러방식NCMB.ValueMember = "name"
        Me.보일러방식NCMB.DataBindings.Add("selectedvalue", Me.bs, "보일러방식")
        'AddHandler 보일러방식NCMB.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_지역난방방식NCMB As New BindingSource(DSET, "tbl_common")
        bs_지역난방방식NCMB.Filter = "gubun='1037'"
        bs_지역난방방식NCMB.Sort = "code"
        Me.지역난방방식NCMB.DataSource = bs_지역난방방식NCMB
        지역난방방식NCMB.DisplayMember = "name"
        지역난방방식NCMB.ValueMember = "name"
        Me.지역난방방식NCMB.DataBindings.Add("selectedvalue", Me.bs, "지역난방방식")
        'AddHandler 지역난방방식NCMB.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_단열등급NCMB As New BindingSource(DSET, "tbl_common")
        bs_단열등급NCMB.Filter = "gubun='1038'"
        bs_단열등급NCMB.Sort = "code"
        Me.단열등급NCMB.DataSource = bs_단열등급NCMB
        단열등급NCMB.DisplayMember = "name"
        단열등급NCMB.ValueMember = "name"
        Me.단열등급NCMB.DataBindings.Add("selectedvalue", Me.bs, "단열등급")
        'AddHandler 단열등급NCMB.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_축열탱크방식NCMB As New BindingSource(DSET, "tbl_common")
        bs_축열탱크방식NCMB.Filter = "gubun='1039'"
        bs_축열탱크방식NCMB.Sort = "code"
        Me.축열탱크방식NCMB.DataSource = bs_축열탱크방식NCMB
        축열탱크방식NCMB.DisplayMember = "name"
        축열탱크방식NCMB.ValueMember = "name"
        Me.축열탱크방식NCMB.DataBindings.Add("selectedvalue", Me.bs, "축열탱크방식")
        ' AddHandler 축열탱크방식NCMB.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_배관망유형ComboBox As New BindingSource(DSET, "tbl_common")
        bs_배관망유형ComboBox.Filter = "gubun='1040'"
        bs_배관망유형ComboBox.Sort = "code"
        Me.배관망유형ComboBox.DataSource = bs_배관망유형ComboBox
        배관망유형ComboBox.DisplayMember = "name"
        배관망유형ComboBox.ValueMember = "name"
        Me.배관망유형ComboBox.DataBindings.Add("selectedvalue", Me.bs, "배관망유형")
        'AddHandler 배관망유형ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_펌프교정계수ComboBox As New BindingSource(DSET, "tbl_common")
        bs_펌프교정계수ComboBox.Filter = "gubun='1002'"
        bs_펌프교정계수ComboBox.Sort = "code"
        Me.펌프교정계수ComboBox.DataSource = bs_펌프교정계수ComboBox
        펌프교정계수ComboBox.DisplayMember = "name"
        펌프교정계수ComboBox.ValueMember = "name"
        Me.펌프교정계수ComboBox.DataBindings.Add("selectedvalue", Me.bs, "펌프교정계수")
        'AddHandler 펌프교정계수ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_펌프제어유형ComboBox As New BindingSource(DSET, "tbl_common")
        bs_펌프제어유형ComboBox.Filter = "gubun='1041'"
        bs_펌프제어유형ComboBox.Sort = "code"
        Me.펌프제어유형ComboBox.DataSource = bs_펌프제어유형ComboBox
        펌프제어유형ComboBox.DisplayMember = "name"
        펌프제어유형ComboBox.ValueMember = "name"
        Me.펌프제어유형ComboBox.DataBindings.Add("selectedvalue", Me.bs, "펌프제어유형")
        'AddHandler 펌프제어유형ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_분배시스템방식ComboBox As New BindingSource(DSET, "tbl_common")
        bs_분배시스템방식ComboBox.Filter = "gubun='1042'"
        bs_분배시스템방식ComboBox.Sort = "code"
        Me.분배시스템방식ComboBox.DataSource = bs_분배시스템방식ComboBox
        분배시스템방식ComboBox.DisplayMember = "name"
        분배시스템방식ComboBox.ValueMember = "name"
        Me.분배시스템방식ComboBox.DataBindings.Add("selectedvalue", Me.bs, "분배시스템방식")
        'AddHandler 분배시스템방식ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_순환유무ComboBox As New BindingSource(DSET, "tbl_common")
        bs_순환유무ComboBox.Filter = "gubun='1032'"
        bs_순환유무ComboBox.Sort = "code"
        Me.순환유무ComboBox.DataSource = bs_순환유무ComboBox
        순환유무ComboBox.DisplayMember = "name"
        순환유무ComboBox.ValueMember = "name"
        Me.순환유무ComboBox.DataBindings.Add("selectedvalue", Me.bs, "순환유무")
        'AddHandler 순환유무ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_펌프제어ComboBox As New BindingSource(DSET, "tbl_common")
        bs_펌프제어ComboBox.Filter = "gubun='1043'"
        bs_펌프제어ComboBox.Sort = "code"
        Me.펌프제어ComboBox.DataSource = bs_펌프제어ComboBox
        펌프제어ComboBox.DisplayMember = "name"
        펌프제어ComboBox.ValueMember = "name"
        Me.펌프제어ComboBox.DataBindings.Add("selectedvalue", Me.bs, "펌프제어")
        'AddHandler 펌프제어ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_신재생연결여부ComboBox As New BindingSource(DSET, "tbl_common")
        bs_신재생연결여부ComboBox.Filter = "gubun='1044'"
        bs_신재생연결여부ComboBox.Sort = "code"
        Me.신재생연결여부ComboBox.DataSource = bs_신재생연결여부ComboBox
        신재생연결여부ComboBox.DisplayMember = "name"
        신재생연결여부ComboBox.ValueMember = "name"
        Me.신재생연결여부ComboBox.DataBindings.Add("selectedvalue", Me.bs, "신재생연결여부")
        'AddHandler 신재생연결여부ComboBox.KeyDown, AddressOf Cmb_DeleteVal



        Dim bs_연결된시스템 As New BindingSource(DSET, "tbl_new")
        bs_연결된시스템.Sort = "code"
        Me.cmb_신재생.DataSource = bs_연결된시스템
        cmb_신재생.DisplayMember = "설명"
        cmb_신재생.ValueMember = "code"
        Me.cmb_신재생.DataBindings.Add("selectedvalue", Me.bs, "연결된시스템")
        'AddHandler 연결된시스템ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_히트펌프연료 As New BindingSource(DSET, "tbl_common")
        bs_히트펌프연료.Filter = "gubun='1086'"
        bs_히트펌프연료.Sort = "code"
        Me.cmb_히트사용연료.DataSource = bs_히트펌프연료
        cmb_히트사용연료.DisplayMember = "name"
        cmb_히트사용연료.ValueMember = "name"
        Me.cmb_히트사용연료.DataBindings.Add("selectedvalue", Me.bs, "히트연료")

        Dim bs_히트펌프종류 As New BindingSource(DSET, "tbl_common")
        bs_히트펌프종류.Filter = "gubun='1087'"
        bs_히트펌프종류.Sort = "code"
        Me.cmb_히트펌프시스템종류.DataSource = bs_히트펌프종류
        cmb_히트펌프시스템종류.DisplayMember = "name"
        cmb_히트펌프시스템종류.ValueMember = "name"
        Me.cmb_히트펌프시스템종류.DataBindings.Add("selectedvalue", Me.bs, "히트펌프시스템종류")
        'AddHandler 신재생연결여부ComboBox.KeyDown, AddressOf Cmb_DeleteVal
    End Sub

    Private Sub Binding_nanbangkiki()

    End Sub
    Private Sub AddNewDataRow_nanbangkiki(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs)
        e.Row.Item("code") = GetMaxCode(DSET.tbl_nanbangkiki)
    End Sub
#End Region

    Private Sub 신재생연결여부ComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 신재생연결여부ComboBox.SelectedIndexChanged
        Validate_Control()
    End Sub

    Private Sub 축열탱크방식NCMB_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 축열탱크방식NCMB.SelectedIndexChanged
        Validate_Control()
    End Sub

    Private Sub 운전방식NCMB_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 운전방식NCMB.SelectedIndexChanged
        Validate_Control()
    End Sub

    Private Sub Validate_Control()
        If Not Init Then Return
        If isCopy Then Return

        Try
            If Me.신재생연결여부ComboBox.SelectedIndex = 0 Then
                cmb_신재생.Enabled = False
            Else
                cmb_신재생.Enabled = True
            End If
        Catch ex As Exception

        End Try
        Try
            If Me.축열탱크방식NCMB.SelectedIndex = 0 Then
                축열제척NTb.Enabled = False
                MyTb1.Enabled = False
            Else
                축열제척NTb.Enabled = True
                MyTb1.Enabled = True
            End If
        Catch ex As Exception

        End Try


        Try
            If Me.운전방식NCMB.SelectedIndex = 0 Then
                tb_보일러대수다수.Enabled = False
            Else
                tb_보일러대수다수.Enabled = True
            End If
        Catch ex As Exception

        End Try

        Try
            Select Case Me.열생산기기방식NCMB.SelectedValue.ToString.Trim
                Case "보일러"  '//보일러
                    사용연료NCMB.Enabled = True
                    Me.급수온도NTb1.Enabled = True
                    Me.환수온도NTb1.Enabled = True
                    보일러정격출력NTb.Enabled = True
                    열교환기정격출력NTb.Enabled = False
                    운전방식NCMB.Enabled = True
                    정격보일러효율NTb.Enabled = True
                    보일러방식NCMB.Enabled = True
                    지역난방방식NCMB.Enabled = False
                    Me.단열등급NCMB.Enabled = False
                    '/// 2011. 1. 31 수정
                    Me.배관망유형ComboBox.Enabled = True
                    Me.펌프교정계수ComboBox.Enabled = True
                    Me.펌프제어유형ComboBox.Enabled = True
                    Me.펌프동력NTb.Enabled = True
                    '// 2011. 1. 31 수정

                Case "지역난방"  '//지역난방
                    사용연료NCMB.Enabled = False
                    Me.급수온도NTb1.Enabled = True
                    Me.환수온도NTb1.Enabled = True
                    보일러정격출력NTb.Enabled = False
                    열교환기정격출력NTb.Enabled = True
                    운전방식NCMB.Enabled = False
                    tb_보일러대수다수.Enabled = False
                    정격보일러효율NTb.Enabled = True
                    보일러방식NCMB.Enabled = False
                    지역난방방식NCMB.Enabled = True
                    Me.단열등급NCMB.Enabled = True
                    '/// 2011. 1. 31 수정
                    Me.배관망유형ComboBox.Enabled = True
                    Me.펌프교정계수ComboBox.Enabled = True
                    Me.펌프제어유형ComboBox.Enabled = True
                    Me.펌프동력NTb.Enabled = True
                    '// 2011. 1. 31 수정

                Case "전기보일러"  '//전기보일러
                    사용연료NCMB.Enabled = False
                    Me.급수온도NTb1.Enabled = True
                    Me.환수온도NTb1.Enabled = True
                    보일러정격출력NTb.Enabled = True
                    열교환기정격출력NTb.Enabled = False
                    운전방식NCMB.Enabled = False
                    정격보일러효율NTb.Enabled = True
                    보일러방식NCMB.Enabled = False
                    지역난방방식NCMB.Enabled = False
                    Me.단열등급NCMB.Enabled = False
                    '/// 2011. 1. 31 수정
                    Me.배관망유형ComboBox.Enabled = True
                    Me.펌프교정계수ComboBox.Enabled = True
                    Me.펌프제어유형ComboBox.Enabled = True
                    Me.펌프동력NTb.Enabled = True
                    '// 2011. 1. 31 수정


                Case "히트펌프" '//히트펌프
                    사용연료NCMB.Enabled = False
                    Me.급수온도NTb1.Enabled = True
                    Me.환수온도NTb1.Enabled = True
                    보일러정격출력NTb.Enabled = False
                    열교환기정격출력NTb.Enabled = False
                    운전방식NCMB.Enabled = False
                    정격보일러효율NTb.Enabled = False
                    보일러방식NCMB.Enabled = False
                    지역난방방식NCMB.Enabled = False
                    Me.단열등급NCMB.Enabled = False
                    '/// 2011. 1. 31 수정
                    Me.배관망유형ComboBox.Enabled = True
                    Me.펌프교정계수ComboBox.Enabled = True
                    Me.펌프제어유형ComboBox.Enabled = True
                    Me.펌프동력NTb.Enabled = True
                    '// 2011. 1. 31 수정

            End Select
            Me.bs.EndEdit()
        Catch ex As Exception

        End Try

        Try
            If Me.열생산기기방식NCMB.Text = "히트펌프" Then
                cmb_히트사용연료.Enabled = True
                tb_히트용량.Enabled = True
                tb_히트정격7.Enabled = True
                tb_히트정격10.Enabled = True
                tb_히트길이.Enabled = True
                cmb_히트펌프시스템종류.Enabled = True
            Else
                cmb_히트사용연료.Enabled = False
                tb_히트용량.Enabled = False
                tb_히트정격7.Enabled = False
                tb_히트정격10.Enabled = False
                tb_히트길이.Enabled = False
                cmb_히트펌프시스템종류.Enabled = False
            End If
        Catch ex As Exception

        End Try

        If Me.분배시스템방식ComboBox.SelectedIndex >= 0 Then
            Try
                Select Case Me.분배시스템방식ComboBox.Text
                    Case "중앙식"
                        순환유무ComboBox.Enabled = True
                        펌프제어ComboBox.Enabled = True
                        펌프동력급탕NTb.Enabled = True
                        건물길이NTb.Enabled = True
                        건물넓이NTb.Enabled = True
                        열공급층수NTb.Enabled = True
                        층고NTb.Enabled = True
                        Me.RadioButton1.Enabled = True
                        Me.RadioButton2.Enabled = True
                        If RadioButton2.Checked = True Then
                            Me.급탕배관길이NTB.Enabled = True
                        End If
                    Case "개별식"
                        순환유무ComboBox.Enabled = False
                        펌프제어ComboBox.Enabled = True
                        펌프동력급탕NTb.Enabled = True
                        건물길이NTb.Enabled = False
                        건물넓이NTb.Enabled = False
                        열공급층수NTb.Enabled = False
                        층고NTb.Enabled = False
                        Me.급탕배관길이NTB.Enabled = False
                        Me.RadioButton1.Enabled = False
                        Me.RadioButton2.Enabled = False
                End Select
            Catch ex As Exception

            End Try
        End If

        If Me.급탕배관길이NTB.Text <> "" AndAlso Me.급탕배관길이NTB.Text <> "0" Then    '//배관길이 값을통해서 라디오버튼설정
            Me.RadioButton2.Checked = True
            건물길이NTb.Enabled = False
            건물넓이NTb.Enabled = False
            열공급층수NTb.Enabled = False
            층고NTb.Enabled = False
        ElseIf Me.분배시스템방식ComboBox.Text = "중앙식" Then
            Me.RadioButton1.Checked = True
            건물길이NTb.Enabled = True
            건물넓이NTb.Enabled = True
            열공급층수NTb.Enabled = True
            층고NTb.Enabled = True

        End If



    End Sub

    Private Sub 열생산기기방식NCMB_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles 열생산기기방식NCMB.KeyDown
        If e.KeyCode = Keys.V And e.Control Then
            isCopy = True
            ' Clear_Control(Me.TabPage2)

            e.Handled = True
            e.SuppressKeyPress = False
            '//클립보드붙여넣기
            Dim CB() As String = My.Computer.Clipboard.GetText.Split(CChar(vbCrLf))
            If CB.GetUpperBound(0) <> 58 Then
                MsgBox("붙여넣기가 호환되는 데이터가 아닙니다.", MsgBoxStyle.Information, "확인")
                Return
            End If

            For ii As Integer = 0 To CType(CB(0).Split(CChar(vbTab)), String()).GetUpperBound(0)
                If Me.bs.Count = 0 OrElse ii > 0 Then Me.bt_Add.PerformClick() '//한줄추가


                Dim Cnt As Short = 0
                For i As Integer = 0 To CB.GetUpperBound(0)
                    Select Case i
                        Case 0
                            CType(bs.Current, DataRowView)("설명") = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 0 + 8 '//사용프로필 앞에 두개를 숫자4자리로변환 '//뒷부분이 와존히 다른느낌 ^^;;어 아닌데.. 수정안된거예요..
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.열생산기기방식NCMB.SelectedIndex = 0
                            Else
                                Me.열생산기기방식NCMB.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            'Me.열생산기기방식NCMB.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 1 + 8 '//공란
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.사용연료NCMB.SelectedIndex = 0
                            Else
                                Me.사용연료NCMB.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            'Me.사용연료NCMB.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 2 + 8  '//면적
                            Me.급수온도NTb1.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 3 + 8
                            Me.환수온도NTb1.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 4 + 8
                            Me.보일러정격출력NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 5 + 8
                            Me.열교환기정격출력NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 6 + 8
                        Case 15
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.운전방식NCMB.SelectedIndex = 0
                            Else
                                Me.운전방식NCMB.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            'Me.운전방식NCMB.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 8 + 8
                            Me.tb_보일러대수다수.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 11 + 8
                            'Me.TabControl12.SelectedIndex = 1
                            Me.정격보일러효율NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 13 + 8
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.보일러방식NCMB.SelectedIndex = 0
                            Else
                                Me.보일러방식NCMB.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If
                            'Me.보일러방식NCMB.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 23
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.지역난방방식NCMB.SelectedIndex = 0
                            Else
                                Me.지역난방방식NCMB.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            'Me.지역난방방식NCMB.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 16 + 8
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.단열등급NCMB.SelectedIndex = 0
                            Else
                                Me.단열등급NCMB.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            'Me.단열등급NCMB.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))

                        Case 25    '//히트펌프
                        Case 26    '//사용연료
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.cmb_히트사용연료.SelectedIndex = 0
                            Else
                                Me.cmb_히트사용연료.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If
                        Case 27
                            Me.tb_히트용량.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 28
                            Me.tb_히트정격7.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 29
                            Me.tb_히트정격10.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 30
                            Me.tb_히트길이.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 31
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.cmb_히트펌프시스템종류.SelectedIndex = 0
                            Else
                                Me.cmb_히트펌프시스템종류.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                        Case 19 + 8 + 6 + 1
                            ' Me.TabControl12.SelectedIndex = 2
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.축열탱크방식NCMB.SelectedIndex = 0
                            Else
                                Me.축열탱크방식NCMB.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If
                        Case 20 + 8 + 6 + 1
                            Me.축열제척NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 21 + 8 + 6 + 1
                            Me.MyTb1.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 24 + 8 + 6 + 1
                            ' Me.TabControl12.SelectedIndex = 3
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.배관망유형ComboBox.SelectedIndex = 0
                            Else
                                Me.배관망유형ComboBox.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            ' Me.배관망유형ComboBox.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 25 + 8 + 6 + 1
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.펌프교정계수ComboBox.SelectedIndex = 0
                            Else
                                Me.펌프교정계수ComboBox.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            ' Me.펌프교정계수ComboBox.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 26 + 8 + 6 + 1
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.펌프제어유형ComboBox.SelectedIndex = 0
                            Else
                                Me.펌프제어유형ComboBox.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If
                            ' Me.펌프제어유형ComboBox.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 27 + 8 + 6 + 1
                            Me.펌프동력NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 30 + 8 + 6 + 1 '//33

                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                'MsgBox("null")
                                Me.분배시스템방식ComboBox.SelectedIndex = 0
                            Else
                                'Dim iii As Short = 0

                                'For Each C As DataRowView In Me.분배시스템방식ComboBox.Items
                                '    If C("name").ToString.Trim = CB(i).Split(CChar(vbTab))(ii).Trim Then
                                '        Me.분배시스템방식ComboBox.SelectedIndex = iii
                                '    End If
                                '    iii += 1
                                'Next
                                '      MsgBox(CB(i).Split(CChar(vbTab))(ii).Trim)
                                Me.분배시스템방식ComboBox.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If


                            'Me.분배시스템방식ComboBox.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 31 + 8 + 6 + 1
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.순환유무ComboBox.SelectedIndex = 0
                            Else
                                Me.순환유무ComboBox.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            'Me.순환유무ComboBox.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 32 + 8 + 6 + 1
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.펌프제어ComboBox.SelectedIndex = 0
                            Else
                                Me.펌프제어ComboBox.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            ' Me.펌프제어ComboBox.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 33 + 8 + 6 + 1
                            Me.펌프동력급탕NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 35 + 8 + 6 + 1
                            Me.건물길이NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 36 + 8 + 6 + 1
                            Me.건물넓이NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 37 + 8 + 6 + 1
                            Me.열공급층수NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 38 + 8 + 6 + 1
                            Me.층고NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 41 + 8 + 6 + 1
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.신재생연결여부ComboBox.SelectedIndex = 0
                            Else
                                Me.신재생연결여부ComboBox.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            ' Me.신재생연결여부ComboBox.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 57 '42 + 8 + 6 + 1
                            If CB(i).Split(CChar(vbTab))(ii).Trim = "" Then
                                Me.cmb_신재생.SelectedIndex = 0
                            Else
                                Me.cmb_신재생.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                            End If

                            'Me.연결된시스템ComboBox.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                    End Select
                Next
            Next

            Me.bs.EndEdit()
            isCopy = False
            Me.Validate_Control()
        End If
     
    End Sub

    Private Sub 열생산기기방식NCMB_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 열생산기기방식NCMB.SelectedIndexChanged
        Validate_Control()
    End Sub

    Private Sub bs_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bs.CurrentChanged
        If Not Init Then Return
        Dim Drv As DataRowView = CType(bs.Current, DataRowView)

        Try
            Dim DR() As DataRow = DSET.tbl_zone.Select("열생산난방생산기기='" & Drv("code").ToString & "' or 공조난방생산기기='" & Drv("code").ToString & "'")
            Me.lbl_cnt1.Text = CStr(DR.GetUpperBound(0) + 1)
        Catch ex As Exception
            Me.lbl_cnt1.Text = "0"
        End Try

        Try
            Dim DR() As DataRow = DSET.tbl_zone.Select("열생산급탕생산기기='" & Drv("code").ToString & "'")
            Me.lbl_cnt2.Text = CStr(DR.GetUpperBound(0) + 1)
        Catch ex As Exception
            Me.lbl_cnt2.Text = "0"
        End Try
        Me.bs.EndEdit()
    End Sub

    Private Sub Frm_V20091231_Zone_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
        If e.Delta < 0 Then
            If Me.bs.Position < Me.bs.Count Then Me.bs.Position += 1
        Else
            If Me.bs.Position > 0 Then Me.bs.Position -= 1
        End If
        Me.Validate()
        My.Application.DoEvents()
    End Sub


    Private Sub bt_Del_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles bt_Del.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Right Then
            If MsgBox("전체삭제를 하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
                Dim dR() As DataRow = DSET.tbl_nanbangkiki.Select(Me.bs.Filter, "")
                For i As Integer = dR.GetUpperBound(0) To 0 Step -1
                    dR(i).Delete()
                Next
                DSET.tbl_nanbangkiki.AcceptChanges()
            End If
        End If
    End Sub


    Private Sub dv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dv.MouseUp
        If Prj.UserAuthType = "ADMIN" OrElse Prj.UserAuthType = "BOTH" OrElse Prj.UserAuthType = "BOTH2" OrElse Prj.UserAuthType = "BOTH1" Then  '//2011.03.08 추가
            If e.Button = Windows.Forms.MouseButtons.Right Then
                Dim Frm_FilterA As New Frm_Filter
                Frm_FilterA.ColumTitle = getColCaption(Me.Dt)
                Frm_FilterA.ColumList = getColName(Me.Dt)
                Frm_FilterA.Colorlist = "연결된시스템"
                Frm_FilterA.Numfield = ""    '//20100618  Color 리스트처럼 , 구분해서 필드들을 모두 넣으세요.(=, >= 등을 사용하기 위해서는 해당 항목을 추가 요망)
                Frm_FilterA.Default_Filter = "code <> '0'"
                If Frm_FilterA.ShowDialog <> Windows.Forms.DialogResult.OK Then Return '//창떳을떄 확인아ㅣ고 취소눌르면 다음을 수행하지않는다는거에요.
                Dim Filter As String = Frm_FilterA.tb_filter.Text   '//값은 아까 그 텍박에 잇구요.
                Try
                    Me.bs.Filter = Filter

                    '//바꾸기값이 있으면 변경 20100618
                    If Frm_FilterA.cmb_fieldc.SelectedIndex >= 0 AndAlso Frm_FilterA.cmb_fieldc.Text.ToLower <> "code" AndAlso _
                    Frm_FilterA.tb_valuec.Text <> "" Then
                        Dim Drow() As DataRow = Me.Dt.Select(Filter)
                        For Each Dr As DataRow In Drow
                            Dr(Frm_FilterA.cmb_fieldc.Text) = Frm_FilterA.tb_valuec.Text
                        Next
                        MsgBox("바꾸기 완료", MsgBoxStyle.Information, "확인")
                    End If

                Catch ex As Exception
                    Me.bs.Filter = ""
                End Try
            End If
        End If
    End Sub

    Private Sub dv_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dv.KeyDown
        '//여기보시면   alt+d 누르면  한줄을 경고없이(falsE)삭제하도록 햇어요.. 사실원래 밋alt +d 인데.. ㅎㅎ 잘못해서 ctrl 됫다는
        If Prj.UserAuthType = "ADMIN" OrElse Prj.UserAuthType = "BOTH" OrElse Prj.UserAuthType = "BOTH2" OrElse Prj.UserAuthType = "BOTH1" Then  '//2011.03.08 추가
            Select Case e.KeyCode
                Case Keys.D
                    If e.Alt Then
                        Dbbase.DelCrow(Me.bs, False)
                    End If
                Case Keys.C
                    If e.Control Then
                        Me.SrcDrv = Me.bs.Current
                        If Me.SrcDrv Is Nothing Then
                            MsgBox("저장할 ROW가 없습니다", MsgBoxStyle.Information, "확인")
                            Return
                        End If
                        ' My.Computer.Clipboard.SetData("ZDATA", Drv)
                    End If
                Case Keys.V
                    If e.Control Then
                        If Me.SrcDrv Is Nothing Then Return
                        Me.bt_add.PerformClick()  '//신규추가
                        Dim NewDrv As DataRowView = Me.bs.Current

                        For Each C As DataColumn In Me.Dt.Columns
                            If C.ColumnName.ToUpper = "CODE" Then
                            ElseIf C.ColumnName.ToUpper = "설명" Then
                                NewDrv(C.ColumnName) = SrcDrv(C.ColumnName) & "#1"
                            Else
                                NewDrv(C.ColumnName) = SrcDrv(C.ColumnName)
                            End If
                        Next
                        Me.bs.EndEdit()
                        bs.MoveLast()
                    End If
            End Select
        End If
    End Sub

    Private Sub lbl_cnt2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbl_cnt2.TextChanged

        Try
            If Me.lbl_cnt2.Text = "0" Then
                GroupBox10.Enabled = False
                GroupBox9.Enabled = False
            Else
                GroupBox10.Enabled = True
                GroupBox9.Enabled = True
            End If
        Catch ex As Exception

        End Try

    End Sub

    Private Sub 분배시스템방식ComboBox_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles 분배시스템방식ComboBox.SelectedValueChanged
        Validate_Control()
    End Sub

    Private Sub lbl_cnt1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbl_cnt1.TextChanged

        Try
            If Me.lbl_cnt1.Text = "0" Then
                GroupBox8.Enabled = False
            Else
                GroupBox8.Enabled = True
            End If
        Catch ex As Exception

        End Try

    End Sub

    Private Sub 분배시스템방식ComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 분배시스템방식ComboBox.SelectedIndexChanged

    End Sub

    Private Sub 급탕배관길이NTB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 급탕배관길이NTB.TextChanged
        If Me.급탕배관길이NTB.Text <> "" AndAlso Me.급탕배관길이NTB.Text <> "0" Then    '//배관길이에 값이 바뀌면 체크변경
            Me.RadioButton2.Checked = True
        End If
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged, RadioButton1.CheckedChanged
        If Me.RadioButton2.Checked = False Then    '//표준치로 선택되면 배관길이값을 지워버림
            Me.급탕배관길이NTB.Text = ""
            Me.급탕배관길이NTB.Enabled = False
            Me.건물길이NTb.Enabled = True
            Me.건물넓이NTb.Enabled = True
            Me.열공급층수NTb.Enabled = True
            Me.층고NTb.Enabled = True
        Else
            Me.건물길이NTb.Enabled = False
            Me.건물넓이NTb.Enabled = False
            Me.열공급층수NTb.Enabled = False
            Me.층고NTb.Enabled = False
            Me.급탕배관길이NTB.Enabled = True
        End If
    End Sub

End Class