160 lines
5.9 KiB
VB.net
160 lines
5.9 KiB
VB.net
Imports VERAG_PROG_ALLGEMEIN
|
|
|
|
Public Class frmEintragStandort
|
|
Public frmHilf As frmTabelleStandorte
|
|
|
|
Dim StandorteDAL As New cStandorteDAL
|
|
Dim myStandort As New cStandort
|
|
Dim hÄnderung As Boolean = False
|
|
Dim Neuanlage As Boolean = False
|
|
|
|
|
|
Public Sub New()
|
|
InitializeComponent()
|
|
Icon = cMeineFunktionenAVISO.GetProgrammIcon
|
|
End Sub
|
|
|
|
Private Sub frmEintragStandort_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
|
|
'Escape händisch abfangen und auf Abbruch-Taste legen
|
|
If e.KeyCode = Keys.Escape Then
|
|
btnAbbruch.PerformClick()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub frmEintragStandort_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
|
|
Me.CenterToParent()
|
|
|
|
If VERAG_PROG_ALLGEMEIN.cglobal.Aktive_ID = 0 Then
|
|
'es erfolgt eine Neuanlage
|
|
Neuanlage = True
|
|
Me.Text = "Neuanlage Standort"
|
|
Else
|
|
Me.Text = "Änderung Standort-Stammdaten"
|
|
'ausgewählter Datensatz wird geladen
|
|
myStandort = StandorteDAL.LesenStandort(VERAG_PROG_ALLGEMEIN.cglobal.Aktive_ID, "", "")
|
|
|
|
'Werte(zuweisen)
|
|
txtStandort.Text = myStandort.Standort
|
|
txtStandort_Text.Text = myStandort.Standort_Text
|
|
txtInfo.Text = myStandort.Info
|
|
txtAnkunft_Betreff.Text = myStandort.eMail_Ankunft_Betreff
|
|
txtAnkunft_Text.Text = myStandort.eMail_Ankunft_Text
|
|
txtFreigabe_Betreff.Text = myStandort.eMail_Freigabe_Betreff
|
|
txtFreigabe_Text.Text = myStandort.eMail_Freigabe_Text
|
|
End If
|
|
|
|
hÄnderung = False
|
|
End Sub
|
|
|
|
|
|
Private Sub btnAbbruch_Click(sender As System.Object, e As System.EventArgs) Handles btnAbbruch.Click
|
|
'Irgendwas wurde geändert, deshalb ein Hinweis, ob auch wirklich abgebrochen werden soll
|
|
'If hÄnderung Then
|
|
' Dim antwort As MsgBoxResult = MsgBox("Wollen Sie wirklich abbrechen?" & vbCrLf & vbCrLf & "Alle Änderungen gehen dabei verloren.", CType(MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, MsgBoxStyle),
|
|
' "Dateneingabe wird abgebrochen")
|
|
' If antwort = vbNo Then
|
|
' Exit Sub
|
|
' End If
|
|
'End If
|
|
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Private Sub txtFeld_GotFocus(sender As Object, e As System.EventArgs) Handles txtStandort.GotFocus,
|
|
txtStandort_Text.GotFocus
|
|
CType(sender, TextBox).SelectAll()
|
|
End Sub
|
|
|
|
'Private Sub txtBilanzart_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtBilanzart.TextChanged, txtBilanzart.TextChanged, txtAIS_Bilanzart.TextChanged, txtInfo.TextChanged, txtStandort.TextChanged
|
|
' hÄnderung = True 'es wurde etwas geändert
|
|
'End Sub
|
|
|
|
'Private Sub txtStandort_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs)
|
|
' 'Es sind nur Zahleneingaben erlaubt
|
|
' Dim asc As Integer = Convert.ToInt32(e.KeyChar)
|
|
' Select Case asc
|
|
' 'Folgende Tasten sind erlaubt
|
|
' '8 = Rücktaste (Back)
|
|
' '13 = Enter
|
|
' '27 = Esc
|
|
' '48 To 57 = 0 bis 9
|
|
' Case 8, 13, 27, 48 To 57
|
|
' Case Else
|
|
' e.Handled = True
|
|
' End Select
|
|
'End Sub
|
|
|
|
Private Sub btnOK_Click(sender As System.Object, e As System.EventArgs) Handles btnOK.Click
|
|
'Falls keine Änderung oder Neuanlage, dann kann Fenster geschlossen werden
|
|
If Not hÄnderung And myStandort.StandortID > 0 Then Me.Close()
|
|
|
|
'Logische Prüfungen vor dem Speichern
|
|
If txtStandort.Text.Trim = "" Then
|
|
MsgBox("Bitte ein Standortkürzel eintragen.", MsgBoxStyle.Exclamation)
|
|
txtStandort.Focus()
|
|
Exit Sub
|
|
End If
|
|
|
|
If txtStandort_Text.Text.Trim = "" Then
|
|
MsgBox("Bitte den Standort-Text eintragen.", MsgBoxStyle.Exclamation)
|
|
txtStandort_Text.Focus()
|
|
Exit Sub
|
|
End If
|
|
|
|
'bei Neuanlage oder Änderung des Keys prüfen, ob Key bereits existiert
|
|
Dim hDoppelt As Boolean = False
|
|
If Neuanlage Then
|
|
hDoppelt = bereits_angelegt()
|
|
ElseIf myStandort.Standort <> txtStandort.Text.Trim Then
|
|
hDoppelt = bereits_angelegt()
|
|
End If
|
|
If hDoppelt Then
|
|
MsgBox("Der Standort '" & txtStandort.Text.Trim & "' existiert bereits.", MsgBoxStyle.Exclamation)
|
|
txtStandort.Focus()
|
|
Exit Sub
|
|
End If
|
|
|
|
'If txtAnkunft_Betreff.Text.Trim = "" Then
|
|
' MsgBox("Bitte den Betreff beim Ankunftsmail eingeben.", MsgBoxStyle.Exclamation)
|
|
' txtAnkunft_Betreff.Focus()
|
|
' Exit Sub
|
|
'End If
|
|
|
|
'If txtFreigabe_Betreff.Text.Trim = "" Then
|
|
' MsgBox("Bitte den Betreff beim Freigabemail eingeben.", MsgBoxStyle.Exclamation)
|
|
' txtFreigabe_Betreff.Focus()
|
|
' Exit Sub
|
|
'End If
|
|
|
|
'Änderungen werden gespeichert
|
|
myStandort.eMail_Ankunft_Betreff = txtAnkunft_Betreff.Text.Trim
|
|
myStandort.eMail_Ankunft_Text = txtAnkunft_Text.Text.Trim
|
|
myStandort.eMail_Freigabe_Betreff = txtFreigabe_Betreff.Text.Trim
|
|
myStandort.eMail_Freigabe_Text = txtFreigabe_Text.Text.Trim
|
|
myStandort.Standort = txtStandort.Text.Trim.ToUpper
|
|
myStandort.Standort_Text = txtStandort_Text.Text.Trim
|
|
myStandort.Info = txtInfo.Text.Trim
|
|
|
|
StandorteDAL.SpeichernStandort(myStandort)
|
|
|
|
If Neuanlage Then
|
|
'bei Neuanlage KZ setzen, damit Tabelle neu anzeigt wird
|
|
VERAG_PROG_ALLGEMEIN.cglobal.Aktive_ID = 1
|
|
End If
|
|
|
|
'Jetzt wird Fenster geschlossen
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Private Function bereits_angelegt() As Boolean
|
|
Dim checkEintrag As New cStandort
|
|
checkEintrag = StandorteDAL.LesenStandort(0, txtStandort.Text.Trim, "")
|
|
If IsNothing(checkEintrag) Then
|
|
Return False
|
|
Else
|
|
Return True
|
|
End If
|
|
|
|
End Function
|
|
End Class
|