Public Class frmHistory

    Private Sub frmHistory_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        LoadData_Today()
    End Sub

    Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
        Try
            'TODO: Diese Codezeile lädt Daten in die Tabelle "MyDataset.TBGI_HISTORY". Sie können sie bei Bedarf verschieben oder entfernen.
            Dim user As String = Environment.UserDomainName & "\" & Environment.UserName
            TBGI_HISTORYTableAdapter.Connection.ConnectionString = MyConnectionString
            Me.TBGI_HISTORYTableAdapter.FillByAll(Me.MyDataset.TBGI_HISTORY, user)
        Catch ex As Exception
            MsgBox("Error loading All Data:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub

    Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click
        LoadData_Today()
    End Sub
    Sub LoadData_Today()
        Try
            'TODO: Diese Codezeile lädt Daten in die Tabelle "MyDataset.TBGI_HISTORY". Sie können sie bei Bedarf verschieben oder entfernen.
            Dim user As String = Environment.UserDomainName & "\" & Environment.UserName
            TBGI_HISTORYTableAdapter.Connection.ConnectionString = MyConnectionString
            Me.TBGI_HISTORYTableAdapter.FillToday(Me.MyDataset.TBGI_HISTORY, user)
        Catch ex As Exception
            MsgBox("Error loading Today Data:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub

    Private Sub ToolStripButton3_Click(sender As Object, e As EventArgs) Handles ToolStripButton3.Click
        Dim saveFileDialog1 As New SaveFileDialog
        saveFileDialog1.Filter = "Excel (*.xls)|*.xls|Excel (*.xlsx)|*.xlsx"
        saveFileDialog1.Title = "Export to Excel:"
        saveFileDialog1.ShowDialog()
        If saveFileDialog1.FileName <> "" Then
            Cursor = Cursors.WaitCursor
            If saveFileDialog1.FileName.EndsWith("xlsx") Then
                GridView1.ExportToXlsx(saveFileDialog1.FileName)
            Else
                GridView1.ExportToXls(saveFileDialog1.FileName)
            End If
            Dim result As MsgBoxResult

            If USER_LANGUAGE = "de-DE" Then
                result = MessageBox.Show("Datei wurde erstellt! Wollen Sie diese nun öffnen?", "Erfolgsmeldung:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            Else
                result = MessageBox.Show("File created! Do you want to open it now?", "Success:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            End If

            If result = MsgBoxResult.Yes Then
                Process.Start(saveFileDialog1.FileName)
            End If


        End If
        Cursor = Cursors.Default
    End Sub
End Class