Exemplo n.º 1
0
 public void newUSer()
 {
     if (Login1 != null && Pass1 != null)
     {
         UserSet user = new UserSet();
         user.login       = Login1;
         user.password    = Pass1;
         user.IsSuperUser = Sadmin1;
         user.SUperMdp    = Pass1;
         user.profile     = UTOI(Profile1);
         try
         {
             ctx.UserSets.Add(user);
             ctx.SaveChanges();
             RaisePropertyChanged("Uers1");
             MessageBox.Show("User " + user.login + "Create");
         }
         catch (Exception e)
         {
             MessageBox.Show("DataBase Connection Error");
         }
     }
     else
     {
         MessageBox.Show("All entries must be filled");
     }
 }
        public int Roles(UserSet u)
        {
            switch (u.profile)
            {
            case 1: return(1);

            case 2: return(2);

            case 3: return(3);

            default: return(4);
            }
        }
 public void connect()
 {
     if (pass != null && name != null)
     {
         UserSet USER = new UserSet();
         USER = ctx.UserSets.SingleOrDefault(u => u.login == name);
         if (USER != null)
         {
             if (USER.password == pass && (Roles(USER) == 1 || Roles(USER) == 2 || Roles(USER) == 3))
             {
                 acceuil acceuil = new acceuil(USER.profile);
                 acceuil.Show();
                 ThisWindow.Close();
                 MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(acceuil) as MahApps.Metro.Controls.MetroWindow;
                 if (window != null)
                 {
                     DateTime dt = DateTime.Today;
                     string   mt = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(dt.Month);
                     window.ShowMessageAsync("Hello " + USER.login, "It is ' " + dt.DayOfWeek + " the " + dt.Day + " of " + mt + " '. ");
                 }
             }
             else
             {
                 MessageBox.Show("Wrong Pass! Please verify");
             }
         }
         else
         {
             MessageBox.Show("User Doesn't Exist ! Please verify");
         }
     }
     else
     {
         MessageBox.Show("Wrong UserName! Please verify");
     }
 }