This commit is contained in:
2024-04-19 14:33:02 +02:00
27 changed files with 1857 additions and 600 deletions

View File

@@ -293,19 +293,23 @@ Public Class usrCntlUSTV
End Sub
Private Function excelAuswertung(Optional filepath As String = "", Optional feedback As Boolean = False, Optional openExcel As Boolean = True) As Boolean
Private Function excelAuswertung(Optional ByRef filepath As String = "", Optional feedback As Boolean = False, Optional openExcel As Boolean = True) As Boolean
Dim sqlStr = "SELECT [UStVPo_ReDat] as InvoiceDate , [UStVPo_ReNr] As InvoiceNumber, 'Verag 360 GmbH' as Company, 'FR' as CountryOfRefund ,'EUR' as Currency ,[UStVPo_Leistender] as SupplierName, leist.[UstV_Leistender_Strasse] AS SupplierStreet, leist.[UstV_Leistender_StrasseNr] as SupplierStreetNumber, leist.[UstV_Leistender_PLZ] as SupplierPostalCode, leist.[UstV_Leistender_Stadt] as SupplierCity, leist.[UstV_Leistender_Land] as SupplierCountry, leist.[UstV_Leistender_UstNr] as SupplierVAT_TaxNumber, [UStVPo_Leistungsbezeichnung] as ExpenseCategory ,Round((1119/19*[UStVPo_USteuerbetragEUR]),2) as ExpenseGrossAmount, [UStVPo_USteuerbetragEUR] as ExpenseVATAmount,Round((100/19*[UStVPo_USteuerbetragEUR]),2) as ExpenseNetAmount
Dim sqlStr = "SELECT [UStVPo_ReDat] as InvoiceDate , [UStVPo_ReNr] As InvoiceNumber, antr.UStVAn_Name as Company, 'FR' as CountryOfRefund ,'EUR' as Currency ,[UStVPo_Leistender] as SupplierName, leist.[UstV_Leistender_Strasse] AS SupplierStreet, leist.[UstV_Leistender_StrasseNr] as SupplierStreetNumber, leist.[UstV_Leistender_PLZ] as SupplierPostalCode, leist.[UstV_Leistender_Stadt] as SupplierCity, leist.[UstV_Leistender_Land] as SupplierCountry, leist.[UstV_Leistender_UstNr] as SupplierVAT_TaxNumber, [UStVPo_Leistungsbezeichnung] as ExpenseCategory ,Round((1119/19*[UStVPo_USteuerbetragEUR]),2) as ExpenseGrossAmount, [UStVPo_USteuerbetragEUR] as ExpenseVATAmount,Round((100/19*[UStVPo_USteuerbetragEUR]),2) as ExpenseNetAmount
FROM [tblUStVPositionen]
inner Join [tblUStVLeistender] as leist on leist.UStV_Leistender = [tblUStVPositionen].[UStVPo_Leistender]
where UStVAn_ID ='" & dgvUSTV.SelectedRows(0).Cells("UStVAn_ID").Value & "' ORDER BY UStVPo_ID"
inner join [tblUStVAntrag] as antr on antr.UStVAn_ID = [tblUStVPositionen].UStVAn_ID
where [tblUStVPositionen].UStVAn_ID ='" & dgvUSTV.SelectedRows(0).Cells("UStVAn_ID").Value & "' ORDER BY UStVPo_ID"
Dim dt = SQL.loadDgvBySql(sqlStr, "FMZOLL")
filepath = ""
'filepath = ""
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
filepath = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt, {"N1:N" & (dt.Rows.Count + 1), "O1:O" & (dt.Rows.Count + 1), "P1:P" & (dt.Rows.Count + 1)},,,, openExcel)
Return True
Else
MsgBox("Keine Daten!")
Return False
End If
End Function
@@ -313,33 +317,48 @@ Public Class usrCntlUSTV
Private Sub mailmitExcelauswertung()
Try
Dim outl As New Outlook.Application
Dim Mail As Microsoft.Office.Interop.Outlook.MailItem
Mail = outl.CreateItem(0)
Dim filepath = ""
If excelAuswertung(filepath, False, False) Then
If dgvUSTV.Columns.Count > 0 Then
Mail.Attachments.Add(filepath, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue)
Dim subject As String = ""
subject &= IIf(dgvUSTV.CurrentRow.Cells("UStVAn_Name").Value <> "", dgvUSTV.CurrentRow.Cells("UStVAn_Name").Value & "_", "")
'subject &= If(dgvUSTV.CurrentRow.Cells("UStVAn_LandKz").Value <> "", dgvUSTV.CurrentRow.Cells("UStVAn_LandKz").Value & "_")
If (dgvUSTV.CurrentRow.Cells("UStVAn_ReDatVon").Value IsNot Nothing AndAlso dgvUSTV.CurrentRow.Cells("UStVAn_ReDatBis").Value IsNot Nothing) Then
subject &= CDate(dgvUSTV.CurrentRow.Cells("UStVAn_ReDatVon").Value).ToShortDateString & "-" & CDate(dgvUSTV.CurrentRow.Cells("UStVAn_ReDatBis").Value).ToShortDateString
End If
End If
Dim outl As New Outlook.Application
Dim Mail As Microsoft.Office.Interop.Outlook.MailItem
Mail = outl.CreateItem(0)
If dgvUSTV.Columns.Count > 0 Then Mail.Subject = dgvUSTV.CurrentRow.Cells("UStVAn_Name").Value & "_" & dgvUSTV.CurrentRow.Cells("UStVAn_LandKz").Value & "_" & dgvUSTV.CurrentRow.Cells("UStVAn_ReDatVon").Value & "-" & dgvUSTV.CurrentRow.Cells("UStVAn_ReDatBis").Value
Dim TextHTML = ""
TextHTML &= "Ladies and Gentlemen,<br>"
TextHTML &= "<br>"
TextHTML &= "In the attachment we will send you the Excel list and the corresponding invoices for the VAT refund.<br>"
TextHTML &= "Please submit these invoices to the tax office.<br>"
TextHTML &= "We are always available to answer more questions.<br>"
Dim filepath = ""
If excelAuswertung(filepath, False, False) Then
TextHTML &= "Mit freundlichen Grüßen<br>"
TextHTML &= VERAG_PROG_ALLGEMEIN.cAllgemein.USRNAME & "<br>"
TextHTML &= "<br>"
Mail.HTMLBody = "<div style=""font-family:Calibri, Arial;font-size:15px;"">" & TextHTML & SDL.cFakturierung.getSignature("DE") & "</div>"
Mail.Attachments.Add(filepath, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue)
Mail.Display()
End If
Mail.Subject = subject
Dim TextHTML = ""
TextHTML &= "Ladies and Gentlemen,<br>"
TextHTML &= "<br>"
TextHTML &= "In the attachment we will send you the Excel list and the corresponding invoices for the VAT refund.<br>"
TextHTML &= "Please submit these invoices to the tax office.<br>"
TextHTML &= "We are always available to answer more questions.<br>"
TextHTML &= "Mit freundlichen Grüßen<br>"
TextHTML &= VERAG_PROG_ALLGEMEIN.cAllgemein.USRNAME & "<br>"
TextHTML &= "<br>"
Mail.HTMLBody = "<div style=""font-family:Calibri, Arial;font-size:15px;"">" & TextHTML & SDL.cFakturierung.getSignature("DE") & "</div>"
Mail.Display()
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name,, "Fehler beim Öffnen der Mail!")