Пример #1
0
 private void GetUser()
 {
     try
     {
         XDocument doc = XDocument.Load(@"Resources\RestUsr.xml");
         user = eFUser.GetUserByLogin(doc.Root.Attribute("login").Value);
         if (user.Login == null)
         {
             GetUser();
         }
     }
     catch (NullReferenceException) { IsICanWork = false; }
     catch (System.Data.DataException) { IsICanWork = false; }
 }
 public bool Registration(string password1, string password2)
 {
     Reg_Password = password1;
     Db_Password  = password2;
     if (!String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Reg_Login) && !String.IsNullOrEmpty(Reg_Password) && !String.IsNullOrEmpty(Db_Password))
     {
         if (Group >= 1 && Group <= 10)
         {
             if (Course >= 1 && Course <= 5)
             {
                 if (Subgroup == 1 || Subgroup == 2)
                 {
                     if (NumStudCard.ToString().Length == 8)
                     {
                         if (password1.Equals(password2))
                         {
                             User    tmp1 = eFUser.GetUserByLogin(Reg_Login);
                             Student tmp2 = eFStudent.GetStudentById(NumStudCard);
                             if (tmp2 == null)
                             {
                                 if (tmp1 == null)
                                 {
                                     Model.Group tmp = eFGroup.GetGroup(Group, Course, Subgroup);
                                     if (tmp == null)
                                     {
                                         eFGroup.addGroup(new Model.Group(Group, Course, Subgroup));
                                     }
                                     eFStudent.addStudent(new Student(NumStudCard, eFGroup.GetGroup(Group, Course, Subgroup).idGroup, Name));
                                     eFUser.addUser(new User(NumStudCard, Reg_Login, User.getHash(Reg_Password)));
                                     eFUser.Save();
                                     return(true);
                                 }
                                 else
                                 {
                                     MyMessageBox.Show("User with this login already exists!", MessageBoxButton.OK);
                                     return(false);
                                 }
                             }
                             else
                             {
                                 MyMessageBox.Show("A user with that student card number is already there!", MessageBoxButton.OK);
                                 return(false);
                             }
                         }
                         else
                         {
                             MyMessageBox.Show("Passwords must match!", MessageBoxButton.OK);
                             return(false);
                         }
                     }
                     else
                     {
                         MyMessageBox.Show("Student card number must contain 8 digits!", MessageBoxButton.OK);
                         return(false);
                     }
                 }
                 else
                 {
                     MyMessageBox.Show("Subgroup must be 1 or 2!", MessageBoxButton.OK);
                     return(false);
                 }
             }
             else
             {
                 MyMessageBox.Show("Course must be 1-5!", MessageBoxButton.OK);
                 return(false);
             }
         }
         else
         {
             MyMessageBox.Show("Group must be 1-10!", MessageBoxButton.OK);
             return(false);
         }
     }
     else
     {
         MyMessageBox.Show("Check entered data!", MessageBoxButton.OK);
         return(false);
     }
 }