809 lines
30 KiB
VB.net
809 lines
30 KiB
VB.net
Imports System.Reflection
|
|
Imports DocumentFormat.OpenXml.Bibliography
|
|
Imports DocumentFormat.OpenXml.Presentation
|
|
Imports DocumentFormat.OpenXml.Spreadsheet
|
|
Imports VERAG_PROG_ALLGEMEIN
|
|
|
|
Public Class frmGesamtsicherheitenNEU
|
|
|
|
|
|
'Dim openopened As cSicherheiten
|
|
|
|
'Dim closedopened As cSicherheiten
|
|
|
|
Dim currentSicherheit As cSicherheiten
|
|
Property currentSPos As cGesamtsicherheitsPositionen
|
|
Property currentGesSichRef As cGesamtsicherheitsReferenz
|
|
Public Property gessicherheitID As Integer
|
|
Public Property datum As DateTime = Nothing
|
|
Property Standort As String = ""
|
|
|
|
Public ZollsatzMulti As Double = 0
|
|
|
|
Public Zollsatz As Double
|
|
|
|
Public Saldo As Integer = 0
|
|
|
|
Public Neu As Boolean = False
|
|
|
|
Public FilialNummer As Integer
|
|
|
|
Public Abfertigungsnummer As String
|
|
|
|
Public LKWID As String
|
|
|
|
Public warenortID As String
|
|
|
|
Dim indexGsId As Integer = 0
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
|
|
Dim MONAT As Date = CDate("01." & Now.Month & "." & Now.Year) '.AddMonths(-1)
|
|
|
|
Dim srcTAG As Date = CDate(Now.ToShortDateString)
|
|
|
|
Dim JAHR As Date = CDate("01.01." & Now.Year)
|
|
|
|
|
|
|
|
Private Sub frmGesamtsicherheitNEU_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
|
|
currentGesSichRef = New VERAG_PROG_ALLGEMEIN.cGesamtsicherheitsReferenz(Standort)
|
|
lblSaldo.Text = "Saldo: €" & Decimal.Parse(currentGesSichRef.CalcSaldo()).ToString("N")
|
|
|
|
|
|
|
|
If setNullToZero(gessicherheitID) = 0 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 [grz_Grenzstelle], [grz_Bezeichnung] FROM [tblGrenzstelle] WHERE [grz_Aktiv] ='1' AND [grz_Warenort] ='1' ORDER BY [grz_Reihenfolge] ", True, "AVISO", True)
|
|
|
|
cbx_Suche_Filiale.Items.AddRange(cboFiliale.Items.Cast(Of VERAG_PROG_ALLGEMEIN.MyListItem).ToArray())
|
|
cbx_Suche_Warenort.Items.AddRange(cboWarenort.Items.Cast(Of VERAG_PROG_ALLGEMEIN.MyListItem).ToArray())
|
|
|
|
If datum = Nothing Then datum = Date.Now
|
|
Else
|
|
LoadDGVSicherheiten()
|
|
End If
|
|
LoadStandort()
|
|
cboATR.Enabled = currentGesSichRef.gsr_ATR
|
|
Zollsatz = currentGesSichRef.gsr_zollsatz
|
|
|
|
txtDatVon.Text = Date.Today.ToString("dd.MM.yyyy")
|
|
txtDatBis.Text = Date.Today.ToString("dd.MM.yyyy")
|
|
|
|
btnMonat.Text = MONAT.ToString("MMMM")
|
|
btnJahr.Text = JAHR.Year
|
|
|
|
Me.Text = "Gesamtsicherheit " & Standort
|
|
frmHauptfenster.EnableDoubleBuffered(dgvSicherheitsPos)
|
|
End Sub
|
|
|
|
|
|
Public Sub LoadDGVSicherheiten()
|
|
|
|
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]"
|
|
|
|
|
|
Dim addtosqlstring As String = ""
|
|
Dim SQLStringMRN 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_LKWID like '%" & txt_Suche.Text & "%' OR" &
|
|
" gs_warenort like '%" & cbx_Suche_Warenort.Text & "%') order by [gs_datum]"
|
|
|
|
dgvGesamtsicherheit.SET_SQL(SQLStringMRN, "AVISO", ,)
|
|
dgvGesamtsicherheit.LOAD()
|
|
|
|
|
|
|
|
|
|
|
|
If dgvGesamtsicherheit.Columns.Count > 0 Then
|
|
With dgvGesamtsicherheit
|
|
.RowHeadersWidth = 10
|
|
.Columns("gs_gsId").Visible = False
|
|
.Columns("gs_warenwert").DefaultCellStyle.Format = "c"
|
|
.Columns("gs_sicherheitsbetrag").DefaultCellStyle.Format = "c"
|
|
.Columns("gs_saldo").DefaultCellStyle.Format = "c"
|
|
.Columns("gs_saldo").Visible = False
|
|
Select Case currentGesSichRef.gsr_ATR
|
|
Case True
|
|
.Columns("gs_ATBNr").HeaderText = "ATB"
|
|
.Columns("gs_atr").HeaderText = "ATR"
|
|
.Columns("gs_atr").Width = 33
|
|
.Columns("gs_ust").Width = 69
|
|
Case Else
|
|
.Columns("gs_ATBNr").HeaderText = "CRN"
|
|
End Select
|
|
.Columns("gs_ATBNr").Width = 146
|
|
|
|
.Columns("gs_posNr").Width = 20
|
|
.Columns("gs_datum").Width = 95
|
|
.Columns("gs_warenwert").Width = 100
|
|
.Columns("gs_saldo").Width = 100
|
|
|
|
.Columns("gs_sicherheitsbetrag").Width = 100
|
|
.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
|
|
|
|
|
|
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)
|
|
currentSicherheit = New cSicherheiten(indexGsId)
|
|
|
|
LoadDGVSicherheitsPos(indexGsId)
|
|
loadTitle(indexGsId)
|
|
|
|
If dgvGesamtsicherheit.Enabled = False Then Exit Sub
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub LoadDGVSicherheitsPos(gsId As Integer)
|
|
|
|
If gsId = 0 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] from [tblGesamtsicherheitsPositionen] where [gsp_gsId] = '" & gsId & "' order by [gsp_gspPosId]"
|
|
dgvSicherheitsPos.SET_SQL(SQLStringCRN, "AVISO", ,)
|
|
dgvSicherheitsPos.LOAD()
|
|
|
|
If dgvSicherheitsPos.Columns.Count > 0 Then
|
|
With dgvSicherheitsPos
|
|
.RowHeadersWidth = 10
|
|
.Columns("gsp_gsId").Visible = False
|
|
.Columns("gsp_warenwert").DefaultCellStyle.Format = "c"
|
|
.Columns("gsp_sicherheitsbetrag").DefaultCellStyle.Format = "c"
|
|
'.Columns("gs_saldo").DefaultCellStyle.Format = "c"
|
|
'.Columns("gs_saldo").Visible = False
|
|
Select Case currentGesSichRef.gsr_ATR
|
|
Case True
|
|
.Columns("gsp_ATCNr").HeaderText = "ATC / MRN"
|
|
Case Else
|
|
.Columns("gsp_ATCNr").HeaderText = "CRN"
|
|
End Select
|
|
.Columns("gsp_ATCNr").Width = 120
|
|
'.Columns("gs_datum").Width = 140
|
|
.Columns("gsp_warenwert").Width = 100
|
|
.Columns("gsp_sicherheitsbetrag").Width = 100
|
|
.Columns("gsp_freitext").Width = 220
|
|
End With
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Sub loadTitle(indexGsId As Integer)
|
|
'Dim StandortSqlString As String = "select * from [tblGesamtsicherheit] where [gs_gsNr] = '" & gessicherheitID & "'"
|
|
|
|
lblGestellungNr.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.LKWID = setNullToZero(dt.Rows(0).Item("gs_LKWID"))
|
|
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"))
|
|
|
|
If Me.LKWID.ToString.Length > 0 Then lblGestellungNr.Text &= "LKW-ID: " & Me.LKWID & " "
|
|
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 & " "
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Public Sub LoadStandort()
|
|
|
|
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 txtMRNWarenwert.TextChanged, txtPosWarenwert.TextChanged
|
|
Try
|
|
Select Case sender.name
|
|
Case "txtMRNWarenwert"
|
|
txtMRNSicherheitsbetrag.Text = (txtMRNWarenwert.Text * ZollsatzMulti).ToString("N")
|
|
If currentGesSichRef.gsr_ustEnabled Then txtEust.Text = (Double.Parse(txtMRNWarenwert.Text) + Double.Parse(txtMRNSicherheitsbetrag.Text)) * (currentGesSichRef.gsr_ust / 100)
|
|
Case "txtCRNWarenwert"
|
|
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 txtMRNWarenwert.KeyPress, txtPosWarenwert.KeyPress, txtPos.KeyPress
|
|
Select Case Asc(e.KeyChar)
|
|
Case 48 To 57, 8, 44
|
|
' 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 txtCRNDate.KeyPress, txtCRNTime.KeyPress, txtMRNDate.KeyPress, txtMRNTime.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 btnSaveOben_Click(sender As Object, e As EventArgs) Handles btnSaveOben.Click
|
|
Try
|
|
Dim a As Date = Date.ParseExact(txtMRNDate.Text, "dd.MM.yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
|
|
Dim b As Date = Date.ParseExact(txtMRNTime.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 txtMRNDate_GotFocus(sender As Object, e As EventArgs) Handles txtMRNDate.GotFocus, txtCRNDate.GotFocus, txtMRNTime.GotFocus, txtCRNTime.GotFocus
|
|
Select Case sender.name
|
|
Case "txtMRNDate"
|
|
If txtMRNDate.Text.Length < 1 Then txtMRNDate.Text = Date.Today.ToString("dd.MM.yyyy")
|
|
Case "txtCRNDate"
|
|
If txtCRNDate.Text.Length < 1 Then txtCRNDate.Text = Date.Today.ToString("dd.MM.yyyy")
|
|
Case "txtMRNTime"
|
|
If txtMRNTime.Text.Length < 1 Then txtMRNTime.Text = Date.Now.ToString("HH:mm")
|
|
Case "txtCRNTime"
|
|
If txtCRNTime.Text.Length < 1 Then txtCRNTime.Text = Date.Now.ToString("HH:mm")
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub btnAddSicherheit_Click(sender As Object, e As EventArgs) Handles btnAddSicherheit.Click
|
|
Try
|
|
|
|
|
|
Dim limit As Integer = Integer.Parse(setNullToZero(txtPos.Text))
|
|
|
|
Dim OPEN As New cSicherheiten()
|
|
|
|
With OPEN
|
|
.gs_ATBNr = txtMRN.Text
|
|
.gs_posNr = Integer.Parse(setNullToZero(txtPos.Text))
|
|
.gs_datum = DateTimeString2DateTimeKonvertinator(txtMRNDate.Text, txtMRNTime.Text)
|
|
.gs_warenwert = Double.Parse(txtMRNWarenwert.Text) '.Replace(".", "").Replace(",", ".")
|
|
.gs_sicherheitsbetrag = Double.Parse(txtMRNSicherheitsbetrag.Text) '.Replace(".", "").Replace(",", ".")
|
|
.gs_standort = Me.Standort
|
|
.gs_art = "OPEN"
|
|
.gs_gsNr = Me.gessicherheitID
|
|
.gs_erstellungsdatum = Me.datum
|
|
.gs_freitext = Me.txtFreitextOpen.Text
|
|
.gs_saldo = currentGesSichRef.gsr_Saldo
|
|
.gs_atr = setNullToZero(cboATR.SelectedItem)
|
|
setEnviromentDataToObject(OPEN, Me)
|
|
End With
|
|
indexGsId = OPEN.SAVEOBJECT()
|
|
|
|
|
|
For count As Integer = 1 To limit
|
|
'If (count > 1) Then txtMRNWarenwert.Text = 0
|
|
|
|
Dim OPENPos As New cGesamtsicherheitsPositionen(indexGsId, count)
|
|
|
|
With OPENPos
|
|
'.gsp_gsId =
|
|
'.gsp_gspPosId = count
|
|
.gsp_warenwert = 0
|
|
.gsp_sicherheitsbetrag = 0
|
|
.gsp_freitext = ""
|
|
.gsp_filialenNr = OPEN.gs_filialenNr
|
|
.gsp_art = "OPEN"
|
|
.gsp_abfertigungsNr = OPEN.gs_filialenNr
|
|
.gsp_avisoId = OPEN.gs_ATBNr
|
|
.gsp_ust = ""
|
|
.gsp_ATCNr = ""
|
|
.gsp_MRNNr = ""
|
|
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
|
|
End Sub
|
|
|
|
Private Sub btnAddPos_Click(sender As Object, e As EventArgs) Handles btnAddPos.Click
|
|
|
|
If dgvGesamtsicherheit.SelectedRows.Count = 0 Then
|
|
|
|
MsgBox("Bitte Sicherheit markieren, zu diese eine Pos hinzugefügt/entfernt/aktualisiert werden soll")
|
|
Exit Sub
|
|
End If
|
|
|
|
Try
|
|
|
|
Dim SicherheitsPos As New cGesamtsicherheitsPositionen()
|
|
With SicherheitsPos
|
|
.gsp_gsId = currentSicherheit.gs_gsId
|
|
.gsp_gspPosId = Me.getLatestPosNr(currentSicherheit.gs_gsId) + 1
|
|
.gsp_warenwert = 0
|
|
.gsp_sicherheitsbetrag = 0
|
|
.gsp_freitext = ""
|
|
.gsp_filialenNr = currentSicherheit.gs_filialenNr
|
|
.gsp_art = "OPEN"
|
|
.gsp_abfertigungsNr = ""
|
|
.gsp_avisoId = ""
|
|
.gsp_ust = currentSicherheit.gs_ust
|
|
.gsp_ATCNr = ""
|
|
.gsp_MRNNr = ""
|
|
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)
|
|
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
|
|
cboATR.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(cbx_Suche_Warenort.SelectedItem, "String")
|
|
|
|
Catch
|
|
Me.warenortID = "-"
|
|
End Try
|
|
|
|
Me.Abfertigungsnummer = txtAbfertNum.Text
|
|
Me.LKWID = txtLKWID.Text
|
|
|
|
If setNullToZero(Me.gessicherheitID) >= 0 Then
|
|
Dim sqlstring = "Update [tblGesamtsicherheit] set [gs_filialenNr] = '" & Me.FilialNummer & "', [gs_abfertigungsNr] = '" & Me.Abfertigungsnummer & "', [gs_LKWID] = '" & Me.LKWID & "', [gs_warenort] = '" & Me.warenortID & "' WHERE [gs_gsNr] = '" & Me.gessicherheitID & "' "
|
|
SQL.doSQL(sqlstring, "AVISO")
|
|
LoadDGVSicherheiten()
|
|
End If
|
|
|
|
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 Then
|
|
Return Nothing
|
|
Else
|
|
Return Integer.Parse(obj.value)
|
|
End If
|
|
End Select
|
|
|
|
|
|
End Function
|
|
|
|
Private Sub dgvGesamtsicherheit_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvGesamtsicherheit.CellContentClick
|
|
|
|
Dim Sicherh As New cSicherheiten(dgvGesamtsicherheit.CurrentRow.Cells("gs_gsId").Value)
|
|
|
|
txtMRN.Text = Sicherh.gs_ATBNr
|
|
txtPos.Text = Sicherh.gs_posNr
|
|
txtMRNWarenwert.Text = Sicherh.gs_warenwert
|
|
txtFreitextOpen.Text = Sicherh.gs_freitext
|
|
cboATR.SelectedItem = Sicherh.gs_atr
|
|
txtMRNDate.Text = Sicherh.gs_erstellungsdatum.ToString("dd.MM.yyyy")
|
|
txtMRNTime.Text = Sicherh.gs_erstellungsdatum.ToString("HH:mm")
|
|
|
|
currentSicherheit = Sicherh
|
|
|
|
btnAddSicherheit.Visible = False
|
|
btnUpdateSicherheit.Visible = True
|
|
btnDeleteSicherheit.Visible = True
|
|
End Sub
|
|
|
|
Private Sub btnUpdateSicherheit_Click(sender As Object, e As EventArgs) Handles btnUpdateSicherheit.Click
|
|
With currentSicherheit
|
|
.gs_ATBNr = txtMRN.Text
|
|
.gs_posNr = Double.Parse(setNullToZero(txtPos.Text))
|
|
.gs_datum = DateTimeString2DateTimeKonvertinator(txtMRNDate.Text, txtMRNTime.Text)
|
|
.gs_warenwert = Double.Parse(txtMRNWarenwert.Text) '.Replace(".", "").Replace(",", ".")
|
|
.gs_sicherheitsbetrag = Double.Parse(txtMRNSicherheitsbetrag.Text) '.Replace(".", "").Replace(",", ".")
|
|
.gs_standort = Me.Standort
|
|
.gs_art = "OPEN"
|
|
.gs_gsNr = Me.gessicherheitID
|
|
'.MakeDate = Me.MakeDate
|
|
.gs_freitext = Me.txtFreitextOpen.Text
|
|
'.saldo = currentGesSichRef.Saldo
|
|
.gs_atr = setNullToZero(cboATR.SelectedItem)
|
|
End With
|
|
currentSicherheit.SAVE()
|
|
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_gspPosId = txtPos.Text
|
|
.gsp_freitext = txtPosFreitext.Text
|
|
.gsp_sicherheitsbetrag = txtPosSicherheitsbetrag.Text
|
|
.gsp_warenwert = txtPosWarenwert.Text
|
|
.gsp_ATCNr = txtPositionenCRN.Text
|
|
|
|
End With
|
|
currentSPos.SAVE()
|
|
btnAddPos.Visible = True
|
|
btnUpdatePos.Visible = False
|
|
btnDeletePos.Visible = False
|
|
AfterButton()
|
|
End Sub
|
|
|
|
Private Sub dgvGesamtsicherheitPositionen_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvSicherheitsPos.CellContentClick
|
|
|
|
Dim sPos As New cGesamtsicherheitsPositionen(indexGsId, dgvSicherheitsPos.CurrentRow.Cells("gsp_gspPosId").Value)
|
|
|
|
txtPos.Text = sPos.gsp_gspPosId
|
|
txtPosFreitext.Text = sPos.gsp_freitext
|
|
txtPosSicherheitsbetrag.Text = sPos.gsp_sicherheitsbetrag
|
|
txtPosWarenwert.Text = sPos.gsp_sicherheitsbetrag
|
|
txtPositionenCRN.Text = sPos.gsp_ATCNr
|
|
|
|
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
|
|
currentSicherheit.Delete()
|
|
btnUpdateSicherheit.Visible = False
|
|
btnAddSicherheit.Visible = True
|
|
btnDeleteSicherheit.Visible = False
|
|
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)
|
|
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)
|
|
txtAbfertNum.Text = Me.Abfertigungsnummer
|
|
txtLKWID.Text = Me.LKWID
|
|
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_LKWID = gessich.LKWID
|
|
sicherheiten.gs_warenort = gessich.warenortID
|
|
End Sub
|
|
|
|
|
|
|
|
Private Function getLatestPosNr(gs_gsId As Integer) 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 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
|
|
|
|
|
|
'Kalenderhandling
|
|
|
|
|
|
Sub initBtns(MonatJahr)
|
|
btnMonat.Text = MONAT.ToString("MMMM")
|
|
btnJahr.Text = JAHR.Year
|
|
Select Case MonatJahr
|
|
Case "Monat"
|
|
DateTimePicker1.Value = MONAT
|
|
DateTimePicker2.Value = MONAT.AddMonths(1).AddDays(-1)
|
|
Case "Jahr"
|
|
|
|
DateTimePicker1.Value = JAHR
|
|
DateTimePicker2.Value = JAHR.AddYears(1).AddDays(-1)
|
|
'End If
|
|
Case "Tag"
|
|
|
|
DateTimePicker1.Value = srcTAG
|
|
DateTimePicker2.Value = srcTAG
|
|
If srcTAG = Now.ToShortDateString Then
|
|
btnTag.Text = "Heute"
|
|
ElseIf srcTAG = Now.AddDays(-1).ToShortDateString Then
|
|
btnTag.Text = "Gestern"
|
|
ElseIf srcTAG = Now.AddDays(-2).ToShortDateString Then
|
|
btnTag.Text = "Vorgestern"
|
|
Else
|
|
btnTag.Text = srcTAG.ToString("dd.MM")
|
|
End If
|
|
|
|
'End If
|
|
Case ""
|
|
DateTimePicker1.Value = ("01." & Now.Month & "." & Now.Year)
|
|
DateTimePicker2.Value = Now
|
|
End Select
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub btnJahr_Click(sender As Object, e As EventArgs) Handles btnJahr.Click
|
|
initBtns("Jahr")
|
|
End Sub
|
|
|
|
Private Sub btnBisJahr_Click(sender As Object, e As EventArgs) Handles btnBisJahr.Click
|
|
JAHR = JAHR.AddYears(1)
|
|
initBtns("Jahr")
|
|
End Sub
|
|
|
|
Private Sub btnVonJahr_Click(sender As Object, e As EventArgs) Handles btnVonJahr.Click
|
|
JAHR = JAHR.AddYears(-1)
|
|
initBtns("Jahr")
|
|
End Sub
|
|
|
|
Private Sub btnMonat_Click(sender As Object, e As EventArgs) Handles btnMonat.Click
|
|
initBtns("Monat")
|
|
End Sub
|
|
|
|
Private Sub btnBisMonat_Click(sender As Object, e As EventArgs) Handles btnBisMonat.Click
|
|
MONAT = MONAT.AddMonths(1)
|
|
initBtns("Monat")
|
|
End Sub
|
|
|
|
Private Sub btnVonMonat_Click(sender As Object, e As EventArgs) Handles btnVonMonat.Click
|
|
MONAT = MONAT.AddMonths(-1)
|
|
initBtns("Monat")
|
|
End Sub
|
|
|
|
|
|
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles btnTag.Click
|
|
initBtns("Tag")
|
|
End Sub
|
|
|
|
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles btnVonTag.Click
|
|
srcTAG = srcTAG.AddDays(-1)
|
|
initBtns("Tag")
|
|
End Sub
|
|
|
|
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles btnBisTag.Click
|
|
srcTAG = srcTAG.AddDays(1)
|
|
initBtns("Tag")
|
|
End Sub
|
|
|
|
Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker1.ValueChanged
|
|
txtDatVon._value = CDate(sender.value).ToShortDateString
|
|
End Sub
|
|
|
|
Private Sub DateTimePicker2_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker2.ValueChanged
|
|
txtDatBis._value = CDate(sender.value).ToShortDateString
|
|
End Sub
|
|
|
|
Private Sub btnSuche_Click(sender As Object, e As EventArgs) Handles btnSuche.Click
|
|
Try
|
|
Date.Parse(txtDatVon.Text)
|
|
Date.Parse(txtDatBis.Text)
|
|
If Me.Visible Then LoadDGVSicherheiten()
|
|
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) Handles btnNeu.Click
|
|
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("")
|
|
cbx_Suche_Filiale.changeItem("")
|
|
txt_Suche.Clear()
|
|
End Sub
|
|
|
|
|
|
End Class
|
|
|