private void btnLogin_Click_1(object sender, EventArgs e) { try { if (CheckAccount()) { Account = ConnectSQL.ExcuteQuery("Update Account set Status = '1' where IDStaff = '" + txtUserName.Text + "'"); txtUserName.Text = ""; txtPassword.Text = ""; this.Hide(); fHomePage fHP = new fHomePage(); fHP.ReturnIDAccount = txtUserName.Text; fHP.ShowDialog(); this.Close(); } else { MessageBox.Show("Tài khoản hoặc mật khẩu sai", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtUserName.Focus(); } } catch { MessageBox.Show("Vui lòng kiểm tra lại", "Thông báo"); } }
private void timer1_Tick(object sender, EventArgs e) { if (timer1.Interval == 2900) { timer1.Enabled = false; timer1.Stop(); Connect ConnectSQL = new Connect(); DataTable Account = new DataTable(); Account = ConnectSQL.ExcuteQuery("Select IDStaff, Status from Account"); bool CheckAccountOnline() { bool Flag = false; if (Account.Rows.Count >= 1) { for (int i = 0; i < Account.Rows.Count; i++) { if (Convert.ToInt32(Account.Rows[i][1]) == 1) { Flag = true; break; } } } return(Flag); } if (CheckAccountOnline()) { string IDStaff = ""; for (int i = 0; i < Account.Rows.Count; i++) { if (Account.Rows[i][1].ToString() == "1") { IDStaff = Account.Rows[i][0].ToString(); } } this.Hide(); fHomePage fhp = new fHomePage(); fhp.ShowDialog(); this.Close(); } else { this.Hide(); fLogin flog = new fLogin(); flog.ShowDialog(); this.Close(); } } }