feature_gesamtsicherheiten
This commit is contained in:
@@ -13,6 +13,8 @@ Public Class frmGesamtsicherheitenNEU
|
||||
Property currentSPos As cGesamtsicherheitsPositionen
|
||||
Property currentGesSichRef As cGesamtsicherheitsReferenz
|
||||
Public Property gessicherheitID As Integer
|
||||
Public Property prevGessicherheitID As Integer = 0
|
||||
Public Property nextGessicherheitID As Integer = 0
|
||||
Public Property datum As DateTime = Nothing
|
||||
Property Standort As String = ""
|
||||
|
||||
@@ -36,8 +38,12 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
Dim indexGspPosId As Integer
|
||||
|
||||
Dim isOpen As Boolean = False
|
||||
|
||||
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
||||
|
||||
Public dt As New DataTable
|
||||
|
||||
|
||||
Private Sub frmGesamtsicherheitNEU_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
|
||||
@@ -59,13 +65,17 @@ Public Class frmGesamtsicherheitenNEU
|
||||
cboWarenort.fillWithSQL("SELECT [grz_Grenzstelle], [grz_Bezeichnung] FROM [tblGrenzstelle] WHERE [grz_Aktiv] ='1' AND [grz_Warenort] ='1' ORDER BY [grz_Reihenfolge] ", True, "AVISO", True)
|
||||
|
||||
If datum = Nothing Then datum = Date.Now
|
||||
nextGessicherheitID = -1
|
||||
prevGessicherheitID = -1
|
||||
|
||||
Else
|
||||
LoadDGVSicherheiten()
|
||||
End If
|
||||
LoadStandort()
|
||||
cboSicherheitATR.Enabled = currentGesSichRef.gsr_ATR
|
||||
Zollsatz = currentGesSichRef.gsr_zollsatz
|
||||
|
||||
cbx_offene.Checked = True
|
||||
initPrevNextButtons()
|
||||
|
||||
|
||||
Me.Text = "Gesamtsicherheit " & Standort
|
||||
@@ -74,26 +84,22 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
|
||||
|
||||
Public Sub LoadDGVSicherheiten()
|
||||
Public Sub LoadDGVSicherheiten(Optional withFilterParam As Boolean = False)
|
||||
|
||||
lblSaldo.Text = "Saldo: € " & currentGesSichRef.gsr_Saldo.ToString()
|
||||
lblGestellungNr.Text = ""
|
||||
Dim sqladd1 As String = ""
|
||||
If currentGesSichRef.gsr_ustEnabled Then sqladd1 &= ", FORMAT((([gs_warenwert] + [gs_sicherheitsbetrag]) * " & currentGesSichRef.gsr_ust & "/100), 'C', 'de-DE') as gs_ust"
|
||||
If currentGesSichRef.gsr_ATR Then sqladd1 &= ", [gs_atr]"
|
||||
If txt_Suche.Text <> "" Or cbx_Suche_Warenort._value <> "" Then Dim sqlSearchSting As String = ""
|
||||
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.Text & "%'"
|
||||
End If
|
||||
|
||||
'Dim addtosqlstring As String = ""
|
||||
|
||||
Dim addtosqlstring As String = ""
|
||||
'Dim SQLStringSicherheit As String = "select [gs_gsId], [gs_ATBNr], [gs_posNr], [gs_datum], [gs_warenwert], [gs_sicherheitsbetrag], [gs_saldo] " &
|
||||
' sqladd1 & " , [gs_freitext] from [tblGesamtsicherheit]
|
||||
' where gs_standort = '" & Standort & "'And gs_datum > '" & Date.Parse(txtDatVon.Text) & "' And gs_datum < '" & Date.Parse(txtDatBis.Text).AddDays(1).AddSeconds(-1) & "'" &
|
||||
' "AND (gs_abfertigungsNr Like '%" & txt_Suche.Text & "%' OR" &
|
||||
' " gs_ATBNr like '%" & txt_Suche.Text & "%' OR" &
|
||||
' " gs_LKWKZ like '%" & txt_Suche.Text & "%' OR" &
|
||||
' " gs_warenort like '%" & cbx_Suche_Warenort.Text & "%') order by [gs_datum]"
|
||||
|
||||
Dim SQLStringSicherheit As String = "select [gs_gsId], [gs_gsnr], [gs_ATBNr], [gs_posNr], [gs_datum], [gs_warenwert], [gs_sicherheitsbetrag], [gs_saldo] " & sqladd1 & " , [gs_freitext] from [tblGesamtsicherheit] where [gs_gsnr] = '" & gessicherheitID & "' order by [gs_datum]"
|
||||
Dim SQLStringSicherheit As String = "select [gs_gsId], [gs_gsnr], [gs_ATBNr], [gs_posNr], [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()
|
||||
@@ -111,11 +117,11 @@ Public Class frmGesamtsicherheitenNEU
|
||||
Select Case currentGesSichRef.gsr_ATR
|
||||
Case True
|
||||
.Columns("gs_ATBNr").HeaderText = "ATB"
|
||||
.Columns("gs_atr").HeaderText = "ATR"
|
||||
.Columns("gs_atr").HeaderText = "MRN"
|
||||
.Columns("gs_atr").Width = 33
|
||||
.Columns("gs_ust").Width = 69
|
||||
Case Else
|
||||
.Columns("gs_ATBNr").HeaderText = "CRN"
|
||||
.Columns("gs_ATBNr").HeaderText = "ATB"
|
||||
End Select
|
||||
.Columns("gs_ATBNr").Width = 146
|
||||
|
||||
@@ -128,15 +134,6 @@ Public Class frmGesamtsicherheitenNEU
|
||||
.Columns("gs_freitext").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
|
||||
End With
|
||||
|
||||
|
||||
'For Each row As DataGridViewRow In dgvGesamtsicherheit.Rows
|
||||
' If row.Cells("gs_SicherheitsSaldo").Value <> 0 Then
|
||||
' row.DefaultCellStyle.BackColor = Color.Red
|
||||
' Else
|
||||
' row.DefaultCellStyle.BackColor = Color.Green
|
||||
' End If
|
||||
'Next
|
||||
|
||||
End If
|
||||
|
||||
|
||||
@@ -145,24 +142,36 @@ Public Class frmGesamtsicherheitenNEU
|
||||
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)
|
||||
indexGsId = CInt(dgvGesamtsicherheit.SelectedRows(0).Cells("gs_gsNr").Value)
|
||||
currentSicherheit = New cSicherheiten(indexGsId)
|
||||
|
||||
LoadDGVSicherheitsPos(indexGsId)
|
||||
LoadDGVSicherheitsPos(indexGsId, True)
|
||||
loadTitle()
|
||||
setSaldo()
|
||||
|
||||
|
||||
If dgvGesamtsicherheit.Enabled = False Then Exit Sub
|
||||
|
||||
Else
|
||||
LoadDGVSicherheitsPos(-1, True)
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub LoadDGVSicherheitsPos(gsId As Integer)
|
||||
Public Sub LoadDGVSicherheitsPos(gsNr As Integer, Optional withFilterParam As Boolean = False)
|
||||
|
||||
If gsId = 0 Then Exit Sub
|
||||
'If gsNr = "" Then Exit Sub
|
||||
|
||||
Dim SQLStringCRN As String = "select [gsp_gspPosId] ,[gsp_gsId],[gsp_warenwert],[gsp_sicherheitsbetrag],[gsp_freitext],[gsp_art] ,[gsp_avisoId] ,[gsp_ust] ,[gsp_filialenNr],[gsp_abfertigungsNr] ,[gsp_ATCNr] ,[gsp_MRNNr],[gsp_erstellungsdatum] from [tblGesamtsicherheitsPositionen] where [gsp_gsId] = '" & gsId & "' order by [gsp_gspPosId]"
|
||||
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.Text & "%'"
|
||||
sqlSearchSting &= ")"
|
||||
End If
|
||||
|
||||
|
||||
Dim SQLStringCRN As String = "select [gsp_gspPosId] ,[gsp_gsId],[gsp_gsnr],[gsp_warenwert],[gsp_sicherheitsbetrag],[gsp_freitext],[gsp_art] ,[gsp_avisoId] ,[gsp_ust] ,[gsp_filialenNr],[gsp_abfertigungsNr] ,[gsp_ATCNr] ,[gsp_MRNNr],[gsp_erstellungsdatum] from [tblGesamtsicherheitsPositionen] where [gsp_gsnr] = '" & gsNr & "'" & sqlSearchSting & " order by [gsp_gsId]"
|
||||
dgvSicherheitsPos.SET_SQL(SQLStringCRN, "AVISO", ,)
|
||||
dgvSicherheitsPos.LOAD()
|
||||
|
||||
@@ -188,6 +197,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
End With
|
||||
|
||||
End If
|
||||
btnAddPos.Visible = True
|
||||
|
||||
End Sub
|
||||
|
||||
@@ -206,7 +216,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
'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 & "'"
|
||||
|
||||
|
||||
@@ -224,6 +234,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -232,9 +243,13 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
Public Sub LoadStandort()
|
||||
|
||||
Zollsatz = currentGesSichRef.gsr_zollsatz
|
||||
txtZollsatzueberschreiben.Text = Zollsatz
|
||||
cbxZollsatzueberschreiben.Checked = False
|
||||
lblReferenzwert.Text = "Referenzwert: €" & currentGesSichRef.gsr_referenzwert.ToString()
|
||||
lblZollsatz.Text = "Zollsatz: " & currentGesSichRef.gsr_zollsatz & "%"
|
||||
ZollsatzMulti = currentGesSichRef.gsr_zollsatz / 100
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Warenwert_TextChanged(sender As Object, e As EventArgs) Handles txtSicherheitWarenwert.TextChanged, txtPosWarenwert.TextChanged
|
||||
@@ -250,7 +265,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Warenwert_Keypresses(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtSicherheitWarenwert.KeyPress, txtPosWarenwert.KeyPress, txtAnzahlPos.KeyPress
|
||||
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
|
||||
' Zahlen, Backspace und , zulassen
|
||||
@@ -299,55 +314,82 @@ Public Class frmGesamtsicherheitenNEU
|
||||
End Sub
|
||||
|
||||
Private Sub btnAddSicherheit_Click(sender As Object, e As EventArgs) Handles btnAddSicherheit.Click
|
||||
|
||||
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))
|
||||
|
||||
Dim OPEN As New cSicherheiten()
|
||||
|
||||
With OPEN
|
||||
.gs_gsNr = AddNewGesamtSichNr()
|
||||
.gs_ATBNr = txtSicherheitATBNr.Text
|
||||
.gs_posNr = Integer.Parse(setNullToZero(txtAnzahlPos.Text))
|
||||
.gs_datum = DateTimeString2DateTimeKonvertinator(txtSicherheitDate.Text, txtSicherheitTime.Text)
|
||||
.gs_warenwert = Double.Parse(txtSicherheitWarenwert.Text) '.Replace(".", "").Replace(",", ".")
|
||||
.gs_sicherheitsbetrag = Double.Parse(txtSicherheitSicherheitsbetrag.Text) '.Replace(".", "").Replace(",", ".")
|
||||
.gs_standort = Me.Standort
|
||||
.gs_art = "OPEN"
|
||||
.gs_gsNr = Me.gessicherheitID
|
||||
.gs_erstellungsdatum = Me.datum
|
||||
.gs_freitext = Me.txtSicherheitFreitext.Text
|
||||
.gs_saldo = currentGesSichRef.gsr_Saldo
|
||||
.gs_atr = setNullToZero(cboSicherheitATR.SelectedItem)
|
||||
setEnviromentDataToObject(OPEN, Me)
|
||||
End With
|
||||
|
||||
'If Neu = True AndAlso count <= 1 Then OPENWithMultiplePosNr.gs_gsNr = AddNewGesamtSichNr()
|
||||
|
||||
'Select Case checkIfExist(OPENWithMultiplePosNr.gs_ATBNr, gessicherheitID)
|
||||
' Case "Neu"
|
||||
' OPENWithMultiplePosNr.SAVE()
|
||||
' Case Else
|
||||
' If (count > 1) Then
|
||||
' OPENWithMultiplePosNr.SAVE()
|
||||
' Else
|
||||
' MsgBox("INFO: Dieser Eintrag wurde bereits bei GesamtsichNr " & checkIfExist(OPENWithMultiplePosNr.gs_ATBNr, gessicherheitID) & "eingetragen") : OPENWithMultiplePosNr.SAVE()
|
||||
' End If
|
||||
|
||||
'End Select
|
||||
|
||||
indexGsId = OPEN.SAVEOBJECT()
|
||||
|
||||
|
||||
For count As Integer = 1 To limit
|
||||
'If (count > 1) Then txtMRNWarenwert.Text = 0
|
||||
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 OPENPos As New cGesamtsicherheitsPositionen(indexGsId, count)
|
||||
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.gsr_Saldo
|
||||
.gs_atr = setNullToZero(cboSicherheitATR.SelectedItem)
|
||||
.gs_zollsatz = Me.Zollsatz
|
||||
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 bereits 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_gsId =
|
||||
'.gsp_gspPosId = count
|
||||
|
||||
.gsp_gsNr = OPEN.gs_gsNr
|
||||
.gsp_warenwert = 0
|
||||
.gsp_sicherheitsbetrag = 0
|
||||
.gsp_freitext = ""
|
||||
@@ -359,32 +401,20 @@ Public Class frmGesamtsicherheitenNEU
|
||||
.gsp_ust = ""
|
||||
.gsp_ATCNr = ""
|
||||
.gsp_MRNNr = ""
|
||||
.gsp_gsNr = OPEN.gs_gsNr
|
||||
End With
|
||||
|
||||
|
||||
OPENPos.SAVE()
|
||||
|
||||
|
||||
If Neu = True AndAlso count <= 1 Then OPEN.gs_gsNr = AddNewGesamtSichNr()
|
||||
|
||||
Select Case checkIfExist(OPEN.gs_ATBNr, gessicherheitID)
|
||||
Case "Neu"
|
||||
OPEN.SAVE()
|
||||
|
||||
Case Else
|
||||
If (count >= 1) Then
|
||||
OPEN.SAVE()
|
||||
OPENPos.SAVE()
|
||||
Else
|
||||
MsgBox("INFO: Dieser Eintrag wurde bereits bei GesamtsichNr " & checkIfExist(OPEN.gs_ATBNr, gessicherheitID) & "eingetragen") : OPEN.SAVE()
|
||||
End If
|
||||
|
||||
End Select
|
||||
|
||||
Next
|
||||
|
||||
|
||||
AfterButton()
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
@@ -394,11 +424,11 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
If dgvGesamtsicherheit.SelectedRows.Count = 0 Then
|
||||
|
||||
MsgBox("Bitte Sicherheit markieren, zu diese eine Pos hinzugefügt/entfernt/aktualisiert werden soll")
|
||||
MsgBox("Bitte eine Gestellung markieren, zu diese eine Pos hinzugefügt/entfernt/aktualisiert werden soll")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If (checkWarenwert() = False) Then
|
||||
If (checkSicherheitsbetrag() = False) Then
|
||||
MsgBox("Der Warenwert der Positionen übersteigt den Warenwert der Gestellung!")
|
||||
txtPosWarenwert.Focus()
|
||||
Exit Sub
|
||||
@@ -406,15 +436,38 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
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.gsr_Saldo
|
||||
.gs_atr = setNullToZero(cboSicherheitATR.SelectedItem)
|
||||
.gs_zollsatz = Me.Zollsatz
|
||||
setEnviromentDataToObject(OPEN, Me)
|
||||
End With
|
||||
|
||||
Dim gs_gsId = OPEN.SAVEOBJECT()
|
||||
|
||||
Dim SicherheitsPos As New cGesamtsicherheitsPositionen()
|
||||
With SicherheitsPos
|
||||
.gsp_gsId = currentSicherheit.gs_gsId
|
||||
.gsp_gspPosId = Me.getLatestPosNr(currentSicherheit.gs_gsId) + 1
|
||||
.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 = "OPEN"
|
||||
.gsp_art = "CLOSE"
|
||||
.gsp_gsNr = gessicherheitID
|
||||
.gsp_abfertigungsNr = currentSicherheit.gs_abfertigungsnr
|
||||
.gsp_erstellungsdatum = DateTimeString2DateTimeKonvertinator(txtPosDate.Text, txtPosTime.Text)
|
||||
.gsp_ust = currentSicherheit.gs_ust
|
||||
@@ -422,19 +475,8 @@ Public Class frmGesamtsicherheitenNEU
|
||||
.gsp_MRNNr = txtPositionenCRN.Text
|
||||
End With
|
||||
|
||||
|
||||
|
||||
SicherheitsPos.SAVE()
|
||||
|
||||
'If Neu = True Then Close.gs_gsNr = AddNewGesamtSichNr()
|
||||
|
||||
'Select Case checkIfExist(Close.gs_ATBNr, gessicherheitID)
|
||||
' Case "Neu"
|
||||
' Close.SAVE()
|
||||
' Case Else
|
||||
' MsgBox("Dieser Eintrag wurde bereits bei GesamtsichNr " & checkIfExist(Close.gs_ATBNr, gessicherheitID) & "eingetragen") : Exit Sub
|
||||
'End Select
|
||||
|
||||
AfterButton()
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
@@ -520,7 +562,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
End Try
|
||||
|
||||
Try
|
||||
Me.warenortID = checkNothingValue(cbx_Suche_Warenort.SelectedItem, "String")
|
||||
Me.warenortID = checkNothingValue(cboWarenort.SelectedItem, "String")
|
||||
|
||||
Catch
|
||||
Me.warenortID = "-"
|
||||
@@ -529,13 +571,14 @@ Public Class frmGesamtsicherheitenNEU
|
||||
Me.Abfertigungsnummer = txtAbfertNum.Text
|
||||
Me.LKWKZ = txtLKWID.Text
|
||||
|
||||
If setNullToZero(Me.gessicherheitID) >= 0 Then
|
||||
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
|
||||
@@ -559,9 +602,9 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
End Function
|
||||
|
||||
Private Sub dgvGesamtsicherheit_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvGesamtsicherheit.CellContentClick
|
||||
Private Sub dgvGesamtsicherheit_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvGesamtsicherheit.CellDoubleClick
|
||||
|
||||
Dim Sicherh As New cSicherheiten(dgvGesamtsicherheit.CurrentRow.Cells("gs_gsId").Value)
|
||||
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
|
||||
@@ -572,6 +615,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
txtSicherheitTime.Text = Sicherh.gs_erstellungsdatum.ToString("HH:mm")
|
||||
|
||||
currentSicherheit = Sicherh
|
||||
txtAnzahlPos.Enabled = False
|
||||
|
||||
btnAddSicherheit.Visible = False
|
||||
btnUpdateSicherheit.Visible = True
|
||||
@@ -581,10 +625,10 @@ Public Class frmGesamtsicherheitenNEU
|
||||
Private Sub btnUpdateSicherheit_Click(sender As Object, e As EventArgs) Handles btnUpdateSicherheit.Click
|
||||
With currentSicherheit
|
||||
.gs_ATBNr = txtSicherheitATBNr.Text
|
||||
.gs_posNr = Double.Parse(setNullToZero(txtAnzahlPos.Text))
|
||||
.gs_posNr = Integer.Parse(setNullToZero(txtAnzahlPos.Text))
|
||||
.gs_datum = DateTimeString2DateTimeKonvertinator(txtSicherheitDate.Text, txtSicherheitTime.Text)
|
||||
.gs_warenwert = Double.Parse(txtSicherheitWarenwert.Text) '.Replace(".", "").Replace(",", ".")
|
||||
.gs_sicherheitsbetrag = Double.Parse(txtSicherheitSicherheitsbetrag.Text) '.Replace(".", "").Replace(",", ".")
|
||||
.gs_warenwert = Double.Parse(txtSicherheitWarenwert.Text)
|
||||
.gs_sicherheitsbetrag = Double.Parse(txtSicherheitSicherheitsbetrag.Text)
|
||||
.gs_standort = Me.Standort
|
||||
.gs_art = "OPEN"
|
||||
.gs_gsNr = Me.gessicherheitID
|
||||
@@ -593,8 +637,9 @@ Public Class frmGesamtsicherheitenNEU
|
||||
'.saldo = currentGesSichRef.Saldo
|
||||
.gs_atr = setNullToZero(cboSicherheitATR.SelectedItem)
|
||||
End With
|
||||
checkWarenwert()
|
||||
checkSicherheitsbetrag()
|
||||
currentSicherheit.SAVE()
|
||||
txtAnzahlPos.Enabled = True
|
||||
btnUpdateSicherheit.Visible = False
|
||||
btnAddSicherheit.Visible = True
|
||||
btnDeleteSicherheit.Visible = False
|
||||
@@ -611,7 +656,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
.gsp_ATCNr = txtPositionenCRN.Text
|
||||
|
||||
End With
|
||||
checkWarenwert()
|
||||
checkSicherheitsbetrag()
|
||||
currentSPos.SAVE()
|
||||
btnAddPos.Visible = True
|
||||
btnUpdatePos.Visible = False
|
||||
@@ -619,9 +664,9 @@ Public Class frmGesamtsicherheitenNEU
|
||||
AfterButton()
|
||||
End Sub
|
||||
|
||||
Private Sub dgvGesamtsicherheitPositionen_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvSicherheitsPos.CellDoubleClick
|
||||
Private Sub dgvGesamtsicherheitPositionen_CellCellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvSicherheitsPos.CellDoubleClick
|
||||
|
||||
Dim sPos As New cGesamtsicherheitsPositionen(indexGsId, dgvSicherheitsPos.CurrentRow.Cells("gsp_gspPosId").Value)
|
||||
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
|
||||
@@ -631,6 +676,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
txtPosDate.Text = sPos.gsp_erstellungsdatum.ToString("dd.MM.yyyy")
|
||||
txtPosTime.Text = sPos.gsp_erstellungsdatum.ToString("HH:mm")
|
||||
|
||||
|
||||
currentSPos = sPos
|
||||
|
||||
btnDeletePos.Visible = True
|
||||
@@ -644,6 +690,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
btnUpdateSicherheit.Visible = False
|
||||
btnAddSicherheit.Visible = True
|
||||
btnDeleteSicherheit.Visible = False
|
||||
txtAnzahlPos.Enabled = True
|
||||
AfterButton()
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
@@ -666,8 +713,8 @@ Public Class frmGesamtsicherheitenNEU
|
||||
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)
|
||||
cbx_Suche_Warenort.fillWithSQL("SELECT [grz_Grenzstelle], [grz_Bezeichnung] FROM [tblGrenzstelle] WHERE [grz_Aktiv] ='1' AND [grz_Warenort] ='1' ORDER BY [grz_Reihenfolge] ", True, "AVISO", True)
|
||||
cbx_Suche_Warenort.SelectedIndex = cbx_Suche_Warenort.FindString(Me.warenortID)
|
||||
cboWarenort.fillWithSQL("SELECT [grz_Grenzstelle], [grz_Bezeichnung] FROM [tblGrenzstelle] WHERE [grz_Aktiv] ='1' AND [grz_Warenort] ='1' ORDER BY [grz_Reihenfolge] ", True, "AVISO", True)
|
||||
cboWarenort.SelectedIndex = cbx_Suche_Warenort.FindString(Me.warenortID)
|
||||
txtAbfertNum.Text = Me.Abfertigungsnummer
|
||||
txtLKWID.Text = Me.LKWKZ
|
||||
panOben.Enabled = False
|
||||
@@ -684,6 +731,7 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
MsgBox("Bitte Warenort angeben!")
|
||||
isFilled = False
|
||||
|
||||
End If
|
||||
|
||||
Return isFilled
|
||||
@@ -699,10 +747,10 @@ Public Class frmGesamtsicherheitenNEU
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Function getLatestPosNr(gs_gsId As Integer) As Integer
|
||||
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_gsId = " & gs_gsId
|
||||
'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)
|
||||
|
||||
@@ -716,11 +764,9 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Private Sub btnSuche_Click(sender As Object, e As EventArgs) Handles btnSuche.Click
|
||||
Try
|
||||
If Me.Visible Then LoadDGVSicherheiten()
|
||||
If Me.Visible Then LoadDGVSicherheiten(True)
|
||||
Catch ex As Exception
|
||||
MsgBox("Datum VON und/oder BIS konnte nicht konvertiert werden.")
|
||||
End Try
|
||||
@@ -749,36 +795,64 @@ Public Class frmGesamtsicherheitenNEU
|
||||
txt_Suche.Clear()
|
||||
End Sub
|
||||
|
||||
Private Function checkWarenwert() As Boolean
|
||||
Private Function checkSicherheitsbetrag() As Boolean
|
||||
|
||||
Dim ok As Boolean = True
|
||||
|
||||
Dim offenerWarenwert As Double
|
||||
Dim offenerSicherheitsbetrag As Double
|
||||
Dim offenerSicherheitsbetragPos As Double
|
||||
|
||||
Try
|
||||
|
||||
offenerWarenwert = calcOffenenWarenwert()
|
||||
offenerSicherheitsbetrag = calcOffenerSicherheitsbetrag()
|
||||
|
||||
If (offenerWarenwert < Double.Parse(txtPosWarenwert.Text)) Then
|
||||
ok = False
|
||||
End If
|
||||
If (offenerSicherheitsbetrag < 0) Then Return False
|
||||
|
||||
If (offenerSicherheitsbetrag < offenerSicherheitsbetragPos) Then Return False
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
|
||||
|
||||
Return ok
|
||||
|
||||
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(txtPosWarenwert.Text))
|
||||
End If
|
||||
|
||||
Return sicherheitsbetragSumPositionen
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Private Function calcOffenenWarenwert() As Double
|
||||
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
|
||||
If currentSicherheit Is Nothing Then Exit Function
|
||||
|
||||
Try
|
||||
Dim warenwertSumPositionen = CDbl(SQL.DLookup("SUM(gsp_warenwert)", "[tblGesamtsicherheitsPositionen]", "gsp_gsId ='" & currentSicherheit.gs_gsId & "'", "AVISO"))
|
||||
diff = Double.Parse(currentSicherheit.gs_warenwert) - Double.Parse(warenwertSumPositionen)
|
||||
Dim sicherheitsbetragSumPositionen = calcSicherheitsbetragPos()
|
||||
Dim sicherheitsbetragSumGestelle = calcSicherheitsbetragGestelle()
|
||||
|
||||
diff = Double.Parse(sicherheitsbetragSumGestelle) - Double.Parse(sicherheitsbetragSumPositionen)
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
@@ -789,11 +863,14 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
Private Sub setSaldo()
|
||||
|
||||
lbloffenerSaldo.Text = "offener Saldo: "
|
||||
If Me.calcOffenenWarenwert > 0 Then
|
||||
lbloffenerSaldo.Text &= Me.calcOffenenWarenwert()
|
||||
lbloffenerSaldo.Text = "offener S-Saldo: "
|
||||
Dim offernerSB As Double = Me.calcOffenerSicherheitsbetrag()
|
||||
If offernerSB > 0 Then
|
||||
lbloffenerSaldo.Text &= Me.calcOffenerSicherheitsbetrag().ToString
|
||||
isOpen = True
|
||||
Else
|
||||
lbloffenerSaldo.Text &= "0"
|
||||
isOpen = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -801,9 +878,156 @@ Public Class frmGesamtsicherheitenNEU
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function setPrevAndNextGesIDAllOpen()
|
||||
|
||||
Dim isInList As Boolean = False
|
||||
|
||||
Dim onlyOpenDT As DataTable
|
||||
|
||||
onlyOpenDT = dt.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
|
||||
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
|
||||
|
||||
For i As Integer = 0 To dt.Rows.Count - 1
|
||||
If dt.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 dt.Rows(j).Item("gs_isOpen") Then
|
||||
prevGessicherheitID = dt.Rows(j).Item("gs_gsnr")
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
|
||||
If i = dt.Rows.Count - 1 Then
|
||||
nextGessicherheitID = -1 ' ' no next Sicherheit
|
||||
Else
|
||||
For k As Integer = i To dt.Rows.Count - 1
|
||||
If dt.Rows(k).Item("gs_isOpen") Then
|
||||
nextGessicherheitID = dt.Rows(k).Item("gs_gsnr")
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
|
||||
Next
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Private Function setPrevAndNextGesAll()
|
||||
|
||||
For i As Integer = 0 To dt.Rows.Count - 1
|
||||
If dt.Rows(i).Item("gs_gsnr") = Me.gessicherheitID Then
|
||||
|
||||
prevGessicherheitID = i - 1
|
||||
nextGessicherheitID = i + 1
|
||||
|
||||
If i = 0 Then prevGessicherheitID = -1 ' no prev Sicherheit
|
||||
If i = dt.Rows.Count - 1 Then nextGessicherheitID = -1 ' ' no next Sicherheit
|
||||
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 = False
|
||||
Else
|
||||
btnNext.Enabled = True
|
||||
End If
|
||||
|
||||
|
||||
If prevGessicherheitID = -1 Then
|
||||
btnPrev.Enabled = False
|
||||
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.gsr_zollsatz.ToString
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub txtZollsatzueberschreiben_TextChanged(sender As Object, e As EventArgs) Handles txtZollsatzueberschreiben.TextChanged
|
||||
lblZollsatz.Text = "Zollsatz: " & txtZollsatzueberschreiben.Text & "%"
|
||||
|
||||
ZollsatzMulti = CDbl(setNullToZero(txtZollsatzueberschreiben.Text)) / 100
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user