1424 lines
53 KiB
VB.net
1424 lines
53 KiB
VB.net
|
|
Imports System.Data.SqlTypes
|
|
Imports System.Linq.Expressions
|
|
Imports GrapeCity.Viewer.Common.Model
|
|
Imports Org.BouncyCastle.Cms
|
|
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 indexGspPosId As Integer
|
|
|
|
Dim isOpen As Boolean = False
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
|
|
Public dataTable As New DataTable()
|
|
|
|
Public dtSicherheiten As New DataTable()
|
|
|
|
|
|
Private Sub frmGesamtsicherheitNEU_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
|
|
currentGesSichRef = New VERAG_PROG_ALLGEMEIN.cAufschubKonten(Standort)
|
|
SaldoNew = Decimal.Parse(currentGesSichRef.CalcSaldo())
|
|
lblSaldo.Text = "Saldo: €" & Decimal.Parse(currentGesSichRef.CalcSaldo()).ToString("N")
|
|
|
|
Me.Text = "Gesamtsicherheit " & Standort
|
|
|
|
|
|
cbx_Suche_Warenort.fillWithSQL("SELECT [wo_warenort],CONCAT([wo_knnr],' - ' ,[wo_bezeichnung]) FROM [tblWarenorte] WHERE [wo_aktiv] ='1' ORDER BY [wo_reihenfolge]", True, "AVISO", True)
|
|
|
|
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_knnr],' - ' ,[wo_bezeichnung]) FROM [tblWarenorte] WHERE [wo_aktiv] ='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)
|
|
|
|
Else
|
|
LoadDGVSicherheiten()
|
|
End If
|
|
LoadStandort()
|
|
cboSicherheitATR.Enabled = currentGesSichRef.brgakto_gs_ATR
|
|
|
|
cbx_offene.Checked = True
|
|
initPrevNextButtons()
|
|
|
|
|
|
Me.Text = "Gesamtsicherheit " & Standort
|
|
frmHauptfenster.EnableDoubleBuffered(dgvSicherheitsPos)
|
|
End Sub
|
|
|
|
|
|
|
|
Public Sub LoadDGVSicherheiten(Optional withFilterParam As Boolean = False)
|
|
|
|
'lblSaldo.Text = "Saldo: € " & currentGesSichRef.gsr_Saldo.ToString()
|
|
lblGestellungNr.Text = ""
|
|
Dim sqladd1 As String = ""
|
|
If currentGesSichRef.brgakto_gs_ustEnabled Then sqladd1 &= ", FORMAT((([gs_warenwert] + [gs_sicherheitsbetrag]) * " & currentGesSichRef.brgakto_gs_ust & "/100), 'C', 'de-DE') as gs_ust"
|
|
If currentGesSichRef.brgakto_gs_ATR Then sqladd1 &= ", [gs_atr]"
|
|
Dim sqlSearchSting As String = ""
|
|
If withFilterParam = True Then
|
|
If txt_Suche.Text <> "" Then sqlSearchSting &= "AND ([gs_abfertigungsNr] Like '%" & txt_Suche.Text & "%' OR [gs_ATBNr] Like '%" & txt_Suche.Text & "%' OR [gs_LKWKZ] like '%" & txt_Suche.Text & "%' OR [gs_avisoId] like '%" & txt_Suche.Text & "%' OR [gs_freitext] like '%" & txt_Suche.Text & "%')"
|
|
If cbx_Suche_Warenort._value <> "" Then sqlSearchSting &= "AND gs_warenort like '%" & cbx_Suche_Warenort._value & "%'"
|
|
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_gsId"
|
|
|
|
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
|
|
.Columns("gs_ATBNr").HeaderText = "ATB"
|
|
.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"
|
|
Case Else
|
|
.Columns("gs_ATBNr").HeaderText = "ATB"
|
|
.Columns("gs_ATBNr").Width = 150
|
|
End Select
|
|
|
|
|
|
.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
|
|
|
|
End If
|
|
|
|
calcGesamtsummen()
|
|
|
|
|
|
End Sub
|
|
|
|
Public Sub LoadDataTableSicherheitenForExport(list As List(Of Integer), datumVon As String, datumBis As String)
|
|
|
|
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 'ATB 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_erstellungsdatum as Date) as Datum, CONVERT(VARCHAR(5),gsp_erstellungsdatum, 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("ATB 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("ATB 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")
|
|
|
|
|
|
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_gsNr").Value)
|
|
currentSicherheit = New cSicherheiten(indexGsId)
|
|
LoadDGVSicherheitsPos(indexGsId, True)
|
|
loadTitle()
|
|
setSaldo()
|
|
|
|
If dgvGesamtsicherheit.Enabled = False Then Exit Sub
|
|
ATBNraendernToolStripMenuItem.Visible = True
|
|
|
|
Else
|
|
LoadDGVSicherheitsPos(-1, True)
|
|
ATBNraendernToolStripMenuItem.Visible = False
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub LoadDGVSicherheitsPos(gsNr As Integer, Optional withFilterParam As Boolean = False)
|
|
|
|
'If gsNr = "" Then Exit Sub
|
|
|
|
Dim sqlSearchSting As String = ""
|
|
|
|
If withFilterParam = True Then
|
|
sqlSearchSting &= "And gsp_gsid In (Select gs_gsId from [tblGesamtsicherheit] where [gs_gsnr] = '" & gessicherheitID & "'"
|
|
If txt_Suche.Text <> "" Then sqlSearchSting &= "AND ([gs_abfertigungsNr] Like '%" & txt_Suche.Text & "%' OR [gs_ATBNr] Like '%" & txt_Suche.Text & "%' OR [gs_LKWKZ] like '%" & txt_Suche.Text & "%' OR [gs_avisoId] like '%" & txt_Suche.Text & "%' OR [gs_freitext] like '%" & txt_Suche.Text & "%')"
|
|
If cbx_Suche_Warenort._value <> "" Then sqlSearchSting &= " AND gs_warenort like '%" & cbx_Suche_Warenort._value & "%'"
|
|
sqlSearchSting &= ")"
|
|
End If
|
|
|
|
|
|
Dim SQLStringCRN As String =
|
|
"select [gsp_gspPosId],[gsp_ATCNr],[gsp_erstellungsdatum],[gsp_gsId],[gsp_gsnr],[gsp_warenwert],[gsp_sicherheitsbetrag], [gsp_freitext]" &' ,[gsp_avisoId] ,[gsp_ust] ,[gsp_filialenNr],[gsp_abfertigungsNr] ,[gsp_MRNNr], [gsp_art]
|
|
"From [tblGesamtsicherheitsPositionen] where [gsp_gsnr] = '" & gsNr & "'" & sqlSearchSting & " order by [gsp_gsId]"
|
|
|
|
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
|
|
.Columns("gsp_ATCNr").HeaderText = "ATC / MRN"
|
|
Case Else
|
|
.Columns("gsp_ATCNr").HeaderText = "CRN / MRN"
|
|
End Select
|
|
.Columns("gsp_ATCNr").Width = 140
|
|
.Columns("gsp_erstellungsdatum").Width = 100
|
|
.Columns("gsp_erstellungsdatum").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
|
|
|
|
End If
|
|
btnAddPos.Visible = True
|
|
|
|
End Sub
|
|
|
|
|
|
'Private Sub dgvSicherheitsPos_SelectionChanged(sender As Object, e As EventArgs) Handles dgvSicherheitsPos.SelectionChanged
|
|
' If dgvSicherheitsPos.SelectedRows.Count > 0 Then
|
|
|
|
' indexGspPosId = CInt(dgvSicherheitsPos.SelectedRows(0).Cells("gsp_gspPosId").Value)
|
|
' currentSPos = New cGesamtsicherheitsPositionen(indexGsId, indexGspPosId)
|
|
|
|
' If dgvSicherheitsPos.Enabled = False Then Exit Sub
|
|
|
|
' End If
|
|
'End Sub
|
|
|
|
Sub loadTitle()
|
|
'Dim StandortSqlString As String = "select * from [tblGesamtsicherheit] where [gs_gsNr] = '" & gessicherheitID & "'"
|
|
|
|
lblGestellungNr.Text = ""
|
|
lblId.Text = ""
|
|
Dim StandortSqlString As String = "select * from [tblGesamtsicherheit] where [gs_gsId] = '" & indexGsId & "'"
|
|
|
|
|
|
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 = setNullToZero(dt.Rows(0).Item("gs_abfertigungsNr"))
|
|
Me.warenortID = setNullToZero(dt.Rows(0).Item("gs_warenort"))
|
|
End If
|
|
|
|
If Me.avisoID.ToString.Length > 0 Then lblGestellungNr.Text &= "Aviso-ID: " & Me.avisoID & " "
|
|
If Me.LKWKZ.ToString.Length > 0 Then lblGestellungNr.Text &= "LKW-ID: " & Me.LKWKZ & " "
|
|
If Me.FilialNummer.ToString.Length > 0 Then lblGestellungNr.Text &= "FilialNr: " & Me.FilialNummer & " "
|
|
If Me.Abfertigungsnummer.Length > 0 Then lblGestellungNr.Text &= "AbfNr: " & Me.Abfertigungsnummer & " "
|
|
If Me.warenortID.Length > 0 Then lblGestellungNr.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 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 DateTime_Keypresses(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtPosDate.KeyPress, txtPosTime.KeyPress, txtSicherheitDate.KeyPress, txtSicherheitTime.KeyPress
|
|
Select Case Asc(e.KeyChar)
|
|
Case 48 To 57, 8, 46, 58
|
|
|
|
' 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 txtSicherheitDate.GotFocus, txtPosDate.GotFocus, txtSicherheitTime.GotFocus, txtPosTime.GotFocus
|
|
Select Case sender.name
|
|
Case "txtSicherheitDate"
|
|
If txtSicherheitDate.Text.Length < 1 Then txtSicherheitDate.Text = Date.Today.ToString("dd.MM.yyyy")
|
|
Case "txtPosDate"
|
|
If txtPosDate.Text.Length < 1 Then txtPosDate.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")
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub btnAddSicherheit_Click(sender As Object, e As EventArgs) Handles btnAddSicherheit.Click
|
|
|
|
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
|
|
|
|
Try
|
|
|
|
If (txtAnzahlPos.Text = "") Then
|
|
txtAnzahlPos.Focus()
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim limit As Integer = Integer.Parse(setNullToZero(txtAnzahlPos.Text))
|
|
|
|
|
|
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(txtSicherheitDate.Text, txtSicherheitTime.Text)
|
|
.gs_warenwert = warenwert
|
|
.gs_sicherheitsbetrag = sicherheitsbetrag
|
|
.gs_standort = Me.Standort
|
|
.gs_art = "OPEN"
|
|
.gs_erstellungsdatum = Me.datum
|
|
.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 = Me.datum
|
|
.gsp_avisoId = ""
|
|
.gsp_ust = ""
|
|
.gsp_avisoId = Me.avisoID
|
|
'.gsp_ATCNr = ""
|
|
.gsp_gsNr = OPEN.gs_gsNr
|
|
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
|
|
|
|
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(txtPosDate.Text, txtPosTime.Text)
|
|
.gs_warenwert = 0
|
|
.gs_sicherheitsbetrag = 0
|
|
.gs_standort = Me.Standort
|
|
.gs_art = "OPEN"
|
|
.gs_erstellungsdatum = Me.datum
|
|
.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_erstellungsdatum = DateTimeString2DateTimeKonvertinator(txtPosDate.Text, txtPosTime.Text)
|
|
.gsp_ust = currentSicherheit.gs_ust
|
|
.gsp_ATCNr = txtPositionenCRN.Text
|
|
.gsp_avisoId = Me.avisoID
|
|
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()
|
|
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" 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, "HH: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
|
|
|
|
Me.Abfertigungsnummer = txtAbfertNum.Text
|
|
Me.LKWKZ = txtLKWID.Text
|
|
|
|
If setNullToZero(Me.gessicherheitID) > 0 Then
|
|
Dim sqlstring = "Update [tblGesamtsicherheit] set [gs_filialenNr] = '" & Me.FilialNummer & "', [gs_abfertigungsNr] = '" & Me.Abfertigungsnummer & "', [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 Or obj = "" Then
|
|
Return Nothing
|
|
Else
|
|
Return Integer.Parse(CStr(obj))
|
|
End If
|
|
|
|
Case "Double"
|
|
If obj Is Nothing Or obj Is DBNull.Value Or obj = "" Then
|
|
Return Nothing
|
|
Else
|
|
Return Double.Parse(CStr(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
|
|
txtSicherheitDate.Text = Sicherh.gs_erstellungsdatum.ToString("dd.MM.yyyy")
|
|
txtSicherheitTime.Text = Sicherh.gs_erstellungsdatum.ToString("HH:mm")
|
|
|
|
currentSicherheit = Sicherh
|
|
txtAnzahlPos.Enabled = False
|
|
|
|
btnAddSicherheit.Visible = False
|
|
btnUpdateSicherheit.Visible = True
|
|
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(txtSicherheitDate.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.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
|
|
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)
|
|
|
|
End With
|
|
If checkSicherheitsbetrag() = False Then Exit Sub
|
|
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)
|
|
|
|
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)
|
|
txtPosDate.Text = sPos.gsp_erstellungsdatum.ToString("dd.MM.yyyy")
|
|
txtPosTime.Text = sPos.gsp_erstellungsdatum.ToString("HH:mm")
|
|
|
|
|
|
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 lblGestellungNr.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' ORDER BY [wo_reihenfolge] ", True, "AVISO", True)
|
|
cboWarenort.SelectedIndex = cbx_Suche_Warenort.FindString(Me.warenortID)
|
|
txtAbfertNum.Text = Me.Abfertigungsnummer
|
|
txtLKWID.Text = Me.LKWKZ
|
|
panOben.Enabled = False
|
|
End Sub
|
|
|
|
Private Sub btnClosePanOverlay_Click(sender As Object, e As EventArgs) Handles btnClosePanOverlay.Click
|
|
panOverlay.Visible = False
|
|
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
|
|
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) Handles btnSuche.Click
|
|
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) Handles btn_resetSearch.Click
|
|
|
|
Dim dgv As String = ""
|
|
For Each c As DataGridViewColumn In dgvGesamtsicherheit.Columns
|
|
dgv &= c.Width & c.HeaderText & vbCrLf
|
|
Next
|
|
|
|
clearSearchFields()
|
|
|
|
LoadDGVSicherheiten()
|
|
currentGesSichRef.LOAD()
|
|
LoadStandort()
|
|
End Sub
|
|
|
|
Private Sub clearSearchFields()
|
|
cbx_Suche_Warenort.changeItem("")
|
|
txt_Suche.Clear()
|
|
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 currentSaldo As Double = Decimal.Parse(currentGesSichRef.CalcSaldo()).ToString("N")
|
|
|
|
Dim SaldoNewTemp = SaldoNew
|
|
Dim calcSicherheiten As Double = calcSicherheitsbetragGestelle()
|
|
Dim calcSicherheitenPos As Double = calcSicherheitsbetragPos()
|
|
Dim newCalcSaldo As Double
|
|
|
|
|
|
If newPosition Then
|
|
newCalcSaldo = SaldoNewTemp - currentSBetrag
|
|
Else
|
|
newCalcSaldo = SaldoNewTemp - currentSBetrag
|
|
End If
|
|
|
|
Dim referenzbetrag As Double = currentGesSichRef.brgakto_betrag
|
|
|
|
|
|
If SaldoNewTemp < 0 Then
|
|
MsgBox("Achtung!" & vbCrLf & " Saldo ist NEGATIV")
|
|
Return True 'Saldo ist bereits negativ!
|
|
End If
|
|
|
|
Dim diffAbs As Double = Math.Abs(SaldoNewTemp - currentSBetrag)
|
|
|
|
If (referenzbetrag - newCalcSaldo < 0) Then
|
|
If vbNo = MsgBox("ACHTUNG! " & vbCrLf & " Dieser Sicherheitsbetrag würde den jezigen Saldo um " & diffAbs & " ü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 S-Betrag: €"
|
|
Dim offernerSB As Double = Me.calcOffenerSicherheitsbetrag()
|
|
If offernerSB <> 0 Then
|
|
lbloffenerSaldo.Text &= Decimal.Parse(Math.Round(offernerSB, 2)).ToString("N")
|
|
|
|
isOpen = True
|
|
Else
|
|
lbloffenerSaldo.Text &= "0"
|
|
isOpen = False
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Function setPrevAndNextGesIDAllOpen()
|
|
|
|
Dim isInList As Boolean = False
|
|
|
|
Dim onlyOpenDT As DataTable
|
|
|
|
onlyOpenDT = dataTable.Select("gs_isOpen = True").CopyToDataTable
|
|
|
|
|
|
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
|
|
|
|
'MsgBox("prevOPENGessicherheitID " & prevGessicherheitID)
|
|
|
|
If i = onlyOpenDT.Rows.Count - 1 Then
|
|
nextGessicherheitID = -1 ' no next Sicherheit
|
|
Else
|
|
nextGessicherheitID = onlyOpenDT.Rows(i + 1).Item("gs_gsnr")
|
|
|
|
End If
|
|
|
|
'MsgBox("nextOPENGessicherheitID " & nextGessicherheitID)
|
|
|
|
End If
|
|
|
|
Next
|
|
|
|
If isInList = False AndAlso onlyOpenDT.Rows.Count - 1 <> 0 Then
|
|
|
|
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
|
|
|
|
For j As Integer = i To 0
|
|
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 If
|
|
|
|
End Function
|
|
|
|
Private Function setPrevAndNextGesAll()
|
|
|
|
For i As Integer = 0 To dataTable.Rows.Count - 1
|
|
If dataTable.Rows(i).Item("gs_gsnr") = Me.gessicherheitID Then
|
|
|
|
prevGessicherheitID = dataTable.Rows(i).Item("gs_gsnr") - 1
|
|
|
|
nextGessicherheitID = dataTable.Rows(i).Item("gs_gsnr") + 1
|
|
|
|
|
|
If i = 0 Then prevGessicherheitID = -1 ' no prev Sicherheit
|
|
If i = dataTable.Rows.Count - 1 Then nextGessicherheitID = -1 ' ' no next Sicherheit
|
|
|
|
'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 (cbx_offene.Checked) Then
|
|
setPrevAndNextGesIDAllOpen()
|
|
Else
|
|
setPrevAndNextGesAll()
|
|
End If
|
|
|
|
If Me.prevGessicherheitID = -1 Then
|
|
initPrevNextButtons()
|
|
Exit Sub
|
|
End If
|
|
Me.gessicherheitID = Me.prevGessicherheitID
|
|
|
|
LoadDGVSicherheiten()
|
|
End Sub
|
|
|
|
Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
|
|
|
|
If (cbx_offene.Checked) Then
|
|
setPrevAndNextGesIDAllOpen()
|
|
Else
|
|
setPrevAndNextGesAll()
|
|
End If
|
|
|
|
|
|
|
|
If Me.nextGessicherheitID = -1 Then
|
|
initPrevNextButtons()
|
|
Exit Sub
|
|
End If
|
|
Me.gessicherheitID = Me.nextGessicherheitID
|
|
|
|
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(txtSicherheitDate.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
|
|
|
|
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
|
|
txtLKWID.Text = txtlkwIdSearch._value
|
|
txtLKWID.ReadOnly = True
|
|
Else
|
|
txtLKWID.Clear()
|
|
txtLKWID.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(0).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. ATB-Nummern 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 mutlitpleATCNr As Boolean = False
|
|
|
|
ATCNr = dgvSicherheitsPos.SelectedRows(0).Cells("gsp_ATCNr").Value.ToString
|
|
|
|
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. ATC-Nummern markiert!"
|
|
Else
|
|
lblATCwarning.Text = ""
|
|
End If
|
|
dgvSicherheitsPos.Enabled = False
|
|
txtATCaendern.Text = ATCNr
|
|
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
|
|
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 ATC/MRN-Nr angeben!")
|
|
Exit Sub
|
|
End If
|
|
If dgvSicherheitsPos.SelectedRows.Count > 0 Then
|
|
|
|
For Each row As DataGridViewRow In dgvSicherheitsPos.SelectedRows
|
|
|
|
Dim SicherhPos As New cGesamtsicherheitsPositionen(row.Cells("gsp_gsId").Value, row.Cells("gsp_gspPosId").Value)
|
|
SicherhPos.gsp_ATCNr = txtATCaendern.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) Then
|
|
txtAbfertNum.ForeColor = Color.Red
|
|
btnSave.Enabled = False
|
|
Exit Sub
|
|
Else
|
|
txtAbfertNum.ForeColor = Color.Black
|
|
btnSave.Enabled = True
|
|
|
|
End If
|
|
End Sub
|
|
End Class
|