Imports Gemeinsames Imports VERAG_PROG_ALLGEMEIN Public Class usrctStatistik Dim SQL As New Statistik Dim cProgramFunctions As New cProgramFunctions Dim year As Integer = Now.Year Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click lblWartezeit.Text = CStr(SQL.getAVG(CDate(datStatVon.Value.ToShortDateString), CDate(datStatBis.Value.ToShortDateString), txtMin.Text, txtMax.Text)) & " min" End Sub Private Sub usrctStatistik_Load(sender As Object, e As EventArgs) Handles MyBase.Load datStatVon.Format = DateTimePickerFormat.Short datStatBis.Format = DateTimePickerFormat.Short ' Button2.PerformClick() cboArt.SelectedIndex = 0 End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim g As Graphics = Panel1.CreateGraphics g.Clear(Color.FromArgb(245, 245, 245)) Dim p As Panel = Panel1 'DirectCast(sender, Panel) 'Jahre: Dim topbound = 10 For i = 2013 To Now.Year Dim b As New Button b.Left = p.Width - 100 b.Width = 90 b.Top = topbound topbound += 25 b.Text = CStr(i) p.Controls.Add(b) b.FlatStyle = FlatStyle.Flat AddHandler b.Click, AddressOf changeYear Next ' End Sub ' ' Private Sub initJahresDurchschnitt(sender As Object, e As PaintEventArgs) 'Dim g As Graphics = e.Graphics ' g.Clear(Color.FromArgb(230, 230, 230)) ' Dim p As Panel = DirectCast(sender, Panel) Dim y0 As Integer = 0 Dim x0 As Integer = 0 Dim yMax As Integer = p.Height - 50 Dim xMax As Integer = p.Width Dim h As Integer = p.Height Dim w As Integer = p.Width 'Koordinatensystem von links unten: ' e.Graphics.ScaleTransform(1.0F, -1.0F) ' e.Graphics.TranslateTransform(0, -p.ClientRectangle.Height) ' g.FillRectangle(Brushes.Red, CoordRectangle(w, h, 50, 50, 10, 10)) 'Dim s(10, 2) As String 'Dim s As String()() Dim s(12, 2) As String For i = 0 To 11 Dim d As New Date(year, i + 1, 1) s(i, 0) = d.ToString("MMM") s(i, 1) = CStr(SQL.getAVG(d, d.AddMonths(1).AddDays(-1), txtAuswJahrDauerVon.Text, txtAuswJahrDauerBis.Text)) ' MsgBox(s(i, 0) & " - " & s(i, 1)) Next Dim sMax As Long = getMax(s) Dim xLeftBound As Integer = 0 For i = 0 To s.GetUpperBound(0) - 1 Dim hoehe = 0 If sMax > 0 Then hoehe = CInt(yMax * (CLng(s(i, 1)) * 100 / sMax) / 100) ' MsgBox(hoehe) ' g.FillRectangle(Brushes.Red, New Rectangle(x0 + xLeftBound, y0, 20, hoehe)) g.FillRectangle(Brushes.Red, CoordRectangle(w, h, x0 + xLeftBound, y0 + 20, 20, hoehe)) g.DrawString(CInt(s(i, 1)).ToString, p.Font, Brushes.Black, CoordPoint(h, x0 + xLeftBound, 20 + hoehe + 15)) g.DrawString(CStr(s(i, 0)).ToString, p.Font, Brushes.Black, CoordPoint(h, x0 + xLeftBound, 15)) xLeftBound += 30 Next End Sub Sub changeYear(sender As Object, e As EventArgs) year = CInt(DirectCast(sender, Button).Text) ' Panel1_Paint(Panel1, New PaintEventArgs(Panel1.CreateGraphics, Panel1.ClientRectangle)) End Sub Function CoordRectangle(w As Integer, h As Integer, x0 As Integer, y0 As Integer, x As Integer, y As Integer) As Rectangle ' MsgBox(" x0: " & x0 & " y0: " & CStr(h - y0 - y) & " x: " & x & " y: " & y) Return New Rectangle(x0, h - y0 - y, x, y) End Function Function CoordPoint(h As Integer, x As Integer, y As Integer) As Point Return New Point(x, h - y) End Function Private Sub txtAuswJahrDauer_TextChanged(sender As Object, e As EventArgs) ' Panel1_Paint(Panel1, New PaintEventArgs(Panel1.CreateGraphics, Panel1.ClientRectangle)) End Sub Private Sub AuswertungWoToag(sender As Object, e As EventArgs) Handles Button11.Click ', cboTag.SelectedIndexChanged Dim s(17, 2) As String Dim t As String = Button11.Text Dim datVon As Date = CDate(txtdatVon.Value) Dim datBis As Date = CDate(txtdatBis.Value) Dim TESTgesLKWs = 0 Dim TESTgesLKWs2 = 0 Dim SQLstat As New StatDB Dim c As Integer = 0 Dim art = "" If cboArt.SelectedIndex = 0 Then art = "Ankunft" If cboArt.SelectedIndex = 1 Then art = "Freigabe" If cboArt.SelectedIndex = 2 Then art = "AvisoEingang" For i = 6 To 22 Dim cnt As Integer = 0 Dim gesLKWs As Integer = 0 Dim datTmp As Date = datVon While datTmp <= datBis If datTmp.DayOfWeek = cboTag.SelectedIndex Then Dim Firma = "" Dim Cluster="" If cboFirma.Text = "FRONTOFFICE" Then Cluster = cboFirma.Text Else Firma = cboFirma.Text End If gesLKWs += SQLstat.getAnzahlLkwAnkunft(art, datTmp, i, Firma, Cluster) cnt += 1 End If datTmp = datTmp.AddDays(1) End While s(c, 0) = i & ":00" If gesLKWs > 0 And cnt > 0 Then s(c, 1) = CStr(CInt(gesLKWs / cnt)) Else s(c, 1) = CStr(0) End If c += 1 Next StatAuswertungWoToag(s) Button11.Text = t End Sub Private Sub StatAuswertungWoToag(s(,) As String) 'Handles Panel1.Paint Dim g As Graphics = Panel5.CreateGraphics g.Clear(Color.FromArgb(245, 245, 245)) Dim p As Panel = Panel5 'Jahre: Dim topbound = 10 Dim y0 As Integer = 0 Dim x0 As Integer = 0 Dim yMax As Integer = p.Height - 50 Dim xMax As Integer = p.Width Dim h As Integer = p.Height Dim w As Integer = p.Width ' MsgBox(s(i, 0) & " - " & s(i, 1)) Dim sMax As Long = getMax(s) Dim xLeftBound As Integer = 0 For i = 0 To s.GetUpperBound(0) - 1 Dim hoehe = 0 If sMax > 0 Then hoehe = CInt(yMax * (CLng(s(i, 1)) * 100 / sMax) / 100) ' MsgBox(hoehe) ' g.FillRectangle(Brushes.Red, New Rectangle(x0 + xLeftBound, y0, 20, hoehe)) g.FillRectangle(Brushes.Red, CoordRectangle(w, h, x0 + xLeftBound, y0 + 20, 20, hoehe)) g.DrawString(CInt(s(i, 1)).ToString, p.Font, Brushes.Black, CoordPoint(h, x0 + xLeftBound, 20 + hoehe + 15)) g.DrawString(CStr(s(i, 0)).ToString, p.Font, Brushes.Black, CoordPoint(h, x0 + xLeftBound, 15)) xLeftBound += 30 Next End Sub Function getMax(s(,) As String) As Long Dim max As Long = 0 For i = 0 To s.GetUpperBound(0) - 1 If CLng(s(i, 1)) > max Then max = CLng(s(i, 1)) End If Next Return max End Function Private Sub AuswertungWoToag2(sender As Object, e As EventArgs) Handles Button5.Click ', cboTag.SelectedIndexChanged 'Exit Sub Dim s(7, 2) As String Dim s_Weekdays() As String = {"SO", "MO", "DI", "MI", "DO", "FR", "SA"} Dim t As String = Button5.Text Dim datVon As Date = CDate(DateTimePicker1.Value) Dim datBis As Date = CDate(DateTimePicker2.Value) Dim TESTgesLKWs = 0 Dim TESTgesLKWs2 = 0 Dim SQLstat As New StatDB ' Dim c As Integer = 0 Dim art = "" If ComboBox1.SelectedIndex = 0 Then art = "Ankunft" If ComboBox1.SelectedIndex = 1 Then art = "Freigabe" 'If ComboBox1.SelectedIndex = 2 Then art = "Erfasst" 'asdasdasd If ComboBox1.SelectedIndex = 2 Then art = "AvisoEingang" 'asdasdasd For i = 1 To 7 Dim c = CInt(i.ToString.Replace("7", "0")) 'Sonntag Dim cnt As Integer = 0 Dim gesLKWs As Integer = 0 Dim datTmp As Date = datVon While datTmp <= datBis If datTmp.DayOfWeek = i Then gesLKWs += SQLstat.getAnzahlLkwAnkunft(art, datTmp, cboFirma2.Text) cnt += 1 End If datTmp = datTmp.AddDays(1) End While s((i - 1), 0) = s_Weekdays(c) If gesLKWs > 0 And cnt > 0 Then s((i - 1), 1) = CStr(CInt(gesLKWs / cnt)) Else s((i - 1), 1) = CStr(0) End If ' c += 1 Next StatAuswertungWo(s) Button5.Text = t End Sub Private Sub StatAuswertungWo(s(,) As String) 'Handles Panel1.Paint Dim g As Graphics = Panel8.CreateGraphics g.Clear(Color.FromArgb(245, 245, 245)) Dim p As Panel = Panel8 'Jahre: Dim topbound = 10 Dim y0 As Integer = 0 Dim x0 As Integer = 0 Dim yMax As Integer = p.Height - 50 Dim xMax As Integer = p.Width Dim h As Integer = p.Height Dim w As Integer = p.Width ' MsgBox(s(i, 0) & " - " & s(i, 1)) Dim sMax As Long = getMax(s) Dim xLeftBound As Integer = 0 For i = 0 To s.GetUpperBound(0) - 1 Dim hoehe = 0 If sMax > 0 Then hoehe = CInt(yMax * (CLng(s(i, 1)) * 100 / sMax) / 100) ' MsgBox(hoehe) ' g.FillRectangle(Brushes.Red, New Rectangle(x0 + xLeftBound, y0, 20, hoehe)) g.FillRectangle(Brushes.Red, CoordRectangle(w, h, x0 + xLeftBound, y0 + 20, 20, hoehe)) g.DrawString(CInt(s(i, 1)).ToString, p.Font, Brushes.Black, CoordPoint(h, x0 + xLeftBound, 20 + hoehe + 15)) g.DrawString(CStr(s(i, 0)).ToString, p.Font, Brushes.Black, CoordPoint(h, x0 + xLeftBound, 15)) xLeftBound += 60 Next End Sub Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click Dim i As Image = cProgramFunctions.TakeScreenShot(Panel5) If Not My.Computer.FileSystem.DirectoryExists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\STAT\") Then My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.SpecialDirectories.Desktop & "\STAT\") End If Dim s As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\STAT\Stat_" & cboTag.Text & "_" & txtdatVon.Value.ToShortDateString & "_" & txtdatBis.Value.ToShortDateString & " .png" i.Save(s, Drawing.Imaging.ImageFormat.Png) End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Dim i As Image = cProgramFunctions.TakeScreenShot(Panel1) If Not My.Computer.FileSystem.DirectoryExists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\STAT\") Then My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.SpecialDirectories.Desktop & "\STAT\") End If Dim s As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\STAT\Stat_" & cboTag.Text & "_" & txtdatVon.Value.ToShortDateString & "_" & txtdatBis.Value.ToShortDateString & " .png" i.Save(s, Drawing.Imaging.ImageFormat.Png) End Sub End Class