//Connecter private void button2_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(IpBox.Text)) { hostname = IpBox.Text.ToString(); } if (!String.IsNullOrEmpty(PortBox.Text)) { port = Convert.ToInt32(PortBox.Text); } if (!String.IsNullOrEmpty(PassBox.Text)) { password = Convert.ToString(PassBox.ToString()); } if (checkBox1.Checked && firspass) { param.UsePasswordAuthentication(password); firspass = false; } bool retry = true; while (retry) { try { ConnectToIED.Connect(hostname, port); Disconnect_button.Enabled = true; Connect_button.Enabled = false; Exit_button.Enabled = false; CreateButton.Enabled = true; Get_reports.Enabled = true; IpBox.Clear(); PortBox.Clear(); PassBox.Clear(); retry = false; toolStatus.Text = "Connected"; IEDConnected = true; int i = 1; for (i = 1; i < 65; i++) { refer.Add("GEDeviceF650/vinGGIO1.SPCSO" + i.ToString() + ""); control.Add(ConnectToIED.CreateControlObject(refer[i - 1])); } } catch (IedConnectionException ex) { IEDConnected = false; toolStatus.Text = "Failed to connect"; if (MessageBox.Show(ex.Message + "for the following reason" + ex.GetIedClientError(), "Erreur", MessageBoxButtons.RetryCancel) == DialogResult.Cancel) { retry = false; } else { retry = true; } } } }
private async void SaveProfileButton_Click(object sender, EventArgs e) { if (sqlConnection.State.ToString() == "Closed") { await sqlConnection.OpenAsync(); } SqlCommand updatecom = new SqlCommand("UPDATE [Users] SET [FIO]=@FIO, [Phone]=@Phone, [Email]=@Email WHERE [Nickname]=@Nickname", sqlConnection); updatecom.Parameters.AddWithValue("Nickname", NickBox.Text); updatecom.Parameters.AddWithValue("FIO", FIOBox.Text); updatecom.Parameters.AddWithValue("Phone", PhoneBox.Text); updatecom.Parameters.AddWithValue("Email", EmailBox.Text); await updatecom.ExecuteNonQueryAsync(); if (!string.IsNullOrWhiteSpace(PassBox.Text)) { SqlCommand passupdate = new SqlCommand("Update [Users] SET [Password]=@Password Where [Nickname] = @Nickname", sqlConnection); passupdate.Parameters.AddWithValue("Nickname", NickBox.Text); passupdate.Parameters.Add("@Password", SqlDbType.NVarChar).Value = PassBox.Text; //Просто еще один способ добавления await passupdate.ExecuteNonQueryAsync(); } sqlConnection.Close(); ChangeProfileButton.Enabled = true; SaveProfileButton.Enabled = false; DiscardChangesProfile.Enabled = false; FIOBox.Enabled = false; PhoneBox.Enabled = false; EmailBox.Enabled = false; PassBox.Enabled = false; OrderButton.Enabled = true; PassBox.Clear(); }
private void button1_Click(object sender, EventArgs e) { int id = Convert.ToInt32(IdBox.Text); string name = NameBox.Text; int Phon = Convert.ToInt32(PhonBox.Text); string payment = PaymentBox.Text; string pass = PassBox.Text; int paid = Convert.ToInt32(PaidBox.Text); string package = PackageBox.Text; int due = Convert.ToInt32(DueBox.Text); string validity = ValidityBox.Text; MemRegDAO b = new MemRegDAO(); b.createMember(new MemRegDTO(id, pass, name, Phon, payment, package, paid, due, validity)); LoadCustomersInfo(); IdBox.Clear(); PassBox.Clear(); NameBox.Clear(); PhonBox.Clear(); PaymentBox.Clear(); PaidBox.Clear(); DueBox.Clear(); ValidityBox.Clear(); }
void HidePassword() { ImgShowHide.Source = new BitmapImage(new Uri("/Resources/openeye.png", UriKind.Relative)); PassBoxSec.Visibility = Visibility.Hidden; PassBox.Visibility = Visibility.Visible; PassBox.Focus(); }
private void PassBox_GotFocus(object sender, EventArgs e) { if (PassBox.Text == "Password") { PassBox.Clear(); } }
private void button1_Click(object sender, EventArgs e) { int employeeid = Convert.ToInt32(IdBox.Text); string name = NameBox.Text; int Phone = Convert.ToInt32(PhoneBox.Text); string joinigdate = JoinBox.Text; string pass = PassBox.Text; int salary = Convert.ToInt32(SalaryBox.Text); // string package = PackageBox.Text; // int due = Convert.ToInt32(DueBox.Text); string position = PsitionBox.Text; EmployeeDAO b = new EmployeeDAO(); b.createEmployee(new EmployeeDTO(name, employeeid, pass, Phone, joinigdate, position, salary)); loademployee(); IdBox.Clear(); PassBox.Clear(); NameBox.Clear(); PhoneBox.Clear(); JoinBox.Clear(); PsitionBox.Clear(); SalaryBox.Clear(); }
private async void DiscardChangesProfile_Click(object sender, EventArgs e) { if (sqlConnection.State.ToString() == "Closed") { await sqlConnection.OpenAsync(); } reader = null; commandnick = new SqlCommand("Select * from [Users] where [Nickname] = @Nickname", sqlConnection); commandnick.Parameters.AddWithValue("Nickname", NickBox.Text); reader = commandnick.ExecuteReader(); await reader.ReadAsync(); FIOBox.Text = reader["FIO"].ToString(); PhoneBox.Text = reader["Phone"].ToString(); EmailBox.Text = reader["Email"].ToString(); reader.Close(); sqlConnection.Close(); ChangeProfileButton.Enabled = true; SaveProfileButton.Enabled = false; DiscardChangesProfile.Enabled = false; FIOBox.Enabled = false; PhoneBox.Enabled = false; EmailBox.Enabled = false; PassBox.Enabled = false; OrderButton.Enabled = true; PassBox.Clear(); }
private void UserTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { PassBox.Focus(); e.Handled = true; } }
private void ClearBoxes() { RegNumBox.Clear(); NameBox.Clear(); SurnameBox.Clear(); EmailBox.Clear(); PassBox.Clear(); CourseTitleBox.Clear(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (Password) { PassBox.Focus(); } else { TextBox.Focus(); } }
//utilisation de mot de passe private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (!checkBox1.Checked) { label5.Hide(); PassBox.Hide(); } else { label5.Show(); PassBox.Show(); } }
private void ShowPasswordButton_Click(object sender, RoutedEventArgs e) { //Toggle the password visible flag passwordIsVisible = !passwordIsVisible; if (passwordIsVisible) { PassBox.Visibility = Visibility.Hidden; PassTextBox.Visibility = Visibility.Visible; PassTextBox.Focus(); PassTextBox.Select(PassTextBox.Text.Length, 0); } else { PassBox.Visibility = Visibility.Visible; PassTextBox.Visibility = Visibility.Hidden; PassBox.Focus(); } }
private void LoginButton_Click(object sender, EventArgs e) { ErrorLabel.Visible = false; String Login = LoginBox.Text; String Password = PassBox.Text; if (Login.Length == 0 || Password.Length == 0) { ErrorLabel.Text = "Введите логин и/или пароль"; ErrorLabel.Visible = true; PassBox.Clear(); return; } Dictionary <string, string> Args = new Dictionary <string, string>(); Args["TYPE"] = "login"; Args["LOGIN"] = Login; Args["PASSWORD"] = Password; Loop.AddTask("SendToServer", Args); }
private void EditDelUsersMnBtn_Click(object sender, EventArgs e) { CourseGroupBox.Hide(); CoursesList.Hide(); PassBox.Hide(); PassLabel.Hide(); AssignMsgLabel.Hide(); AssignCourseBtn.Hide(); HideAllErrors(); CancelUsersBtn.Hide(); CancelCoursesBtn.Hide(); ClearBoxes(); UsersList.Enabled = true; CoursesList.Enabled = true; RegNumBox.Enabled = false; UserGroupBox.Show(); UsersList.Show(); this.UserGroupBox.Location = new Point(550, 12); this.UsersList.Location = new Point(150, 12); ChangeMsgLabel("Edit", "Users"); CreateEditUserBtn.Text = "Submit"; }
private void Reset() { if (tries > 0) { tries--; Login(user, pass); return; } foreach (var obj in AccountList.Children) { if (obj is LoginAccount) { ((LoginAccount)obj).State = LoginAccountState.Normal; } } Progress.Visibility = Visibility.Hidden; LoginBar.IsIndeterminate = false; PassBox.Password = ""; LoginButt.IsEnabled = UserBox.IsEnabled = PassBox.IsEnabled = AutoLoginToggle.IsEnabled = true; PassBox.Focus(); }
private void CheckBox_Changed(object sender, RoutedEventArgs e) { //TODO: Make undermentioned, commented line of code work or inspect what's wrong with it //PassBox.PasswordChar = CheckBox.IsChecked == true ? default(char): '*'; if (CheckBox.IsChecked == true) { PassBox.Visibility = Visibility.Hidden; PassBox.IsEnabled = false; TxtPassBox.IsEnabled = true; TxtPassBox.Text = PassBox.Password; TxtPassBox.Focus(); TxtPassBox.Visibility = Visibility.Visible; } else { TxtPassBox.Visibility = Visibility.Hidden; TxtPassBox.IsEnabled = false; PassBox.IsEnabled = true; PassBox.Password = TxtPassBox.Text; PassBox.Focus(); PassBox.Visibility = Visibility.Visible; } }
private void CreateUserMenuBtn_Click(object sender, EventArgs e) { CourseGroupBox.Hide(); UsersList.Hide(); CoursesList.Hide(); AssignMsgLabel.Hide(); AssignCourseBtn.Hide(); CancelUsersBtn.Hide(); CancelCoursesBtn.Hide(); HideAllErrors(); ChangeMsgLabel("Create", "Users"); ClearBoxes(); UsersList.Enabled = true; CoursesList.Enabled = true; RegNumBox.Enabled = true; PassBox.Show(); PassLabel.Show(); UserGroupBox.Show(); UserGroupBox.Left = (this.ClientSize.Width - UserGroupBox.Width + 100) / 2; UserGroupBox.Top = (this.ClientSize.Height - UserGroupBox.Height - 100) / 2; CreateEditUserBtn.Text = "Create"; }
private void LoginButton_Click(object sender, RoutedEventArgs e) { if (LoginBox.Text != "" && PassBox.Password != "") { bool isAdmin = false; var hash = ""; var hashfromsql = ""; using (var md5Hash = MD5.Create()) { var data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(PassBox.Password)); var sBuilder = new StringBuilder(); foreach (var item in data) { sBuilder.Append(item.ToString("x2")); } hash = sBuilder.ToString(); } try { using (var con = new SqlConnection(SystemSingleton.Configuration.ConnectionString)) { SystemSingleton.Configuration.SqlConnections.Add(con); using (var command = new SqlCommand(SqlCommands.LoginCommand, con)) { command.Parameters.Add("@LoginText", SqlDbType.NVarChar); command.Parameters["@LoginText"].Value = LoginBox.Text; EnvironmentHelper.SendLogSQL(command.CommandText); con.Open(); using (var reader = command.ExecuteReader()) { if (reader.Read()) { SystemSingleton.CurrentSession.ID = reader.GetGuid(0); hashfromsql = reader.GetString(1); SystemSingleton.CurrentSession.TelegramID = reader.GetInt64(2); SystemSingleton.CurrentSession.FirstName = reader.GetString(3); SystemSingleton.CurrentSession.LastName = reader.GetString(4); SystemSingleton.CurrentSession.FullName = reader.GetString(5); isAdmin = reader.GetBoolean(6); } } con.Close(); } } } catch (Exception ex) { EnvironmentHelper.SendErrorDialogBox(ex.Message, "SQL Error", ex.StackTrace); } if (SystemSingleton.CurrentSession.ID == Guid.Empty || hash != hashfromsql) { SendAttentionToBottomBar("m_tab_LogIn_PasWrong"); SystemSingleton.CurrentSession.CloseSession(); } else if (!isAdmin) { SendAttentionToBottomBar("m_tab_LogIn_NotAdmin_PasWrong"); SystemSingleton.CurrentSession.CloseSession(); } else { SystemSingleton.CurrentSession.Login = LoginBox.Text; PassBox.Clear(); ClearBottomBar(); LogOffItem.Visibility = Visibility.Visible; WorkingTab.Visibility = Visibility.Visible; TabControl.SelectedIndex = 1; LoginTab.Visibility = Visibility.Collapsed; menuLanguage.Visibility = Visibility.Collapsed; EnvironmentHelper.SendLog("Log In - " + SystemSingleton.CurrentSession.Login); OnLogin(); } } else { SendAttentionToBottomBar("m_tab_LogIn_LogOrPassNotTyped"); } }
private void Login_Click(object sender, RoutedEventArgs e) { Manager manager = Manager.Instance(); manager.ManagerOperation(); string managerEmail = manager.GetManagerEmail(); string managerPassword = manager.GetManagerPassword(); if (LoginBox.Text == managerEmail && PassBox.Password == managerPassword) { context = new Context(new ConcreteStrategyE()); context.ContextInterface(); this.Close(); } else { try { var email = DB.Clients.Where(u => u.Email == LoginBox.Text).FirstOrDefault(); var email2 = DB.Sellers.Where(u => u.Email == LoginBox.Text).FirstOrDefault(); var email3 = DB.Storekeepers.Where(u => u.Email == LoginBox.Text).FirstOrDefault(); if ((LoginBox.Text == "") || (PassBox.Password == "")) { if (LoginBox.Text == "") { MessageBox.Show("Email is Required!", "Caution", MessageBoxButton.OK); LoginBox.Focus(); } else if (PassBox.Password == "") { MessageBox.Show("Password is Required!", "Caution", MessageBoxButton.OK); PassBox.Focus(); } } else { if (email != null) { var pass = email.Password; pass = PassBox.Password; if (PassBox.Password == pass) { MessageBox.Show("Login Successfully!", "Login Success", MessageBoxButton.OK); client = DB.Clients.Where(u => u.Email == LoginBox.Text).FirstOrDefault(); context = new Context(new ConcreteStrategyE(client)); context.ContextInterface(); this.Close(); } else { MessageBox.Show("Email or Password are wrong!"); } } else if (email2 != null) { var pass = email2.Password; pass = PassBox.Password; if (PassBox.Password == pass) { MessageBox.Show("Login Successfully!", "Login Success", MessageBoxButton.OK); seller = DB.Sellers.Where(u => u.Email == LoginBox.Text).FirstOrDefault(); context = new Context(new ConcreteStrategyE(seller)); context.ContextInterface(); this.Close(); } else { MessageBox.Show("Email and Password or wrong!"); } } else if (email3 != null) { var pass = email3.Password; pass = PassBox.Password; if (PassBox.Password == pass) { MessageBox.Show("Login Successfully!", "Login Success", MessageBoxButton.OK); storekeeper = DB.Storekeepers.Where(u => u.Email == LoginBox.Text).FirstOrDefault(); context = new Context(new ConcreteStrategyE(storekeeper)); context.ContextInterface(); this.Close(); } else { MessageBox.Show("Email and Password or wrong!"); } } else { MessageBox.Show("Email and Password is invalid"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
//_______________________________ /** Coding Login Panel **/ //________________________________ private void Connection_Click(object sender, EventArgs e) { int i = 0; string Mode; SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from registration where login='******' and motdepasse='" + PassBox.Text + "' "; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); i = Convert.ToInt32(dt.Rows.Count.ToString()); foreach (DataRow dr in dt.Rows) { Mode = dr["UserMode"].ToString(); UserMod.Text = Mode.ToString(); utilisateurname.Text = dr["nom"].ToString(); utilisateurfname.Text = dr["prenom"].ToString(); } if (i == 0) { WrongFill.Visible = true; // MessageBox.Show("This username password does not match"); } else if (UserMod.Text == "Admin") { UsersSecurity.Hide(); Login.Hide(); LoginBox.Clear(); PassBox.Clear(); WelcomePage.BringToFront(); Header.Show(); Waiting.Show(); WaitingTimer.Start(); WrongFill.Visible = false; } else { // button1.Enabled = false; // SupprimerCommande.Enabled = false; // commander.Enabled = false; dataGridView1.Hide(); UsersSecurity.Show(); ajoutstock.Enabled = false; Ajouterbutton.Enabled = false; Annulation.Enabled = false; Moduser.Enabled = false; Suppbutton.Enabled = false; DelDealer.Enabled = false; SaveDealer.Enabled = false; SupprimerUnite.Enabled = false; AjouterUnite.Enabled = false; Delbutton.Enabled = false; Modbutton.Enabled = false; AjoutButton.Enabled = false; UserAddPanel.Enabled = false; Fournisseurs.Enabled = false; pictureBox5.Visible = false; Login.Hide(); LoginBox.Clear(); PassBox.Clear(); WelcomePage.BringToFront(); Header.Show(); Waiting.Show(); WaitingTimer.Start(); WrongFill.Visible = false; } }
//Cleans the field of passbox private void PassBox_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { PassBox.Clear(); }
public LoginWindow() { InitializeComponent(); PassBox.Focus(); }
private void btnLogin_Click(object sender, EventArgs e) { //авторизация int role, id; login = LogBox.Text; password = getHashSha256(PassBox.Text); connect.Open(); SqlCommand sql = new SqlCommand($"SELECT * FROM Пользователи WHERE Логин = '{login}' and Пароль = '{password}'", connect); reader = sql.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { role = reader.GetInt32(3); id = reader.GetInt32(0); switch (role) { case 1: AdminForm adm = new AdminForm(); this.StyleManager.Clone(adm); this.Hide(); adm.Show(); break; case 2: ManageForm mng = new ManageForm(id); this.StyleManager.Clone(mng); this.Hide(); mng.Show(); break; case 3: MasterForm mst = new MasterForm(); this.StyleManager.Clone(mst); mst.Show(); break; case 4: OpenClientForm oclt = new OpenClientForm(id); this.StyleManager.Clone(oclt); this.Hide(); oclt.Show(); break; } } } else { MessageBox.Show("Неверный логин или пароль, попробуйте снова", "Ошибка входа", MessageBoxButtons.OK, MessageBoxIcon.Error); attempts++; PassBox.Clear(); } reader.Close(); connect.Close(); if (attempts >= 3) { capcha(); } }
private void Cancelar_Click(object sender, RoutedEventArgs e) { PassBox.Clear(); cboUsuario.SelectedIndex = -1; }