Beispiel #1
0
        public string UpdateLastLoginDB()
        {
            ClsDatabaseReader efactDB  = new ClsDatabaseReader();
            string            queryStr = "";

            queryStr  = "UPDATE Users SET UserLastLoginDate = \"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\" ";
            queryStr += "WHERE UserId = \"" + UserName + "\"";

            string returnStr = "";

            efactDB.ExecuteDBCommand(queryStr, "ClsLoginUpdateLastLoginDB1");

            queryStr  = "";
            queryStr  = "INSERT INTO CurrentUsers (";
            queryStr += "CurrentUserId, ";
            queryStr += "CurrentLastLoginDate) ";
            queryStr += "VALUES (";

            queryStr += "\"" + UserName + "\", ";
            queryStr += "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\") ";

            returnStr = "";
            efactDB.ExecuteDBCommand(queryStr, "ClsLoginUpdateLastLoginDB2");

            return(returnStr);
        }
Beispiel #2
0
        public Boolean CheckUserLoggedIn()
        {
            Boolean           IsUserLoggedIn = false;
            ClsDatabaseReader efactDB        = new ClsDatabaseReader();

            string queryStr = "SELECT * FROM CurrentUsers WHERE CurrentUserId = \"" + UserName + "\"";

            using (SqlDataReader dr = efactDB.ExecuteDBCommand(queryStr, "CLSLoginCheckUserLoggedIn"))
            {
                if (dr != null)
                {
                    dr.Read();
                    if (dr.HasRows)  // If any user found?
                    {
                        MessageBox.Show("User " + UserName + " is already logged in ",
                                        "Login Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        IsUserLoggedIn = true;
                    }
                }
            }

            return(IsUserLoggedIn);
        }
Beispiel #3
0
        public Boolean CheckUserExistInDB()
        {
            ClsDatabaseReader efactDB = new ClsDatabaseReader();

            string  queryStr    = "SELECT * FROM Users WHERE UserId = \"" + UserName + "\"";
            Boolean IsUserExist = true;

            using (SqlDataReader dr = efactDB.ExecuteDBCommand(queryStr, "ClsLoginCheckUserExistInDB"))
            {
                if (dr != null)
                {
                    dr.Read();
                    if (dr.HasRows)  // If any user found? Yes, check for correct User name and password
                    {
                        if (dr["UserId"].ToString() != UserName || dr["UserPwd"].ToString() != Encrypt(UserPassword, UserName))
                        {
                            MessageBox.Show("Username or Password is invalid",
                                            "User Login", MessageBoxButton.OK, MessageBoxImage.Error);

                            NumberOfLogins += 1;
                            IsUserExist     = false;
                            log.Write_SysLog(UserName, "LOGIN", "", "Invalid User login", 0);
                        }
                        else
                        {
                            if (dr["Userstatus"].ToString() == "D")
                            {
                                MessageBox.Show("User is disabled. Contact your Security Officer",
                                                "User Login", MessageBoxButton.OK, MessageBoxImage.Error);
                                IsUserExist = false;
                                log.Write_SysLog(UserName, "LOGIN", "", "User is disabled", 0);
                            }
                            else
                            {
                                UserName           = dr["UserId"].ToString();
                                UserPassword       = dr["UserPwd"].ToString();
                                UserLstLoginDate   = (DateTime)dr["UserLastLoginDate"];
                                UserActivationDate = (DateTime)dr["UserActivationDate"];
                                UserPwdExpireDate  = (DateTime)dr["UserPwdExpireDate"];
                                UserForcePwdChange = (Boolean)dr["UserForcePwdChange"];
                                UserProfileEndDate = (DateTime)dr["UserProfileEndDate"];
                                UserRecordStatus   = dr["UserRecordStatus"].ToString();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Username or Password is invalid.",
                                        "User Login", MessageBoxButton.OK, MessageBoxImage.Error);

                        NumberOfLogins += 1;
                        IsUserExist     = false;
                        log.Write_SysLog(UserName, "LOGIN", "", "Invalid User login", 0);
                    }
                }
                else
                {
                    // Database error, something wrong with the tables. Can not read the table
                    MessageBox.Show("Database pecific error",
                                    "User Login", MessageBoxButton.OK, MessageBoxImage.Error);
                    IsUserExist = false;
                }
            }

            return(IsUserExist);
        }
Beispiel #4
0
        public string UpdateLastLoginDB()
        {
            ClsDatabaseReader efactDB = new ClsDatabaseReader();
            string queryStr = "";
            queryStr = "UPDATE Users SET UserLastLoginDate = \"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\" ";
            queryStr += "WHERE UserId = \"" + UserName + "\"";

            string returnStr = "";
            efactDB.ExecuteDBCommand(queryStr, "ClsLoginUpdateLastLoginDB1");

            queryStr = "";
            queryStr = "INSERT INTO CurrentUsers (";
            queryStr += "CurrentUserId, ";
            queryStr += "CurrentLastLoginDate) ";
            queryStr += "VALUES (";

            queryStr += "\"" + UserName + "\", ";
            queryStr += "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\") ";

            returnStr = "";
            efactDB.ExecuteDBCommand(queryStr, "ClsLoginUpdateLastLoginDB2");

            return returnStr;
        }
Beispiel #5
0
        public Boolean CheckUserLoggedIn()
        {
            Boolean IsUserLoggedIn = false;
            ClsDatabaseReader efactDB = new ClsDatabaseReader();

            string queryStr = "SELECT * FROM CurrentUsers WHERE CurrentUserId = \"" + UserName + "\"";
            using (SqlDataReader dr = efactDB.ExecuteDBCommand(queryStr, "CLSLoginCheckUserLoggedIn"))
            {
                if (dr != null)
                {
                    dr.Read();
                    if (dr.HasRows)  // If any user found?
                    {
                        MessageBox.Show("User " + UserName + " is already logged in ",
                                        "Login Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        IsUserLoggedIn = true;
                    }
                }
            }

            return IsUserLoggedIn;
        }
Beispiel #6
0
        public Boolean CheckUserExistInDB()
        {
            ClsDatabaseReader efactDB = new ClsDatabaseReader();

            string queryStr = "SELECT * FROM Users WHERE UserId = \"" + UserName + "\"";
            Boolean IsUserExist = true;

            using (SqlDataReader dr = efactDB.ExecuteDBCommand(queryStr, "ClsLoginCheckUserExistInDB"))
            {
                if (dr != null)
                {
                    dr.Read();
                    if (dr.HasRows)  // If any user found? Yes, check for correct User name and password
                    {
                        if (dr["UserId"].ToString() != UserName || dr["UserPwd"].ToString() != Encrypt(UserPassword, UserName))
                        {
                            MessageBox.Show("Username or Password is invalid",
                                            "User Login", MessageBoxButton.OK, MessageBoxImage.Error);

                            NumberOfLogins += 1;
                            IsUserExist = false;
                            log.Write_SysLog(UserName, "LOGIN", "", "Invalid User login", 0);
                        }
                        else
                        {
                            if (dr["Userstatus"].ToString() == "D")
                            {
                                MessageBox.Show("User is disabled. Contact your Security Officer",
                                                "User Login", MessageBoxButton.OK, MessageBoxImage.Error);
                                IsUserExist = false;
                                log.Write_SysLog(UserName, "LOGIN", "", "User is disabled", 0);
                            }
                            else
                            {
                                UserName = dr["UserId"].ToString();
                                UserPassword = dr["UserPwd"].ToString();
                                UserLstLoginDate = (DateTime)dr["UserLastLoginDate"];
                                UserActivationDate = (DateTime)dr["UserActivationDate"];
                                UserPwdExpireDate = (DateTime)dr["UserPwdExpireDate"];
                                UserForcePwdChange = (Boolean)dr["UserForcePwdChange"];
                                UserProfileEndDate = (DateTime)dr["UserProfileEndDate"];
                                UserRecordStatus = dr["UserRecordStatus"].ToString();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Username or Password is invalid.",
                                        "User Login", MessageBoxButton.OK, MessageBoxImage.Error);

                        NumberOfLogins += 1;
                        IsUserExist = false;
                        log.Write_SysLog(UserName, "LOGIN", "", "Invalid User login", 0);
                    }
                }
                else
                {
                    // Database error, something wrong with the tables. Can not read the table
                    MessageBox.Show("Database pecific error",
                                    "User Login", MessageBoxButton.OK, MessageBoxImage.Error);
                    IsUserExist = false;
                }
            }

            return IsUserExist;
        }