Handling, etc.

This commit is contained in:
2026-05-08 14:58:49 +02:00
parent 1b677dee85
commit 614b55dd8b
6 changed files with 1555 additions and 151 deletions

View File

@@ -0,0 +1,107 @@
Partial Class frmAbrechnungHandling
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Wird vom Windows Form-Designer benötigt.
Private components As System.ComponentModel.IContainer
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmAbrechnungHandling))
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.dgvHandling = New VERAG_PROG_ALLGEMEIN.MyDatagridview(Me.components)
Me.btnPreisliste = New System.Windows.Forms.Button()
CType(Me.dgvHandling, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.BackColor = System.Drawing.Color.LightGray
Me.Button1.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.Location = New System.Drawing.Point(568, 415)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Abbrechen"
Me.Button1.UseVisualStyleBackColor = False
'
'Button2
'
Me.Button2.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Button2.FlatAppearance.BorderSize = 0
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button2.Location = New System.Drawing.Point(660, 415)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(128, 23)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Rechnung erstellen"
Me.Button2.UseVisualStyleBackColor = True
'
'dgvHandling
'
Me.dgvHandling.AKTUALISIERUNGS_INTERVALL = -1
Me.dgvHandling.AllowUserToAddRows = False
Me.dgvHandling.AllowUserToDeleteRows = False
Me.dgvHandling.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.dgvHandling.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill
Me.dgvHandling.BackgroundColor = System.Drawing.Color.White
Me.dgvHandling.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.dgvHandling.Location = New System.Drawing.Point(12, 12)
Me.dgvHandling.Name = "dgvHandling"
Me.dgvHandling.ReadOnly = True
Me.dgvHandling.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect
Me.dgvHandling.Size = New System.Drawing.Size(776, 397)
Me.dgvHandling.TabIndex = 3
'
'btnPreisliste
'
Me.btnPreisliste.FlatAppearance.BorderSize = 0
Me.btnPreisliste.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnPreisliste.Location = New System.Drawing.Point(12, 415)
Me.btnPreisliste.Name = "btnPreisliste"
Me.btnPreisliste.Size = New System.Drawing.Size(87, 23)
Me.btnPreisliste.TabIndex = 4
Me.btnPreisliste.Text = "Preisliste"
Me.btnPreisliste.UseVisualStyleBackColor = True
'
'frmAbrechnungHandling
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
Me.Controls.Add(Me.btnPreisliste)
Me.Controls.Add(Me.dgvHandling)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmAbrechnungHandling"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Handling"
CType(Me.dgvHandling, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents Button1 As Button
Friend WithEvents Button2 As Button
Friend WithEvents dgvHandling As VERAG_PROG_ALLGEMEIN.MyDatagridview
Friend WithEvents btnPreisliste As Button
End Class

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
Imports VERAG_PROG_ALLGEMEIN
Public Class frmAbrechnungHandling
Dim dt As DataTable
Dim HandlingList As cHandlingssaetzeInternLIST
Dim title As String
Public Sub New(dt As DataTable, HandlingList As VERAG_PROG_ALLGEMEIN.cHandlingssaetzeInternLIST, title As String)
InitializeComponent()
Me.dt = dt
Me.HandlingList = HandlingList
Me.title = title
End Sub
Private Sub frmAbrechnungHandling_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If dt.Rows.Count > 0 Then
dgvHandling.DataSource = dt
End If
Me.Text = title
End Sub
Private Sub btnPreisliste_Click(sender As Object, e As EventArgs) Handles btnPreisliste.Click
If HandlingList.LIST.Count > 0 Then
Dim dt_temp As New DataTable()
Dim props = HandlingList.LIST(0).GetType().GetProperties()
' Create columns automatically
For Each p In props
dt_temp.Columns.Add(p.Name, p.PropertyType)
Next
' Fill rows
For Each item In HandlingList.LIST
Dim row = dt_temp.NewRow()
For Each p In props
row(p.Name) = p.GetValue(item, Nothing)
Next
dt_temp.Rows.Add(row)
Next
dgvHandling.DataSource = dt_temp
VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt_temp)
End If
End Sub
End Class

View File

@@ -841,6 +841,12 @@
</Compile>
<Compile Include="cSqlDb.vb" />
<Compile Include="Fakturierung\cAutomailversand.vb" />
<Compile Include="Fakturierung\frmAbrechnungHandling.Designer.vb">
<DependentUpon>frmAbrechnungHandling.vb</DependentUpon>
</Compile>
<Compile Include="Fakturierung\frmAbrechnungHandling.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Fakturierung\frmSendEmail.Designer.vb">
<DependentUpon>frmSendEmail.vb</DependentUpon>
</Compile>
@@ -3661,6 +3667,9 @@
<EmbeddedResource Include="Creditsafe\usrcntlVAT_ATEZ.resx">
<DependentUpon>usrcntlVAT_ATEZ.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Fakturierung\frmAbrechnungHandling.resx">
<DependentUpon>frmAbrechnungHandling.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Fakturierung\frmSendEmail.resx">
<DependentUpon>frmSendEmail.vb</DependentUpon>
</EmbeddedResource>

View File

@@ -1645,12 +1645,13 @@ Public Class usrCntlSpeditionsBuchSuche
End Sub
Function getrHandlingAussenstellen(ByRef year As Integer, ByRef dtAbrechnung As DataTable, Optional showDok As Boolean = True, Optional Handlingssatz As String = "", Optional whereOpt As String = "", Optional ignoreFiliale As Boolean = False) 'Firma As String, kdnrTmp As Integer, Optional showDok As Boolean = False, Optional ByRef VBNr As Integer = -1) As String
Function getrHandlingAussenstellen(ByRef ab_datum As Date, ByRef dtAbrechnung As DataTable, ByRef HandlingList As VERAG_PROG_ALLGEMEIN.cHandlingssaetzeInternLIST, Optional showDok As Boolean = True, Optional Handlingssatz As String = "", Optional whereOpt As String = "", Optional ignoreFiliale As Boolean = False) 'Firma As String, kdnrTmp As Integer, Optional showDok As Boolean = False, Optional ByRef VBNr As Integer = -1) As String
Dim displayFilter = cbxFilterInBericht.Checked
If ignoreFiliale Or VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("ZOLL_Auswertungen", "SDL") Then
Dim sqlstr As String = ""
Dim dtAbrechnungLocal As DataTable = dtAbrechnung
Dim HandlingListLocal As VERAG_PROG_ALLGEMEIN.cHandlingssaetzeInternLIST = HandlingList
Dim sql_KdAuftragsNr = ""
sqlstr &= " SELECT Speditionsbuch.*,Abfertigungsbezeichnung"
@@ -1673,9 +1674,7 @@ Public Class usrCntlSpeditionsBuchSuche
If showDok Then
If vbYes = MsgBox("Möchten Sie den Bericht ZUSÄTZLICH als Excel exportieren?", vbYesNoCancel) Then
cProgramFunctions.genExcelFromDT_NEW(dt,,, header)
End If
End If
@@ -1690,8 +1689,8 @@ Public Class usrCntlSpeditionsBuchSuche
Case "IMEX" : rpt.picVERAG.Image = My.Resources.IMEX_LOGO_simple : rpt.Label28.Text = "IMEX Customs Service GmbH"
Case "ATILLA" : rpt.picVERAG.Image = My.Resources.Atilla : rpt.Label28.Text = "ATILLA Spedition"
Case "AMBAR" : rpt.picVERAG.Image = My.Resources.ambar_simple : rpt.Label28.Text = "AMBAR Logistc Services GmbH" : print.Text = "Handling / AMBAR Bad Reichenhall"
Case Else
If lstFiliale._value <> "" Then print.Text = "Handling / " & lstFiliale._value
End Select
rpt.DataSource = dt
@@ -1712,11 +1711,10 @@ Public Class usrCntlSpeditionsBuchSuche
Dim sum = 0
rpt.lblSachbearbeiter.Text = VERAG_PROG_ALLGEMEIN.cAllgemein.USRNAME
Dim defaultHandlingPreis As Double = 15
Dim defaultHandlingPreis As Double = 15 'der fallback vom fallback!
Dim HandlingList As VERAG_PROG_ALLGEMEIN.cHandlingssaetzeInternLIST = Nothing
If Handlingssatz <> "" Then
HandlingList = New VERAG_PROG_ALLGEMEIN.cHandlingssaetzeInternLIST(Handlingssatz, year)
HandlingListLocal = New VERAG_PROG_ALLGEMEIN.cHandlingssaetzeInternLIST(Handlingssatz, ab_datum)
End If
rpt.lblDat.Text = Now.ToLongDateString
@@ -1770,7 +1768,7 @@ Public Class usrCntlSpeditionsBuchSuche
' If IsNumeric(checkNull(rpt.Fields.Item("Rechnungsbetrag").Value)) Then rg = CDbl(rpt.Fields.Item("Rechnungsbetrag").Value())
If IsNumeric(checkNull(rpt.Fields.Item("Abfertigungsanzahl").Value)) Then anz = CDbl(rpt.Fields.Item("Abfertigungsanzahl").Value)
Dim Abfertigungsart = checkNull(rpt.Fields.Item("Abfertigungsart").Value)
handling = getHandlingKostByListe(Abfertigungsart, defaultHandlingPreis, HandlingList) * anz
handling = getHandlingKostByListe(Abfertigungsart, defaultHandlingPreis, HandlingListLocal) * anz
' rpt.lblLKWNr.Text = checkNull(rpt.Fields.Item("LKW Kennzeichen").Value)
rpt.lblAnzahl.Text = checkNull(rpt.Fields.Item("Abfertigungsanzahl").Value)
@@ -1900,6 +1898,7 @@ Public Class usrCntlSpeditionsBuchSuche
dtAbrechnungLocal = dt_summen.Copy()
End If
dtAbrechnung = dtAbrechnungLocal
HandlingList = HandlingListLocal
print.Show()
Else
@@ -1914,6 +1913,7 @@ Public Class usrCntlSpeditionsBuchSuche
dtAbrechnungLocal = dt_summen.Copy()
End If
dtAbrechnung = dtAbrechnungLocal
HandlingList = HandlingListLocal
Return tmpPath
End If
@@ -1930,6 +1930,7 @@ Public Class usrCntlSpeditionsBuchSuche
If HandlingList IsNot Nothing AndAlso HandlingList.LIST IsNot Nothing Then
For Each h In HandlingList.LIST
If h.hs_Abfertigungsart = AbfertigungsArt Then Return h.hs_Preis
If IsDBNull(h.hs_Abfertigungsart) Then Return h.hs_Preis
If h.hs_Abfertigungsart Is Nothing Then defaultHandlingPreis = h.hs_Preis
Next
End If
@@ -2146,7 +2147,8 @@ Public Class usrCntlSpeditionsBuchSuche
Exit Sub
End If
Dim dtAbrechnung As New DataTable
getrHandlingAussenstellen(CDate(txtAbfertDat.Text).Year, dtAbrechnung, Not cbxHandlingAbrechnen.Checked, cboHandlingssatz.Text.Trim)
Dim HandlingList As VERAG_PROG_ALLGEMEIN.cHandlingssaetzeInternLIST = Nothing
Dim anhang = getrHandlingAussenstellen(CDate(txtAbfertDat.Text), dtAbrechnung, HandlingList, Not cbxHandlingAbrechnen.Checked, cboHandlingssatz.Text.Trim,,)
If cbxHandlingAbrechnen.Checked Then
@@ -2155,7 +2157,7 @@ Public Class usrCntlSpeditionsBuchSuche
Exit Sub
End If
createHandlingAbrechnung(dtAbrechnung, cboHandlingssatz.Text.Trim, cboHandlingssatz._value, CInt(lstFiliale._value), CDate(txtAbfertDat.Text), CDate(txtAbfertDatBis.Text))
createHandlingAbrechnung(dtAbrechnung, cboHandlingssatz.Text.Trim, cboHandlingssatz._value, CInt(lstFiliale._value), CDate(txtAbfertDat.Text), CDate(txtAbfertDatBis.Text), anhang, HandlingList)
End If
End Sub
@@ -2885,7 +2887,8 @@ Public Class usrCntlSpeditionsBuchSuche
End Select
where &= " and Grenzstelle='AMB' "
Dim dtAbrechnung As New DataTable
getrHandlingAussenstellen(CDate(txtAbfertDat.Text).Year, dtAbrechnung, Not cbxHandlingAbrechnen.Checked, "AMBAR an ALL", where, True)
Dim HandlingList As VERAG_PROG_ALLGEMEIN.cHandlingssaetzeInternLIST = Nothing
Dim anhang_path = getrHandlingAussenstellen(CDate(txtAbfertDat.Text), dtAbrechnung, HandlingList, Not cbxHandlingAbrechnen.Checked, "AMBAR an ALL", where, True)
If cbxHandlingAbrechnen.Checked Then
If lstFiliale.SelectedItems.Count > 1 Then
@@ -2893,7 +2896,7 @@ Public Class usrCntlSpeditionsBuchSuche
Exit Sub
End If
createHandlingAbrechnung(dtAbrechnung, MyComboBox2._value, MyComboBox2._value, lstFiliale._value, CDate(txtAbfertDat.Text), CDate(txtAbfertDatBis.Text))
createHandlingAbrechnung(dtAbrechnung, MyComboBox2._value, MyComboBox2._value, lstFiliale._value, CDate(txtAbfertDat.Text), CDate(txtAbfertDatBis.Text), anhang_path, HandlingList)
End If
End Sub
@@ -2919,7 +2922,7 @@ Public Class usrCntlSpeditionsBuchSuche
End Sub
Private Shared Function createHandlingAbrechnung(dt As DataTable, title As String, anFirma As String, filiale As Integer, von As Date, bis As Date) As Boolean
Private Shared Function createHandlingAbrechnung(dt As DataTable, title As String, anFirma As String, filiale As Integer, von As Date, bis As Date, anhang_path As String, HandlingList As VERAG_PROG_ALLGEMEIN.cHandlingssaetzeInternLIST) As Boolean
Try
@@ -2932,126 +2935,39 @@ Public Class usrCntlSpeditionsBuchSuche
Using frm As New Form
Using dgv As New DataGridView
Using pnlBottom As New Panel
Using btnOk As New Button
Using btnCancel As New Button
Using frm As New frmAbrechnungHandling(dt, HandlingList, "Handling " & anFirma & " " & title)
' =========================
' FORM
' =========================
frm.Text = anFirma & " Handling-Abrechnung - PL:" & title
frm.StartPosition = FormStartPosition.CenterScreen
frm.Size = New Size(1400, 900)
frm.BackColor = Color.White
frm.Font = New Font("Segoe UI", 10)
If frm.ShowDialog() = DialogResult.OK Then
Dim kdNr As Integer = -1
Select Case anFirma.Trim()
Case "UNISPED" : kdNr = 704028
Case "IMEX" : kdNr = 550574
Case "AMBAR" : kdNr = 725012
Case Else
MsgBox("falscher Kunde!")
Return False
End Select
' =========================
' DATAGRIDVIEW
' =========================
dgv.DataSource = dt
dgv.Dock = DockStyle.Fill
dgv.ReadOnly = True
dgv.MultiSelect = True
dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
dgv.AllowUserToAddRows = False
dgv.AllowUserToDeleteRows = False
dgv.AllowUserToResizeRows = False
dgv.RowHeadersVisible = False
dgv.BackgroundColor = Color.White
dgv.BorderStyle = BorderStyle.None
dgv.EnableHeadersVisualStyles = False
Dim counter = 0
' Header Style
dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(45, 45, 48)
dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
dgv.ColumnHeadersDefaultCellStyle.Font = New Font("Segoe UI", 10, FontStyle.Bold)
dgv.ColumnHeadersHeight = 40
' Row Style
dgv.DefaultCellStyle.SelectionBackColor = Color.FromArgb(0, 120, 215)
dgv.DefaultCellStyle.SelectionForeColor = Color.White
dgv.DefaultCellStyle.Font = New Font("Segoe UI", 10)
dgv.RowTemplate.Height = 32
dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(245, 245, 245)
Dim fi As New System.IO.FileInfo(anhang_path)
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "ANHÄNGE", anFirma.Trim(), bis.ToShortDateString, "", fi.Name,)
If Not DS.uploadDataToDATENSERVER(anhang_path, fi.Name, fi.Extension,,,, True) Then
MsgBox("Fehler beim Speichern: Datenserver! :" & anFirma.Trim())
End If
' =========================
' BUTTON PANEL
' =========================
pnlBottom.Dock = DockStyle.Bottom
pnlBottom.Height = 60
pnlBottom.Padding = New Padding(10)
pnlBottom.BackColor = Color.WhiteSmoke
For Each row As DataGridViewRow In frm.dgvHandling.SelectedRows
' OK BUTTON
btnOk.Text = "Rechnung erstellen"
btnOk.Width = 180
btnOk.Height = 35
btnOk.Anchor = AnchorStyles.Right
btnOk.BackColor = Color.FromArgb(0, 120, 215)
btnOk.ForeColor = Color.White
btnOk.FlatStyle = FlatStyle.Flat
btnOk.FlatAppearance.BorderSize = 0
btnOk.DialogResult = DialogResult.OK
doRechnung(filiale, kdNr, row.Cells("Grenzstelle").Value, row.Cells("Anzahl").Value, von, bis, row.Cells("HANDLING").Value, row.Cells("zu_kassieren_BAR").Value, counter, DS, anFirma.Trim())
' CANCEL BUTTON
btnCancel.Text = "Abbrechen"
btnCancel.Width = 120
btnCancel.Height = 35
btnCancel.Left = btnOk.Right + 10
btnCancel.BackColor = Color.LightGray
btnCancel.FlatStyle = FlatStyle.Flat
btnCancel.DialogResult = DialogResult.Cancel
Next
' Position Buttons
btnCancel.Dock = DockStyle.Right
btnOk.Dock = DockStyle.Right
MsgBox("Es wurden " & counter & " Belege erstellt!")
pnlBottom.Controls.Add(btnCancel)
pnlBottom.Controls.Add(btnOk)
Return True
End If
' =========================
' ADD CONTROLS
' =========================
frm.Controls.Add(dgv)
frm.Controls.Add(pnlBottom)
frm.AcceptButton = btnOk
frm.CancelButton = btnCancel
' =========================
' SHOW FORM
' =========================
If frm.ShowDialog() = DialogResult.OK Then
Dim kdNr As Integer = -1
Select Case anFirma.Trim()
Case "UNISPED" : kdNr = 704028
Case "IMEX" : kdNr = 550574
Case "AMBAR" : kdNr = 725012
Case Else
MsgBox("falscher Kunde!")
Return False
End Select
Dim counter = 0
For Each row As DataGridViewRow In dgv.SelectedRows
doRechnung(filiale, kdNr, row.Cells("Grenzstelle").Value, row.Cells("Anzahl").Value, von, bis, row.Cells("HANDLING").Value, row.Cells("zu_kassieren_BAR").Value, counter)
Next
MsgBox("Es wurden " & counter & " Belege erstellt!")
Return True
End If
End Using
End Using
End Using
End Using
End Using
Return False
@@ -3069,7 +2985,7 @@ Public Class usrCntlSpeditionsBuchSuche
End Function
Private Shared Function doRechnung(filiale As Integer, kdNr As Integer, grenzstelle As String, Anzahl As Integer, von As Date, bis As Date, AB_Handling As Double, AB_Handling_BAR As Double, ByRef counter As Integer) As Boolean
Private Shared Function doRechnung(filiale As Integer, kdNr As Integer, grenzstelle As String, Anzahl As Integer, von As Date, bis As Date, AB_Handling As Double, AB_Handling_BAR As Double, ByRef counter As Integer, ByRef DS As cDATENSERVER, ByRef an_firma As String) As Boolean
Dim verarbOK As Boolean = True
Dim AbfertigungNr As Integer = 0
@@ -3095,7 +3011,7 @@ Public Class usrCntlSpeditionsBuchSuche
If bruttobetrag <> 0 AndAlso nettobetrag <> 0 Then
If Not gen_SPEDBUCH_ByKdNr(kdNr, SPEDBUCH, filiale, AbfertigungNr, Anzahl, von, bis) Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(kdNr, SPEDBUCH, RK_ID, grenzstelle, isGutschrift, nettobetrag, bruttobetrag, Ust) Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(kdNr, SPEDBUCH, RK_ID, grenzstelle, isGutschrift, nettobetrag, bruttobetrag, Ust, DS, an_firma) Then verarbOK = False
If verarbOK Then
counter += 1
End If
@@ -3169,7 +3085,7 @@ Public Class usrCntlSpeditionsBuchSuche
End Function
Private Shared Function gen_RECHNUNG_BySPEDBUCH(KdNr As String, SPEDBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch, ByRef RK_ID As Integer, ByRef grenzstelle As String, isGutschrift As Boolean, Nettobetrag As Double, Bruttobetrag As Double, UstBetrag As Double)
Private Shared Function gen_RECHNUNG_BySPEDBUCH(KdNr As String, SPEDBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch, ByRef RK_ID As Integer, ByRef grenzstelle As String, isGutschrift As Boolean, Nettobetrag As Double, Bruttobetrag As Double, UstBetrag As Double, DS As cDATENSERVER, firma_an As String)
Try
If KdNr = "" Then Return False
@@ -3280,12 +3196,12 @@ Public Class usrCntlSpeditionsBuchSuche
Dim useNettogesamtbetrag As Boolean = False
Dim OFFERTE As New VERAG_PROG_ALLGEMEIN.cOfferte(KdNr, OffertenNr, True)
RG.LOAD_OFFERT_POSITIONEN() ' --> OFFERTE MIT ANZAHL >0 und Preis >0
' RG.LOAD_OFFERT_POSITIONEN() ' --> OFFERTE MIT ANZAHL >0 und Preis >0
If isGutschrift Then
allPos(RG, OFFERTE, 496, Nettobetrag, Bruttobetrag, UstBetrag, "Barinkasso Handling " & grenzstelle)
allPos(RG, OFFERTE, 496, Nettobetrag, Bruttobetrag, UstBetrag, "Barinkasso Handling")
Else
allPos(RG, OFFERTE, 345, Nettobetrag, Bruttobetrag, UstBetrag, "Handling " & grenzstelle)
allPos(RG, OFFERTE, 345, Nettobetrag, Bruttobetrag, UstBetrag, "Handling")
End If
Dim dtSt As DataTable = (New SQL).loadDgvBySql("SELECT TOP 1 isnull([Steuersatz %],0),isnull([Steuerbezeichnung],'') FROM [Steuertabelle] WHERE [Steuerschlüssel]='" & RG.Steuerschlüssel & "'", "FMZOLL")
@@ -3297,8 +3213,15 @@ Public Class usrCntlSpeditionsBuchSuche
RG.Text = (cFakturierung.przRechnungstextTXT(RG, SPEDBUCH) & vbNewLine & cFakturierung.przRechnungstextZZ(RG)).Trim
Dim ANH As New VERAG_PROG_ALLGEMEIN.cRechnungsausgangAnhaenge
ANH.dsId = CInt(DS.da_id)
ANH.Bezeichnung = CDate(SPEDBUCH.Abfertigungsdatum).ToShortDateString & "_" & firma_an & "_Handling"
RG.ANHAENGE.Add(ANH)
If RG.SAVE Then
RK_ID = RG.RK_ID
Return True
Else
Return False

View File

@@ -5,46 +5,98 @@ Imports System.Data.SqlClient
Public Class cHandlingssaetzeInternLIST
Property hs_Bezeichnung As Object = Nothing
Property hs_jahr As Object = Nothing
Property hs_datum As Object = Nothing
' Property OffertenNr As Object = Nothing
Public LIST As New List(Of cHandlingssaetzeIntern)
Dim SQL As New SQL
'Dim listTodelete As New List(Of cHandlingssaetzeIntern)
Sub New(hs_Bezeichnung, hs_jahr)
Sub New(hs_Bezeichnung, hs_datum)
Me.hs_Bezeichnung = hs_Bezeichnung
Me.hs_jahr = hs_jahr
Me.hs_datum = hs_datum
' Me.OffertenNr = OffertenNr
LOAD_LIST(Me.hs_Bezeichnung, Me.hs_jahr)
LOAD_LIST_DATUM(Me.hs_Bezeichnung, Me.hs_datum)
End Sub
Sub New(hs_Bezeichnung)
Me.hs_Bezeichnung = hs_Bezeichnung
LOAD_LIST(Me.hs_Bezeichnung)
End Sub
Public Sub CLEAR()
LIST.Clear()
End Sub
Public Sub LOAD_LIST(hs_Bezeichnung, Jahr)
Dim SQLString = " AND ISNULL(hs_gueltigAbJahr, " & Jahr & ") =
CASE
WHEN EXISTS (
SELECT 1
FROM [VERAG].[dbo].[tblHandlingssaetzeIntern]
WHERE hs_Bezeichnung = @hs_Bezeichnung
AND ISNULL(hs_gueltigAbJahr, " & Jahr & ") = " & Jahr & "
)
THEN 2023
ELSE (
SELECT MAX(ISNULL(hs_gueltigAbJahr, " & Jahr & "))
FROM [VERAG].[dbo].[tblHandlingssaetzeIntern]
WHERE hs_Bezeichnung = @hs_Bezeichnung
)
END"
Public Sub LOAD_LIST(hs_Bezeichnung)
Try
LIST.Clear()
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("SELECT * FROM tblHandlingssaetzeIntern WHERE hs_Bezeichnung=@hs_Bezeichnung " & SQLString, conn)
Using cmd As New SqlCommand("SELECT * FROM tblHandlingssaetzeIntern WHERE hs_Bezeichnung=@hs_Bezeichnung ", conn)
cmd.Parameters.AddWithValue("@hs_Bezeichnung", hs_Bezeichnung)
Dim dr = cmd.ExecuteReader()
While dr.Read
Dim l As New cHandlingssaetzeIntern
For Each i In l.getParameterList()
Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
If dr.Item(i.Text) Is DBNull.Value Then
propInfo.SetValue(l, Nothing)
Else
propInfo.SetValue(l, dr.Item(i.Text))
End If
Next
LIST.Add(l)
End While
dr.Close()
End Using
End Using
Catch ex As Exception
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
End Try
End Sub
Public Sub LOAD_LIST_DATUM(hs_Bezeichnung, ab_datum)
Dim SQLString = ";WITH cte AS (
SELECT *,
ROW_NUMBER() OVER
(
PARTITION BY
hs_Bezeichnung,
hs_Abfertigungsart
ORDER BY
hs_gueltigAbDatum DESC
) AS rn
FROM tblHandlingssaetzeIntern
WHERE isnull(hs_gueltigAbDatum,'01-01-2021') <= @Stichtag AND hs_Bezeichnung = @hs_Bezeichnung
)
SELECT
hs_Bezeichnung,
hs_Abfertigungsart,
hs_Preis,
hs_gueltigAbDatum,
hs_RgVon,
hs_RgAn
FROM cte
WHERE rn = 1
ORDER BY
hs_Bezeichnung,
hs_Abfertigungsart desc;"
Try
LIST.Clear()
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand(SQLString, conn)
cmd.Parameters.AddWithValue("@hs_Bezeichnung", hs_Bezeichnung)
cmd.Parameters.AddWithValue("@Stichtag", CDate(ab_datum))
' cmd.Parameters.AddWithValue("@OffertenNr", OffertenNr)
Dim dr = cmd.ExecuteReader()
While dr.Read
@@ -68,6 +120,7 @@ Public Class cHandlingssaetzeInternLIST
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
End Try
End Sub
'Function SAVE()
' If SQL.doSQLVarList("DELETE FROM tblEmailBenachrichtigung WHERE eb_KundenNr=" & Me.eb_KundenNr & " and eb_ebartId=" & Me.eb_ebartId & " ", "FMZOLL") Then
' For Each l In LIST