Files
AVISO/Aviso/frmGesamtsicherheitenNEU.vb

1988 lines
75 KiB
VB.net

Imports System.Web.UI.WebControls.Expressions
Imports VERAG_PROG_ALLGEMEIN
Public Class frmGesamtsicherheitenNEU
Property currentSicherheit As cSicherheiten
Property currentSPos As cGesamtsicherheitsPositionen
Property currentGesSichRef As cAufschubKonten
Public Property gessicherheitID As Integer
Public Property prevGessicherheitID As Integer
Public Property nextGessicherheitID As Integer
Public Property datum As DateTime = Nothing
Property Standort As String = ""
Public ZollsatzMulti As Double = 0
Public Zollsatz As Double
Public SaldoNew As Double = 0
Public Neu As Boolean = False
Public FilialNummer As Integer
Public Abfertigungsnummer As String
Public LKWKZ As String
Public warenortID As String
Public avisoID As Integer
Dim indexGsId As Integer
Dim indexGsNr As Integer
Dim indexGspPosId As Integer
Dim isOpen As Boolean = False
Dim rundungsdiff As Double = 0
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Public dataTable As New DataTable()
Public dtSicherheiten As New DataTable()
Public firmaId As Integer
Private Sub frmGesamtsicherheitNEU_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("GESAMTSICHERHEIT_RUNDUNGSKORREKTUR", "AVISO") Then
btnRundungsdifAusgl.Visible = True
cbxRundPosanzeigen.Visible = True
Else
btnRundungsdifAusgl.Visible = False
cbxRundPosanzeigen.Visible = False
End If
currentGesSichRef = New VERAG_PROG_ALLGEMEIN.cAufschubKonten(Standort)
SaldoNew = Decimal.Parse(currentGesSichRef.CalcSaldo())
lblSaldo.Text = "Saldo: €" & SaldoNew.ToString("N")
Me.Text = "Gesamtsicherheit " & Standort
If setNullToZero(gessicherheitID) = "" Or Neu = True Then
panOben.Enabled = False : panOben.Enabled = False
Panel1.Enabled = True
panOverlay.Visible = True
cboFiliale.fillWithSQL("SELECT FilialenNr, cast(FilialenNr as varchar(4)) + ' ' + Grenzstelle FROM Filialen WHERE Fil_Status='A' ORDER BY FilialenNr ", True, "FMZOLL", True)
cboWarenort.fillWithSQL("SELECT [wo_warenort],CONCAT([wo_bezeichnung],' - ' ,[wo_knnr]) FROM [tblWarenorte] WHERE [wo_aktiv] = 1 AND [wo_firma] = " & firmaId & " AND wo_ze = 1 ORDER BY [wo_reihenfolge] ", True, "AVISO", True)
If datum = Nothing Then datum = Date.Now
nextGessicherheitID = -1
prevGessicherheitID = -1
txtlkwIdSearch.initSearchBox(Me.FindForm, " LKW_Nr, AvisoID, CAST(Datum as Date) as Datum FROM [Aviso]", {"LKW_Nr", "AvisoID", "Datum"}, "", "Datum desc", "LKW_Nr", "AvisoID", "AVISO",, 250, 200)
If Standort = "AMBAR GmbH" Then
For i As Integer = 0 To cboFiliale.Items.Count - 1
If cboFiliale.Items(i).ToString().Contains("5701") Then
cboFiliale.SelectedIndex = i
Exit For
End If
Next
For i As Integer = 0 To cboWarenort.Items.Count - 1
If cboWarenort.Items(i).ToString().Contains("AMBAR") Then
cboWarenort.SelectedIndex = i
Exit For
End If
Next
End If
Else
LoadDGVSicherheiten(True)
End If
LoadStandort()
cboSicherheitATR.Enabled = currentGesSichRef.brgakto_gs_ATR
cbx_offene.Checked = True
initPrevNextButtons()
changeLabel()
Me.Text = "Gesamtsicherheit " & Standort
frmHauptfenster.EnableDoubleBuffered(dgvSicherheitsPos)
End Sub
Public Sub LoadDGVSicherheiten(Optional withFilterParam As Boolean = False)
txtGestellInfo.Text = ""
Dim sqladd1 As String = ""
If currentGesSichRef.brgakto_gs_ustEnabled Then sqladd1 &= ", (([gs_warenwert] + [gs_sicherheitsbetrag]) * " & currentGesSichRef.brgakto_gs_ust & "/100) as gs_ust"
If currentGesSichRef.brgakto_gs_ATR Then sqladd1 &= ", [gs_atr]"
Dim sqlSearchSting As String = ""
If withFilterParam = True Then
If txtSuche.Text <> "" Then sqlSearchSting &= " AND ([gs_abfertigungsNr] Like '%" & txtSuche.Text & "%' OR [gs_ATBNr] Like '%" & txtSuche.Text & "%' OR [gs_LKWKZ] like '%" & txtSuche.Text & "%' OR [gs_avisoId] like '%" & txtSuche.Text & "%' OR [gs_freitext] like '%" & txtSuche.Text & "%')"
If cbxRundPosanzeigen.Checked = False Then sqlSearchSting &= "AND ISNULL(gs_isRundungsdiff,0) = 0"
End If
Dim SQLStringSicherheit As String = "select [gs_gsId], [gs_gsnr], [gs_posNr], [gs_ATBNr], [gs_datum], [gs_warenwert], [gs_sicherheitsbetrag], [gs_saldo] " & sqladd1 & " , [gs_freitext] from [tblGesamtsicherheit] where [gs_gsnr] = " & gessicherheitID & sqlSearchSting & " order by [gs_ATBNr], [gs_posNr]"
dgvGesamtsicherheit.SET_SQL(SQLStringSicherheit, "AVISO", ,)
dgvGesamtsicherheit.LOAD()
If dgvGesamtsicherheit.Columns.Count > 0 Then
With dgvGesamtsicherheit
.RowHeadersWidth = 10
.Columns("gs_gsId").Visible = False
.Columns("gs_gsnr").Visible = False
.Columns("gs_warenwert").DefaultCellStyle.Format = "c"
.Columns("gs_sicherheitsbetrag").DefaultCellStyle.Format = "c"
.Columns("gs_saldo").DefaultCellStyle.Format = "c"
.Columns("gs_saldo").Visible = True
Select Case currentGesSichRef.brgakto_gs_ATR
Case True
If Standort = "Verag GmbH" Then
.Columns("gs_ATBNr").HeaderText = "Reg-Nr."
Else
.Columns("gs_ATBNr").HeaderText = "T1 MRN"
End If
.Columns("gs_ATBNr").Width = 130
.Columns("gs_atr").HeaderText = "ATR"
.Columns("gs_atr").Visible = True
.Columns("gs_atr").Width = 35
.Columns("gs_ust").Width = 70
.Columns("gs_ust").HeaderText = "Ust"
.Columns("gs_ust").DefaultCellStyle.Format = "c2"
Case Else
If Standort = "Verag GmbH" Then
.Columns("gs_ATBNr").HeaderText = "Reg-Nr."
Else
.Columns("gs_ATBNr").HeaderText = "T1 MRN"
End If
.Columns("gs_ATBNr").Width = 150
End Select
changeLabel(currentGesSichRef.brgakto_gs_ATR)
.Columns("gs_posNr").Width = 35
.Columns("gs_posNr").HeaderText = "Pos#"
.Columns("gs_datum").Width = 95
.Columns("gs_datum").HeaderText = "Datum"
.Columns("gs_warenwert").Width = 85
.Columns("gs_warenwert").HeaderText = "Warenwert"
.Columns("gs_saldo").Width = 100
.Columns("gs_saldo").HeaderText = "Saldo"
.Columns("gs_sicherheitsbetrag").Width = 85
.Columns("gs_sicherheitsbetrag").HeaderText = "S-Betrag"
.Columns("gs_freitext").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
.Columns("gs_freitext").HeaderText = "Freitext"
End With
Dim changeColor = True
For i As Integer = 0 To dgvGesamtsicherheit.Rows.Count - 1
If dgvGesamtsicherheit.Rows(i).Cells("gs_posNr").Value = 1 Then changeColor = IIf(changeColor, False, True)
If changeColor Then
Me.dgvGesamtsicherheit.Rows(i).DefaultCellStyle.BackColor = Color.LightBlue
Else
Me.dgvGesamtsicherheit.Rows(i).DefaultCellStyle.BackColor = Color.White
End If
Next
End If
calcGesamtsummen()
End Sub
Public Sub LoadDataTableSicherheitenForExport(list As List(Of Integer), datumVon As String, datumBis As String, standort As String)
Me.Cursor = Cursors.WaitCursor
Dim currentGesSichRef = New VERAG_PROG_ALLGEMEIN.cAufschubKonten(standort)
Dim gsnr As String
Dim counter = 0
For Each n In list
gsnr &= n.ToString()
counter = counter + 1
If (list.Count <> 0 And counter <> list.Count) Then
gsnr &= ","
End If
Next
Dim SQLStringSicherheit = "select gs_gsnr as 'Nr',[gs_ATBNr] as 'Reg-Nr. Verwahrlager " & standort & "','Eingang Verwahrlager' as 'Typ', CAST(gs_datum as Date) as Datum, CONVERT(VARCHAR(5),gs_datum, 108) as Uhrzeit, [gs_warenwert] as Warenwert, [gs_sicherheitsbetrag] as Sicherheitbetrag, [gs_sicherheitsbetrag] *-1 as Sicherheitbetrag_Calc, [gs_freitext] as Freitext, [gs_atr] as 'ATR ja/nein', [gs_ust] as '19% EUSt'
From [tblGesamtsicherheit]
Where [gs_gsnr] In (" & gsnr & ")
and isnull(gs_warenwert,0) <> 0
UNION
Select gsp_gsnr, [gsp_ATCNr],'Ausgang Verwahrlager', CAST(gsp_datum as Date), CONVERT(VARCHAR(5),gsp_datum, 108), [gsp_warenwert] , [gsp_sicherheitsbetrag],[gsp_sicherheitsbetrag], [gsp_freitext],[gsp_art],[gsp_ust]
From [tblGesamtsicherheitsPositionen]
where [gsp_gsnr] In (" & gsnr & ")
and isnull(gsp_warenwert,0) <> 0
order by Datum, Uhrzeit"
dtSicherheiten = SQL.loadDgvBySql(SQLStringSicherheit, "AVISO", 100, True)
dtSicherheiten.Columns.Add("Saldo")
Dim drFirst = dtSicherheiten.NewRow
drFirst.Item("Nr") = 0
drFirst.Item("Typ") = "Uebertrag vom"
drFirst.Item("Datum") = CDate(datumVon).ToShortDateString
drFirst.Item("Saldo") = SQL.getValueTxtBySql("SELECT TOP 1 isnull([gs_saldo],0) FROM [tblGesamtsicherheit] where gs_standort = '" & standort & "' AND gs_datum <'" & CDate(datumVon).ToShortDateString & "' order by gs_datum asc", "AVISO",,, currentGesSichRef.getReferenzbetrag(CDate(datumVon).ToShortDateString)) 'CDbl(dtSicherheiten.Rows(0).Item("Saldo"))
dtSicherheiten.Rows.InsertAt(drFirst, 0)
Dim sicherheitsbetrag As Double
Dim saldo As Double
Dim c1 As Double
Dim saldoStart As Double
For i As Integer = 1 To dtSicherheiten.Rows.Count - 1
saldoStart = CDbl(dtSicherheiten.Rows(0).Item("Saldo"))
saldo = CDbl(dtSicherheiten.Rows(i - 1).Item("Saldo"))
sicherheitsbetrag = IIf(dtSicherheiten.Rows(i).Item("Sicherheitbetrag_Calc") IsNot Nothing, CDbl(dtSicherheiten.Rows(i).Item("Sicherheitbetrag_Calc")), 0)
c1 = saldo + sicherheitsbetrag
dtSicherheiten.Rows(i)("Saldo") = c1
Next
Dim drLast = dtSicherheiten.NewRow
drLast.Item("Nr") = 0
drLast.Item("Typ") = "Saldo zum"
drLast.Item("Datum") = CDate(datumBis).ToShortDateString
drLast.Item("Saldo") = CDbl(dtSicherheiten.Rows(dtSicherheiten.Rows.Count - 1).Item("Saldo"))
dtSicherheiten.Rows.InsertAt(drLast, dtSicherheiten.Rows.Count)
'dtSicherheiten.Columns.Remove("Sicherheitbetrag_Calc")
Me.Cursor = Cursors.Default
End Sub
Public Sub LoadDataTableSicherheitenForExport2(list As List(Of Integer), datumVon As String, datumBis As String)
Me.Cursor = Cursors.WaitCursor
Dim gsnr As String
Dim counter = 0
For Each n In list
gsnr &= n.ToString()
counter = counter + 1
If (list.Count <> 0 And counter <> list.Count) Then
gsnr &= ","
End If
Next
Dim SQLStringSicherheit As String = "select [gs_ATBNr] as 'Reg-Nr. Verwahrlager',[gs_gsnr] as 'GS Nr', CAST(gs_datum as Date) as Datum, CONVERT(VARCHAR(5),gs_datum, 108) as Uhrzeit, [gs_warenwert] as Warenwert, [gs_sicherheitsbetrag] as Sicherheitbetrag, [gs_saldo] as Saldo, [gs_freitext] as Freitext, [gs_atr] as 'ATR ja/nein', [gs_ust] as '19% EUSt',
[gsp_ATCNr] as 'ATCNr oder MRN eroeffnet', CAST(gsp_datum as Date) as Datum, CONVERT(VARCHAR(5),gsp_datum, 108) as Uhrzeit, [gsp_warenwert] as Warenwert, [gsp_sicherheitsbetrag] as Sicherheitsbetrag2, [gsp_freitext] as Freitext
from [tblGesamtsicherheit]
inner join [tblGesamtsicherheitsPositionen] on [tblGesamtsicherheit].gs_gsId = [tblGesamtsicherheitsPositionen].gsp_gsId
where [gs_gsnr] IN (" & gsnr & ")
order by gs_gsId"
dtSicherheiten = SQL.loadDgvBySql(SQLStringSicherheit, "AVISO", 100, True)
dtSicherheiten.Columns.Add("SSaldo")
Dim drFirst = dtSicherheiten.NewRow
drFirst.Item("Reg-Nr. Verwahrlager") = "Uebertrag vom " & datumVon
drFirst.Item("SSaldo") = CDbl(dtSicherheiten.Rows(0).Item("Saldo"))
dtSicherheiten.Rows.InsertAt(drFirst, 0)
Dim sicherheitsbetragATBs As Double
Dim sicherheitsbetragATCs As Double
Dim saldo As Double
Dim c1 As Double
Dim saldoStart As Double
For i As Integer = 1 To dtSicherheiten.Rows.Count - 1
saldoStart = CDbl(dtSicherheiten.Rows(0).Item("SSaldo"))
saldo = CDbl(dtSicherheiten.Rows(i - 1).Item("SSaldo"))
sicherheitsbetragATCs = CDbl(dtSicherheiten.Rows(i).Item("Sicherheitbetrag"))
sicherheitsbetragATBs = CDbl(dtSicherheiten.Rows(i).Item("Sicherheitsbetrag2"))
c1 = saldo - sicherheitsbetragATCs + sicherheitsbetragATBs
dtSicherheiten.Rows(i)("SSaldo") = c1
Next
Dim drLast = dtSicherheiten.NewRow
drLast.Item("Reg-Nr. Verwahrlager") = "Saldo zum " & datumBis
drLast.Item("SSaldo") = CDbl(dtSicherheiten.Rows(dtSicherheiten.Rows.Count - 1).Item("SSaldo"))
dtSicherheiten.Rows.InsertAt(drLast, dtSicherheiten.Rows.Count)
dtSicherheiten.Columns.Remove("Saldo")
Me.Cursor = Cursors.Default
End Sub
Private Sub dgvGesamtsicherheit_SelectionChanged(sender As Object, e As EventArgs) Handles dgvGesamtsicherheit.SelectionChanged
If dgvGesamtsicherheit.SelectedRows.Count > 0 Then
indexGsId = CInt(dgvGesamtsicherheit.SelectedRows(0).Cells("gs_gsId").Value)
indexGsNr = CInt(dgvGesamtsicherheit.SelectedRows(0).Cells("gs_gsNr").Value)
currentSicherheit = New cSicherheiten(indexGsNr)
LoadDGVSicherheitsPos(indexGsNr, True)
loadTitle()
setSaldo()
If dgvGesamtsicherheit.Enabled = False Then Exit Sub
ATBNraendernToolStripMenuItem.Visible = True
btnAddPos.Visible = False
Else
LoadDGVSicherheitsPos(-1, True)
ATBNraendernToolStripMenuItem.Visible = False
'btnAddPos.Visible = True
End If
End Sub
Public Sub LoadDGVSicherheitsPos(gsNr As Integer, Optional withFilterParam As Boolean = False)
'If gsNr = "" Then Exit Sub
Dim sqlSearch As String = ""
If withFilterParam = True Then
sqlSearch &= "And gsp_gsid In (Select gs_gsId from [tblGesamtsicherheit] where [gs_gsnr] = '" & gessicherheitID & "'"
If txtSuche.Text <> "" Then sqlSearch &= "AND ([gs_abfertigungsNr] Like '%" & txtSuche.Text & "%' OR [gs_ATBNr] Like '%" & txtSuche.Text & "%' OR [gs_LKWKZ] like '%" & txtSuche.Text & "%' OR [gs_avisoId] like '%" & txtSuche.Text & "%' OR [gs_freitext] like '%" & txtSuche.Text & "%')"
If cbxRundPosanzeigen.Checked = False Then sqlSearch &= "AND ISNULL(gsp_isPosRundungsdiff,0) = 0"
sqlSearch &= ")"
End If
Dim SQLStringCRN As String =
"select [gsp_gspPosId],[gsp_ATCNr],[gsp_datum],[gsp_gsId],[gsp_gsnr],[gsp_warenwert],[gsp_sicherheitsbetrag], [gsp_freitext]" &' ,[gsp_avisoId] ,[gsp_ust] ,[gsp_filialenNr],[gsp_abfertigungsNr] ,[gsp_MRNNr], [gsp_art]
"From [tblGesamtsicherheitsPositionen] inner join [tblGesamtsicherheit] on gs_gsId = gsp_gsId where [gsp_gsnr] = '" & gsNr & "'" & sqlSearch & " order by [gs_ATBNr], [gs_posNr]"
dgvSicherheitsPos.SET_SQL(SQLStringCRN, "AVISO", ,)
dgvSicherheitsPos.LOAD()
If dgvSicherheitsPos.Columns.Count > 0 Then
With dgvSicherheitsPos
.RowHeadersWidth = 10
.Columns("gsp_gspPosId").Width = 35
.Columns("gsp_gspPosId").HeaderText = "Pos#"
.Columns("gsp_gsId").Visible = False
.Columns("gsp_gsnr").Visible = False
.Columns("gsp_warenwert").DefaultCellStyle.Format = "c"
.Columns("gsp_sicherheitsbetrag").DefaultCellStyle.Format = "c"
Select Case currentGesSichRef.brgakto_gs_ATR
Case True
If Standort = "Verag GmbH" Then
.Columns("gsp_ATCNr").HeaderText = "Reg-Nr. / MRN"
ElseIf Standort = "VERAG AG" Then
.Columns("gsp_ATCNr").HeaderText = "T1 CRN"
Else
.Columns("gsp_ATCNr").HeaderText = "EZA / T1 CRN"
End If
Case Else
If Standort = "Verag GmbH" Then
.Columns("gsp_ATCNr").HeaderText = "Reg-Nr. / MRN"
ElseIf Standort = "VERAG AG" Then
.Columns("gsp_ATCNr").HeaderText = "T1 CRN"
Else
.Columns("gsp_ATCNr").HeaderText = "EZA / T1 CRN"
End If
End Select
.Columns("gsp_ATCNr").Width = 140
.Columns("gsp_datum").Width = 100
.Columns("gsp_datum").HeaderText = "Datum"
.Columns("gsp_warenwert").Width = 100
.Columns("gsp_warenwert").HeaderText = "Warenwert"
.Columns("gsp_sicherheitsbetrag").Width = 85
.Columns("gsp_sicherheitsbetrag").HeaderText = "S-Betrag"
.Columns("gsp_freitext").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
.Columns("gsp_freitext").HeaderText = "Freitext"
End With
Dim changeColor = True
For i As Integer = 0 To dgvSicherheitsPos.Rows.Count - 1
If dgvSicherheitsPos.Rows(i).Cells("gsp_gspPosId").Value = 1 Then changeColor = IIf(changeColor, False, True)
If changeColor Then
Me.dgvSicherheitsPos.Rows(i).DefaultCellStyle.BackColor = Color.LightBlue
Else
Me.dgvSicherheitsPos.Rows(i).DefaultCellStyle.BackColor = Color.White
End If
Next
End If
btnAddPos.Visible = True
End Sub
Sub loadTitle()
txtGestellInfo.Text = ""
lblId.Text = ""
Dim StandortSqlString As String = "select * from [tblGesamtsicherheit] where [gs_gsNr] = '" & indexGsNr & "'"
Dim dt As New DataTable
dt = SQL.loadDgvBySql(StandortSqlString, "AVISO", 100, True)
If dt.Rows.Count > 0 Then
Me.avisoID = setNullToZero(dt.Rows(0).Item("gs_avisoId"))
Me.LKWKZ = setNullToZero(dt.Rows(0).Item("gs_LKWKZ"))
Me.FilialNummer = setNullToZero(dt.Rows(0).Item("gs_filialenNr"))
Me.Abfertigungsnummer = dt.Rows(0).Item("gs_abfertigungsNr")
Me.warenortID = setNullToZero(dt.Rows(0).Item("gs_warenort"))
End If
If Me.avisoID.ToString.Length > 0 Then txtGestellInfo.Text &= "LKW-ID: " & Me.avisoID & " "
If Me.LKWKZ.ToString.Length > 0 Then txtGestellInfo.Text &= "LKW-KZ: " & Me.LKWKZ & " "
If Me.FilialNummer.ToString.Length > 0 Then txtGestellInfo.Text &= "FilialNr: " & Me.FilialNummer & " "
If Me.Abfertigungsnummer.Length > 0 Then txtGestellInfo.Text &= "AbfNr: " & Me.Abfertigungsnummer & " "
If Me.warenortID.Length > 0 Then txtGestellInfo.Text &= "Warenort: " & Me.warenortID & " "
If gessicherheitID <> 0 Then lblId.Text &= "GS-Nr: " & gessicherheitID 'currentSicherheit.gs_gsNr
End Sub
Public Sub LoadStandort()
Zollsatz = currentGesSichRef.brgakto_gs_zollsatz
txtZollsatzueberschreiben.Text = Zollsatz
cbxZollsatzueberschreiben.Checked = False
lblReferenzwert.Text = "Referenzwert: € " & CDbl(currentGesSichRef.brgakto_betrag).ToString("N")
lblZollsatz.Text = "Zollsatz: " & currentGesSichRef.brgakto_gs_zollsatz & "%"
ZollsatzMulti = currentGesSichRef.brgakto_gs_zollsatz / 100
End Sub
Private Sub Warenwert_TextChanged(sender As Object, e As EventArgs) Handles txtSicherheitWarenwert.TextChanged, txtPosWarenwert.TextChanged
If Not IsNumeric(txtSicherheitWarenwert.Text) And sender.name = "txtSicherheitWarenwert" Then
txtSicherheitWarenwert.ForeColor = Color.Red
Exit Sub
Else
txtSicherheitWarenwert.ForeColor = Color.Black
End If
If Not IsNumeric(txtPosWarenwert.Text) And sender.name = "txtPosWarenwert" Then
txtPosWarenwert.ForeColor = Color.Red
Exit Sub
Else
txtPosWarenwert.ForeColor = Color.Black
End If
txtSicherheitWarenwert.Text = Replace(txtSicherheitWarenwert.Text, ".", "")
txtPosWarenwert.Text = Replace(txtPosWarenwert.Text, ".", "")
txtSicherheitWarenwert.Text = Replace(txtSicherheitWarenwert.Text, "", "")
txtPosWarenwert.Text = Replace(txtPosWarenwert.Text, "", "")
Try
Select Case sender.name
Case "txtSicherheitWarenwert"
txtSicherheitSicherheitsbetrag.Text = (txtSicherheitWarenwert.Text * ZollsatzMulti).ToString("N")
If currentGesSichRef.brgakto_gs_ustEnabled Then txtSicherheitEust.Text = (Double.Parse(txtSicherheitWarenwert.Text) + Double.Parse(txtSicherheitSicherheitsbetrag.Text)) * (currentGesSichRef.brgakto_gs_ust / 100)
Case "txtPosWarenwert"
txtPosSicherheitsbetrag.Text = (txtPosWarenwert.Text * ZollsatzMulti).ToString("N")
End Select
Catch
End Try
End Sub
Private Sub WarenwertContext_TextChanged(sender As Object, e As EventArgs) Handles txtWarenwertContext.TextChanged
If Not IsNumeric(txtWarenwertContext.Text) And sender.name = "txtWarenwertContext" Then
txtWarenwertContext.ForeColor = Color.Red
Exit Sub
Else
txtWarenwertContext.ForeColor = Color.Black
End If
txtWarenwertContext.Text = Replace(txtWarenwertContext.Text, ".", "")
txtWarenwertContext.Text = Replace(txtWarenwertContext.Text, "", "")
Try
Select Case sender.name
Case "txtWarenwertContext"
txtSicherheitsbetragContext.Text = (txtWarenwertContext.Text * ZollsatzMulti).ToString("N")
End Select
Catch
End Try
End Sub
Private Sub Warenwert_Keypresses(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtSicherheitWarenwert.KeyPress, txtPosWarenwert.KeyPress, txtAnzahlPos.KeyPress, txtZollsatzueberschreiben.KeyPress
Select Case Asc(e.KeyChar)
Case 48 To 57, 8, 44, 22
' Zahlen, Backspace und , zulassen
Case Else
' alle anderen Eingaben unterdrücken
e.Handled = True
End Select
End Sub
Private Sub Date_Keypresses(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtPosDat.KeyPress, txtSicherheitDat.KeyPress, txtDatumaendern.KeyPress
Select Case Asc(e.KeyChar)
Case 48 To 57, 8, 44, 46, 58, 47
' Zahlen, Backspace, . und : zulassen
Case Else
' alle anderen Eingaben unterdrücken
e.Handled = True
End Select
End Sub
Private Sub DateTime_Keypresses(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtPosTime.KeyPress, txtSicherheitTime.KeyPress, txtUhrzeitaendern.KeyPress
Select Case Asc(e.KeyChar)
Case 48 To 57, 8, 44, 46, 58
'Case 48 To 57, 8, 44, 46, 58, 160, 188, 110, 111, 190, 226
' Zahlen, Backspace, . und : zulassen
Case Else
' alle anderen Eingaben unterdrücken
e.Handled = True
End Select
End Sub
Private Sub txtMRNDate_GotFocus(sender As Object, e As EventArgs) Handles txtSicherheitDat.GotFocus, txtSicherheitTime.GotFocus, txtPosTime.GotFocus, txtUhrzeitaendern.GotFocus, txtDatumaendern.GotFocus, txtPosDat.GotFocus
Select Case sender.name
Case "txtSicherheitDat"
If txtSicherheitDat.Text.Length < 1 Then txtSicherheitDat.Text = Date.Today.ToString("dd.MM.yyyy")
'Case "txtPosDate"
' If txtPosDate.Text.Length < 1 Then txtPosDate.Text = Date.Today.ToString("dd.MM.yyyy")
Case "txtPosDat"
If txtPosDat.Text.Length < 1 Then txtPosDat.Text = Date.Today.ToString("dd.MM.yyyy")
Case "txtSicherheitTime"
If txtSicherheitTime.Text.Length < 1 Then txtSicherheitTime.Text = Date.Now.ToString("HH:mm")
Case "txtPosTime"
If txtPosTime.Text.Length < 1 Then txtPosTime.Text = Date.Now.ToString("HH:mm")
Case "txtDatumaendern"
If txtDatumaendern.Text.Length < 1 Then txtDatumaendern.Text = Date.Today.ToString("dd.MM.yyyy")
Case "txtUhrzeitaendern"
If txtUhrzeitaendern.Text.Length < 1 Then txtUhrzeitaendern.Text = Date.Now.ToString("HH:mm")
End Select
End Sub
Private Sub btnAddSicherheit_Click(sender As Object, e As EventArgs) Handles btnAddSicherheit.Click
Try
If (txtSicherheitATBNr.Text = "") Then
txtSicherheitATBNr.Focus()
Exit Sub
End If
If (txtAnzahlPos.Text = "") Then
txtAnzahlPos.Focus()
Exit Sub
End If
If checkNothingValue(txtSicherheitSicherheitsbetrag.Text, "Double") IsNot Nothing Then
Dim sichBetr As Double = Double.Parse(txtSicherheitSicherheitsbetrag.Text)
If checkSaldo(sichBetr, True) = False Then Exit Sub
End If
Dim attachPosNrToExistingATB As Boolean = False
Dim limit As Integer = Integer.Parse(setNullToZero(txtAnzahlPos.Text))
If (limit > 10) Then
Dim result As MsgBoxResult = MsgBox("Sollen wirklich " & limit & "Positionen angelegt werden?", vbYesNoCancel)
If result <> vbYes Then
txtAnzahlPos.Focus()
Exit Sub
End If
End If
For count As Integer = 1 To limit
attachPosNrToExistingATB = False
Dim warenwert As Double
Dim sicherheitsbetrag As Double
If count > 1 Then
warenwert = 0
sicherheitsbetrag = 0
Else
warenwert = Double.Parse(txtSicherheitWarenwert.Text)
sicherheitsbetrag = Double.Parse(txtSicherheitSicherheitsbetrag.Text)
End If
Dim OPEN As New cSicherheiten()
With OPEN
.gs_gsNr = gessicherheitID
.gs_ATBNr = txtSicherheitATBNr.Text
.gs_posNr = count
.gs_datum = DateTimeString2DateTimeKonvertinator(txtSicherheitDat.Text, txtSicherheitTime.Text)
.gs_warenwert = warenwert
.gs_sicherheitsbetrag = sicherheitsbetrag
.gs_standort = Me.Standort
.gs_art = "OPEN"
.gs_erstellungsdatum = DateTime.Now
.gs_freitext = Me.txtSicherheitFreitext.Text
.gs_saldo = currentGesSichRef.brgakto_gs_aktSaldo
.gs_atr = setNullToZero(cboSicherheitATR.SelectedItem)
.gs_zollsatz = Me.Zollsatz
.gs_avisoId = Me.avisoID
setEnviromentDataToObject(OPEN, Me)
End With
If Neu = True AndAlso count <= 1 Then OPEN.gs_gsNr = AddNewGesamtSichNr()
Select Case checkIfExist(OPEN.gs_ATBNr, gessicherheitID)
Case "Neu"
indexGsId = OPEN.SAVEOBJECT()
Case Else
With OPEN
.gs_posNr = getLatestPosNr(gessicherheitID, txtSicherheitATBNr.Text) + 1
End With
attachPosNrToExistingATB = True
indexGsId = OPEN.SAVEOBJECT()
If count = 1 Then MsgBox("INFO: Dieser Eintrag wurde bei GesamtsichNr " & checkIfExist(OPEN.gs_ATBNr, gessicherheitID) & "eingetragen") ': indexGsId = OPEN.SAVEOBJECT()
End Select
Dim OPENPos As cGesamtsicherheitsPositionen
If attachPosNrToExistingATB Then
OPENPos = New cGesamtsicherheitsPositionen(indexGsId, OPEN.gs_posNr)
Else
OPENPos = New cGesamtsicherheitsPositionen(indexGsId, count)
End If
With OPENPos
.gsp_gsNr = OPEN.gs_gsNr
.gsp_warenwert = 0
.gsp_sicherheitsbetrag = 0
.gsp_freitext = ""
.gsp_filialenNr = OPEN.gs_filialenNr
.gsp_art = "OPEN"
.gsp_abfertigungsNr = OPEN.gs_abfertigungsnr
.gsp_erstellungsdatum = DateTime.Now
.gsp_ust = ""
.gsp_avisoId = Me.avisoID
.gsp_gsNr = OPEN.gs_gsNr
.gsp_systemuser = VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME
End With
OPENPos.SAVE()
Next
AfterButton()
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Private Sub btnAddPos_Click(sender As Object, e As EventArgs) Handles btnAddPos.Click
If dgvGesamtsicherheit.SelectedRows.Count = 0 Then
MsgBox("Bitte eine Gestellung markieren, zu diese eine Pos hinzugefügt/entfernt/aktualisiert werden soll")
Exit Sub
End If
If checkSicherheitsbetrag() = False Then Exit Sub
If Not checkDateOfPosition(txtPosDat.Text, txtPosTime.Text) Then Exit Sub
Try
Dim OPEN As New cSicherheiten()
With OPEN
.gs_gsNr = gessicherheitID
.gs_ATBNr = ""
.gs_posNr = Me.getLatestPosNr(currentSicherheit.gs_gsNr, currentSicherheit.gs_ATBNr) + 1
.gs_datum = DateTimeString2DateTimeKonvertinator(txtPosDat.Text, txtPosTime.Text)
.gs_warenwert = 0
.gs_sicherheitsbetrag = 0
.gs_standort = Me.Standort
.gs_art = "OPEN"
.gs_erstellungsdatum = DateTime.Now
.gs_freitext = Me.txtSicherheitFreitext.Text
.gs_saldo = currentGesSichRef.brgakto_gs_aktSaldo
.gs_atr = setNullToZero(cboSicherheitATR.SelectedItem)
.gs_zollsatz = Me.Zollsatz
.gs_avisoId = Me.avisoID
setEnviromentDataToObject(OPEN, Me)
End With
Dim gs_gsId = OPEN.SAVEOBJECT()
Dim SicherheitsPos As New cGesamtsicherheitsPositionen()
With SicherheitsPos
.gsp_gsId = gs_gsId
'.gsp_gspPosId = Me.getLatestPosNr(currentSicherheit.gs_gsNr, ) + 1
.gsp_gspPosId = OPEN.gs_posNr
.gsp_warenwert = Double.Parse(txtPosWarenwert.Text)
.gsp_sicherheitsbetrag = Double.Parse(txtPosSicherheitsbetrag.Text)
.gsp_freitext = txtPosFreitext.Text
.gsp_filialenNr = currentSicherheit.gs_filialenNr
.gsp_art = "CLOSE"
.gsp_gsNr = gessicherheitID
.gsp_abfertigungsNr = currentSicherheit.gs_abfertigungsnr
.gsp_datum = DateTimeString2DateTimeKonvertinator(txtPosDat.Text, txtPosTime.Text)
.gsp_erstellungsdatum = DateTime.Now
.gsp_ust = currentSicherheit.gs_ust
.gsp_ATCNr = txtPositionenCRN.Text
.gsp_avisoId = Me.avisoID
.gsp_systemuser = VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME
End With
SicherheitsPos.SAVE()
AfterButton()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Function setNullToZero(s As String, Optional type As String = "")
If s = "" Then
Dim zero As Double = 0
Return zero
Else
Return s
End If
End Function
Sub AfterButton()
'currentGesSichRef.CalcSaldo()
lblSaldo.Text = "Saldo: €" & Decimal.Parse(currentGesSichRef.CalcSaldo()).ToString("N")
LoadDGVSicherheiten()
EmptyTXT()
End Sub
Public Function AddNewGesamtSichNr() As Integer
Dim sqlq As String = "select MAX([gs_gsNr]) as MaxGesSich from tblGesamtsicherheit"
Dim dt As New DataTable
dt = SQL.loadDgvBySql(sqlq, "AVISO", 100, True)
Dim LetzteGesSichNum As Integer = -1
If (dt.Rows(0).Item(0) IsNot DBNull.Value) Then
LetzteGesSichNum = dt.Rows(0).Item(0)
Me.gessicherheitID = LetzteGesSichNum + 1
Me.Neu = False
End If
Return Me.gessicherheitID
End Function
Public Sub EmptyTXT()
Dim a As New List(Of Windows.Forms.Control)
For Each contr As Windows.Forms.Control In panOben.Controls
If (contr.GetType.FullName = "System.Windows.Forms.TextBox" Or contr.GetType.FullName = "VERAG_PROG_ALLGEMEIN.MyTextBox") And Not contr.Name = "txtZollsatzueberschreiben" Then contr.Text = ""
Next
cboSicherheitATR.SelectedItem = Nothing
End Sub
Public Function checkIfExist(KennnummerStr As String, Optional ByVal lkw As String = "") As String
If lkw = "" And Me.gessicherheitID > 0 Then lkw = gessicherheitID
Dim SQLString As String = "Select * from [tblGesamtsicherheit] where [gs_ATBNr] = '" & KennnummerStr & "'"
Dim dt As New DataTable
dt = SQL.loadDgvBySql(SQLString, "AVISO", 100, True)
If dt.Rows.Count > 0 Then
Return dt.Rows(0).Item("gs_gsNr").ToString
Else
Return "Neu"
End If
End Function
Public Function DateTimeString2DateTimeKonvertinator(datum As String, uhrzeit As String) As DateTime
Try
Dim a As Date = Date.ParseExact(datum, "dd.MM.yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
Dim b As Date = Date.ParseExact(uhrzeit, "H:mm", System.Globalization.DateTimeFormatInfo.InvariantInfo)
Dim ab As Date = a.AddHours(b.Hour).AddMinutes(b.Minute)
Return ab
Catch ex As Exception
MsgBox(ex.Message)
Return Date.Now
End Try
End Function
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click ', btnSaveOben.Click
If checkMandatoryFieldsAreFilled() = False Then Exit Sub
Try
Me.FilialNummer = checkNothingValue(cboFiliale.SelectedItem, "Integer")
Catch
Me.FilialNummer = "0"
End Try
Try
Me.warenortID = checkNothingValue(cboWarenort.SelectedItem, "String")
Catch
Me.warenortID = "-"
End Try
Try
Me.Abfertigungsnummer = checkNothingValue(txtAbfertNum.Text, "String")
Catch
Me.Abfertigungsnummer = txtAbfertNum.Text
End Try
If txtlkwIdSearch.Text IsNot "" Then
Me.avisoID = CInt(txtlkwIdSearch.Text)
End If
Me.LKWKZ = txtLKWKZ.Text
If setNullToZero(Me.gessicherheitID) > 0 Then
Dim sqlstring = "Update [tblGesamtsicherheit] set [gs_filialenNr] = '" & Me.FilialNummer & "', [gs_abfertigungsNr] = '" & Me.Abfertigungsnummer & "', [gs_avisoId] = '" & Me.avisoID & "',[gs_LKWKZ] = '" & Me.LKWKZ & "', [gs_warenort] = '" & Me.warenortID & "' WHERE [gs_gsNr] = '" & Me.gessicherheitID & "' "
SQL.doSQL(sqlstring, "AVISO")
btnAddPos.Visible = True
LoadDGVSicherheiten()
End If
loadTitle()
btnAddPos.Visible = False
panOben.Enabled = True : panOben.Enabled = True
panOverlay.Visible = False
End Sub
Private Function checkNothingValue(obj As Object, Optional type As String = "String") As Object
Select Case type
Case "String"
If obj Is Nothing Then
Return ""
Else
Return obj.value.ToString
End If
Case "Integer"
If obj Is Nothing Or obj Is DBNull.Value Then
Return Nothing
Else
Return Integer.Parse(CInt(obj.value))
End If
Case "Double"
If obj Is Nothing Or obj Is DBNull.Value Or obj = "" Then
Return Nothing
Else
Return Double.Parse(CDbl(obj))
End If
End Select
End Function
Private Sub dgvGesamtsicherheit_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvGesamtsicherheit.CellDoubleClick
Dim Sicherh As New cSicherheiten(dgvGesamtsicherheit.CurrentRow.Cells("gs_gsId").Value, dgvGesamtsicherheit.CurrentRow.Cells("gs_posNr").Value)
txtSicherheitATBNr.Text = Sicherh.gs_ATBNr
txtAnzahlPos.Text = Sicherh.gs_posNr
txtSicherheitWarenwert.Text = Sicherh.gs_warenwert
txtSicherheitFreitext.Text = Sicherh.gs_freitext
cboSicherheitATR.SelectedItem = Sicherh.gs_atr
txtSicherheitDat.Text = Sicherh.gs_datum.ToString("dd.MM.yyyy")
txtSicherheitTime.Text = Sicherh.gs_datum.ToString("HH:mm")
currentSicherheit = Sicherh
txtAnzahlPos.Enabled = False
If Sicherh.gs_isRundungsdiff = True Then
btnAddSicherheit.Visible = False
btnUpdateSicherheit.Visible = False
Else
btnAddSicherheit.Visible = False
btnUpdateSicherheit.Visible = True
End If
btnDeleteSicherheit.Visible = True
End Sub
Private Sub btnUpdateSicherheit_Click(sender As Object, e As EventArgs) Handles btnUpdateSicherheit.Click
If checkNothingValue(txtSicherheitSicherheitsbetrag.Text, "Double") IsNot Nothing Then
Dim sichBetr As Double = Double.Parse(txtSicherheitSicherheitsbetrag.Text)
If checkSaldo(sichBetr - Double.Parse(currentSicherheit.gs_sicherheitsbetrag)) = False Then Exit Sub
End If
With currentSicherheit
.gs_ATBNr = txtSicherheitATBNr.Text
.gs_posNr = Integer.Parse(setNullToZero(txtAnzahlPos.Text))
.gs_datum = DateTimeString2DateTimeKonvertinator(txtSicherheitDat.Text, txtSicherheitTime.Text)
.gs_warenwert = Double.Parse(txtSicherheitWarenwert.Text)
.gs_sicherheitsbetrag = Double.Parse(txtSicherheitSicherheitsbetrag.Text)
.gs_standort = Me.Standort
.gs_art = "OPEN"
.gs_gsNr = Me.gessicherheitID
'.MakeDate = Me.MakeDate
.gs_freitext = Me.txtSicherheitFreitext.Text
'.saldo = currentGesSichRef.Saldo
.gs_atr = setNullToZero(cboSicherheitATR.SelectedItem)
End With
If checkSicherheitsbetrag() = False Then Exit Sub
currentSicherheit.gs_systemuser = VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME
currentSicherheit.gs_zuletztgeandert = Now()
currentSicherheit.SAVE()
txtAnzahlPos.Enabled = True
btnUpdateSicherheit.Visible = False
btnAddSicherheit.Visible = True
btnDeleteSicherheit.Visible = False
AfterButton()
End Sub
Private Sub btnUpdatePos_Click(sender As Object, e As EventArgs) Handles btnUpdatePos.Click
If Not checkDateOfPosition(txtPosDat.Text, txtPosTime.Text) Then
Exit Sub
End If
With currentSPos
.gsp_art = "CLOSE"
.gsp_freitext = txtPosFreitext.Text
.gsp_sicherheitsbetrag = Double.Parse(txtPosSicherheitsbetrag.Text)
.gsp_warenwert = Double.Parse(txtPosWarenwert.Text)
.gsp_ATCNr = If(txtPositionenCRN.Text <> "", txtPositionenCRN.Text, Nothing)
If txtPosDat.Text <> "" AndAlso txtPosTime.Text <> "" Then
currentSPos.gsp_datum = DateTimeString2DateTimeKonvertinator(txtPosDat.Text, txtPosTime.Text)
Else
currentSPos.gsp_datum = Nothing
If .gsp_ATCNr <> "" AndAlso currentSPos.gsp_datum Is Nothing Then
MsgBox("Datum/Uhrzeit bei Position " & currentSPos.gsp_gspPosId & " muss eingetragen werden!")
Exit Sub
End If
End If
End With
If checkSicherheitsbetrag() = False Then Exit Sub
currentSPos.gsp_systemuser = VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME
currentSPos.gsp_zuletztgeandert = Now()
currentSPos.SAVE()
btnAddPos.Visible = True
btnUpdatePos.Visible = False
btnDeletePos.Visible = False
AfterButton()
End Sub
Private Sub dgvGesamtsicherheitPositionen_CellCellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvSicherheitsPos.CellDoubleClick
Dim sPos As New cGesamtsicherheitsPositionen(dgvSicherheitsPos.CurrentRow.Cells("gsp_gsId").Value, dgvSicherheitsPos.CurrentRow.Cells("gsp_gspPosId").Value)
If sPos.gsp_isPosRundungsdiff = True Then Exit Sub
txtPosNr.Text = sPos.gsp_gspPosId
txtPosFreitext.Text = sPos.gsp_freitext
txtPosSicherheitsbetrag.Text = sPos.gsp_sicherheitsbetrag
txtPosWarenwert.Text = sPos.gsp_warenwert
txtPositionenCRN.Text = CStr(sPos.gsp_ATCNr)
Try
If sPos.gsp_datum IsNot Nothing Then
txtPosDat.Text = CDate(sPos.gsp_datum).ToString("dd.MM.yyyy")
txtPosTime.Text = CDate(sPos.gsp_datum).ToString("HH:mm")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
currentSPos = sPos
'btnDeletePos.Visible = True
btnAddPos.Visible = False
btnUpdatePos.Visible = True
End Sub
Private Sub btnDeleteSicherheit_Click(sender As Object, e As EventArgs) Handles btnDeleteSicherheit.Click
Try
Dim posNr = currentSicherheit.gs_posNr
Dim ATBNr = currentSicherheit.gs_ATBNr
Dim gsNr = currentSicherheit.gs_gsNr
currentSicherheit.Delete()
rearangePosNr(gsNr, ATBNr, posNr)
btnUpdateSicherheit.Visible = False
btnAddSicherheit.Visible = True
btnDeleteSicherheit.Visible = False
txtAnzahlPos.Enabled = True
AfterButton()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btnDeletePos_Click(sender As Object, e As EventArgs) Handles btnDeletePos.Click
Try
currentSPos.Delete()
btnUpdatePos.Visible = False
btnAddPos.Visible = True
btnDeletePos.Visible = False
AfterButton()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub lblGestellungNr_Click(sender As Object, e As EventArgs) Handles txtGestellInfo.DoubleClick
panOverlay.Visible = True
cboFiliale.fillWithSQL("SELECT FilialenNr, cast(FilialenNr as varchar(4)) + ' ' + Grenzstelle FROM Filialen WHERE Fil_Status='A' ORDER BY FilialenNr ", True, "FMZOLL", True)
cboFiliale.SelectedIndex = cboFiliale.FindString(Me.FilialNummer)
cboWarenort.fillWithSQL("SELECT [wo_warenort],CONCAT([wo_knnr],' - ' ,[wo_bezeichnung]) FROM [tblWarenorte] WHERE [wo_aktiv] ='1' AND wo_ze = 1 AND [wo_firma] = '" & firmaId & "' ORDER BY [wo_reihenfolge] ", True, "AVISO", True)
txtlkwIdSearch.initSearchBox(Me.FindForm, " LKW_Nr, avisoID, CAST(datum As Date) As Datum FROM [Aviso]", {"LKW_Nr", "AvisoID", "Datum"}, "", "Datum desc", "LKW_Nr", "AvisoId", "AVISO",, 250, 200)
txtlkwIdSearch.SET_VALUE(avisoID)
txtAbfertNum.Text = Me.Abfertigungsnummer
txtLKWKZ.Text = Me.LKWKZ
panOben.Enabled = False
End Sub
Private Sub btnClosePanOverlay_Click(sender As Object, e As EventArgs) Handles btnClosePanOverlay.Click
panOverlay.Visible = False
Me.Close()
End Sub
Private Function checkMandatoryFieldsAreFilled() As Boolean
Dim isFilled = True
If cboWarenort._value = Nothing Or cboWarenort._value = "" Then
MsgBox("Bitte Warenort angeben!")
isFilled = False
End If
Return isFilled
End Function
Private Sub setEnviromentDataToObject(sicherheiten As cSicherheiten, Optional ByVal gessich As frmGesamtsicherheitenNEU = Nothing)
sicherheiten.gs_filialenNr = gessich.FilialNummer
sicherheiten.gs_abfertigungsnr = gessich.Abfertigungsnummer
sicherheiten.gs_LKWKZ = gessich.LKWKZ
sicherheiten.gs_warenort = gessich.warenortID
sicherheiten.gs_systemuser = VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME
End Sub
Private Function getLatestPosNr(gs_gsnr As Integer, gs_ATBNr As String) As Integer
Dim posNr As Integer = 0
'Dim sqlq As String = "Select MAX([gsp_gspPosId]) As MaxPosNr from tblGesamtsicherheitsPositionen where gsp_gsnr = " & gs_gsnr
Dim sqlq As String = "Select MAX([gs_posNr]) As MaxPosNr from [tblGesamtsicherheit] where gs_gsnr = " & gs_gsnr & " And gs_ATBNR = '" & gs_ATBNr & "'"
Dim dt As New DataTable
dt = SQL.loadDgvBySql(sqlq, "AVISO", 100, True)
If (dt.Rows(0).Item(0) IsNot DBNull.Value) Then
posNr = dt.Rows(0).Item(0)
End If
Return posNr
End Function
Private Sub btnSuche_Click(sender As Object, e As EventArgs)
Try
If Me.Visible Then LoadDGVSicherheiten(True)
Catch ex As Exception
MsgBox("Datum VON und/oder BIS konnte nicht konvertiert werden.")
End Try
End Sub
Private Sub btnNeu_Click(sender As Object, e As EventArgs)
panOverlay.Visible = True
End Sub
Private Sub btn_resetSearch_Click(sender As Object, e As EventArgs)
Dim dgv As String = ""
For Each c As DataGridViewColumn In dgvGesamtsicherheit.Columns
dgv &= c.Width & c.HeaderText & vbCrLf
Next
LoadDGVSicherheiten()
currentGesSichRef.LOAD()
LoadStandort()
End Sub
Private Function checkSicherheitsbetrag() As Boolean
Dim ok As Boolean = True
Dim offenerSicherheitsbetrag As Double
Dim offenerSicherheitsbetragPos As Double
Try
'If checkSaldo() = False Then
' Return False
'End If
If (offenerSicherheitsbetrag < 0 Or offenerSicherheitsbetrag < offenerSicherheitsbetragPos) Then
If vbYes = MsgBox("Der Warenwert der Positionen übersteigt den Warenwert der Gestellung!" & vbCrLf & "Trotzdem speichen?", vbYesNo) Then
Return True
Else
Return False
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return ok
End Function
Private Function checkSaldo(Optional currentSBetrag As Double = 0, Optional newPosition As Boolean = False) As Boolean
Try
Dim SaldoNewTemp = SaldoNew
Dim calcSicherheiten As Double = calcSicherheitsbetragGestelle()
Dim calcSicherheitenPos As Double = calcSicherheitsbetragPos()
Dim newCalcSaldo As Double
newCalcSaldo = SaldoNew - currentSBetrag
'Dim referenzbetrag As Double = currentGesSichRef.brgakto_betrag
If SaldoNew < 0 Then
MsgBox("Achtung!" & vbCrLf & "Saldo ist NEGATIV")
Return True 'Saldo ist bereits negativ!
End If
Dim diffAbs As Double = Math.Abs(SaldoNew - currentSBetrag)
'If (referenzbetrag - newCalcSaldo < 0) Then
If (newCalcSaldo < 0) Then
If vbNo = MsgBox("ACHTUNG!" & vbCrLf & "Dieser Sicherheitsbetrag würde den jetzigen Saldo um " & Math.Abs(newCalcSaldo) & "€ übersteigen!" & vbCrLf & "Trotzdem speichen?", vbYesNo) Then
Return False
Else
Return True
End If
Return True
End If
Return True
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
Private Function calcSicherheitsbetragPos() As Double
Dim sicherheitsbetragSumPositionen As Double
If currentSicherheit Is Nothing Then Exit Function
sicherheitsbetragSumPositionen = CDbl(SQL.DLookup("SUM(gsp_sicherheitsbetrag)", "[tblGesamtsicherheitsPositionen]", "gsp_gsnr ='" & currentSicherheit.gs_gsNr & "'", "AVISO"))
If currentSPos IsNot Nothing Then
sicherheitsbetragSumPositionen = sicherheitsbetragSumPositionen + Double.Parse(setNullToZero(txtPosSicherheitsbetrag.Text))
End If
Return sicherheitsbetragSumPositionen
End Function
Private Function calcSicherheitsbetragGestelle() As Double
Dim sicherheitsbetragSumGestelle As Double
If currentSicherheit Is Nothing Then Exit Function
sicherheitsbetragSumGestelle = CDbl(SQL.DLookup("SUM(gs_sicherheitsbetrag)", "[tblGesamtsicherheit]", "gs_gsnr ='" & currentSicherheit.gs_gsNr & "'", "AVISO"))
Return sicherheitsbetragSumGestelle
End Function
Private Function calcOffenerSicherheitsbetrag() As Double
Dim diff As Double = -10000
Try
Dim sicherheitsbetragSumPositionen = calcSicherheitsbetragPos()
Dim sicherheitsbetragSumGestelle = calcSicherheitsbetragGestelle()
diff = Double.Parse(sicherheitsbetragSumGestelle) - Double.Parse(sicherheitsbetragSumPositionen)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return diff
End Function
Private Sub setSaldo()
lbloffenerSaldo.Text = "offener Sicherheitswert: €"
Dim offernerSB As Double = Math.Round(Me.calcOffenerSicherheitsbetrag(), 2)
If offernerSB > 0.01 Then
lbloffenerSaldo.Text &= Decimal.Parse(offernerSB.ToString("N"))
isOpen = True
Else
lbloffenerSaldo.Text &= "0"
isOpen = False
End If
End Sub
Private Sub setPrevAndNextGesIDAllOpen()
Dim isInList As Boolean = False
Dim onlyOpenDT As DataTable
dataTable.DefaultView.Sort = "gs_gsnr ASC"
dataTable = dataTable.DefaultView.ToTable
If dataTable.Select("gs_isOpen = True").Any Then
onlyOpenDT = dataTable.Select("gs_isOpen = True").CopyToDataTable
Else
prevGessicherheitID = -1
nextGessicherheitID = -1
MsgBox("keine offenen Gesamtsicherheiten gefunden!")
Exit Sub
End If
For i As Integer = 0 To onlyOpenDT.Rows.Count - 1
If onlyOpenDT.Rows(i).Item("gs_gsnr") = Me.gessicherheitID Then
isInList = True
If i = 0 Then
prevGessicherheitID = -1 ' no prev Sicherheit
Else
prevGessicherheitID = onlyOpenDT.Rows(i - 1).Item("gs_gsnr")
End If
If i = onlyOpenDT.Rows.Count - 1 Then
nextGessicherheitID = -1 ' no next Sicherheit
Else
nextGessicherheitID = onlyOpenDT.Rows(i + 1).Item("gs_gsnr")
End If
End If
Next
If isInList = False AndAlso onlyOpenDT.Rows.Count - 1 <> 0 Then
setPrevAndNextGesIDAllOpenIfNotInList(isInList) 'wenn Me.gessicherheitID selbst nicht mehr offen ist!!!
If isInList = False Then
dataTable.Rows.Add(Me.gessicherheitID, True) ' wenn Me.gessicherheitsID neu angelegt wurde!!!
setPrevAndNextGesIDAllOpenIfNotInList(isInList)
End If
End If
End Sub
Private Sub setPrevAndNextGesIDAllOpenIfNotInList(ByRef isInList As Boolean)
For i As Integer = 0 To dataTable.Rows.Count - 1
If dataTable.Rows(i).Item("gs_gsnr") = Me.gessicherheitID Then
isInList = True
If i = 0 Then
prevGessicherheitID = -1 ' no prev Sicherheit
Else
For j As Integer = i - 1 To 0 Step -1
If dataTable.Rows(j).Item("gs_isOpen") Then
prevGessicherheitID = dataTable.Rows(j).Item("gs_gsnr")
'MsgBox("prevGessicherheitID " & prevGessicherheitID)
Exit For
End If
Next
End If
If i = dataTable.Rows.Count - 1 Then
nextGessicherheitID = -1 ' ' no next Sicherheit
Else
For k As Integer = i To dataTable.Rows.Count - 1
If dataTable.Rows(k).Item("gs_isOpen") Then
nextGessicherheitID = dataTable.Rows(k).Item("gs_gsnr")
'MsgBox("nextGessicherheitID " & nextGessicherheitID)
Exit For
End If
Next
End If
End If
Next
End Sub
Private Function setPrevAndNextGesAll() As Integer
For i As Integer = 0 To dataTable.Rows.Count - 1
If dataTable.Rows(i).Item("gs_gsnr") = Me.gessicherheitID Then
If i = 0 Then
prevGessicherheitID = -1 ' no prev Sicherheit
Else
prevGessicherheitID = dataTable.Rows(i - 1).Item("gs_gsnr")
End If
If i = dataTable.Rows.Count - 1 Then
nextGessicherheitID = -1 ' ' no next Sicherheit
Else
nextGessicherheitID = dataTable.Rows(i + 1).Item("gs_gsnr")
End If
'MsgBox("prevGessicherheitID " & prevGessicherheitID)
'MsgBox("nextGessicherheitID " & nextGessicherheitID)
Return i
End If
Next
End Function
Private Sub btnPrev_Click(sender As Object, e As EventArgs) Handles btnPrev.Click
If dataTable.Rows.Count < 2 Then Exit Sub
If (cbx_offene.Checked) Then
setPrevAndNextGesIDAllOpen()
Else
setPrevAndNextGesAll()
End If
If Me.prevGessicherheitID = -1 Then
initPrevNextButtons()
Exit Sub
ElseIf Me.prevGessicherheitID > 0 Then
Me.gessicherheitID = Me.prevGessicherheitID
End If
LoadDGVSicherheiten()
End Sub
Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
If dataTable.Rows.Count < 2 Then Exit Sub
If (cbx_offene.Checked) Then
setPrevAndNextGesIDAllOpen()
Else
setPrevAndNextGesAll()
End If
If Me.nextGessicherheitID = -1 Then
initPrevNextButtons()
Exit Sub
ElseIf Me.nextGessicherheitID > 0 Then
Me.gessicherheitID = Me.nextGessicherheitID
End If
LoadDGVSicherheiten()
End Sub
Private Sub initPrevNextButtons()
If nextGessicherheitID = -1 Then
btnNext.Enabled = True
Else
btnNext.Enabled = True
End If
If prevGessicherheitID = -1 Then
btnPrev.Enabled = True
Else
btnPrev.Enabled = True
End If
End Sub
Private Sub cbxZollsatzueberschreiben_CheckedChanged(sender As Object, e As EventArgs) Handles cbxZollsatzueberschreiben.CheckedChanged
If cbxZollsatzueberschreiben.Checked Then
txtZollsatzueberschreiben.Enabled = True
Else
txtZollsatzueberschreiben.Enabled = False
txtZollsatzueberschreiben.Text = currentGesSichRef.brgakto_gs_zollsatz.ToString
End If
End Sub
Private Sub txtZollsatzueberschreiben_TextChanged(sender As Object, e As EventArgs) Handles txtZollsatzueberschreiben.TextChanged
lblZollsatz.Text = "Zollsatz: " & txtZollsatzueberschreiben.Text & "%"
Zollsatz = CDbl(setNullToZero(txtZollsatzueberschreiben.Text))
ZollsatzMulti = CDbl(setNullToZero(txtZollsatzueberschreiben.Text)) / 100
End Sub
Private Sub btnSaveDatetime_Click(sender As Object, e As EventArgs) Handles btnSaveDatetime.Click
Try
Dim a As Date = Date.ParseExact(txtSicherheitDat.Text, "dd.MM.yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
Dim b As Date = Date.ParseExact(txtSicherheitTime.Text, "HH:mm", System.Globalization.DateTimeFormatInfo.InvariantInfo)
Dim ab As Date = a.AddHours(b.Hour).AddMinutes(b.Minute)
MsgBox(ab.ToString)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub calcGesamtsummen()
txtAnzalPosGes.Text = DirectCast(dgvGesamtsicherheit.Rows.Count().ToString(), String)
txtPosAnzalPosGes.Text = DirectCast(dgvSicherheitsPos.Rows.Count().ToString(), String)
Dim countSicherheitsbetrag As Double = 0
Dim countWarenwert As Double = 0
For i As Integer = 0 To dgvGesamtsicherheit.Rows.Count - 1
countSicherheitsbetrag += CDbl(dgvGesamtsicherheit.Rows(i).Cells("gs_sicherheitsbetrag").Value)
countWarenwert += CDbl(dgvGesamtsicherheit.Rows(i).Cells("gs_warenwert").Value)
Next
txtSicherheitsbGes._value = countSicherheitsbetrag.ToString
txtWarenwertGes._value = countWarenwert.ToString
Dim countSicherheitsbetragPos As Double = 0
Dim countWarenwertPos As Double = 0
For i As Integer = 0 To dgvSicherheitsPos.Rows.Count - 1
countSicherheitsbetragPos += CDbl(dgvSicherheitsPos.Rows(i).Cells("gsp_sicherheitsbetrag").Value)
countWarenwertPos += CDbl(dgvSicherheitsPos.Rows(i).Cells("gsp_warenwert").Value)
Next
txtPosSicherheitsbGes._value = countSicherheitsbetragPos.ToString
txtPosWarenwertGes._value = countWarenwertPos.ToString
lbloffenerWarenwert.Text = "offener Warenwert: €"
lbloffenerWarenwert.Text &= Math.Round(countWarenwert, 2) - Math.Round(countWarenwertPos, 2)
If (Math.Abs(countSicherheitsbetrag - countSicherheitsbetragPos) < 0.1 AndAlso Math.Abs(countSicherheitsbetrag - countSicherheitsbetragPos) <> 0) Then
btnRundungsdifAusgl.Enabled = True
rundungsdiff = Math.Round(countSicherheitsbetrag - countSicherheitsbetragPos, 2)
Else
btnRundungsdifAusgl.Enabled = False
End If
End Sub
Private Sub rearangePosNr(gsNr As Integer, ATBNr As String, posNr As Integer)
If posNr = -1 Or posNr = 1 Then Exit Sub
Dim sqlq As String = "select [gs_gsId], [gs_posNr] from [tblGesamtsicherheit] where gs_gsnr = " & gsNr & " AND gs_ATBNR = '" & ATBNr & "' AND gs_posNr > '" & posNr & "'"
Dim dt As New DataTable
dt = SQL.loadDgvBySql(sqlq, "AVISO", 100, True)
If (dt.Rows.Count = 0) Then Exit Sub
For i As Integer = 0 To dt.Rows.Count - 1
'MsgBox("gs_gsId: " & dt.Rows(i).Item("gs_gsId").ToString & " " & "gs_posNr: " & dt.Rows(i).Item("gs_posNr").ToString)
Dim sicherheit = New cSicherheiten(dt.Rows(i).Item("gs_gsId"), dt.Rows(i).Item("gs_posNr"))
Dim currentPos = sicherheit.gs_posNr
sicherheit.gs_posNr = currentPos - 1
sicherheit.UPDATEWithNewPosNr()
Next
End Sub
Private Sub txtlkwIdSearch_VALUE_CHANGED() Handles txtlkwIdSearch.VALUE_CHANGED
If (txtlkwIdSearch._value <> "") Then
txtLKWKZ.Text = txtlkwIdSearch._value
txtLKWKZ.ReadOnly = True
Else
txtLKWKZ.Clear()
txtLKWKZ.ReadOnly = False
End If
End Sub
Private Sub ATBNraendernToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ATBNraendernToolStripMenuItem.Click
Dim ATBNr As String
Dim mutlitpleATBNr As Boolean = False
ATBNr = dgvGesamtsicherheit.SelectedRows(dgvGesamtsicherheit.SelectedRows.Count - 1).Cells("gs_ATBNr").Value.ToString
If dgvGesamtsicherheit.SelectedRows.Count > 0 Then
For Each row As DataGridViewRow In dgvGesamtsicherheit.SelectedRows
If row.Cells("gs_ATBNr").Value.ToString <> ATBNr Then
mutlitpleATBNr = True
End If
Next
End If
If mutlitpleATBNr Then
lblWarningATB.Text = "ACHTUNG!" & vbCrLf & "Es wurden unterschiedl. Reg-Nr. markiert!"
Else
lblWarningATB.Text = ""
End If
dgvGesamtsicherheit.Enabled = False
txtATBNraendern.Text = ATBNr
pnlChangeATBNr.Visible = True
End Sub
Private Sub ATCMRNNraendernToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ATCMRNNraendernToolStripMenuItem.Click
Dim ATCNr As String
Dim tempDatum As String
Dim TempUhrzeit As String
Dim mutlitpleATCNr As Boolean = False
Dim Warenwert As Double
ATCNr = dgvSicherheitsPos.SelectedRows(dgvSicherheitsPos.SelectedRows.Count - 1).Cells("gsp_ATCNr").Value.ToString
tempDatum = If(dgvSicherheitsPos.SelectedRows(dgvSicherheitsPos.SelectedRows.Count - 1).Cells("gsp_datum").Value IsNot DBNull.Value, CDate(dgvSicherheitsPos.SelectedRows(dgvSicherheitsPos.SelectedRows.Count - 1).Cells("gsp_datum").Value).ToString("dd.MM.yyyy"), "")
TempUhrzeit = If(dgvSicherheitsPos.SelectedRows(dgvSicherheitsPos.SelectedRows.Count - 1).Cells("gsp_datum").Value IsNot DBNull.Value, CDate(dgvSicherheitsPos.SelectedRows(dgvSicherheitsPos.SelectedRows.Count - 1).Cells("gsp_datum").Value).ToString("HH:mm"), "")
Warenwert = If(dgvSicherheitsPos.SelectedRows(dgvSicherheitsPos.SelectedRows.Count - 1).Cells("gsp_warenwert").Value IsNot DBNull.Value, CDbl(dgvSicherheitsPos.SelectedRows(dgvSicherheitsPos.SelectedRows.Count - 1).Cells("gsp_warenwert").Value), "")
If dgvSicherheitsPos.SelectedRows.Count > 0 Then
For Each row As DataGridViewRow In dgvSicherheitsPos.SelectedRows
If row.Cells("gsp_ATCNr").Value.ToString <> ATCNr Then
mutlitpleATCNr = True
End If
Next
End If
If mutlitpleATCNr Then
lblATCwarning.Text = "ACHTUNG!" & vbCrLf & "Es wurden unterschiedl. Reg-Nr.Nummern markiert!"
Else
lblATCwarning.Text = ""
End If
dgvSicherheitsPos.Enabled = False
txtATCaendern.Text = ATCNr
txtDatumaendern.Text = tempDatum
txtUhrzeitaendern.Text = TempUhrzeit
txtWarenwertContext.Text = Warenwert.ToString
pnlChangeATCNr.Visible = True
End Sub
Private Sub dgvSicherheitsPos_SelectionChanged(sender As Object, e As EventArgs) Handles dgvSicherheitsPos.SelectionChanged
If dgvSicherheitsPos.SelectedRows.Count > 0 Then
ATCMRNNraendernToolStripMenuItem.Visible = True
loadTitle()
Else
ATCMRNNraendernToolStripMenuItem.Visible = False
End If
End Sub
Private Sub FlatButton1_Click(sender As Object, e As EventArgs) Handles FlatButton1.Click
If txtATBNraendern.Text = "" Then
MsgBox("Bitte ATR-Nr angeben!")
Exit Sub
End If
If dgvGesamtsicherheit.SelectedRows.Count > 0 Then
For Each row As DataGridViewRow In dgvGesamtsicherheit.SelectedRows
Dim sicherh As New cSicherheiten(row.Cells("gs_gsId").Value, row.Cells("gs_posNr").Value)
sicherh.gs_ATBNr = txtATBNraendern.Text
sicherh.SAVE()
Next
End If
pnlChangeATBNr.Visible = False
dgvGesamtsicherheit.Enabled = True
AfterButton()
End Sub
Private Sub FlatButton2_Click(sender As Object, e As EventArgs) Handles FlatButton2.Click
pnlChangeATBNr.Visible = False
dgvGesamtsicherheit.Enabled = True
End Sub
Private Sub FlatButton3_Click(sender As Object, e As EventArgs) Handles FlatButton3.Click
If txtATCaendern.Text = "" Then
MsgBox("Bitte Reg/MRN-Nr angeben!")
Exit Sub
End If
If txtUhrzeitaendern.Text = "" Or txtDatumaendern.Text = "" Then
MsgBox("Bitte Datum/Uhrzeit angeben!")
Exit Sub
End If
If txtWarenwertContext.Text = "" Then
MsgBox("Bitte Warenwert angeben!")
Exit Sub
End If
If dgvSicherheitsPos.SelectedRows.Count > 0 Then
Dim firstIndex As Integer = 10000
If dgvSicherheitsPos.SelectedRows.Count = 1 Then firstIndex = dgvSicherheitsPos.SelectedRows(0).Index
If dgvSicherheitsPos.SelectedRows.Count > 1 Then
For Each row As DataGridViewRow In dgvSicherheitsPos.SelectedRows
If row.Index < firstIndex Then
firstIndex = row.Index
End If
Next
End If
For Each row As DataGridViewRow In dgvSicherheitsPos.SelectedRows
Dim SicherhPos As New cGesamtsicherheitsPositionen(row.Cells("gsp_gsId").Value, row.Cells("gsp_gspPosId").Value)
If row.Index = firstIndex Then
Dim warenwert = Double.Parse(txtWarenwertContext.Text)
SicherhPos.gsp_warenwert = warenwert
SicherhPos.gsp_sicherheitsbetrag = Double.Parse(txtSicherheitsbetragContext.Text)
If warenwert > 0 Then
SicherhPos.gsp_art = "CLOSE"
End If
End If
SicherhPos.gsp_ATCNr = txtATCaendern.Text
SicherhPos.gsp_datum = DateTimeString2DateTimeKonvertinator(txtDatumaendern.Text, txtUhrzeitaendern.Text)
SicherhPos.SAVE()
Next
End If
pnlChangeATCNr.Visible = False
dgvSicherheitsPos.Enabled = True
AfterButton()
End Sub
Private Sub FlatButton4_Click(sender As Object, e As EventArgs) Handles FlatButton4.Click
pnlChangeATCNr.Visible = False
dgvSicherheitsPos.Enabled = True
End Sub
Private Sub txtAbfertNum_TextChanged(sender As Object, e As EventArgs) Handles txtAbfertNum.TextChanged
If Not IsNumeric(txtAbfertNum.Text) AndAlso txtAbfertNum.Text <> "" Then
txtAbfertNum.ForeColor = Color.Red
btnSave.Enabled = False
Exit Sub
Else
txtAbfertNum.ForeColor = Color.Black
btnSave.Enabled = True
End If
End Sub
Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click
If Not System.Windows.Forms.Application.OpenForms.Item("frmGesamtsicherheitenMenuNEU") Is Nothing Then
Dim p = System.Windows.Forms.Application.OpenForms.Item("frmGesamtsicherheitenMenuNEU")
DirectCast(p, frmGesamtsicherheitenMenuNEU).btnNeu.PerformClick()
Me.Close()
Me.Cursor = Cursors.Default : Exit Sub
End If
End Sub
Private Sub dtpSicherheitDat_ValueChanged(sender As Object, e As EventArgs) Handles dtpSicherheitDat.ValueChanged
txtSicherheitDat._value = CDate(sender.value).ToShortDateString
End Sub
Private Sub dtpPosDat_ValueChanged(sender As Object, e As EventArgs) Handles dtpPosDat.ValueChanged
txtPosDat._value = CDate(sender.value).ToShortDateString
End Sub
Private Sub txtPosTime_Leave(sender As Object, e As EventArgs) Handles txtPosTime.Leave, txtSicherheitTime.Leave, txtUhrzeitaendern.Leave
If txtPosTime.Text <> "" Then
txtPosTime.Text = Replace(txtPosTime.Text, ".", ":")
txtPosTime.Text = Replace(txtPosTime.Text, ",", ":")
End If
If txtSicherheitTime.Text <> "" Then
txtSicherheitTime.Text = Replace(txtSicherheitTime.Text, ".", ":")
txtSicherheitTime.Text = Replace(txtSicherheitTime.Text, ",", ":")
End If
If txtUhrzeitaendern.Text <> "" Then
txtUhrzeitaendern.Text = Replace(txtUhrzeitaendern.Text, ".", ":")
txtUhrzeitaendern.Text = Replace(txtUhrzeitaendern.Text, ",", ":")
End If
End Sub
Private Sub txtPosDat_Leave(sender As Object, e As EventArgs) Handles txtPosDat.Leave, txtSicherheitDat.Leave, txtDatumaendern.Leave, txtUhrzeitaendern.Leave
If txtPosDat.Text <> "" Then
txtPosDat.Text = Replace(txtPosDat.Text, "/", ".")
txtPosDat.Text = Replace(txtPosDat.Text, ",", ".")
End If
If txtSicherheitDat.Text <> "" Then
txtSicherheitDat.Text = Replace(txtSicherheitDat.Text, "/", ".")
txtSicherheitDat.Text = Replace(txtSicherheitDat.Text, ",", ".")
End If
If txtDatumaendern.Text <> "" Then
txtDatumaendern.Text = Replace(txtDatumaendern.Text, "/", ".")
txtDatumaendern.Text = Replace(txtDatumaendern.Text, ",", ".")
End If
End Sub
Private Sub changeLabel(Optional isATR As Boolean = True)
If Standort = "Verag GmbH" Then
Label1.Text = "Reg-Nr."
If isATR Then
Label12.Text = "Reg-Nr. / MRN"
Else
Label12.Text = "CRN / MRN"
End If
ElseIf Standort = "VERAG AG" Then
Label12.Text = "T1 CRN"
Label1.Text = "T1 MRN"
Else
Label12.Text = "EZA / T1 CRN"
Label1.Text = "T1 MRN"
End If
End Sub
Private Sub btnRundungsdifAusgl_Click(sender As Object, e As EventArgs) Handles btnRundungsdifAusgl.Click
Try
If (rundungsdiff <> 0) AndAlso checkIfRundungsPosExists() = False Then
Dim OPEN As New cSicherheiten()
With OPEN
.gs_gsNr = gessicherheitID
.gs_ATBNr = "Korrekt. Rundungsdiff. " & gessicherheitID
.gs_posNr = Me.getLatestPosNr(currentSicherheit.gs_gsNr, currentSicherheit.gs_ATBNr) + 1
.gs_datum = DateTime.Now
.gs_warenwert = 0
.gs_sicherheitsbetrag = 0
.gs_standort = Me.Standort
.gs_art = "OPEN"
.gs_erstellungsdatum = DateTime.Now
.gs_freitext = ""
.gs_saldo = currentGesSichRef.brgakto_gs_aktSaldo
.gs_atr = setNullToZero(cboSicherheitATR.SelectedItem)
.gs_zollsatz = Me.Zollsatz
.gs_avisoId = Me.avisoID
.gs_isRundungsdiff = True
setEnviromentDataToObject(OPEN, Me)
End With
Dim gs_gsId = OPEN.SAVEOBJECT()
Dim SicherheitsPos As New cGesamtsicherheitsPositionen()
With SicherheitsPos
.gsp_gsId = gs_gsId
.gsp_gspPosId = OPEN.gs_posNr
.gsp_warenwert = 0
.gsp_sicherheitsbetrag = rundungsdiff
.gsp_freitext = ""
.gsp_filialenNr = currentSicherheit.gs_filialenNr
.gsp_art = "CLOSE"
.gsp_gsNr = gessicherheitID
.gsp_abfertigungsNr = currentSicherheit.gs_abfertigungsnr
.gsp_datum = DateTime.Now
.gsp_erstellungsdatum = DateTime.Now
.gsp_ust = currentSicherheit.gs_ust
.gsp_ATCNr = "Korrekt. Rundungsdiff. " & gessicherheitID
.gsp_isPosRundungsdiff = True
.gsp_avisoId = Me.avisoID
.gsp_systemuser = VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME
End With
SicherheitsPos.SAVE()
cbxRundPosanzeigen.Checked = True
AfterButton()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Function checkIfRundungsPosExists()
If dgvGesamtsicherheit.Rows.Count < 1 Then Return False
For Each Row In dgvGesamtsicherheit.Rows
Dim sicherh As New cSicherheiten(Row.Cells("gs_gsId").Value, Row.Cells("gs_posNr").Value)
If sicherh.gs_isRundungsdiff Then Return True
Next
Return False
End Function
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles cbxRundPosanzeigen.CheckedChanged
LoadDGVSicherheiten(True)
End Sub
Private Function checkDateOfPosition(datum As String, uhrzeit As String) As Boolean
Dim checkOK As Boolean = True
Dim datumPos As Date = Nothing
If datum <> "" AndAlso uhrzeit <> "" Then
datumPos = DateTimeString2DateTimeKonvertinator(datum, uhrzeit)
ElseIf datum <> "" Then
datumPos = CDate(datum).ToShortDateString
End If
If datumPos <> Nothing And dgvGesamtsicherheit.Rows.Count > 0 Then
If IsDate(dgvGesamtsicherheit.Rows(0).Cells("gs_datum").Value) Then
If datumPos <= dgvGesamtsicherheit.Rows(0).Cells("gs_datum").Value Then
MsgBox("Datum/Uhrzeit des Gestellungsausganges muss zeitlich nach dem Gestellungseingang liegen! (" & dgvGesamtsicherheit.Rows(0).Cells("gs_datum").Value & ")")
checkOK = False
End If
End If
End If
Return checkOK
End Function
Private Function checkMandatoryFields() As Boolean
Dim valuesOK As Boolean = True
If (txtAnzahlPos.Text = "") Then
txtAnzahlPos.Focus()
valuesOK = False
End If
Return valuesOK
End Function
Private Sub txt_Suche_KeyDown(sender As Object, e As KeyEventArgs) Handles txtSuche.KeyDown
If e.KeyCode = Keys.Enter Then
If txtSuche.Text <> "" Then
If Me.Visible Then LoadDGVSicherheiten(True)
e.Handled = True
Else
If Me.Visible Then LoadDGVSicherheiten(True)
e.Handled = True
End If
End If
End Sub
End Class