Public Class Frm_monuse

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

    '''변경된내용을적용한다.
    Public Overrides Function AcceptChanged() As Boolean
        bs1.EndEdit() : bs2.EndEdit() : bs3.EndEdit()

        '//현재입력된 년차수의값을 모두 업데이트한다.
        If Me.tb_y1.Text.Trim = "" Then Me.tb_y1.Text = "1차년도"
        If Me.tb_y2.Text.Trim = "" Then Me.tb_y2.Text = "2차년도"
        If Me.tb_y3.Text.Trim = "" Then Me.tb_y3.Text = "3차년도"
        For Each dr As DS.tbl_monuseRow In DSET1.tbl_monuse.Select("code='0001'")
            dr.년 = Me.tb_y1.Text.Trim
        Next
        For Each dr As DS.tbl_monuseRow In DSET1.tbl_monuse.Select("code='0002'")
            dr.년 = Me.tb_y2.Text.Trim
        Next
        For Each dr As DS.tbl_monuseRow In DSET1.tbl_monuse.Select("code='0003'")
            dr.년 = Me.tb_y3.Text.Trim
        Next

        Dim BaseDS As DataSet = CType(bs1.DataSource, DataSet)
        Dim BaseDT As DataTable = BaseDS.Tables(bs1.DataMember)
        BaseDT.AcceptChanges()
        Return True
    End Function

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

    '''데이터에변형이있었는가?
    Public Overrides Function HasChanged() As Boolean
        bs1.EndEdit() : bs2.EndEdit() : bs3.EndEdit()
        Dim BaseDS As DataSet = CType(bs1.DataSource, DataSet)
        Dim BaseDT As DataTable = BaseDS.Tables(bs1.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(bs1.DataSource, DataSet)
        Return BaseDS.Tables(bs1.DataMember)
    End Function

#End Region


    Public Sub New(_opentime)

        ' 이 호출은 디자이너에 필요합니다.
        InitializeComponent()
        OpenTime = _opentime

        ' InitializeComponent() 호출 뒤에 초기화 코드를 추가하십시오.


    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
            Case Keys.Escape
                Me.Close()
        End Select
    End Sub

    Private Sub MdiMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

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

        '//프로필 관련

        '//공유데이터셋에 연결한다.
        Me.bs1.DataSource = DSET1
        Me.bs2.DataSource = DSET1
        Me.bs3.DataSource = DSET1

        '//냉방기기
        'AddHandler DSET1.tbl_buha.TableNewRow, AddressOf AddNewDataRow_nangbangkiki

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

        Me.tb_y1.Text = DSET1.tbl_monuse.Select("code='0001'")(0)("년").ToString
        Me.tb_y2.Text = DSET1.tbl_monuse.Select("code='0002'")(0)("년").ToString
        Me.tb_y3.Text = DSET1.tbl_monuse.Select("code='0003'")(0)("년").ToString

        Try
            Me.bs1.Position = CEnergy.ARINCLASS.Read_LastPos_Frm(Me)
        Catch ex As Exception
            Me.bs1.MoveFirst()
        End Try
        AddDebug("▲ Form Load")
    End Sub


#Region "냉방기기"
    Private Sub MdiMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        AcceptChanged()
        CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me, Me.bs1.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
    '        Return "0001"
    '    End Try
    'End Function

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

    Private Sub Binding_Zone()

    End Sub
    'Private Sub AddNewDataRow_nangbangkiki(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs)
    '    e.Row.Item("code") = GetMaxCode(DSET1.tbl_buha)
    'End Sub
    'Private Sub ToolStripButton48_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton48.Click

    '    If Not EndEdit(Me.bs1) Then Return
    '    Me.bs1.AddNew()

    'End Sub
    'Private Sub ToolStripButton49_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton49.Click

    '    'DbBase.DelCrow(Me.bs1, True)

    'End Sub

    Private Sub ToolStripButton51_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton51.Click

        If Not EndEdit(Me.bs1) Then Return
        If Not EndEdit(Me.bs2) Then Return
        If Not EndEdit(Me.bs3) Then Return
        Data_Cancel(DSET1.tbl_monuse, Nothing)
        MdiMain.RefreshMenuList(TreeTag)
    End Sub
#End Region
    Private Sub bs_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bs1.CurrentChanged, bs2.CurrentChanged, bs3.CurrentChanged
        Dim item As BindingSource = CType(sender, BindingSource)
        item.EndEdit()
    End Sub

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

    End Sub

    Private Sub Panel3_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles Panel3.Paint

    End Sub

    Private Sub Arindv9_DataError(sender As Object, e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles Arindv9.DataError, Arindv1.DataError, Arindv2.DataError

    End Sub

    Private Sub ToolStripButton48_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton48.Click

    End Sub
End Class