Files
SDL/SDL/Formulare/KDFormulare/FormulareBaukasten/usrCntlQualitaetskontrolle.vb

531 lines
23 KiB
VB.net

Imports DAKOSY_Worker.DEXPSD
Imports DocumentFormat.OpenXml.Drawing.Diagrams
Imports VERAG_PROG_ALLGEMEIN
Public Class usrCntlQualitaetskontrolle
Implements FormualrInterface
Public Event CHANGED(name, value)
Public Event KDNR_CHANGED(kdnr)
Public Event DELETE(c As Control)
Public Event MOVE_UP(c As Control)
Public Event MOVE_DOWN(c As Control)
Dim FV_ID = -1
Public KdNR As Integer = -1
Public KdFirma As String = ""
Public SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen = Nothing
Public AVISO As VERAG_PROG_ALLGEMEIN.cAviso = Nothing
Public EZA_Nr As String
Public CRN As String
Dim packstueckeZOLL_TMP As String = ""
Dim Normen, normenSpeziell, normenAllg As New DataTable
Dim NormenpreisAllg As Double
Dim NormenpreisSpez As Double
Dim EZOLL_SQL = "EZOLL"
Sub New()
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
End Sub
Sub New(param() As Object)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
If param.Length > 0 AndAlso param(0) IsNot Nothing Then KdNR = param(0)
If param.Length > 1 Then KdFirma = param(1)
If param.Length > 2 Then SENDUNG = param(2)
If param.Length > 3 Then AVISO = param(3)
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
End Sub
Public Sub ChangeKDNr(kdnr As Integer) _
Implements FormualrInterface.ChangeKDNr
initKdNR(kdnr)
End Sub
'Dim KdNR As Integer = -1
Sub initControlsHandler()
For Each c In Me.Controls
Select Case c.GetType.ToString
Case GetType(VERAG_PROG_ALLGEMEIN.MyTextBox).ToString
AddHandler DirectCast(c, VERAG_PROG_ALLGEMEIN.MyTextBox).Leave, Sub()
RaiseEvent CHANGED(c.name, c.text)
End Sub
Case GetType(VERAG_PROG_ALLGEMEIN.MyComboBox).ToString
AddHandler DirectCast(c, VERAG_PROG_ALLGEMEIN.MyComboBox).SelectedIndexChanged, Sub()
RaiseEvent CHANGED(c.name, c._value)
End Sub
Case GetType(TextBox).ToString
AddHandler DirectCast(c, TextBox).Leave, Sub()
RaiseEvent CHANGED(c.name, c.text)
End Sub
End Select
Next
End Sub
Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
Dim kdsrch As New SDL.frmKundenSuche
If kdsrch.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
If IsNumeric(kdsrch.kundenNrSearch.Text) Then
initKdNR(kdsrch.kundenNrSearch.Text)
RaiseEvent KDNR_CHANGED(KdNR)
End If
End If
' Panel1.Enabled = True
End Sub
Public Sub initSND()
If SENDUNG IsNot Nothing Then
txtFilialNr.Text = SENDUNG.FilialenNr.ToString
txtAbfNr.Text = SENDUNG.AbfertigungsNr.ToString
txtGewicht.Text &= " kg"
If SENDUNG.tblSnd_AbsenderKdNr > 0 Then
Dim ADRESSE As New VERAG_PROG_ALLGEMEIN.cAdressen(SENDUNG.tblSnd_AbsenderKdNr)
txtPackFirma.Text = If(ADRESSE.Name_1, "") & If(If(ADRESSE.Name_2, "") <> "", " " & ADRESSE.Name_2, "")
txtPackAdresse1.Text = If(ADRESSE.Straße, "")
txtPackAdresse2.Text = (If(ADRESSE.LandKz, "") & " " & If(ADRESSE.PLZ, "") & " " & If(ADRESSE.Ort, "")).ToString.Trim
Else
txtPackFirma.Text = SENDUNG.tblSnd_Absender
End If
End If
If AVISO IsNot Nothing Then
txtLKWKennz.Text = If(AVISO.LKW_Nr, "")
End If
End Sub
Public Sub initKdNR(KdNR)
If KdNR > 0 Then
Me.KdNR = KdNR
Dim KUNDE As New VERAG_PROG_ALLGEMEIN.cKunde(KdNR)
Dim ADRESSE As New VERAG_PROG_ALLGEMEIN.cAdressen(KdNR)
txtFirma.Text = If(ADRESSE.Name_1, "") & If(If(ADRESSE.Name_2, "") <> "", " " & ADRESSE.Name_2, "")
txtAdresse1.Text = If(ADRESSE.Straße, "")
txtAdresse2.Text = (If(ADRESSE.LandKz, "") & " " & If(ADRESSE.PLZ, "") & " " & If(ADRESSE.Ort, "")).ToString.Trim
' txtAnsprechpartnerVERAG.Text = If(ADRESSE.Ansprechpartner, "")
Else
txtFirma.Text = KdFirma
End If
End Sub
Private Sub btnDel_Click(sender As Object, e As EventArgs) Handles btnDel.Click
RaiseEvent DELETE(Me)
End Sub
Private Sub btnup_Click(sender As Object, e As EventArgs) Handles btnUp.Click
RaiseEvent MOVE_UP(Me)
End Sub
Private Sub btnDown_Click(sender As Object, e As EventArgs) Handles btnDown.Click
RaiseEvent MOVE_DOWN(Me)
End Sub
Private Sub usrCntlZollbeschau_Load(sender As Object, e As EventArgs) Handles Me.Load
EZOLL_SQL = "EZOLL"
Select Case VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA
Case "UNISPED" : EZOLL_SQL = "EZOLL_UNISPED"
End Select
initControlsHandler()
'txtAnsprechpartnerVERAG.Text = VERAG_PROG_ALLGEMEIN.cAllgemein.USRNAME
txtBeschauDat.Text = Date.Today.ToString("dd.MM.yyyy")
cbxEinf.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Einfuhr", "E"))
cbxEinf.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Ausfuhr", "A"))
cbxEinf.changeItem("E")
cbxTyp.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Obst und Gemüse", "O"))
cbxTyp.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Bananen", "B"))
cbxTyp.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Eier und Gefl.", "E"))
cboZollstelle.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("ZA Österreich / Zst Nickelsdorf", "NKD"))
cboZollstelle.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("ZA Österreich / Zst Spielfeld", "SFD"))
' cboZollstelle.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("ZA Österreich / Zst Salzburg", "SBG"))
' cboZollstelle.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("ZA Österreich / Zst Suben", "SUB"))
cboZollstelle.changeItem("NKD")
cbxUrsprungslang.fillWithSQL("SELECT [Länderverzeichnis für die Außenhandelsstatistik].LandKz, [Länderverzeichnis für die Außenhandelsstatistik].LandBez FROM [Länderverzeichnis für die Außenhandelsstatistik] ORDER BY [Länderverzeichnis für die Außenhandelsstatistik].LandKz; ", True, "VERAG", True)
cbxBestimmungsland.Items.AddRange(cbxUrsprungslang.Items.Cast(Of VERAG_PROG_ALLGEMEIN.MyListItem).ToArray())
If SENDUNG IsNot Nothing Then
If SENDUNG.tblSnd_DakosyRef <> "" Then
loadEZollData(SENDUNG.tblSnd_DakosyRef)
ElseIf SENDUNG.FilialenNr > 0 AndAlso SENDUNG.AbfertigungsNr > 0 Then
Dim ref = SENDUNG.FilialenNr.ToString & "/" & SENDUNG.AbfertigungsNr.ToString
loadEZollData(ref)
End If
End If
initKdNR(KdNR)
initSND()
Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
Normen = sql.loadDgvBySql("select * from tblVermarktungsnormen", "FMZOLL")
Dim dvAllgNormen = New DataView(Normen)
Dim dvSpezNormen = New DataView(Normen)
dvSpezNormen.RowFilter = "speziell = true"
dvAllgNormen.RowFilter = "speziell = false"
normenSpeziell = dvSpezNormen.ToTable
normenAllg = dvAllgNormen.ToTable
NormenpreisAllg = CDbl(sql.getValueTxtBySql("select top(1) betrag FROM tblVermarktungsnormenGebuehren where gueltigAb <= GETDATE() and [speziell] = 0 order by gueltigAb desc", "FMZOLL"))
NormenpreisSpez = CDbl(sql.getValueTxtBySql("select top(1) betrag FROM tblVermarktungsnormenGebuehren where gueltigAb <= GETDATE() and [speziell] = 1 order by gueltigAb desc", "FMZOLL"))
End Sub
Private Sub pic_Click(sender As Object, e As EventArgs) Handles pic.Click
FormularManagerNEU.genPDF(Me, True)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If KdNR > 0 Then
Dim f As New frmKundenUebersichtZOLL(KdNR)
f.ShowDialog(Me)
End If
End Sub
Private Sub dtpBeschauDat_ValueChanged(sender As Object, e As EventArgs) Handles dtpBeschauDat.ValueChanged
txtBeschauDat._value = CDate(sender.value).ToShortDateString
End Sub
Private Sub loadDGV(dt As DataTable)
Dim couter As Integer = 1
For Each row As DataRow In dt.Rows
dgvPositionen.Rows.Add(row("ItNr"), row("Nr"), row("Kind"), row("GdsDes"), row("Net"), row("ComCd"))
couter = +1
Next
End Sub
Private Sub dgvPositionen_DefaultValuesNeeded(sender As Object, e As DataGridViewRowEventArgs) Handles dgvPositionen.DefaultValuesNeeded
e.Row.Cells("pos").Value = dgvPositionen.Rows.Count
End Sub
Private Sub loadEZollData(EZA_Nr As String)
Dim KDSQL As New SQL
Dim notFound As Boolean = True
'EZA_Nr = "4/23208/15"
Try
txtLRN.Text = EZA_Nr
Dim dEZOLL As DataTable = KDSQL.loadDgvBySql("SELECT LizenzNr, OperatorID, VorgangID, AnmID, GeaendertAm, GeaendertVon, CRN, LRN" &
" FROM zsAnmRefs" &
" WHERE (VorgangID = 'EF') AND (LRN = '" & EZA_Nr & "')" &
" ORDER BY GeaendertAm DESC", EZOLL_SQL)
If dEZOLL Is Nothing Then MsgBox("Keine Daten im EZOLL vorhanden, Daten können nicht geladen werden!") : Exit Sub
If dEZOLL.Rows.Count = 0 Then MsgBox("Keine Daten im EZOLL vorhanden, Daten können nicht geladen werden!") : Exit Sub
Dim DR_zsAnmRefs As DataRow = dEZOLL.Rows(0)
notFound = False
If DR_zsAnmRefs.Item("CRN") IsNot DBNull.Value Then CRN = DR_zsAnmRefs.Item("CRN")
Dim DTzsAnmTransp As DataTable = KDSQL.loadDgvBySql("SELECT DepIdnt, DepNat, CrossIdntNat" &
" FROM zsAnmTransp" &
" WHERE (LizenzNr = '" & DR_zsAnmRefs.Item("LizenzNr") & "') And (OperatorID = " & DR_zsAnmRefs.Item("OperatorID") & ") And (VorgangID = '" & DR_zsAnmRefs.Item("VorgangID") & "') And (AnmID = " & DR_zsAnmRefs.Item("AnmID") & ")", EZOLL_SQL)
If DTzsAnmTransp IsNot Nothing AndAlso DTzsAnmTransp.Rows().Count > 0 Then
If Not IsNull(DTzsAnmTransp.Rows(0).Item("DepIdnt")) Then txtLKWKennz.Text = Strings.Left(DTzsAnmTransp.Rows(0).Item("DepIdnt"), 25)
If Not IsNull(DTzsAnmTransp.Rows(0).Item("DepNat")) Then cbxBestimmungsland.changeItem(DTzsAnmTransp.Rows(0).Item("DepNat"))
' If Not IsNull(DTzsAnmTransp.Rows(0).Item("CrossIdntNat")) Then cbxUrsprungslang.changeItem(DTzsAnmTransp.Rows(0).Item("CrossIdntNat"))
End If
' Tabelle zsAnmConorTra lesen.
Dim DTzsAnmConorTra As DataTable = KDSQL.loadDgvBySql("SELECT Na, Pst, Cty,Strt, Ctry" &
" FROM zsAnmConorTra" &
" WHERE (LizenzNr = '" & DR_zsAnmRefs.Item("LizenzNr") & "') And (OperatorID = " & DR_zsAnmRefs.Item("OperatorID") & ") And (VorgangID = '" & DR_zsAnmRefs.Item("VorgangID") & "') And (AnmID = " & DR_zsAnmRefs.Item("AnmID") & ")", EZOLL_SQL)
If DTzsAnmConorTra IsNot Nothing AndAlso DTzsAnmConorTra.Rows().Count > 0 Then
If SENDUNG Is Nothing OrElse SENDUNG.tblSnd_AbsenderKdNr <= 0 Then
If Not IsNull(DTzsAnmConorTra.Rows(0).Item("Na")) Then txtPackFirma.Text = Strings.Left(DTzsAnmConorTra.Rows(0).Item("Na"), 50)
If Not IsNull(DTzsAnmConorTra.Rows(0).Item("Pst")) Then
txtPackAdresse1.Text = ""
txtPackAdresse2.Text = ""
If Not IsNull(DTzsAnmConorTra.Rows(0).Item("Strt")) Then txtPackAdresse1.Text &= Strings.Left(DTzsAnmConorTra.Rows(0).Item("Strt"), 50) & " "
If Not IsNull(DTzsAnmConorTra.Rows(0).Item("Ctry")) Then txtPackAdresse2.Text &= Strings.Left(DTzsAnmConorTra.Rows(0).Item("Ctry"), 50) & " "
If Not IsNull(DTzsAnmConorTra.Rows(0).Item("Pst")) Then txtPackAdresse2.Text &= Strings.Left(DTzsAnmConorTra.Rows(0).Item("Pst"), 50) & " "
If Not IsNull(DTzsAnmConorTra.Rows(0).Item("Cty")) Then txtPackAdresse2.Text &= Strings.Left(DTzsAnmConorTra.Rows(0).Item("Cty"), 50) & " "
End If
End If
If Not IsNull(DTzsAnmConorTra.Rows(0).Item("Ctry")) Then cbxUrsprungslang.changeItem(DTzsAnmConorTra.Rows(0).Item("Ctry"))
End If
' Tabelle zsAnmConeeTra lesen.
Dim DTzsAnmConeeTra As DataTable = KDSQL.loadDgvBySql("SELECT Na, Pst, Cty,Strt, Ctry" &
" FROM zsAnmConeeTra" &
" WHERE (LizenzNr = '" & DR_zsAnmRefs.Item("LizenzNr") & "') And (OperatorID = " & DR_zsAnmRefs.Item("OperatorID") & ") And (VorgangID = '" & DR_zsAnmRefs.Item("VorgangID") & "') And (AnmID = " & DR_zsAnmRefs.Item("AnmID") & ")", EZOLL_SQL)
If DTzsAnmConeeTra IsNot Nothing AndAlso DTzsAnmConeeTra.Rows().Count > 0 Then
If SENDUNG Is Nothing OrElse SENDUNG.tblSnd_EmpfaengerKdNr <= 0 Then
If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Na")) Then txtFirma.Text = Strings.Left(DTzsAnmConeeTra.Rows(0).Item("Na"), 50)
If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Pst")) Then
txtAdresse1.Text = ""
txtAdresse2.Text = ""
If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Strt")) Then txtAdresse1.Text &= Strings.Left(DTzsAnmConeeTra.Rows(0).Item("Strt"), 50) & " "
If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Ctry")) Then txtAdresse2.Text &= Strings.Left(DTzsAnmConeeTra.Rows(0).Item("Ctry"), 50) & " "
If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Pst")) Then txtAdresse2.Text &= Strings.Left(DTzsAnmConeeTra.Rows(0).Item("Pst"), 50) & " "
If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Cty")) Then txtAdresse2.Text &= Strings.Left(DTzsAnmConeeTra.Rows(0).Item("Cty"), 50) & " "
End If
End If
'If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Na")) Then SPEDITIONSBUCH.Empfänger = Strings.Left(DTzsAnmConeeTra.Rows(0).Item("Na"), 50)
'If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Ctry")) Then SPEDITIONSBUCH.Empfänger = Strings.Left(SPEDITIONSBUCH.Empfänger & ", " & DTzsAnmConeeTra.Rows(0).Item("Ctry"), 50)
'If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Pst")) Then SPEDITIONSBUCH.Empfänger = Strings.Left(SPEDITIONSBUCH.Empfänger & ", " & DTzsAnmConeeTra.Rows(0).Item("Pst"), 50)
'If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Cty")) Then SPEDITIONSBUCH.Empfänger = Strings.Left(SPEDITIONSBUCH.Empfänger & ", " & DTzsAnmConeeTra.Rows(0).Item("Cty"), 50)
If Not IsNull(DTzsAnmConeeTra.Rows(0).Item("Ctry")) Then cbxBestimmungsland.changeItem(DTzsAnmConeeTra.Rows(0).Item("Ctry"))
End If
' Tabelle zsAnmHea lesen.
Dim DTzsAnmHea As DataTable = KDSQL.loadDgvBySql("SELECT TotItem, TotPack, TotGross" &
" FROM zsAnmHea" &
" WHERE (LizenzNr = '" & DR_zsAnmRefs.Item("LizenzNr") & "') And (OperatorID = " & DR_zsAnmRefs.Item("OperatorID") & ") And (VorgangID = '" & DR_zsAnmRefs.Item("VorgangID") & "') And (AnmID = " & DR_zsAnmRefs.Item("AnmID") & ")", EZOLL_SQL)
If DTzsAnmHea IsNot Nothing AndAlso DTzsAnmHea.Rows().Count > 0 Then
If Not IsNull(DTzsAnmHea.Rows(0).Item("TotPack")) Then txtAnzVerp.Text = DTzsAnmHea.Rows(0).Item("TotPack") 'Gesamt packstücke
If Not IsNull(DTzsAnmHea.Rows(0).Item("TotGross")) Then txtGewicht.Text = DTzsAnmHea.Rows(0).Item("TotGross") ' Gesamtbruttogewicht
If Not IsNull(DTzsAnmHea.Rows(0).Item("TotItem")) Then txtPos.Text = DTzsAnmHea.Rows(0).Item("TotItem") ' Anzahl Pos
End If
berechneDGVSum()
' Tabelle zsAnmGdsitem lesen.
Dim DTzsAnmGdsitem As DataTable = KDSQL.loadDgvBySql("SELECT item.ItNr ,item.GdsDes , item.Net, pack.Kind, pack.Nr, item.Orig, item.ComCd" &
" FROM zsAnmGdsitem as item" &
" INNER JOIN zsAnmGdsItemPack as pack ON item.LizenzNr = pack.LizenzNr And item.OperatorID = pack.OperatorID and item.VorgangID = pack.VorgangID and pack.AnmID = item.AnmID" &
" WHERE (item.LizenzNr = '" & DR_zsAnmRefs.Item("LizenzNr") & "') And (item.OperatorID = " & DR_zsAnmRefs.Item("OperatorID") & ") And (item.VorgangID = '" & DR_zsAnmRefs.Item("VorgangID") & "') And (item.AnmID = " & DR_zsAnmRefs.Item("AnmID") & " and item.GdsItemID = pack.GdsItemID)" &
" ORDER BY item.GdsItemID", EZOLL_SQL)
If DTzsAnmGdsitem IsNot Nothing AndAlso DTzsAnmGdsitem.Rows().Count > 0 Then
loadDGV(DTzsAnmGdsitem)
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR("Fehler EZOLL Personal: " & vbNewLine & ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Function IsNull(o) As Boolean
Try
If o Is Nothing Then Return True
If o Is DBNull.Value Then Return True
If o.ToString.Trim = "" Then Return True
Catch : End Try
Return False
End Function
Function berechneDGVSum() As Boolean
Dim sumPk As Integer = 0
Dim sumKg As Double = 0
Dim sumPos As Integer = 0
For Each r As DataGridViewRow In dgvPositionen.Rows
sumPos += 1
If IsNumeric(r.Cells(1).Value) Then sumPk += r.Cells(1).Value
If IsNumeric(r.Cells(4).Value) Then sumKg += r.Cells(4).Value
Next
txtAnzVerp.Text = sumPk
txtGewicht.Text = sumKg
txtPos.Text = sumPos - 1
End Function
Private Sub dgvPositionen_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles dgvPositionen.CellValueChanged
Dim gewicht As Double = 0
Dim colli As Double = 0
For Each r As DataGridViewRow In dgvPositionen.Rows
If r IsNot Nothing And IsNumeric(r.Cells(4).Value) Then
gewicht += CDbl(r.Cells(4).Value)
End If
If r IsNot Nothing And IsNumeric(r.Cells(1).Value) Then
colli += CDbl(r.Cells(1).Value)
End If
Next
txtGewicht.Text = gewicht & " kg"
txtAnzVerp.Text = colli
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
dgvPositionen.Rows.Clear()
If txtLRN.Text <> "" Then
loadEZollData(txtLRN.Text)
End If
End Sub
Private Sub dgvPositionen_RowsAdded(sender As Object, e As DataGridViewRowsAddedEventArgs) Handles dgvPositionen.RowsAdded
berechneDGVSum()
initdgvGebuehren()
End Sub
Private Sub dgvPositionen_RowsRemoved(sender As Object, e As DataGridViewRowsRemovedEventArgs) Handles dgvPositionen.RowsRemoved
berechneDGVSum()
initdgvGebuehren()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
If dgvGebuehren.Rows.Count = 0 Then Exit Sub
Dim PERSONAL As SDL.cPersonal = Nothing
Dim frmSecureLoginKassenbuch As New SDL.frmSecureLoginKassenbuch
' frmSecureLoginKassenbuch.KassenbuchNr_tmp = PERSONAL.KassenbuchNr
If frmSecureLoginKassenbuch.ShowDialog(Me) = DialogResult.OK Then
PERSONAL = frmSecureLoginKassenbuch.PERSONAL
Dim f As New frmBelegNeu(PERSONAL, Nothing, "E")
AddHandler f.LOADED, Sub()
f.AddPositions(dgvGebuehren, False)
End Sub
f.ShowDialog(Me)
End If
End Sub
Private Sub initdgvGebuehren()
If dgvGebuehren.Rows.Count > 0 Then dgvGebuehren.Rows.Clear()
Dim posVorhanden As Boolean = False
If dgvPositionen.Rows.Count < 1 Then Exit Sub
Dim sumNormenAllg As Double = 0
Dim sumNormenSpez As Double = 0
For Each r As DataGridViewRow In dgvPositionen.Rows
Dim found As Boolean = False
If r IsNot Nothing And IsNumeric(r.Cells(4).Value) AndAlso r.Cells(4).Value >= 1000 Then
posVorhanden = True
If r.Cells(5).Value <> "" Then
For Each row As DataRow In normenSpeziell.Rows
Dim code = row("kncode")
Dim seachedCode = r.Cells(5).Value
seachedCode = seachedCode.ToString.Substring(0, code.Length)
If row("kncode") = seachedCode Then
sumNormenSpez += r.Cells(4).Value
found = True
Exit For
End If
Next
If Not found Then
For Each row As DataRow In normenAllg.Rows
Dim code = row("kncode")
Dim seachedCode = r.Cells(5).Value
If seachedCode = seachedCode.ToString.Substring(0, code.Length) Then
sumNormenAllg += r.Cells(4).Value
found = True
Exit For
End If
Next
End If
End If
End If
Next
If Not posVorhanden Then Exit Sub
If sumNormenAllg > 0 Then
Dim anzAllg As Integer
anzAllg = sumNormenAllg / 1000
dgvGebuehren.Rows.Add("Allgemein", sumNormenAllg, NormenpreisAllg, anzAllg, anzAllg * NormenpreisAllg)
End If
If sumNormenSpez > 0 Then
Dim anzSpez As Integer
anzSpez = sumNormenSpez / 1000
dgvGebuehren.Rows.Add("Speziell", sumNormenSpez, NormenpreisSpez, anzSpez, anzSpez * NormenpreisSpez)
End If
Dim antrag, verzicht, idk As Double
antrag = 40.7
verzicht = 9.3
idk = 39.4
If cbxVerzicht.Checked Then
dgvGebuehren.Rows.Clear()
dgvGebuehren.Rows.Add("Antrag", "", antrag, "", antrag)
dgvGebuehren.Rows.Add("Verzicht", "", verzicht, "", verzicht)
Else
dgvGebuehren.Rows.Add("Antrag", "", antrag, "", antrag)
dgvGebuehren.Rows.Add("Identitätskontrolle", "", idk, "", idk)
End If
Dim sumBetrag As Double = 0
For Each r As DataGridViewRow In dgvGebuehren.Rows
If IsNumeric(r.Cells(4).Value) Then sumBetrag += r.Cells(4).Value
Next
txtSumme.Text = CDbl(sumBetrag)
End Sub
Private Sub cbxVerzicht_CheckedChanged(sender As Object, e As EventArgs) Handles cbxVerzicht.CheckedChanged
initdgvGebuehren()
End Sub
End Class