private void BtnOk_Click(object sender, EventArgs e) { if (TxtName.Text.Trim() == "") { TxtName.Focus(); return; } if (TxtPassWord.Text.Trim() == "") { TxtPassWord.Focus(); return; } if (TxtName.Text.Trim() != "admin") { TxtName.Focus(); MessageBox.Show("请输入正确的帐号!"); return; } if (TxtPassWord.Text.Trim() != "6096") { TxtPassWord.Focus(); MessageBox.Show("请输入正确的密码!"); return; } this.DialogResult = DialogResult.OK; this.Close(); }
private void TxtUserID_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) // 엔터 { TxtPassWord.Focus(); } }
private void button1_Click(object sender, EventArgs e) { if (TxtName.Text == "" && TxtPassWord.Text == "") { MessageBox.Show("请输入账号!"); TxtName.Focus(); } if (TxtName.Text != "f" && TxtPassWord.Text != "") { MessageBox.Show("账号错误!\n 请重新输入…"); TxtName.Clear(); TxtName.Focus(); } if (TxtName.Text == "f" && TxtPassWord.Text == "") { MessageBox.Show("请输入密码!"); TxtPassWord.Focus(); } else if (TxtPassWord.Text != "f" && TxtName.Text == "f") { MessageBox.Show("密码错误!"); TxtPassWord.SelectAll(); TxtPassWord.Focus(); } if (TxtName.Text == "f" && TxtPassWord.Text == "f") { this.Close(); frmMain.showShiYanOrder(); } }
private void BtnLogin_Click(object sender, RoutedEventArgs e) { SqlConnection MysqlConnect = new SqlConnection(MydbConnect); // open connect to DB try { MysqlConnect.Open(); string MyLoginQuery = "select * from Library_Login where UserName= '******' and UserPassWord= '******' "; // create the commande for the query with 2 arguments(the query var , sqlconnection var) SqlCommand MyCommande = new SqlCommand(MyLoginQuery, MysqlConnect); //execute the query MyCommande.ExecuteNonQuery(); SqlDataReader MyReader = MyCommande.ExecuteReader(); int count = 0; while (MyReader.Read()) { count++; } // if the the reader of the query which is username and pass word is correct once then: if (count == 1) { //MessageBox.Show("Correct User name & password"); MainWindow window = new MainWindow(); window.Show(); this.Hide(); } /* if (count>1) * { * MessageBox.Show("Duplicate Username and Password, try again"); * }*/ if (count < 1) { MessageBox.Show("Incorrect Username and Password!! try again"); TxtPassWord.Clear(); TxtUserName.Clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { label1.Text = ""; int i = 0; if (TxtName.Text == "" && TxtPassWord.Text == "") { MessageBox.Show("请输入账号!"); TxtName.Focus(); } else if (TxtName.Text != "" && TxtPassWord.Text == "") { MessageBox.Show("请输入密码…"); TxtPassWord.Focus(); } else { while (true) { if (TxtName.Text == users[i].Name && TxtPassWord.Text == users[i].passWord) { label1.Text = "用户:" + users[i].Name + " 已登录"; button1.Visible = false; button2.Text = "注销"; TxtName.Clear(); TxtPassWord.Clear(); if (!File.Exists("Log.txt")) { File.Create("Log.txt").Close(); } string strLog = users[i].Name + "\t" + DateTime.Now.ToString(); StreamWriter sWriter = new StreamWriter("Log.txt", true); sWriter.WriteLine(strLog); sWriter.Close(); } i++; if (i > 4) { if (label1.Text == "") { MessageBox.Show("账号或密码错误!"); TxtName.Focus(); TxtName.SelectAll(); } break; } } } }
private async void imgbtnLogin_Click(object sender, RoutedEventArgs e) { this.Dispatcher.Invoke(new Action(() => { if (txtUser.Text.Trim().Equals("") || USER_NAME_HIT.Equals(txtUser.Text.Trim())) { MessageBox.Show("请输入用户名!"); //MsgTip.Visibility = Visibility.Visible; //MsgTipLabel.Content = "请输入用户名!"; txtUser.Focus(); return; } if (TxtPassWord.Password.Trim() == "") { MessageBox.Show("请输入密码!"); TxtPassWord.Focus(); return; } // 容器隐藏 Login2.Visibility = Visibility.Hidden; Login3.Visibility = Visibility.Visible; progressbar1.Visibility = Visibility.Visible; new Thread(() => { this.Dispatcher.Invoke(new Action(() => { LoginService loginService = new LoginService(); JObject j1 = loginService.login(txtUser.Text.Trim(), TxtPassWord.Password.Trim()); Main mainView = new Main(); mainView.Show(); this.Close(); })); }).Start(); })); }
private void txtPasw_GotFocus(object sender, RoutedEventArgs e) { TxtPassWord.Background = null as Brush; TxtPassWord.Clear(); }