Example #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var mail     = MailTextBox.Text;
            var password = PasswordBox.Password.ToString();
            var db       = new ShopEntities();
            IQueryable <Client> ClientsTable = db.Client;
            bool loggedin = false;

            foreach (var item in ClientsTable)
            {
                if (mail == item.Mail)
                {
                    if (password == item.ClientPassword)
                    {
                        loggedin = true;
                        loggerID = item.ClientID;
                    }
                    else
                    {
                        MessageBox.Show("Wpisałeś niepoprawne hasło");
                    }
                }
            }
            if (loggedin)
            {
                LoggedIn loggedInWindow = new LoggedIn();
                loggedInWindow.Passdata.Text = loggerID.ToString();
                loggedInWindow.Show();
                this.Close();
            }
        }
Example #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var FirstName = FirstNameTextBox.Text;
         var LastName  = LastNameTextBox.Text;
         var BornYear  = Int32.Parse(BornYearTextBox.Text);
         var Telephone = PhoneTextBox.Text;
         var Email     = EmailTextBox.Text;
         var Pass1     = PasswordTextBox.Password.ToString();
         var Pass2     = SecondPasswTextBox.Password.ToString();
         if ((bool)CheckBox.IsChecked)
         {
             if (Pass1 == Pass2 && Pass1 != "")
             {
                 var db      = new ShopEntities();
                 var clients = db.Set <Client>();
                 clients.Add(new Client {
                     FirstName = FirstName, LastName = LastName,
                     BornYear  = BornYear, PhoneNb = Telephone, ClientPassword = Pass1, Mail = Email
                 });
                 db.SaveChanges();
                 MessageBox.Show("Zarejestrowano!");
             }
             else
             {
                 MessageBox.Show("Podane hasła nie są takie same!");
             }
         }
         else
         {
             MessageBox.Show("Musisz zaakceptować nasze warunki!");
         }
     }
     catch (System.Data.Entity.Infrastructure.DbUpdateException)
     {
         MessageBox.Show("Baza danych nie chce przyjac danych w takiej postaci !");
     }
     catch (FormatException)
     {
         MessageBox.Show("Wpisałeś niepoprawne dane (Rok urodzenia)!");
     }
 }