Exemple #1
0
 private void OK_btn_Click(object sender, RoutedEventArgs e)
 {
     if (Login_field.Text.Length == 0 || Password_field.Password.Length == 0 || City_combo.Text.Length == 0 || Street_field.Text.Length == 0 ||
         Number_field.Text.Length == 0)
     {
         MessageBox.Show("Wrong data.");
     }
     else if (Password_field.Password == ConfirmPassword_field.Password)
     {
         if (!bll.IsSuchUserNameInDB(Login_field.Text))
         {
             LoginName = Login_field.Text;
             bll.AddNewUser(LoginName, Password_field.Password, City_combo.Text, Street_field.Text, Number_field.Text, "user");
             MessageBox.Show("New login was added.");
         }
         else
         {
             MessageBox.Show("Sorry, but such login has been added earlier. Choose other.");
         }
     }
     else
     {
         MessageBox.Show("Different Passwords");
     }
 }
 private void LoginWindow_btn_OK_Click(object sender, RoutedEventArgs e)
 {
     //DAL dal = new DAL();
     if (bll.IsSuchUserNameInDB(Login_field.Text))
     {
         //  var data = Encoding.ASCII.GetBytes(Password_field.Password);
         if (bll.IsValidPassword(Login_field.Text, Password_field.Password))
         {
             //login = bll.GetLoginWithName(Login_field.Text);
             IsSuccsesfullLogin = true;
             LoginName          = Login_field.Text;
             LoginStatusName    = bll.GetLoginStatusOfUser(LoginName);
             if (LoginStatusName == "user")
             {
                 string[] userAddress = bll.GetCityStreetAndNumberOfUser(LoginName);
                 City   = userAddress[0];
                 Street = userAddress[1];
                 Number = userAddress[2];
             }
             this.Close();
         }
         else
         {
             MessageBox.Show("Wrong login or password");
             IsSuccsesfullLogin = false;
         }
     }
     else
     {
         MessageBox.Show("Wrong login or password");
         IsSuccsesfullLogin = false;
     }
 }