Public Class Frm_New
    Dim Init As Boolean = False
    Dim SrcDrv As DataRowView

#Region "data Base 변경여부및 적용방법"

    '''변경된내용을적용한다.
    Public Overrides Function AcceptChanged() As Boolean
        bs.EndEdit()
        Dim BaseDS As DataSet = CType(bs.DataSource, DataSet)
        Dim BaseDT As DataTable = BaseDS.Tables(bs.DataMember)
        BaseDT.AcceptChanges()
        Return True
    End Function

    '''변경된내용이있다면 취소한다.
    Public Overrides Function RejectChanged() As Boolean
        Dim BaseDS As DataSet = CType(bs.DataSource, DataSet)
        Dim BaseDT As DataTable = BaseDS.Tables(bs.DataMember)
        BaseDT.RejectChanges()
        Return True
    End Function

    '''데이터에변형이있었는가?
    Public Overrides Function HasChanged() As Boolean
        bs.EndEdit()
        Dim BaseDS As DataSet = CType(bs.DataSource, DataSet)
        Dim BaseDT As DataTable = BaseDS.Tables(bs.DataMember)
        Dim ChangeDT As DataTable = BaseDT.GetChanges
        If Not ChangeDT Is Nothing Then Return True
        Return False
    End Function

    '''기본데이터테이블을 반환합니다.
    Public Function DT() As DataTable
        Dim BaseDS As DataSet = CType(bs.DataSource, DataSet)
        Return BaseDS.Tables(bs.DataMember)
    End Function


#End Region



    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
        'If Me.bs.Count < 1 Then
        '    Me.bs.AddNew()
        '    Dim DRv As DataRowView = bs.Current
        '    DRv("code") = Me.GetMaxCode(DSET.tbl_new)
        'End If

        '//신재생
        AddHandler DSET.tbl_new.TableNewRow, AddressOf AddNewDataRow_new

        '//콤보컨트롤 바인딩
        Binding_Zone()

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


        Me.bs.Filter = "code <> '0' and 기기종류 = '" + Me.Parameter + "'"
        Me.lb_grpname.Text = Me.Parameter

        Me.Init = True


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

        bs_CurrentChanged(sender, e)
        Me.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 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_기기종류ComboBox As New BindingSource(DSET, "tbl_common")
        bs_기기종류ComboBox.Filter = "gubun='1028'"
        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='1066'"
        bs_가동연료ComboBox.Sort = "code"
        Me.cmb_가동연료.DataSource = bs_가동연료ComboBox
        cmb_가동연료.DisplayMember = "name"
        cmb_가동연료.ValueMember = "name"
        Me.cmb_가동연료.DataBindings.Add("selectedvalue", Me.bs, "가동연료")
        'AddHandler 지열가동연료ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_태양열종류ComboBox As New BindingSource(DSET, "tbl_common")
        bs_태양열종류ComboBox.Filter = "gubun='1057'"
        bs_태양열종류ComboBox.Sort = "code"
        Me.cmb_태양열시스템종류.DataSource = bs_태양열종류ComboBox
        cmb_태양열시스템종류.DisplayMember = "name"
        cmb_태양열시스템종류.ValueMember = "name"
        Me.cmb_태양열시스템종류.DataBindings.Add("selectedvalue", Me.bs, "태양열종류")
        'AddHandler 태양열종류ComboBox.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_집열기유형ComboBox As New BindingSource(DSET, "tbl_common")
        bs_집열기유형ComboBox.Filter = "gubun='1058'"
        bs_집열기유형ComboBox.Sort = "code"
        Me.cmb_집열기유형.DataSource = bs_집열기유형ComboBox
        cmb_집열기유형.DisplayMember = "name"
        cmb_집열기유형.ValueMember = "name"
        Me.cmb_집열기유형.DataBindings.Add("selectedvalue", Me.bs, "집열기유형")
        'AddHandler 집열기유형ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        '집열기유형ComboBox

        Dim bs_집열판방위ComboBox As New BindingSource(DSET, "tbl_common")
        bs_집열판방위ComboBox.Filter = "gubun='1059'"
        bs_집열판방위ComboBox.Sort = "code"
        Me.cmb_집열판방위.DataSource = bs_집열판방위ComboBox
        cmb_집열판방위.DisplayMember = "name"
        cmb_집열판방위.ValueMember = "name"
        Me.cmb_집열판방위.DataBindings.Add("selectedvalue", Me.bs, "집열판방위")
        'AddHandler 집열판방위ComboBox.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_태양열시스템의성능ComboBox As New BindingSource(DSET, "tbl_common")
        bs_태양열시스템의성능ComboBox.Filter = "gubun='1060'"
        bs_태양열시스템의성능ComboBox.Sort = "code"
        Me.cmb_태양열시스템의성능.DataSource = bs_태양열시스템의성능ComboBox
        cmb_태양열시스템의성능.DisplayMember = "name"
        cmb_태양열시스템의성능.ValueMember = "name"
        Me.cmb_태양열시스템의성능.DataBindings.Add("selectedvalue", Me.bs, "태양열시스템의성능")
        'AddHandler 태양열시스템의성능ComboBox.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_축열탱크설치장소ComboBox As New BindingSource(DSET, "tbl_common")
        bs_축열탱크설치장소ComboBox.Filter = "gubun='1061'"
        bs_축열탱크설치장소ComboBox.Sort = "code"
        Me.cmb_축열탱크설치장소.DataSource = bs_축열탱크설치장소ComboBox
        cmb_축열탱크설치장소.DisplayMember = "name"
        cmb_축열탱크설치장소.ValueMember = "name"
        Me.cmb_축열탱크설치장소.DataBindings.Add("selectedvalue", Me.bs, "축열탱크설치장소")
        'AddHandler 축열탱크설치장소ComboBox.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_태양광모듈기울기ComboBox As New BindingSource(DSET, "tbl_common")
        bs_태양광모듈기울기ComboBox.Filter = "gubun='1062'"
        bs_태양광모듈기울기ComboBox.Sort = "code"
        Me.cmb_모듈기울기.DataSource = bs_태양광모듈기울기ComboBox
        cmb_모듈기울기.DisplayMember = "name"
        cmb_모듈기울기.ValueMember = "name"
        Me.cmb_모듈기울기.DataBindings.Add("selectedvalue", Me.bs, "태양광모듈기울기")
        'AddHandler 태양광모듈기울기ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_태양광모듈방위ComboBox As New BindingSource(DSET, "tbl_common")
        bs_태양광모듈방위ComboBox.Filter = "gubun='1063'"
        bs_태양광모듈방위ComboBox.Sort = "code"
        Me.cmb_모듈방위.DataSource = bs_태양광모듈방위ComboBox
        cmb_모듈방위.DisplayMember = "name"
        cmb_모듈방위.ValueMember = "name"
        Me.cmb_모듈방위.DataBindings.Add("selectedvalue", Me.bs, "태양광모듈방위")
        'AddHandler 태양광모듈방위ComboBox.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_태양광모듈종류ComboBox As New BindingSource(DSET, "tbl_common")
        bs_태양광모듈종류ComboBox.Filter = "gubun='1064'"
        bs_태양광모듈종류ComboBox.Sort = "code"
        Me.cmb_모듈종류.DataSource = bs_태양광모듈종류ComboBox
        cmb_모듈종류.DisplayMember = "name"
        cmb_모듈종류.ValueMember = "name"
        Me.cmb_모듈종류.DataBindings.Add("selectedvalue", Me.bs, "태양광모듈종류")
        'AddHandler 태양광모듈종류ComboBox.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_태양광모듈적용타입ComboBox As New BindingSource(DSET, "tbl_common")
        bs_태양광모듈적용타입ComboBox.Filter = "gubun='1065'"
        bs_태양광모듈적용타입ComboBox.Sort = "code"
        Me.cmb_모듈적용타입.DataSource = bs_태양광모듈적용타입ComboBox
        cmb_모듈적용타입.DisplayMember = "name"
        cmb_모듈적용타입.ValueMember = "name"
        Me.cmb_모듈적용타입.DataBindings.Add("selectedvalue", Me.bs, "태양광모듈적용타입")
        'AddHandler 태양광모듈적용타입ComboBox.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_열교환기설치여부ComboBox As New BindingSource(DSET, "tbl_common")
        bs_열교환기설치여부ComboBox.Filter = "gubun='1054'"
        bs_열교환기설치여부ComboBox.Sort = "code"
        Me.cmb_열교환기설치여부.DataSource = bs_열교환기설치여부ComboBox
        cmb_열교환기설치여부.DisplayMember = "name"
        cmb_열교환기설치여부.ValueMember = "name"
        Me.cmb_열교환기설치여부.DataBindings.Add("selectedvalue", Me.bs, "열교환기설치여부")
        'AddHandler 열교환기설치여부ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_팽창탱크설치여부ComboBox As New BindingSource(DSET, "tbl_common")
        bs_팽창탱크설치여부ComboBox.Filter = "gubun='1054'"
        bs_팽창탱크설치여부ComboBox.Sort = "code"
        Me.cmb_지열팽창설치여부.DataSource = bs_팽창탱크설치여부ComboBox
        cmb_지열팽창설치여부.DisplayMember = "name"
        cmb_지열팽창설치여부.ValueMember = "name"
        Me.cmb_지열팽창설치여부.DataBindings.Add("selectedvalue", Me.bs, "팽창탱크설치여부")
        'AddHandler 팽창탱크설치여부ComboBox.KeyDown, AddressOf Cmb_DeleteVal

    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.bs.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 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()
        'Dim DRv As DataRowView = bs.Current
        'DRv("code") = Me.GetMaxCode(DSET.tbl_new)
        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 Binding_new()

    End Sub
    Private Sub AddNewDataRow_new(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs)
        ' MsgBox("new")
        e.Row.Item("code") = GetMaxCode(DSET.tbl_new)
    End Sub
#End Region

    Private Sub 태양열종류ComboBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmb_태양열시스템종류.KeyDown
        If e.KeyCode = Keys.V And e.Control Then

            e.Handled = True
            e.SuppressKeyPress = False
            '//클립보드붙여넣기
            Dim CB() As String = My.Computer.Clipboard.GetText.Split(CChar(vbCrLf))
            If CB.GetUpperBound(0) <> 12 Then
                MsgBox("붙여넣기가 호환되는 데이터가 아닙니다.", MsgBoxStyle.Information, "확인")
                Return
            End If
            Dim Cnt As Short = 0
            For i As Integer = 0 To CB.GetUpperBound(0)
                Select Case i
                    Case 0  '//사용프로필 앞에 두개를 숫자4자로변환
                        'If CB(i).Trim = "" Then Me.태양열종류ComboBox.SelectedIndex = -1
                        If CB(i).Trim = "" Then
                            Me.cmb_태양열시스템종류.SelectedIndex = 0
                        Else
                            Me.cmb_태양열시스템종류.Text = CB(i).Trim
                        End If
                        ' Me.태양열종류ComboBox.Text = CStr(IIf(CB(i).Trim = "", "0", CB(i).Trim))
                    Case 1  '//공란
                        If CB(i).Trim = "" Then
                            Me.cmb_집열기유형.SelectedIndex = 0
                        Else
                            Me.cmb_집열기유형.Text = CB(i).Trim
                        End If
                        'Me.집열기유형ComboBox.Text = CStr(IIf(CB(i).Trim = "", "0", CB(i).Trim))
                    Case 2  '//면적
                        Me.tb_집열판면적.Text = CB(i).Trim
                    Case 3
                        If CB(i).Trim = "" Then
                            Me.cmb_집열판방위.SelectedIndex = 0
                        Else
                            Me.cmb_집열판방위.Text = CB(i).Trim
                        End If
                        'Me.집열판방위ComboBox.Text = CStr(IIf(CB(i).Trim = "", "0", CB(i).Trim))
                    Case 4
                        Me.tB_솔라펌프출력.Text = CB(i).Trim
                    Case 5
                        If CB(i).Trim = "" Then
                            Me.cmb_태양열시스템의성능.SelectedIndex = 0
                        Else
                            Me.cmb_태양열시스템의성능.Text = CB(i).Trim
                        End If

                        ' Me.태양열시스템의성능ComboBox.Text = CStr(IIf(CB(i).Trim = "", "0", CB(i).Trim))
                    Case 6
                        Me.tb_무손실효율계수.Text = CB(i).Trim
                    Case 7
                        Me.tb_1차손실계수.Text = CB(i).Trim
                    Case 8
                        Me.tb_2차손실계수.Text = CB(i).Trim
                    Case 9
                    Case 10
                        Me.tb_축열탱크체적급.Text = CB(i).Trim
                    Case 11
                        Me.tb_축열탱크체적난.Text = CB(i).Trim
                    Case 12
                        If CB(i).Trim = "" Then
                            Me.cmb_축열탱크설치장소.SelectedIndex = 0
                        Else
                            Me.cmb_축열탱크설치장소.Text = CB(i).Trim
                        End If

                        'Me.축열탱크설치장소ComboBox.Text = CStr(IIf(CB(i).Trim = "", "0", CB(i).Trim))
                End Select
            Next
            Me.bs.EndEdit()
        End If
    End Sub


    Private Sub 태양광모듈면적NTb_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_모듈면적.KeyDown
        If e.KeyCode = Keys.V And e.Control Then

            e.Handled = True
            e.SuppressKeyPress = False
            '//클립보드붙여넣기
            Dim CB() As String = My.Computer.Clipboard.GetText.Split(CChar(vbCrLf))
            If CB.GetUpperBound(0) < 3 Then
                MsgBox("정상적인 데이터가 아닙니다")
                Return
            End If
            Dim Cnt As Short = 0
            For i As Integer = 0 To CB.GetUpperBound(0)
                Select Case i
                    Case 0  '//사용프로필 앞에 두개를 숫자4자로변환
                        Me.tb_모듈면적.Text = CB(i).Trim
                    Case 1  '//공란
                        If CB(i).Trim = "" Then Me.cmb_모듈기울기.SelectedIndex = -1
                        Me.cmb_모듈기울기.Text = CB(i).Trim
                    Case 2  '//면적
                        If CB(i).Trim = "" Then Me.cmb_모듈방위.SelectedIndex = -1
                        Me.cmb_모듈방위.Text = CB(i).Trim
                    Case 3
                        If CB(i).Trim = "" Then Me.cmb_모듈종류.SelectedIndex = -1
                        Me.cmb_모듈종류.Text = CB(i).Trim
                    Case 4
                        If CB(i).Trim = "" Then Me.cmb_모듈적용타입.SelectedIndex = -1
                        Me.cmb_모듈적용타입.Text = CB(i).Trim
                End Select
            Next
            Me.bs.EndEdit()
        End If
    End Sub

    Private Sub 지열가동연료ComboBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmb_가동연료.KeyDown, tb_지열펌프용량.KeyDown

    End Sub

    Private Sub bs_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bs.CurrentChanged
        '//존이 옴겨질떄 해당 존의 사용량을 표시
        If Not Init Then Return
        Try
            Dim Drv As DataRowView = CType(bs.Current, DataRowView)
            Me.tb_태양열_cnt1.Text = CStr(DSET.tbl_nanbangkiki.Select("신재생연결여부='시스템연결' and 연결된시스템='" & Drv("Code").ToString & "'").GetUpperBound(0) + 1)
            Me.tb_태양열_cnt2.Text = CStr(DSET.tbl_nangbangkiki.Select("신재생연결여부='시스템연결' and 연결된시스템='" & Drv("Code").ToString & "'").GetUpperBound(0) + 1)
        Catch ex As Exception
            Me.tb_태양열_cnt1.Text = ex.Message.ToString
            Me.tb_태양열_cnt2.Text = ex.Message.ToString
        End Try
        Me.bs.EndEdit()
    End Sub

    Private Sub 기기종류ComboBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles 기기종류ComboBox.KeyDown
        If e.KeyCode = Keys.V And e.Control Then

            e.Handled = True
            e.SuppressKeyPress = False
            '//클립보드붙여넣기
            Dim CB() As String = My.Computer.Clipboard.GetText.Split(CChar(vbCrLf))
            If CB.GetUpperBound(0) < 2 Then
                MsgBox("정상적인 데이터가 아닙니다")
                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 5
                            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
                        Case 6
                            ' If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.열교가산치ComboBox.SelectedIndex = -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))

                        Case 9
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.cmb_냉난방방식.SelectedIndex = -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.cmb_냉난방방식.Text = CStr(IIf( CB(i).Split(CChar(vbTab))(ii).Trim = "", "0",  CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 10
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방공조ComboBox.SelectedIndex = -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
                        Case 11 '//열생산지정
                            ' Me.TabControl10.SelectedIndex = 1
                            Me.tb_집열판면적.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 12
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방공조ComboBox.SelectedIndex = -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
                        Case 13 '//열생산지정
                            ' Me.TabControl10.SelectedIndex = 1
                            Me.tB_솔라펌프출력.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 14
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방공조ComboBox.SelectedIndex = -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
                        Case 15 '//열생산지정
                            ' Me.TabControl10.SelectedIndex = 1
                            Me.tb_무손실효율계수.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 16 '//열생산지정
                            Me.tb_1차손실계수.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 17 '//열생산지정
                            Me.tb_2차손실계수.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 19 '//열생산지정
                            Me.tb_축열탱크체적급.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 20 '//열생산지정
                            Me.tb_축열탱크체적난.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 21
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방공조ComboBox.SelectedIndex = -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
                        Case 24 '//열생산지정
                            Me.tb_모듈면적.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 25
                            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 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
                            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 28 '//열생산지정
                            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.cmb_모듈적용타입.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 31 '//열생산지정
                            Me.tb_지열펌프용량.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 32 '//열생산지정
                            Me.tb_열성능비.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 33 '//열생산지정
                            Me.tb_열성능비2.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 34 '//열생산지정
                            Me.tb_1차펌프용량.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 35 '//열생산지정
                            Me.tb_2차펌프용량.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 36
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방공조ComboBox.SelectedIndex = -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
                        Case 37
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방공조ComboBox.SelectedIndex = -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
                        Case 38 '//열생산지정
                            Me.tb_지열팽창탱크체적.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 41 '//열생산지정
                            Me.tb_열생산능력.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 42 '//열생산지정
                            Me.tb_열생산효율.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 43 '//열생산지정
                            Me.tb_발전효율.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                    End Select
                Next
            Next

            Me.bs.EndEdit()
        End If
    End Sub

    Private Sub 기기종류ComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 기기종류ComboBox.SelectedIndexChanged
        Validate_Control()
    End Sub

    Private Sub Validate_Control()
        If Not Init Then Return
        Try
            Select Case Me.기기종류ComboBox.Text
                Case "태양열", "태양광"
                    Me.cmb_가동연료.SelectedIndex = 0
                    Me.cmb_가동연료.Enabled = False
                Case Else
                    Me.cmb_가동연료.Enabled = True
            End Select
        Catch ex As Exception

        End Try

        Try
            Select Case Me.cmb_태양열시스템의성능.Text
                Case "성능치"
                    Me.tb_무손실효율계수.Enabled = True
                    Me.tb_1차손실계수.Enabled = True
                    Me.tb_2차손실계수.Enabled = True
                Case Else
                    Me.tb_무손실효율계수.Enabled = False
                    Me.tb_1차손실계수.Enabled = False
                    Me.tb_2차손실계수.Enabled = False
            End Select
        Catch ex As Exception

        End Try

        Try
            If 기기종류ComboBox.Text = "태양열" Then
                태양열Panel.Enabled = True
                축열탱크Panel.Enabled = True
                열병합Panel.Enabled = False
                태양광Panel.Enabled = False
                지열Panel.Enabled = False
            ElseIf 기기종류ComboBox.Text = "열병합" Then
                태양열Panel.Enabled = False
                축열탱크Panel.Enabled = False
                열병합Panel.Enabled = True
                태양광Panel.Enabled = False
                지열Panel.Enabled = False
            ElseIf 기기종류ComboBox.Text = "태양광" Then
                태양열Panel.Enabled = False
                축열탱크Panel.Enabled = False
                열병합Panel.Enabled = False
                태양광Panel.Enabled = True
                지열Panel.Enabled = False
            ElseIf 기기종류ComboBox.Text = "지열" Then
                태양열Panel.Enabled = False
                축열탱크Panel.Enabled = False
                열병합Panel.Enabled = False
                태양광Panel.Enabled = False
                지열Panel.Enabled = True
            Else
                태양열Panel.Enabled = False
                축열탱크Panel.Enabled = False
                열병합Panel.Enabled = False
                태양광Panel.Enabled = False
                지열Panel.Enabled = False
            End If
        Catch ex As Exception

        End Try

        '//건기연 추가 (2010.04.07)
        'MsgBox(Me.cmb_가동연료.Text)
        Try
            Select Case Me.cmb_가동연료.Text
                Case "전기"
                    Me.cmb_열교환기설치여부.Enabled = False
                Case Else
                    Me.cmb_열교환기설치여부.Enabled = True
            End Select
        Catch ex As Exception

        End Try

        Try

            Select Case Me.cmb_모듈기울기.Text
                Case "수평", "(없음)"
                    Me.cmb_모듈방위.Enabled = False
                Case Else
                    Me.cmb_모듈방위.Enabled = True
            End Select

        Catch ex As Exception

        End Try

        Try
            Select Case Me.cmb_모듈종류.Text
                Case "성능치 입력"
                    Me.tb_모듈효율.Enabled = True
                Case Else
                    Me.tb_모듈효율.Enabled = False
            End Select
        Catch ex As Exception

        End Try

    End Sub

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



    Private Sub cmb_가동연료_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_가동연료.SelectedIndexChanged
        If Me.cmb_가동연료.SelectedIndex <> -1 Then Me.Validate_Control()
    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 = ""
                '//getfiled 며령으로 모든 필드명을 찾아서
                '//그것을 그 화면으로  보내는거에요
                '//그런데 여기서 어떤필드는 색을 달리하겟다라고할려면 해당   ::::   정보도 같이 넘겨줘야해요
                '//그부분 구현이 좀 매끄럽게 생각정리가안되네요

                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 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 cmb_지열팽창설치여부_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmb_지열팽창설치여부.SelectedValueChanged

        Try
            Select Case Me.cmb_지열팽창설치여부.Text
                Case "예"
                    Me.tb_지열팽창탱크체적.Enabled = True
                Case Else
                    Me.tb_지열팽창탱크체적.Enabled = False
            End Select
        Catch ex As Exception

        End Try


    End Sub

    Private Sub cmb_모듈기울기_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmb_모듈기울기.SelectedValueChanged
        Validate_Control()
    End Sub

    Private Sub dv_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dv.CellContentClick

    End Sub

    Private Sub cmb_태양열시스템의성능_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_태양열시스템의성능.SelectedIndexChanged
        Validate_Control()
    End Sub

    Private Sub cmb_모듈종류_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_모듈종류.SelectedIndexChanged
        Validate_Control()
    End Sub
End Class