Ejemplo n.º 1
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            while (attempt <= maxattempts)
            {
                if (TxtUser.Text != username)

                {
                    MessageBox.Show("invalid username," + (maxattempts - attempt) + "attempt remaining");
                    TxtUser.Clear();

                    attempt++;
                    return;
                }
                else
                {
                    if (TxtPassword.Text != "1234")
                    {
                        attempt++;
                        MessageBox.Show("incorrect password," + (maxattempts - attempt) + "attempt remaining");
                        TxtPassword.Clear();
                        return;
                    }
                    else
                    {
                        attempt = 0;
                        MessageBox.Show("Login successfull");
                        BtnLogin.Text = "Logout";
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void Login(string naam, string pass) // inlogknop
        {
            api  api       = new api();
            User loginUser = api.GetUser(naam, pass);

            if (loginUser.Name != null)
            {
                GlobalSettings.Id    = loginUser.Id;
                GlobalSettings.Naam  = loginUser.Name;
                GlobalSettings.Email = loginUser.Email;
                GlobalSettings.Pass  = loginUser.Password;

                char[] seperator = ".".ToCharArray();

                GlobalSettings.AllergieList = loginUser.allergies.Split(seperator).ToList();
                MainWindow.AppWindow.switchPage(2);
                MainWindow.AppWindow.EnableButtons();

                MainWindow.AppWindow.GetShoppinglist();
            }
            else
            {
                MessageBox.Show("Kan gebruiker niet vinden", "Error!", MessageBoxButton.OK);
                TxtUser.Clear();
                TxtPass.Clear();
            }
        }
Ejemplo n.º 3
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            if (TxtUser.Text == "firas")
            {
                if (TxtPass.Text == "1234")
                {
                    MessageBox.Show("Login Successful");
                }
                else
                {
                    MessageBox.Show("Incorrect Paasword");
                }
            }

            else
            {
                MessageBox.Show("Incorrect Username");
            }
            while (attempt <= MaxAttempts)
            {
                if (TxtUser.Text != username)
                {
                    // username is incorrect
                    MessageBox.Show("Invalid username, " + (MaxAttempts - attempt) + " attempts remaining");
                    attempt++;
                    TxtUser.Clear();
                    TxtPass.Clear();
                    return;
                }
                else
                {   // username is correct
                    // so check password
                    if (TxtPass.Text != "1234")
                    {
                        // Incorrect password
                        attempt++;
                        MessageBox.Show("Incorrect password," + (MaxAttempts - attempt) + " attempts remaining");
                        TxtUser.Clear();
                        TxtPass.Clear();
                        return;
                    }
                    else
                    {
                        //Both are correct
                        attempt = 0; // reset the number of attempts
                        MessageBox.Show("Login successful");
                        TxtUser.Clear();
                        TxtPass.Clear();



                        BtnLogin.Text = "Logout";

                        // this.Width = 1600;
                        break; // come out of while loop
                    }//endif
                }//endif
            }//end while
        }
        public void BtnLogin_Click(object sender, EventArgs e)
        {
            if (!loggedIn)
            {
                while (attempt <= MaxAttempts)
                {
                    if (TxtPw.Text != myPassword && TxtUser.Text != username)
                    {
                        MessageBox.Show("Incorrect login," + (MaxAttempts - attempt) + " attempts remaining");
                        attempt++;
                        return;
                    }
                    else if (TxtUser.Text != username)
                    {
                        // username is incorrect
                        MessageBox.Show("Invalid username, " + (MaxAttempts - attempt) + " attempts remaining");
                        attempt++;
                        return;
                    }
                    else
                    {   // username is correct
                        // so check password
                        if (TxtPw.Text != myPassword)
                        {
                            // Incorrect password
                            MessageBox.Show("Incorrect password," + (MaxAttempts - attempt) + " attempts remaining");
                            attempt++;
                            return;
                        }
                        else
                        {
                            //Both are correct
                            attempt = 1; // reset the number of attempts
                            MessageBox.Show("Login successful");
                            loggedIn = true;

                            BtnLogin.Text = "Logout";
                            // this.Width = 1600;
                            break; // come out of while loop
                        }//endif
                    }//endif
                }//end while
            }
            else
            {
                BtnLogin.Text = "Login";
                loggedIn      = false;

                TxtUser.Clear();
                TxtPw.Clear();
            }
        }
Ejemplo n.º 5
0
 private void BtnLimpia_Click(object sender, EventArgs e)
 {
     TxtApellido.Clear();
     TxtQueryID.Clear();
     MTxtCedula.Clear();
     TxtCodigo.Clear();
     TxtNombre.Clear();
     TxtUser.Clear();
     TxtQueryNombre.Clear();
     TxtTelefono.Clear();
     TxtUser.Clear();
     TxtConfirmar.Clear();
     TxtContrasena.Clear();
 }
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            if (!loggedin)
            {
                while (attempt <= MaxAttempts)
                {
                    if (TxtUser.Text != username)
                    {
                        // username is incorrect
                        MessageBox.Show("Invalid username, " + (MaxAttempts - attempt) + " attempts remaining");
                        attempt++;
                        TxtUser.Clear();
                        TxtPass.Clear();
                        return; // معناها عودة عشان يسجل دخول مرة ثانية. بدونها بيكمل البرنامج من نفسه ويرفض التسجيل
                    }

                    else
                    {   // username is correct
                        // so check password
                        if (TxtPass.Text != "1234")
                        {
                            // Incorrect password
                            MessageBox.Show("Incorrect password," + (MaxAttempts - attempt) + " attempts remaining");
                            attempt++;
                            TxtUser.Clear();
                            TxtPass.Clear();
                            return;
                        }
                        else
                        {
                            //Both are correct
                            attempt  = 0;    // reset the number of attempts
                            loggedin = true; // you dont have to declear the variable toice
                            MessageBox.Show(" Hi " + username + " your login successful ");
                            TxtUser.Clear();
                            TxtPass.Clear();


                            BtnLogin.Text = "Logout";
                            //toolStripStatusLabel1.Text = "You are logged in."; هذا مرحلة قادمة
                            // this.Width = 1600;
                            break; // come out of while loop
                        }//endif
                    }//endif
                }//end while
            }
        }
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            while (attempt <= maxattempts)
            {
                if (TxtUser.Text != username)



                { // username is incorrect
                    MessageBox.Show("invalid username," + (maxattempts - attempt) +
                                    "attempts remaining");
                    TxtUser.Clear();

                    attempt++;
                    return;
                }
                else
                {  // username is correct
                    // so check password
                    if (TxtPass.Text != "4724")
                    {
                        attempt++;
                        // incorrect password attempt++;
                        MessageBox.Show("incorrect password" + (maxattempts - attempt) +
                                        "attempts remaining");
                        TxtPass.Clear();

                        return;
                    }

                    else


                    {
                        // both are correct
                        attempt = 0; // reset the number of attempts
                        MessageBox.Show("Login Successfull");
                        BtnLogin.Text =
                            "Logout";

                        // this.width = 1600;
                        break; // come out of while loop
                    }// end if
                } // end if
            } // end while
        }
Ejemplo n.º 8
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            if (!loggedIn)
            {
                while (attempt <= MaxAttempts)
                {
                    if (TxtUser.Text != username)
                    {
                        MessageBox.Show("Invalid username, " + (MaxAttempts - attempt) + " attempts remaining");
                        attempt++;
                        return;
                    }
                    else
                    {
                        if (TxtPassword.Text != myPassword)
                        {
                            attempt++;
                            MessageBox.Show("Incorrect password," + (MaxAttempts - attempt) + " attempts remaining");
                            return;
                        }
                        else
                        {
                            attempt  = 1;
                            loggedIn = true;
                            MessageBox.Show("Hi " + username + ", your login successful");



                            BtnLogin.Text = "Logout";

                            break;
                        }
                    }
                }
            }
            else
            {
                BtnLogin.Text = "Login";

                loggedIn = false;

                TxtUser.Clear();
                TxtPassword.Clear();
            }
        }
Ejemplo n.º 9
0
 // Send server a login request containing user credentials
 private void BtnLogin_Click(object sender, EventArgs e)
 {
     // send a login request
     if (TxtUser.Text.Length > 3 && TxtPass.Text.Length > 3)
     {
         socket.Send(ASCIIEncoding.ASCII.GetBytes("[LOGIN_REQUEST]" + TxtUser.Text + "," + TxtPass.Text));
         // set local user/pass variables
         user = TxtUser.Text;
         pass = TxtPass.Text;
         // clear the textboxes
         TxtPass.Clear();
         TxtUser.Clear();
     }
     else
     {
         LblStatus.Text = "Please enter a valid user/pass.";
     }
 }
Ejemplo n.º 10
0
        private void Ingreso()
        {
            string consulta;

            consulta = "ValidarEntrada";
            SqlConnection getconexion = Conexion.Cnn();

            scmd = new SqlCommand(consulta, getconexion);
            scmd.Parameters.AddWithValue("@usu", TxtUser.Text);
            scmd.Parameters.AddWithValue("@pass", TxtPass.Text);
            scmd.CommandType = CommandType.StoredProcedure;
            scmd.ExecuteNonQuery();
            sread = scmd.ExecuteReader();
            if (sread.Read())
            {
                if (sread["Usuario"].ToString() == TxtUser.Text && sread["Pass"].ToString() == TxtPass.Text)
                {
                    Usuario.usuario = TxtUser.Text;
                    int valor = p.Preferencia(TxtUser.Text.Trim());

                    if (valor == 1)
                    {
                        MenuDIC m = new MenuDIC();
                        this.Hide();
                        m.ShowDialog();
                    }
                    else
                    {
                        MenuDOC call = new MenuDOC();
                        this.Hide();
                        call.ShowDialog();
                    }
                }
            }
            else
            {
                MessageBox.Show("Datos no coinciden", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtUser.Clear();
                TxtPass.Clear();
            }
            getconexion.Close();
        }
Ejemplo n.º 11
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (!loggedIn)
            {
                while (attempt <= MaxAttempts)
                {
                    if (TxtUser.Text != username)
                    {
                        MessageBox.Show("Invalid username, " + (MaxAttempts - attempt) + " attempts remaining");
                        attempt++;
                        return;
                    }
                    else
                    {
                        if (TxtPassword.Text != myPassword)
                        {
                            attempt++;
                            MessageBox.Show("Incorrect password," + (MaxAttempts - attempt) + " attempts remaining");
                            return;
                        }
                        else
                        {
                            attempt  = 1;
                            loggedIn = true;
                            MessageBox.Show("Hi " + username + ", your login successful");


                            foreach (var grp in groupBox1.Controls.OfType <GroupBox>())
                            {
                                foreach (var btn in grp.Controls.OfType <Button>())
                                {
                                    btn.Enabled   = true;
                                    btn.ForeColor = Color.Black;
                                }
                            }

                            btnLogin.Text = "Logout";
                            toolStripStatusLabel1.Text = "Hi " + username + ", you are logged in.";

                            break;
                        }
                    }
                }
            }
            else
            {
                btnLogin.Text = "Login";
                toolStripStatusLabel1.Text = "You are logged out.";
                loggedIn = false;

                TxtUser.Clear();
                TxtPassword.Clear();

                foreach (var grp in groupBox1.Controls.OfType <GroupBox>())
                {
                    foreach (var btn in grp.Controls.OfType <Button>())
                    {
                        btn.Enabled = false;
                    }
                }
            }
        }