private void CmdRemoveUser_OnClick(object sender, RoutedEventArgs e) { TemplateMyUsersDataBase u = MainWindow.SqliteSource.GetUserEdit(TxtUser.Text); if (u == null) { return; } // check password if (TxtPw.Password != u.Password || TxtUser.Text != u.User || TxtOwner.Text != u.Owner && MainWindow.SqliteSource.CheckUserExist(TxtUser.Text)) { return; } MainWindow.SqliteSource.DeleteUser(TxtUser.Text); // refresh list user ListUserInDataBase(); // clear txt TxtUser.Text = string.Empty; TxtPw.Password = string.Empty; TxtOwner.Text = string.Empty; TxtUser.Focus(); this.ShowMessageAsync(@"Sucess", @"User deleted"); }
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; } } } }
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 CmdAddUser_OnClick(object sender, RoutedEventArgs e) { // check exist user if update TemplateMyUsersDataBase u = MainWindow.SqliteSource.GetUserEdit(TxtUser.Text); // existe usuario update if (TxtUser.Text != string.Empty && TxtPw.Password != string.Empty && MainWindow.SqliteSource.CheckUserExist(TxtUser.Text)) { if (TxtUser.Text != u.User || TxtPw.Password != u.Password || TxtOwner.Text != u.Owner) { // update algum valor alterado MainWindow.SqliteSource.UpdateUserIn(TxtUser.Text, TxtPw.Password, TxtOwner.Text, u.User); } } // cria novo usuario if (TxtUser.Text != string.Empty && TxtPw.Password != string.Empty && !MainWindow.SqliteSource.CheckUserExist(TxtUser.Text)) { MainWindow.SqliteSource.CreatUser(TxtUser.Text, TxtPw.Password, TxtOwner.Text); this.ShowMessageAsync(@"Sucess", @"User created"); } // refresh list user ListUserInDataBase(); // clear txt TxtUser.Text = string.Empty; TxtPw.Password = string.Empty; TxtOwner.Text = string.Empty; TxtUser.Focus(); }
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 }
private void BtnAceptar_Click(object sender, EventArgs e) { if (TxtUser.Text.IsNullOrEmpty() || TxtPWD.Text.IsNullOrEmpty()) { MessageBox.Show(@"Error, favor de capturar el usuario y/o contraseña"); TxtUser.Focus(); } else if (ValidaUsuario(TxtUser.Text, TxtPWD.Text)) { Hide(); } }
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(); } }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (TxtUser.Text == "" || TxtUser.Text == "User ID") { MessageBox.Show("Enter your User ID then Press Enter Key!", "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtUser.Focus(); } else { PasswordHint(); } panelHint.Visible = true; }
private void MnuItemClearAll_OnClick(object sender, RoutedEventArgs e) { MainWindow.SqliteSource.DeleteAllUsers(); // refresh list user ListUserInDataBase(); // clear txt TxtUser.Text = string.Empty; TxtPw.Password = string.Empty; TxtOwner.Text = string.Empty; TxtUser.Focus(); this.ShowMessageAsync(@"Sucess", @"deleted all"); }
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 }
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(); } }
// 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."; } }
public LoginControl(LoginLayer layer) { InitializeComponent(); Layer = layer; this.SkinLayer(Layer.LayerStyle); TxtUser.GotFocus += (o, e) => TxtUser.SelectAll(); if (layer.UsernameLabel != null) { LblUser.Text = layer.UsernameLabel; } if (layer.PasswordLabel != null) { LblPassword.Text = layer.PasswordLabel; } if (layer.DefaultUsername != null) { TxtUser.Text = layer.DefaultUsername; } if (!Layer.LayerStyle.ErrorTextColor.IsDefaultColor) { LblError.Foreground = Layer.LayerStyle.ErrorTextColor.GetBrush(); } if (Layer.BrandImage != null) { var brandImage = WpfFactory.LoadBitmap(Layer.BrandImage.Location); if (brandImage != null) { BrandImage.Source = brandImage; } } KeyUp += (o, e) => { if (e.Key == Key.Enter) { btnLogin_Click(o, e); } }; }
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 BtnIngresar_Click(object sender, EventArgs e) { try { string Ingreso = string.Format("Select * FROM analista WHERE usuariored='{0}' AND contraseña='{1}'", TxtUser.Text.Trim(), TxtPass.Text.Trim()); DataSet dataSet = Utilidades.EjecutarBd(Ingreso); string cuenta = dataSet.Tables[0].Rows[0]["usuariored"].ToString().Trim(); usuarioRed = cuenta; string password = dataSet.Tables[0].Rows[0]["contraseña"].ToString().Trim(); contraseñaUsuario = password; string usercode = dataSet.Tables[0].Rows[0]["id"].ToString().Trim(); idusuario = usercode; string nombre = dataSet.Tables[0].Rows[0]["nombre"].ToString().Trim(); nombreUsuario = nombre; string apellido = dataSet.Tables[0].Rows[0]["apellido"].ToString().Trim(); apellidoUsuario = apellido; if (cuenta == "admin" && TxtPass.Text == password) { this.Hide(); administrador NuevaVentana = new administrador(); NuevaVentana.Show(); } else if (TxtUser.Text == cuenta && TxtPass.Text == password) { this.Hide(); ConfigUsuario configuracionUser = new ConfigUsuario(); configuracionUser.Show(); } } catch { MessageBox.Show("No puedes ingresar, datos incorrectos"); TxtUser.Text = ""; TxtPass.Text = ""; TxtUser.Focus(); } }
//VALIDACION DE ACCESSO private void BtnLogin_Click(object sender, EventArgs e) { if (TxtUser.Text != "Username") { if (TxtUser.Text != "Username" && TxtUser.TextLength > 2) { if (TxtPass.Text != "Password") { var valirpass = TxtPass.Text; var valiruser = TxtUser.Text; if (valirpass == "admin" && valiruser == "lobo") { this.Hide(); Bienvenida welcome = new Bienvenida(); welcome.ShowDialog(); Menu abrir = new Menu(); abrir.Show(); abrir.FormClosed += Logout; } else { msgError("Incorrect username or password entered. \n Please try again."); TxtPass.Text = "Password"; TxtPass.UseSystemPasswordChar = false; TxtUser.Focus(); } } else { msgError("Please enter password."); } } else { msgError("Please enter username."); } } }
private void BtnLogin_Click(object sender, EventArgs e) { if (TxtUser.Text.Equals("Usuario") || TxtPassword.Text.Equals("Contraseña") || TxtUser.Text.Equals("") || TxtPassword.Text.Equals("")) { MessageBox.Show("Ingrese los Datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtUser.Focus(); } else { var usr = userService.ValidateUser(TxtUser.Text, TxtPassword.Text); if (usr != null) { MessageBox.Show("Usuario Logeado!", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information); FrmPrincipal principal = new FrmPrincipal(usr); principal.Show(); this.Hide(); } else { MessageBox.Show("Ingrese los Datos correctos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtUser.Focus(); } } }
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; } } } }
private void CmdLogin_Click(object sender, EventArgs e) { if (TxtUser.Text != "" && TxtPW.Text != "") { con.Open(); OleDbCommand cmd1 = new OleDbCommand("select * from UserDetails where UserID='" + TxtUser.Text.Trim() + "' ", con); cmd1.Connection = con; rdr = cmd1.ExecuteReader(); bool temp = false; while (rdr.Read()) { lblPW.Text = rdr["Password1"].ToString(); lblUser.Text = rdr["UserName"].ToString(); lblULevel.Text = rdr["UserLevel"].ToString(); lblPWHint.Text = rdr["PWHint"].ToString(); lblColor.Text = rdr["BGColor"].ToString(); temp = true; } con.Close(); if (temp == false) { MessageBox.Show("Please Enter the correct User ID, or Sign Up your details!", "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtUser.Text = ""; TxtPW.Text = ""; TxtUser.Focus(); return; } else { if (TxtPW.Text == lblPW.Text) { FrmLoad FLoad = new FrmLoad(); Control[] ctrlsID = FLoad.Controls.Find("lblUser", false); Label lbl1 = (Label)ctrlsID[0]; lbl1.Text = lblUser.Text; Control[] ctrlsUL = FLoad.Controls.Find("lblULevel", false); Label lbl2 = (Label)ctrlsUL[0]; lbl2.Text = lblULevel.Text; Control[] ctrlsIDD = FLoad.Controls.Find("lblID", false); Label lbl3 = (Label)ctrlsIDD[0]; lbl3.Text = TxtUser.Text; Control[] ctrlsPW = FLoad.Controls.Find("lblPW", false); Label lbl4 = (Label)ctrlsPW[0]; lbl4.Text = TxtPW.Text; Control[] ctrlsPWh = FLoad.Controls.Find("lblPWHint", false); Label lbl5 = (Label)ctrlsPWh[0]; lbl5.Text = lblPWHint.Text; Control[] ctrlsClr = FLoad.Controls.Find("lblColor", false); Label lbl6 = (Label)ctrlsClr[0]; lbl6.Text = lblColor.Text; this.Visible = false; FLoad.Show(); return; } else { MessageBox.Show("Please Enter the Valied Password!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtPW.Text = ""; TxtPW.Focus(); return; } } } else { MessageBox.Show("Please Enter the Valied User ID and Password!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtUser.Text = ""; TxtPW.Text = ""; TxtUser.Focus(); return; } }