Public Class Frm_V20091231_desc
#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_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me, Me.bs.Position, True)
    End Sub

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

    Private Sub MdiMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.LinkLabel1.Visible = False
        Me.LinkLabel2.Visible = False
        Me.LinkLabel3.Visible = False

        'MdiMain.Toggle_Menu_Color(MdiMain.E_MenuIdx.건물개요)
        'CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me)
        '//프로필 관련

        '//공유데이터셋에 연결한다.
        Me.bs.DataSource = DSET
        If Me.bs.Count = 0 Then bs.AddNew()
        bs.EndEdit()

        '//Zone
        Binding_Zone()

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

        If Not (Prj.UserAuthType = "ADMIN" OrElse Prj.UserAuthType = "BOTH" OrElse Prj.UserAuthType = "BOTH2" OrElse Prj.UserAuthType = "BOTH1") Then  '//2011.03.08 추가
            Dim MyVersion As String '= Format(My.Application.Info.Version.Minor, "0000") & Format(My.Application.Info.Version.Build, "0000")
            Dim L As New ArinLogin.ArinLOgin
            Dim VersionInfo As ArinLogin.ArinLOgin.sVersionInfo = Nothing
            '/공용코드버젼확인
            Try
                MyVersion = DSET.tbl_Desc.Rows(0)("versionc").ToString
                If MyVersion = "" Then MyVersion = "20100101"
            Catch ex As Exception
                MyVersion = "20100101"
            End Try
            Try
                VersionInfo = L.Get_LastVersion("C")   '//버젼을 가져오는데  eco 버젼만 가져오게 바꺼야겟죵 ^^ 구분자를 넣도록 합시닷!
                If VersionInfo.Ver <> "0" AndAlso (CInt(VersionInfo.Ver) > CInt(MyVersion)) Then   '//0은 없거나 관리안함의 뜻이므로 넘어간다.
                    Dim Lc As String = Me.cmb_location.SelectedValue
                    Read_CommonCode()
                    Me.cmb_location.SelectedValue = Lc
                    Me.bs.EndEdit()
                End If
            Catch ex As Exception
                MsgBox("공용코드 에러" & ex.Message.ToString)
            End Try

            '/표준프로파일버젼확인 '//2010.12.06 추가
            Try
                MyVersion = DSET.tbl_Desc.Rows(0)("versionp").ToString
                If MyVersion = "" Then MyVersion = "20100101"
            Catch ex As Exception
                MyVersion = "20100101"
            End Try
            Try

                VersionInfo = L.Get_LastVersion("P")   '//버젼을 가져오는데  eco 버젼만 가져오게 바꺼야겟죵 ^^ 구분자를 넣도록 합시닷!
                If VersionInfo.Ver <> "0" AndAlso (CInt(VersionInfo.Ver) > CInt(MyVersion)) Then   '//0은 없거나 관리안함의 뜻이므로 넘어간다.
                    Dim Lp As String = Me.cmb_location.SelectedValue
                    Read_ProfileData()
                    Me.cmb_location.SelectedValue = Lp
                    Me.bs.EndEdit()
                End If
            Catch ex As Exception
                MsgBox("표준프로파일 에러" & ex.Message.ToString)
            End Try

            '/기상데이터버젼확인
            Try
                MyVersion = DSET.tbl_Desc.Rows(0)("versionw").ToString
                If MyVersion = "" Then MyVersion = "20100101"
            Catch ex As Exception
                MyVersion = "20100101"
            End Try
            Try
                'MyVersion = DSET.tbl_Desc.Rows(0)("versionw").ToString
                VersionInfo = L.Get_LastVersion("W")   '//버젼을 가져오는데  eco 버젼만 가져오게 바꺼야겟죵 ^^ 구분자를 넣도록 합시닷!
                If VersionInfo.Ver <> "0" AndAlso (CInt(VersionInfo.Ver) > CInt(MyVersion)) Then   '//0은 없거나 관리안함의 뜻이므로 넘어간다.
                    Dim Lw As String = Me.cmb_location.SelectedValue
                    Read_WeatherData()
                    Me.cmb_location.SelectedValue = Lw
                    Me.bs.EndEdit()
                End If
            Catch ex As Exception

            End Try
        Else
            Me.LinkLabel1.Visible = True
            Me.LinkLabel2.Visible = True
            Me.LinkLabel3.Visible = True

        End If
    End Sub


    Private Sub Frm_Intro_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
        '//판넬1을 항상 중앙에 위치하도록
        Me.Panel2.Left = CInt((Me.Width - Me.Panel2.Width) / 2)
        Me.Panel2.Top = CInt((Me.Height - Me.Panel2.Height) / 2)
    End Sub

    Private Sub Binding_Zone()
        Dim bs_cmb_공조방식 As New BindingSource(DSET, "tbl_weather")
        bs_cmb_공조방식.Filter = ""
        Me.cmb_location.DataSource = bs_cmb_공조방식
        cmb_location.DisplayMember = "건물위치"
        cmb_location.ValueMember = "code"
        Me.cmb_location.DataBindings.Add("selectedvalue", Me.bs, "buildarea")
        'AddHandler cmb_location.KeyDown, AddressOf Cmb_DeleteVal
    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 ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        DSET.AcceptChanges()
        DSETR.AcceptChanges()

    End Sub

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Dim L As String = Me.cmb_location.SelectedValue
        If MsgBox("공용코드값을 서버로부터 가져오시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then Read_CommonCode()
        Me.cmb_location.SelectedValue = L
        Me.bs.EndEdit()
    End Sub

    Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
        Dim L As String = Me.cmb_location.SelectedValue
        If MsgBox("기상데이터값을 서버로부터 가져오시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then Read_WeatherData()
        Me.cmb_location.SelectedValue = L
        Me.bs.EndEdit()
    End Sub
    Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked '//2010.12.06 추가
        Dim L As String = Me.cmb_location.SelectedValue
        If MsgBox("표준프로파일값을 서버로부터 가져오시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then Read_ProfileData()
        Me.cmb_location.SelectedValue = L
        Me.bs.EndEdit()
    End Sub

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

    Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
        Dim datetime1 As String = Format(Me.DateTimePicker1.Value, "yyyy")
        Dim datetime2 As String = Format(Me.DateTimePicker2.Value, "yyyy")
        Dim datetime3 As String = Format(Me.DateTimePicker1.Value, "MM")
        Dim datetime4 As String = Format(Me.DateTimePicker2.Value, "MM")
        Dim priod As Single
        Try
            If TOSG(datetime3) - TOSG(datetime4) >= 0 Then
                priod = Math.Round(TOSG(datetime1) - TOSG(datetime2) + (TOSG(datetime3) - TOSG(datetime4)) / 12, 1)
            Else
                priod = Math.Round(TOSG(datetime1) - TOSG(datetime2) - (TOSG(datetime4) - TOSG(datetime3)) / 12, 1)
            End If

        Catch ex As Exception
            priod = 0
        End Try
        If priod < 0 Then priod = 0
        MyTb6.Text = CStr(priod)
        Me.bs.EndEdit()
    End Sub

    Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged
        Dim datetime1 As String = Format(Me.DateTimePicker1.Value, "yyyy")
        Dim datetime2 As String = Format(Me.DateTimePicker2.Value, "yyyy")
        Dim datetime3 As String = Format(Me.DateTimePicker1.Value, "MM")
        Dim datetime4 As String = Format(Me.DateTimePicker2.Value, "MM")
        Dim priod As Single
        Try
            If TOSG(datetime3) - TOSG(datetime4) >= 0 Then
                priod = Math.Round(TOSG(datetime1) - TOSG(datetime2) + (TOSG(datetime3) - TOSG(datetime4)) / 12, 1)
            Else
                priod = Math.Round(TOSG(datetime1) - TOSG(datetime2) - (TOSG(datetime4) - TOSG(datetime3)) / 12, 1)
            End If

        Catch ex As Exception
            priod = 0
        End Try
        If priod < 0 Then priod = 0
        MyTb6.Text = CStr(priod)
        Me.bs.EndEdit()
    End Sub



End Class