예제 #1
0
 public static string check_login(string user_name, string password, ref log_status log_status)
 {
     using (ECOS_Context database = new ECOS_Context())
     {
         password = password == null ? "" : password;
         var user = database.Logins.SingleOrDefault(u => (u.User_name == user_name));
         if (user == null)
         {
             log_status = log_status.wrong_user;
             return(null);
         }
         else if (MD5Hash(password) != user.Password)
         {
             log_status = log_status.wrong_pass;
             return(null);
         }
         else if (user.IsEnable == false)
         {
             log_status = log_status.disable;
             return(null);
         }
         log_status = log_status.correct;
         return(user.Role);
     }
 }
예제 #2
0
        public static void Show_login_status(string role, log_status status)
        {
            switch (status)
            {
                case log_status.wrong_user:
                    MessageBox.Show("The given user name does not exist", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                    break;

                case log_status.wrong_pass:
                    MessageBox.Show("The specified password is incorrect", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                    break;
                case log_status.disable:
                    MessageBox.Show("Acces to your account was disable", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                    break;
                case log_status.correct:

                    switch (role)
                    {
                        case "ADM":
                            ChooseEditItemView EditView = new ChooseEditItemView();
                            Application.Current.MainWindow = EditView;
                            EditView.ShowDialog();
                   
                            break;
                    }
                    //    case "PRAC":
                    //        this.Visible = false;
                    //        WorkerForm WorkerForm = new WorkerForm((int)user.WORKER_ID);
                    //        WorkerForm.ShowDialog();
                    //        this.Close();
                    //        break;
                    //    case "STUD":
                    //        this.Visible = false;
                    //        StudentForm StudentForm = new StudentForm((int)user.ALBUM_NUMBER);
                    //        StudentForm.ShowDialog();
                    //        this.Close();
                    //        break;
                    //    default:

                    break;
            }
        }