Public Class Frm_Zone
    Dim isCopy As Boolean = False
    Dim Init As Boolean = False '//validate가 true일경우에만 동작하도록한다. 프로그램초기화중에는 작동하지않도록
    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
        Me.Init = False
        'MdiMain.Toggle_Menu_Color(MdiMain.E_MenuIdx.입력존)
        '//공유데이터셋에 연결한다.
        Me.bs.DataSource = DSET

        '//Zone
        AddHandler DSET.tbl_zone.TableNewRow, AddressOf AddNewDataRow_Zone
        AddHandler DSET.tbl_zone.ColumnChanged, AddressOf AddNewDataRow_Zone_Changed

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

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

        Me.bs.Filter = "code <> '0' and 그룹 = '" + Me.Parameter + "'"
        Me.lb_grpname.text = Me.Parameter

        Try
            Me.bs.Position = CEnergy.ARINCLASS.Read_LastPos_Frm(Me)
        Catch ex As Exception
            Me.bs.MoveFirst()
        End Try
        Me.Init = True
        bs_CurrentChanged(sender, e)
        Validate_Control()
        ZONE_Control()
    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

#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
                    AddHandler CType(C, MyCmb).MouseHover, AddressOf ComboBox_MouseHover
                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, "") 'Dt.rows
                    Dr(Field) = CType(sender, MyCmb).SelectedValue
                Next
                Work_msg_timer("모든값이 변경되었습니다", 25)
            Catch ex As Exception

            End Try
        End If
    End Sub

    Private Sub ComboBox_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs)
        '//공백의 경우 에러가 나서 우선 막아둠.
        Try
            Me.ToolTip1.SetToolTip(CType(sender, ComboBox), CType(sender, ComboBox).DataBindings("selectedvalue").BindingMemberInfo.BindingMember & vbCrLf & CType(sender, ComboBox).SelectedValue.ToString)
        Catch ex As Exception

        End Try

    End Sub


#End Region

#Region "ComboxBox Binding"
    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 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_cmb_profile As New BindingSource(DSET, "tbl_profile")
        bs_cmb_profile.Sort = "code"
        cmb_profile.DataSource = bs_cmb_profile
        cmb_profile.DisplayMember = "설명"
        cmb_profile.ValueMember = "code"
        Me.cmb_profile.DataBindings.Add("selectedvalue", Me.bs, "프로필")
        'AddHandler cmb_profile.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_kongkub As New BindingSource(DSET, "tbl_kongkub")
        bs_cmb_kongkub.Sort = "code"
        냉난방열공급시스템ComboBox.DataSource = bs_cmb_kongkub
        냉난방열공급시스템ComboBox.DisplayMember = "설명"
        냉난방열공급시스템ComboBox.ValueMember = "code"
        Me.냉난방열공급시스템ComboBox.DataBindings.Add("selectedvalue", Me.bs, "냉난방열공급시스템")
        'AddHandler 냉난방열공급시스템ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_열저장능력 As New BindingSource(DSET, "tbl_common")
        bs_cmb_열저장능력.Filter = "gubun='1023'"
        bs_cmb_열저장능력.Sort = "code"
        열저장능력ComboBox.DataSource = bs_cmb_열저장능력
        열저장능력ComboBox.DisplayMember = "name"
        열저장능력ComboBox.ValueMember = "name"
        Me.열저장능력ComboBox.DataBindings.Add("selectedvalue", Me.bs, "열저장능력")
        'AddHandler 열저장능력ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_열교가산치 As New BindingSource(DSET, "tbl_common")
        bs_cmb_열교가산치.Filter = "gubun='1022'"
        bs_cmb_열교가산치.Sort = "code"
        열교가산치ComboBox.DataSource = bs_cmb_열교가산치
        열교가산치ComboBox.DisplayMember = "name"
        열교가산치ComboBox.ValueMember = "name"
        Me.열교가산치ComboBox.DataBindings.Add("selectedvalue", Me.bs, "열교가산치")
        'AddHandler 열교가산치ComboBox.KeyDown, AddressOf Cmb_DeleteVal

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

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

        Dim bs_cmb_외기처리여부 As New BindingSource(DSET, "tbl_common")
        bs_cmb_외기처리여부.Filter = "gubun='1054'"
        bs_cmb_외기처리여부.Sort = "code"
        외기부하처리여부ComboBox.DataSource = bs_cmb_외기처리여부
        외기부하처리여부ComboBox.DisplayMember = "name"
        외기부하처리여부ComboBox.ValueMember = "name"
        Me.외기부하처리여부ComboBox.DataBindings.Add("selectedvalue", Me.bs, "외기부하처리여부")
        'AddHandler 외기부하처리여부ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_냉난방공조 As New BindingSource(DSET, "tbl_common")
        bs_cmb_냉난방공조.Filter = "gubun='1001'"
        bs_cmb_냉난방공조.Sort = "code"
        냉난방공조ComboBox.DataSource = bs_cmb_냉난방공조
        냉난방공조ComboBox.DisplayMember = "name"
        냉난방공조ComboBox.ValueMember = "name"
        Me.냉난방공조ComboBox.DataBindings.Add("selectedvalue", Me.bs, "냉난방공조")
        'AddHandler 냉난방공조ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_냉난방방식 As New BindingSource(DSET, "tbl_common")
        bs_cmb_냉난방방식.Filter = "gubun='1000'"
        bs_cmb_냉난방방식.Sort = "code"
        cmb_냉난방방식.DataSource = bs_cmb_냉난방방식
        cmb_냉난방방식.DisplayMember = "name"
        cmb_냉난방방식.ValueMember = "name"
        Me.cmb_냉난방방식.DataBindings.Add("selectedvalue", Me.bs, "냉난방방식")
        'AddHandler cmb_냉난방방식.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_cmb_공조처리 As New BindingSource(DSET, "tbl_kongjo")
        bs_cmb_공조처리.Sort = "code"
        냉난방공조처리시스템ComboBox.DataSource = bs_cmb_공조처리
        냉난방공조처리시스템ComboBox.DisplayMember = "설명"
        냉난방공조처리시스템ComboBox.ValueMember = "code"
        Me.냉난방공조처리시스템ComboBox.DataBindings.Add("selectedvalue", Me.bs, "냉난방공조처리시스템")


        'AddHandler 냉난방공조처리시스템ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_난방기기 As New BindingSource(DSET, "tbl_nanbangkiki")
        bs_cmb_난방기기.Sort = "code"
        cmb_열생산지정1.DataSource = bs_cmb_난방기기
        cmb_열생산지정1.DisplayMember = "설명"
        cmb_열생산지정1.ValueMember = "code"
        Me.cmb_열생산지정1.DataBindings.Add("selectedvalue", Me.bs, "열생산난방생산기기")
        'AddHandler cmb_열생산지정1.KeyDown, AddressOf Cmb_DeleteVal


        '//공조추가 101105
        Dim bs_cmb_공조난방기기 As New BindingSource(DSET, "tbl_nanbangkiki")
        bs_cmb_공조난방기기.Sort = "code"
        cmb_공조난방생산.DataSource = bs_cmb_공조난방기기
        cmb_공조난방생산.DisplayMember = "설명"
        cmb_공조난방생산.ValueMember = "code"
        Me.cmb_공조난방생산.DataBindings.Add("selectedvalue", Me.bs, "공조난방생산기기")

        Dim bs_cmb_공조냉방기기 As New BindingSource(DSET, "tbl_nangbangkiki")
        bs_cmb_공조냉방기기.Sort = "code"
        cmb_공조냉방생산.DataSource = bs_cmb_공조냉방기기
        cmb_공조냉방생산.DisplayMember = "설명"
        cmb_공조냉방생산.ValueMember = "code"
        Me.cmb_공조냉방생산.DataBindings.Add("selectedvalue", Me.bs, "공조냉방생산기기")
        '//공조추가 101105

        Dim bs_cmb_급탕기기 As New BindingSource(DSET, "tbl_nanbangkiki")
        bs_cmb_급탕기기.Sort = "code"
        cmb_열생산급탕기기.DataSource = bs_cmb_급탕기기
        cmb_열생산급탕기기.DisplayMember = "설명"
        cmb_열생산급탕기기.ValueMember = "code"
        Me.cmb_열생산급탕기기.DataBindings.Add("selectedvalue", Me.bs, "열생산급탕생산기기")
        'AddHandler cmb_열생산지정2.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_냉방기기 As New BindingSource(DSET, "tbl_nangbangkiki")
        bs_cmb_냉방기기.Sort = "code"
        cmb_열생산지정3.DataSource = bs_cmb_냉방기기
        cmb_열생산지정3.DisplayMember = "설명"
        cmb_열생산지정3.ValueMember = "code"
        Me.cmb_열생산지정3.DataBindings.Add("selectedvalue", Me.bs, "열생산냉방생산기기")
        'AddHandler cmb_열생산지정3.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_가습기기 As New BindingSource(DSET, "tbl_nanbangkiki")
        bs_cmb_가습기기.Sort = "code"
        cmb_공조가습생산.DataSource = bs_cmb_가습기기
        cmb_공조가습생산.DisplayMember = "설명"
        cmb_공조가습생산.ValueMember = "code"
        Me.cmb_공조가습생산.DataBindings.Add("selectedvalue", Me.bs, "열생산가습생산기기")
        'AddHandler cmb_열생산지정4.KeyDown, AddressOf Cmb_DeleteVal



        'Dim bs_cmb_냉방공조분배 As New BindingSource(DSET, "tbl_bunbae")
        'bs_cmb_냉방공조분배.Sort = "code"
        '냉난방공조분배시스템ComboBox.DataSource = bs_cmb_냉방공조분배
        '냉난방공조분배시스템ComboBox.DisplayMember = "설명"
        '냉난방공조분배시스템ComboBox.ValueMember = "code"
        'Me.냉난방공조분배시스템ComboBox.DataBindings.Add("selectedvalue", Me.bs, "냉난방공조분배시스템")
        ''AddHandler 냉난방공조분배시스템ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        'Dim bs_cmb_냉방분배 As New BindingSource(DSET, "tbl_bunbae")
        'bs_cmb_냉방분배.Sort = "code"
        '냉난방분배시스템ComboBox.DataSource = bs_cmb_냉방분배
        '냉난방분배시스템ComboBox.DisplayMember = "설명"
        '냉난방분배시스템ComboBox.ValueMember = "code"
        'Me.냉난방분배시스템ComboBox.DataBindings.Add("selectedvalue", Me.bs, "냉난방분배시스템")
        ''AddHandler 냉난방분배시스템ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_조명부하산출방법 As New BindingSource(DSET, "tbl_common")
        bs_cmb_조명부하산출방법.Sort = "code"
        bs_cmb_조명부하산출방법.Filter = "gubun='1031'"
        조명부하산출방법ComboBox.DataSource = bs_cmb_조명부하산출방법
        조명부하산출방법ComboBox.DisplayMember = "name"
        조명부하산출방법ComboBox.ValueMember = "name"
        Me.조명부하산출방법ComboBox.DataBindings.Add("selectedvalue", Me.bs, "조명부하산출방법")
        'AddHandler 조명부하산출방법ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_인공광원 As New BindingSource(DSET, "tbl_common")
        bs_cmb_인공광원.Sort = "code"
        bs_cmb_인공광원.Filter = "gubun='1024'"
        Me.인공광원ComboBox.DataSource = bs_cmb_인공광원
        인공광원ComboBox.DisplayMember = "name"
        인공광원ComboBox.ValueMember = "name"
        Me.인공광원ComboBox.DataBindings.Add("selectedvalue", Me.bs, "인공광원")
        'AddHandler 인공광원ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_조명방식 As New BindingSource(DSET, "tbl_common")
        bs_cmb_조명방식.Sort = "code"
        bs_cmb_조명방식.Filter = "gubun='1025'"
        Me.조명방식ComboBox.DataSource = bs_cmb_조명방식
        조명방식ComboBox.DisplayMember = "name"
        조명방식ComboBox.ValueMember = "name"
        Me.조명방식ComboBox.DataBindings.Add("selectedvalue", Me.bs, "조명방식")
        'AddHandler 조명방식ComboBox.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_cmb_그룹존 As New BindingSource(DSET, "tbl_common")
        bs_cmb_그룹존.Sort = "code"
        bs_cmb_그룹존.Filter = "gubun='1200'"
        Me.cmb_그룹_존.DataSource = bs_cmb_그룹존
        Me.cmb_그룹_존.DisplayMember = "name"
        Me.cmb_그룹_존.ValueMember = "name"
        Me.cmb_그룹_존.DataBindings.Add("selectedvalue", Me.bs, "그룹")
        'AddHandler 조명방식ComboBox.KeyDown, AddressOf Cmb_DeleteVal

    End Sub

    Private Sub AddNewDataRow_Zone(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs)
        '//모든화면에는 이와같은게 잇습니다. 이게 신규생성할떄의 명령이에요.
        ''//아래엔 코드값만새로 만들어주는루틴만잇어요
        e.Row.Item("code") = GetMaxCode(DSET.tbl_zone, DSET.tbl_myoun)
        e.Row.Item("조명부하산출방법") = "입력치"
        e.Row.Item("설명") = "신규이름"
        '//위처럼 데이터를 넣어주면 기본값이 되요.. 계산치
    End Sub

    Private Function GetMaxCode(ByVal dt As DataTable, ByVal dt_myoun As DataTable) As String
        Try
            Dim Dr As DataRow = dt.Select("", "code desc")(0)
            Dim Dr_myoun As DataRow = dt_myoun.Select("", "존분류 desc")(0)
            If Dr("code") >= Dr_myoun("존분류") Then
                Return Format(CInt(Dr("code")) + 1, "0000")
            Else
                Return Format(CInt(Dr_myoun("존분류")) + 1, "0000")
            End If

        Catch ex As Exception
            Return "0001"
        End Try
    End Function
    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
        Del_ZoneMyoun(True)
        '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 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

#End Region

    Private Sub AddNewDataRow_Zone_Changed(ByVal sender As Object, ByVal e As System.Data.DataColumnChangeEventArgs)
        '//값이바뀐다면 조명의실지수값을 재계산한다.
        ' If isCopy Then Return
        Select Case e.Column.Caption.Trim
            Case "면적", "천장고p"  '//순실체적
                Try
                    Me.순실체적NTb.Text = Val(e.Row("면적")) * Val(e.Row("천장고p"))
                Catch ex As Exception
                    Me.순실체적NTb.Text = 0
                    'e.Row("순실체적") = 0
                End Try
                Me.bs.EndEdit()
            Case "실깊이", "실너비", "천장고", "작업면높이"
                If Me.조명부하산출방법ComboBox.Text = "계산치" Then
                    Try
                        Dim 실깊이 As Decimal = TOSG(e.Row("실깊이"))
                        Dim 실너비 As Decimal = TOSG(e.Row("실너비"))
                        Dim 천장고 As Decimal = TOSG(e.Row("천장고"))
                        Dim 작업면높이 As Decimal = TOSG(e.Row("작업면높이"))
                        e.Row("실지수") = 실깊이 * 실너비 / ((천장고 - 작업면높이) * (실깊이 + 실너비))
                    Catch ex As Exception
                        e.Row("실지수") = 0
                    End Try
                End If
                Me.bs.EndEdit()
            Case "조명방식", "인공광원", "실지수"
                'MsgBox("2")
                If Me.조명부하산출방법ComboBox.Text = "계산치" Then
                    Dim 조명방식 As String = TOST(e.Row("조명방식"))
                    Dim 인공광원 As String = TOST(e.Row("인공광원"))
                    Select Case 인공광원.Trim
                        Case "형광등"
                            e.Row("조명기기효율") = 65
                        Case "백열등"
                            e.Row("조명기기효율") = 15
                        Case "할로겐등"
                            e.Row("조명기기효율") = 21
                        Case "고압수은등"
                            e.Row("조명기기효율") = 52
                        Case "메탈할라이드등"
                            e.Row("조명기기효율") = 72
                        Case "고압나트륨등"
                            e.Row("조명기기효율") = 108
                        Case Else
                            e.Row("조명기기효율") = 0
                    End Select
                    Try
                        If e.Row("실지수").ToString <> "" AndAlso e.Row("실지수").ToString <> "NaN" Then
                            Dim 실지수 As Decimal = TOSG(e.Row("실지수"))
                            If 조명방식 = "직접" Then  '//직접
                                e.Row("조명률") = TOSG(IIf(인공광원 = "백열등", TOSG(78 - 32 / (실지수 + 0.47)), TOSG(70 - 38 / (실지수 + 0.35)))) * 0.01
                            Else   '//간접
                                e.Row("조명률") = (52 - 60 / (실지수 + 1.02)) * 0.01
                            End If
                        Else
                            e.Row("조명률") = 0
                        End If

                    Catch ex As Exception
                        e.Row("조명률") = 0
                    End Try

                End If
                Me.bs.EndEdit()
            Case "보수율", "조명기기효율", "조명률", "요구조도"
                If Me.조명부하산출방법ComboBox.Text = "계산치" Then
                    Try
                        Dim 보수율 As Decimal = TOSG(e.Row("보수율"))
                        Dim 효율 As Decimal = TOSG(e.Row("조명기기효율"))
                        Dim 조명률 As Decimal = TOSG(e.Row("조명률"))
                        Dim 요구조도 As Decimal = TOSG(e.Row("요구조도"))
                        e.Row("조명에너지부하율계산치") = 요구조도 / (조명률 * 보수율 * 효율)
                    Catch ex As Exception
                        e.Row("조명에너지부하율계산치") = 0
                    End Try
                End If
                Me.bs.EndEdit()
        End Select


    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))
            'MsgBox(CB.GetUpperBound(0))
            If CB.GetUpperBound(0) <> 19 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 + 2
                            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 =  CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 1 + 2
                            Me.요구조도NTb1.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 2 + 2
                            Me.천장고NTB1.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 3 + 2
                            Me.작업면높이NTb1.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 4 + 2
                            Me.실깊이NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 5 + 2
                            Me.실너비NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 6  '//실지수넘어감
                        Case 7 + 2
                        Case 8 + 2
                        Case 9 + 2
                            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 =  CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 10 + 2
                            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 =  CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 11 + 2
                            Me.보수율NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 12 + 2
                            Me.tb_점등시간.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 13 + 2
                            ' Me.조명기기효율NTb.Text =  CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 14 + 2
                            'Me.조명률NTb.Text =  CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 15 + 2
                            'me.조명에너지부하율계산치NTb.Text= CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 16 + 2
                            Me.tb_조명입력치.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                    End Select
                Next
                If bs.Position < bs.Count Then bs.Position += 1 '//위치이동
            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
        If isCopy Then Return
        '=============================================================2012.07.08 추가
        Try
            If Me.입력존의수NTb.Text = "" Then
                Me.입력존의수NTb.Text = "1"
            End If
        Catch ex As Exception

        End Try





        '=============================================================2012.07.08 추가

        ' If Me.TabControl2.SelectedIndex = 1 Then    '//조명부하의경우 탭컨트롤이 1일때 행한다.
        Try
            If Me.조명부하산출방법ComboBox.Text = "계산치" Then   '//계산치
                Me.요구조도NTb1.Enabled = True
                Me.천장고NTB1.Enabled = True
                Me.작업면높이NTb1.Enabled = True
                Me.실깊이NTb.Enabled = True
                Me.실너비NTb.Enabled = True
                Me.실지수NTb1.Enabled = True
                Me.조명방식ComboBox.Enabled = True
                Me.인공광원ComboBox.Enabled = True
                Me.보수율NTb.Enabled = True
                'Me.점등시간NTb.Enabled = False
                Me.조명기기효율NTb.Enabled = True
                Me.tb_조명률.Enabled = True
                Me.tb_조명계산치.Enabled = True
                Me.tb_조명입력치.Enabled = False
            Else
                Me.요구조도NTb1.Enabled = False
                Me.천장고NTB1.Enabled = False
                Me.작업면높이NTb1.Enabled = False
                Me.실깊이NTb.Enabled = False
                Me.실너비NTb.Enabled = False
                Me.실지수NTb1.Enabled = False

                Me.조명방식ComboBox.SelectedIndex = 0
                Me.인공광원ComboBox.SelectedIndex = 0
                Me.조명방식ComboBox.Enabled = False
                Me.인공광원ComboBox.Enabled = False

                Me.보수율NTb.Enabled = False
                'Me.점등시간NTb.Enabled = False
                Me.조명기기효율NTb.Enabled = False
                Me.tb_조명률.Enabled = False
                Me.tb_조명계산치.Enabled = False
                Me.tb_조명입력치.Enabled = True
                'Me.점등시간TextBox.Enabled = True
            End If


        Catch ex As Exception

        End Try
        Try
            Select Case Me.cmb_profile.SelectedIndex
                Case 0, 6, 8, 9, 11
                    Me.cmb_열생산급탕기기.SelectedIndex = 0
                    Me.cmb_열생산급탕기기.Enabled = False
                Case Else
                    Me.cmb_열생산급탕기기.Enabled = True
            End Select

        Catch ex As Exception
            ' MsgBox(ex.Message.ToString, MsgBoxStyle.Critical)
        End Try

        ' End If
        Show_점등시간()
        Me.bs.EndEdit()
    End Sub

    Private Sub 인공광원ComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 인공광원ComboBox.SelectedIndexChanged
        Try
            Me.조명기기효율NTb.Text = CStr(CType(Me.인공광원ComboBox.SelectedItem, DataRowView)("valn1"))
            Me.bs.EndEdit()
        Catch ex As Exception
            Me.조명기기효율NTb.Text = "0.0"
        End Try

    End Sub

    Private Sub 조명방식ComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 조명방식ComboBox.SelectedIndexChanged
        Me.bs.EndEdit()
    End Sub

    Private Sub cmb_profile_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmb_profile.KeyDown
        If e.KeyCode = Keys.V And e.Control Then
            isCopy = True
            e.Handled = True
            e.SuppressKeyPress = False
            '//클립보드붙여넣기
            Dim CB() As String = My.Computer.Clipboard.GetText.Split(CChar(vbCrLf))
            If CB.GetUpperBound(0) <> 35 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 0 + 3 '//사용프로필 앞에 두개를 숫자4자리로변환
                            Me.cmb_profile.Text = CStr(IIf(CB(i).Split(CChar(vbTab))(ii).Trim = "", "0", CB(i).Split(CChar(vbTab))(ii).Trim))
                        Case 1 + 3  '//공란
                        Case 2 + 3 '//면적
                            Me.면적NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 3 + 3
                            Me.천장고NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 4 + 3
                            'Me.순실체적NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 5 + 3
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.열저장능력ComboBox.SelectedIndex = -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

                        Case 6 + 3
                            ' If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.열교가산치ComboBox.SelectedIndex = -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 7 + 3
                            Me.침기율NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 8 + 3
                            '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 9 + 3
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방공조ComboBox.SelectedIndex = -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 10 + 3
                            ' If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.외기부하처리여부ComboBox.SelectedIndex = -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 11 + 3 '//지역사용안함
                        Case 12 + 3 '//야간운전방식
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.야간운전방식ComboBox.SelectedIndex = -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 13 + 3 '//주말운전방식
                            ' If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.주말운전방식ComboBox.SelectedIndex = -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 16 + 3 '//일급탕요구량
                            'Me.급탕요구량NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 17 + 3
                        Case 18 + 3
                        Case 19 + 3 '//난방공급시스템-1
                            ' Me.TabControl10.SelectedIndex = 0
                            ' If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방열공급시스템ComboBox.SelectedIndex = -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


                        Case 20 + 3 '//
                            Me.냉난방열공급시스템수NTb.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 21 + 3
                            ' If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방공조처리시스템ComboBox.SelectedIndex = -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 24 + 3 '//열생산지정
                            ' Me.TabControl10.SelectedIndex = 1
                            Me.cmb_열생산지정1.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 25 + 3
                            Me.cmb_열생산급탕기기.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 26 + 3
                            Me.cmb_열생산지정3.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 27 + 3
                            Me.cmb_공조가습생산.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 30 + 3
                            'Me.TabControl10.SelectedIndex = 2
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방공조분배시스템ComboBox.SelectedIndex = -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 31 + 3
                            'If  CB(i).Split(CChar(vbTab))(ii).Trim = "" Then Me.냉난방분배시스템ComboBox.SelectedIndex = -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).Trim = "", "0", CB(i).Trim))
                    End Select
                Next
            Next

            Me.bs.EndEdit()
            isCopy = False
            Me.Validate_Control()
            ' AddNewDataRow_Zone_Changed(Nothing, Nothing)
        End If
    End Sub

    Private Sub Show_점등시간()
        Try
            If cmb_profile.SelectedIndex > 0 Then   '//뭔가선택되면
                Dim Drv As DataRowView = CType(Me.bs.Current, DataRowView)

                Dim DRProf As DS.tbl_profileRow = CType(DSET.tbl_profile.Select("code='" & Drv("프로필").ToString & "'")(0), DS.tbl_profileRow)
                Me.tb_점등시간.Text = DRProf.일일사용시간
                'MsgBox("선택프로필코드=" & Drv("프로필").ToString, MsgBoxStyle.Information, DRProf.일일사용시간)
            Else
                Me.tb_점등시간.Text = "없음"
            End If
        Catch ex As Exception
            Me.tb_점등시간.Text = ex.Message.ToString
        End Try
    End Sub

    Private Sub cmb_profile_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cmb_profile.MouseUp
        If Me.cmb_profile.SelectedIndex < 0 Then Return
        If e.Button = Windows.Forms.MouseButtons.Right Then
            '//냉난방공조처리시스템
            Me.bs.Filter = "프로필='" & cmb_profile.SelectedValue.ToString & "'"


        End If
    End Sub

    Private Sub cmb_profile_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_profile.SelectedIndexChanged
        Me.Validate_Control()

    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
                'DSET.tbl_zone.Clear()
                Dim dR() As DataRow = DSET.tbl_zone.Select(Me.bs.Filter, "")
                For i As Integer = dR.GetUpperBound(0) To 0 Step -1
                    dR(i).Delete()
                Next
                DSET.tbl_zone.AcceptChanges()
            End If
        End If
    End Sub

    Private Sub bs_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bs.CurrentChanged

        '//이존이 어떠한 면들한테 쓰엿는지 그거죠?'/종류가 몇가지요? 내벽 외벽 같은거
        '//입력면은 존분류값이 존이죠? ? 외벽, 외부창, 내벽, 내부창, 간벽 5가지

        If Not Init Then Return
        Dim Drv As DataRowView = CType(bs.Current, DataRowView)
        If Drv Is Nothing Then Return


        Dim Zonecode As String = Drv("code")
        If Zonecode = "0" Then Return

        Show_점등시간()

        Dim cnt1, cnt2, cnt3, cnt4, cnt5 As Integer
        cnt1 = 0 : cnt2 = 0 : cnt3 = 0 : cnt4 = 0 : cnt5 = 0


        Dim DR() As DataRow = DSET.tbl_myoun.Select("code <> '0' and 존분류='" & Drv("code").ToString & "' and 건축부위방식='외벽'")
        If DR.GetUpperBound(0) <> -1 Then cnt1 = (DR.GetUpperBound(0) + 1)

        DR = DSET.tbl_myoun.Select("code <> '0' and 존분류='" & Drv("code").ToString & "' and 건축부위방식='외부창'")
        If DR.GetUpperBound(0) <> -1 Then cnt2 = (DR.GetUpperBound(0) + 1)

        DR = DSET.tbl_myoun.Select("code <> '0' and 존분류='" & Drv("code").ToString & "' and 건축부위방식='내벽'")
        If DR.GetUpperBound(0) <> -1 Then cnt3 = (DR.GetUpperBound(0) + 1)

        DR = DSET.tbl_myoun.Select("code <> '0' and 존분류='" & Drv("code").ToString & "' and 건축부위방식='내부창'")
        If DR.GetUpperBound(0) <> -1 Then cnt4 = (DR.GetUpperBound(0) + 1)

        DR = DSET.tbl_myoun.Select("code <> '0' and 존분류='" & Drv("code").ToString & "' and 건축부위방식='간벽'")
        If DR.GetUpperBound(0) <> -1 Then cnt5 = (DR.GetUpperBound(0) + 1)

        '//각각순서대로 변수에 해당값이 들어갓어요
        '//화면에 표시할 컨트롤 만드시다음에   컨트롤.text = cnt1 식으로  연결만 해주시면됩니다.
        Me.ToolStripLabel3.Text = cnt1.ToString
        If cnt1 > 0 Then
            Me.ToolStripLabel2.ForeColor = Color.Purple
            Me.ToolStripLabel3.ForeColor = Color.Purple
        Else
            Me.ToolStripLabel2.ForeColor = Color.LightGray
            Me.ToolStripLabel3.ForeColor = Color.LightGray
        End If

        Me.ToolStripLabel5.Text = cnt3.ToString
        If cnt3 > 0 Then
            Me.ToolStripLabel4.ForeColor = Color.Purple
            Me.ToolStripLabel5.ForeColor = Color.Purple
        Else
            Me.ToolStripLabel4.ForeColor = Color.LightGray
            Me.ToolStripLabel5.ForeColor = Color.LightGray
        End If

        Me.ToolStripLabel7.Text = cnt2.ToString
        If cnt2 > 0 Then
            Me.ToolStripLabel6.ForeColor = Color.Purple
            Me.ToolStripLabel7.ForeColor = Color.Purple
        Else
            Me.ToolStripLabel6.ForeColor = Color.LightGray
            Me.ToolStripLabel7.ForeColor = Color.LightGray
        End If

        Me.ToolStripLabel9.Text = cnt4.ToString
        If cnt4 > 0 Then
            Me.ToolStripLabel8.ForeColor = Color.Purple
            Me.ToolStripLabel9.ForeColor = Color.Purple
        Else
            Me.ToolStripLabel8.ForeColor = Color.LightGray
            Me.ToolStripLabel9.ForeColor = Color.LightGray
        End If

        Me.ToolStripLabel11.Text = cnt5.ToString
        If cnt5 > 0 Then
            Me.ToolStripLabel10.ForeColor = Color.Purple
            Me.ToolStripLabel11.ForeColor = Color.Purple
        Else
            Me.ToolStripLabel10.ForeColor = Color.LightGray
            Me.ToolStripLabel11.ForeColor = Color.LightGray
        End If

        Me.Validate_Control()

        Me.bs.EndEdit()
    End Sub



    Private Sub 냉난방공조처리시스템ComboBox_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 냉난방공조처리시스템ComboBox.MouseUp
        If e.Button = Windows.Forms.MouseButtons.Right Then
            '//냉난방공조처리시스템
            Me.bs.Filter = "냉난방공조처리시스템='" & 냉난방공조처리시스템ComboBox.SelectedValue.ToString & "'"


        End If
    End Sub


    Private Sub 냉난방공조ComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 냉난방공조ComboBox.SelectedIndexChanged
        ZONE_Control()
    End Sub

    Private Sub ZONE_Control() '//건기연 추가(2010.04.07)
        If Me.Init = False Then Return
        Try
            If Me.냉난방공조ComboBox.SelectedIndex = 4 Then
                외기부하처리여부ComboBox.Enabled = True
                냉난방공조처리시스템ComboBox.Enabled = True
            Else
                외기부하처리여부ComboBox.Enabled = False
                If Me.냉난방공조ComboBox.SelectedIndex = 0 Then
                    냉난방공조처리시스템ComboBox.Enabled = False
                    냉난방공조처리시스템ComboBox.SelectedIndex = 0
                Else
                    냉난방공조처리시스템ComboBox.Enabled = True
                End If
            End If
        Catch ex As Exception

        End Try
        Try
            Select Case Me.냉난방공조ComboBox.SelectedIndex
                Case 0, 4
                    If Me.냉난방공조ComboBox.SelectedIndex = 4 AndAlso Me.외기부하처리여부ComboBox.Enabled AndAlso Me.외기부하처리여부ComboBox.Text = "예" Then
                        Me.cmb_공조난방생산.Enabled = True
                        Me.cmb_공조가습생산.Enabled = True
                        Me.cmb_공조냉방생산.Enabled = True
                        'Me.cmb_공조난방생산.BackColor = Nothing
                        'Me.cmb_공조냉방생산.BackColor = Nothing
                        'Me.cmb_공조가습생산.BackColor = Nothing
                        'Me.cmb_공조난방생산.ForeColor = Nothing
                        'Me.cmb_공조냉방생산.ForeColor = Nothing
                        'Me.cmb_공조가습생산.ForeColor = Nothing
                        'Me.cmb_공조난방생산.Font = New Font(Me.cmb_공조난방생산.Font, FontStyle.Regular)
                        'Me.cmb_공조냉방생산.Font = New Font(Me.cmb_공조난방생산.Font, FontStyle.Regular)
                        'Me.cmb_공조가습생산.Font = New Font(Me.cmb_공조난방생산.Font, FontStyle.Regular)

                    Else
                        Me.cmb_공조난방생산.Enabled = False
                        Me.cmb_공조가습생산.Enabled = False
                        Me.cmb_공조냉방생산.Enabled = False
                        'Me.cmb_공조난방생산.BackColor = Color.LightGray
                        'Me.cmb_공조냉방생산.BackColor = Color.LightGray
                        'Me.cmb_공조가습생산.BackColor = Color.LightGray
                        'If Me.cmb_공조난방생산.SelectedIndex <> 0 Then
                        '    Me.cmb_공조난방생산.ForeColor = Color.Red
                        '    Me.cmb_공조난방생산.Font = New Font(Me.cmb_공조난방생산.Font, FontStyle.Strikeout)
                        'End If
                        'If Me.cmb_공조가습생산.SelectedIndex <> 0 Then
                        '    Me.cmb_공조가습생산.ForeColor = Color.Red
                        '    Me.cmb_공조가습생산.Font = New Font(Me.cmb_공조난방생산.Font, FontStyle.Strikeout)
                        'End If
                        'If Me.cmb_공조냉방생산.SelectedIndex <> 0 Then
                        '    Me.cmb_공조냉방생산.ForeColor = Color.Red
                        '    Me.cmb_공조냉방생산.Font = New Font(Me.cmb_공조난방생산.Font, FontStyle.Strikeout)
                        'End If

                    End If
                    Me.cmb_냉난방방식.ForeColor = Nothing
                    'Me.cmb_냉난방방식.Font = New Font(Me.cmb_냉난방방식.Font, FontStyle.Regular)
                    Me.ErrProvider.SetError(Me.cmb_냉난방방식, "")
                Case 1
                    If Me.외기부하처리여부ComboBox.Enabled AndAlso Me.외기부하처리여부ComboBox.Text = "예" Then
                        Me.cmb_공조난방생산.Enabled = True
                        Me.cmb_공조가습생산.Enabled = True
                    Else
                        Me.cmb_공조난방생산.Enabled = False
                        Me.cmb_공조가습생산.Enabled = False
                    End If
                    Me.cmb_공조냉방생산.Enabled = True
                    If Me.cmb_냉난방방식.SelectedIndex = 0 OrElse Me.cmb_냉난방방식.SelectedIndex = 2 Then
                        Me.cmb_냉난방방식.ForeColor = Nothing
                        'Me.cmb_냉난방방식.Font = New Font(Me.cmb_냉난방방식.Font, FontStyle.Regular)
                        Me.ErrProvider.SetError(Me.cmb_냉난방방식, "")
                    Else
                        Me.cmb_냉난방방식.ForeColor = Color.Red
                        'Me.cmb_냉난방방식.Font = New Font(Me.cmb_냉난방방식.Font, FontStyle.Strikeout)
                        Me.ErrProvider.SetError(Me.cmb_냉난방방식, "이건 안된다구요")
                    End If
                Case 2
                    If Me.외기부하처리여부ComboBox.Enabled AndAlso Me.외기부하처리여부ComboBox.Text = "예" Then
                        Me.cmb_공조냉방생산.Enabled = True
                    Else
                        Me.cmb_공조냉방생산.Enabled = False
                    End If
                    Me.cmb_공조난방생산.Enabled = True
                    Me.cmb_공조가습생산.Enabled = True
                    If Me.cmb_냉난방방식.SelectedIndex = 0 OrElse Me.cmb_냉난방방식.SelectedIndex = 1 Then
                        Me.cmb_냉난방방식.ForeColor = Nothing
                        'Me.cmb_냉난방방식.Font = New Font(Me.cmb_냉난방방식.Font, FontStyle.Regular)
                        Me.ErrProvider.SetError(Me.cmb_냉난방방식, "")
                    Else
                        Me.cmb_냉난방방식.ForeColor = Color.Red
                        'Me.cmb_냉난방방식.Font = New Font(Me.cmb_냉난방방식.Font, FontStyle.Strikeout)
                        Me.ErrProvider.SetError(Me.cmb_냉난방방식, "이건 안된다구요")
                    End If
                Case 3
                    Me.cmb_공조난방생산.Enabled = True
                    Me.cmb_공조가습생산.Enabled = True
                    Me.cmb_공조냉방생산.Enabled = True
                    If Me.cmb_냉난방방식.SelectedIndex = 0 Then
                        Me.cmb_냉난방방식.ForeColor = Nothing
                        'Me.cmb_냉난방방식.Font = New Font(Me.cmb_냉난방방식.Font, FontStyle.Regular)
                        Me.ErrProvider.SetError(Me.cmb_냉난방방식, "")
                    Else
                        Me.cmb_냉난방방식.ForeColor = Color.Red
                        'Me.cmb_냉난방방식.Font = New Font(Me.cmb_냉난방방식.Font, FontStyle.Strikeout)
                        Me.ErrProvider.SetError(Me.cmb_냉난방방식, "이건 안된다구요")
                    End If

                Case Else

            End Select
        Catch ex As Exception

        End Try

        Try
            Select Case Me.cmb_냉난방방식.SelectedIndex
                Case 0
                    Me.냉난방공조ComboBox.ForeColor = Nothing
                    Me.ErrProvider.SetError(Me.냉난방공조ComboBox, "")
                    Me.cmb_열생산지정1.Enabled = False
                    Me.cmb_열생산지정3.Enabled = False
                Case 1
                    Me.cmb_열생산지정1.Enabled = False
                    Me.cmb_열생산지정3.Enabled = True
                    If Me.냉난방공조ComboBox.SelectedIndex = 0 OrElse Me.냉난방공조ComboBox.SelectedIndex = 2 OrElse Me.냉난방공조ComboBox.SelectedIndex = 4 Then
                        Me.냉난방공조ComboBox.ForeColor = Nothing
                        Me.ErrProvider.SetError(Me.냉난방공조ComboBox, "")
                    Else
                        Me.냉난방공조ComboBox.ForeColor = Color.Red
                        Me.ErrProvider.SetError(Me.냉난방공조ComboBox, "이건 안된다구요")
                    End If
                Case 2
                    Me.cmb_열생산지정1.Enabled = True
                    Me.cmb_열생산지정3.Enabled = False
                    If Me.냉난방공조ComboBox.SelectedIndex = 0 OrElse Me.냉난방공조ComboBox.SelectedIndex = 1 OrElse Me.냉난방공조ComboBox.SelectedIndex = 4 Then
                        Me.냉난방공조ComboBox.ForeColor = Nothing
                        Me.ErrProvider.SetError(Me.냉난방공조ComboBox, "")
                    Else
                        Me.냉난방공조ComboBox.ForeColor = Color.Red
                        Me.ErrProvider.SetError(Me.냉난방공조ComboBox, "이건 안된다구요")
                    End If
                Case 3
                    Me.cmb_열생산지정1.Enabled = True
                    Me.cmb_열생산지정3.Enabled = True
                    If Me.냉난방공조ComboBox.SelectedIndex = 0 OrElse Me.냉난방공조ComboBox.SelectedIndex = 4 Then
                        Me.냉난방공조ComboBox.ForeColor = Nothing
                        Me.ErrProvider.SetError(Me.냉난방공조ComboBox, "")
                    Else
                        Me.냉난방공조ComboBox.ForeColor = Color.Red
                        Me.ErrProvider.SetError(Me.냉난방공조ComboBox, "이건 안된다구요")
                    End If

                Case Else

            End Select
        Catch ex As Exception

        End Try

        Try
            If Me.cmb_냉난방방식.SelectedIndex = 0 Then
                Me.냉난방열공급시스템ComboBox.Enabled = False
                Me.냉난방열공급시스템수NTb.Enabled = False
                '냉난방분배시스템ComboBox.SelectedIndex = 0
                'Me.냉난방열공급시스템수NTb.Text = "0" '// 2010.11.29 수정
            Else
                Me.냉난방열공급시스템ComboBox.Enabled = True
                Me.냉난방열공급시스템수NTb.Enabled = True

            End If
        Catch ex As Exception

        End Try
        bs.EndEdit()
    End Sub

    Private Sub cmb_냉난방방식_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_냉난방방식.SelectedIndexChanged
        ZONE_Control()
    End Sub

    Private Sub 면적NTb_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles 면적NTb.TextChanged
        순실체적NTb.Text = TOST(TOSG(면적NTb.Text) * TOSG(천장고NTb.Text))
    End Sub

    Private Sub 천장고NTb_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles 천장고NTb.TextChanged
        순실체적NTb.Text = TOST(TOSG(면적NTb.Text) * TOSG(천장고NTb.Text))
    End Sub

    Private Sub 순실체적NTb_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles 순실체적NTb.MouseHover
        순실체적NTb.Text = TOST(TOSG(면적NTb.Text) * TOSG(천장고NTb.Text))
    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
                        Del_ZoneMyoun(False)
                        '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 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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    CType(Me.bs.Current, DataRowView)("공조난방생산기기") = DBNull.Value
    '    CType(Me.bs.Current, DataRowView)("공조냉방생산기기") = DBNull.Value
    '    If MsgBox("sdf", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
    '        Me.bs.EndEdit()
    '        Me.bsmain.EndEdit()
    '    End If
    'End Sub

    Private Sub 외기부하처리여부ComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 외기부하처리여부ComboBox.SelectedIndexChanged
        ZONE_Control()
    End Sub
    Private Sub Del_ZoneMyoun(ByVal prompt As Boolean)
        If prompt Then
            If MsgBox("선택된 줄을 삭제하시겠습니까?", MsgBoxStyle.OkCancel Or MsgBoxStyle.Information, "삭제확인") <> MsgBoxResult.Ok Then Return
        End If
        Dim Drv As DataRowView = CType(bs.Current, DataRowView)
        If Drv Is Nothing Then Return
        Dim DR() As DataRow = DSET.tbl_myoun.Select("code <> '0' and 존분류='" & Drv("code").ToString & "'")
        If DR.GetUpperBound(0) <> -1 Then
            For i As Integer = DR.GetUpperBound(0) To 0 Step -1
                DR(i).Delete()
            Next
        End If
        Me.bs.RemoveCurrent()
    End Sub

    Private Sub bt_copy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_copy.Click
        If Me.bs.Current Is Nothing Then Return
        Me.SrcDrv = Me.bs.Current
        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 Sub
End Class