Vous êtes sur la page 1sur 3

using System;

using System.IO;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
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.Navigation;
using System.Windows.Shapes;
namespace HZ_Prodaja_Karata.Pages
{
/// <summary>
/// Interaction logic for HomePage.xaml
/// </summary>
public partial class HomePage : Page
{
public HomePage()
{
InitializeComponent();
}
private void button2_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri("Pages/HelpPage.xaml", UriKi
nd.Relative));
}
private void button1_Click(object sender, RoutedEventArgs e)
{
string[] usernames = new string[5] { "joprlic", "jpucic", "iradic",
"ssoric", "dstajduh" };
string[] passwords = new string[5] { "joprlic", "jpucic", "iradic",
"ssoric", "dstajduh" };
if (((textBox1.Text == usernames[0]) && (textBox2.Password == passwo
rds[0])) ||
((textBox1.Text == usernames[1]) && (textBox2.Password == passwo
rds[1])) ||
((textBox1.Text == usernames[2]) && (textBox2.Password == passwo
rds[2])) ||
((textBox1.Text == usernames[3]) && (textBox2.Password == passwo
rds[3])) ||
((textBox1.Text == usernames[4]) && (textBox2.Password == passwo
rds[4])))
{
FileStream fs = new FileStream("temp.txt", FileMode.Create);
StreamWriter w = new StreamWriter(fs, Encoding.UTF8);
w.Write("Konobar: ");
w.Write(textBox1.Text);
w.WriteLine();
w.Close();
textBox1.Text = null;
this.NavigationService.Navigate(new Uri("Pages/SelectTable.xaml"
, UriKind.Relative));
}
else
{
if ((textBox1.Text == String.Empty) && (textBox2.Password == Str
ing.Empty))
{
MessageBox.Show("Please enter your username and password");
this.NavigationService.Navigate(new Uri("Pages/HomePage.xaml
", UriKind.Relative));
textBox1.Text = null;
textBox2.Password = null;
}
else if (textBox1.Text == String.Empty)
{
MessageBox.Show("Please enter your username!");
this.NavigationService.Navigate(new Uri("Pages/HomePage.xaml
", UriKind.Relative));
textBox1.Text = null;
textBox2.Password = null;
}
else if (textBox2.Password == String.Empty)
{
MessageBox.Show("Please enter your password!");
this.NavigationService.Navigate(new Uri("Pages/HomePage.xaml
", UriKind.Relative));
textBox1.Text = null;
textBox2.Password = null;
}
else if ((textBox1.Text == usernames[0]) ||
(textBox1.Text == usernames[1]) ||
(textBox1.Text == usernames[2]) ||
(textBox1.Text == usernames[3]) ||
(textBox1.Text == usernames[4]))
{
MessageBox.Show("The username is correct but the password is
wrong. Enter your password again!");
this.NavigationService.Navigate(new Uri("Pages/HomePage.xaml
", UriKind.Relative));
//textBox1.Text = null;
textBox2.Password = null;
}
else
{
MessageBox.Show("The username or password you entered is inv
alid! Please try again");
this.NavigationService.Navigate(new Uri("Pages/HomePage.xaml
", UriKind.Relative));
textBox1.Text = null;
textBox2.Password = null;
}
}
}
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
}
private void textBox2_PasswordChanged(object sender, RoutedEventArgs e)
{
}
}
}

Vous aimerez peut-être aussi