private void frmMain_KeyPress(object sender, KeyPressEventArgs e) { SecurityManager.ResetCounter(); }
public static bool IsAuthenticate(string userID, string password, string dbName) { bool valid = false; DataTable dt, dtU; Database db; if (dbName != "") { db = new Database(dbName); } else { 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.Parse(dt.Rows[0]["TglPassword"].ToString()); _active = bool.Parse(dt.Rows[0]["Active"].ToString()); if (_active) { //Get Parts db.Commands[0].Parameters.Clear(); db.Commands.RemoveAt(0); 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()); } db.Commands.Add(db.CreateCommand("usp_UserLogin_AUTHENTICATE")); db.Commands[4].Parameters.Add(new Parameter("@Username", SqlDbType.VarChar, userID)); dtU = db.Commands[4].ExecuteDataTable(); if (dtU.Rows.Count > 0) { _tgl = DateTime.Parse(dtU.Rows[0]["LastLogin"].ToString()); } //if (GlobalVar.GetServerDate.Date < _tgl.Date) //{ // MessageBox.Show("Tanggal server tidak valid", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // valid = false; //} //else if (DateTime.Today.Date < _tgl.Date) //{ // MessageBox.Show("Tanggal client tidak valid", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // valid = false; //} //else //{ // valid = true; //} 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 frmMain_MouseMove(object sender, MouseEventArgs e) { SecurityManager.ResetCounter(); }