private void button1_Click(object sender, EventArgs e) { DataTable datos = new DataTable(); datos = log.Logueo(TxtUsu.Text, TxtPass.Text); if (datos.Rows.Count > 0) { if (datos.Rows[0][2].ToString() == TxtUsu.Text && datos.Rows[0][3].ToString() == TxtPass.Text) { MessageBox.Show("Ingreso Correcto", "Inicio", MessageBoxButtons.OK, MessageBoxIcon.Information); Formularios.Main inicio = new Formularios.Main(); Main.idvende = datos.Rows[0][0].ToString(); Main.nombrev = datos.Rows[0][1].ToString(); Main.nivel = datos.Rows[0][4].ToString(); inicio.Show(); this.Close(); } else { MessageBox.Show("Usuario o contraseña incorrecta, intente de nuevo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtPass.Clear(); TxtUsu.Clear(); } } else { MessageBox.Show("Error de inicio de sesion", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); TxtPass.Clear(); TxtUsu.Clear(); } }
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(); } }
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 }
void Clear() { TxtId.Clear(); TxtNombre.Clear(); TxtApellido.Clear();; TxtEdad.Clear(); TxtPass.Clear(); }
void clear() { TxtId.Clear(); TxtNameUser.Clear(); TxtApellido.Clear(); TxtEdad.Clear(); TxtPass.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 }
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 (TxtPass.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(); TxtPass.Clear(); } }
// 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."; } }
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(); }
private void BtRegistrar_Click(object sender, EventArgs e) { try { if (TxtPass.Text == TxtUserName.Text) { MessageBox.Show("El usuario y al contraseña no pueden ser iguales"); TxtUserName.Clear(); TxtPass.Clear(); return; } DataBaseControl DBControl = new DataBaseControl(DataBaseControl.cPath, "ProjectDataBase.mdf"); string[] parameters = { "@userName", "@pass", "cat" }; string[] elements = { TxtUserName.Text, TxtPass.Text, CBCat.SelectedItem.ToString() }; if (DBControl.Insertar("insert into Users values(@userName,@pass,@cat)", parameters, elements)) { string[] para = { "@id" }; string[] val = { System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() }; int activos = int.Parse(DBControl.BuscarElemento("select [registros] from Activos where [ID] = @id", para, val)); para = new string[] { "@id", "@nums" }; string[] nums = { System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(), (++activos).ToString(), }; DBControl.Insertar("update [Activos] set [registros]=@nums where [id]=@id", para, nums); MessageBox.Show("Usuario agregado"); this.Close(); } else { MessageBox.Show("El usuario no pudo ser agregado"); } DBControl.Close(); } catch (Exception) { MessageBox.Show("Por favor, verifique los datos"); } }
private void limpiar() { TxtPass.Clear(); TxtUsu.Clear(); }
private void selection_changed(object sender, SelectionChangedEventArgs e) { TxtPass.Clear(); TxtPass.Focus(); }
/// <summary> /// método logout /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Logout(object sender, FormClosedEventArgs e) { TxtNombre.Clear(); TxtPass.Clear(); this.Show(); }
public void LimpiarTextBox() { TxtId.Clear(); TxtEmail.Clear(); TxtPass.Clear(); }