private void Add(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TbLogin.Text))
     {
         MB.MessageBoxInfo("Введите логин");
         TbLogin.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbPassword.Text))
     {
         MB.MessageBoxInfo("Введите пароль");
         TbPassword.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbRole.Text))
     {
         MB.MessageBoxInfo("Выберите роль");
         CbRole.Focus();
     }
     else
     {
         try
         {
             DataService.GetContext().User.Add(user);
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo("Пользователь успешно добавлен");
         }
         catch
         {
             MB.MessageBoxError("Ошибка подключения к базе данных");
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Metoda przycisku Cofnij. Metoda usuwa jeden znak z TbLogin.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BCofnij_Click(object sender, RoutedEventArgs e)
        {
            int    ile    = TbLogin.GetLineLength(0);
            int    ile1   = ile - 1;
            string tekst  = TbLogin.Text;
            string tekst1 = tekst.Remove(ile1, 1);

            TbLogin.Text = tekst1;
        }
Пример #3
0
 public void LogIn(string login, string password)
 {
     _driver.Navigate().GoToUrl(StringHelper.LogInPageUrl);
     TbLogin.Clear();
     TbLogin.SendKeys(login);
     TbPassword.Clear();
     TbPassword.SendKeys(password);
     BtnZaloguj.Click();
 }
Пример #4
0
        /// <summary>
        /// Metoda przycisku Zaloguj.Sprawdza podane wartości TbLogin i PbHasło z danymi zawartymi w bazie danaych [Numer Karty == Login i Pin == Hasło]
        /// oraz wartość zmiennej karta , jeśli podane dane są prawdziwe i wartość karta = true to pokazuje komunikat logowanie udane i wywołuje nowe okno
        /// jeśli któryś z warunków jest niepoprawny pokazuje się komunikat informujący o błędnym logowaniu jeśli niepoprawne logowanie powtarza się 3 razy
        /// to zarówno TbLogin jak i PbHasło zostają zablokowane.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BZaloguj_Click(object sender, RoutedEventArgs e)
        {
            string Login = TbLogin.Text;
            string Hasło = PbHasło.Password;

            SqlDataReader sprawdz = null;


            string        connectionString = @"Data source=.\SQLExpress;database=BazaBankomat;Trusted_Connection=True";
            SqlConnection connection       = new SqlConnection(connectionString);

            connection.Open();

            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandType = CommandType.Text;



            string commandText = "Select * From[Dane Logowania] Where[Numer Karty]='" + Login + "' And Pin ='" + Hasło + "'";


            command.CommandText = commandText;
            sprawdz             = command.ExecuteReader();

            if (sprawdz.HasRows == true && karta == true)
            {
                MessageBox.Show("Logowanie udane");

                Okno pokaż = new Okno();
                pokaż.Show();
                this.Close();
            }
            else
            {
                liczLogowania++;
                int próba = 3;
                próba = próba - liczLogowania;
                MessageBox.Show("Logowanie nieudane.  Zostało prób : " + próba + "\nPo 3 nieudanych próbach możliwość logowania zostaje zablokowana.");
            }

            connection.Close();

            if (liczLogowania >= 3)
            {
                TbLogin.Clear();
                TbLogin.IsReadOnly = true;
                TbLogin.IsEnabled  = false;
                PbHasło.Clear();
                PbHasło.IsEnabled = false;
            }
        }
Пример #5
0
        /// <summary>
        /// Metoda przycisku Zaloguj.Sprawdza wartości wpisane w textboxie i passwordboxie z danymi w bazie danych jeśli są poprawne otwiera nowe okno WybórPoczty
        /// A przy 3 błędnych logowaniach blokuje textboxa i possword boxa.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BLogin_Click(object sender, RoutedEventArgs e)
        {
            string Login = TbLogin.Text;
            string Hasło = PbHasło.Password;

            SqlDataReader sprawdz = null;


            string        connectionString = @"Data source=.\SQLExpress;database=BazaPoczta;Trusted_Connection=True";
            SqlConnection connection       = new SqlConnection(connectionString);

            connection.Open();

            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandType = CommandType.Text;



            string commandText = "Select * From Logowanie Where Login ='******' And Hasło ='" + Hasło + "'";

            command.CommandText = commandText;
            sprawdz             = command.ExecuteReader();

            if (sprawdz.HasRows == true)
            {
                //MessageBox.Show("Logowanie udane");

                WybórPoczty pokaż = new WybórPoczty();
                pokaż.Show();
                this.Close();
            }
            else
            {
                int próba = 3;
                próba = próba - liczLogowania;
                liczLogowania++;
                MessageBox.Show("Logowanie nieudane.Zostało prób = " + próba);
            }

            connection.Close();

            if (liczLogowania >= 3)
            {
                TbLogin.Clear();
                TbLogin.IsReadOnly = true;
                TbLogin.IsEnabled  = false;
                PbHasło.Clear();
                PbHasło.IsEnabled = false;
            }
        }
Пример #6
0
        public string Login(string login, string senha)
        {
            TbLogin usuario = db.Login(login, senha);

            if (usuario == null)
            {
                throw new ArgumentException("Credenciais inválidas.");
            }

            string token = tokenManager.CriarToken(usuario.IdLogin);

            return(token);
        }
Пример #7
0
 private void BtnNext_Click(object sender, RoutedEventArgs e)
 {
     if (TbLogin.Text == RandomClass.Saver)
     {
         ActionWindowClass.MainFrame.NavigationService.RemoveBackEntry();
         ActionWindowClass.MainFrame.Navigate(new PageChangePassword());
     }
     else
     {
         TbLogin.BorderBrush = Brushes.OrangeRed;
         TbLogin.Clear();
     }
 }
Пример #8
0
        public async Task <IActionResult> Create(TbLogin login)
        {
            if (ModelState.IsValid)
            {
                login.Senha = Modulo.GerarHashMd5(login.Senha);

                _context.Add(login);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "TbNoticias"));
            }

            return(View(login));
        }
Пример #9
0
        /// <summary>
        /// Metoda dla przycisków numerycznych. Wysyła nazwę buttona do TbLogin oraz ustawia maksymalną długość TbLogin na 16 znaków a PbHasło na 4 znaki.
        /// </summary>
        /// <param name="sender"></param>
        public void Button(object sender)
        {
            TbLogin.MaxLength = 16;
            PbHasło.MaxLength = 4;
            int ilośćznakówtb = TbLogin.GetLineLength(0);

            Button obutton = (Button)sender;

            if (ilośćznakówtb <= 16)
            {
                TbLogin.Text += obutton.Content;
            }
            else
            {
                PbHasło.Password += obutton.Content;
            }
        }
Пример #10
0
        public IActionResult Logar(TbLogin login)
        {
            if (ModelState.IsValid)
            {
                login.Senha = Modulo.GerarHashMd5(login.Senha);

                var User = _context.TbLogin.Where(W => W.Username == login.Username && W.Senha == login.Senha);
                if (User.Any())
                {
                    Modulo._login = User.FirstOrDefault();
                    return(RedirectToAction("Index", "TbNoticias"));
                }
                else
                {
                    ModelState.AddModelError("Senha", "Usuario ou Senha Inválido!");
                    Modulo._login = null;
                }
            }

            return(View(login));
        }
Пример #11
0
        private void ListaUtenze_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            TbLogin temp   = new TbLogin();
            var     i      = e.Item as Utente;
            var     utenza = LoginData.getUser();

            foreach (var z in utenza)
            {
                z.attivo = false;
                LoginData.updateUser(z);
            }
            temp.id             = i.id;
            temp.username       = i.username;
            temp.password       = i.password;
            temp.splash_logo    = i.splash_logo;
            temp.circle_logo    = i.circle_logo;
            temp.token          = i.token;
            temp.organizzazione = i.organizzazione;
            temp.attivo         = true;
            LoginData.updateUser(temp);
            App.Current.MainPage = new NavigationPage(new MainPage());
        }
        private async Task check()
        {
            var    utente = LoginData.getUser();
            Utente user   = new Utente();

            foreach (var i in utente)
            {
                if (i.attivo)
                {
                    user.id             = i.id;
                    user.attivo         = i.attivo;
                    user.username       = i.username;
                    user.password       = i.password;
                    user.token          = i.token;
                    user.organizzazione = i.organizzazione;
                    user.eliminato      = "false";
                    user.splash_logo    = i.splash_logo;
                    user.circle_logo    = i.circle_logo;
                }
            }
            if (string.IsNullOrEmpty(user.username))
            {
                user.id             = utente[0].id;
                user.attivo         = true;
                user.username       = utente[0].username;
                user.password       = utente[0].password;
                user.token          = utente[0].token;
                user.organizzazione = utente[0].organizzazione;
                user.splash_logo    = utente[0].splash_logo;
                user.circle_logo    = utente[0].circle_logo;
                user.eliminato      = "false";
            }
            REST <Utente, Final> rest = new REST <Utente, Final>();

            if (CrossConnectivity.Current.IsConnected)
            {
                var response = await rest.PostJson(URL.Login, user);

                if (response != null)
                {
                    if (response.status)
                    {
                        if (response.final[0].attivo == false)
                        {
                            await App.Current.MainPage.DisplayAlert("Login", "Utenza non attiva", "OK");

                            LoginData.dropUser(new TbLogin(user.username, user.password, user.token, user.organizzazione, user.circle_logo, user.splash_logo, true));
                            UtenzaData.DropUser(new TbUtente(response.final[0]));
                            App.Current.MainPage = new Login();
                        }
                        else
                        {
                            //await App.Current.MainPage.DisplayAlert("Login", "Login Effettuata con successo", "OK");
                            response.final[0].organizzazione = user.organizzazione;
                            foreach (var i in utente)
                            {
                                i.attivo = false;
                                LoginData.updateUser(i);
                            }
                            TbLogin us = new TbLogin(user.username, user.password, user.token, user.organizzazione, user.circle_logo, user.splash_logo, user.attivo);
                            us.id     = user.id;
                            us.attivo = true;
                            LoginData.updateUser(us);
                            UtenzaData.UpdateUser(new TbUtente(response.final[0]));
                        }
                    }
                    else
                    {
                        LoginData.dropUser(new TbLogin(user.username, user.password, user.token, user.organizzazione, user.circle_logo, user.splash_logo, true));
                        UtenzaData.DropUser(new TbUtente(response.final[0]));
                        App.Current.MainPage = new NavigationPage(new Login());
                    }
                }
                else
                {
                    await DisplayAlert("Attenzione", "Il servizio è momentaneamente non disponibile, riprova più tardi",
                                       "OK");
                    await check();
                }
            }
        }
Пример #13
0
        private void BtnJoin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(TbLogin.Text))
                {
                    Runtb.Text = null;
                    Runtb2.Inlines.Clear();
                    Runtb.Text += "Вы не ввели логин.";
                    Runtb2.Inlines.Add("Забыли пароль?");
                    TbLogin.BorderBrush    = Brushes.OrangeRed;
                    PBPassword.BorderBrush = Brushes.OrangeRed;
                    TbLogin.Clear();
                    PBPassword.Clear();
                }
                else if (string.IsNullOrWhiteSpace(PBPassword.Password))
                {
                    Runtb.Text = null;
                    Runtb2.Inlines.Clear();
                    Runtb.Text += "Вы не ввели пароль.";
                    Runtb2.Inlines.Add("Забыли пароль?");
                    PBPassword.BorderBrush = Brushes.OrangeRed;
                }
                else
                {
                    var user = DataClass.GetContext().User.FirstOrDefault(u => u.Login == TbLogin.Text);
                    if ((user == null) || (user.Password != PBPassword.Password))
                    {
                        Runtb.Text = null;
                        Runtb2.Inlines.Clear();
                        Runtb.Text += "Вы ввели неверный логин или пароль.";
                        Runtb2.Inlines.Add("Забыли пароль?");
                        TbLogin.BorderBrush    = Brushes.OrangeRed;
                        PBPassword.BorderBrush = Brushes.OrangeRed;
                        TbLogin.Clear();
                        PBPassword.Clear();
                    }
                    else
                    {
                        switch (user.IdRole)
                        {
                        case 1:
                            ActionWindowClass.staffUser = DataClass.GetContext().Staff.FirstOrDefault(s => s.IdUser == user.Id);
                            new WinAdmin().Show();
                            winAuth.Close();

                            break;

                        case 2:
                            ActionWindowClass.staffUser = DataClass.GetContext().Staff.FirstOrDefault(s => s.IdUser == user.Id);
                            new WinManager().Show();
                            winAuth.Close();

                            break;

                        case 3:
                            ActionWindowClass.staffUser = DataClass.GetContext().Staff.FirstOrDefault(s => s.IdUser == user.Id);
                            new WinStaff().Show();
                            winAuth.Close();

                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #14
0
        private void SignIn(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TbLogin.Text))
            {
                MB.MessageBoxInfo("Введите логин");
                TbLogin.Focus();
            }
            else if (string.IsNullOrWhiteSpace(PbPassword.Password))
            {
                MB.MessageBoxInfo("Введите пароль");
                PbPassword.Focus();
            }
            else
            {
                var employee = DataService.GetContext().Employee.FirstOrDefault(u => u.User.Login == TbLogin.Text);

                if (employee == null)
                {
                    MB.MessageBoxInfo("Введен неверно логин/пароль");
                    TbLogin.Focus();
                    count++;
                }
                else
                {
                    if (employee.User.Password != PbPassword.Password)
                    {
                        MB.MessageBoxInfo("Введен неверно логин/пароль");
                        TbLogin.Clear();
                        PbPassword.Clear();
                        count++;
                    }
                    else
                    {
                        Entity.CurrentEmployee = employee;
                        switch (employee.User.IdRole)
                        {
                        case 1:
                            new WinManager().Show();
                            this.Close();
                            break;

                        case 2:
                            new WinEmployee().Show();
                            this.Close();
                            break;

                        case 3:
                            new WinAdmin().Show();
                            this.Close();
                            break;
                        }
                        count = 0;
                    }
                }
                if (count >= 3)
                {
                    TbLogin.Text           = string.Empty;
                    PbPassword.Password    = string.Empty;
                    GridSignIn.Visibility  = Visibility.Hidden;
                    GridCaptcha.Visibility = Visibility.Visible;
                    TbCaptcha.Text         = Captcha.GenerateString(5);
                    return;
                }
            }
        }
Пример #15
0
 public static int updateUser(TbLogin user)
 {
     return(Database.Connection.Update(user));
 }
Пример #16
0
 public static int InsertUser(TbLogin user)
 {
     return(Database.Connection.Insert(user));
 }
Пример #17
0
 public static int dropUser(TbLogin user)
 {
     return(Database.Connection.Delete(user));
 }