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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.txtOrt = New System.Windows.Forms.TextBox()
Me.Label12 = New System.Windows.Forms.Label()
Me.txtPlz = New System.Windows.Forms.TextBox()
@@ -37,7 +36,8 @@ Partial Class frmKundenSuche
Me.FlatButton1 = New VERAG_PROG_ALLGEMEIN.FlatButton()
Me.FlatButton2 = New VERAG_PROG_ALLGEMEIN.FlatButton()
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.txtSteuerNr = New System.Windows.Forms.TextBox()
Me.Label6 = New System.Windows.Forms.Label()
@@ -45,12 +45,13 @@ Partial Class frmKundenSuche
Me.txtEORI = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
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.FlatButton3 = New System.Windows.Forms.Button()
Me.pnlTop = New System.Windows.Forms.Panel()
Me.Label2 = New System.Windows.Forms.Label()
Me.lklErweitert = New System.Windows.Forms.LinkLabel()
Me.lblInfo = New System.Windows.Forms.Label()
CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.Panel1.SuspendLayout()
Me.pnlMain.SuspendLayout()
@@ -203,6 +204,7 @@ Partial Class frmKundenSuche
'
'pnlErweiterteSuche
'
Me.pnlErweiterteSuche.Controls.Add(Me.Button1)
Me.pnlErweiterteSuche.Controls.Add(Me.cbxAlleFirmen)
Me.pnlErweiterteSuche.Controls.Add(Me.Label7)
Me.pnlErweiterteSuche.Controls.Add(Me.txtSteuerNr)
@@ -226,6 +228,18 @@ Partial Class frmKundenSuche
Me.pnlErweiterteSuche.TabIndex = 151
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
'
Me.cbxAlleFirmen._value = ""
@@ -346,13 +360,14 @@ Partial Class frmKundenSuche
Me.FlatButton3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.FlatButton3.Location = New System.Drawing.Point(450, 49)
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.Text = "Suchen"
Me.FlatButton3.UseVisualStyleBackColor = True
'
'pnlTop
'
Me.pnlTop.Controls.Add(Me.lblInfo)
Me.pnlTop.Controls.Add(Me.Label2)
Me.pnlTop.Controls.Add(Me.lklErweitert)
Me.pnlTop.Controls.Add(Me.txtKurzname)
@@ -384,6 +399,16 @@ Partial Class frmKundenSuche
Me.lklErweitert.TabStop = True
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
'
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 Label7 As Label
Friend WithEvents txtSteuerNr As TextBox
Friend WithEvents Button1 As Button
Friend WithEvents lblInfo As Label
End Class

View File

@@ -39,7 +39,9 @@
End Sub
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
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 "
Dim suchparam As Boolean = False
If txtKurzname.Text <> "" Then SQLstr &= " AND Ordnungsbegriff LIKE '" & txtKurzname.Text & "%'" : suchparam = True
If txtKundenNr.Text <> "" Then SQLstr &= " AND AdressenNr LIKE '" & txtKundenNr.Text & "%'" : suchparam = True
If txtStrasse.Text <> "" Then SQLstr &= " AND Adressen.Straße LIKE '" & txtStrasse.Text & "%'" : suchparam = True
If txtOrt.Text <> "" Then SQLstr &= " AND Adressen.Ort LIKE '" & txtOrt.Text & "%'" : suchparam = True
If txtPlz.Text <> "" Then SQLstr &= " AND Adressen.[PLZ] LIKE '" & txtPlz.Text & "%'" : suchparam = True
If txtUID.Text <> "" Then SQLstr &= " AND (Adressen.[UstIdKz] + Adressen.[UstIdNr]) LIKE '" & txtUID.Text.Replace("*", "%") & "'" : suchparam = True
If txtEORI.Text <> "" Then SQLstr &= " AND [EORITIN] LIKE '" & txtEORI.Text.Replace("*", "%") & "'" : suchparam = True
If cbxLandKz.Text <> "" Then SQLstr &= " AND Adressen.LandKz = '" & DirectCast(cbxLandKz.SelectedItem, VERAG_PROG_ALLGEMEIN.MyListItem).Value & "'" : suchparam = True
If txtSteuerNr.Text <> "" Then SQLstr &= " AND Adressen.Steuernummer LIKE '" & txtSteuerNr.Text & "%'" : suchparam = True
If txtKurzname.Text <> "" Then
SQLstr &= " AND Ordnungsbegriff LIKE '" & setLIke(txtKurzname.Text) & "%'"
suchparam = True
End If
If txtKundenNr.Text <> "" Then
SQLstr &= " AND AdressenNr LIKE '" & setLIke(txtKundenNr.Text) & "%'"
suchparam = True
End If
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
Case CheckState.Checked : SQLstr &= " AND Auswahl='A' " : suchparam = True
Case CheckState.Unchecked : SQLstr &= " AND Auswahl='I' " : suchparam = True
End Select
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
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 "VERIMEX" : 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 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 Else : SQLstr &= " AND Filialen.Firma='" & VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA & "' " : suchparam = True
End Select
@@ -84,7 +113,13 @@
Else
' MsgBox("Bitte geben Sie einen Suchbegriff ein!")
End If
lblInfo.Text = ""
If .RowCount = 0 Then Exit Sub
If .RowCount = 10 Then
lblInfo.Text = "ersten 10 Eintrage!"
End If
.Columns("KdNr").Width = 60
.Columns("Firma").Width = 250
If .Columns("Firma_intern") IsNot Nothing Then .Columns("Firma_intern").HeaderText = "Firma"
@@ -93,6 +128,16 @@
End With
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
If DataGridView1.RowCount > 0 Then
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
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
Private Sub lklErweitert_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles lklErweitert.LinkClicked
@@ -165,10 +213,21 @@
End Sub
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()
End Sub
Private Sub pnlErweiterteSuche_Paint(sender As Object, e As PaintEventArgs) Handles pnlErweiterteSuche.Paint
End Sub
End Class