Login verbessert

This commit is contained in:
marcusferl@weifer.de 2022-10-26 10:55:56 +02:00
parent 8954fb1197
commit 508d2cb06c
8 changed files with 74 additions and 52 deletions

View File

@ -152,11 +152,11 @@
// //
this.label4.AutoSize = true; 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.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.Location = new System.Drawing.Point(648, 859);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(101, 20); this.label4.Size = new System.Drawing.Size(73, 20);
this.label4.TabIndex = 11; this.label4.TabIndex = 11;
this.label4.Text = "Insgesammt:"; this.label4.Text = "Bestand:";
// //
// label5 // label5
// //

View File

@ -48,8 +48,6 @@ namespace Artikelverwaltung
} }
return false; return false;
} }
public void BenutzerAnlegen(MitarbeiterAccount acc) public void BenutzerAnlegen(MitarbeiterAccount acc)
{ {
@ -65,7 +63,6 @@ namespace Artikelverwaltung
{ {
MessageBox.Show("SQL Error"); MessageBox.Show("SQL Error");
} }
} }
public void ArtikelAnlegen(Artikel artikel) public void ArtikelAnlegen(Artikel artikel)
{ {
@ -98,7 +95,6 @@ namespace Artikelverwaltung
{ {
MessageBox.Show("SQL Error"); MessageBox.Show("SQL Error");
} }
} }
public void ArtikelAendern(Artikel artikel, int id) public void ArtikelAendern(Artikel artikel, int id)
@ -141,7 +137,6 @@ namespace Artikelverwaltung
MessageBox.Show("SQL Error"); MessageBox.Show("SQL Error");
return null; return null;
} }
} }
// Gibt anzahl an Artikel zurück // Gibt anzahl an Artikel zurück
public int ArtikelZählen() public int ArtikelZählen()
@ -194,7 +189,6 @@ namespace Artikelverwaltung
connection.Close(); connection.Close();
return null; return null;
} }
} }
} }
} }

View File

@ -98,6 +98,7 @@ namespace Artikelverwaltung
private bool verfügbarerPlatz(int menge) private bool verfügbarerPlatz(int menge)
{ {
return (Lagerbestand + menge) <= Kapazitaet; return (Lagerbestand + menge) <= Kapazitaet;
} }
} }

View File

@ -35,6 +35,8 @@
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox(); this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.verwaltungsButton = new System.Windows.Forms.Button();
this.beenden_Button = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
@ -76,9 +78,9 @@
// button1 // button1
// //
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(27, 268); this.button1.Location = new System.Drawing.Point(12, 268);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(95, 35); this.button1.Size = new System.Drawing.Size(116, 35);
this.button1.TabIndex = 4; this.button1.TabIndex = 4;
this.button1.Text = "Login"; this.button1.Text = "Login";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
@ -98,14 +100,38 @@
// //
// button2 // button2
// //
this.button2.Enabled = false;
this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button2.Location = new System.Drawing.Point(161, 268); this.button2.Location = new System.Drawing.Point(158, 268);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(95, 35); this.button2.Size = new System.Drawing.Size(116, 35);
this.button2.TabIndex = 6; this.button2.TabIndex = 6;
this.button2.Text = "Anlegen"; this.button2.Text = "Add User";
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click); this.button2.Click += new System.EventHandler(this.RegistrierungsButton);
//
// verwaltungsButton
//
this.verwaltungsButton.Enabled = false;
this.verwaltungsButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.verwaltungsButton.Location = new System.Drawing.Point(12, 309);
this.verwaltungsButton.Name = "verwaltungsButton";
this.verwaltungsButton.Size = new System.Drawing.Size(116, 35);
this.verwaltungsButton.TabIndex = 7;
this.verwaltungsButton.Text = "Verwaltung";
this.verwaltungsButton.UseVisualStyleBackColor = true;
this.verwaltungsButton.Click += new System.EventHandler(this.verwaltungsButton_Click);
//
// beenden_Button
//
this.beenden_Button.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.beenden_Button.Location = new System.Drawing.Point(158, 309);
this.beenden_Button.Name = "beenden_Button";
this.beenden_Button.Size = new System.Drawing.Size(116, 35);
this.beenden_Button.TabIndex = 8;
this.beenden_Button.Text = "Beenden";
this.beenden_Button.UseVisualStyleBackColor = true;
this.beenden_Button.Click += new System.EventHandler(this.beenden_Button_Click);
// //
// Login // Login
// //
@ -113,7 +139,9 @@
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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.ClientSize = new System.Drawing.Size(284, 331); this.ClientSize = new System.Drawing.Size(286, 354);
this.Controls.Add(this.beenden_Button);
this.Controls.Add(this.verwaltungsButton);
this.Controls.Add(this.button2); this.Controls.Add(this.button2);
this.Controls.Add(this.checkBox1); this.Controls.Add(this.checkBox1);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
@ -140,6 +168,8 @@
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button verwaltungsButton;
private System.Windows.Forms.Button beenden_Button;
} }
} }

View File

@ -20,25 +20,22 @@ namespace Artikelverwaltung
InitializeComponent(); InitializeComponent();
zugriffsverwaltung = new Zugriffsverwaltung(); zugriffsverwaltung = new Zugriffsverwaltung();
textBoxPasswort.PasswordChar = '*'; textBoxPasswort.PasswordChar = '*';
} }
private void login(object sender, EventArgs e) private void login(object sender, EventArgs e)
{ {
if (zugriffsverwaltung.loginArtikelverwaltung(textBoxBenutzername.Text, textBoxPasswort.Text)) if (zugriffsverwaltung.loginArtikelverwaltung(textBoxBenutzername.Text, textBoxPasswort.Text))
{ {
MessageBox.Show("Login erfolgreich!"); MessageBox.Show("Login erfolgreich!");
this.Close(); verwaltungsButton.Enabled = true;
th = new Thread(AritelverwaltunForm); button2.Enabled = true;
th.SetApartmentState(ApartmentState.STA); textBoxBenutzername.Text = "";
th.Start(); textBoxPasswort.Text = "";
} }
else else
{ {
MessageBox.Show("Login Fehlgeschlagen!"); MessageBox.Show("Login Fehlgeschlagen!");
} }
} }
private void checkBox1_CheckedChanged(object sender, EventArgs e) private void checkBox1_CheckedChanged(object sender, EventArgs e)
{ {
if(checkBox1.CheckState != CheckState.Checked) if(checkBox1.CheckState != CheckState.Checked)
@ -50,22 +47,28 @@ namespace Artikelverwaltung
textBoxPasswort.PasswordChar = '\0'; textBoxPasswort.PasswordChar = '\0';
} }
} }
private void RegistrierungsButton(object sender, EventArgs e)
{
this.Hide();
Register register = new Register(this);
register.Show();
}
private void AritelverwaltunForm(object obj)
{
Application.Run(new Artikelverwaltung());
}
private void button2_Click(object sender, EventArgs e) private void beenden_Button_Click(object sender, EventArgs e)
{
Close();
}
private void verwaltungsButton_Click(object sender, EventArgs e)
{ {
this.Close(); this.Close();
th = new Thread(RegisterForm); th = new Thread(AritelverwaltunForm);
th.SetApartmentState(ApartmentState.STA); th.SetApartmentState(ApartmentState.STA);
th.Start(); th.Start();
} }
private void RegisterForm(object obj)
{
Application.Run(new Register());
}
private void AritelverwaltunForm(object obj)
{
Application.Run(new Artikelverwaltung()); ;
}
} }
} }

View File

@ -92,7 +92,7 @@
this.button1.TabIndex = 5; this.button1.TabIndex = 5;
this.button1.Text = "Anlegen"; this.button1.Text = "Anlegen";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click); this.button1.Click += new System.EventHandler(this.AnlegenButton);
// //
// button2 // button2
// //
@ -103,7 +103,7 @@
this.button2.TabIndex = 6; this.button2.TabIndex = 6;
this.button2.Text = "Zurück"; this.button2.Text = "Zurück";
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click); this.button2.Click += new System.EventHandler(this.ZurückButton);
// //
// Register // Register
// //

View File

@ -14,35 +14,30 @@ namespace Artikelverwaltung
public partial class Register : Form public partial class Register : Form
{ {
Zugriffsverwaltung zugriffsverwaltung; Zugriffsverwaltung zugriffsverwaltung;
Thread th; Form form; // Login Form
public Register() public Register(Form form)
{ {
InitializeComponent(); InitializeComponent();
zugriffsverwaltung = new Zugriffsverwaltung(); zugriffsverwaltung = new Zugriffsverwaltung();
this.form = form;
} }
private void AnlegenButton(object sender, EventArgs e)
private void button1_Click(object sender, EventArgs e)
{ {
if (zugriffsverwaltung.benutzerAnlegen(textBoxRegisterBenutzername.Text, textBoxRegisterPasswort.Text)) if (zugriffsverwaltung.benutzerAnlegen(textBoxRegisterBenutzername.Text, textBoxRegisterPasswort.Text))
{ {
MessageBox.Show("Benutzer Angelegt"); MessageBox.Show($"Benutzer {textBoxRegisterBenutzername.Text} Angelegt ");
textBoxRegisterBenutzername.Text = "";
textBoxRegisterPasswort.Text = "";
} }
else else
{ {
MessageBox.Show("Fehler beim Anlegen!"); MessageBox.Show("Fehler beim Anlegen!");
} }
} }
private void ZurückButton(object sender, EventArgs e)
private void button2_Click(object sender, EventArgs e)
{ {
this.Close(); this.Close();
th = new Thread(openNewForm); form.Show();
th.SetApartmentState(ApartmentState.STA);
th.Start();
}
private void openNewForm(object obj)
{
Application.Run(new Login());
} }
} }
} }

View File

@ -32,7 +32,6 @@ namespace Artikelverwaltung
{ {
return false; return false;
} }
} }
} }
} }