Public Class Frm_V20091231_Myoun

    Dim isCopy As Boolean = False
    Dim Init As Boolean = False
    Dim SrcDrv As DataRowView

    Dim SelectedZone As String = ""
    Dim SelectedZoneName As String = ""

    Public Sub New(_opentime)

        ' 이 호출은 디자이너에 필요합니다.
        InitializeComponent()
        OpenTime = _opentime
        ' InitializeComponent() 호출 뒤에 초기화 코드를 추가하십시오.

    End Sub

#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

        Init = False

        Me.Show()
        My.Application.DoEvents()
        'Work_msg_timer("잠시만 기다려주세요")


        If Prj.UserAuthType = "ADMIN" OrElse Prj.UserAuthType = "BOTH" OrElse Prj.UserAuthType = "BOTH2" OrElse Prj.UserAuthType = "BOTH1" Then  '//2011.03.08 추가
            Me.ToolStripLabel1.Visible = True
            Me.ToolStripLabel3.Visible = True
            Me.ToolStripLabel5.Visible = True
            Me.lbl_cnt1.Visible = True
            Me.lbl_cnt2.Visible = True
            Me.lbl_cnt3.Visible = True
            Me.lbl_cnt4.Visible = True
        Else
            Me.ToolStripLabel1.Visible = False
            Me.ToolStripLabel3.Visible = False
            Me.ToolStripLabel5.Visible = False
            Me.lbl_cnt1.Visible = False
            Me.lbl_cnt2.Visible = False
            Me.lbl_cnt3.Visible = False
            Me.lbl_cnt4.Visible = False
        End If

        '//공유데이터셋에 연결한다.
        Me.bs.DataSource = DSET1
        Me.bszone.DataSource = DSET1

        '//입력면
        AddHandler DSET1.tbl_myoun.TableNewRow, AddressOf TblAddNew
        '//AddHandler DSET1.tbl_myoun.ColumnChanged, AddressOf TblColumnChanged
        AddHandler DSET1.tbl_myoun.ColumnChanging, AddressOf TblColumnChanging
        '//콤보컨트롤 바인딩
        Binding_Zone()

        Me.bszone.Filter = "code <> '0'"
        If Me.Parameter <> "" Then Me.bszone.Filter &= " and 그룹 ='" + Me.Parameter + "'"

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

        Try
            Me.bszone.Position = CEnergy.ARINCLASS.Read_LastPos_Frm(Me.Name & "1")
        Catch ex As Exception
            Me.bszone.MoveFirst()
        End Try

        '//마지막저장된 존의이름이 일치하면 면의 레코드를 이동
        Dim LastZoneName As String = CEnergy.ARINCLASS.Read_LastZone(Me.Name)
        Dim DRv As DataRowView = Me.bszone.Current
        If Not DRv Is Nothing Then
            Dim CurZoneName As String = DRv("설명").ToString
            If LastZoneName = CurZoneName Then
                Try
                    Me.bs.Position = CEnergy.ARINCLASS.Read_LastPos_Frm(Me)
                Catch ex As Exception
                    Me.bs.MoveFirst()
                End Try
            Else
                Me.bs.MoveFirst()
            End If
        Else
            Me.bs.MoveFirst()
        End If

        'bs_CurrentChanged(sender, e)    '//현재데이터변경이벤트추가
        Validate_Control()

        AddDebug("form load ok")
    End Sub

    Private Sub TblAddNew(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs)
        AddDebug("♠TblAddNew")

        '//존분류값가져오기
        'If Me.FilterMode Then
        '    If MsgBox("현재 필터적용상태에서는 추가할 수 없습니다" & vbCrLf & "필터상태를 해제하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then
        '        Return  '//필터상태에서는 추가불가 / 다른존의 값이 들어갈수있음(방지코드)
        '    Else
        '        Me.FilterMode = False
        '        MsgBox("추가할 존을 다시 선택하세요", MsgBoxStyle.Information, "확인")
        '        Return
        '    End If
        'End If
        If Me.SelectedZone = "" Then
            'MsgBox("선택된 존이없으므로 추가할 수 없습니다!", MsgBoxStyle.Critical, "확인")
            Return
        End If

        Dim Zone As String = Me.SelectedZone
        e.Row.Item("존분류") = Zone
        e.Row.Item("code") = GetMaxCode(DSET1.tbl_myoun)
        'e.Row.Item("열관류율2") = Me.cmb_gubun.Text  '//선택된 그것의 값이 들어가도록..필드명만찾아서 입력하세요.
        e.Row.Item("sortkey") = GetNewSortKey(DSET1.tbl_myoun, Zone)
        '//동일존을 가지는 면데이터로부터 마지막 sortkey 를 가져와서 설정한다.

        Try
            If Me.cmb_gubun.SelectedIndex = -1 OrElse Me.cmb_gubun.Text = "(없음)" Then
                e.Row.Item("설명") = bs.Count + 1 & "_" & Me.SelectedZoneName
            Else
                e.Row.Item("설명") = Me.cmb_gubun.Text & "_" & Me.SelectedZoneName
            End If
        Catch ex As Exception
            e.Row.Item("설명") = Me.SelectedZoneName
        End Try

        'Select Case Me.cmb_gubun.Text
        '    Case "외벽"
        '        e.Row.Item("설명") = DRv("설명").ToString & "_외벽" & bs.Count + 1
        '    Case "외부창"
        '        e.Row.Item("설명") = DRv("설명").ToString & "_외부창" & bs.Count + 1
        '    Case "내벽"
        '        e.Row.Item("설명") = DRv("설명").ToString & "_내벽" & bs.Count + 1
        '    Case "간벽"
        '        e.Row.Item("설명") = DRv("설명").ToString & "_간벽" & bs.Count + 1
        '    Case "내부창"
        '        e.Row.Item("설명") = DRv("설명").ToString & "_내부창" & bs.Count + 1
        'End Select
    End Sub

    Private Function GetNewSortKey(ByRef dt As DS.tbl_myounDataTable, Optional Zone As String = "") As String
        AddDebug("GetNewSortKey")


        If Not String.IsNullOrWhiteSpace(Zone) Then
            Dim drows() As DS.tbl_myounRow = dt.Select("존분류='" + Zone + "' and code <> '0'", "sortkey desc")
            If drows.Length < 1 Then Return 1
            Dim Dr As DS.tbl_myounRow = drows(0)
            Dim maxsortkey As Integer = Dr.sortkey
            Return maxsortkey + 1
        Else
            Dim drows() As DS.tbl_myounRow = dt.Select("code <> '0'", "sortkey desc")
            If drows.Length < 1 Then Return 1
            Dim Dr As DS.tbl_myounRow = drows(0)
            Dim maxsortkey As Integer = Dr.sortkey
            Return maxsortkey + 1
        End If

    End Function


#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, "")
                    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)
        If CType(sender, ComboBox).SelectedIndex = -1 Then Return
        Me.ToolTip1.SetToolTip(CType(sender, ComboBox), CType(sender, ComboBox).DataBindings("selectedvalue").BindingMemberInfo.BindingMember & vbCrLf & CType(sender, ComboBox).SelectedValue.ToString)

    End Sub
#End Region
#Region "ComboxBox Binding"

    Private Sub ShowHistory()
        AddDebug("ShowHistory")

        Dim drv As DataRowView = Me.bs.Current
        Dim f As New Frm_History("tbl_myoun", drv("code").ToString)
        If f.ShowDialog = DialogResult.OK Then
            drv(f.colname) = f.val
            Me.Validate()
            Me.bs.EndEdit()
            My.Application.DoEvents()
            MsgBox("값이 변경되었습니다", MsgBoxStyle.Information, "확인")
        End If
    End Sub
    Private Sub TblColumnChanging(ByVal sender As Object, ByVal e As System.Data.DataColumnChangeEventArgs)

        Dim oval As String = e.Row(e.Column.ColumnName).ToString
        Dim nval As String = e.ProposedValue.ToString

        AddDebug(String.Format("♠TblColumnChanging {0} {1}->{2}", e.Column.ColumnName, oval, nval))

        If oval <> nval Then
            Dim newdr As DS2.historyRow = DSHistory.history.NewhistoryRow
            newdr.time = Now.ToString("yyyy-MM-dd HH:mm:ss")
            newdr.tablename = "tbl_myoun"
            newdr.ovalue = oval
            newdr.nvalue = nval
            newdr.column = e.Column.ColumnName
            newdr.code = e.Row("code").ToString
            DSHistory.history.AddhistoryRow(newdr)
            DSHistory.history.AcceptChanges()
        End If
    End Sub


    'Private Sub TblColumnChanged(ByVal sender As Object, ByVal e As System.Data.DataColumnChangeEventArgs)
    '    AddDebug("♠TblColumnChanged")

    '    Dim oval As String = e.Row(e.Column.ColumnName).ToString
    '    Dim nval As String = e.ProposedValue.ToString

    '    Select Case e.Column.Caption.Trim
    '        Case "건축부위방식"
    '            If e.ProposedValue.ToString = "내벽" OrElse e.ProposedValue.ToString = "간벽" OrElse e.ProposedValue.ToString = "내부창" Then
    '                'e.Row("방위") = "일사없음" '//언제바뀌엇는지 모름, 재확인 160327
    '            End If
    '            Me.bs.EndEdit()
    '    End Select

    '    '//값이 바뀌는 내역을 모두 저장한다. 시간,필드,이전값,바뀐값,테이블
    'End Sub

    Private Sub MdiMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        AddDebug("MdiMain_FormClosed")

        RemoveHandler DSET1.tbl_myoun.TableNewRow, AddressOf TblAddNew
        RemoveHandler DSET1.tbl_myoun.ColumnChanging, AddressOf TblColumnChanging

        CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me, Me.bs.Position, True)
        CEnergy.ARINCLASS.Save_LastPos_Frm(Me.Name & "1", Me.bszone.Position)
        CEnergy.ARINCLASS.Save_LastZone(Me.Name, Me.SelectedZoneName) '//선택된 존의 이름을 저장
    End Sub

    Private Sub Frm_V20091231_Zone_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
        If e.Delta < 0 Then
            If Me.bs.Position < Me.bs.Count Then Me.bs.Position += 1
        Else
            If Me.bs.Position > 0 Then Me.bs.Position -= 1
        End If
        Me.Validate()
        My.Application.DoEvents()
    End Sub
    Private Sub MdiMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Select Case e.KeyCode
            Case Keys.F12
                ShowHistory()
            Case Keys.A
                If e.Alt Then
                    bt_add.PerformClick()
                End If
        End Select
    End Sub

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

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

#Region "제어버튼"


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

        'If Me.FilterMode Then
        '    If MsgBox("현재 필터적용상태에서는 추가할 수 없습니다" & vbCrLf & "필터상태를 해제하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then
        '        Return  '//필터상태에서는 추가불가 / 다른존의 값이 들어갈수있음(방지코드)
        '    Else
        '        Me.FilterMode = False
        '        MsgBox("추가할 존을 다시 선택하세요", MsgBoxStyle.Information, "확인")
        '        Return
        '    End If
        'End If

        If Me.SelectedZone = "" Then
            MsgBox("선택된 존이없으므로 추가할 수 없습니다.", MsgBoxStyle.Critical, "확인")
            Return
        End If

        '//Me.cmb_gubun.SelectedIndex = 0
        Me.bs.AddNew()
        INitRow(Me.Controls)
        '//추가한후에
        Me.cmb_열관류율.Text = Me.cmb_gubun.Text
        '//이게 콤보넣을떄인데요. 면의형태의 값을.. 어디다가 넣으시게요?

        Dim Dr1() As DS.tbl_ykRow = DSET1.tbl_yk.Select("설명='" & Me.cmb_gubun.Text & "'")
        If Dr1.GetUpperBound(0) = 0 Then   '//해당데이터가 찾아졋을경우에


            Dim dr2() As DS.tbl_commonRow = DSET1.tbl_common.Select("gubun='1088' and code='" & Dr1(0).면형태 & "'")
            Dim 면형태 As String = dr2(0).name
            Select Case 면형태
                Case "외벽(벽체)"
                    Me.cmb_건축부위방식.Text = "외벽"
                Case "외벽(지붕)"
                    Me.cmb_건축부위방식.Text = "외벽"
                    Me.cmb_방위.Text = "수평"
                Case "외벽(바닥)"
                    Me.cmb_건축부위방식.Text = "외벽"
                    Me.cmb_방위.Text = "일사없음"
                Case "내벽(벽체)", "지중벽"
                    Me.cmb_건축부위방식.Text = "내벽"
                    Me.cmb_방위.Text = "일사없음"
                Case "내벽(지붕)"
                    Me.cmb_건축부위방식.Text = "내벽"
                    Me.cmb_방위.Text = "일사없음"
                Case "내벽(바닥)"
                    Me.cmb_건축부위방식.Text = "내벽"
                    Me.cmb_방위.Text = "일사없음"
                Case "간벽"
                    Me.cmb_건축부위방식.Text = "간벽"
                    Me.cmb_방위.Text = "일사없음"
                Case "외부창", "내부창"
                    If 면형태 = "외부창" Then
                        Me.cmb_건축부위방식.Text = "외부창"
                    Else
                        Me.cmb_건축부위방식.Text = "내부창"
                        Me.cmb_방위.Text = "일사없음"
                    End If
                    Dim Dr As DS.tbl_ykRow = DSET1.tbl_yk.Select("code='" & Me.cmb_열관류율.SelectedValue & "'")(0)
                    Me.tb_04.Text = Dr.투과율

                Case Else
                    MsgBox("모르는값 " & Dr1(0).면형태 & "/" & 면형태)
            End Select
        Else
            MsgBox("못찻음")
        End If
        MdiMain.RefreshMenuList(TreeTag)
    End Sub


    Private Sub ToolStripButton49_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_Del.Click
        'MsgBox(Me.bs.ToString)
        Dbbase.DelCrow(Me.bs, True)
        MdiMain.RefreshMenuList(TreeTag)
    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(DSET1.tbl_profile, Nothing)
        MdiMain.RefreshMenuList(TreeTag)
    End Sub

#End Region

    Private Sub Binding_Zone()
        AddDebug("Binding_Zone")

        '//구분 콤봅박스
        Me.cmb_gubun.Items.Clear()
        For Each Dr As DS.tbl_ykRow In DSET1.tbl_yk.Select("")
            Me.cmb_gubun.Items.Add(Dr.설명)
        Next
        '//콤보의 리스트가없는데 0번 지정하려니 오류난거에요 콤보는 여기서 만들어지니.. 이렇게 해야겟죠
        If Me.cmb_gubun.Items.Count > 0 Then Me.cmb_gubun.SelectedIndex = 0

        Dim bs_건축부위방식 As New BindingSource(DSET1, "tbl_common")
        bs_건축부위방식.Filter = "gubun='1067'"
        bs_건축부위방식.Sort = "code"
        Me.cmb_건축부위방식.DataSource = bs_건축부위방식
        cmb_건축부위방식.DisplayMember = "name"
        cmb_건축부위방식.ValueMember = "name"
        Me.cmb_건축부위방식.DataBindings.Add("selectedvalue", Me.bs, "건축부위방식")
        AddHandler cmb_건축부위방식.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_블라인드유무 As New BindingSource(DSET1, "tbl_common")
        bs_블라인드유무.Filter = "gubun='1032'"
        bs_블라인드유무.Sort = "code"
        Me.cmb_블라인드설치유무.DataSource = bs_블라인드유무
        cmb_블라인드설치유무.DisplayMember = "name"
        cmb_블라인드설치유무.ValueMember = "name"
        Me.cmb_블라인드설치유무.DataBindings.Add("selectedvalue", Me.bs, "블라인드유무")
        AddHandler cmb_블라인드설치유무.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_블라인드위치 As New BindingSource(DSET1, "tbl_common")
        bs_블라인드위치.Filter = "gubun='1068'"
        bs_블라인드위치.Sort = "code"
        Me.cmb_블라인드위치.DataSource = bs_블라인드위치
        cmb_블라인드위치.DisplayMember = "name"
        cmb_블라인드위치.ValueMember = "name"
        Me.cmb_블라인드위치.DataBindings.Add("selectedvalue", Me.bs, "블라인드위치")
        AddHandler cmb_블라인드위치.KeyDown, AddressOf Cmb_DeleteVal

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

        Dim bs_블라인드종류 As New BindingSource(DSET1, "tbl_common")
        bs_블라인드종류.Filter = "gubun='1069'"
        bs_블라인드종류.Sort = "code"
        Me.cmb_블라인드종류.DataSource = bs_블라인드종류
        cmb_블라인드종류.DisplayMember = "name"
        cmb_블라인드종류.ValueMember = "name"
        Me.cmb_블라인드종류.DataBindings.Add("selectedvalue", Me.bs, "블라인드빛종류")
        AddHandler cmb_블라인드종류.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_블라인드색상 As New BindingSource(DSET1, "tbl_common")
        bs_블라인드색상.Filter = "gubun='1070'"
        bs_블라인드색상.Sort = "code"
        Me.cmb_블라인드색상.DataSource = bs_블라인드색상
        cmb_블라인드색상.DisplayMember = "name"
        cmb_블라인드색상.ValueMember = "name"
        Me.cmb_블라인드색상.DataBindings.Add("selectedvalue", Me.bs, "블라인드색상")
        AddHandler cmb_블라인드색상.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_블라인드각도 As New BindingSource(DSET1, "tbl_common")
        bs_블라인드각도.Filter = "gubun='1071'"
        bs_블라인드각도.Sort = "code"
        Me.cmb_블라인드각도.DataSource = bs_블라인드각도
        cmb_블라인드각도.DisplayMember = "name"
        cmb_블라인드각도.ValueMember = "name"
        Me.cmb_블라인드각도.DataBindings.Add("selectedvalue", Me.bs, "블라인드각도")
        AddHandler cmb_블라인드각도.KeyDown, AddressOf Cmb_DeleteVal


        Dim bs_존분류 As New BindingSource(DSET1, "tbl_zone")
        bs_존분류.Sort = "code"
        Me.cmb_존분류.DataSource = bs_존분류
        cmb_존분류.DisplayMember = "그룹설명"
        cmb_존분류.ValueMember = "code"
        Me.cmb_존분류.DataBindings.Add("selectedvalue", Me.bs, "존분류")
        AddHandler cmb_존분류.KeyDown, AddressOf Cmb_DeleteVal

        Dim bs_대차존 As New BindingSource(DSET1, "tbl_zone")
        bs_대차존.Sort = "code"
        Me.cmb_대차존.DataSource = bs_대차존
        cmb_대차존.DisplayMember = "설명"
        cmb_대차존.ValueMember = "code"
        Me.cmb_대차존.DataBindings.Add("selectedvalue", Me.bs, "대차대조존")
        AddHandler cmb_대차존.KeyDown, AddressOf Cmb_DeleteVal
        '//존연결해야한다.

        '//여긴괜찮아요 보이는게아네요 
        Dim bs_열관류율2 As New BindingSource(DSET1, "tbl_yk")
        bs_열관류율2.Sort = "code"
        Me.cmb_열관류율.DataSource = bs_열관류율2
        cmb_열관류율.DisplayMember = "설명"
        cmb_열관류율.ValueMember = "code"
        Me.cmb_열관류율.DataBindings.Add("selectedvalue", Me.bs, "열관류율2")
        AddHandler cmb_열관류율.KeyDown, AddressOf Cmb_DeleteVal

    End Sub


#End Region

    ''' <summary>
    ''' 콤보박스등에의한 개체의 활성화여부를 확인
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Validate_Control()

        AddDebug("Validate_Control")

        If Not Init Then Return
        If Me.isCopy Then Return

        Try
            If Me.cmb_블라인드설치유무.Text = "유" Then
                Me.cmb_블라인드위치.Enabled = True
                Me.cmb_블라인드각도.Enabled = True
                Me.cmb_블라인드색상.Enabled = True
                Me.cmb_블라인드종류.Enabled = True
            Else
                Me.cmb_블라인드위치.Enabled = False
                Me.cmb_블라인드각도.Enabled = False
                Me.cmb_블라인드색상.Enabled = False
                Me.cmb_블라인드종류.Enabled = False
            End If
            Me.bs.EndEdit()
        Catch ex As Exception
            Me.cmb_블라인드설치유무.SelectedIndex = 1
        End Try

        Try
            If Me.cmb_열관류율.Text = "(없음)" OrElse Me.cmb_열관류율.Text = "" Then
                Me.tb_03.Enabled = True
                Me.cmb_건축부위방식.Enabled = True
            Else
                Me.tb_03.Enabled = False
                Me.cmb_건축부위방식.Enabled = False
            End If
        Catch ex As Exception

        End Try

        Try
            If Me.cmb_건축부위방식.Text = "내벽" OrElse Me.cmb_건축부위방식.Text = "간벽" Then
                'Me.cmb_방위.Text = "(없음)" '=========================2011.05.25 수정
                Me.cmb_방위.Enabled = False
            Else
                Me.cmb_방위.Enabled = True
            End If

            '//160327 방위와 활성화여부를 동일하게한다
            Me.rad1.Enabled = Me.cmb_방위.Enabled
            Me.rad2.Enabled = Me.cmb_방위.Enabled
            Me.rad3.Enabled = Me.cmb_방위.Enabled
            Me.rad4.Enabled = Me.cmb_방위.Enabled
            Me.rad5.Enabled = Me.cmb_방위.Enabled
            Me.rad6.Enabled = Me.cmb_방위.Enabled
            Me.rad7.Enabled = Me.cmb_방위.Enabled
            Me.rad8.Enabled = Me.cmb_방위.Enabled
            Me.rad9.Enabled = Me.cmb_방위.Enabled
            Me.rad10.Enabled = Me.cmb_방위.Enabled
            Me.rad0.Enabled = Me.cmb_방위.Enabled

            bs.EndEdit()
        Catch ex As Exception

        End Try

        Try
            If Me.cmb_건축부위방식.Text = "외부창" OrElse Me.cmb_건축부위방식.Text = "내부창" Then
                Me.tb_04.Enabled = True
                Me.tb_05.Enabled = True
                Me.tb_06.Enabled = True
            Else
                'Me.tb_04.Enabled = False
                Me.tb_05.Enabled = False
                Me.tb_06.Enabled = False
            End If
        Catch ex As Exception

        End Try



        Try
            If Me.cmb_건축부위방식.Text = "외부창" OrElse Me.cmb_건축부위방식.Text = "내부창" Then
                Me.GroupBox3.Enabled = True
                Me.GroupBox4.Enabled = True
            Else
                Me.GroupBox3.Enabled = False
                Me.GroupBox4.Enabled = False
            End If
        Catch ex As Exception

        End Try
        Display_info()

    End Sub
    Private Sub Display_info()

        AddDebug("Display_info")

        Dim WallArea As Decimal, WindowArea As Decimal
        WallArea = 0
        WindowArea = 0

        'If Me.cmb_열관류율.SelectedIndex > 0 Then'
        Dim 열관류율합 As Double
        Dim 존수 As Integer = 0
        Dim 비연결 As Integer = 0
        Dim 비연결존 As String = ""

        'ToolStripLabel2
        Dim 면데이터() As DS.tbl_myounRow = DSET1.tbl_myoun.Select("code <> '0' and (건축부위방식='외벽' or 건축부위방식 ='외부창' or 건축부위방식='내벽' or 건축부위방식 ='내부창')")

        ' Dim fn1 As String = My.Application.Info.DirectoryPath & "\t1.txt"
        'Dim fn2 As String = My.Application.Info.DirectoryPath & "\t2.txt"
        Dim 열관없는갯수 As Integer = 0
        Try
            For Each Dr입력면 As DS.tbl_myounRow In 면데이터
                Dim 열관 As Single = 0

                If Dr입력면.열관류율2 = "0" OrElse Dr입력면.열관류율2 = "" Then
                    열관없는갯수 += 1
                End If

                Dim Dryk As DS.tbl_ykRow = Nothing
                If Dr입력면.열관류율2 <> "0" Then '
                    Dryk = DSET1.tbl_yk.Select("code='" & Dr입력면.열관류율2 & "'")(0)
                    열관 = TOSG(Dryk("열관류율").ToString)
                Else '//선택안된경우
                    열관 = TOSG(Dr입력면.열관류율)
                End If

                Dim 존코드 As String = Dr입력면.존분류
                Dim dr존() As DS.tbl_zoneRow = DSET1.tbl_zone.Select("code='" + 존코드 + "'")
                If dr존.GetUpperBound(0) = -1 Then
                    존수 = 1
                Else
                    If IsNumeric(dr존(0).입력존의수) Then
                        존수 = CInt(dr존(0).입력존의수)
                    Else
                        존수 = 1
                    End If
                End If

                Select Case Dr입력면.건축부위방식
                    Case "외벽"
                        열관류율합 += 열관 * 1 * TOSG(Dr입력면.건축부위면적) * 존수
                    Case "내벽"
                        열관류율합 += 열관 * 0.7 * TOSG(Dr입력면.건축부위면적) * 존수
                    Case "외부창"
                        열관류율합 += 열관 * 1 * TOSG(Dr입력면.건축부위면적) * 존수
                    Case "내부창"
                        열관류율합 += 열관 * 0.8 * TOSG(Dr입력면.건축부위면적) * 존수
                End Select

                '//    Debug.WriteLine(Dr입력면.열관류율2 + "/" + Dr입력면.code + "/" + 열관.ToString() + "/" + Dr입력면.설명 + "/" + Dr입력면.건축부위면적.ToCharArray() + "/" + 존수.ToString() + "/" + 열관류율합.ToString(), True)

                If Dryk Is Nothing Then
                    비연결 += 1

                    '//사용한 존
                    If dr존 Is Nothing Then
                    Else
                        비연결존 = dr존(0).설명 + "의 " + Dr입력면.설명
                    End If


                    '//열관류 선택안된경우
                    Select Case Dr입력면.건축부위방식
                        Case "외벽"
                            If Dr입력면.방위 <> "수평" AndAlso Dr입력면.방위 <> "일사없음" AndAlso Dr입력면.방위 <> "(없음)" Then
                                WallArea = WallArea + TOSG(Dr입력면.건축부위면적) * 존수
                            End If
                        Case "내벽" '
                            WallArea = WallArea + TOSG(Dr입력면.건축부위면적) * 존수
                        Case "외부창"
                            If Dr입력면.방위 <> "수평" AndAlso Dr입력면.방위 <> "일사없음" AndAlso Dr입력면.방위 <> "(없음)" Then
                                WindowArea = WindowArea + TOSG(Dr입력면.건축부위면적) * 존수
                            End If
                        Case "내부창"
                            WindowArea = WindowArea + TOSG(Dr입력면.건축부위면적) * 존수
                    End Select

                Else

                    Dim 면형태이름 As String = Get_CName("1088", Dryk.면형태)
                    Select Case 면형태이름
                        Case "외벽(벽체)"
                            WallArea = WallArea + TOSG(Dr입력면.건축부위면적) * 존수
                        Case "내벽(벽체)"
                            WallArea = WallArea + TOSG(Dr입력면.건축부위면적) * 존수
                        Case "외부창"
                            If Dr입력면.방위 <> "수평" AndAlso Dr입력면.방위 <> "일사없음" AndAlso Dr입력면.방위 <> "(없음)" Then
                                WindowArea = WindowArea + TOSG(Dr입력면.건축부위면적) * 존수
                            End If
                        Case "내부창"
                            WindowArea = WindowArea + TOSG(Dr입력면.건축부위면적) * 존수
                    End Select
                End If

                'Debug.WriteLine(Dr입력면.code + ":wall=" + WallArea.ToString() + ",win=" + WindowArea.ToString())
            Next
            'For Each Dr입력면 As DS.tbl_myounRow In DSET1.tbl_myoun.Select("건축부위방식='외부창'")
            '    WindowArea = WindowArea + TOSG(Dr입력면.건축부위면적) * 존수
            'Next
        Catch ex As Exception

        End Try

        '//평균열관류율표시(140506)
        Dim 평균열관류율 As Single
        If WallArea + WindowArea = 0 Then
            평균열관류율 = (0.0F)
        Else
            평균열관류율 = 열관류율합 / (WallArea + WindowArea)
        End If

        'ToolStripLabel2.Text = 면데이터.Length.ToString + "/" + 열관류율합.ToString

        lbl_cnt1.Text = TOST(WallArea) & " ㎡"
        lbl_cnt2.Text = TOST(WindowArea) & " ㎡"
        lbl_cnt4.Text = 평균열관류율.ToString("N3") & " W/㎡K"

        Dim r As Decimal
        Try
            r = WindowArea / (WallArea + WindowArea) * 100
        Catch ex As Exception
            r = 0 '//게삭과정에 오류가낫다면 0처리합니다.
        End Try
        If WallArea + WindowArea = 0 Then
            lbl_cnt3.Text = "0 %"
        Else
            lbl_cnt3.Text = r.ToString("N1") & " %" '//N1은 소수점 1자리 N0ㄴ소수점 없음 N다음에 숫자가 소수점 자릿수에요
        End If

        If 비연결 > 0 Then
            ToolStrip1.Visible = False
            Me.lbl_cnt4.Visible = False
            If 비연결 > 1 Then
                Me.ToolStripLabel11.Text = "해당 부위 확인 요망(" + 비연결존 + " 외 " + (비연결 - 1).ToString() + " 개)"
            Else
                Me.ToolStripLabel11.Text = "해당 부위 확인 요망(" + 비연결존 + ")"
            End If
        Else
            ToolStrip1.Visible = True
            Me.lbl_cnt4.Visible = True
            Me.ToolStripLabel11.Text = "외벽평균열관류율:"
        End If
    End Sub
    Private Sub cmb_블라인드설치유무_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_블라인드설치유무.SelectedIndexChanged
        AddDebug("cmb_블라인드설치유무_SelectedIndexChanged")
        Validate_Control()
    End Sub

    Private Sub cmb_건축부위방식_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmb_건축부위방식.KeyDown

        If e.KeyCode = Keys.V And e.Control Then



            Me.isCopy = True

            Dim StartPos As Integer = Me.bs.Position  '//현재 바인딩셋의 위치정보를 확인
            Dim CurPos As Integer = StartPos

            e.Handled = True
            e.SuppressKeyPress = False
            '//클립보드붙여넣기
            Dim CB() As String = My.Computer.Clipboard.GetText.Split(CChar(vbCrLf))
            If CB.GetUpperBound(0) <> 18 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(Me.bs.Current, DataRowView)("설명") = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 0 + 3  '//사용프로필 앞에 두개를 숫자4자로변환
                            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).Trim = "", "0", CB(i).Trim))
                        Case 1 + 3  '//공란
                            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).Trim = "", "0", CB(i).Trim))
                        Case 2 + 3  '//면적
                            Me.tb_02.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 3 + 3
                            Me.cmb_열관류율.SelectedIndex = 0  '//사용자입력이므로 사용안함으로 변경
                            Me.tb_03.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 4 + 3
                            Me.tb_04.Text = CB(i).Split(CChar(vbTab))(ii).Trim
                        Case 5 + 3
                            Me.tb_05.Text = Val(CB(i).Split(CChar(vbTab))(ii).Trim).ToString
                        Case 6 + 3
                            Me.tb_06.Text = Val(CB(i).Split(CChar(vbTab))(ii).Trim).ToString
                        Case 7 + 3
                            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).Trim = "", "0", CB(i).Trim))
                        Case 8 + 3
                            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).Trim = "", "0", CB(i).Trim))
                        Case 9 + 3
                            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).Trim = "", "0", CB(i).Trim))
                        Case 10 + 3
                            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).Trim = "", "0", CB(i).Trim))
                        Case 11 + 3
                            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).Trim = "", "0", CB(i).Trim))
                        Case 12 + 3
                        Case 13 + 3
                            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).Trim = "", "0", CB(i).Trim))
                        Case 14 + 3
                            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).Trim = "", "0", CB(i).Trim))
                    End Select
                Next
            Next
            Me.bs.EndEdit()
            Me.isCopy = False
            Me.Validate_Control()
        End If
    End Sub

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

        AddDebug("▶bs_CurrentChanged")

        If Not Init Then Return
        Me.bs.EndEdit()
        Dim drv As DataRowView = Me.bs.Current
        If drv Is Nothing Then Return
        Dim dr As DS.tbl_myounRow = drv.Row

        If dr.차양각선택 = "1" Then
            Me.rad_수평직입력.Checked = True
        Else
            Me.rad_차양각입력.Checked = True
        End If

        'refresh차양각선택()
        'If Me.cmb_방위.Enabled = False Then Me.rad0.Checked = True '======================2011.05.25 수정
    End Sub

    Private Function R2d(radian As Double) As Double
        Return radian * 180 / Math.PI
    End Function

    Private Sub refresh차양각선택()
        AddDebug("refresh차양각선택")

        If rad_차양각입력.Checked Then
            If MyTb3.Text <> Me.tb_05.Text Then Me.tb_05.Text = MyTb3.Text
            If MyTb2.Text <> Me.tb_06.Text Then Me.tb_06.Text = MyTb2.Text
        Else
            If TOSG(MyTb7.Text) = 0 Then   '==================================2014.03.04 수정
                If Me.tb_05.Text <> "0" Then Me.tb_05.Text = "0"
            Else
                Dim datastr As String = Math.Round(R2d(Math.Atan(TOSG(MyTb5.Text) / TOSG(MyTb7.Text))), 1)
                If datastr <> Me.tb_05.Text Then Me.tb_05.Text = datastr ' = Math.Round(R2d(Math.Atan(TOSG(MyTb5.Text) / TOSG(MyTb7.Text))), 1)   '==================================2014.03.04 수정
            End If

            If TOSG(MyTb6.Text) = 0 Then   '==================================2014.03.04 수정
                If Me.tb_06.Text <> "0" Then Me.tb_06.Text = "0"
            Else
                Dim datastr As String = Math.Round(R2d(Math.Atan(TOSG(MyTb4.Text) / TOSG(MyTb6.Text))), 1)
                If datastr <> Me.tb_06.Text Then Me.tb_06.Text = datastr ' Math.Round(R2d(Math.Atan(TOSG(MyTb4.Text) / TOSG(MyTb6.Text))), 1)   '==================================2014.03.04 수정
            End If
        End If
    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 = DSET1.tbl_myoun.Select(Me.bs.Filter, "")
                For i As Integer = dR.GetUpperBound(0) To 0 Step -1
                    dR(i).Delete()
                Next
                DSET1.tbl_myoun.AcceptChanges()
            End If
        End If
    End Sub

    'Private Sub ToolStripComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmb_gubun.SelectedIndexChanged
    '    If Me.cmb_gubun.Text = "전체" Then
    '        bs.Filter = "code <> '0'"
    '    Else
    '        bs.Filter = "code <> '0' and 건축부위방식 like '" & Me.cmb_gubun.Text & "%'"
    '    End If
    'End Sub

    Private Sub cmb_건축부위방식_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_건축부위방식.SelectedIndexChanged
        AddDebug("cmb_건축부위방식_SelectedIndexChanged")
        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
                Dim dR() As DataRow = DSET1.tbl_myoun.Select(Me.bs.Filter, "")
                For i As Integer = dR.GetUpperBound(0) To 0 Step -1
                    dR(i).Delete()
                Next

                DSET1.tbl_myoun.AcceptChanges()
            End If
        End If
    End Sub

    Private Sub dv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dv.MouseUp
        If Prj.UserAuthType = "ADMIN" OrElse Prj.UserAuthType = "BOTH" OrElse Prj.UserAuthType = "BOTH2" OrElse Prj.UserAuthType = "BOTH1" Then  '//2011.03.08 추가
            If e.Button = Windows.Forms.MouseButtons.Right Then

                AddDebug("dv_MouseUp-right")

                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'"
                '//Frm_Filter.Default_Filter = "존분류='" & Me.SelectedZone & "' and code <> '0'"

                'Me.FilterMode = False
                MsgBox("화면필터값은 적용이 되지않습니다" & vbCrLf & "바꾸기 기능만 사용가능", MsgBoxStyle.Information, "확인")
                If Frm_FilterA.ShowDialog <> Windows.Forms.DialogResult.OK Then Return '//창떳을떄 확인아ㅣ고 취소눌르면 다음을 수행하지않는다는거에요.
                'Me.FilterMode = True
                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)
                        Dim i As Integer = 0
                        For Each Dr As DataRow In Drow
                            Dr(Frm_FilterA.cmb_fieldc.Text) = Frm_FilterA.tb_valuec.Text
                            i += 1
                        Next
                        MsgBox("'" & i & "'개 바꾸기 완료", 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" OrElse Prj.UserAuthType = "BOTH0" Then  '//2011.03.08 추가
            Select Case e.KeyCode
                Case Keys.D
                    If e.Alt Then
                        Dbbase.DelCrow(Me.bs, False)
                    End If
                Case Keys.C
                    If e.Control Then
                        Me.SrcDrv = Me.bs.Current
                        If Me.SrcDrv Is Nothing Then
                            MsgBox("저장할 ROW가 없습니다", MsgBoxStyle.Information, "확인")
                            Return
                        End If
                        ' My.Computer.Clipboard.SetData("ZDATA", Drv)
                    End If
                Case Keys.V
                    If e.Control Then
                        If Me.SrcDrv Is Nothing Then Return
                        Me.bt_add.PerformClick()  '//신규추가
                        Dim NewDrv As DataRowView = Me.bs.Current

                        For Each C As DataColumn In Me.DT.Columns
                            If C.ColumnName.ToUpper = "CODE" Then




                            ElseIf C.ColumnName.ToUpper = "설명" Then

                                Dim newname As String = SrcDrv(C.ColumnName) & "#Copy"

                                For i As Integer = 1 To 999 '//160327복제시 뒷부분을 자동 계산하도록 수정
                                    Dim newname2 As String = SrcDrv(C.ColumnName) & "#" & i.ToString()
                                    If DSET1.tbl_myoun.Select("설명='" + newname2 + "'").Length < 1 Then
                                        NewDrv(C.ColumnName) = newname2
                                        Exit For
                                    End If
                                Next

                            ElseIf C.ColumnName.ToUpper = "SORTKEY" Then
                                NewDrv(C.ColumnName) = SrcDrv(C.ColumnName)

                                '   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 tb_02_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_02.TextChanged
        AddDebug("tb_02_TextChanged")
        Display_info() 'Validate_Control()
    End Sub

    Private Sub cmb_열관류율_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_열관류율.SelectedIndexChanged
        'If Not Init Then Return '//초기화전에는 작동하지 않는다.
        AddDebug("cmb_열관류율_SelectedIndexChanged")
        If Me.cmb_열관류율.SelectedIndex > 0 Then
            ' Me.tb_03.Text = ""
            Me.tb_03.Enabled = False
            Me.cmb_건축부위방식.Enabled = False
            ' MsgBox(Me.cmb_열관류율.SelectedValue)


            '//아래와동일한 코드 pub Update_열관류율_140409() 에 있음
            '//변경시 같이 변경해야함 250710-2320

            Try
                Dim Dr As DS.tbl_ykRow = DSET1.tbl_yk.Select("code='" & Me.cmb_열관류율.SelectedValue & "'")(0)
                Dim dr2() As DS.tbl_commonRow = DSET1.tbl_common.Select("gubun='1088' and code='" & Dr("면형태").ToString & "'")
                Dim 면형태 As String = dr2(0).name
                Me.MyTb1.Text = Dr("열관류율").ToString

                'If 면형태.IndexOf("(지붕)") <> -1 Then
                '    rad9.Checked = True
                '    Me.tb_04.Text = "0"
                'ElseIf 면형태.IndexOf("(바닥)") <> -1 Then
                '    rad10.Checked = True
                '    Me.tb_04.Text = "0"
                'End If

                Select Case 면형태
                    Case "외벽(벽체)"
                        Me.cmb_건축부위방식.Text = "외벽"
                        Me.tb_04.Text = "0"
                    Case "외벽(지붕)"
                        Me.cmb_건축부위방식.Text = "외벽"
                        Me.cmb_방위.Text = "수평"
                        Me.tb_04.Text = "0"
                    Case "외벽(바닥)"
                        Me.cmb_건축부위방식.Text = "외벽"
                        Me.cmb_방위.Text = "일사없음"
                        Me.tb_04.Text = "0"
                    Case "내벽(벽체)", "지중벽"
                        Me.cmb_건축부위방식.Text = "내벽"
                        Me.cmb_방위.Text = "일사없음"
                        Me.tb_04.Text = "0"
                    Case "내벽(지붕)"
                        Me.cmb_건축부위방식.Text = "내벽"
                        Me.cmb_방위.Text = "일사없음"
                        Me.tb_04.Text = "0"
                    Case "내벽(바닥)"
                        Me.cmb_건축부위방식.Text = "내벽"
                        Me.cmb_방위.Text = "일사없음"
                        Me.tb_04.Text = "0"
                    Case "간벽"
                        Me.cmb_건축부위방식.Text = "간벽"
                        Me.cmb_방위.Text = "일사없음"
                        Me.tb_04.Text = "0"
                    Case "외부창", "내부창"
                        If 면형태 = "외부창" Then
                            Me.cmb_건축부위방식.Text = "외부창"
                        Else
                            Me.cmb_건축부위방식.Text = "내부창"
                            Me.cmb_방위.Text = "일사없음"
                        End If



                        Me.tb_04.Text = Dr.투과율


                    Case Else
                        MsgBox("모르는값 " & Dr("면형태").ToString & "/" & 면형태)
                End Select
            Catch ex As Exception
                Me.MyTb1.Text = ex.Message.ToString
            End Try

        ElseIf Me.cmb_열관류율.SelectedIndex = -1 Then
            Me.cmb_열관류율.SelectedIndex = 0  '//ㅣ본없음으로
            Me.tb_03.Enabled = True
            'Me.tb_03.Focus()
            Me.MyTb1.Text = ""
            Me.cmb_건축부위방식.Enabled = True
        Else
            Me.tb_03.Enabled = True
            'Me.tb_03.Focus()
            Me.MyTb1.Text = ""
            Me.cmb_건축부위방식.Enabled = True
        End If

        Validate()
        Validate_Control()
        Me.bs.EndEdit()


    End Sub

    Private Sub bszone_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bszone.CurrentChanged

        AddDebug("bszone_CurrentChanged")

        'If Me.FilterMode Then
        '    Me.FilterMode = False
        '    MsgBox("필터적용상태가 해제되었습니다", MsgBoxStyle.Information, "확인")
        'End If
        Dim drv As DataRowView = Me.bszone.Current
        If drv Is Nothing Then
            Me.SelectedZone = ""
            Me.SelectedZoneName = ""
        Else
            Me.SelectedZone = drv("code").ToString
            Me.SelectedZoneName = drv("설명").ToString
        End If
        Dim Filter As String
        'Me.FilterMode = False
        Filter = "존분류='" & SelectedZone & "' and code <> '0'"
        Try
            Me.bs.Filter = Filter
        Catch ex As Exception
            Me.bs.Filter = "code <> '0'"
        End Try

    End Sub


    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rad1.CheckedChanged, rad2.CheckedChanged, rad3.CheckedChanged, _
    rad4.CheckedChanged, rad5.CheckedChanged, rad6.CheckedChanged, rad7.CheckedChanged, rad8.CheckedChanged, rad9.CheckedChanged, rad10.CheckedChanged, rad0.CheckedChanged

        AddDebug("RadioButton2_CheckedChanged")


        Dim Drv As DataRowView = Me.bs.Current
        If Drv Is Nothing Then Return
        '//콤보박스으 실제값하고 비교하셔서 이름 바꾸시구요.
        If rad1.Checked Then Me.cmb_방위.Text = "북서"
        If rad2.Checked Then Me.cmb_방위.Text = "서"
        If rad3.Checked Then Me.cmb_방위.Text = "남서"
        If rad4.Checked Then Me.cmb_방위.Text = "남"
        If rad5.Checked Then Me.cmb_방위.Text = "남동"
        If rad6.Checked Then Me.cmb_방위.Text = "동"
        If rad7.Checked Then Me.cmb_방위.Text = "북동"
        If rad8.Checked Then Me.cmb_방위.Text = "북"
        If rad9.Checked Then Me.cmb_방위.Text = "수평"
        If rad10.Checked Then Me.cmb_방위.Text = "일사없음"
        If rad0.Checked Then Me.cmb_방위.Text = "(없음)"

        Me.bs.EndEdit()
        Me.DT.AcceptChanges()
        '//여기까지 라디오를 건들면 콤보가 움직이는게 됬구요..


    End Sub

    Private Sub cmb_방위_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_방위.SelectedIndexChanged
        AddDebug("cmb_방위_SelectedIndexChanged")

        '//콤보의 값에따라서 라디오를 변경?
        Select Case Me.cmb_방위.Text
            Case "(없음)", ""
                Me.rad0.Checked = True
            Case "북서"
                Me.rad1.Checked = True
            Case "서"
                Me.rad2.Checked = True
            Case "남서"
                Me.rad3.Checked = True
            Case "남"
                Me.rad4.Checked = True
            Case "남동"
                Me.rad5.Checked = True
            Case "동"
                Me.rad6.Checked = True
            Case "북동"
                Me.rad7.Checked = True
            Case "북"
                Me.rad8.Checked = True
            Case "수평"
                Me.rad9.Checked = True
            Case "일사없음"
                Me.rad10.Checked = True
        End Select
    End Sub

    Private Sub cmb_존분류_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_존분류.SelectedIndexChanged
        AddDebug("cmb_존분류_SelectedIndexChanged")
        Me.bs.EndEdit()
    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 Arindv1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Arindv1.CellContentClick

    End Sub

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

    End Sub

    Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rad_차양각입력.CheckedChanged, rad_수평직입력.CheckedChanged
        AddDebug("rad차양각,수평직입력 CheckedChanged")

        Me.MyTb2.Enabled = rad_차양각입력.Checked
        Me.MyTb3.Enabled = rad_차양각입력.Checked
        Me.Label1.Enabled = rad_차양각입력.Checked
        Me.Label8.Enabled = rad_차양각입력.Checked

        Me.MyTb4.Enabled = Not rad_차양각입력.Checked
        Me.MyTb5.Enabled = Not rad_차양각입력.Checked
        Me.MyTb6.Enabled = Not rad_차양각입력.Checked
        Me.MyTb7.Enabled = Not rad_차양각입력.Checked

        Me.Label9.Enabled = Not rad_차양각입력.Checked
        Me.Label10.Enabled = Not rad_차양각입력.Checked
        Me.Label12.Enabled = Not rad_차양각입력.Checked
        Me.Label13.Enabled = Not rad_차양각입력.Checked

        Dim drv As DataRowView = Me.bs.Current
        If Not drv Is Nothing Then
            drv("차양각선택") = IIf(rad_수평직입력.Checked, "1", "0")
        End If
        refresh차양각선택()
    End Sub

    Private Sub MyTb3_TextChanged(sender As System.Object, e As System.EventArgs) Handles MyTb2.TextChanged, MyTb3.TextChanged, MyTb4.TextChanged, MyTb5.TextChanged, MyTb6.TextChanged, MyTb7.TextChanged

        Dim tb As MyTb = CType(sender, MyTb)
        AddDebug(String.Format("[{0}] TextChanged", tb.Name))
        refresh차양각선택()

    End Sub

    Private Sub ToolStrip2_MouseDoubleClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles ToolStrip2.MouseDoubleClick
        If Prj.UserAuthType = "ADMIN" OrElse Prj.UserAuthType = "BOTH2" OrElse Prj.UserAuthType = "BOTH1" Then
            If ToolStrip1.Visible = False Then
                If MsgBox("열관류율탭과 자동연결을 진행합니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
                    Try
                        Dim 열관류율코드 As String = 0
                        Dim i As Integer = 0
                        Dim j As Integer = 0
                        DSET1.tbl_myoun.CaseSensitive = True
                        Dim 면() As DS.tbl_myounRow = DSET1.tbl_myoun.Select("code<>'0' and (열관류율2 = '0' or 열관류율2='') and 설명 <> ''")
                        For Each Dr As DS.tbl_myounRow In 면
                            'Dr(Frm_FilterA.cmb_fieldc.Text) = Frm_FilterA.tb_valuec.Text

                            Dim Dryk() As DS.tbl_ykRow = DSET1.tbl_yk.Select("설명='" & Dr.설명 & "'")
                            Dim Find As Boolean = False
                            For Each Drykdetail As DS.tbl_ykRow In Dryk
                                If Drykdetail.설명 = Dr.설명 Then
                                    열관류율코드 = Drykdetail.code
                                    Dr.열관류율2 = 열관류율코드
                                    Dr.열관류율 = "0"
                                    Find = True
                                    Exit For
                                End If
                            Next
                            If Find Then
                                '//있는 경우
                                i += 1
                            Else
                                j += 1
                                '//없는 경우
                            End If

                        Next
                        Display_info()
                        MsgBox("'" & i & "'개 바꾸기 완료", MsgBoxStyle.Information, "확인")

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

                End If
            End If
        End If


    End Sub

   
    Private Sub dv_DataError(sender As System.Object, e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dv.DataError

        AddDebug("dv_DataError")

        Dim ermsg As String = String.Format("입력값에 오류가 있습니다" + vbCrLf + vbCrLf + "줄번호:{0},열번호{1}" + vbCrLf + _
                                     "메세지:{2}", e.RowIndex, e.ColumnIndex, e.Exception.Message)

        Select Case e.ColumnIndex
            Case 0
                ermsg += vbCrLf + vbCrLf + "숫자만 입력하세요"
        End Select
        MsgBox(ermsg, MsgBoxStyle.Critical, "Error")
    End Sub
End Class