fix Kundensuche

This commit is contained in:
2026-10-23 11:31:26 +02:00
parent 85c794053e
commit 576a3c55ab
2 changed files with 108 additions and 22 deletions

View File

@@ -22,7 +22,6 @@ Partial Class frmKundenSuche
'Das Bearbeiten mit dem Code-Editor ist nicht möglich. 'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _ <System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent() Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.txtOrt = New System.Windows.Forms.TextBox() Me.txtOrt = New System.Windows.Forms.TextBox()
Me.Label12 = New System.Windows.Forms.Label() Me.Label12 = New System.Windows.Forms.Label()
Me.txtPlz = New System.Windows.Forms.TextBox() Me.txtPlz = New System.Windows.Forms.TextBox()
@@ -37,7 +36,8 @@ Partial Class frmKundenSuche
Me.FlatButton1 = New VERAG_PROG_ALLGEMEIN.FlatButton() Me.FlatButton1 = New VERAG_PROG_ALLGEMEIN.FlatButton()
Me.FlatButton2 = New VERAG_PROG_ALLGEMEIN.FlatButton() Me.FlatButton2 = New VERAG_PROG_ALLGEMEIN.FlatButton()
Me.pnlErweiterteSuche = New System.Windows.Forms.Panel() Me.pnlErweiterteSuche = New System.Windows.Forms.Panel()
Me.cbxAlleFirmen = New VERAG_PROG_ALLGEMEIN.MyCheckbox(Me.components) Me.Button1 = New System.Windows.Forms.Button()
Me.cbxAlleFirmen = New VERAG_PROG_ALLGEMEIN.MyCheckbox()
Me.Label7 = New System.Windows.Forms.Label() Me.Label7 = New System.Windows.Forms.Label()
Me.txtSteuerNr = New System.Windows.Forms.TextBox() Me.txtSteuerNr = New System.Windows.Forms.TextBox()
Me.Label6 = New System.Windows.Forms.Label() Me.Label6 = New System.Windows.Forms.Label()
@@ -45,12 +45,13 @@ Partial Class frmKundenSuche
Me.txtEORI = New System.Windows.Forms.TextBox() Me.txtEORI = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label() Me.Label1 = New System.Windows.Forms.Label()
Me.txtUID = New System.Windows.Forms.TextBox() Me.txtUID = New System.Windows.Forms.TextBox()
Me.cbxAktiv = New VERAG_PROG_ALLGEMEIN.MyCheckbox(Me.components) Me.cbxAktiv = New VERAG_PROG_ALLGEMEIN.MyCheckbox()
Me.cbxLandKz = New VERAG_PROG_ALLGEMEIN.MyComboBox() Me.cbxLandKz = New VERAG_PROG_ALLGEMEIN.MyComboBox()
Me.FlatButton3 = New System.Windows.Forms.Button() Me.FlatButton3 = New System.Windows.Forms.Button()
Me.pnlTop = New System.Windows.Forms.Panel() Me.pnlTop = New System.Windows.Forms.Panel()
Me.Label2 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label()
Me.lklErweitert = New System.Windows.Forms.LinkLabel() Me.lklErweitert = New System.Windows.Forms.LinkLabel()
Me.lblInfo = New System.Windows.Forms.Label()
CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.Panel1.SuspendLayout() Me.Panel1.SuspendLayout()
Me.pnlMain.SuspendLayout() Me.pnlMain.SuspendLayout()
@@ -203,6 +204,7 @@ Partial Class frmKundenSuche
' '
'pnlErweiterteSuche 'pnlErweiterteSuche
' '
Me.pnlErweiterteSuche.Controls.Add(Me.Button1)
Me.pnlErweiterteSuche.Controls.Add(Me.cbxAlleFirmen) Me.pnlErweiterteSuche.Controls.Add(Me.cbxAlleFirmen)
Me.pnlErweiterteSuche.Controls.Add(Me.Label7) Me.pnlErweiterteSuche.Controls.Add(Me.Label7)
Me.pnlErweiterteSuche.Controls.Add(Me.txtSteuerNr) Me.pnlErweiterteSuche.Controls.Add(Me.txtSteuerNr)
@@ -226,6 +228,18 @@ Partial Class frmKundenSuche
Me.pnlErweiterteSuche.TabIndex = 151 Me.pnlErweiterteSuche.TabIndex = 151
Me.pnlErweiterteSuche.Visible = False Me.pnlErweiterteSuche.Visible = False
' '
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.ForeColor = System.Drawing.Color.Black
Me.Button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.Button1.Location = New System.Drawing.Point(575, 49)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(113, 30)
Me.Button1.TabIndex = 154
Me.Button1.Text = "Reset"
Me.Button1.UseVisualStyleBackColor = True
'
'cbxAlleFirmen 'cbxAlleFirmen
' '
Me.cbxAlleFirmen._value = "" Me.cbxAlleFirmen._value = ""
@@ -346,13 +360,14 @@ Partial Class frmKundenSuche
Me.FlatButton3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft Me.FlatButton3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.FlatButton3.Location = New System.Drawing.Point(450, 49) Me.FlatButton3.Location = New System.Drawing.Point(450, 49)
Me.FlatButton3.Name = "FlatButton3" Me.FlatButton3.Name = "FlatButton3"
Me.FlatButton3.Size = New System.Drawing.Size(246, 30) Me.FlatButton3.Size = New System.Drawing.Size(113, 30)
Me.FlatButton3.TabIndex = 7 Me.FlatButton3.TabIndex = 7
Me.FlatButton3.Text = "Suchen" Me.FlatButton3.Text = "Suchen"
Me.FlatButton3.UseVisualStyleBackColor = True Me.FlatButton3.UseVisualStyleBackColor = True
' '
'pnlTop 'pnlTop
' '
Me.pnlTop.Controls.Add(Me.lblInfo)
Me.pnlTop.Controls.Add(Me.Label2) Me.pnlTop.Controls.Add(Me.Label2)
Me.pnlTop.Controls.Add(Me.lklErweitert) Me.pnlTop.Controls.Add(Me.lklErweitert)
Me.pnlTop.Controls.Add(Me.txtKurzname) Me.pnlTop.Controls.Add(Me.txtKurzname)
@@ -384,6 +399,16 @@ Partial Class frmKundenSuche
Me.lklErweitert.TabStop = True Me.lklErweitert.TabStop = True
Me.lklErweitert.Text = "erweiterte Suche" Me.lklErweitert.Text = "erweiterte Suche"
' '
'lblInfo
'
Me.lblInfo.AutoSize = True
Me.lblInfo.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblInfo.ForeColor = System.Drawing.Color.Red
Me.lblInfo.Location = New System.Drawing.Point(115, 7)
Me.lblInfo.Name = "lblInfo"
Me.lblInfo.Size = New System.Drawing.Size(0, 13)
Me.lblInfo.TabIndex = 150
'
'frmKundenSuche 'frmKundenSuche
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -433,4 +458,6 @@ Partial Class frmKundenSuche
Friend WithEvents cbxAlleFirmen As VERAG_PROG_ALLGEMEIN.MyCheckbox Friend WithEvents cbxAlleFirmen As VERAG_PROG_ALLGEMEIN.MyCheckbox
Friend WithEvents Label7 As Label Friend WithEvents Label7 As Label
Friend WithEvents txtSteuerNr As TextBox Friend WithEvents txtSteuerNr As TextBox
Friend WithEvents Button1 As Button
Friend WithEvents lblInfo As Label
End Class End Class

View File

@@ -39,7 +39,9 @@
End Sub End Sub
Private Sub FlatButton3_Click(sender As Object, e As EventArgs) Handles FlatButton3.Click, cbxAlleFirmen.CheckedChanged Private Sub FlatButton3_Click(sender As Object, e As EventArgs) Handles FlatButton3.Click, cbxAlleFirmen.CheckedChanged
initSearch() If txtKurzname.Text <> "" OrElse txtKundenNr.Text <> "" OrElse txtSteuerNr.Text <> "" OrElse txtOrt.Text <> "" OrElse cbxLandKz.Text <> "" OrElse txtPlz.Text <> "" Then
initSearch()
End If
End Sub End Sub
Sub initSearch() Sub initSearch()
@@ -51,25 +53,52 @@
SQLstr &= " From [Adressen] INNER JOIN Kunden ON KundenNr=AdressenNr inner join Filialen on Filialen.FilialenNr=Kunden.FilialenNr WHERE 1=1 " SQLstr &= " From [Adressen] INNER JOIN Kunden ON KundenNr=AdressenNr inner join Filialen on Filialen.FilialenNr=Kunden.FilialenNr WHERE 1=1 "
Dim suchparam As Boolean = False Dim suchparam As Boolean = False
If txtKurzname.Text <> "" Then SQLstr &= " AND Ordnungsbegriff LIKE '" & txtKurzname.Text & "%'" : suchparam = True If txtKurzname.Text <> "" Then
If txtKundenNr.Text <> "" Then SQLstr &= " AND AdressenNr LIKE '" & txtKundenNr.Text & "%'" : suchparam = True SQLstr &= " AND Ordnungsbegriff LIKE '" & setLIke(txtKurzname.Text) & "%'"
If txtStrasse.Text <> "" Then SQLstr &= " AND Adressen.Straße LIKE '" & txtStrasse.Text & "%'" : suchparam = True suchparam = True
If txtOrt.Text <> "" Then SQLstr &= " AND Adressen.Ort LIKE '" & txtOrt.Text & "%'" : suchparam = True End If
If txtPlz.Text <> "" Then SQLstr &= " AND Adressen.[PLZ] LIKE '" & txtPlz.Text & "%'" : suchparam = True If txtKundenNr.Text <> "" Then
If txtUID.Text <> "" Then SQLstr &= " AND (Adressen.[UstIdKz] + Adressen.[UstIdNr]) LIKE '" & txtUID.Text.Replace("*", "%") & "'" : suchparam = True SQLstr &= " AND AdressenNr LIKE '" & setLIke(txtKundenNr.Text) & "%'"
If txtEORI.Text <> "" Then SQLstr &= " AND [EORITIN] LIKE '" & txtEORI.Text.Replace("*", "%") & "'" : suchparam = True suchparam = True
If cbxLandKz.Text <> "" Then SQLstr &= " AND Adressen.LandKz = '" & DirectCast(cbxLandKz.SelectedItem, VERAG_PROG_ALLGEMEIN.MyListItem).Value & "'" : suchparam = True End If
If txtSteuerNr.Text <> "" Then SQLstr &= " AND Adressen.Steuernummer LIKE '" & txtSteuerNr.Text & "%'" : suchparam = True If txtStrasse.Text <> "" Then
SQLstr &= " AND Adressen.Straße LIKE '" & setLIke(txtStrasse.Text) & "%'"
suchparam = True
End If
If txtOrt.Text <> "" Then
SQLstr &= " AND Adressen.Ort LIKE '" & setLIke(txtOrt.Text) & "%'"
suchparam = True
End If
If txtPlz.Text <> "" Then
SQLstr &= " AND Adressen.[PLZ] LIKE '" & setLIke(txtPlz.Text) & "%'"
suchparam = True
End If
If txtUID.Text <> "" Then
SQLstr &= " AND (Adressen.[UstIdKz] + Adressen.[UstIdNr]) LIKE '" & setLIke(txtUID.Text) & "'"
suchparam = True
End If
If txtEORI.Text <> "" Then
SQLstr &= " AND [EORITIN] LIKE '" & setLIke(txtEORI.Text) & "'"
suchparam = True
End If
If cbxLandKz.Text <> "" Then
SQLstr &= " AND Adressen.LandKz = '" & DirectCast(cbxLandKz.SelectedItem, VERAG_PROG_ALLGEMEIN.MyListItem).Value & "'"
suchparam = True
End If
If txtSteuerNr.Text <> "" Then
SQLstr &= " AND Adressen.Steuernummer LIKE '" & setLIke(txtSteuerNr.Text) & "%'"
suchparam = True
End If
Select Case cbxAktiv.CheckState Select Case cbxAktiv.CheckState
Case CheckState.Checked : SQLstr &= " AND Auswahl='A' " : suchparam = True Case CheckState.Checked : SQLstr &= " AND Auswahl='A' " : suchparam = True
Case CheckState.Unchecked : SQLstr &= " AND Auswahl='I' " : suchparam = True Case CheckState.Unchecked : SQLstr &= " AND Auswahl='I' " : suchparam = True
End Select End Select
If cbxAlleFirmen.Checked Then If cbxAlleFirmen.Checked Then
SQLstr &= " AND '" & VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER & "' IN (Filialen.Firma,Filialen.Cluster) " ' Wenn die Firmenbezeichnung im CLUSter vorkommt .--> Alle Firmen SQLstr &= " AND (Filialen.Firma IN ('" & VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER & "') OR Filialen.Cluster IN ('" & VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER & "')) " ' Wenn die Firmenbezeichnung im CLUSter vorkommt .--> Alle Firmen
Else Else
Select Case VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA Select Case VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA
Case "FRONTOFFICE" : SQLstr &= " AND '" & VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER & "' IN (Filialen.Firma,Filialen.Cluster) " ' Wenn die Firmenbezeichnung im CLUSter vorkommt .--> Frontoffice Case "FRONTOFFICE" : SQLstr &= " AND Filialen.Firma IN (" & VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER & ") " ' Wenn die Firmenbezeichnung im CLUSter vorkommt .--> Frontoffice
Case "VERIMEX" : SQLstr &= " AND '" & VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER & "' IN (Filialen.Firma,Filialen.Cluster) " ' Wenn die Firmenbezeichnung im CLUSter vorkommt .--> Frontoffice Case "VERIMEX" : SQLstr &= " AND Filialen.Cluster IN ('" & VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER & "') " ' Wenn die Firmenbezeichnung im CLUSter vorkommt .--> Frontoffice
Case "VERAG", "ATILLA" : SQLstr &= " AND isnull(Kunden.[FilialenNr],0) NOT IN ('5501','5601','5701','5801') " : suchparam = True Case "VERAG", "ATILLA" : SQLstr &= " AND isnull(Kunden.[FilialenNr],0) NOT IN ('5501','5601','5701','5801') " : suchparam = True
Case Else : SQLstr &= " AND Filialen.Firma='" & VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA & "' " : suchparam = True Case Else : SQLstr &= " AND Filialen.Firma='" & VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA & "' " : suchparam = True
End Select End Select
@@ -84,7 +113,13 @@
Else Else
' MsgBox("Bitte geben Sie einen Suchbegriff ein!") ' MsgBox("Bitte geben Sie einen Suchbegriff ein!")
End If End If
lblInfo.Text = ""
If .RowCount = 0 Then Exit Sub If .RowCount = 0 Then Exit Sub
If .RowCount = 10 Then
lblInfo.Text = "ersten 10 Eintrage!"
End If
.Columns("KdNr").Width = 60 .Columns("KdNr").Width = 60
.Columns("Firma").Width = 250 .Columns("Firma").Width = 250
If .Columns("Firma_intern") IsNot Nothing Then .Columns("Firma_intern").HeaderText = "Firma" If .Columns("Firma_intern") IsNot Nothing Then .Columns("Firma_intern").HeaderText = "Firma"
@@ -93,6 +128,16 @@
End With End With
End Sub End Sub
Private Function setLIke(text As String) As String
text = text.Trim()
If text.StartsWith("*") Then
text = "%" & text.Substring(1).Replace("*", "")
End If
Return text
End Function
Private Sub checkKey(sender As Object, e As KeyEventArgs) Handles txtKurzname.KeyDown, txtKundenNr.KeyDown, txtStrasse.KeyDown, txtOrt.KeyDown, txtPlz.KeyDown Private Sub checkKey(sender As Object, e As KeyEventArgs) Handles txtKurzname.KeyDown, txtKundenNr.KeyDown, txtStrasse.KeyDown, txtOrt.KeyDown, txtPlz.KeyDown
If DataGridView1.RowCount > 0 Then If DataGridView1.RowCount > 0 Then
Select Case e.KeyCode Select Case e.KeyCode
@@ -136,7 +181,10 @@
Private Sub txtKurzname_TextChanged(sender As Object, e As EventArgs) Handles txtKurzname.TextChanged, txtKundenNr.TextChanged, txtStrasse.TextChanged, txtOrt.TextChanged, cbxLandKz.TextChanged, txtPlz.TextChanged Private Sub txtKurzname_TextChanged(sender As Object, e As EventArgs) Handles txtKurzname.TextChanged, txtKundenNr.TextChanged, txtStrasse.TextChanged, txtOrt.TextChanged, cbxLandKz.TextChanged, txtPlz.TextChanged
initSearch() If txtKurzname.Text <> "" OrElse txtKundenNr.Text <> "" OrElse txtSteuerNr.Text <> "" OrElse txtOrt.Text <> "" OrElse cbxLandKz.Text <> "" OrElse txtPlz.Text <> "" Then
initSearch()
End If
End Sub End Sub
Private Sub lklErweitert_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles lklErweitert.LinkClicked Private Sub lklErweitert_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles lklErweitert.LinkClicked
@@ -165,10 +213,21 @@
End Sub End Sub
Private Sub cbxAktiv_CheckedChanged(sender As Object, e As EventArgs) Handles cbxAktiv.CheckedChanged Private Sub cbxAktiv_CheckedChanged(sender As Object, e As EventArgs) Handles cbxAktiv.CheckedChanged
If txtKurzname.Text <> "" OrElse txtKundenNr.Text <> "" OrElse txtSteuerNr.Text <> "" OrElse txtOrt.Text <> "" OrElse cbxLandKz.Text <> "" OrElse txtPlz.Text <> "" Then
initSearch()
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
txtKurzname.Text = ""
txtKundenNr.Text = ""
txtSteuerNr.Text = ""
txtOrt.Text = ""
cbxLandKz.changeItem("")
txtPlz.Text = ""
initSearch() initSearch()
End Sub End Sub
Private Sub pnlErweiterteSuche_Paint(sender As Object, e As PaintEventArgs) Handles pnlErweiterteSuche.Paint
End Sub
End Class End Class