Files
AVISO/AvisoTV/frmAnzeige.vb
2022-07-08 08:11:33 +02:00

1011 lines
43 KiB
VB.net

Imports System.IO
Imports VERAG_PROG_ALLGEMEIN
Imports VERAG_PROG_ALLGEMEIN.cMeineFunktionenAVISO
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports AvisoTV.cUserSettings
Public Class frmAnzeige
Dim cptmp As Point
Dim displayZeilen As Boolean = False
Dim displayZeilenBIG As Boolean = False
Private AvisoDAL As New cAvisoDAL
Private VermerkeDAL As New cVermerkeDAL
Private locZeilen As Integer = -1
Private Anzahl As Integer
Private Grid_aktiv As Boolean = False
Private Zähler As Long = 0
Private hMerkZeit As Date
Private Max_Zeilen As Integer = 8 'maximale Zeilenanzeige pro Seite
Private ZeilenStandard As Integer = 8
Private Max_Seiten As Integer = 1 'maximale Zeilenanzeige pro Seite
Private Aktive_Seite As Integer = 0 'Merker, welche Seite gerade angezeigt wird
Private Merk_Ankunftsdatum As Date 'Merker Datum des zuletzt angezeigten LKWs (wegen Umblättern)
Private Anzahl_alle As Integer = 0
Private Standort As String = "" 'ev. Einschränkung auf Standort
Private StandortATILLA As Boolean = False
Private StandortSUB12 As Boolean = False
Private ZeilenATILLA As Integer = 16
Dim CLUSTER As String = ""
Private Font1 As New Font(FontFamily.GenericSansSerif, 70, FontStyle.Bold)
Private Font1_MESS As New Font(FontFamily.GenericSansSerif, 40, FontStyle.Bold)
Private Font2 As New Font(FontFamily.GenericSansSerif, 70, FontStyle.Bold)
Private Font3 As New Font(FontFamily.GenericSansSerif, 44, FontStyle.Bold)
Private Font4 As New Font(FontFamily.GenericSansSerif, 44, FontStyle.Bold)
Private Font5 As New Font(FontFamily.GenericSansSerif, 30, FontStyle.Bold)
Private Font6 As New Font(FontFamily.GenericSansSerif, 30, FontStyle.Bold)
Private Font7 As New Font(FontFamily.GenericSansSerif, 30, FontStyle.Bold)
Private Font8 As New Font(FontFamily.GenericSansSerif, 30, FontStyle.Bold)
Private Font_LkwOK_LKWNr As New Font(FontFamily.GenericSansSerif, 30, FontStyle.Bold)
Dim GridBackgroundColor As Color = Color.FromArgb(240, 245, 255)
Dim TESTSYSTEM As Boolean = False
Private isloaded As Boolean = False
Private Sekunden As Integer = 10
Dim StandortDatei As String = Application.StartupPath & "\Standort.txt"
Private Sub frmAnzeige_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.PageDown Then
Listen_ermitteln()
End If
End Sub
Private Sub frmAnzeige_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
' Cursor.Position = Me.PointToScreen(New Point(Me.Width, Me.Height))
Me.CenterToScreen()
'TEST
StandortATILLA = False
Me.Left = 0
Me.Top = 0
' Me.Width = 1920
' Me.Height = 1080
Me.Text += " " & Application.ProductVersion
'Falls kein File vorhanden, dann werden alle angezeigt
If Standort = "" Then
If Not File.Exists(StandortDatei) Then
Standort = ""
Else
Dim fs As New FileStream(StandortDatei, FileMode.Open, FileAccess.Read)
Dim strmReader As New StreamReader(fs)
Standort = strmReader.ReadLine
fs.Close()
End If
End If
If cDatenbankAVISO.GlobalConnection IsNot Nothing Then cDatenbankAVISO.GlobalConnection.Close()
cDatenbankAVISO.GlobalConnection = Nothing
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = TESTSYSTEM
If TESTSYSTEM Then
Button2.Text = "Zum Echtsystem wechseln"
Else
Button2.Text = "Zum Testsystem wechseln"
End If
Panel1.BackColor = Color.FromArgb(0, 54, 128)
lblZeit.BackColor = Color.FromArgb(0, 54, 128)
lblAnzahl.BackColor = Color.FromArgb(0, 54, 128)
lblSeite.BackColor = Color.FromArgb(0, 54, 128)
Label11.ForeColor = Color.White
lblZeit.ForeColor = Color.White
Panel1.ForeColor = Color.White
lblAnzahl.ForeColor = Color.White
lblSeite.ForeColor = Color.White
CLUSTER = ""
VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "VERAG"
'Standort Atilla bekommt Sonderanzeige
If Standort = "ATILLA" Then
VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "ATILLA"
StandortATILLA = True
ZeilenStandard = ZeilenATILLA
'jetzt noch Standort auf leer setzen, damit alles angezeigt wird
Standort = ""
ElseIf Standort = "IMEX" Then
VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "IMEX"
' VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER = "FRONTOFFICE"
Panel1.BackColor = Color.Gold
Panel1.BackColor = Color.Gold
lblZeit.BackColor = Color.Gold
lblAnzahl.BackColor = Color.Gold
lblSeite.BackColor = Color.Gold
Label11.ForeColor = Color.Black
lblZeit.ForeColor = Color.Black
Panel1.ForeColor = Color.Black
lblAnzahl.ForeColor = Color.Black
lblSeite.ForeColor = Color.Black
'gridAnkunft.BackgroundColor = Color.FromArgb(255, 255, 240)
GridBackgroundColor = Color.FromArgb(255, 255, 240)
ElseIf Standort = "UNISPED" Then
VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "UNISPED"
' VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER = "FRONTOFFICE"
Panel1.BackColor = Color.Red
Panel1.BackColor = Color.Red
lblZeit.BackColor = Color.Red
lblAnzahl.BackColor = Color.Red
lblSeite.BackColor = Color.Red
'gridAnkunft.BackgroundColor = Color.FromArgb(255, 255, 240)
GridBackgroundColor = Color.FromArgb(255, 255, 240)
ElseIf Standort = "AMBAR" Then
VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "AMBAR"
CLUSTER = "FRONTOFFICE"
ElseIf Standort = "FRONTOFFICE" Then
VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "FRONTOFFICE"
CLUSTER = "FRONTOFFICE"
ElseIf Standort = "VERAG" Then
' VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER = "FRONTOFFICE"
End If
gridAnkunft.AlternatingRowsDefaultCellStyle.BackColor = GridBackgroundColor
'Standort Suben12 bekommt Sonderanzeige
If Standort = "SUB12" Then
Max_Zeilen = 12
ZeilenStandard = 12
StandortSUB12 = True
'jetzt noch Standort anpassen, damit alles angezeigt wird
Standort = "SUB"
End If
If Standort = "VERAG_ALLE" Then
Standort = ""
End If
Merk_Ankunftsdatum = LeerDatum
Listen_ermitteln()
loadsettings()
initSettings()
'Timer starten
hMerkZeit = Now
Timer1.Enabled = True
End Sub
WithEvents timerRemove As New Timer
Private Sub timerRemove_Tick(sender As Object, e As EventArgs) Handles timerRemove.Tick
Exit Sub
For Each c As Control In Me.Controls
'MsgBox(c.Name)
If c.Name.Contains("TMPpic") Then
'MsgBox(c.Name)
Me.Controls.Remove(c)
End If
Next
End Sub
Function getSQL(ByRef where As String, seiten As Boolean, onlyOK As Boolean) As String
Dim buero As String = ""
If StandortATILLA Then
buero = " , Buero "
End If
Dim stat_tmp As String = cGlobal.Status_Ankunft.ToString
Dim ank_tmp As String = ""
If seiten Then ank_tmp = " And Ankunft > " & SQLDatumZeitSekunden(Merk_Ankunftsdatum)
If onlyOK Then ank_tmp = " And LKW_fertig = 1 "
If False Then 'alle Staten
stat_tmp = "3,99,4,5,0"
ank_tmp = ""
End If
where = " WHERE "
Dim hSQL As String = "SELECT AvisoID, Status, UPPER(LKW_Nr) as LKW_Nr, Ankunft, Dauer, letzterMitarbeiter,WeiterleitungTextTV, LKW_fertig " & buero & " , AvisoTVHinweis, ImEx, ZOLLDigitalEingereicht FROM Aviso "
where &= " Status IN( " & stat_tmp & ") "
If CLUSTER <> "" Then
where &= " AND (Firma= '" & VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA & "' OR Cluster= '" & CLUSTER & "') "
ElseIf Standort <> "WAI" And Standort <> "SBG" And Standort <> "NKD" Then
where &= " AND Firma= '" & VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA & "' "
End If
If Standort <> "" Then where &= " AND Grenzstelle = '" & Standort.Replace("IMEX", "SUB").Replace("UNISPED", "SUB").Replace("FRONTOFFICE", "SUB").Replace("AMBAR", "AMB") & "'" 'nur die IMEX-LKW in SUB anzeigen
If Standort = "FRONTOFFICE" Then where &= " AND isnull(ImEx,'IMPORT') IN ('IMPORT','') "
hSQL &= where
hSQL += ank_tmp & " ORDER BY CASE " &
" when [Status] =3 then 1 " &
" when [Status] =99 then 2 " &
" when [Status] =4 then 3 " &
" when [Status] =5 then 4 " &
" when [Status] =0 then 4 " &
" END , Ankunft"
Return hSQL
End Function
Dim contrnamecnt As Integer = 0
Public Sub Listen_ermitteln()
picConnectionProblem.Visible = False
Dim connok As Boolean = False
Try
Dim conn As SqlConnection = cDatenbankAVISO.GetNewOpenConnectionWithoutError()
If conn Is Nothing Then
picConnectionProblem.Visible = True
Else
picConnectionProblem.Visible = False
connok = True
conn.Close()
End If
' End Using
'conn.Close()
Catch ex As Exception
picConnectionProblem.Visible = True 'MsgBox("what " & ex.Message)
End Try
If connok Then
clmnBuero.Visible = StandortATILLA
clmnImEx.Visible = (Standort = "WAI" Or Standort.Replace("AMBAR", "AMB") = "AMB")
If Aktive_Seite <= Max_Seiten Then Aktive_Seite += 1 'nächste Seite anzeigen
If Aktive_Seite > Max_Seiten Then
Merk_Ankunftsdatum = LeerDatum 'falls letzte Seite angezeigt, dann wieder von vorne anfangen
Aktive_Seite = 1
End If
Dim where As String = ""
Dim hSQL = getSQL(where, True, False)
'Anzahl der Aviso mit Status Ankunft ermitteln
Dim CheckAnzahl As String = "SELECT AvisoID FROM Aviso " & where 'WHERE Status IN( " & stat_tmp & ") "
' If Standort <> "" Then CheckAnzahl += " AND Grenzstelle = '" & Standort.Replace("IMEX", "SUB") & "'"
Anzahl_alle = AvisoDAL.Anzahl_Aviso_ermitteln(CheckAnzahl)
lblAnzahl.Text = Anzahl_alle.ToString
Max_Seiten = VarToInt(Fix(Anzahl_alle / ZeilenStandard))
If Anzahl_alle Mod ZeilenStandard <> 0 Then Max_Seiten += 1
'Max_Seiten = (Anzahl_alle Mod 8) + 1
timerRemove.Enabled = True
contrnamecnt = 0
Dim anz As Integer = 0
Try
Dim conn As SqlConnection = cDatenbankAVISO.GetNewOpenConnectionWithoutError()
removeControls()
'MsgBox(hSQL)
'If IsNothing(conn) Then Exit Sub 'Fehler bei DB-Zugriff - Anzeige nicht aktualisieren
Using cmd As New SqlCommand(hSQL, conn)
' MsgBox(conn.ConnectionString)
Dim dr = cmd.ExecuteReader()
'MsgBox(cmd.Connection.ConnectionString)
If Not IsNothing(dr) Then
gridAnkunft.Rows.Clear() 'Ansicht löschen
While dr.Read()
' MsgBox(VarToStr(dr.Item("LKW_Nr")))
anz += 1
Dim LKW_Nr As String = VarToStr(dr.Item("LKW_Nr"))
Dim hAnkunft As String = Format(CDate(VarToDate((dr.Item("Ankunft")))), "dd.MM. HH:mm")
Dim hDauer As Long = DateDiff(DateInterval.Minute, CDate(VarToDate((dr.Item("Ankunft")))), Now)
Dim Dauer As String = Minuten_auf_Text(hDauer)
Dim hMitarbeiter As String = VarToStr(dr.Item("LetzterMitarbeiter"))
Dim WeiterleitungTextTV As String = VarToStr(dr.Item("WeiterleitungTextTV"))
Dim ImEx As String = VarToStr(dr.Item("ImEx"))
Dim ZOLLDigitalEingereicht As String = If(CBool(dr.Item("ZOLLDigitalEingereicht")), "D", "")
If (hMitarbeiter = "Weiterleitung" Or hMitarbeiter = "") And WeiterleitungTextTV <> "" Then
hMitarbeiter = WeiterleitungTextTV
Else
If StandortATILLA Or Standort = "IMEX" Or Standort = "FRONTOFFICE" Then
'bei Mitarbeiter nur User aus letzter Bearbeiter rausfiltern
Dim x As String = ""
Dim n As Integer = 0
While n < hMitarbeiter.Length
If hMitarbeiter.Substring(n, 1) <> "/" Then
x += hMitarbeiter.Substring(n, 1)
Else
Exit While
End If
n += 1
End While
hMitarbeiter = x
End If
End If
Dim hFertig As String = ""
' If VarToBool(dr.Item("LKW_fertig")) Then hFertig = "OK"
If VarToStr(dr.Item("AvisoTVHinweis")) <> "" Then
hFertig = VarToStr(dr.Item("AvisoTVHinweis"))
ElseIf VarToBool(dr.Item("LKW_fertig")) Then
Select Case Standort
Case "FRONTOFFICE"
hFertig = "OK > Front-Office"
Case Else
hFertig = "OK"
End Select
End If
If anz <= Max_Zeilen Then
If StandortATILLA Then
Dim hBuero As String = VarToStr(dr.Item("buero"))
gridAnkunft.Rows.Add(hFertig, LKW_Nr, hAnkunft, Dauer, hMitarbeiter, hBuero, "", ZOLLDigitalEingereicht)
ElseIf Standort = "WAI" Or Standort.Replace("AMBAR", "AMB") = "AMB" Then
If ImEx = "IMPORT" Then ImEx = "IM"
If ImEx = "EXPORT" Then ImEx = "EX"
' MsgBox(ImEx)
gridAnkunft.Rows.Add(hFertig, LKW_Nr, hAnkunft, Dauer, hMitarbeiter, "", ImEx, ZOLLDigitalEingereicht)
Else
gridAnkunft.Rows.Add(hFertig, LKW_Nr, hAnkunft, Dauer, hMitarbeiter, "", "", ZOLLDigitalEingereicht)
End If
If ImEx <> "" Then
Dim r As DataGridViewRow = gridAnkunft.Rows(gridAnkunft.RowCount - 1)
r.Cells("clmnImEx").Style.ForeColor = Color.White
If ImEx = "IM" Then r.Cells("clmnImEx").Style.BackColor = Color.Green
If ImEx = "EX" Then r.Cells("clmnImEx").Style.BackColor = Color.Blue
End If
If hFertig.StartsWith("OK") Then
Dim r As DataGridViewRow = gridAnkunft.Rows(gridAnkunft.RowCount - 1)
r.Cells(0).Style.ForeColor = Color.Green
r.Cells(1).Style.ForeColor = Color.Green
End If
If CBool(dr.Item("ZOLLDigitalEingereicht")) Then
Dim r As DataGridViewRow = gridAnkunft.Rows(gridAnkunft.RowCount - 1)
' r.Cells("clmnArt").Style.BackColor = Color.DarkGreen
r.Cells("clmnArt").Style.ForeColor = Color.DarkGreen
End If
If VarToStr(dr.Item("AvisoTVHinweis")) <> "" Then
Dim r As DataGridViewRow = gridAnkunft.Rows(gridAnkunft.RowCount - 1)
r.Cells(0).Style.ForeColor = Color.Red
r.Cells(1).Style.ForeColor = Color.Red
r.Cells(0).Style.Font = Font1_MESS
Dim doimage As Image = Nothing
Select Case r.Cells(0).Value.ToString
Case "PASSPORT" : doimage = My.Resources.passport : r.Cells(0).Value = "PASSPORT" ' r.Cells(0).Value = "PASS"
Case "DOKUMENT" : doimage = My.Resources.passport : r.Cells(0).Value = "PROBLEM" ' r.Cells(0).Value = "PASS"
Case "URGENT" : doimage = My.Resources.urgent_qu : r.Cells(0).Value = "PROBLEM"
End Select
doimage = Nothing
If doimage IsNot Nothing Then
r.Cells(0).Style.Alignment = DataGridViewContentAlignment.MiddleRight
Dim pic As New PictureBox
pic.Location = getLocation(gridAnkunft, r)
pic.BackColor = r.Cells(0).Style.BackColor
pic.Image = doimage
pic.Height = r.Cells(0).Size.Height - 2 : pic.Width = pic.Height
pic.SizeMode = PictureBoxSizeMode.Zoom
pic.Name = "TMPpic" & contrnamecnt
Me.Controls.Add(pic)
'Me.Controls(pic.Name).BringToFront()
pic.BringToFront()
contrnamecnt += 1
' MsgBox(pic.Name)
End If
End If
Merk_Ankunftsdatum = CDate(VarToDate((dr.Item("Ankunft")))).AddSeconds(1)
' lblZeile1.Text = Merk_Ankunftsdatum.ToShortDateString & Merk_Ankunftsdatum.ToShortTimeString
' lblZeile1.Refresh()
End If
End While
End If
dr.Close()
End Using
'gridFertig:
Using cmd As New SqlCommand(getSQL("", False, True), conn)
Dim dr = cmd.ExecuteReader()
If Not IsNothing(dr) Then
gridFertig.Rows.Clear() 'Ansicht löschen
While dr.Read()
anz += 1
Dim LKW_Nr As String = VarToStr(dr.Item("LKW_Nr"))
gridFertig.Rows.Add(My.Resources.okRound, LKW_Nr)
End While
End If
dr.Close()
End Using
Catch ex As Exception
picConnectionProblem.Visible = True 'sdfsdf MsgBox("ERR: " & ex.Message & ex.StackTrace)
End Try
'Ermitteln
If Max_Seiten > 0 Then
lblSeite.Text = Aktive_Seite.ToString & "/" & Max_Seiten.ToString
Else
lblSeite.Text = "0/0"
End If
Dim Special = ""
Select Case Now.DayOfWeek
Case DayOfWeek.Monday : Special = "MO"
Case DayOfWeek.Tuesday : Special = "DI"
Case DayOfWeek.Wednesday : Special = "MI"
Case DayOfWeek.Thursday : Special = "DO"
Case DayOfWeek.Friday : Special = "FR"
Case DayOfWeek.Saturday : Special = "SA"
Case DayOfWeek.Sunday : Special = "SO"
End Select
'If Now.Day = 24 And Now.Month = 12 Then
' Special = "CHRISTMAS"
'End If
'If Now.Day = 1 And Now.Month = 1 Then
' Special = "NEWYEAR"
'End If
'Infotext auslesen
Dim AvisoTVDAL As New cAvisoTVDAL
Dim AvisoTV As cAvisoTV = Nothing
If StandortATILLA Then
AvisoTV = AvisoTVDAL.LesenAvisoTV(-1, "", "ATILLA", Special)
Else
AvisoTV = AvisoTVDAL.LesenAvisoTV(-1, "", Standort, Special)
End If
Dim lblBigInfoVisible = False
lblBigInfo.Visible = False
displayZeilen = False
displayZeilenBIG = False
Dim Panel2Height = 109 '143
If Not IsNothing(AvisoTV) Then
Select Case AvisoTV.Art
Case "INFO"
Panel2Height = 109 '143
lblZeile1.Text = AvisoTV.FixeZeile1.Trim
lblZeile2.Text = AvisoTV.FixeZeile2.Trim
displayZeilen = True
Case "BIG"
Panel2Height = 310 '344
displayZeilenBIG = True
lblBigInfoVisible = True
lblBigInfo2.Text = AvisoTV.FixeZeile2.Trim
lblBigInfo2.Padding = New Padding(0, 0, 0, 20)
lblBigInfo2.Dock = DockStyle.Top
lblBigInfo2.Height = 100
lblBigInfoVisible = True
lblBigInfo.Text = AvisoTV.FixeZeile1.Trim
lblBigInfo.Padding = New Padding(0, 20, 0, 0)
lblBigInfo.Dock = DockStyle.Top
lblBigInfo.Height = 100
End Select
End If
Panel2.Height = Panel2Height
lblBigInfo2.Visible = lblBigInfoVisible
lblBigInfo.Visible = lblBigInfoVisible
lblZeit.Text = Format(Now, "dd.MM. HH:mm:ss")
End If
For Each c As Control In gridAnkunft.Parent.Controls
If c.Name.ToString.Contains("TMPpic") Then
c.BringToFront()
End If
Next
gridAnkunft.ClearSelection() 'wenn erste Zeile Markiert, Problem mit Farblicher Darstellung
End Sub
Sub removeControls()
For Each c As Control In Me.Controls
'MsgBox(c.Name)
If c.Name.Contains("TMPpic") Then
'MsgBox(c.Name)
Me.Controls.Remove(c)
End If
Next
End Sub
Function getLocation(d As DataGridView, r As DataGridViewRow) As Point
Dim CellRectangle1 As Rectangle = d.GetCellDisplayRectangle(0, d.RowCount - 1, False)
CellRectangle1.X += d.Left
CellRectangle1.Y += d.Top + r.Height
Return PointToScreen(New Point(CellRectangle1.X, CellRectangle1.Y - r.Cells(0).Size.Height))
End Function
Private Sub dataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles gridAnkunft.CellPainting
Exit Sub
If e.ColumnIndex = 0 Then
If gridAnkunft.Rows(e.RowIndex).Cells(0).Value.ToString = "" Then
'Dim newImage As Image = Image.FromFile("Images/image.jpg")
Dim maskImage As Image = My.Resources.waitLKW
' e.Graphics.DrawImage(newImage, e.CellBounds.Left + 2, e.CellBounds.Top + 2, 26, 26)
e.Graphics.DrawImage(maskImage, e.CellBounds.Left, e.CellBounds.Top, 30, 30)
e.Handled = True
Else
e.Handled = False
End If
End If
If False Then
For Each r As DataGridViewRow In gridAnkunft.Rows
If r.Cells(0).Value.ToString = "" Then
'Dim newImage As Image = Image.FromFile("Images/image.jpg")
Dim maskImage As Image = My.Resources.waitLKW
' e.Graphics.DrawImage(newImage, e.CellBounds.Left + 2, e.CellBounds.Top + 2, 26, 26)
Dim c As DataGridViewCell = r.Cells(0)
gridAnkunft.CreateGraphics.DrawImage(maskImage, c.ContentBounds.Left, c.ContentBounds.Top, 30, 30)
' e.Handled = True
Else
'e.Handled = False
End If
Next
End If
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
initZeilenWerte()
lblZeit.Text = Format(Now, "dd.MM. HH:mm:ss")
lblZeit.Refresh()
If DateDiff(DateInterval.Second, hMerkZeit, Now) > Sekunden Then 'aktualisieren alle xx Sekunden
If Not grpTestAnzeige.Visible Then
If Cursor.Position = cptmp Then
Cursor.Position = Me.PointToScreen(New Point(0, Me.Height))
End If
cptmp = Cursor.Position
End If
Listen_ermitteln()
hMerkZeit = Now
' MsgBox("now")
If (lblZeile1.Text & lblZeile1.Text).Trim = String.Empty Then displayZeilen = False : 'wenn alles leer
If displayZeilenBIG Then
lblBigInfo.Visible = True
lblBigInfo2.Visible = True
lblZeile1.Visible = False
lblZeile2.Visible = False
Else
lblBigInfo.Visible = False
lblBigInfo2.Visible = False
If displayZeilen Then
lblZeile1.Visible = Not lblZeile1.Visible
lblZeile2.Visible = Not lblZeile2.Visible
Else
lblZeile1.Visible = False
lblZeile2.Visible = False
End If
End If
End If
End Sub
Private Sub gridAnkunft_DoubleClick(sender As Object, e As System.EventArgs) Handles gridAnkunft.DoubleClick
txtBreite.Text = Me.Width.ToString
txtHöhe.Text = Me.Height.ToString
grpTestAnzeige.Visible = True
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
grpTestAnzeige.Visible = False
Cursor.Position = Me.PointToScreen(New Point(Me.Width, Me.Height))
End Sub
Sub initSettings()
initZeilen()
picVERAG.Height = lblZeile1.Height
Select Case Standort
Case "ATILLA" : picVERAG.Image = My.Resources.Atilla 'Atilla such su
Case "IMEX" : picVERAG.Image = My.Resources.IMEX_LOGO_simple
Case "UNISPED" : picVERAG.Image = My.Resources.Unisped_logo
Case "AMBAR" : picVERAG.Image = My.Resources.Ambar_Logo : picVERAG.Height = Panel2.Height
Case "FRONTOFFICE" : picVERAG.Image = My.Resources.FrontOfficeSUB
Case Else : picVERAG.Image = My.Resources.Verag_AG_Logopng
End Select
If StandortATILLA Then picVERAG.Image = My.Resources.Atilla
'If StandortATILLA Then
' picVERAG.Image = My.Resources.Atilla
'Else
' picVERAG.Image = My.Resources.Verag_AG_Logopng
'End If
gridFertig.Visible = cbxGridLKWOK.Checked
If txtBreite.Text <> "" Then
If VarToInt(txtBreite.Text) < 800 Then
MsgBox("Breite ist zu klein - mind. 800")
txtBreite.Focus()
Exit Sub
End If
Me.Width = VarToInt(txtBreite.Text)
End If
If txtHöhe.Text <> "" Then
If VarToInt(txtHöhe.Text) < 600 Then
MsgBox("Höhe ist zu klein - mind. 600")
txtHöhe.Focus()
Exit Sub
End If
Me.Height = VarToInt(txtHöhe.Text)
End If
If txtSchrift1.Text <> "" Then
If VarToInt(txtSchrift1.Text) < 10 Then
MsgBox("Schrift1 ist zu klein - mind. 10")
txtSchrift1.Focus()
Exit Sub
End If
Font1 = New Font(FontFamily.GenericSansSerif, VarToInt(txtSchrift1.Text), FontStyle.Bold)
End If
If txtSchrift1_MESS.Text <> "" Then
If VarToInt(txtSchrift1_MESS.Text) < 10 Then
MsgBox("Schrift1 ist zu klein - mind. 10")
txtSchrift1_MESS.Focus()
Exit Sub
End If
Font1_MESS = New Font(FontFamily.GenericSansSerif, VarToInt(txtSchrift1_MESS.Text), FontStyle.Bold)
End If
If txtSchrift2.Text <> "" Then
If VarToInt(txtSchrift2.Text) < 10 Then
MsgBox("Schrift2 ist zu klein - mind. 10")
txtSchrift2.Focus()
Exit Sub
End If
Font2 = New Font(FontFamily.GenericSansSerif, VarToInt(txtSchrift2.Text), FontStyle.Bold)
End If
If txtSchrift3.Text <> "" Then
If VarToInt(txtSchrift3.Text) < 10 Then
MsgBox("Schrift3 ist zu klein - mind. 10")
txtSchrift3.Focus()
Exit Sub
End If
Font3 = New Font(FontFamily.GenericSansSerif, VarToInt(txtSchrift3.Text), FontStyle.Bold)
End If
If txtLkwOK_LKWNrSchrift.Text <> "" Then
If VarToInt(txtLkwOK_LKWNrSchrift.Text) < 10 Then
MsgBox("txtLkwOK_LKWNrSchrift ist zu klein - mind. 10")
txtLkwOK_LKWNrSchrift.Focus()
Exit Sub
End If
Font_LkwOK_LKWNr = New Font(FontFamily.GenericSansSerif, VarToInt(txtLkwOK_LKWNrSchrift.Text), FontStyle.Bold)
End If
If txtSekunden.Text <> "" Then
If VarToInt(txtSekunden.Text) < 10 Then
MsgBox("Resfresh unter 10 Sekunden ist nicht erlaubt.")
txtSekunden.Focus()
Exit Sub
End If
End If
If txtSchrift4.Text <> "" Then Font4 = New Font(FontFamily.GenericSansSerif, VarToInt(txtSchrift4.Text), FontStyle.Bold)
If txtSchrift5.Text <> "" Then Font5 = New Font(FontFamily.GenericSansSerif, VarToInt(txtSchrift5.Text), FontStyle.Bold)
If txtSchrift6.Text <> "" Then Font6 = New Font(FontFamily.GenericSansSerif, VarToInt(txtSchrift6.Text), FontStyle.Bold)
If txtSchrift7.Text <> "" Then Font7 = New Font(FontFamily.GenericSansSerif, VarToInt(txtSchrift7.Text), FontStyle.Bold)
If txtSchrift8.Text <> "" Then Font8 = New Font(FontFamily.GenericSansSerif, VarToInt(txtSchrift8.Text), FontStyle.Bold)
gridAnkunft.Columns(0).DefaultCellStyle.Font = Font1
gridAnkunft.Columns(1).DefaultCellStyle.Font = Font2
gridAnkunft.Columns(2).DefaultCellStyle.Font = Font3
gridAnkunft.Columns(3).DefaultCellStyle.Font = Font4
gridAnkunft.Columns(4).DefaultCellStyle.Font = Font5
gridFertig.Columns(1).DefaultCellStyle.Font = Font_LkwOK_LKWNr
gridFertig.Columns(1).Visible = True
If StandortATILLA And gridAnkunft.Columns("clmnBuero") IsNot Nothing Then
gridAnkunft.Columns("clmnBuero").Width = CInt(IIf(IsNumeric(txtBreite6.Text), txtBreite6.Text, 50))
gridAnkunft.Columns("clmnBuero").DefaultCellStyle.Font = Font6
gridAnkunft.Columns("clmnBuero").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
End If
If (Standort = "WAI" Or Standort.Replace("AMBAR", "AMB") = "AMB") And gridAnkunft.Columns("clmnImEx") IsNot Nothing Then
' MsgBox(IIf(IsNumeric(txtBreite7.Text), txtBreite7.Text, 30))
gridAnkunft.Columns("clmnImEx").Width = CInt(IIf(IsNumeric(txtBreite7.Text), txtBreite7.Text, 50))
gridAnkunft.Columns("clmnImEx").DefaultCellStyle.Font = Font7
gridAnkunft.Columns("clmnImEx").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
End If
gridAnkunft.Columns("clmnArt").Width = CInt(IIf(IsNumeric(txtBreite8.Text), txtBreite8.Text, 50))
gridAnkunft.Columns("clmnArt").DefaultCellStyle.Font = Font8
gridAnkunft.Columns("clmnArt").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
If CInt(IIf(IsNumeric(txtBreite8.Text), txtBreite8.Text, 0)) = 0 Then
gridAnkunft.Columns("clmnArt").Visible = False
Else
gridAnkunft.Columns("clmnArt").Visible = True
End If
If txtBreite2.Text <> "" Then gridAnkunft.Columns(1).MinimumWidth = 10 'Default, weil minwisth später gesetzt werden kann
If txtBreite1.Text <> "" Then gridAnkunft.Columns(0).Width = CInt(txtBreite1.Text)
If txtBreite2.Text <> "" Then gridAnkunft.Columns(1).Width = CInt(txtBreite2.Text)
If txtBreite3.Text <> "" Then gridAnkunft.Columns(2).Width = CInt(txtBreite3.Text)
If txtBreite4.Text <> "" Then gridAnkunft.Columns(3).Width = CInt(txtBreite4.Text)
If cbxBearbeiter.Checked Then
gridAnkunft.Columns(4).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
Else
gridAnkunft.Columns(4).Width = 0
If txtBreite2.Text <> "" Then gridAnkunft.Columns(1).MinimumWidth = CInt(txtBreite2.Text)
gridAnkunft.Columns(2).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
End If
If txtLkwOK_BildBreite.Text <> "" Then gridFertig.Columns(0).Width = CInt(txtLkwOK_BildBreite.Text)
If txtBreiteGridLKWOK.Text <> "" Then gridFertig.Width = CInt(txtBreiteGridLKWOK.Text)
'gridAnkunft.Columns(4).Width = Me.Width - gridAnkunft.Columns(0).Width - gridAnkunft.Columns(1).Width - gridAnkunft.Columns(2).Width - gridAnkunft.Columns(3).Width - 20
'txtBreite5.Text = gridAnkunft.Columns(4).Width.ToString
If txtSekunden.Text <> "" Then
Sekunden = VarToInt(txtSekunden.Text.Trim)
If Sekunden < 10 Then Sekunden = 10
End If
savesettings()
End Sub
Sub initZeilen()
initZeilenWerte()
'MsgBox(ZeilenStandard)
Aktive_Seite = 0
Merk_Ankunftsdatum = LeerDatum
Listen_ermitteln()
End Sub
Sub initZeilenWerte()
If gridAnkunft.RowCount > 0 Then
ZeilenStandard = CInt(gridAnkunft.Height / gridAnkunft.Rows(0).Cells(0).Size.Height) - 1
Else
ZeilenStandard = 8
End If
Max_Zeilen = ZeilenStandard
End Sub
Private Sub btnTestAnzeige_Click(sender As System.Object, e As System.EventArgs) Handles btnTestAnzeige.Click
isloaded = False
initSettings()
grpTestAnzeige.Visible = False
End Sub
Private Sub btnTestSystem_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
TESTSYSTEM = Not TESTSYSTEM
frmAnzeige_Load(Me, New EventArgs)
End Sub
Sub loadsettings()
For Each c In grpTestAnzeige.Controls
If c.GetType.Name = "TextBox" Then
Dim p As String = getProperty(DirectCast(c, TextBox).Name)
If p <> "" Then DirectCast(c, TextBox).Text = p
End If
If c.GetType.Name = "CheckBox" Then
Dim p As String = getProperty(DirectCast(c, CheckBox).Name)
If p <> "" Then DirectCast(c, CheckBox).Checked = CBool(p)
End If
Next
End Sub
Sub savesettings()
If txtBreite.Text <> "" Then setProperty("txtBreite", txtBreite.Text)
If txtHöhe.Text <> "" Then setProperty("txtHöhe", txtHöhe.Text)
If txtSchrift1.Text <> "" Then setProperty("txtSchrift1", txtSchrift1.Text)
If txtSchrift1_MESS.Text <> "" Then setProperty("txtSchrift1_MESS", txtSchrift1_MESS.Text)
If txtSchrift2.Text <> "" Then setProperty("txtSchrift2", txtSchrift2.Text)
If txtSchrift3.Text <> "" Then setProperty("txtSchrift3", txtSchrift3.Text)
If txtSchrift4.Text <> "" Then setProperty("txtSchrift4", txtSchrift4.Text)
If txtSchrift5.Text <> "" Then setProperty("txtSchrift5", txtSchrift5.Text)
If txtSchrift6.Text <> "" Then setProperty("txtSchrift6", txtSchrift6.Text)
If txtSchrift7.Text <> "" Then setProperty("txtSchrift7", txtSchrift7.Text)
If txtSchrift8.Text <> "" Then setProperty("txtSchrift8", txtSchrift8.Text)
If txtBreite1.Text <> "" Then setProperty("txtBreite1", txtBreite1.Text)
If txtBreite2.Text <> "" Then setProperty("txtBreite2", txtBreite2.Text)
If txtBreite3.Text <> "" Then setProperty("txtBreite3", txtBreite3.Text)
If txtBreite4.Text <> "" Then setProperty("txtBreite4", txtBreite4.Text)
If txtBreite5.Text <> "" Then setProperty("txtBreite5", txtBreite5.Text)
If txtBreite6.Text <> "" Then setProperty("txtBreite6", txtBreite6.Text)
If txtBreite7.Text <> "" Then setProperty("txtBreite7", txtBreite7.Text)
If txtBreite8.Text <> "" Then setProperty("txtBreite8", txtBreite8.Text)
If txtSekunden.Text <> "" Then setProperty("txtSekunden", txtSekunden.Text)
If txtLkwOK_LKWNrSchrift.Text <> "" Then setProperty("txtLkwOK_LKWNrSchrift", txtLkwOK_LKWNrSchrift.Text)
If txtLkwOK_BildBreite.Text <> "" Then setProperty("txtLkwOK_BildBreite", txtLkwOK_BildBreite.Text)
If txtBreiteGridLKWOK.Text <> "" Then setProperty("txtBreiteGridLKWOK", txtBreiteGridLKWOK.Text)
setProperty("cbxGridLKWOK", CInt(cbxGridLKWOK.Checked).ToString)
setProperty("cbxBearbeiter", CInt(cbxBearbeiter.Checked).ToString)
End Sub
Private Sub lblSeite_Click(sender As Object, e As EventArgs) Handles lblSeite.Click
Listen_ermitteln()
End Sub
Private Sub gridAnkunft_Paint(sender As Object, e As PaintEventArgs) Handles gridAnkunft.Paint
If Not isloaded Then initZeilen() : isloaded = True
End Sub
Private Sub frmAnzeige_Shown(sender As Object, e As EventArgs) Handles Me.Shown
gridAnkunft.ClearSelection()
End Sub
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboFirma.SelectedIndexChanged
Standort = cboFirma.Text
cDatenbankAVISO.GlobalConnection = Nothing
' Dim fs As New FileStream(StandortDatei, FileMode.Open, FileAccess.Write)
Dim strmWriter As New StreamWriter(StandortDatei, False)
strmWriter.WriteLine(cboFirma.Text)
strmWriter.Close() ' fs.Close()
frmAnzeige_Load(Me, New EventArgs)
grpTestAnzeige.Visible = False
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub txtBreite1_KeyUp(sender As Object, e As KeyEventArgs) Handles txtSchrift1_MESS.KeyUp, txtSekunden.KeyUp,
txtSchrift1.KeyUp, txtSchrift2.KeyUp, txtSchrift3.KeyUp, txtSchrift4.KeyUp, txtSchrift5.KeyUp, txtSchrift6.KeyUp, txtSchrift7.KeyUp, txtSchrift8.KeyUp,
txtBreite1.KeyUp, txtBreite2.KeyUp, txtBreite3.KeyUp, txtBreite4.KeyUp, txtBreite5.KeyUp, txtBreite6.KeyUp, txtBreite7.KeyUp, txtBreite8.KeyUp,
txtLkwOK_BildBreite.KeyUp, txtLkwOK_LKWNrSchrift.KeyUp, txtBreiteGridLKWOK.KeyUp
If e.KeyCode = Keys.Return Then
btnTestAnzeige.PerformClick()
e.Handled = True
e.SuppressKeyPress = True
End If
End Sub
Dim secondmonitorSelected As Boolean = False
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim secondaryMonitor = Screen.AllScreens.FirstOrDefault(Function(x) Not x.Primary)
If secondmonitorSelected Then
secondaryMonitor = Screen.AllScreens.FirstOrDefault(Function(x) x.Primary) 'Hauptbildschirm
End If
If secondaryMonitor IsNot Nothing Then
Me.WindowState = FormWindowState.Normal
Dim newLocation = secondaryMonitor.Bounds.Location
newLocation.Offset(0, 0) ' adjust as needed
Me.Location = newLocation
Me.Refresh()
Me.WindowState = FormWindowState.Maximized
' Also see Me.Size and Me.Bounds
End If
secondmonitorSelected = Not secondmonitorSelected
End Sub
Private Sub gridFertig_SelectionChanged(sender As Object, e As EventArgs) Handles gridFertig.SelectionChanged
gridFertig.ClearSelection()
End Sub
End Class
Public Class cUserSettings
Shared settings As New List(Of cListUserSettings)
Public Shared Sub setProperty(ByVal name As String, ByVal value As String)
settings = New List(Of cListUserSettings)
loadPropertys()
setNewProperty(name, value)
writesettings()
End Sub
Public Shared Function getProperty(ByVal name As String) As String
settings = New List(Of cListUserSettings)
loadPropertys()
For Each a In settings
If a.name = name Then Return a.value
Next
Return ""
End Function
Shared Sub setNewProperty(ByVal name As String, ByVal value As String)
For Each a In settings
If a.name = name Then
a.value = value
Exit Sub
End If
Next
'settings.Add(New Dictionary(name, value))
settings.Add(New cListUserSettings(name, value))
End Sub
Shared Sub loadPropertys()
Try
Using sr As New StreamReader(AppDomain.CurrentDomain.BaseDirectory & "settings.txt")
Dim line As String = ""
Do While sr.Peek() >= 0
line = CStr(sr.ReadLine())
If line.Contains(Chr(29)) Then
Dim s = line.Split(Chr(29)) 'nach GroupSeperator splitten
'If s(0) = name Then Return True
settings.Add(New cListUserSettings(s(0), s(1)))
End If
Loop
End Using
Catch ex As Exception
' MsgBox("FEHLER beim Einlesen der UserSettings.")
End Try
End Sub
Shared Sub writesettings()
Try
Using sr As New StreamWriter(AppDomain.CurrentDomain.BaseDirectory & "settings.txt", False)
For Each a In settings
sr.WriteLine(a.name & Chr(29) & a.value)
Next
End Using
Catch ex As Exception
End Try
End Sub
End Class
Public Class cListUserSettings
Property name As String
Property value As String
Sub New(ByVal n As String, v As String)
name = n
value = v
End Sub
End Class