Esempio n. 1
0
        public string GetModuleSequenceNumber(string strModuleName, string seqType)
        {
            //If the seqType = Key, we are going to form a key of 7 char for a entity else
            // we are dealing with a transaction of 4 char.
            int    modSeqNo = 1;
            string queryStr = "";

            queryStr = "SELECT * FROM SequenceNos where SequenceId = \"" + strModuleName + "\"";

            using (SqlDataReader dr = efactDB.ExecuteDBCommand(queryStr, "ClseFactMethodsGetModuleSequenceNumber1"))
            {
                if (dr.HasRows)
                {
                    dr.Read();
                    modSeqNo = (int)dr["SeqNoValue"] + 1;
                }
            }

            queryStr  = "UPDATE SequenceNos SET SeqNoValue = \"" + modSeqNo + "\" ";
            queryStr += "WHERE SequenceId = \"" + strModuleName + "\"";

            using (SqlDataReader dr = efactDB.ExecuteDBCommand(queryStr, "ClseFactMethodsGetModuleSequenceNumber2")) { };

            if (seqType == "KEY")
            {
                return((modSeqNo - 1).ToString("D7"));
            }
            else
            {
                return((modSeqNo - 1).ToString("D4"));
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// Write SysLog file of User actions
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="functionId"></param>
        /// <param name="functionKey"></param>
        /// <param name="actionType"></param>
        /// <param name="recModNo"></param>
        public void Write_SysLog(string userId, string functionId, string functionKey, string actionType, int recModNo)
        {
            string   queryStr = "";
            DateTime dt       = DateTime.Today;

            //Insert SysLog record
            queryStr  = "INSERT INTO SysLog (";
            queryStr += "UserId, ";
            queryStr += "FunctionId, ";
            queryStr += "FunctionKey, ";
            queryStr += "ActionType, ";
            queryStr += "RecordModNo, ";
            queryStr += "DateStamp) ";
            queryStr += "VALUES (";

            queryStr += "'" + userId + "', ";
            queryStr += "'" + functionId + "', ";
            queryStr += "'" + functionKey + "', ";
            queryStr += "'" + actionType + "', ";
            queryStr += recModNo + ", ";
            queryStr += "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "') ";

            using (SqlDataReader dr = efactDB.ExecuteDBCommand(queryStr, "ClsTransactionLogWrite_SysLog")) { };
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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;
        }
Esempio n. 7
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;
        }
Esempio n. 8
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;
        }