229 lines
7.8 KiB
VB.net
229 lines
7.8 KiB
VB.net
Imports DocumentFormat.OpenXml.Drawing.Diagrams
|
|
Imports Org.BouncyCastle.Crypto.Modes
|
|
Imports VERAG_PROG_ALLGEMEIN
|
|
|
|
Public Class frmWarenorte
|
|
|
|
Dim warenort As New cWarenorte
|
|
|
|
Private Sub Warenorte_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
initDGVWarenort()
|
|
cbxGrenzstelle.fillWithSQL("SELECT [grz_Grenzstelle],[grz_BezeichnungCBO] FROM tblGrenzstelle where grz_Aktiv=1 order by grz_Reihenfolge, grz_Grenzstelle", False, "AVISO", True)
|
|
cbxGrenzstelle.changeItem("")
|
|
cbxFirma.fillWithSQL("SELECT [Firma_id],[Firma_Bez] FROM [tblFirma] WHERE ISNULL(Firma_Warenort,0) = 1 ", False, "FMZOLL", True)
|
|
'cbxFirma.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("VERAG", "VERAG"))
|
|
cbxFirmaChange.Items.AddRange(cbxFirma.Items.Cast(Of VERAG_PROG_ALLGEMEIN.MyListItem).ToArray())
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub initDGVWarenort(Optional firma As String = "")
|
|
|
|
lblWarning.Text = ""
|
|
|
|
Dim SQLString As String = "SELECT [wo_id], [wo_warenort] ,[wo_bezeichnung], [wo_aktiv], [wo_firma] FROM [tblWarenorte]"
|
|
Dim SQLWHere = ""
|
|
If firma <> "" Then
|
|
SQLWHere = " WHERE wo_firma = '" & firma & "'"
|
|
End If
|
|
|
|
|
|
dgvWarenorteNew.SET_SQL(SQLString & SQLWHere, "AVISO", ,)
|
|
dgvWarenorteNew.LOAD()
|
|
|
|
|
|
If dgvWarenorteNew.Columns.Count < 1 Then Exit Sub
|
|
|
|
With dgvWarenorteNew
|
|
If .RowCount = 0 Then Me.Cursor = Cursors.Default : Exit Sub
|
|
.MultiSelect = False
|
|
.RowHeadersVisible = False
|
|
.ReadOnly = True
|
|
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
|
|
.Columns("wo_id").Visible = False
|
|
.Columns("wo_warenort").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
|
|
.Columns("wo_warenort").HeaderText = "Warenort"
|
|
.Columns("wo_bezeichnung").Visible = False
|
|
.Columns("wo_aktiv").Visible = False
|
|
'.Columns("wo_firma").Visible = False
|
|
.Columns("wo_firma").HeaderText = "Firma"
|
|
.Columns("wo_firma").Width = 150
|
|
End With
|
|
|
|
|
|
For Each row As DataGridViewRow In dgvWarenorteNew.Rows
|
|
|
|
|
|
If row.Cells("wo_firma").Value IsNot DBNull.Value AndAlso row.Cells("wo_firma").Value <> "" Then
|
|
If CInt(row.Cells("wo_firma").Value) > 0 Then
|
|
|
|
Dim tmpFirma = New VERAG_PROG_ALLGEMEIN.cFirmen(row.Cells("wo_firma").Value)
|
|
row.Cells("wo_firma").Value = tmpFirma.Firma_Bez.ToString
|
|
End If
|
|
End If
|
|
|
|
If Not IsDBNull(row.Cells("wo_aktiv").Value) Then
|
|
If Not row.Cells("wo_aktiv").Value Then
|
|
row.DefaultCellStyle.BackColor = Color.IndianRed
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
|
|
|
|
If checkIfFirmaIsFilled(True) = False Then Exit Sub
|
|
|
|
Dim input = InputBox("Bitte geben Sie die Bezeichnung des neuen Warenorts ein:", "Warenort anlegen")
|
|
If input <> "" Then
|
|
If checkNameIsValid(input) Then
|
|
Dim WarenortNew As New cWarenorte(input, cbxFirma._value)
|
|
WarenortNew.wo_cluster = ""
|
|
WarenortNew.wo_aktiv = True
|
|
WarenortNew.wo_bezeichnung = ""
|
|
WarenortNew.wo_grenzstelle = DBNull.Value
|
|
WarenortNew.wo_knnr = ""
|
|
WarenortNew.wo_ort = ""
|
|
WarenortNew.wo_reihenfolge = "-1"
|
|
WarenortNew.wo_strasse = ""
|
|
|
|
If WarenortNew.SAVE() Then
|
|
initDGVWarenort(cbxFirma._value)
|
|
End If
|
|
|
|
Else
|
|
MsgBox("Es existiert bereits ein Warenort " & input & " für die Firma " & cbxFirma._value)
|
|
End If
|
|
|
|
Else
|
|
MsgBox("Keine Bezeichnung angegeben!")
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
|
|
If dgvWarenorteNew.SelectedRows.Count > 0 Then
|
|
|
|
Dim Warenort As New cWarenorte(dgvWarenorteNew.SelectedRows(0).Cells("wo_id").Value)
|
|
|
|
If vbYes = MsgBox("Möchten Sie diesen Warenort " & Warenort.wo_warenort & " in " & Warenort.wo_firma & " wirklich löschen?", vbYesNo) Then
|
|
Warenort.deleteWarenort(Warenort.wo_id)
|
|
initDGVWarenort(cbxFirma._value)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function checkNameIsValid(name As String) As Boolean
|
|
|
|
If dgvWarenorteNew.Rows.Count = 0 Then Return True
|
|
If checkIfFirmaIsFilled(False) = False Then Return False
|
|
|
|
|
|
For Each row As DataGridViewRow In dgvWarenorteNew.Rows
|
|
If Not IsDBNull(row.Cells("wo_warenort").Value) AndAlso Not IsDBNull(row.Cells("wo_firma").Value) Then
|
|
If row.Cells("wo_warenort").Value.ToLower = name.ToLower AndAlso row.Cells("wo_firma").Value = cbxFirma._value Then
|
|
Return False
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
Return True
|
|
|
|
End Function
|
|
|
|
|
|
Private Sub dgvWarenorteNew_SelectionChanged(sender As Object, e As EventArgs) Handles dgvWarenorteNew.SelectionChanged
|
|
|
|
If dgvWarenorteNew.SelectedRows.Count < 1 Then
|
|
mainPanel.Enabled = False
|
|
Exit Sub
|
|
Else
|
|
mainPanel.Enabled = True
|
|
|
|
End If
|
|
|
|
Dim Warenort = New cWarenorte(dgvWarenorteNew.SelectedRows(0).Cells("wo_id").Value)
|
|
|
|
txtWarenort.Text = Warenort.wo_warenort
|
|
txtBezeichnung.Text = Warenort.wo_bezeichnung
|
|
cbxAktiv.Checked = Warenort.wo_aktiv
|
|
txtOrt.Text = Warenort.wo_ort
|
|
cbxGrenzstelle.changeItem(Warenort.wo_grenzstelle)
|
|
cbxFirmaChange.changeItem(Warenort.wo_firma)
|
|
txtCluster.Text = Warenort.wo_cluster
|
|
txtKennr.Text = Warenort.wo_knnr
|
|
txtReihenfolge.Text = Warenort.wo_reihenfolge
|
|
txtStrasse.Text = Warenort.wo_strasse
|
|
|
|
End Sub
|
|
|
|
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
|
|
|
|
checkIfFirmaIsFilled(False)
|
|
|
|
Dim WarenortNew As New cWarenorte(dgvWarenorteNew.SelectedRows(0).Cells("wo_id").Value)
|
|
|
|
WarenortNew.wo_warenort = txtWarenort.Text
|
|
WarenortNew.wo_bezeichnung = txtBezeichnung.Text
|
|
WarenortNew.wo_aktiv = cbxAktiv.Checked
|
|
WarenortNew.wo_ort = txtOrt.Text
|
|
WarenortNew.wo_grenzstelle = cbxGrenzstelle._value
|
|
WarenortNew.wo_firma = cbxFirmaChange._value
|
|
WarenortNew.wo_cluster = txtCluster.Text
|
|
WarenortNew.wo_knnr = txtKennr.Text
|
|
WarenortNew.wo_reihenfolge = txtReihenfolge.Text
|
|
WarenortNew.wo_strasse = txtStrasse.Text
|
|
|
|
If cbxGrenzstelle._value = "" Then
|
|
lblWarning.Text = "Grenzstelle muss ausgewählt werden!"
|
|
Exit Sub
|
|
Else
|
|
lblWarning.Text = ""
|
|
End If
|
|
|
|
WarenortNew.SAVE()
|
|
dgvWarenorteNew.GetOrder()
|
|
initDGVWarenort(cbxFirma._value)
|
|
dgvWarenorteNew.SetOrder()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub cbxFirma_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxFirma.SelectedValueChanged
|
|
dgvWarenorteNew.GetOrder()
|
|
initDGVWarenort(cbxFirma._value)
|
|
dgvWarenorteNew.SetOrder()
|
|
End Sub
|
|
|
|
Private Function checkIfFirmaIsFilled(initialSave As Boolean)
|
|
|
|
|
|
|
|
If cbxFirma._value = "" Then
|
|
If (dgvWarenorteNew.SelectedRows(0).Cells("wo_firma").Value Is DBNull.Value Or dgvWarenorteNew.SelectedRows(0).Cells("wo_firma").Value Is Nothing) Or initialSave Then
|
|
|
|
lblWarning.Text = "Bitte Firma auswählen!"
|
|
Return False
|
|
End If
|
|
lblWarning.Text = ""
|
|
Return True
|
|
|
|
Else
|
|
|
|
lblWarning.Text = ""
|
|
Return True
|
|
|
|
|
|
End If
|
|
|
|
Return False
|
|
|
|
End Function
|
|
End Class |