div. Änderungen (USTVA, Ausewrtung, etc.)

This commit is contained in:
2026-01-22 17:41:06 +01:00
parent a8c6f91f1d
commit 8896aa1def
5 changed files with 311 additions and 67 deletions

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.5.1.5")>
<Assembly: AssemblyFileVersion("1.5.1.5")>
<Assembly: AssemblyVersion("1.5.1.7")>
<Assembly: AssemblyFileVersion("1.5.1.7")>

View File

@@ -3314,6 +3314,7 @@ Public Class frmMDM_USTVAntrag
Private Sub Button5_Click_1(sender As Object, e As EventArgs) Handles Button5.Click
If IsDBNull(USTV_ANTRAG.FilialenNr) OrElse USTV_ANTRAG.FilialenNr Is Nothing OrElse USTV_ANTRAG.FilialenNr = 0 Then MsgBox("Für das Speditionsbuch muss die Filiale eingegeben werden.") : Exit Sub
If IsDBNull(USTV_ANTRAG.AbfertigungsNr) OrElse USTV_ANTRAG.AbfertigungsNr Is Nothing OrElse USTV_ANTRAG.AbfertigungsNr <= 0 Then MsgBox("Für das Speditionsbuch muss die Abfertigungs-Nr eingegeben werden.") : Exit Sub

View File

@@ -47,7 +47,7 @@ Public Class frmBU_Mahnlauf
Dim sqlStr_New = "WITH EmailCTE AS (
SELECT
kkd_KundenNr," & IIf(Firma_ID = 7, "MAX(CASE WHEN kkd_kkaId = 18 THEN kkd_Email END) AS EmailMAhnungAtilla", "") & ",MAX(CASE WHEN kkd_kkaId = 10 THEN kkd_Email END) AS EmailMahnung
kkd_KundenNr" & IIf(Firma_ID = 7, ",MAX(CASE WHEN kkd_kkaId = 18 THEN kkd_Email END) AS EmailMAhnungAtilla", "") & ",MAX(CASE WHEN kkd_kkaId = 10 THEN kkd_Email END) AS EmailMahnung
FROM [FMZOLL\SQLFMZOLL].[VERAG].[dbo].[tblKundenKontakt]
WHERE kkd_kkaId IN (" & IIf(Firma_ID = 7, "10, 18", "10") & ")
GROUP BY kkd_KundenNr
@@ -343,24 +343,23 @@ Public Class frmBU_Mahnlauf
'Wenn <0, dann Guthaben!!
End Function
Public Function increaseMahnstufe(KdNr As Integer, Firma_ID As Integer) As Boolean
Public Function increaseMahnstufe(KdNr As Integer, Firma_ID As Integer, ErhoehungBeiMahnsperre As Boolean) As Boolean '
Dim sqlStr = "UPDATE op_debitor SET si_mahnstufe=(isnull(si_mahnstufe,0)+1),d_mahnung=GETDATE()
WHERE (i_firm_refid = '" & Firma_ID & "') AND (dt_geloescht IS NULL)
and i_personenkonto='" & KdNr & "' and dec_fremdbrutto>0 and (si_mahnstufe >=0 OR si_mahnstufe is NULL) and d_netto<=getdate()"
and i_personenkonto='" & KdNr & "' and dec_fremdbrutto>0 and (si_mahnstufe >=0 OR si_mahnstufe is NULL) " & IIf(ErhoehungBeiMahnsperre, "", "AND isnull(si_mahnflags,0) <>(1)") & " and d_netto<=getdate()"
Return SQL.doSQL(sqlStr, "FIBU")
End Function
Public Function redoMahnstufe(Firma_ID As Integer, Mahn_Datum As Date) As Boolean
Public Function redoMahnstufe(Firma_ID As Integer, Mahn_Datum As Date, ErhoehungBeiMahnsperre As Boolean) As Boolean
Dim sqlStr = " UPDATE op_debitor SET si_mahnstufe=(si_mahnstufe-1)
WHERE (i_firm_refid = '" & Firma_ID & "') AND (dt_geloescht IS NULL)
and (si_mahnstufe >0 AND si_mahnstufe is not NULL) and d_mahnung>='" & Mahn_Datum.ToShortDateString & "' and d_netto<=getdate()"
Return SQL.doSQL(sqlStr, "FIBU")
End Function
Public Function cntRedoMahnstufe(Firma_ID As Integer, Mahn_Datum As Date) As Integer
Public Function cntRedoMahnstufe(Firma_ID As Integer, Mahn_Datum As Date, MahnsperreBeruecksichtigen As Boolean) As Integer
Dim sqlStr = " SELECT COUNT(*) FROM op_debitor
WHERE (i_firm_refid = '" & Firma_ID & "') AND (dt_geloescht IS NULL)
and (si_mahnstufe >0 AND si_mahnstufe is not NULL) and d_mahnung>='" & Mahn_Datum.ToShortDateString & "' and d_netto<=getdate()"
and (si_mahnstufe >0 AND si_mahnstufe is not NULL) " & IIf(MahnsperreBeruecksichtigen, "", "AND isnull(si_mahnflags,0) <>(1)") & " and d_mahnung>='" & Mahn_Datum.ToShortDateString & "' and d_netto<=getdate()"
Return SQL.getValueTxtBySql(sqlStr, "FIBU",,, 0)
End Function
Public Shared Function doMahnung(Mahndruckart As Integer, KdNr As Integer, Firma_ID As Integer, art As String, Optional ByRef Path As String = "", Optional ByRef PrinterName As String = "", Optional ByRef forceMahnstufe As String = "", Optional showErr As Boolean = True, Optional hideMahnstopp As Boolean = True) As Boolean
@@ -1425,9 +1424,9 @@ Public Class frmBU_Mahnlauf
For Each r As DataGridViewRow In MyDatagridview1.SelectedRows
Dim mahnsperre As Boolean = r.Cells("mahnbar").Value
Dim mahnbar As Boolean = r.Cells("mahnbar").Value
If Not cbxMahnsperre.Checked Or (cbxMahnsperre.Checked And mahnsperre) Then
If Not cbxMahnsperre.Checked Or (cbxMahnsperre.Checked And mahnbar) Then ' Mahnsperre -> Kunde mit Mahnsperre wird NICHT gemahnt!
Dim Konto = r.Cells("Konto").Value
Dim FirmaId = cboFirma._value
@@ -1436,18 +1435,18 @@ Public Class frmBU_Mahnlauf
Dim Path = ""
Select Case AUSGABE
Case "PDF"
If bool_increaseMahnstufe Then increaseMahnstufe(Konto, FirmaId)
If bool_increaseMahnstufe Then increaseMahnstufe(Konto, FirmaId, Not cbxMahnsperre.Checked)
If doMahnung(4, Konto, FirmaId, "ZE", Path, srchPrinter) Then
PDF_LIST.Add(Path)
End If
Case "MAIL"
If bool_increaseMahnstufe Then increaseMahnstufe(Konto, FirmaId)
If bool_increaseMahnstufe Then increaseMahnstufe(Konto, FirmaId, Not cbxMahnsperre.Checked)
doMahnung(2, Konto, FirmaId, "ZE",, srchPrinter)
Case "MAIL_SEND"
If bool_increaseMahnstufe Then increaseMahnstufe(Konto, FirmaId)
If bool_increaseMahnstufe Then increaseMahnstufe(Konto, FirmaId, Not cbxMahnsperre.Checked)
doMahnung(5, Konto, FirmaId, "ZE",, srchPrinter)
Case "PRINT"
If bool_increaseMahnstufe Then increaseMahnstufe(Konto, FirmaId)
If bool_increaseMahnstufe Then increaseMahnstufe(Konto, FirmaId, Not cbxMahnsperre.Checked)
doMahnung(0, Konto, FirmaId, "ZE",, srchPrinter)
End Select
End If
@@ -1525,9 +1524,9 @@ Public Class frmBU_Mahnlauf
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
If MyTextBox2._value <> "" Then
Dim mahndatum As Date = MyTextBox2._value
Dim cntRedo As Integer = cntRedoMahnstufe(cboFirma._value, mahndatum)
Dim cntRedo As Integer = cntRedoMahnstufe(cboFirma._value, mahndatum, Not cbxMahnsperre.Checked)
If vbYes = MsgBox("Möchten Sie wirklich den Mahnzähler zurücksetzen?" & vbNewLine & "Ab Mahndatum: " & mahndatum & vbNewLine & "Betrifft '" & cntRedo & "' Mahnungen/Einträge " & mahndatum, vbYesNoCancel) Then
If redoMahnstufe(cboFirma._value, mahndatum) Then
If redoMahnstufe(cboFirma._value, mahndatum, Not cbxMahnsperre.Checked) Then
MsgBox("Der Mahnzähler wurde erfolgreich zurückgesetzt.")
End If
End If

View File

@@ -127,6 +127,13 @@ Partial Class usrCntlMDMAuswertungen
Me.MyComboBox2 = New VERAG_PROG_ALLGEMEIN.MyComboBox()
Me.Label36 = New System.Windows.Forms.Label()
Me.TabPage3 = New System.Windows.Forms.TabPage()
Me.Label66 = New System.Windows.Forms.Label()
Me.GroupBox20 = New System.Windows.Forms.GroupBox()
Me.PictureBox7 = New System.Windows.Forms.PictureBox()
Me.Label45 = New System.Windows.Forms.Label()
Me.Label64 = New System.Windows.Forms.Label()
Me.Label65 = New System.Windows.Forms.Label()
Me.Button20 = New System.Windows.Forms.Button()
Me.UsrCntlWoelfl_IM_CSVRg1 = New SDL.usrCntlWoelfl_IM_CSVRg()
Me.tbIDS = New System.Windows.Forms.TabPage()
Me.Label62 = New System.Windows.Forms.Label()
@@ -168,6 +175,7 @@ Partial Class usrCntlMDMAuswertungen
Me.TabPage5 = New System.Windows.Forms.TabPage()
Me.Label56 = New System.Windows.Forms.Label()
Me.GroupBox17 = New System.Windows.Forms.GroupBox()
Me.cbxExcel = New System.Windows.Forms.CheckBox()
Me.Label55 = New System.Windows.Forms.Label()
Me.Button16 = New System.Windows.Forms.Button()
Me.Label53 = New System.Windows.Forms.Label()
@@ -189,7 +197,10 @@ Partial Class usrCntlMDMAuswertungen
Me.btnContractdaten = New System.Windows.Forms.Button()
Me.Button15 = New System.Windows.Forms.Button()
Me.pnl = New System.Windows.Forms.Panel()
Me.cbxExcel = New System.Windows.Forms.CheckBox()
Me.Label67 = New System.Windows.Forms.Label()
Me.txtJahr = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtLeistungsNr = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.cboQuartal = New VERAG_PROG_ALLGEMEIN.MyComboBox()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
CType(Me.pic, System.ComponentModel.ISupportInitialize).BeginInit()
@@ -210,6 +221,8 @@ Partial Class usrCntlMDMAuswertungen
Me.GroupBox9.SuspendLayout()
CType(Me.PictureBox5, System.ComponentModel.ISupportInitialize).BeginInit()
Me.TabPage3.SuspendLayout()
Me.GroupBox20.SuspendLayout()
CType(Me.PictureBox7, System.ComponentModel.ISupportInitialize).BeginInit()
Me.tbIDS.SuspendLayout()
Me.GroupBox13.SuspendLayout()
Me.GroupBox18.SuspendLayout()
@@ -1406,6 +1419,8 @@ Partial Class usrCntlMDMAuswertungen
'
'TabPage3
'
Me.TabPage3.Controls.Add(Me.Label66)
Me.TabPage3.Controls.Add(Me.GroupBox20)
Me.TabPage3.Controls.Add(Me.UsrCntlWoelfl_IM_CSVRg1)
Me.TabPage3.Controls.Add(Me.Label4)
Me.TabPage3.Controls.Add(Me.GroupBox2)
@@ -1416,10 +1431,86 @@ Partial Class usrCntlMDMAuswertungen
Me.TabPage3.Text = "WÖLFL"
Me.TabPage3.UseVisualStyleBackColor = True
'
'Label66
'
Me.Label66.AutoSize = True
Me.Label66.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label66.ForeColor = System.Drawing.SystemColors.ControlDarkDark
Me.Label66.Location = New System.Drawing.Point(9, 136)
Me.Label66.Name = "Label66"
Me.Label66.Size = New System.Drawing.Size(347, 17)
Me.Label66.TabIndex = 15
Me.Label66.Text = "Wölfl Rechnungen Bearbeitungsbetrag Quartal"
'
'GroupBox20
'
Me.GroupBox20.Controls.Add(Me.cboQuartal)
Me.GroupBox20.Controls.Add(Me.txtLeistungsNr)
Me.GroupBox20.Controls.Add(Me.txtJahr)
Me.GroupBox20.Controls.Add(Me.Label67)
Me.GroupBox20.Controls.Add(Me.PictureBox7)
Me.GroupBox20.Controls.Add(Me.Label45)
Me.GroupBox20.Controls.Add(Me.Label64)
Me.GroupBox20.Controls.Add(Me.Label65)
Me.GroupBox20.Controls.Add(Me.Button20)
Me.GroupBox20.Location = New System.Drawing.Point(6, 153)
Me.GroupBox20.Name = "GroupBox20"
Me.GroupBox20.Size = New System.Drawing.Size(697, 111)
Me.GroupBox20.TabIndex = 14
Me.GroupBox20.TabStop = False
'
'PictureBox7
'
Me.PictureBox7.Image = Global.SDL.My.Resources.Resources.woelfl
Me.PictureBox7.Location = New System.Drawing.Point(640, 8)
Me.PictureBox7.Name = "PictureBox7"
Me.PictureBox7.Size = New System.Drawing.Size(51, 37)
Me.PictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.PictureBox7.TabIndex = 11
Me.PictureBox7.TabStop = False
'
'Label45
'
Me.Label45.AutoSize = True
Me.Label45.Location = New System.Drawing.Point(249, 50)
Me.Label45.Name = "Label45"
Me.Label45.Size = New System.Drawing.Size(44, 13)
Me.Label45.TabIndex = 10
Me.Label45.Text = "Quartal:"
'
'Label64
'
Me.Label64.AutoSize = True
Me.Label64.Location = New System.Drawing.Point(153, 50)
Me.Label64.Name = "Label64"
Me.Label64.Size = New System.Drawing.Size(27, 13)
Me.Label64.TabIndex = 8
Me.Label64.Text = "Jahr"
'
'Label65
'
Me.Label65.AutoSize = True
Me.Label65.Location = New System.Drawing.Point(145, 19)
Me.Label65.Name = "Label65"
Me.Label65.Size = New System.Drawing.Size(373, 13)
Me.Label65.TabIndex = 5
Me.Label65.Text = "Alle Woelfl-Kunden, deren Bearbeitungsbetrag pro Quartal unter 50 EUR liegt."
'
'Button20
'
Me.Button20.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button20.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(54, Byte), Integer), CType(CType(128, Byte), Integer))
Me.Button20.Location = New System.Drawing.Point(6, 19)
Me.Button20.Name = "Button20"
Me.Button20.Size = New System.Drawing.Size(121, 49)
Me.Button20.TabIndex = 4
Me.Button20.Text = "CSV erstellen"
Me.Button20.UseVisualStyleBackColor = True
'
'UsrCntlWoelfl_IM_CSVRg1
'
Me.UsrCntlWoelfl_IM_CSVRg1.BackColor = System.Drawing.Color.White
Me.UsrCntlWoelfl_IM_CSVRg1.Location = New System.Drawing.Point(6, 167)
Me.UsrCntlWoelfl_IM_CSVRg1.Location = New System.Drawing.Point(12, 292)
Me.UsrCntlWoelfl_IM_CSVRg1.Name = "UsrCntlWoelfl_IM_CSVRg1"
Me.UsrCntlWoelfl_IM_CSVRg1.Size = New System.Drawing.Size(728, 97)
Me.UsrCntlWoelfl_IM_CSVRg1.TabIndex = 10
@@ -1849,6 +1940,18 @@ Partial Class usrCntlMDMAuswertungen
Me.GroupBox17.TabIndex = 13
Me.GroupBox17.TabStop = False
'
'cbxExcel
'
Me.cbxExcel.AutoSize = True
Me.cbxExcel.Checked = True
Me.cbxExcel.CheckState = System.Windows.Forms.CheckState.Checked
Me.cbxExcel.Location = New System.Drawing.Point(150, 36)
Me.cbxExcel.Name = "cbxExcel"
Me.cbxExcel.Size = New System.Drawing.Size(68, 17)
Me.cbxExcel.TabIndex = 56
Me.cbxExcel.Text = "als Excel"
Me.cbxExcel.UseVisualStyleBackColor = True
'
'Label55
'
Me.Label55.AutoSize = True
@@ -2070,17 +2173,72 @@ Partial Class usrCntlMDMAuswertungen
Me.pnl.Size = New System.Drawing.Size(1057, 54)
Me.pnl.TabIndex = 26
'
'cbxExcel
'Label67
'
Me.cbxExcel.AutoSize = True
Me.cbxExcel.Checked = True
Me.cbxExcel.CheckState = System.Windows.Forms.CheckState.Checked
Me.cbxExcel.Location = New System.Drawing.Point(150, 36)
Me.cbxExcel.Name = "cbxExcel"
Me.cbxExcel.Size = New System.Drawing.Size(68, 17)
Me.cbxExcel.TabIndex = 56
Me.cbxExcel.Text = "als Excel"
Me.cbxExcel.UseVisualStyleBackColor = True
Me.Label67.AutoSize = True
Me.Label67.Location = New System.Drawing.Point(145, 80)
Me.Label67.Name = "Label67"
Me.Label67.Size = New System.Drawing.Size(155, 13)
Me.Label67.TabIndex = 12
Me.Label67.Text = "LeistungsNr (Komma-getrennt).:"
'
'txtJahr
'
Me.txtJahr._DateTimeOnly = False
Me.txtJahr._numbersOnly = False
Me.txtJahr._numbersOnlyKommastellen = ""
Me.txtJahr._numbersOnlyTrennzeichen = True
Me.txtJahr._Prozent = False
Me.txtJahr._ShortDateNew = False
Me.txtJahr._ShortDateOnly = False
Me.txtJahr._TimeOnly = False
Me.txtJahr._TimeOnly_Seconds = False
Me.txtJahr._value = ""
Me.txtJahr._Waehrung = False
Me.txtJahr._WaehrungZeichen = True
Me.txtJahr.ForeColor = System.Drawing.Color.Black
Me.txtJahr.Location = New System.Drawing.Point(185, 47)
Me.txtJahr.MaxLineLength = -1
Me.txtJahr.MaxLines_Warning = ""
Me.txtJahr.MaxLines_Warning_Label = Nothing
Me.txtJahr.Name = "txtJahr"
Me.txtJahr.Size = New System.Drawing.Size(53, 20)
Me.txtJahr.TabIndex = 13
'
'txtLeistungsNr
'
Me.txtLeistungsNr._DateTimeOnly = False
Me.txtLeistungsNr._numbersOnly = False
Me.txtLeistungsNr._numbersOnlyKommastellen = ""
Me.txtLeistungsNr._numbersOnlyTrennzeichen = True
Me.txtLeistungsNr._Prozent = False
Me.txtLeistungsNr._ShortDateNew = False
Me.txtLeistungsNr._ShortDateOnly = False
Me.txtLeistungsNr._TimeOnly = False
Me.txtLeistungsNr._TimeOnly_Seconds = False
Me.txtLeistungsNr._value = "327"
Me.txtLeistungsNr._Waehrung = False
Me.txtLeistungsNr._WaehrungZeichen = True
Me.txtLeistungsNr.ForeColor = System.Drawing.Color.Black
Me.txtLeistungsNr.Location = New System.Drawing.Point(306, 73)
Me.txtLeistungsNr.MaxLineLength = -1
Me.txtLeistungsNr.MaxLines_Warning = ""
Me.txtLeistungsNr.MaxLines_Warning_Label = Nothing
Me.txtLeistungsNr.Name = "txtLeistungsNr"
Me.txtLeistungsNr.Size = New System.Drawing.Size(93, 20)
Me.txtLeistungsNr.TabIndex = 15
Me.txtLeistungsNr.Text = "327"
'
'cboQuartal
'
Me.cboQuartal._allowedValuesFreiText = Nothing
Me.cboQuartal._allowFreiText = False
Me.cboQuartal._value = ""
Me.cboQuartal.FormattingEnabled = True
Me.cboQuartal.Location = New System.Drawing.Point(306, 46)
Me.cboQuartal.Name = "cboQuartal"
Me.cboQuartal.Size = New System.Drawing.Size(59, 21)
Me.cboQuartal.TabIndex = 16
'
'usrCntlMDMAuswertungen
'
@@ -2123,6 +2281,9 @@ Partial Class usrCntlMDMAuswertungen
CType(Me.PictureBox5, System.ComponentModel.ISupportInitialize).EndInit()
Me.TabPage3.ResumeLayout(False)
Me.TabPage3.PerformLayout()
Me.GroupBox20.ResumeLayout(False)
Me.GroupBox20.PerformLayout()
CType(Me.PictureBox7, System.ComponentModel.ISupportInitialize).EndInit()
Me.tbIDS.ResumeLayout(False)
Me.tbIDS.PerformLayout()
Me.GroupBox13.ResumeLayout(False)
@@ -2321,4 +2482,15 @@ Partial Class usrCntlMDMAuswertungen
Friend WithEvents Label63 As Label
Friend WithEvents Button19 As Button
Friend WithEvents cbxExcel As CheckBox
Friend WithEvents Label66 As Label
Friend WithEvents GroupBox20 As GroupBox
Friend WithEvents PictureBox7 As PictureBox
Friend WithEvents Label45 As Label
Friend WithEvents Label64 As Label
Friend WithEvents Label65 As Label
Friend WithEvents Button20 As Button
Friend WithEvents txtJahr As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents Label67 As Label
Friend WithEvents txtLeistungsNr As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents cboQuartal As VERAG_PROG_ALLGEMEIN.MyComboBox
End Class

View File

@@ -56,6 +56,18 @@ Public Class usrCntlMDMAuswertungen
cboIDSDateType.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Leistungsdatum", "LDat"))
cboIDSDateType.changeItem("RGDat")
txtJahr.Text = Now.Year
cboQuartal.Items.Clear()
cboQuartal.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("1", "1"))
cboQuartal.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("2", "2"))
cboQuartal.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("3", "3"))
cboQuartal.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("4", "4"))
cboQuartal.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem(" ", " "))
cboQuartal.changeItem(" ")
txtLeistungsNr.Text = "327"
If Not VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("MDM_Auswertungen_IDS", Me.FindForm) Then
tbcntr.TabPages.Remove(tbIDS)
End If
@@ -178,58 +190,58 @@ Public Class usrCntlMDMAuswertungen
If MonthStart = MonthEnd Then MonthEnd = ""
If r.Item("RK_ID") > 0 Then
For Each pos As cUStVPositionen In MWSTAntrag.POSITIONEN.OrderBy(Function(x) If(IsDate(x.UStVPo_ReDat), CDate(x.UStVPo_ReDat), Nothing))
For Each pos As cUStVPositionen In MWSTAntrag.POSITIONEN.OrderBy(Function(x) If(IsDate(x.UStVPo_ReDat), CDate(x.UStVPo_ReDat), Nothing))
If Not IsDBNull(pos.UStVPo_VZ) AndAlso pos.UStVPo_VZ AndAlso pos.UStVPo_VZ_RKID = r.Item("RK_ID") AndAlso IsDate(pos.UStVPo_ReDat) Then
If Not listVZMonth.Contains(CDate(pos.UStVPo_ReDat).Month) Then listVZMonth.Add(CDate(pos.UStVPo_ReDat).Month)
End If
Next
End If
If listVZMonth.Count > 0 Then
If listVZMonth.Count = 1 Then
MonthStart = IIf(CDate(MWSTAntrag.UStVAn_ReDatVon).Month < 10, "0", "") & listVZMonth(0).ToString
MonthEnd = ""
Else
MonthStart = IIf(CDate(MWSTAntrag.UStVAn_ReDatVon).Month < 10, "0", "") & listVZMonth(0).ToString
MonthEnd = IIf(CDate(MWSTAntrag.UStVAn_ReDatBis).Month < 10, "0", "") & listVZMonth(listVZMonth.Count - 1).ToString
If Not IsDBNull(pos.UStVPo_VZ) AndAlso pos.UStVPo_VZ AndAlso pos.UStVPo_VZ_RKID = r.Item("RK_ID") AndAlso IsDate(pos.UStVPo_ReDat) Then
If Not listVZMonth.Contains(CDate(pos.UStVPo_ReDat).Month) Then listVZMonth.Add(CDate(pos.UStVPo_ReDat).Month)
End If
End If
Next
End If
If listVZMonth.Count > 0 Then
Dim LeistungsBez As String = ""
LeistungsBez = r.Item("LeistungsBez").ToString()
If LeistungsBez.Contains("00-00/23") Then
LeistungsBez = LeistungsBez.Replace("00/23", "/" & CDate(MWSTAntrag.UStVAn_ReDatBis).Year.ToString.Substring(2))
ElseIf LeistungsBez.Contains("DL/23") Then
LeistungsBez = LeistungsBez.Replace("DL/23", "/" & CDate(MWSTAntrag.UStVAn_ReDatBis).Year.ToString.Substring(2))
If listVZMonth.Count = 1 Then
MonthStart = IIf(CDate(MWSTAntrag.UStVAn_ReDatVon).Month < 10, "0", "") & listVZMonth(0).ToString
MonthEnd = ""
Else
LeistungsBez = LeistungsBez.Replace("/23", "/" & CDate(MWSTAntrag.UStVAn_ReDatBis).Year.ToString.Substring(2))
End If
If LeistungsBez.Contains("-00") Then
LeistungsBez = LeistungsBez.Replace("-00", MonthStart & IIf(MonthEnd <> "", "-" & MonthEnd, ""))
ElseIf LeistungsBez.Contains("00-") Then
LeistungsBez = LeistungsBez.Replace("00-", MonthStart & IIf(MonthEnd <> "", "-" & MonthEnd, ""))
ElseIf LeistungsBez.Contains("00") Then
LeistungsBez = LeistungsBez.Replace("00", MonthStart & IIf(MonthEnd <> "", "-" & MonthEnd, ""))
End If
If LeistungsBez.Length > 30 Then
r.Item("LeistungsBez") = LeistungsBez.Substring(0, 30)
Else
r.Item("LeistungsBez") = LeistungsBez
MonthStart = IIf(CDate(MWSTAntrag.UStVAn_ReDatVon).Month < 10, "0", "") & listVZMonth(0).ToString
MonthEnd = IIf(CDate(MWSTAntrag.UStVAn_ReDatBis).Month < 10, "0", "") & listVZMonth(listVZMonth.Count - 1).ToString
End If
End If
Dim LeistungsBez As String = ""
LeistungsBez = r.Item("LeistungsBez").ToString()
If LeistungsBez.Contains("00-00/23") Then
LeistungsBez = LeistungsBez.Replace("00/23", "/" & CDate(MWSTAntrag.UStVAn_ReDatBis).Year.ToString.Substring(2))
ElseIf LeistungsBez.Contains("DL/23") Then
LeistungsBez = LeistungsBez.Replace("DL/23", "/" & CDate(MWSTAntrag.UStVAn_ReDatBis).Year.ToString.Substring(2))
Else
LeistungsBez = LeistungsBez.Replace("/23", "/" & CDate(MWSTAntrag.UStVAn_ReDatBis).Year.ToString.Substring(2))
End If
If LeistungsBez.Contains("-00") Then
LeistungsBez = LeistungsBez.Replace("-00", MonthStart & IIf(MonthEnd <> "", "-" & MonthEnd, ""))
ElseIf LeistungsBez.Contains("00-") Then
LeistungsBez = LeistungsBez.Replace("00-", MonthStart & IIf(MonthEnd <> "", "-" & MonthEnd, ""))
ElseIf LeistungsBez.Contains("00") Then
LeistungsBez = LeistungsBez.Replace("00", MonthStart & IIf(MonthEnd <> "", "-" & MonthEnd, ""))
End If
If LeistungsBez.Length > 30 Then
r.Item("LeistungsBez") = LeistungsBez.Substring(0, 30)
Else
r.Item("LeistungsBez") = LeistungsBez
End If
End If
End If
Next
If dt.Columns.Contains("RK_ID") Then dt.Columns.Remove("RK_ID")
@@ -1505,6 +1517,66 @@ Public Class usrCntlMDMAuswertungen
End Sub
Private Sub Button20_Click_1(sender As Object, e As EventArgs) Handles Button20.Click
Try
Me.Cursor = Cursors.WaitCursor
Dim Jahr As Integer = Now().Year
If txtJahr.Text <> "" AndAlso IsNumeric(txtJahr.Text) AndAlso txtJahr.Text.Length = 4 Then
Jahr = txtJahr.Text
End If
Dim SQLstr = "select Temp.KundenNr, Temp.Kundenname, Temp.Jahr, Temp.Quartal, sum(Temp.Betrag) as 'verrechneter Betrag', 50 - sum(Temp.Betrag) as Differenzbetrag from (SELECT
USTVA.UStVAn_KuNr as KundenNr,
USTVA.UStVAn_Name as Kundenname,
YEAR(R.Abfertigungsdatum) AS Jahr,
DATEPART(QUARTER, R.Abfertigungsdatum) AS Quartal,
POS.LeistungsNr,
SUM(POS.SteuerfreierBetrag + POS.SteuerpflichtigerBetrag) AS Betrag
FROM tblUStVAntrag AS USTVA
INNER JOIN Rechnungsausgang AS R
ON R.FilialenNr = USTVA.FilialenNr
AND R.AbfertigungsNr = USTVA.AbfertigungsNr
INNER JOIN RechnungsausgangPositionen AS POS
ON R.RK_ID = POS.RK_ID
WHERE USTVA.UStVAn_KuNr LIKE '15%'
AND YEAR(R.Abfertigungsdatum) = " & Jahr &
" AND POS.LeistungsNr IN (" & IIf(txtLeistungsNr.Text <> "", txtLeistungsNr.Text, "") & ")
GROUP BY
USTVA.UStVAn_KuNr,
USTVA.UStVAn_Name,
YEAR(R.Abfertigungsdatum),
DATEPART(QUARTER, R.Abfertigungsdatum),
POS.LeistungsNr
) as Temp
WHERE 1 = 1 " & IIf(cboQuartal._value.Trim() <> "", " AND temp.Quartal = " & cboQuartal._value, "") & "
Group by Temp.KundenNr, Temp.Kundenname, Temp.Jahr, Temp.Quartal
Having sum(Temp.Betrag) < 50"
Dim dt = (New VERAG_PROG_ALLGEMEIN.SQL).loadDgvBySql(SQLstr, "FMZOLL")
If dt.Rows.Count > 0 Then
cProgramFunctions.genExcelFromDT_NEW(dt)
Else
MsgBox("keine Daten für ausgewählten Zeitraum")
End If
Catch ex As System.Exception
MsgBox(ex.Message & ex.StackTrace)
End Try
Me.Cursor = Cursors.Default
End Sub
End Class