1066 lines
45 KiB
VB.net
1066 lines
45 KiB
VB.net
Imports System.Data.SqlClient
|
|
Imports VERAG_PROG_ALLGEMEIN
|
|
|
|
Public Class frmEintragTvNew
|
|
|
|
Dim AvisoTvNewDAL As New cAvisoTvNewDAL()
|
|
Dim myAvisoTvNew As cAvisoTvNew
|
|
Dim hatAenderung As Boolean = False
|
|
Dim Neuanlage As Boolean = False
|
|
Dim list As New List(Of cAvisoTvNew)()
|
|
Dim listAll As New List(Of cAvisoTvNew)()
|
|
|
|
Private isInitializing As Boolean = False
|
|
|
|
' **Neue Klassenvariable zur Speicherung der zuletzt ausgewählten TVID**
|
|
Private lastSelectedTVID As Integer = 0
|
|
|
|
Public Sub New()
|
|
InitializeComponent()
|
|
InitializeFontComboBoxes()
|
|
Icon = cMeineFunktionenAVISO.GetProgrammIcon()
|
|
End Sub
|
|
|
|
Private Sub frmEintragTvNew_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
LadeStandorte()
|
|
' Erst alle Einträge laden, damit listAll bereits gefüllt ist
|
|
LadenAlleEintraege()
|
|
' Dann erst die Bezeichnungen laden
|
|
LadeTvTextBezeichnungen()
|
|
|
|
grpWochentage.Enabled = chkIsRecurring.Checked
|
|
dgvAVISOTV.SelectionMode = DataGridViewSelectionMode.FullRowSelect
|
|
dgvAVISOTV.MultiSelect = False
|
|
dtpStartDate.ShowCheckBox = True
|
|
dtpEndDate.ShowCheckBox = True
|
|
dtpStartTime.ShowCheckBox = True
|
|
dtpEndTime.ShowCheckBox = True
|
|
chkIsActive.Checked = True
|
|
End Sub
|
|
|
|
|
|
Private Sub LadenAlleEintraege()
|
|
Try
|
|
AvisoTvNewDAL.LesenAlleAvisoTvNew(listAll)
|
|
Catch ex As Exception
|
|
MessageBox.Show("Fehler beim Laden aller Einträge: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub LadeStandorte()
|
|
Dim standorte As New List(Of String)()
|
|
|
|
Try
|
|
Dim conn As SqlConnection = cDatenbankAVISO.GetNewOpenConnectionWithoutError()
|
|
If conn Is Nothing Then
|
|
MessageBox.Show("Die Datenbankverbindung konnte nicht hergestellt werden.", "Verbindungsfehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return
|
|
End If
|
|
|
|
Dim sql As String = "SELECT DISTINCT StandortBezeichnung FROM StandorteTV ORDER BY StandortBezeichnung"
|
|
Using cmd As New SqlCommand(sql, conn)
|
|
Using dr As SqlDataReader = cmd.ExecuteReader()
|
|
While dr.Read()
|
|
Dim standort As String = Convert.ToString(dr("StandortBezeichnung"))
|
|
standorte.Add(standort)
|
|
End While
|
|
End Using
|
|
End Using
|
|
Catch ex As SqlException
|
|
MessageBox.Show("SQL Fehler beim Laden der Standorte: " & ex.Message, "SQL Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Catch ex As Exception
|
|
MessageBox.Show("Allgemeiner Fehler beim Laden der Standorte: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
End Try
|
|
|
|
cbxStandort.Items.Clear()
|
|
cbxStandort.Items.AddRange(standorte.ToArray())
|
|
If cbxStandort.Items.Count > 0 Then cbxStandort.SelectedIndex = 0
|
|
End Sub
|
|
|
|
' Neue parameterlose initdgv-Methode
|
|
Private Sub initdgv()
|
|
Dim selectedStandort As String = If(cbxStandort.SelectedItem IsNot Nothing, cbxStandort.SelectedItem.ToString(), "")
|
|
initdgv(selectedStandort)
|
|
End Sub
|
|
|
|
Private Sub initdgv(selectedStandort As String)
|
|
Try
|
|
' Entfernen Sie vorhandene Event-Handler, um Doppelbindungen zu vermeiden
|
|
RemoveHandler dgvAVISOTV.SelectionChanged, AddressOf dgvAVISOTV_SelectionChanged
|
|
RemoveHandler dgvAVISOTV.CellFormatting, AddressOf dgvAVISOTV_CellFormatting
|
|
|
|
Dim standortID As Integer = AvisoTvNewDAL.GetStandortID(selectedStandort)
|
|
|
|
Dim showInactive As Boolean = chkShowInactive.Checked
|
|
|
|
Dim gefilterteListe As List(Of cAvisoTvNew)
|
|
If showInactive Then
|
|
gefilterteListe = list.Where(Function(x) x.StandortID = standortID).ToList()
|
|
Else
|
|
gefilterteListe = list.Where(Function(x) x.StandortID = standortID AndAlso x.IsActive).ToList()
|
|
End If
|
|
|
|
' Zurücksetzen der DataSource und Löschen der Zeilen
|
|
dgvAVISOTV.DataSource = Nothing
|
|
dgvAVISOTV.Rows.Clear()
|
|
|
|
If gefilterteListe.Count > 0 Then
|
|
dgvAVISOTV.DataSource = gefilterteListe
|
|
|
|
' Anpassen der Spaltenüberschriften und Sichtbarkeiten
|
|
ConfigureDataGridViewColumns()
|
|
|
|
AddFixeZeileTextColumns()
|
|
|
|
' Konvertieren von RTF-Inhalten zu reinem Text
|
|
ConvertRtfToPlainText()
|
|
|
|
dgvAVISOTV.AutoResizeColumns()
|
|
|
|
' Wiederhinzufügen der Event-Handler
|
|
AddHandler dgvAVISOTV.SelectionChanged, AddressOf dgvAVISOTV_SelectionChanged
|
|
|
|
' Wiederherstellung der Auswahl basierend auf lastSelectedTVID
|
|
RestoreSelection()
|
|
Else
|
|
' Wiederhinzufügen der Event-Handler
|
|
AddHandler dgvAVISOTV.SelectionChanged, AddressOf dgvAVISOTV_SelectionChanged
|
|
|
|
' Felder leeren und Auswahl zurücksetzen
|
|
ClearFields()
|
|
myAvisoTvNew = Nothing
|
|
End If
|
|
|
|
Neuanlage = False
|
|
hatAenderung = False
|
|
|
|
Catch ex As Exception
|
|
MessageBox.Show("Fehler beim Laden der Daten: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
End Try
|
|
End Sub
|
|
|
|
' Neue Methode zum Konfigurieren der Spaltenüberschriften und Sichtbarkeiten
|
|
Private Sub ConfigureDataGridViewColumns()
|
|
' Anpassen der Spaltenüberschriften
|
|
Dim headerTexts As New Dictionary(Of String, String) From {
|
|
{"TvTextBezeichnungID", "ID"},
|
|
{"TvTextBezeichnung", "Bezeichnung"},
|
|
{"StartDate", "Startdatum"},
|
|
{"EndDate", "Enddatum"},
|
|
{"StartTime", "Startzeit"},
|
|
{"EndTime", "Endzeit"},
|
|
{"IsRecurring", "Wiederholen"},
|
|
{"IsActive", "Aktiv"}
|
|
}
|
|
|
|
For Each columnName As String In headerTexts.Keys
|
|
If dgvAVISOTV.Columns.Contains(columnName) Then
|
|
dgvAVISOTV.Columns(columnName).HeaderText = headerTexts(columnName)
|
|
End If
|
|
Next
|
|
|
|
' Verstecken der unnötigen Spalten
|
|
Dim columnsToHide As String() = {
|
|
"FixeZeile1RTF", "FixeZeile2RTF", "FixeZeile3RTF",
|
|
"Standort", "Art",
|
|
"IsMonday", "IsTuesday", "IsWednesday",
|
|
"IsThursday", "IsFriday", "IsSaturday", "IsSunday", "StandortID", "FixeZeile1HTML", "FixeZeile2HTML", "FixeZeile3HTML"
|
|
}
|
|
|
|
For Each columnName As String In columnsToHide
|
|
If dgvAVISOTV.Columns.Contains(columnName) Then
|
|
dgvAVISOTV.Columns(columnName).Visible = False
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub AddFixeZeileTextColumns()
|
|
Dim textColumns As New List(Of DataGridViewTextBoxColumn) From {
|
|
New DataGridViewTextBoxColumn() With {
|
|
.Name = "FixeZeile1Text",
|
|
.HeaderText = "Deutsch",
|
|
.ReadOnly = True
|
|
},
|
|
New DataGridViewTextBoxColumn() With {
|
|
.Name = "FixeZeile2Text",
|
|
.HeaderText = "Englisch",
|
|
.ReadOnly = True
|
|
},
|
|
New DataGridViewTextBoxColumn() With {
|
|
.Name = "FixeZeile3Text",
|
|
.HeaderText = "Türkisch",
|
|
.ReadOnly = True
|
|
}
|
|
}
|
|
|
|
For Each col As DataGridViewTextBoxColumn In textColumns
|
|
If Not dgvAVISOTV.Columns.Contains(col.Name) Then
|
|
dgvAVISOTV.Columns.Add(col)
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
' Neue Methode zur Konvertierung von RTF zu reinem Text
|
|
Private Sub ConvertRtfToPlainText()
|
|
For Each row As DataGridViewRow In dgvAVISOTV.Rows
|
|
If Not row.IsNewRow Then
|
|
Dim rtfValue1 As String = If(row.Cells("FixeZeile1RTF").Value?.ToString(), String.Empty)
|
|
Dim rtfValue2 As String = If(row.Cells("FixeZeile2RTF").Value?.ToString(), String.Empty)
|
|
Dim rtfValue3 As String = If(row.Cells("FixeZeile3RTF").Value?.ToString(), String.Empty)
|
|
|
|
row.Cells("FixeZeile1Text").Value = RtfToPlainText(rtfValue1)
|
|
row.Cells("FixeZeile2Text").Value = RtfToPlainText(rtfValue2)
|
|
row.Cells("FixeZeile3Text").Value = RtfToPlainText(rtfValue3)
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
' Neue Methode zur Wiederherstellung der Auswahl
|
|
Private Sub RestoreSelection()
|
|
If lastSelectedTVID <> 0 Then
|
|
Dim rowToSelect = dgvAVISOTV.Rows.Cast(Of DataGridViewRow)().FirstOrDefault(Function(r) CType(r.DataBoundItem, cAvisoTvNew).TvTextBezeichnungID = lastSelectedTVID)
|
|
If rowToSelect IsNot Nothing Then
|
|
rowToSelect.Selected = True
|
|
dgvAVISOTV.FirstDisplayedScrollingRowIndex = rowToSelect.Index
|
|
dgvAVISOTV.CurrentCell = rowToSelect.Cells(0)
|
|
Dim selectedAviso As cAvisoTvNew = listAll.FirstOrDefault(Function(x) x.TvTextBezeichnungID = lastSelectedTVID AndAlso x.IsActive)
|
|
FillFieldsFromAviso(selectedAviso)
|
|
Else
|
|
' Falls die TVID nicht gefunden wird, wähle die erste Zeile aus
|
|
SelectFirstRow()
|
|
End If
|
|
Else
|
|
' Wenn keine letzte Auswahl vorhanden ist, wähle die erste Zeile aus
|
|
If dgvAVISOTV.Rows.Count > 0 Then
|
|
SelectFirstRow()
|
|
End If
|
|
End If
|
|
lastSelectedTVID = 0
|
|
End Sub
|
|
|
|
' Hilfsmethode zum Auswählen der ersten Zeile
|
|
Private Sub SelectFirstRow()
|
|
If dgvAVISOTV.Rows.Count > 0 Then
|
|
dgvAVISOTV.Rows(0).Selected = True
|
|
dgvAVISOTV.CurrentCell = dgvAVISOTV.Rows(0).Cells(0)
|
|
dgvAVISOTV_SelectionChanged(Nothing, Nothing)
|
|
End If
|
|
End Sub
|
|
|
|
' Beispielhafte Implementierung der RtfToPlainText-Methode
|
|
Private Function RtfToPlainText(rtf As String) As String
|
|
If String.IsNullOrEmpty(rtf) Then Return String.Empty
|
|
Using rtb As New RichTextBox()
|
|
Try
|
|
rtb.Rtf = rtf
|
|
Return rtb.Text
|
|
Catch ex As Exception
|
|
' Handle invalid RTF format
|
|
Return String.Empty
|
|
End Try
|
|
End Using
|
|
End Function
|
|
|
|
|
|
Private Sub dgvAVISOTV_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs)
|
|
' Definieren Sie die Namen der RTF-Spalten
|
|
Dim rtfColumns As String() = {"FixeZeile1RTF", "FixeZeile2RTF", "FixeZeile3RTF"}
|
|
|
|
' Überprüfen Sie, ob die aktuelle Spalte eine der RTF-Spalten ist
|
|
If rtfColumns.Contains(dgvAVISOTV.Columns(e.ColumnIndex).Name) AndAlso e.Value IsNot Nothing Then
|
|
Try
|
|
' Konvertieren Sie den RTF-Text in normalen Text
|
|
Using rtb As New RichTextBox()
|
|
rtb.Rtf = e.Value.ToString()
|
|
e.Value = rtb.Text
|
|
e.FormattingApplied = True
|
|
End Using
|
|
Catch ex As Exception
|
|
' Falls das RTF ungültig ist, zeigen Sie den Originalwert an
|
|
e.Value = e.Value.ToString()
|
|
e.FormattingApplied = True
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub cbxStandort_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxStandort.SelectedValueChanged
|
|
If list IsNot Nothing Then list.Clear()
|
|
|
|
Dim selectedStandort As String = If(cbxStandort.SelectedItem IsNot Nothing, cbxStandort.SelectedItem.ToString(), "")
|
|
|
|
Try
|
|
AvisoTvNewDAL.LesenAvisoTvNew(0, "", selectedStandort, list)
|
|
Catch ex As Exception
|
|
MessageBox.Show("Fehler beim Lesen der Einträge: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return
|
|
End Try
|
|
|
|
LadeTvTextBezeichnungen()
|
|
initdgv(selectedStandort)
|
|
End Sub
|
|
|
|
Private Sub btnOpenSettings_Click(sender As Object, e As EventArgs) Handles btnOpenSettings.Click
|
|
Dim currentStandort As String = cbxStandort.SelectedItem?.ToString()
|
|
Dim currentStandortID As Integer = 0
|
|
|
|
If Not String.IsNullOrEmpty(currentStandort) Then
|
|
currentStandortID = AvisoTvNewDAL.GetStandortID(currentStandort)
|
|
End If
|
|
|
|
If currentStandortID = 0 Then
|
|
MessageBox.Show("Bitte wählen Sie einen gültigen Standort aus.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return
|
|
End If
|
|
|
|
Dim settingsForm As New frmTvSettings(currentStandortID)
|
|
settingsForm.ShowDialog()
|
|
End Sub
|
|
|
|
|
|
Private Sub btnNeu_Click(sender As Object, e As EventArgs)
|
|
Dim standort As String = cbxStandort.SelectedItem?.ToString()
|
|
If String.IsNullOrEmpty(standort) Then
|
|
MessageBox.Show("Bitte wählen Sie einen Standort aus.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
|
Return
|
|
End If
|
|
|
|
Dim standortID As Integer = AvisoTvNewDAL.GetStandortID(standort)
|
|
If standortID = 0 Then
|
|
MessageBox.Show("Ungültiger Standort ausgewählt.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return
|
|
End If
|
|
|
|
myAvisoTvNew = New cAvisoTvNew() With {
|
|
.StandortID = standortID,
|
|
.Standort = standort,
|
|
.Art = "",
|
|
.IsActive = True
|
|
}
|
|
|
|
cmbTvTextBezeichnungAuswahl.SelectedIndex = -1
|
|
txtNeueTvTextBezeichnung.Text = ""
|
|
|
|
Neuanlage = True
|
|
hatAenderung = False
|
|
Me.Text = "Neuen Eintrag hinzufügen"
|
|
End Sub
|
|
|
|
Public Class ComboBoxItem
|
|
Public Property ID As Integer
|
|
Public Property DisplayText As String
|
|
|
|
Public Overrides Function ToString() As String
|
|
Return DisplayText
|
|
End Function
|
|
End Class
|
|
|
|
Private Sub cmbTvTextBezeichnungAuswahl_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbTvTextBezeichnungAuswahl.SelectedIndexChanged
|
|
If isInitializing OrElse cmbTvTextBezeichnungAuswahl.SelectedIndex = -1 Then
|
|
Return
|
|
End If
|
|
|
|
If listAll Is Nothing OrElse Not listAll.Any() Then
|
|
MessageBox.Show("Die Liste aller AvisoEinträge ist nicht geladen oder leer.", "Datenfehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return
|
|
End If
|
|
|
|
Try
|
|
Dim selectedTvTextBezeichnungID As Integer
|
|
Try
|
|
selectedTvTextBezeichnungID = Convert.ToInt32(cmbTvTextBezeichnungAuswahl.SelectedValue)
|
|
Debug.WriteLine("Selected TvTextBezeichnungID: " & selectedTvTextBezeichnungID)
|
|
Catch ex As Exception
|
|
MessageBox.Show("Ungültiger Wert für TvTextBezeichnungID: " & ex.Message, "Konvertierungsfehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return
|
|
End Try
|
|
|
|
If listAll Is Nothing OrElse Not listAll.Any() Then
|
|
MessageBox.Show("Die Liste aller AvisoEinträge ist nicht geladen oder leer.", "Datenfehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return
|
|
End If
|
|
|
|
Dim selectedAviso As cAvisoTvNew = listAll.FirstOrDefault(Function(x) x.TvTextBezeichnungID = selectedTvTextBezeichnungID AndAlso x.IsActive)
|
|
|
|
Dim currentStandort As String = cbxStandort.SelectedItem?.ToString()
|
|
Dim currentStandortID As Integer = AvisoTvNewDAL.GetStandortID(currentStandort)
|
|
|
|
If selectedAviso IsNot Nothing Then
|
|
Debug.WriteLine("Gefundenes Aviso: TVID = " & selectedAviso.TvTextBezeichnungID)
|
|
myAvisoTvNew = selectedAviso
|
|
Neuanlage = False
|
|
FillFieldsFromAviso(selectedAviso)
|
|
Me.Text = "Eintrag bearbeiten"
|
|
txtNeueTvTextBezeichnung.Text = ""
|
|
Else
|
|
Debug.WriteLine("Kein bestehender Eintrag gefunden. Neuer Eintrag wird erstellt.")
|
|
myAvisoTvNew = New cAvisoTvNew() With {
|
|
.IsActive = True,
|
|
.StandortID = currentStandortID,
|
|
.Standort = currentStandort
|
|
}
|
|
Neuanlage = True
|
|
Me.Text = "Neuen Eintrag hinzufügen"
|
|
End If
|
|
Catch ex As InvalidCastException
|
|
MessageBox.Show("Fehler beim Konvertieren der TvTextBezeichnungID: " & ex.Message, "Konvertierungsfehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Catch ex As Exception
|
|
MessageBox.Show("Ein unerwarteter Fehler ist aufgetreten: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub tabControlZeilen_SelectedIndexChanged(sender As Object, e As EventArgs) Handles tabControlZeilen.SelectedIndexChanged
|
|
InitializeFontComboBoxes()
|
|
End Sub
|
|
|
|
Private Sub InitializeFontComboBoxes()
|
|
Try
|
|
isInitializing = True
|
|
|
|
' Schritt 1: Font-Familien sammeln
|
|
Dim fontFamilies As New List(Of String)()
|
|
For Each font As FontFamily In FontFamily.Families
|
|
fontFamilies.Add(font.Name)
|
|
Next
|
|
|
|
' Schritt 2: cmbFontFamily initialisieren
|
|
cmbFontFamily.Items.Clear()
|
|
cmbFontFamily.Items.AddRange(fontFamilies.ToArray())
|
|
|
|
' Schritt 3: Schriftgrößen sammeln
|
|
Dim sizes As Integer() = {8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72}
|
|
cmbFontSize.Items.Clear()
|
|
cmbFontSize.Items.AddRange(sizes.Select(Function(s) s.ToString()).ToArray())
|
|
|
|
' Schritt 4: Aktuelle Schriftfamilie und Schriftgröße aus der RichTextBox lesen
|
|
If AktuelleRichTextBox IsNot Nothing Then
|
|
Dim selectedFont As Font = AktuelleRichTextBox.SelectionFont
|
|
|
|
If selectedFont IsNot Nothing Then
|
|
' Setze die Schriftfamilie
|
|
If fontFamilies.Contains(selectedFont.FontFamily.Name) Then
|
|
cmbFontFamily.SelectedItem = selectedFont.FontFamily.Name
|
|
ElseIf cmbFontFamily.Items.Count > 0 Then
|
|
cmbFontFamily.SelectedIndex = 0 ' Standard auf erste Schriftart setzen
|
|
End If
|
|
|
|
' Setze die Schriftgröße
|
|
Dim fontSizeInt As Integer = CInt(Math.Round(selectedFont.Size))
|
|
Dim fontSizeStr As String = fontSizeInt.ToString()
|
|
If cmbFontSize.Items.Contains(fontSizeStr) Then
|
|
cmbFontSize.SelectedItem = fontSizeStr
|
|
ElseIf cmbFontSize.Items.Count > 0 Then
|
|
cmbFontSize.SelectedItem = "12" ' Standard auf 12 setzen
|
|
End If
|
|
Else
|
|
' Falls keine spezifische Schrift ausgewählt ist, setze Standardwerte
|
|
If cmbFontFamily.Items.Count > 0 Then
|
|
cmbFontFamily.SelectedIndex = 0
|
|
End If
|
|
If cmbFontSize.Items.Count > 0 Then
|
|
cmbFontSize.SelectedItem = "12"
|
|
End If
|
|
End If
|
|
Else
|
|
' Falls AktuelleRichTextBox nicht gesetzt ist, setze Standardwerte
|
|
If cmbFontFamily.Items.Count > 0 Then
|
|
cmbFontFamily.SelectedIndex = 0
|
|
End If
|
|
If cmbFontSize.Items.Count > 0 Then
|
|
cmbFontSize.SelectedItem = "12"
|
|
End If
|
|
End If
|
|
|
|
' Schritt 5: Event-Handler aktualisieren
|
|
' Entferne alte Event-Handler, um Doppelbindungen zu vermeiden
|
|
RemoveHandler cmbFontFamily.SelectedIndexChanged, AddressOf cmbFontFamily_SelectedIndexChanged
|
|
RemoveHandler cmbFontSize.SelectedIndexChanged, AddressOf cmbFontSize_SelectedIndexChanged
|
|
|
|
' Füge neue Event-Handler hinzu
|
|
AddHandler cmbFontFamily.SelectedIndexChanged, AddressOf cmbFontFamily_SelectedIndexChanged
|
|
AddHandler cmbFontSize.SelectedIndexChanged, AddressOf cmbFontSize_SelectedIndexChanged
|
|
|
|
isInitializing = False
|
|
Catch ex As Exception
|
|
MessageBox.Show("Fehler beim Initialisieren der Schriftart-ComboBoxes: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Finally
|
|
isInitializing = False
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
|
|
' Schriftfamilie ComboBox SelectionChanged
|
|
Private Sub cmbFontFamily_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
If isInitializing Then Return
|
|
UpdateFont()
|
|
End Sub
|
|
|
|
' Schriftgröße ComboBox SelectionChanged
|
|
Private Sub cmbFontSize_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
If isInitializing Then Return
|
|
UpdateFont()
|
|
End Sub
|
|
|
|
Private Sub UpdateFont()
|
|
If isInitializing Then Return
|
|
|
|
' Nur anwenden, wenn tatsächlich etwas markiert ist
|
|
If AktuelleRichTextBox.SelectionLength <= 0 Then
|
|
Return
|
|
End If
|
|
|
|
Dim selectedFontFamily As String = If(cmbFontFamily.SelectedItem, AktuelleRichTextBox.SelectionFont?.FontFamily.Name)
|
|
Dim selectedFontSize As Single
|
|
If Single.TryParse(cmbFontSize.SelectedItem, selectedFontSize) Then
|
|
' Erstellen einer neuen Schriftart basierend auf der Auswahl
|
|
Dim currentFont As Font = AktuelleRichTextBox.SelectionFont
|
|
If currentFont IsNot Nothing Then
|
|
AktuelleRichTextBox.SelectionFont = New Font(selectedFontFamily, selectedFontSize, currentFont.Style)
|
|
Else
|
|
' Wenn die Auswahl unterschiedliche Schriftarten hat, eine neue Schriftart setzen
|
|
AktuelleRichTextBox.SelectionFont = New Font(selectedFontFamily, selectedFontSize)
|
|
End If
|
|
hatAenderung = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnBold_Click(sender As Object, e As EventArgs) Handles btnBold.Click
|
|
If isInitializing Then Return
|
|
ToggleFontStyle(FontStyle.Bold)
|
|
End Sub
|
|
|
|
Private Sub btnItalic_Click(sender As Object, e As EventArgs) Handles btnItalic.Click
|
|
If isInitializing Then Return
|
|
ToggleFontStyle(FontStyle.Italic)
|
|
End Sub
|
|
|
|
Private Sub btnUnderline_Click(sender As Object, e As EventArgs) Handles btnUnderline.Click
|
|
If isInitializing Then Return
|
|
ToggleFontStyle(FontStyle.Underline)
|
|
End Sub
|
|
|
|
Private Sub btnTextColor_Click(sender As Object, e As EventArgs) Handles btnTextColor.Click
|
|
' Nur anwenden, wenn tatsächlich etwas markiert ist
|
|
If AktuelleRichTextBox.SelectionLength <= 0 Then
|
|
Return
|
|
End If
|
|
|
|
If colorDialogText.ShowDialog() = DialogResult.OK Then
|
|
AktuelleRichTextBox.SelectionColor = colorDialogText.Color
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnBackColor_Click(sender As Object, e As EventArgs) Handles btnBackColor.Click
|
|
' Nur anwenden, wenn tatsächlich etwas markiert ist
|
|
If AktuelleRichTextBox.SelectionLength <= 0 Then
|
|
Return
|
|
End If
|
|
|
|
If colorDialogText.ShowDialog() = DialogResult.OK Then
|
|
AktuelleRichTextBox.SelectionBackColor = colorDialogText.Color
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnAlignLeft_Click(sender As Object, e As EventArgs) Handles btnAlignLeft.Click
|
|
If isInitializing Then Return
|
|
' Nur anwenden, wenn tatsächlich etwas markiert ist
|
|
If AktuelleRichTextBox.SelectionLength <= 0 Then
|
|
Return
|
|
End If
|
|
AktuelleRichTextBox.SelectionAlignment = HorizontalAlignment.Left
|
|
End Sub
|
|
|
|
Private Sub btnAlignCenter_Click(sender As Object, e As EventArgs) Handles btnAlignCenter.Click
|
|
If isInitializing Then Return
|
|
' Nur anwenden, wenn tatsächlich etwas markiert ist
|
|
If AktuelleRichTextBox.SelectionLength <= 0 Then
|
|
Return
|
|
End If
|
|
AktuelleRichTextBox.SelectionAlignment = HorizontalAlignment.Center
|
|
End Sub
|
|
|
|
Private Sub btnAlignRight_Click(sender As Object, e As EventArgs) Handles btnAlignRight.Click
|
|
If isInitializing Then Return
|
|
' Nur anwenden, wenn tatsächlich etwas markiert ist
|
|
If AktuelleRichTextBox.SelectionLength <= 0 Then
|
|
Return
|
|
End If
|
|
AktuelleRichTextBox.SelectionAlignment = HorizontalAlignment.Right
|
|
End Sub
|
|
|
|
Private Sub ToggleFontStyle(style As FontStyle)
|
|
If isInitializing Then Return
|
|
' Nur anwenden, wenn tatsächlich etwas markiert ist
|
|
If AktuelleRichTextBox.SelectionLength <= 0 Then
|
|
Return
|
|
End If
|
|
|
|
If AktuelleRichTextBox.SelectionFont IsNot Nothing Then
|
|
Dim currentFont As Font = AktuelleRichTextBox.SelectionFont
|
|
Dim newFontStyle As FontStyle
|
|
|
|
If AktuelleRichTextBox.SelectionFont.Style.HasFlag(style) Then
|
|
' Entferne den Stil
|
|
newFontStyle = currentFont.Style And Not style
|
|
Else
|
|
' Füge den Stil hinzu
|
|
newFontStyle = currentFont.Style Or style
|
|
End If
|
|
|
|
' Setze die neue Schriftart
|
|
AktuelleRichTextBox.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, newFontStyle)
|
|
hatAenderung = True
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub LadeTvTextBezeichnungen()
|
|
isInitializing = True
|
|
|
|
' Event-Handler entfernen, um zu verhindern, dass SelectedIndexChanged zu früh feuert
|
|
RemoveHandler cmbTvTextBezeichnungAuswahl.SelectedIndexChanged, AddressOf cmbTvTextBezeichnungAuswahl_SelectedIndexChanged
|
|
|
|
Dim bezeichnungen As New List(Of cTvTextBezeichnung)()
|
|
|
|
Try
|
|
bezeichnungen = AvisoTvNewDAL.LadenAlleTvTextBezeichnungen()
|
|
Catch ex As Exception
|
|
MessageBox.Show("Fehler beim Laden der TvTextBezeichnungen: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
isInitializing = False
|
|
' Event-Handler wieder hinzufügen, bevor wir verlassen
|
|
AddHandler cmbTvTextBezeichnungAuswahl.SelectedIndexChanged, AddressOf cmbTvTextBezeichnungAuswahl_SelectedIndexChanged
|
|
Return
|
|
End Try
|
|
|
|
Dim items As New List(Of ComboBoxItem)()
|
|
For Each bezeichnung In bezeichnungen
|
|
items.Add(New ComboBoxItem() With {
|
|
.ID = bezeichnung.TvTextBezeichnungID,
|
|
.DisplayText = bezeichnung.TvTextBezeichnung
|
|
})
|
|
Next
|
|
|
|
cmbTvTextBezeichnungAuswahl.DataSource = Nothing
|
|
cmbTvTextBezeichnungAuswahl.DataSource = items
|
|
cmbTvTextBezeichnungAuswahl.DisplayMember = "DisplayText"
|
|
cmbTvTextBezeichnungAuswahl.ValueMember = "ID"
|
|
cmbTvTextBezeichnungAuswahl.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
|
cmbTvTextBezeichnungAuswahl.SelectedIndex = -1
|
|
|
|
isInitializing = False
|
|
|
|
' Event-Handler jetzt, nachdem alles fertig ist, wieder hinzufügen
|
|
AddHandler cmbTvTextBezeichnungAuswahl.SelectedIndexChanged, AddressOf cmbTvTextBezeichnungAuswahl_SelectedIndexChanged
|
|
End Sub
|
|
|
|
|
|
Private Sub txtNeueTvTextBezeichnung_TextChanged(sender As Object, e As EventArgs) Handles txtNeueTvTextBezeichnung.TextChanged
|
|
If Not String.IsNullOrWhiteSpace(txtNeueTvTextBezeichnung.Text) Then
|
|
cmbTvTextBezeichnungAuswahl.SelectedIndex = -1
|
|
myAvisoTvNew = New cAvisoTvNew() With {
|
|
.TvTextBezeichnung = txtNeueTvTextBezeichnung.Text.Trim(),
|
|
.IsActive = True
|
|
}
|
|
Neuanlage = True
|
|
Me.Text = "Neuen Eintrag hinzufügen"
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub FillFieldsFromAviso(ByVal aviso As cAvisoTvNew)
|
|
cmbTvTextBezeichnungAuswahl.SelectedValue = aviso.TvTextBezeichnungID
|
|
|
|
|
|
txtNeueTvTextBezeichnung.Text = ""
|
|
|
|
' Hier setzt du die Textzeilen, wenn vorhanden
|
|
rtbZeile1.Rtf = aviso.FixeZeile1RTF
|
|
rtbZeile2.Rtf = aviso.FixeZeile2RTF
|
|
rtbZeile3.Rtf = aviso.FixeZeile3RTF
|
|
|
|
chkIsRecurring.Checked = aviso.IsRecurring.GetValueOrDefault(False)
|
|
|
|
If aviso.StartDate.HasValue Then
|
|
dtpStartDate.Value = aviso.StartDate.Value
|
|
dtpStartDate.Checked = True
|
|
Else
|
|
dtpStartDate.Value = DateTime.Now
|
|
dtpStartDate.Checked = False
|
|
End If
|
|
|
|
If aviso.EndDate.HasValue Then
|
|
dtpEndDate.Value = aviso.EndDate.Value
|
|
dtpEndDate.Checked = True
|
|
Else
|
|
dtpEndDate.Value = DateTime.Now
|
|
dtpEndDate.Checked = False
|
|
End If
|
|
|
|
If aviso.StartTime.HasValue Then
|
|
dtpStartTime.Value = DateTime.Today.Add(aviso.StartTime.Value)
|
|
dtpStartTime.Checked = True
|
|
Else
|
|
dtpStartTime.Value = DateTime.Now
|
|
dtpStartTime.Checked = False
|
|
End If
|
|
|
|
If aviso.EndTime.HasValue Then
|
|
dtpEndTime.Value = DateTime.Today.Add(aviso.EndTime.Value)
|
|
dtpEndTime.Checked = True
|
|
Else
|
|
dtpEndTime.Value = DateTime.Now
|
|
dtpEndTime.Checked = False
|
|
End If
|
|
|
|
chkMonday.Checked = aviso.IsMonday.GetValueOrDefault(False)
|
|
chkTuesday.Checked = aviso.IsTuesday.GetValueOrDefault(False)
|
|
chkWednesday.Checked = aviso.IsWednesday.GetValueOrDefault(False)
|
|
chkThursday.Checked = aviso.IsThursday.GetValueOrDefault(False)
|
|
chkFriday.Checked = aviso.IsFriday.GetValueOrDefault(False)
|
|
chkSaturday.Checked = aviso.IsSaturday.GetValueOrDefault(False)
|
|
chkSunday.Checked = aviso.IsSunday.GetValueOrDefault(False)
|
|
nudPrioritaet.Value = Convert.ToDecimal(aviso.Art)
|
|
chkIsActive.Checked = aviso.IsActive
|
|
|
|
grpWochentage.Enabled = chkIsRecurring.Checked
|
|
End Sub
|
|
|
|
Private Function ConvertRtfToHtml(rtf As String) As String
|
|
Using rtb As New RichTextBox()
|
|
rtb.Rtf = rtf
|
|
Dim sb As New System.Text.StringBuilder()
|
|
|
|
Dim defaultFont As System.Drawing.Font = rtb.Font
|
|
Dim totalLength As Integer = rtb.TextLength
|
|
Dim charIndex As Integer = 0
|
|
|
|
While charIndex < totalLength
|
|
' Wähle das aktuelle Zeichen aus
|
|
rtb.Select(charIndex, 1)
|
|
|
|
' Hole die Formatierung des aktuellen Zeichens
|
|
Dim startFont As System.Drawing.Font = rtb.SelectionFont
|
|
Dim startColor As Color = rtb.SelectionColor
|
|
Dim startBackColor As Color = rtb.SelectionBackColor
|
|
Dim startAlignment As HorizontalAlignment = rtb.SelectionAlignment
|
|
|
|
If startFont Is Nothing Then
|
|
startFont = defaultFont
|
|
End If
|
|
|
|
' Initialisiere die Lauf-Länge
|
|
Dim runLength As Integer = 1
|
|
|
|
' Finde die Länge des Laufs
|
|
While (charIndex + runLength < totalLength)
|
|
rtb.Select(charIndex + runLength, 1)
|
|
Dim currentFont As System.Drawing.Font = rtb.SelectionFont
|
|
Dim currentColor As Color = rtb.SelectionColor
|
|
Dim currentBackColor As Color = rtb.SelectionBackColor
|
|
Dim currentAlignment As HorizontalAlignment = rtb.SelectionAlignment
|
|
|
|
If currentFont Is Nothing Then
|
|
currentFont = defaultFont
|
|
End If
|
|
|
|
' Überprüfe, ob die Formatierung gleich ist
|
|
If Not FontsAreEqual(startFont, currentFont) OrElse
|
|
startColor <> currentColor OrElse
|
|
startBackColor <> currentBackColor OrElse
|
|
startAlignment <> currentAlignment Then
|
|
Exit While
|
|
End If
|
|
|
|
runLength += 1
|
|
End While
|
|
|
|
' Hole den Text des Laufs
|
|
Dim runText As String = rtb.Text.Substring(charIndex, runLength)
|
|
Dim style As New System.Text.StringBuilder()
|
|
|
|
Select Case startAlignment
|
|
Case HorizontalAlignment.Left
|
|
' nichts hinzufügen, da Standard
|
|
Case HorizontalAlignment.Center
|
|
style.Append("text-align:center;")
|
|
Case HorizontalAlignment.Right
|
|
style.Append("text-align:right;")
|
|
End Select
|
|
|
|
If startFont IsNot Nothing Then
|
|
style.Append($"font-family:{startFont.FontFamily.Name};")
|
|
style.Append($"font-size:{startFont.SizeInPoints}pt;")
|
|
If startFont.Bold Then
|
|
style.Append("font-weight:bold;")
|
|
End If
|
|
If startFont.Italic Then
|
|
style.Append("font-style:italic;")
|
|
End If
|
|
If startFont.Underline Then
|
|
style.Append("text-decoration:underline;")
|
|
End If
|
|
End If
|
|
|
|
If startColor <> Color.Empty Then
|
|
style.Append($"color:{ColorTranslator.ToHtml(startColor)};")
|
|
End If
|
|
|
|
If startBackColor <> Color.Empty Then
|
|
style.Append($"background-color:{ColorTranslator.ToHtml(startBackColor)};")
|
|
End If
|
|
|
|
If style.Length > 0 Then
|
|
sb.Append($"<div style=""{style.ToString()}"">")
|
|
Else
|
|
sb.Append("<div>")
|
|
End If
|
|
|
|
Dim encodedText As String = System.Net.WebUtility.HtmlEncode(runText)
|
|
sb.Append(encodedText)
|
|
|
|
sb.Append("</div>")
|
|
|
|
charIndex += runLength
|
|
End While
|
|
|
|
Return sb.ToString()
|
|
End Using
|
|
End Function
|
|
|
|
Private Function FontsAreEqual(font1 As System.Drawing.Font, font2 As System.Drawing.Font) As Boolean
|
|
Return font1.FontFamily.Name = font2.FontFamily.Name AndAlso
|
|
font1.SizeInPoints = font2.SizeInPoints AndAlso
|
|
font1.Style = font2.Style
|
|
End Function
|
|
|
|
|
|
Private Sub btnSpeichern_Click(sender As Object, e As EventArgs) Handles btnSpeichern.Click
|
|
Dim verwendeteTvTextBezeichnung As String = ""
|
|
Dim isNeueTvTextBezeichnung As Boolean = False
|
|
Dim currentStandort As String = cbxStandort.SelectedItem?.ToString()
|
|
Dim currentStandortID As Integer = 0
|
|
|
|
If Not String.IsNullOrEmpty(currentStandort) Then
|
|
currentStandortID = AvisoTvNewDAL.GetStandortID(currentStandort)
|
|
End If
|
|
|
|
If currentStandortID = 0 Then
|
|
MessageBox.Show("Ungültiger Standort ausgewählt.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return
|
|
End If
|
|
|
|
Dim selectedTvTextBezeichnungID As Integer = 0
|
|
|
|
If cmbTvTextBezeichnungAuswahl.SelectedIndex >= 0 AndAlso String.IsNullOrWhiteSpace(txtNeueTvTextBezeichnung.Text) Then
|
|
verwendeteTvTextBezeichnung = cmbTvTextBezeichnungAuswahl.Text
|
|
selectedTvTextBezeichnungID = Convert.ToInt32(cmbTvTextBezeichnungAuswahl.SelectedValue)
|
|
ElseIf Not String.IsNullOrWhiteSpace(txtNeueTvTextBezeichnung.Text) Then
|
|
verwendeteTvTextBezeichnung = txtNeueTvTextBezeichnung.Text.Trim()
|
|
isNeueTvTextBezeichnung = True
|
|
Else
|
|
MessageBox.Show("Bitte wählen Sie eine TvTextBezeichnung aus oder geben Sie eine neue TvTextBezeichnung ein.", "Eingabefehler", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
|
cmbTvTextBezeichnungAuswahl.Focus()
|
|
Exit Sub
|
|
End If
|
|
|
|
Try
|
|
' **Speichern der TVID der aktuell ausgewählten Zeile**
|
|
If dgvAVISOTV.CurrentRow IsNot Nothing AndAlso dgvAVISOTV.CurrentRow.DataBoundItem IsNot Nothing Then
|
|
Dim selectedAviso As cAvisoTvNew = CType(dgvAVISOTV.CurrentRow.DataBoundItem, cAvisoTvNew)
|
|
If selectedAviso IsNot Nothing Then
|
|
lastSelectedTVID = selectedAviso.TvTextBezeichnungID
|
|
End If
|
|
End If
|
|
|
|
' Konvertiere RTF zu HTML
|
|
Dim rtfContent As String = rtbZeile1.Rtf
|
|
Dim htmlContent As String = ConvertRtfToHtml(rtfContent)
|
|
Dim rtfContent2 As String = rtbZeile2.Rtf
|
|
Dim htmlContent2 As String = ConvertRtfToHtml(rtfContent2)
|
|
Dim rtfContent3 As String = rtbZeile3.Rtf
|
|
Dim htmlContent3 As String = ConvertRtfToHtml(rtfContent3)
|
|
myAvisoTvNew.TvTextBezeichnung = verwendeteTvTextBezeichnung
|
|
myAvisoTvNew.StandortID = currentStandortID
|
|
|
|
If isNeueTvTextBezeichnung Then
|
|
If AvisoTvNewDAL.IstTvTextBezeichnungVorhanden(myAvisoTvNew.TvTextBezeichnung) Then
|
|
MessageBox.Show("Die TvTextBezeichnung ist vorhanden. Bitte wählen Sie eine eindeutige TvTextBezeichnung.", "Eingabefehler", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
|
txtNeueTvTextBezeichnung.Focus()
|
|
Exit Sub
|
|
End If
|
|
Else
|
|
myAvisoTvNew.TvTextBezeichnungID = selectedTvTextBezeichnungID
|
|
End If
|
|
|
|
' Speichere den HTML-Inhalt
|
|
myAvisoTvNew.FixeZeile1RTF = If(String.IsNullOrWhiteSpace(rtbZeile1.Text), Nothing, rtfContent)
|
|
myAvisoTvNew.FixeZeile1HTML = If(String.IsNullOrWhiteSpace(rtbZeile1.Text), Nothing, htmlContent)
|
|
myAvisoTvNew.FixeZeile2RTF = If(String.IsNullOrWhiteSpace(rtbZeile2.Text), Nothing, rtfContent2)
|
|
myAvisoTvNew.FixeZeile2HTML = If(String.IsNullOrWhiteSpace(rtbZeile2.Text), Nothing, htmlContent2)
|
|
myAvisoTvNew.FixeZeile3RTF = If(String.IsNullOrWhiteSpace(rtbZeile3.Text), Nothing, rtfContent3)
|
|
myAvisoTvNew.FixeZeile3HTML = If(String.IsNullOrWhiteSpace(rtbZeile3.Text), Nothing, htmlContent3)
|
|
|
|
myAvisoTvNew.IsRecurring = chkIsRecurring.Checked
|
|
|
|
myAvisoTvNew.StartDate = If(dtpStartDate.Checked, CType(dtpStartDate.Value.Date, Date?), Nothing)
|
|
myAvisoTvNew.EndDate = If(dtpEndDate.Checked, CType(dtpEndDate.Value.Date, Date?), Nothing)
|
|
|
|
myAvisoTvNew.StartTime = If(dtpStartTime.Checked, CType(dtpStartTime.Value.TimeOfDay, TimeSpan?), Nothing)
|
|
myAvisoTvNew.EndTime = If(dtpEndTime.Checked, CType(dtpEndTime.Value.TimeOfDay, TimeSpan?), Nothing)
|
|
|
|
myAvisoTvNew.IsMonday = chkMonday.Checked
|
|
myAvisoTvNew.IsTuesday = chkTuesday.Checked
|
|
myAvisoTvNew.IsWednesday = chkWednesday.Checked
|
|
myAvisoTvNew.IsThursday = chkThursday.Checked
|
|
myAvisoTvNew.IsFriday = chkFriday.Checked
|
|
myAvisoTvNew.IsSaturday = chkSaturday.Checked
|
|
myAvisoTvNew.IsSunday = chkSunday.Checked
|
|
|
|
myAvisoTvNew.IsActive = chkIsActive.Checked
|
|
myAvisoTvNew.Art = Convert.ToInt32(nudPrioritaet.Value)
|
|
|
|
If Neuanlage Then
|
|
myAvisoTvNew.Standort = cbxStandort.SelectedItem?.ToString()
|
|
If String.IsNullOrEmpty(myAvisoTvNew.Standort) Then
|
|
MessageBox.Show("Bitte wählen Sie einen Standort aus.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
|
Return
|
|
End If
|
|
End If
|
|
|
|
Debug.WriteLine($"Speichern: TVID = {myAvisoTvNew.TvTextBezeichnungID}, TvTextBezeichnungID = {myAvisoTvNew.TvTextBezeichnungID}, StandortID = {myAvisoTvNew.StandortID}")
|
|
|
|
' Speichern der Einstellungen
|
|
AvisoTvNewDAL.SpeichernAvisoTvNew(myAvisoTvNew)
|
|
|
|
LadeTvTextBezeichnungen()
|
|
|
|
list.Clear()
|
|
AvisoTvNewDAL.LesenAvisoTvNew(0, "", currentStandort, list)
|
|
|
|
' Nach dem Speichern und Neuladen der Daten
|
|
initdgv()
|
|
hatAenderung = False
|
|
|
|
If isNeueTvTextBezeichnung Then
|
|
' Setze lastSelectedTVID auf die TVID des neuen Eintrags
|
|
lastSelectedTVID = myAvisoTvNew.TvTextBezeichnungID
|
|
MessageBox.Show("Die neue TvTextBezeichnung wurde erfolgreich gespeichert.", "Erfolg", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|
cmbTvTextBezeichnungAuswahl.SelectedValue = myAvisoTvNew.TvTextBezeichnungID
|
|
txtNeueTvTextBezeichnung.Text = ""
|
|
Else
|
|
MessageBox.Show("Die Änderungen wurden erfolgreich gespeichert.", "Erfolg", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
MessageBox.Show("Fehler beim Speichern der Daten: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub btnLoeschen_Click(sender As Object, e As EventArgs) Handles btnLoeschen.Click
|
|
If myAvisoTvNew Is Nothing OrElse myAvisoTvNew.TvTextBezeichnungID = 0 Then
|
|
MessageBox.Show("Bitte wählen Sie einen Eintrag zum Deaktivieren aus.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|
Return
|
|
End If
|
|
|
|
Dim antwort As DialogResult = MessageBox.Show("Möchten Sie den ausgewählten Eintrag wirklich deaktivieren?", "Deaktivieren bestätigen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
|
|
If antwort = DialogResult.Yes Then
|
|
Try
|
|
AvisoTvNewDAL.SetzeAufInaktiv(myAvisoTvNew.TvTextBezeichnungID)
|
|
list.Clear()
|
|
AvisoTvNewDAL.LesenAvisoTvNew(0, "", cbxStandort.SelectedItem?.ToString(), list)
|
|
initdgv()
|
|
ClearFields()
|
|
myAvisoTvNew = Nothing
|
|
Neuanlage = False
|
|
hatAenderung = False
|
|
MessageBox.Show("Der Eintrag wurde erfolgreich deaktiviert.", "Erfolg", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|
Catch ex As Exception
|
|
MessageBox.Show("Fehler beim Deaktivieren des Eintrags: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub dgvAVISOTV_SelectionChanged(sender As Object, e As EventArgs) Handles dgvAVISOTV.SelectionChanged
|
|
If dgvAVISOTV.CurrentRow IsNot Nothing AndAlso dgvAVISOTV.CurrentRow.DataBoundItem IsNot Nothing Then
|
|
Dim selectedAviso As cAvisoTvNew = CType(dgvAVISOTV.CurrentRow.DataBoundItem, cAvisoTvNew)
|
|
If selectedAviso IsNot Nothing Then
|
|
myAvisoTvNew = selectedAviso
|
|
FillFieldsFromAviso(selectedAviso)
|
|
Neuanlage = False
|
|
hatAenderung = False
|
|
Me.Text = "Eintrag bearbeiten"
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnAbbrechen_Click(sender As Object, e As EventArgs) Handles btnAbbrechen.Click
|
|
If hatAenderung Then
|
|
Dim antwort As DialogResult = MessageBox.Show("Es liegen ungespeicherte Änderungen vor. Möchten Sie das Fenster trotzdem schließen?", "Ungespeicherte Änderungen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
|
|
If antwort = DialogResult.No Then Exit Sub
|
|
End If
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Private Sub txt_TextChanged(sender As Object, e As EventArgs) Handles rtbZeile1.TextChanged, dtpStartDate.ValueChanged, dtpEndDate.ValueChanged, dtpStartTime.ValueChanged, dtpEndTime.ValueChanged, chkIsRecurring.CheckedChanged, chkMonday.CheckedChanged, chkTuesday.CheckedChanged, chkWednesday.CheckedChanged, chkThursday.CheckedChanged, chkFriday.CheckedChanged, chkSaturday.CheckedChanged, chkSunday.CheckedChanged, chkIsActive.CheckedChanged, cmbTvTextBezeichnungAuswahl.SelectedIndexChanged, txtNeueTvTextBezeichnung.TextChanged
|
|
hatAenderung = True
|
|
End Sub
|
|
|
|
Private Sub frmEintragTvNew_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
|
|
If hatAenderung Then
|
|
Dim antwort As DialogResult = MessageBox.Show("Es liegen ungespeicherte Änderungen vor. Möchten Sie das Fenster trotzdem schließen?", "Ungespeicherte Änderungen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
|
|
If antwort = DialogResult.No Then e.Cancel = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub chkIsRecurring_CheckedChanged(sender As Object, e As EventArgs) Handles chkIsRecurring.CheckedChanged
|
|
grpWochentage.Enabled = chkIsRecurring.Checked
|
|
End Sub
|
|
|
|
Private ReadOnly Property AktuelleRichTextBox As RichTextBox
|
|
Get
|
|
Select Case tabControlZeilen.SelectedIndex
|
|
Case 0
|
|
Return rtbZeile1
|
|
Case 1
|
|
Return rtbZeile2
|
|
Case 2
|
|
Return rtbZeile3
|
|
Case Else
|
|
Return rtbZeile1
|
|
End Select
|
|
End Get
|
|
End Property
|
|
|
|
|
|
Private Sub ClearFields()
|
|
cmbTvTextBezeichnungAuswahl.SelectedIndex = -1
|
|
txtNeueTvTextBezeichnung.Text = ""
|
|
rtbZeile1.Text = ""
|
|
rtbZeile2.Text = ""
|
|
rtbZeile3.Text = ""
|
|
nudPrioritaet.Value = Convert.ToDecimal(0)
|
|
dtpStartDate.Value = DateTime.Now
|
|
dtpStartDate.Checked = False
|
|
dtpEndDate.Value = DateTime.Now
|
|
dtpEndDate.Checked = False
|
|
dtpStartTime.Value = DateTime.Now
|
|
dtpStartTime.Checked = False
|
|
dtpEndTime.Value = DateTime.Now
|
|
dtpEndTime.Checked = False
|
|
chkIsRecurring.Checked = False
|
|
chkMonday.Checked = False
|
|
chkTuesday.Checked = False
|
|
chkWednesday.Checked = False
|
|
chkThursday.Checked = False
|
|
chkFriday.Checked = False
|
|
chkSaturday.Checked = False
|
|
chkSunday.Checked = False
|
|
chkIsActive.Checked = True
|
|
grpWochentage.Enabled = False
|
|
End Sub
|
|
|
|
Private Sub chkShowInactive_CheckedChanged_1(sender As Object, e As EventArgs) Handles chkShowInactive.CheckedChanged
|
|
initdgv()
|
|
End Sub
|
|
|
|
End Class
|