div. Plausibilitätsprüfungen

This commit is contained in:
2026-01-30 09:06:59 +01:00
parent d45a046258
commit f8e20b5f60
2 changed files with 308 additions and 1 deletions

View File

@@ -25,6 +25,16 @@ Partial Class usrCntlBH
Me.Label6 = New System.Windows.Forms.Label()
Me.pnl = New System.Windows.Forms.Panel()
Me.TabPage1 = New System.Windows.Forms.TabPage()
Me.GroupBox13 = New System.Windows.Forms.GroupBox()
Me.btnfortlRENr = New System.Windows.Forms.Button()
Me.btnfehlendeBelege = New System.Windows.Forms.Button()
Me.btnBelegeOhnePOS = New System.Windows.Forms.Button()
Me.txtRE_Jahr = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.Label59 = New System.Windows.Forms.Label()
Me.txtRE_Monat = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.cbxFirma_RE = New VERAG_PROG_ALLGEMEIN.MyComboBox()
Me.Label60 = New System.Windows.Forms.Label()
Me.Label58 = New System.Windows.Forms.Label()
Me.btn_fehlendeUID = New System.Windows.Forms.Button()
Me.lblUID_zupruefen = New System.Windows.Forms.Label()
Me.Label53 = New System.Windows.Forms.Label()
@@ -166,6 +176,7 @@ Partial Class usrCntlBH
Me.Label51 = New System.Windows.Forms.Label()
Me.pnl.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.GroupBox13.SuspendLayout()
Me.GroupBox12.SuspendLayout()
Me.GroupBox10.SuspendLayout()
Me.GroupBox8.SuspendLayout()
@@ -209,6 +220,8 @@ Partial Class usrCntlBH
'TabPage1
'
Me.TabPage1.AutoScroll = True
Me.TabPage1.Controls.Add(Me.GroupBox13)
Me.TabPage1.Controls.Add(Me.Label58)
Me.TabPage1.Controls.Add(Me.btn_fehlendeUID)
Me.TabPage1.Controls.Add(Me.lblUID_zupruefen)
Me.TabPage1.Controls.Add(Me.Label53)
@@ -236,6 +249,154 @@ Partial Class usrCntlBH
Me.TabPage1.Text = "Allgemein"
Me.TabPage1.UseVisualStyleBackColor = True
'
'GroupBox13
'
Me.GroupBox13.Controls.Add(Me.btnfortlRENr)
Me.GroupBox13.Controls.Add(Me.btnfehlendeBelege)
Me.GroupBox13.Controls.Add(Me.btnBelegeOhnePOS)
Me.GroupBox13.Controls.Add(Me.txtRE_Jahr)
Me.GroupBox13.Controls.Add(Me.Label59)
Me.GroupBox13.Controls.Add(Me.txtRE_Monat)
Me.GroupBox13.Controls.Add(Me.cbxFirma_RE)
Me.GroupBox13.Controls.Add(Me.Label60)
Me.GroupBox13.Location = New System.Drawing.Point(480, 21)
Me.GroupBox13.Name = "GroupBox13"
Me.GroupBox13.Size = New System.Drawing.Size(372, 79)
Me.GroupBox13.TabIndex = 39
Me.GroupBox13.TabStop = False
'
'btnfortlRENr
'
Me.btnfortlRENr.Enabled = False
Me.btnfortlRENr.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnfortlRENr.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(54, Byte), Integer), CType(CType(128, Byte), Integer))
Me.btnfortlRENr.Image = Global.SDL.My.Resources.Resources.Excel_logo
Me.btnfortlRENr.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.btnfortlRENr.Location = New System.Drawing.Point(236, 56)
Me.btnfortlRENr.Name = "btnfortlRENr"
Me.btnfortlRENr.Size = New System.Drawing.Size(130, 22)
Me.btnfortlRENr.TabIndex = 42
Me.btnfortlRENr.Text = "ReNr fortl."
Me.btnfortlRENr.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.btnfortlRENr.UseVisualStyleBackColor = True
'
'btnfehlendeBelege
'
Me.btnfehlendeBelege.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnfehlendeBelege.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(54, Byte), Integer), CType(CType(128, Byte), Integer))
Me.btnfehlendeBelege.Image = Global.SDL.My.Resources.Resources.Excel_logo
Me.btnfehlendeBelege.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.btnfehlendeBelege.Location = New System.Drawing.Point(236, 32)
Me.btnfehlendeBelege.Name = "btnfehlendeBelege"
Me.btnfehlendeBelege.Size = New System.Drawing.Size(130, 22)
Me.btnfehlendeBelege.TabIndex = 41
Me.btnfehlendeBelege.Text = "fehlende Belege"
Me.btnfehlendeBelege.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.btnfehlendeBelege.UseVisualStyleBackColor = True
'
'btnBelegeOhnePOS
'
Me.btnBelegeOhnePOS.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnBelegeOhnePOS.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(54, Byte), Integer), CType(CType(128, Byte), Integer))
Me.btnBelegeOhnePOS.Image = Global.SDL.My.Resources.Resources.Excel_logo
Me.btnBelegeOhnePOS.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.btnBelegeOhnePOS.Location = New System.Drawing.Point(236, 8)
Me.btnBelegeOhnePOS.Name = "btnBelegeOhnePOS"
Me.btnBelegeOhnePOS.Size = New System.Drawing.Size(130, 22)
Me.btnBelegeOhnePOS.TabIndex = 40
Me.btnBelegeOhnePOS.Text = "Belege ohne POS"
Me.btnBelegeOhnePOS.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.btnBelegeOhnePOS.UseVisualStyleBackColor = True
'
'txtRE_Jahr
'
Me.txtRE_Jahr._DateTimeOnly = False
Me.txtRE_Jahr._numbersOnly = True
Me.txtRE_Jahr._numbersOnlyKommastellen = ""
Me.txtRE_Jahr._numbersOnlyTrennzeichen = False
Me.txtRE_Jahr._Prozent = False
Me.txtRE_Jahr._ShortDateNew = False
Me.txtRE_Jahr._ShortDateOnly = False
Me.txtRE_Jahr._TimeOnly = False
Me.txtRE_Jahr._TimeOnly_Seconds = False
Me.txtRE_Jahr._value = ""
Me.txtRE_Jahr._Waehrung = False
Me.txtRE_Jahr._WaehrungZeichen = False
Me.txtRE_Jahr.ForeColor = System.Drawing.Color.Black
Me.txtRE_Jahr.Location = New System.Drawing.Point(108, 13)
Me.txtRE_Jahr.MaxLength = 4
Me.txtRE_Jahr.MaxLineLength = -1
Me.txtRE_Jahr.MaxLines_Warning = ""
Me.txtRE_Jahr.MaxLines_Warning_Label = Nothing
Me.txtRE_Jahr.Name = "txtRE_Jahr"
Me.txtRE_Jahr.Size = New System.Drawing.Size(64, 20)
Me.txtRE_Jahr.TabIndex = 39
Me.txtRE_Jahr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'Label59
'
Me.Label59.AutoSize = True
Me.Label59.Location = New System.Drawing.Point(6, 16)
Me.Label59.Name = "Label59"
Me.Label59.Size = New System.Drawing.Size(62, 13)
Me.Label59.TabIndex = 38
Me.Label59.Text = "Monat/Jahr"
'
'txtRE_Monat
'
Me.txtRE_Monat._DateTimeOnly = False
Me.txtRE_Monat._numbersOnly = True
Me.txtRE_Monat._numbersOnlyKommastellen = ""
Me.txtRE_Monat._numbersOnlyTrennzeichen = False
Me.txtRE_Monat._Prozent = False
Me.txtRE_Monat._ShortDateNew = False
Me.txtRE_Monat._ShortDateOnly = False
Me.txtRE_Monat._TimeOnly = False
Me.txtRE_Monat._TimeOnly_Seconds = False
Me.txtRE_Monat._value = ""
Me.txtRE_Monat._Waehrung = False
Me.txtRE_Monat._WaehrungZeichen = False
Me.txtRE_Monat.ForeColor = System.Drawing.Color.Black
Me.txtRE_Monat.Location = New System.Drawing.Point(74, 13)
Me.txtRE_Monat.MaxLength = 2
Me.txtRE_Monat.MaxLineLength = -1
Me.txtRE_Monat.MaxLines_Warning = ""
Me.txtRE_Monat.MaxLines_Warning_Label = Nothing
Me.txtRE_Monat.Name = "txtRE_Monat"
Me.txtRE_Monat.Size = New System.Drawing.Size(24, 20)
Me.txtRE_Monat.TabIndex = 35
Me.txtRE_Monat.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'cbxFirma_RE
'
Me.cbxFirma_RE._allowedValuesFreiText = Nothing
Me.cbxFirma_RE._allowFreiText = False
Me.cbxFirma_RE._value = ""
Me.cbxFirma_RE.FormattingEnabled = True
Me.cbxFirma_RE.Location = New System.Drawing.Point(47, 34)
Me.cbxFirma_RE.Name = "cbxFirma_RE"
Me.cbxFirma_RE.Size = New System.Drawing.Size(125, 21)
Me.cbxFirma_RE.TabIndex = 36
'
'Label60
'
Me.Label60.AutoSize = True
Me.Label60.Location = New System.Drawing.Point(6, 38)
Me.Label60.Name = "Label60"
Me.Label60.Size = New System.Drawing.Size(35, 13)
Me.Label60.TabIndex = 37
Me.Label60.Text = "Firma:"
'
'Label58
'
Me.Label58.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label58.ForeColor = System.Drawing.SystemColors.ControlDarkDark
Me.Label58.Location = New System.Drawing.Point(479, 3)
Me.Label58.Name = "Label58"
Me.Label58.Size = New System.Drawing.Size(298, 18)
Me.Label58.TabIndex = 38
Me.Label58.Text = "BELEGE PRÜFEN"
'
'btn_fehlendeUID
'
Me.btn_fehlendeUID.FlatStyle = System.Windows.Forms.FlatStyle.Flat
@@ -714,7 +875,7 @@ Partial Class usrCntlBH
Me.GroupBox2.Controls.Add(Me.Button1)
Me.GroupBox2.Location = New System.Drawing.Point(6, 15)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(847, 86)
Me.GroupBox2.Size = New System.Drawing.Size(461, 86)
Me.GroupBox2.TabIndex = 4
Me.GroupBox2.TabStop = False
'
@@ -2103,6 +2264,8 @@ Partial Class usrCntlBH
Me.pnl.PerformLayout()
Me.TabPage1.ResumeLayout(False)
Me.TabPage1.PerformLayout()
Me.GroupBox13.ResumeLayout(False)
Me.GroupBox13.PerformLayout()
Me.GroupBox12.ResumeLayout(False)
Me.GroupBox12.PerformLayout()
Me.GroupBox10.ResumeLayout(False)
@@ -2282,4 +2445,14 @@ Partial Class usrCntlBH
Friend WithEvents txtZRvon As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents txtZRbis As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents Label51 As Label
Friend WithEvents GroupBox13 As GroupBox
Friend WithEvents btnfehlendeBelege As Button
Friend WithEvents btnBelegeOhnePOS As Button
Friend WithEvents txtRE_Jahr As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents Label59 As Label
Friend WithEvents txtRE_Monat As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents cbxFirma_RE As VERAG_PROG_ALLGEMEIN.MyComboBox
Friend WithEvents Label60 As Label
Friend WithEvents Label58 As Label
Friend WithEvents btnfortlRENr As Button
End Class

View File

@@ -29,6 +29,11 @@ Public Class usrCntlBH
cboAbfVerbFirma.fillWithSQL("SELECT distinct([Firma]) FROM [VERAG].[dbo].[Filialen] order by [Firma]", False, "FMZOLL", True)
cboAbfVerbFirma.changeItem(VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA)
cbxFirma_RE.fillWithSQL("SELECT Firma_ID, Firma_Bez FROM [VERAG].[dbo].[tblFirma] where Firmengruppe in ('VERAG', 'AMBAR', 'VERAG360', 'ATILLA')", False, "FMZOLL", True)
txtRE_Jahr.Text = Now().Year
txtRE_Monat.Text = Now().Month
cbxFirmaUID.Items.Add(New MyListItem("AMBAR", "AMBAR"))
cbxFirmaUID.Items.Add(New MyListItem("IMEX", "IMEX"))
cbxFirmaUID.Items.Add(New MyListItem("ATILLA", "ATILLA"))
@@ -1452,5 +1457,134 @@ Public Class usrCntlBH
End If
End Sub
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles btnBelegeOhnePOS.Click, btnfehlendeBelege.Click, btnfortlRENr.Click
Try
If txtRE_Jahr.Text <> "" AndAlso IsNumeric(txtRE_Jahr.Text) AndAlso txtRE_Jahr.Text.Length = 4 Then
If txtRE_Monat.Text = "" OrElse txtRE_Monat.Text <> "" AndAlso IsNumeric(txtRE_Monat.Text) AndAlso CInt(txtRE_Monat.Text) > 0 AndAlso CInt(txtRE_Monat.Text) < 13 Then
Dim Bezeichnung As String = ""
Dim SQL_RE As String = ""
Select Case sender.Name
Case "btnfehlendeBelege"
If cbxFirma_RE._value = "" Then MsgBox("Es muss eine Firma angegeben werden!") : Exit Sub
Bezeichnung = "fehlende BELEGE von " & cbxFirma_RE.SelectedItem.Text & " Zeitraum: " & txtRE_Monat.Text & "/" & txtRE_Jahr.Text
SQL_RE = "DECLARE @Month INT = " & txtRE_Monat.Text & ";
DECLARE @Year INT = " & txtRE_Jahr.Text & ";
DECLARE @FirmaID INT = " & cbxFirma_RE._value & ";
SELECT DISTINCT
REPLACE(
REPLACE(
REPLACE(da.da_name, 'Rechnung_', ''),
'.pdf', ''),
'Gutschrift_', '') AS RechnungsNr, da_name as Bezeichnung
FROM tblDatenarchiv da
WHERE da.da_kategorie = 'Rechnungen'
AND da.da_ordner = 'Firma_' + CAST(@FirmaID AS VARCHAR)
AND da.da_uOrdner1 = CAST(@Year AS VARCHAR) + '_' + CAST(@Month AS VARCHAR)
AND LEFT(da.da_name, 6) <> 'Sammel'
AND NOT EXISTS (
SELECT 1
FROM Rechnungsausgang ra
WHERE ra.RechnungsNr =
REPLACE(
REPLACE(
REPLACE(da.da_name, 'Rechnung_', ''),
'.pdf', ''),
'Gutschrift_', '')
AND MONTH(ra.RechnungsDatum) = @Month
AND YEAR(ra.RechnungsDatum) = @Year
AND ra.Firma_ID = @FirmaID
AND ra.Sammelrechnung = 0
) UNION
SELECT DISTINCT
REPLACE(
REPLACE(da.da_name, 'Sammelrechnung_', ''),
'.pdf', '') AS RechnungsNr, da_name as Bezeichnung
FROM tblDatenarchiv da
WHERE da.da_kategorie = 'Rechnungen'
AND da.da_ordner = 'Firma_' + CAST(@FirmaID AS VARCHAR)
AND da.da_uOrdner1 = CAST(@Year AS VARCHAR) + '_' + CAST(@Month AS VARCHAR)
AND LEFT(da.da_name, 6) = 'Sammel'
AND NOT EXISTS (
SELECT 1
FROM Rechnungsausgang ra
WHERE ra.RechnungsNr =
REPLACE(
REPLACE(da.da_name, 'Sammelrechnung_', ''),
'.pdf', '')
AND MONTH(ra.RechnungsDatum) = @Month
AND YEAR(ra.RechnungsDatum) = @Year
AND ra.Firma_ID = @FirmaID
AND ra.Sammelrechnung <> 0
);"
Case "btnBelegeOhnePOS"
Bezeichnung = "BELEGE ohne Positionen" & IIf(cbxFirma_RE._value <> "", " von " & cbxFirma_RE.SelectedItem.Text, "") & " Zeitraum: " & txtRE_Monat.Text & "/" & txtRE_Jahr.Text
SQL_RE = "Select * From Rechnungsausgang r Where YEAR(r.RechnungsDatum) = " & txtRE_Jahr.Text & " AND MONTH(r.RechnungsDatum) = " & txtRE_Monat.Text & " AND Not EXISTS( SELECT 1 From RechnungsausgangPositionen p Where p.RK_ID = r.RK_ID) " & IIf(cbxFirma_RE._value <> "", " AND r.[Firma_ID] = " & cbxFirma_RE._value, "")
Case "btnfortlRENr"
If cbxFirma_RE._value = "" Then MsgBox("Es muss eine Firma angegeben werden!") : Exit Sub
Dim ignoreMonth As Boolean = False
If vbYes = MsgBox("Möchten Sie die fortlaufende Re-Nr für das Gesamtjahr " & txtRE_Jahr.Text & " prüfen?", vbYesNoCancel) Then ignoreMonth = True
Bezeichnung = "Lücken in der fortl. Belegnummerierung von " & cbxFirma_RE.SelectedItem.Text & " Zeitraum: " & IIf(Not ignoreMonth, txtRE_Monat.Text & "/" & txtRE_Jahr.Text, txtRE_Jahr.Text)
SQL_RE = "WITH Nummern AS (
SELECT
RechnungsNr,
LEAD(RechnungsNr) OVER (ORDER BY RechnungsNr) AS NextRechnungsNr
FROM Rechnungsausgang
WHERE Firma_ID = " & cbxFirma_RE._value & "
AND YEAR(RechnungsDatum) = " & txtRE_Jahr.Text & IIf(Not ignoreMonth, " and Month(RechnungsDatum) = " & txtRE_Monat.Text, "") &
" GROUP BY RechnungsNr
)
SELECT
RechnungsNr + 1 AS FehlendeVon,
NextRechnungsNr - 1 AS FehlendeBis
FROM Nummern
WHERE NextRechnungsNr IS NOT NULL
AND NextRechnungsNr > RechnungsNr + 1
ORDER BY FehlendeVon;"
End Select
Me.Cursor = Cursors.WaitCursor
Dim dt_RE As DataTable = SQL.loadDgvBySql(SQL_RE, "FMZOLL")
If dt_RE.Rows.Count > 0 Then
cProgramFunctions.genExcelFromDT_NEW(dt_RE,,, Bezeichnung,,, True)
Me.Cursor = Cursors.Default
Else
MsgBox("keine Daten für den ausgewählten Zeitraum!")
Me.Cursor = Cursors.Default
End If
End If
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
Me.Cursor = Cursors.Default
End Try
End Sub
End Class