Erster Login versuch
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
<Window x:Class="Casino.Login"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:Casino"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Login" Height="450" Width="300">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="0*"/>
|
||||||
|
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<StackPanel Margin="15" Grid.ColumnSpan="2">
|
||||||
|
<Label Content="Name" Margin="0,30,0,0"/>
|
||||||
|
<TextBox x:Name="TxtName" Margin="0,0,0,30"/>
|
||||||
|
<Label Content="Passwort"/>
|
||||||
|
<TextBox x:Name="TxtPasswort" Margin="0,0,0,10"/>
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
|
<Button Content="Anmelden" Width="80" Click="Anmelden_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace Casino
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaktionslogik für Login.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class Login : Window
|
||||||
|
{
|
||||||
|
public Login()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Anmelden_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if(checkLogin(TxtName.Text, TxtPasswort.Text))
|
||||||
|
{
|
||||||
|
DialogResult = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool checkLogin(string name, string passwort)
|
||||||
|
{
|
||||||
|
Database db = new Database();
|
||||||
|
ObservableCollection<User> users = new ObservableCollection<User>();
|
||||||
|
users = db.SelectTask();
|
||||||
|
for (int i = 0; i < users.Count(); i++)
|
||||||
|
{
|
||||||
|
if (name.Equals(users[1].Name))
|
||||||
|
{
|
||||||
|
if(passwort.Equals(users[1].Passwort)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,13 @@ namespace Casino
|
|||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
var window = new Login();
|
||||||
|
|
||||||
|
window.Owner = this;
|
||||||
|
window.ShowDialog();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-2
@@ -11,19 +11,22 @@ namespace Casino
|
|||||||
public string ID { get; }
|
public string ID { get; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Alter { get; set; }
|
public int Alter { get; set; }
|
||||||
|
public string Passwort { get; set; }
|
||||||
public int Geld { get; set; }
|
public int Geld { get; set; }
|
||||||
public User(string n, int a)
|
public User(string n, int a, string p)
|
||||||
{
|
{
|
||||||
ID = ID_Generation();
|
ID = ID_Generation();
|
||||||
Name = n;
|
Name = n;
|
||||||
Alter = a;
|
Alter = a;
|
||||||
|
Passwort = p;
|
||||||
Geld = 1000;
|
Geld = 1000;
|
||||||
}
|
}
|
||||||
public User(string id, string n, int a, int g)
|
public User(string id, string n, int a,string p, int g)
|
||||||
{
|
{
|
||||||
ID = id;
|
ID = id;
|
||||||
Name = n;
|
Name = n;
|
||||||
Alter = a;
|
Alter = a;
|
||||||
|
Passwort = p;
|
||||||
Geld = g;
|
Geld = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user