Public Class Frm_V20091231_buha

#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_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
        'MdiMain.Toggle_Menu_Color(MdiMain.E_MenuIdx.부분부하율)
        'CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me)
        '//프로필 관련

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

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

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

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


#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 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()
        '//냉동기기
        'Dim bs_냉동기방식ComboBox As New BindingSource(DSET, "tbl_common")
        'bs_냉동기방식ComboBox.Filter = "gubun='1046'"
        'Me.냉동기방식ComboBox.DataSource = bs_냉동기방식ComboBox
        '냉동기방식ComboBox.DisplayMember = "name"
        '냉동기방식ComboBox.ValueMember = "code"
        'Me.냉동기방식ComboBox.DataBindings.Add("text", Me.bs, "냉동기방식")
        'AddHandler 냉동기방식ComboBox.KeyDown, AddressOf Cmb_DeleteVal

    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.bs) Then Return
        Me.bs.AddNew()

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

        DbBase.DelCrow(Me.bs, True)

    End Sub

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

        If Not EndEdit(Me.bs) Then Return
        Data_Cancel(DSET1.tbl_buha, Nothing)

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

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

    End Sub
End Class