jo
This commit is contained in:
parent
92d0a16d4c
commit
926f62cc1c
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Artikelverwaltung
|
namespace Artikelverwaltung
|
||||||
{
|
{
|
||||||
|
@ -43,6 +44,44 @@ namespace Artikelverwaltung
|
||||||
{
|
{
|
||||||
Artikelliste = database.ArtikelAbrufen();
|
Artikelliste = database.ArtikelAbrufen();
|
||||||
}
|
}
|
||||||
|
public string ArtikelMenge()
|
||||||
|
{
|
||||||
|
return database.ArtikelZählen().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Errechnet die Seitenanzahl
|
||||||
|
public void ComboBoxZähler(ComboBox combo)
|
||||||
|
{
|
||||||
|
int endPosition = 30;
|
||||||
|
bool modo = true;
|
||||||
|
int artikelInsgesammt = database.ArtikelZählen();
|
||||||
|
int teiler = artikelInsgesammt / endPosition;
|
||||||
|
|
||||||
|
while (modo)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int i = 1; i <= teiler +1; i++)
|
||||||
|
{
|
||||||
|
combo.Items.Add(i);
|
||||||
|
modo = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gibt eine Liste mit 30 Artikeln aus der Datenbank zurück
|
||||||
|
public List<Artikel> ListViewPage(int index)
|
||||||
|
{
|
||||||
|
List<Artikel> list = new List<Artikel>();
|
||||||
|
int anzahlDerGezeigtenArtikel = 40;
|
||||||
|
int startPosition = (index * anzahlDerGezeigtenArtikel) - anzahlDerGezeigtenArtikel;
|
||||||
|
int endPosition = anzahlDerGezeigtenArtikel;
|
||||||
|
|
||||||
|
list = database.BestimmteAnzahlanArtikeln(startPosition, endPosition);
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
68
Artikelverwaltung/Artikelverwaltung.Designer.cs
generated
68
Artikelverwaltung/Artikelverwaltung.Designer.cs
generated
|
@ -37,6 +37,11 @@
|
||||||
this.logout = new System.Windows.Forms.Button();
|
this.logout = new System.Windows.Forms.Button();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
this.searchbox = new System.Windows.Forms.TextBox();
|
this.searchbox = new System.Windows.Forms.TextBox();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
|
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
|
@ -100,7 +105,7 @@
|
||||||
this.listView1.HideSelection = false;
|
this.listView1.HideSelection = false;
|
||||||
this.listView1.Location = new System.Drawing.Point(24, 49);
|
this.listView1.Location = new System.Drawing.Point(24, 49);
|
||||||
this.listView1.Name = "listView1";
|
this.listView1.Name = "listView1";
|
||||||
this.listView1.Size = new System.Drawing.Size(754, 821);
|
this.listView1.Size = new System.Drawing.Size(754, 801);
|
||||||
this.listView1.TabIndex = 6;
|
this.listView1.TabIndex = 6;
|
||||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||||
//
|
//
|
||||||
|
@ -133,12 +138,68 @@
|
||||||
this.searchbox.Size = new System.Drawing.Size(212, 26);
|
this.searchbox.Size = new System.Drawing.Size(212, 26);
|
||||||
this.searchbox.TabIndex = 9;
|
this.searchbox.TabIndex = 9;
|
||||||
//
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label3.Location = new System.Drawing.Point(727, 859);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(51, 20);
|
||||||
|
this.label3.TabIndex = 10;
|
||||||
|
this.label3.Text = "label3";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label4.Location = new System.Drawing.Point(620, 859);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(101, 20);
|
||||||
|
this.label4.TabIndex = 11;
|
||||||
|
this.label4.Text = "Insgesammt:";
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.AutoSize = true;
|
||||||
|
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label5.Location = new System.Drawing.Point(20, 859);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(54, 20);
|
||||||
|
this.label5.TabIndex = 12;
|
||||||
|
this.label5.Text = "Seite: ";
|
||||||
|
//
|
||||||
|
// comboBox1
|
||||||
|
//
|
||||||
|
this.comboBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||||
|
this.comboBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.comboBox1.FormattingEnabled = true;
|
||||||
|
this.comboBox1.Location = new System.Drawing.Point(70, 851);
|
||||||
|
this.comboBox1.Name = "comboBox1";
|
||||||
|
this.comboBox1.Size = new System.Drawing.Size(35, 28);
|
||||||
|
this.comboBox1.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.button1.Location = new System.Drawing.Point(784, 340);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(174, 37);
|
||||||
|
this.button1.TabIndex = 14;
|
||||||
|
this.button1.Text = "Beenden";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
// Artikelverwaltung
|
// Artikelverwaltung
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||||
this.ClientSize = new System.Drawing.Size(982, 882);
|
this.ClientSize = new System.Drawing.Size(982, 882);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
|
this.Controls.Add(this.comboBox1);
|
||||||
|
this.Controls.Add(this.label5);
|
||||||
|
this.Controls.Add(this.label4);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.searchbox);
|
this.Controls.Add(this.searchbox);
|
||||||
this.Controls.Add(this.label2);
|
this.Controls.Add(this.label2);
|
||||||
this.Controls.Add(this.logout);
|
this.Controls.Add(this.logout);
|
||||||
|
@ -166,5 +227,10 @@
|
||||||
private System.Windows.Forms.Button logout;
|
private System.Windows.Forms.Button logout;
|
||||||
private System.Windows.Forms.Label label2;
|
private System.Windows.Forms.Label label2;
|
||||||
private System.Windows.Forms.TextBox searchbox;
|
private System.Windows.Forms.TextBox searchbox;
|
||||||
|
private System.Windows.Forms.Label label3;
|
||||||
|
private System.Windows.Forms.Label label4;
|
||||||
|
private System.Windows.Forms.Label label5;
|
||||||
|
private System.Windows.Forms.ComboBox comboBox1;
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,22 +17,18 @@ namespace Artikelverwaltung
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
artikelverwaltung = new Artikel_Verwaltung();
|
artikelverwaltung = new Artikel_Verwaltung();
|
||||||
|
ListeViewStartSetup();
|
||||||
// Spaltern für die Listview erstellen und Listview generieren
|
|
||||||
listView1.Columns.Add("Artikel Nr.", 100);
|
|
||||||
listView1.Columns.Add("Artikelbeschreibung", 220, HorizontalAlignment.Center);
|
|
||||||
listView1.Columns.Add("Modellname", 150, HorizontalAlignment.Center);
|
|
||||||
listView1.Columns.Add("Artikelgruppe", 150, HorizontalAlignment.Center);
|
|
||||||
listView1.Columns.Add("Flag", 110);
|
|
||||||
listView1.View = View.Details;
|
|
||||||
listView1.MouseDoubleClick += new MouseEventHandler(listView1_MouseDoubleClick);
|
|
||||||
ListeAktuallisieren();
|
ListeAktuallisieren();
|
||||||
searchbox.TextChanged += new EventHandler(searchBox_TextChanged);
|
searchbox.TextChanged += new EventHandler(searchBox_TextChanged);
|
||||||
|
label3.Text = artikelverwaltung.ArtikelMenge(); // Artikel Insgesammt in der Datenbank
|
||||||
|
artikelverwaltung.ComboBoxZähler(comboBox1); // Füllt die Combobox
|
||||||
|
comboBox1.SelectedIndexChanged += new EventHandler(ComboboxAuswahl);
|
||||||
|
comboBox1.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
private void anlegen_Click(object sender, EventArgs e)
|
private void anlegen_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Artikel_Anlegen form = new Artikel_Anlegen();
|
Artikel_Anlegen form = new Artikel_Anlegen();
|
||||||
form.ShowDialog();
|
form.Show();
|
||||||
ListeAktuallisieren();
|
ListeAktuallisieren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +43,7 @@ namespace Artikelverwaltung
|
||||||
int id = Convert.ToInt32(listView1.Items[listView1.FocusedItem.Index].Text);
|
int id = Convert.ToInt32(listView1.Items[listView1.FocusedItem.Index].Text);
|
||||||
artikelverwaltung.ArtikelLoeschen(id);
|
artikelverwaltung.ArtikelLoeschen(id);
|
||||||
ListeAktuallisieren();
|
ListeAktuallisieren();
|
||||||
|
label3.Text = artikelverwaltung.ArtikelMenge();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -62,7 +59,7 @@ namespace Artikelverwaltung
|
||||||
|
|
||||||
foreach (Artikel artikel in artikelverwaltung.Artikelliste)
|
foreach (Artikel artikel in artikelverwaltung.Artikelliste)
|
||||||
{
|
{
|
||||||
//Objekt muss in Array umgewandelt werden
|
//Objekt muss in Array umgewandelt werden, damit man es der ListView übergeben kann
|
||||||
string[] arr = { artikel.Artikelnummer.ToString(), artikel.Artikelbeschreibung.ToString(), artikel.Modellname.ToString(), artikel.Artikelgruppe.ToString(), artikel.AktivFlag.ToString() };
|
string[] arr = { artikel.Artikelnummer.ToString(), artikel.Artikelbeschreibung.ToString(), artikel.Modellname.ToString(), artikel.Artikelgruppe.ToString(), artikel.AktivFlag.ToString() };
|
||||||
listView1.Items.Add(new ListViewItem(arr));
|
listView1.Items.Add(new ListViewItem(arr));
|
||||||
}
|
}
|
||||||
|
@ -82,9 +79,10 @@ namespace Artikelverwaltung
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Doppelklick auf zeile muss behandelt werden
|
||||||
private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
|
private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
ListViewHitTestInfo hit = listView1.HitTest(e.Location);
|
ListViewHitTestInfo hit = listView1.HitTest(e.Location); // Position der makierten Zeile
|
||||||
|
|
||||||
if (hit.Item != null)
|
if (hit.Item != null)
|
||||||
|
|
||||||
|
@ -94,6 +92,8 @@ namespace Artikelverwaltung
|
||||||
ListeAktuallisieren();
|
ListeAktuallisieren();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Suchfunktion mit Autosuche
|
||||||
private void searchBox_TextChanged(object sender, EventArgs e)
|
private void searchBox_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ListeAktuallisieren();
|
ListeAktuallisieren();
|
||||||
|
@ -101,9 +101,41 @@ namespace Artikelverwaltung
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var list = listView1.Items.Cast<ListViewItem>().Where(x => x.SubItems.Cast<ListViewItem.ListViewSubItem>().Any(y => y.Text.ToLower().Contains(searchbox.Text.ToLower()))).ToArray();
|
var list = listView1.Items.Cast<ListViewItem>().Where(x => x.SubItems.Cast<ListViewItem.ListViewSubItem>().Any(y => y.Text.ToLower().Contains(searchbox.Text.ToLower()))).ToArray(); // Ähhhm?
|
||||||
listView1.Items.Clear();
|
listView1.Items.Clear();
|
||||||
listView1.Items.AddRange(list);
|
listView1.Items.AddRange(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ComboboxAuswahl(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
listView1.Items.Clear();
|
||||||
|
ComboBox comobox = (ComboBox)sender;
|
||||||
|
int index = comobox.SelectedIndex +1;
|
||||||
|
|
||||||
|
List <Artikel>list = artikelverwaltung.ListViewPage(index);
|
||||||
|
|
||||||
|
foreach (Artikel artikel in list)
|
||||||
|
{
|
||||||
|
//Objekt muss in Array umgewandelt werden, damit man es der ListView übergeben kann
|
||||||
|
string[] arr = { artikel.Artikelnummer.ToString(), artikel.Artikelbeschreibung.ToString(), artikel.Modellname.ToString(), artikel.Artikelgruppe.ToString(), artikel.AktivFlag.ToString() };
|
||||||
|
listView1.Items.Add(new ListViewItem(arr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ListeViewStartSetup()
|
||||||
|
{
|
||||||
|
// Spaltern für die Listview erstellen und Listview generieren
|
||||||
|
listView1.Columns.Add("Artikel Nr.", 100);
|
||||||
|
listView1.Columns.Add("Artikelbeschreibung", 220, HorizontalAlignment.Center);
|
||||||
|
listView1.Columns.Add("Modellname", 150, HorizontalAlignment.Center);
|
||||||
|
listView1.Columns.Add("Artikelgruppe", 150, HorizontalAlignment.Center);
|
||||||
|
listView1.Columns.Add("Flag", 110);
|
||||||
|
listView1.View = View.Details;
|
||||||
|
listView1.MouseDoubleClick += new MouseEventHandler(listView1_MouseDoubleClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Artikelverwaltung
|
namespace Artikelverwaltung
|
||||||
{
|
{
|
||||||
|
@ -23,6 +25,8 @@ namespace Artikelverwaltung
|
||||||
|
|
||||||
// Benutzer abgleich direkt aus der Datenbank, ohne die Daten im Programm zu haben.
|
// Benutzer abgleich direkt aus der Datenbank, ohne die Daten im Programm zu haben.
|
||||||
public bool loginAbgleich(string bn, string pw)
|
public bool loginAbgleich(string bn, string pw)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
cmd.Connection = connection;
|
cmd.Connection = connection;
|
||||||
|
@ -37,11 +41,19 @@ namespace Artikelverwaltung
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connection.Close();
|
connection.Close();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("SQL Error");
|
||||||
|
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public void BenutzerAnlegen(MitarbeiterAccount acc)
|
public void BenutzerAnlegen(MitarbeiterAccount acc)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
cmd.Connection = connection;
|
cmd.Connection = connection;
|
||||||
|
@ -49,16 +61,32 @@ namespace Artikelverwaltung
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
connection.Close();
|
connection.Close();
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("SQL Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public void ArtikelAnlegen(Artikel artikel)
|
public void ArtikelAnlegen(Artikel artikel)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
cmd.Connection= connection;
|
cmd.Connection = connection;
|
||||||
cmd.CommandText = $"insert into artikel(artikelbeschreibung, modellname,artikelgruppe,aktivFlag) values('{artikel.Artikelbeschreibung}','{artikel.Modellname}','{artikel.Artikelgruppe}','{Convert.ToInt16(artikel.AktivFlag)}')";
|
cmd.CommandText = $"insert into artikel(artikelbeschreibung, modellname,artikelgruppe,aktivFlag) values('{artikel.Artikelbeschreibung}','{artikel.Modellname}','{artikel.Artikelgruppe}','{Convert.ToInt16(artikel.AktivFlag)}')";
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
connection.Close();
|
connection.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("SQL Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ArtikelLoeschen(int id)
|
public void ArtikelLoeschen(int id)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
cmd.Connection = connection;
|
cmd.Connection = connection;
|
||||||
|
@ -66,8 +94,16 @@ namespace Artikelverwaltung
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
connection.Close();
|
connection.Close();
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("SQL Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void ArtikelAendern(Artikel artikel, int id)
|
public void ArtikelAendern(Artikel artikel, int id)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
cmd.Connection = connection;
|
cmd.Connection = connection;
|
||||||
|
@ -75,21 +111,79 @@ namespace Artikelverwaltung
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
connection.Close();
|
connection.Close();
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("SQL Error");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public List<Artikel> ArtikelAbrufen()
|
public List<Artikel> ArtikelAbrufen()
|
||||||
{
|
{
|
||||||
List<Artikel> list = new List<Artikel>();
|
List<Artikel> list = new List<Artikel>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
cmd.Connection = connection;
|
cmd.Connection = connection;
|
||||||
cmd.CommandText = $"select * from artikel";
|
cmd.CommandText = $"select * from artikel";
|
||||||
MySqlDataReader reader = cmd.ExecuteReader();
|
MySqlDataReader reader = cmd.ExecuteReader();
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
Artikel artikel = new Artikel(Convert.ToUInt32(reader["artikelnummer"]), reader["artikelbeschreibung"].ToString(), reader["modellname"].ToString(),reader["artikelgruppe"].ToString(), Convert.ToBoolean(reader["aktivFlag"]));
|
Artikel artikel = new Artikel(Convert.ToUInt32(reader["artikelnummer"]), reader["artikelbeschreibung"].ToString(), reader["modellname"].ToString(), reader["artikelgruppe"].ToString(), Convert.ToBoolean(reader["aktivFlag"]));
|
||||||
list.Add(artikel);
|
list.Add(artikel);
|
||||||
}
|
}
|
||||||
connection.Close();
|
connection.Close();
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("SQL Error");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Gibt anzahl an Artikel zurück
|
||||||
|
public int ArtikelZählen()
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
connection.Open();
|
||||||
|
cmd.Connection = connection;
|
||||||
|
cmd.CommandText = $"select count(*) as result from artikel";
|
||||||
|
MySqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
result = Convert.ToInt32(reader["result"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
connection.Close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public List<Artikel> BestimmteAnzahlanArtikeln(int start, int end)
|
||||||
|
{
|
||||||
|
List<Artikel> list = new List<Artikel>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
cmd.Connection = connection;
|
||||||
|
cmd.CommandText = $"select * from artikel limit {start},{end}";
|
||||||
|
MySqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
Artikel artikel = new Artikel(Convert.ToUInt32(reader["artikelnummer"]), reader["artikelbeschreibung"].ToString(), reader["modellname"].ToString(), reader["artikelgruppe"].ToString(), Convert.ToBoolean(reader["aktivFlag"]));
|
||||||
|
list.Add(artikel);
|
||||||
|
}
|
||||||
|
connection.Close();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
//"SQL Error"
|
||||||
|
MessageBox.Show(ex.ToString());
|
||||||
|
connection.Close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user