Exemplo n.º 1
0
 private bool CheckUserName()
 {
     try
     {
         using (DBBL data = new DBBL())
         {
             ccounter = data.CheckUsernameValue(tboxUsername.Text, tboxPassword.Text);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
     }
     if (ccounter == 0)
     {
         AttemptCounter = AttemptCounter + 1;
         if (AttemptCounter > 5)
         {
             Application.Exit();
             return(false);
         }
         else
         {
             WrongUsernameLabel.Text    = "Pristup odbijen. Ovo je Vaš " + AttemptCounter + ". pokušaj.";
             WrongUsernameLabel.Visible = true;
             WrongUsernameLabel.Refresh();
             return(false);
         }
     }
     else
     {
         try
         {
             using (DBBL data = new DBBL())
             {
                 User k = data.getKorisnikByParameter(tboxUsername.Text, tboxPassword.Text);
                 Session.LoggedInUser = k;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         return(true);
     }
 }