Public Class Frm_V20091231_YK
    Dim DT As DataTable
    Dim init As Boolean = False
    Dim pcode As String
    Dim UserCommin As Boolean = False
    Dim SrcDrv As DataRowView
   
    Private Sub Frm_V20091231_YK_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Me.bs.EndEdit()
        Me.bs_detail.EndEdit()

    End Sub
    Private Sub MdiMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: 이 코드는 데이터를 'DS.tbl_common' 테이블에 로드합니다. 필요한 경우 이 코드를 이동하거나 제거할 수 있습니다.
        MdiMain.Toggle_Menu_Color(MdiMain.E_MenuIdx.열관류율)
        'CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me)
        '//프로필 관련

        '//공유데이터셋에 연결한다.
        Me.bs.DataSource = DSET
        Me.bs_detail.DataSource = DSET
        Me.bs_gubun.DataSource = DSET
        Me.bS_재료.DataSource = DSET

        bS_재료.Filter = "gubun='1089'"
        bS_재료.Sort = "code"

        DT = DSET.tbl_yk

        '//냉방분배
        AddHandler DSET.tbl_yk.TableNewRow, AddressOf AddNewDataRow_bunbae
        AddHandler DSET.tbl_ykdetail.TableNewRow, AddressOf AddNewDataRow_Weatherilsa

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

        '//콤보컨트롤 바인딩
        Binding_Zone()
        Me.bsmain = Me.bs

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

        refresh_Image()
        Me.init = True

        'Try '//열전도갱신

        Me.cmb_열전도율.Items.Clear()

        Try
            Dim Dr As DS.tbl_commonRow = DSET.tbl_common.Select("gubun='1089' and name='" & Me.cmb_재료.Text & "'")(0)
            Me.cmb_열전도율.Items.Add(Dr.valn1)
        Catch ex As Exception
            'MsgBox("1. " & ex.Message.ToString)
        End Try

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

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

            End Try

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

            End Try
        End If
    End Sub
#End Region

#Region "기본"
    Private Sub MdiMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me, Me.bsmain.Position, True)
    End Sub
    Private Function GetMaxCode(ByVal dt As DataTable) As String
        Try
            Dim Dr As DataRow = dt.Select("", "code desc")(0)
            Return Format(CInt(Dr("code")) + 1, "0000")
        Catch ex As Exception
            ' MsgBox(ex.Message.ToString)
            Return "0001"
        End Try
    End Function
    Private Sub Cmb_DeleteVal(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.Delete Then
            CType(sender, ComboBox).SelectedValue = ""
        End If
    End Sub
    Private Sub AddNewDataRow_bunbae(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs)
        e.Row.Item("code") = GetMaxCode(DSET.tbl_yk)
        '  MsgBox("22")
    End Sub
    Private Sub AddNewDataRow_Weatherilsa(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs)

        Dim NewCode As String
        Try
            Dim Dr As DataRow = DSET.tbl_ykdetail.Select("pcode = '" & Me.pcode & "'", "code desc")(0)
            NewCode = Format(CInt(Dr("code")) + 1, "0000")
        Catch ex As Exception
            NewCode = ("0001")
        End Try

        Try
            e.Row.Item("pcode") = Me.pcode ' CType(bs.Current, DataRowView)("code")
            e.Row.Item("code") = NewCode
            'MsgBox(e.Row.Item("code").ToString)

        Catch ex As Exception
            MsgBox("부모코드없음 선택다시")
        End Try

    End Sub

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


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

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

    Private Sub Binding_Zone()

        Dim bs_형태 As New BindingSource(DSET, "tbl_common")
        bs_형태.Filter = "gubun='1088'"
        bs_형태.Sort = "code"
        Me.cmb_형태.DataSource = bs_형태
        cmb_형태.DisplayMember = "name"
        cmb_형태.ValueMember = "code"
        Me.cmb_형태.DataBindings.Add("selectedvalue", Me.bs, "면형태")
        AddHandler cmb_형태.KeyDown, AddressOf Cmb_DeleteVal

        'Me.bS_재료.DataSource = DSET.tbl_common
        bS_재료.Filter = "gubun='1089'"
        bS_재료.Sort = "code"

        Me.cmb_재료.DataSource = bS_재료
        cmb_재료.DisplayMember = "name"
        cmb_재료.ValueMember = "name"
        Me.cmb_재료.DataBindings.Add("text", Me.bs_detail, "설명")
        AddHandler cmb_재료.KeyDown, AddressOf Cmb_DeleteVal
        Me.cmb_재료.Text = ""

        'Me.bs_gubun.DataSource = DSET.tbl_common
        bs_gubun.Filter = "gubun='1090'"
        bs_gubun.Sort = "code"

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


    Private Sub dv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dv.MouseUp
        If Prj.UserAuthType = "ADMIN" OrElse Prj.UserAuthType = "BOTH" OrElse Prj.UserAuthType = "BOTH2" OrElse Prj.UserAuthType = "BOTH1" Then  '//2011.03.08 추가
            If e.Button = Windows.Forms.MouseButtons.Right Then
                Dim Frm_FilterA As New Frm_Filter
                Frm_FilterA.ColumTitle = getColCaption(Me.DT)
                Frm_FilterA.ColumList = getColName(Me.DT)
                Frm_FilterA.Colorlist = ""

                Frm_FilterA.Numfield = ""    '//20100618  Color 리스트처럼 , 구분해서 필드들을 모두 넣으세요.(=, >= 등을 사용하기 위해서는 해당 항목을 추가 요망)
                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 = ""
                    'MsgBox("2. " & ex.Message.ToString)
                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)삭제하도록 햇어요.
        If Prj.UserAuthType = "ADMIN" OrElse Prj.UserAuthType = "BOTH" OrElse Prj.UserAuthType = "BOTH2" OrElse Prj.UserAuthType = "BOTH1" Then  '//2011.03.08 추가
            Select Case e.KeyCode
                Case Keys.D
                    If e.Alt Then
                        Dbbase.DelCrow(Me.bs, False)
                    End If
                Case Keys.C
                    If e.Control Then
                        Me.SrcDrv = Me.bs.Current
                        If Me.SrcDrv Is Nothing Then
                            MsgBox("저장할 ROW가 없습니다", MsgBoxStyle.Information, "확인")
                            Return
                        End If
                        ' My.Computer.Clipboard.SetData("ZDATA", Drv)
                    End If
                Case Keys.V
                    If e.Control Then
                        If Me.SrcDrv Is Nothing Then Return
                        Me.bt_add.PerformClick()  '//신규추가
                        Dim NewDrv As DataRowView = Me.bs.Current

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

                        '//하위데이터복제
                        Dim src_pcode As String = SrcDrv("code").ToString
                        Dim new_pcode As String = NewDrv("code").ToString


                        For Each Drow2 As DS.tbl_ykdetailRow In DSET.tbl_ykdetail.Select("pcode='" & src_pcode & "'")
                            Dim Newrow As DS.tbl_ykdetailRow = DSET.tbl_ykdetail.Newtbl_ykdetailRow
                            For Each C As DataColumn In DSET.tbl_ykdetail.Columns
                                Newrow(C.ColumnName) = Drow2(C.ColumnName)
                            Next
                            Newrow.pcode = new_pcode
                            DSET.tbl_ykdetail.Addtbl_ykdetailRow(Newrow)
                        Next

                        Me.bs.EndEdit()
                        Me.bs_detail.EndEdit()
                        Me.refresh_Image()

                        bs.MoveLast()
                    End If
            End Select
        End If
    End Sub

    Private Sub bs_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bs.CurrentChanged
        Try
            pcode = CType(bs.Current, DataRowView)("code").ToString
            Me.bs_detail.Filter = "pcode='" & pcode & "'"
            Me.refresh_Image()
        Catch ex As Exception
            'MsgBox("3. " & ex.Message.ToString)
        End Try
        Me.bs.EndEdit()
    End Sub

    Private Sub refresh_Image()
        ' MsgBox(Me.UserControl11.Vertical)

        Dim width As Decimal = 0   '//뭘고치던 여기 함수가 실행되므로 이곳에서 뭔가 작업하시는게 좋을것 같구요..어떤것을들 더하시려구요?
        Dim R_value As Decimal = 0

        For Each Dr As DS.tbl_ykdetailRow In DSET.tbl_ykdetail.Select(Me.bs_detail.Filter, "")    '//세부내역중 두께를 합치는 루틴입니다.
            'Try
            If Dr.설명 = "공기층" Then
                Dr.열전도율 = ""
                If TOSG(Dr.두께) > 10.0 Then
                    Dr.열저항 = TOST(0.086)
                    R_value += 0.086
                Else
                    Dr.열저항 = TOST(TOSG(Dr.두께) * 0.0086)
                    R_value = R_value + TOSG(Dr.두께) * 0.0086
                End If
            Else  '//여기아래 추가하신거에요?

                If Dr.설명.IndexOf("열전달저항") <> -1 Then
                    Dr.두께 = ""
                    Dr.열전도율 = ""
                    Select Case Dr.설명
                        Case "실내열전달저항(벽체)"
                            Dr.열저항 = TOST(0.11)
                            R_value += 0.11
                        Case "실외열전달저항(벽체,간접)"
                            Dr.열저항 = TOST(0.11)
                            R_value += 0.11
                        Case "실외열전달저항(벽체,직접)"
                            Dr.열저항 = TOST(0.043)
                            R_value += 0.043
                        Case "실내열전달저항(바닥)"
                            Dr.열저항 = TOST(0.086)
                            R_value += 0.086
                        Case "실외열전달저항(바닥,간접)"
                            Dr.열저항 = TOST(0.15)
                            R_value += 0.15
                        Case "실외열전달저항(바닥,직접)"
                            Dr.열저항 = TOST(0.043)
                            R_value += 0.043
                        Case "실내열전달저항(지붕)"
                            Dr.열저항 = TOST(0.086)
                            R_value += 0.086
                        Case "실외열전달저항(지붕,간접)"
                            Dr.열저항 = TOST(0.086)
                            R_value += 0.086
                        Case "실외열전달저항(지붕,직접)"
                            Dr.열저항 = TOST(0.043)
                            R_value += 0.043

                    End Select

                Else
                    If Dr.열전도율 <> "" AndAlso TOSG(Dr.열전도율) <> 0 Then
                        Dr.열저항 = TOSG(Math.Round(TOSG(Dr.두께) / 1000 / TOSG(Dr.열전도율), 4)).ToString
                        R_value += TOSG(Dr.열저항)  '//여부분에서는 나올수잇겟군요.?예
                    End If

                End If

            End If
           

            If Dr.설명.IndexOf("열전달저항") = -1 Then
                width += TOSG(Dr.두께)
            End If
        Next

        Try
            If cmb_형태.Text = "외부창" OrElse cmb_형태.Text = "내부창" Then
                Me.열관류율NTb.Text = Me.NTb_창호열관류율.Text
            Else
                Me.열관류율NTb.Text = CSng(Math.Round(1 / R_value, 3)).ToString
            End If
        Catch ex As Exception
            Me.열관류율NTb.Text = ""
            'MsgBox("4. " & ex.Message.ToString)
        End Try

        '  Me.MyTb1.Text = width.ToString("N2")
        Me.UserControl11.MaxSize = width
        'MsgBox(width)

        ' Me.Label1.Text = Me.UserControl11.Width

        '//  0.51 : me.wid = x : ?

        '  Me.UserControl11.Vertical = True
        Dim FT(Me.arindv1.RowCount - 1) As mn.UserControl1.SM
        For i As Integer = 0 To Me.arindv1.RowCount - 1
            '//아까 열표시해서 검정색 선택해보니 검정은 값이 0 이 나오더라구요
            '//실재로 0값이 근데 표시가안됫어요 그러므로

            Try
                FT(i).BColor = Color.FromArgb(Me.arindv1.Rows(i).Cells("후경색").Value)

            Catch ex As Exception
                FT(i).BColor = Color.FromName("white")
                'MsgBox("5. " & ex.Message.ToString)
            End Try
            Try
                If Me.arindv1.Rows(i).Cells("전경색").Value = "0" Then
                    FT(i).FColor = Color.Black
                Else
                    FT(i).FColor = Color.FromArgb(Me.arindv1.Rows(i).Cells("전경색").Value)
                End If

            Catch ex As Exception
                FT(i).FColor = Color.FromName("black")
                ' MsgBox("6. " & ex.Message.ToString)
            End Try
            ' FT(i).Style=            
            Try
                FT(i).Style = Val(Me.arindv1.Rows(i).Cells("구분").Value)
            Catch ex As Exception
                FT(i).Style = Drawing2D.HatchStyle.Cross
                'MsgBox("7. " & ex.Message.ToString)
            End Try


           
            Try
                FT(i).Width = Me.arindv1.Rows(i).Cells("두께").Value
            Catch ex As Exception
                'MsgBox("8. " & ex.Message.ToString)
            End Try


        Next
        Me.UserControl11.M1FillType = FT
    End Sub

    Private Sub arindv1_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles arindv1.CellFormatting
        Try
            Me.arindv1.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.FromArgb(Me.arindv1.Rows(e.RowIndex).Cells("후경색").Value)
            ' Me.arindv1.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.FromName(Me.arindv1.Rows(e.RowIndex).Cells("전경색").Value)
        Catch ex As Exception
            Me.arindv1.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.White
            'MsgBox("9. " & ex.Message.ToString)
        End Try

    End Sub


    Private Sub Arindv1_CellValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles arindv1.CellValidated
        refresh_Image()
    End Sub

    Private Sub Arindv1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs)

    End Sub

    Private Sub Arindv1_RowValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
        refresh_Image()
    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        'Try
        Me.bs_detail.AddNew()
        Me.bs_detail.EndEdit()
        refresh_Image()
        'Catch ex As Exception
        '    MsgBox(ex.Message.ToString)

        '    MsgBox("상위코드 선택하세요", MsgBoxStyle.Critical, "확인")
        'End Try

    End Sub

    Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
        If Me.bs_detail.Count > 0 Then Me.bs_detail.RemoveCurrent()
    End Sub

    Private Sub arindv1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles arindv1.CellContentClick
        Select Case e.ColumnIndex
            Case 8  '//전경
                Dim Cd As New ColorDialog
                Cd.Color = Color.FromName(Me.arindv1.Rows(e.RowIndex).Cells("전경색").Value)
                If Cd.ShowDialog <> Windows.Forms.DialogResult.OK Then Return
                Me.arindv1.Rows(e.RowIndex).Cells("전경색").Value = Cd.Color.ToArgb
                Me.btn_전경색.BackColor = Cd.Color
                Me.bs_detail.EndEdit()
                refresh_Image()
            Case 9  '//배경
                Dim Cd As New ColorDialog
                Cd.Color = Color.FromName(Me.arindv1.Rows(e.RowIndex).Cells("후경색").Value)
                If Cd.ShowDialog <> Windows.Forms.DialogResult.OK Then Return
                Me.arindv1.Rows(e.RowIndex).Cells("후경색").Value = Cd.Color.ToArgb
                Me.btn_후경색.BackColor = Cd.Color
                Me.bs_detail.EndEdit()
                refresh_Image()
        End Select
    End Sub

    Private Sub arindv1_DataError1(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles arindv1.DataError

    End Sub

    Private Sub cmb_형태_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_형태.SelectedIndexChanged
        If cmb_형태.Text = "외벽(지붕)" OrElse cmb_형태.Text = "외벽(바닥)" OrElse cmb_형태.Text = "내벽(지붕)" OrElse cmb_형태.Text = "내벽(바닥)" Then
            Me.UserControl11.Vertical = False
        Else
            Me.UserControl11.Vertical = True
        End If
        Me.refresh_Image()
        If cmb_형태.Text = "외부창" OrElse cmb_형태.Text = "내부창" Then
            Me.NTb_창호열관류율.Visible = True
            Me.NTb_일사에너지투과율.Visible = True
            Me.NTb_창호세부설명.Visible = True
            Me.lbl_창호열관류율.ForeColor = Color.Black
            Me.lbl_일사에너지투과율.ForeColor = Color.Black
            Me.lbl_창호세부설명.ForeColor = Color.Black
        Else
            Me.NTb_창호열관류율.Visible = False
            Me.NTb_일사에너지투과율.Visible = False
            Me.NTb_창호세부설명.Visible = False
            Me.lbl_창호열관류율.ForeColor = Color.LightGray
            Me.lbl_일사에너지투과율.ForeColor = Color.LightGray
            Me.lbl_창호세부설명.ForeColor = Color.LightGray

        End If

    End Sub

    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
        Dim Drv As DataRowView = Me.bs_detail.Current
        Dim 전경 As String
        Try
            전경 = Drv("전경색").ToString
        Catch ex As Exception
            'MsgBox("10. " & ex.Message.ToString)
        End Try
        Dim 후경 As String
        Try
            후경 = Drv("후경색").ToString
        Catch ex As Exception
            'MsgBox("11. " & ex.Message.ToString)
        End Try
        Dim A As New Frm_DisplayGubun(전경, 후경)
        A.Show()
    End Sub

    Private Sub SplitContainer1_Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles SplitContainer1.Panel2.Paint

    End Sub

    Private Sub bs_detail_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bs_detail.CurrentChanged
        Try
            Dim Drv As DataRowView = CType(Me.bs_detail.Current, DataRowView)
            Me.btn_전경색.BackColor = Color.FromArgb(Drv("전경색").ToString)
            Me.btn_후경색.BackColor = Color.FromArgb(Drv("후경색").ToString)
        Catch ex As Exception
            Me.btn_전경색.BackColor = Color.White
            Me.btn_후경색.BackColor = Color.White
            'MsgBox("12. " & ex.Message.ToString)
        End Try

        Dim Fil As String = "gubun='1089' and name='" & Me.cmb_재료.Text & "'"
        ' Try '//열전도갱신

        Me.cmb_열전도율.Items.Clear()
        Try
            Dim Dr As DS.tbl_commonRow = DSET.tbl_common.Select(Fil)(0)
            Me.cmb_열전도율.Items.Add(Dr.valn1)
        Catch ex As Exception
            '    MsgBox("13. " & ex.Message.ToString & vbCrLf & Fil)
        End Try




        Me.bs_detail.EndEdit()
        Me.refresh_Image()
    End Sub

    Private Sub btn_전경색_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_전경색.Click

        Try
            Dim Cd As New ColorDialog

            If Cd.ShowDialog <> Windows.Forms.DialogResult.OK Then Return
            Me.btn_전경색.BackColor = Cd.Color

            Dim Drv As DataRowView = Me.bs_detail.Current
            Drv("전경색") = Cd.Color.ToArgb

        Catch ex As Exception
            Me.btn_전경색.BackColor = Color.White
            'MsgBox("14. " & ex.Message.ToString)
        End Try
        Me.bs_detail.EndEdit()
        Me.refresh_Image()

    End Sub

    Private Sub cmb_재료_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_재료.SelectedIndexChanged
        If Me.bs_detail.Count < 1 Then Return '// ep데이터가없을경우 무시


       
        Dim 재료코드 As String
        If Me.cmb_재료.SelectedIndex >= 0 Then
            If UserCommin = False Then
                'UserCommin = True
                Return
            End If

            'MsgBox(Me.cmb_재료.Text)

            '//여기가 재로를 선택하는 순간이에요

            '//해당열전도율가져오기
            Try
                Dim Dr As DS.tbl_commonRow = DSET.tbl_common.Select(bS_재료.Filter & " and name='" & Me.cmb_재료.Text & "'")(0)
                재료코드 = Dr.code
                Me.cmb_열전도율.Items.Clear()
                Try '// 20110210 Try문 추가 (열전달저항 관련 Null 값에 의한 재료코드에러수정)
                    Me.cmb_열전도율.Items.Add(Dr.valn1)
                Catch ex As Exception

                End Try

                'Me.tb_열전도.Text = Dr.valn1
                ' MsgBox(Dr.valn1)

            Catch ex As Exception
                'MsgBox(ex.Message.ToString)
                'MsgBox("15. " & ex.Message.ToString)
            End Try

            '//색및 패턴명 가져오기
            Dim DetailDrv As DataRowView = Me.bs_detail.Current
            DetailDrv("설명") = Me.cmb_재료.Text
            Dim Er As Boolean = False

            Dim Dr2() As DS.tbl_commonRow = DSET.tbl_common.Select("gubun='1090' and code='" & 재료코드 & "'")
            If Dr2.GetUpperBound(0) = -1 Then
                DetailDrv("전경색") = Color.Blue.ToArgb
                DetailDrv("후경색") = Color.White.ToArgb '//디비에 해당설ㅈㅇ이 없을경우 행하는 코드들
                DetailDrv("구분") = "5"
                Me.btn_전경색.BackColor = Color.FromArgb(DetailDrv("전경색"))
                Me.btn_후경색.BackColor = Color.FromArgb(DetailDrv("후경색"))
            Else  '//디비에 있을경우
                Try
                    DetailDrv("전경색") = Dr2(0)("name").ToString.Split(",")(0)
                Catch ex As Exception
                    DetailDrv("전경색") = Color.Black.ToArgb
                    'MsgBox("16. " & ex.Message.ToString)
                End Try
                Try
                    DetailDrv("후경색") = Dr2(0)("name").ToString.Split(",")(1)
                Catch ex As Exception
                    DetailDrv("후경색") = Color.White.ToArgb
                    ' MsgBox("17. " & ex.Message.ToString)
                End Try
                DetailDrv("구분") = CInt(Dr2(0)("valn1"))
                Me.btn_후경색.BackColor = Color.FromArgb(DetailDrv("후경색"))
                Me.btn_전경색.BackColor = Color.FromArgb(DetailDrv("전경색"))
            End If




            Me.bs_detail.EndEdit()
            Me.refresh_Image()
            UserCommin = False
        End If
    End Sub

    Private Sub btn_후경색_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_후경색.Click

        Try
            Dim Cd As New ColorDialog

            If Cd.ShowDialog <> Windows.Forms.DialogResult.OK Then Return
            Me.btn_후경색.BackColor = Cd.Color

            Dim Drv As DataRowView = Me.bs_detail.Current
            Drv("후경색") = Cd.Color.ToArgb

        Catch ex As Exception
            Me.btn_후경색.BackColor = Color.White
            'MsgBox("18. " & ex.Message.ToString)
        End Try
        Me.bs_detail.EndEdit()
        Me.refresh_Image()

    End Sub

    Private Sub cmb_열전도율_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_열전도율.SelectedIndexChanged
        Me.bs_detail.EndEdit()
        Me.refresh_Image()
    End Sub

    Private Sub cmb_열전도율_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmb_열전도율.TextChanged
        Me.bs_detail.EndEdit()
        Me.refresh_Image()
    End Sub

    Private Sub cmb_재료_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmb_재료.SelectionChangeCommitted
        Me.UserCommin = True
    End Sub

    Private Sub NTb_창호열관류율_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NTb_창호열관류율.TextChanged
        If cmb_형태.Text = "외부창" OrElse cmb_형태.Text = "내부창" Then
            Me.열관류율NTb.Text = Me.NTb_창호열관류율.Text
        End If
    End Sub

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

    End Sub
End Class
