KundeBeab, Seriendruck, cKundenErw.

This commit is contained in:
2025-06-04 17:09:47 +02:00
parent 451219aa03
commit 929e58e544
6 changed files with 522 additions and 185 deletions

View File

@@ -37,8 +37,18 @@ Partial Class usrCntlSeriendruck
Me.cbxErstSprache = New System.Windows.Forms.ComboBox()
Me.btnWord = New System.Windows.Forms.Button()
Me.GroupBox2 = New System.Windows.Forms.GroupBox()
Me.Button2 = New System.Windows.Forms.Button()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label9 = New System.Windows.Forms.Label()
Me.datBis = New System.Windows.Forms.DateTimePicker()
Me.Label10 = New System.Windows.Forms.Label()
Me.datVon = New System.Windows.Forms.DateTimePicker()
Me.btnMail_Intern = New System.Windows.Forms.Button()
Me.Button1 = New System.Windows.Forms.Button()
Me.txtFiliale = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.Label5 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.cboErstattungsart = New System.Windows.Forms.ComboBox()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.SuspendLayout()
@@ -239,24 +249,21 @@ Partial Class usrCntlSeriendruck
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.Button2)
Me.GroupBox2.Controls.Add(Me.cboErstattungsart)
Me.GroupBox2.Controls.Add(Me.Label6)
Me.GroupBox2.Controls.Add(Me.Label5)
Me.GroupBox2.Controls.Add(Me.txtFiliale)
Me.GroupBox2.Controls.Add(Me.Button1)
Me.GroupBox2.Controls.Add(Me.btnMail_Intern)
Me.GroupBox2.Controls.Add(Me.Label9)
Me.GroupBox2.Controls.Add(Me.datBis)
Me.GroupBox2.Controls.Add(Me.Label10)
Me.GroupBox2.Controls.Add(Me.datVon)
Me.GroupBox2.Location = New System.Drawing.Point(14, 240)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(646, 182)
Me.GroupBox2.TabIndex = 1
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "GroupBox2"
Me.GroupBox2.Visible = False
'
'Button2
'
Me.Button2.Enabled = False
Me.Button2.Location = New System.Drawing.Point(519, 147)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(121, 23)
Me.Button2.TabIndex = 0
Me.Button2.Text = "Button2"
Me.Button2.UseVisualStyleBackColor = True
'
'Label3
'
@@ -269,11 +276,132 @@ Partial Class usrCntlSeriendruck
Me.Label3.TabIndex = 2
Me.Label3.Text = "Gutschrift - Erstattungsschreiben"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(54, Byte), Integer), CType(CType(128, Byte), Integer))
Me.Label4.Location = New System.Drawing.Point(11, 220)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(283, 17)
Me.Label4.TabIndex = 3
Me.Label4.Text = "Gutschrift - Erstattungsschreiben Mail"
'
'Label9
'
Me.Label9.AutoSize = True
Me.Label9.Location = New System.Drawing.Point(190, 22)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(23, 13)
Me.Label9.TabIndex = 14
Me.Label9.Text = "bis:"
'
'datBis
'
Me.datBis.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
Me.datBis.Location = New System.Drawing.Point(219, 19)
Me.datBis.Name = "datBis"
Me.datBis.Size = New System.Drawing.Size(93, 20)
Me.datBis.TabIndex = 13
'
'Label10
'
Me.Label10.AutoSize = True
Me.Label10.Location = New System.Drawing.Point(13, 22)
Me.Label10.Name = "Label10"
Me.Label10.Size = New System.Drawing.Size(72, 13)
Me.Label10.TabIndex = 12
Me.Label10.Text = "Zeitraum von:"
'
'datVon
'
Me.datVon.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
Me.datVon.Location = New System.Drawing.Point(91, 19)
Me.datVon.Name = "datVon"
Me.datVon.Size = New System.Drawing.Size(93, 20)
Me.datVon.TabIndex = 11
'
'btnMail_Intern
'
Me.btnMail_Intern.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.btnMail_Intern.BackgroundImage = Global.SDL.My.Resources.Resources.email_big1
Me.btnMail_Intern.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
Me.btnMail_Intern.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnMail_Intern.Location = New System.Drawing.Point(519, 61)
Me.btnMail_Intern.Name = "btnMail_Intern"
Me.btnMail_Intern.Size = New System.Drawing.Size(41, 34)
Me.btnMail_Intern.TabIndex = 49
Me.btnMail_Intern.UseVisualStyleBackColor = True
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.ForeColor = System.Drawing.Color.Black
Me.Button1.Location = New System.Drawing.Point(519, 17)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(121, 23)
Me.Button1.TabIndex = 11
Me.Button1.Text = "Datensatz anzeigen"
Me.Button1.UseVisualStyleBackColor = True
'
'txtFiliale
'
Me.txtFiliale._DateTimeOnly = False
Me.txtFiliale._numbersOnly = True
Me.txtFiliale._numbersOnlyKommastellen = ""
Me.txtFiliale._numbersOnlyTrennzeichen = False
Me.txtFiliale._Prozent = False
Me.txtFiliale._ShortDateNew = False
Me.txtFiliale._ShortDateOnly = False
Me.txtFiliale._TimeOnly = False
Me.txtFiliale._TimeOnly_Seconds = False
Me.txtFiliale._value = ""
Me.txtFiliale._Waehrung = False
Me.txtFiliale._WaehrungZeichen = True
Me.txtFiliale.ForeColor = System.Drawing.Color.Black
Me.txtFiliale.Location = New System.Drawing.Point(91, 46)
Me.txtFiliale.MaxLineLength = -1
Me.txtFiliale.MaxLines_Warning = ""
Me.txtFiliale.MaxLines_Warning_Label = Nothing
Me.txtFiliale.Name = "txtFiliale"
Me.txtFiliale.Size = New System.Drawing.Size(33, 20)
Me.txtFiliale.TabIndex = 11
Me.txtFiliale.Text = "4817"
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(16, 49)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(36, 13)
Me.Label5.TabIndex = 50
Me.Label5.Text = "Filiale:"
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(132, 49)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(75, 13)
Me.Label6.TabIndex = 51
Me.Label6.Text = "Erstattungsart:"
'
'cboErstattungsart
'
Me.cboErstattungsart.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboErstattungsart.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.cboErstattungsart.FormattingEnabled = True
Me.cboErstattungsart.Location = New System.Drawing.Point(219, 46)
Me.cboErstattungsart.Name = "cboErstattungsart"
Me.cboErstattungsart.Size = New System.Drawing.Size(95, 21)
Me.cboErstattungsart.TabIndex = 11
'
'usrCntlSeriendruck
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.White
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
@@ -282,6 +410,7 @@ Partial Class usrCntlSeriendruck
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.GroupBox2.ResumeLayout(False)
Me.GroupBox2.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
@@ -292,7 +421,6 @@ Partial Class usrCntlSeriendruck
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents btnShowData As System.Windows.Forms.Button
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents txtErstattungAbfNr As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents btnWordPrint As System.Windows.Forms.Button
@@ -303,4 +431,15 @@ Partial Class usrCntlSeriendruck
Friend WithEvents txtErstattungAbfUnterNr_neu As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents txtErstattungAbfNr_neu As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents txtErstattungAbfNrFiliale_neu As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents Label4 As Label
Friend WithEvents Label9 As Label
Friend WithEvents datBis As DateTimePicker
Friend WithEvents Label10 As Label
Friend WithEvents datVon As DateTimePicker
Friend WithEvents Button1 As Button
Friend WithEvents btnMail_Intern As Button
Friend WithEvents cboErstattungsart As ComboBox
Friend WithEvents Label6 As Label
Friend WithEvents Label5 As Label
Friend WithEvents txtFiliale As VERAG_PROG_ALLGEMEIN.MyTextBox
End Class

View File

@@ -1,6 +1,7 @@
Imports Microsoft.Office.Interop
Imports VERAG_PROG_ALLGEMEIN
Public Class usrCntlSeriendruck
Dim withPrint As Boolean = False
@@ -98,7 +99,7 @@ Public Class usrCntlSeriendruck
frmShowData.Label2.Text = "Anzahl: " & frmShowData.DataGridView1.RowCount
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Private Sub Button2_Click(sender As Object, e As EventArgs)
Dim von As DateTime = Now
@@ -132,8 +133,8 @@ Public Class usrCntlSeriendruck
Dim sqlstr As String = "SELECT * FROM vwUStSerienbriefStNrGueltigkeitsdatum WHERE LandKz='RO' AND StNrGültigkeitsdatum BETWEEN '" & von.ToShortDateString & "' AND '" & bis.ToShortDateString & "' GROUP BY [Name 1],StraßePostfach,PLZ ORDER BY PLZ, AdressenNr "
WordDoc.MailMerge.OpenDataSource(Name:="", _
Connection:="DSN=dbConn_FMZOLL;DATABASE=VERAG;uid=sa;pwd=BmWr501956;", _
WordDoc.MailMerge.OpenDataSource(Name:="",
Connection:="DSN=dbConn_FMZOLL;DATABASE=VERAG;uid=sa;pwd=BmWr501956;",
SQLStatement:=sqlstr, SubType:=Microsoft.Office.Interop.Word.WdMergeSubType.wdMergeSubTypeWord2000)
'Provider=SQLOLEDB;Server=DEVELOPER\DEVSQL;Database=VERAG;uid=sa;Password=BmWr501956;
@@ -198,6 +199,14 @@ Public Class usrCntlSeriendruck
cbxErstSprache.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("YU", "YU"))
cbxErstSprache.SelectedIndex = 0
txtErstattungAbfNr_neu.Focus()
cboErstattungsart.Items.Clear()
cboErstattungsart.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", 0))
cboErstattungsart.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("1.Gegenrechnen", 1))
cboErstattungsart.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("2.Überweisung", 2))
cboErstattungsart.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("3.Bankverbindung", 3))
cboErstattungsart.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("4.Auf Sicherheit", 4))
End Sub
Public Function NurZahlen(ByVal Text As String) As Boolean
If Text.Length = 0 Then Return False
@@ -217,5 +226,143 @@ Public Class usrCntlSeriendruck
End If
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
frmShowData.Show()
frmShowData.DataGridView1.DataSource = generateDTErstattungen()
frmShowData.Label2.Text = "Anzahl: " & frmShowData.DataGridView1.RowCount
End Sub
Private Sub btnMail_Intern_Click(sender As Object, e As EventArgs) Handles btnMail_Intern.Click
If cboErstattungsart.SelectedIndex <> 4 Then
MsgBox("Die Erstattungsschreiben sind aktuell nur für den Typ 4 - Auf Sicherheit verfügbar!")
Exit Sub
End If
Dim dt As New DataTable
dt = generateDTErstattungen()
If dt.Rows.Count > 0 Then
If vbYes = MsgBox("Möchten Sie " & dt.Rows.Count & " Emails für den Versand der Erstattungsinfo für die Erstattungsart " & cboErstattungsart.SelectedText & " erstellen ?", vbYesNoCancel) Then
Dim listOfTextconserven As New cTextkonserve_LIST(5, "", 19)
For Each row In dt.Rows
Dim spracheMail As String = "EN" 'Defaultsprache
Select Case row.Item("LandKz")
Case "HR", "SRB" : spracheMail = "SRB"
Case "A", "AT", "D", "DE", "CH" : spracheMail = "DE"
Case "RO" : spracheMail = "RO"
Case Else
spracheMail = "DE"
End Select
If listOfTextconserven.LIST.Any(Function(c) c.txt_sprache = spracheMail) Then
Dim r As cTextkonserve = listOfTextconserven.LIST.Find(Function(c) c.txt_sprache = spracheMail)
If r IsNot Nothing Then
Dim Mail_Subject = ""
Dim Mail_HTMLBody = ""
Dim Mail_To = ""
Dim Mail_CC = ""
Dim Mail_BCC = ""
Mail_Subject = r.txt_betreff
Dim TextHTML = ""
TextHTML &= r.txt_text
Mail_Subject = Mail_Subject.Replace("%BelegNr%", row.Item("Belegnummer"))
Mail_Subject = Mail_Subject.Replace("%Belegdatum%", row.Item("Belegdatum"))
Mail_Subject = Mail_Subject.Replace("%Name%", row.Item("Name"))
Mail_Subject = Mail_Subject.Replace("%AbfertigungsNr%", row.Item("AbfertigungsNr"))
Mail_Subject = Mail_Subject.Replace("%FilialenNr%", row.Item("FilialenNr"))
Mail_Subject = Mail_Subject.Replace("%MWST%", row.Item("MWST"))
Mail_Subject = Mail_Subject.Replace("%Betrag%", row.Item("Betrag"))
TextHTML = TextHTML.Replace("%BelegNr%", row.Item("Belegnummer"))
TextHTML = TextHTML.Replace("%Belegdatum%", row.Item("Belegdatum"))
TextHTML = TextHTML.Replace("%Betrag%", row.Item("Betrag"))
TextHTML = TextHTML.Replace("%Name%", row.Item("Name"))
TextHTML = TextHTML.Replace("%AbfertigungsNr%", row.Item("AbfertigungsNr"))
TextHTML = TextHTML.Replace("%MWST%", row.Item("MWST"))
TextHTML = TextHTML.Replace("%FilialenNr%", row.Item("FilialenNr"))
Mail_HTMLBody = "<div style=""font-family:Calibri, Arial"">" & TextHTML & "</div>"
Mail_To = VERAG_PROG_ALLGEMEIN.cKundenKontakte.getMailAdress(row.Item("kdNr"), "Rechnung an")
Mail_CC = VERAG_PROG_ALLGEMEIN.cKundenKontakte.getMailAdressCC(row.Item("kdNr"), "Rechnung an")
Mail_BCC = VERAG_PROG_ALLGEMEIN.cKundenKontakte.getMailAdressBCC(row.Item("kdNr"), "Rechnung an")
Mail_HTMLBody &= "<br><br><br>" & cFakturierung.getSignature(row.Item("LandKz"), 19)
Dim outl As New Outlook.Application
Dim Mail As Microsoft.Office.Interop.Outlook.MailItem
Mail = outl.CreateItem(0)
Mail.Subject = Mail_Subject
Mail.HTMLBody = Mail_HTMLBody
Mail.To = Mail_To
Mail.CC = Mail_CC
Mail.BCC = Mail_BCC
Try
'Mail.SentOnBehalfOfName = SDL.cFakturierung.getDefaultMail("AMBAR") ',"buchhaltung@verag.ag"
Catch ex2 As Exception
MsgBox(ex2.Message)
End Try
Mail.Display()
End If
End If
Next
End If
End If
End Sub
Private Function generateDTErstattungen() As DataTable
Dim dt As New DataTable
If txtFiliale.Text = "" Then Return Nothing
Dim SQLString = "SELECT dbo.tblUStVAntrag.UStVAn_KuNr as kdNr,Rechnungsausgang.RechnungsNr as Belegnummer, cast(Rechnungsausgang.RechnungsDatum as date) as Belegdatum, CONVERT(varchar(512), dbo.tblUStVAntrag.UStVAn_Name) AS Name, CONVERT(varchar(512), ISNULL(dbo.tblUStVAntrag.UStVAn_Straße, '')) AS Straße, CONVERT(varchar(255),
dbo.tblUStVAntrag.UStVAn_PLZ + ' ' + dbo.tblUStVAntrag.UStVAn_Ort) AS Ort, CONVERT(varchar(10), dbo.tblUStVAntrag.UStVAn_LandKz) AS LandKz, CONVERT(varchar(255),
dbo.[Länderverzeichnis für die Außenhandelsstatistik].LandKz + ' ' + SUBSTRING(CONVERT(varchar(10), dbo.tblUStVAntrag.UStVAn_ReDatVon, 20), 6, 2) + '-' + SUBSTRING(CONVERT(varchar(10),
dbo.tblUStVAntrag.UStVAn_ReDatBis, 20), 6, 2) + '/' + SUBSTRING(CONVERT(varchar(10), dbo.tblUStVAntrag.UStVAn_ReDatBis, 20), 1, 4)) AS MWST, dbo.Rechnungsausgang.AbfertigungsNr,
dbo.Rechnungsausgang.FilialenNr, dbo.Rechnungsausgang.UnterNr, ABS(CONVERT(decimal(12, 2),
dbo.Rechnungsausgang.SteuerpflichtigerGesamtbetrag + dbo.Rechnungsausgang.SteuerfreierGesamtbetrag)) AS Betrag, ISNULL(dbo.Kunden.KD_Korrespondenz, '')
AS KorrAdresse
FROM dbo.Rechnungsausgang
INNER JOIN dbo.tblUStVAntrag ON dbo.Rechnungsausgang.AbfertigungsNr = dbo.tblUStVAntrag.AbfertigungsNr AND dbo.Rechnungsausgang.FilialenNr = dbo.tblUStVAntrag.FilialenNr
INNER JOIN dbo.[Länderverzeichnis für die Außenhandelsstatistik] ON dbo.tblUStVAntrag.UStVAn_LandNr = dbo.[Länderverzeichnis für die Außenhandelsstatistik].LandNr
INNER JOIN dbo.Kunden ON dbo.tblUStVAntrag.UStVAn_KuNr = dbo.Kunden.KundenNr
INNER JOIN dbo.tblKundenErweitert ON dbo.tblUStVAntrag.UStVAn_KuNr = tblKundenErweitert.kde_KundenNr and ISNULL(tblKundenErweitert.kde_Erstattungsart, 0) = " & cboErstattungsart.SelectedIndex &
" WHERE dbo.Rechnungsausgang.Rechnungsdatum between '" & datVon.Value.ToShortDateString & "' and '" & datBis.Value.ToShortDateString & "' AND dbo.Rechnungsausgang.FilialenNr = " & txtFiliale.Text & " AND Rechnungsausgang.RechnungsNr is not null"
dt = (New SQL).loadDgvBySql(SQLString, "FMZOLL")
If dt.Rows.Count > 0 Then
Return dt
End If
End Function
End Class