private void BaseForm_MouseMove(object sender, MouseEventArgs e) { SecurityManager.ResetCounter(); }
public static bool IsAuthenticate(string userID, string password) { bool valid = false; DataTable dt; using (Database db = new Database()) { db.Commands.Add(db.CreateCommand("usp_SecurityUsers_AUTHENTICATE")); db.Commands[0].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[0].Parameters.Add(new Parameter("@password", SqlDbType.VarChar, password)); dt = db.Commands[0].ExecuteDataTable(); } if (dt.Rows.Count > 0) { _userID = userID; _userName = dt.Rows[0]["UserName"].ToString(); _userInitial = dt.Rows[0]["Initial"].ToString(); _TglPassword = (DateTime)dt.Rows[0]["TglPassword"]; _active = bool.Parse(dt.Rows[0]["Active"].ToString()); if (_active) { using (Database db = new Database()) { //Get Parts db.Commands.Add(db.CreateCommand("usp_vwSecurityPartsUsers_LIST")); db.Commands[0].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); dt = db.Commands[0].ExecuteDataTable(); _parts = new List <string>(); foreach (DataRow dr in dt.Rows) { _parts.Add(dr["PartID"].ToString()); } //Get Rights db.Commands.Add(db.CreateCommand("usp_SecurityUsersRights_LIST")); db.Commands[1].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); dt = db.Commands[1].ExecuteDataTable(); _rights = new List <string>(); foreach (DataRow dr in dt.Rows) { _rights.Add(dr["RightID"].ToString()); } //Get App Roles db.Commands.Add(db.CreateCommand("usp_SecurityRolesUsers_LIST")); db.Commands[2].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[2].Parameters.Add(new Parameter("@roleType", SqlDbType.VarChar, "Application")); dt = db.Commands[2].ExecuteDataTable(); _appRoles = new List <string>(); foreach (DataRow dr in dt.Rows) { _appRoles.Add(dr["RoleID"].ToString()); } //Get Biz Roles db.Commands.Add(db.CreateCommand("usp_SecurityRolesUsers_LIST")); db.Commands[3].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[3].Parameters.Add(new Parameter("@roleType", SqlDbType.VarChar, "Business")); dt = db.Commands[3].ExecuteDataTable(); _bizRoles = new List <string>(); foreach (DataRow dr in dt.Rows) { _bizRoles.Add(dr["RoleID"].ToString()); } } valid = true; } else { MessageBox.Show(Messages.Error.AccountInactive, "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //get IP Address IPAddress[] localIPs = Dns.GetHostAddresses(System.Net.Dns.GetHostName()); if (valid) { SecurityManager.ResetCounter(); _state = enState.LogIn; } return(valid); }
private void BaseForm_KeyDown(object sender, KeyEventArgs e) { SecurityManager.ResetCounter(); if (!e.Control) { switch (e.KeyCode) { case Keys.Enter: this.SelectNextControl(this.ActiveControl, true, true, true, true); //e.Handled = true; break; case Keys.Escape: this.Close(); if (this.Caller != null) { this.Caller.Focus(); } break; case Keys.Insert: if (cmdAdd != null) { if (cmdAdd.Enabled && cmdAdd.Visible) { cmdAdd.PerformClick(); } } break; case Keys.Space: if (cmdEdit != null) { if (cmdEdit.Enabled && cmdEdit.Visible) { cmdEdit.PerformClick(); } } break; case Keys.F3: if (e.Control) { if (cmdPrint != null) { if (cmdPrint.Enabled && cmdPrint.Visible) { cmdPrint.PerformClick(); } } } break; } } else { switch (e.KeyCode) { case Keys.E: if (e.Control) { if (cmdEdit != null) { if (cmdEdit.Enabled && cmdEdit.Visible) { cmdEdit.PerformClick(); } } } break; case Keys.N: if (e.Control) { if (cmdAdd != null) { if (cmdAdd.Enabled && cmdAdd.Visible) { cmdAdd.PerformClick(); } } } break; case Keys.S: if (e.Control) { if (cmdSave != null) { if (cmdSave.Enabled && cmdSave.Visible) { cmdSave.PerformClick(); } } } break; case Keys.P: if (e.Control) { if (cmdPrint != null) { if (cmdPrint.Enabled && cmdPrint.Visible) { cmdPrint.PerformClick(); } } } break; } } }