Esempio n. 1
0
        /// <summary>
        /// Change password of user
        /// </summary>
        /// <param name="inItem">input new info of user</param>
        /// <returns></returns>
        public bool ChangePassword(m_login_password inItem)
        {
            EncryptDecrypt endecrypt = new EncryptDecrypt();
            string         pass      = endecrypt.Encrypt(inItem.password);
            //SQL library
            PSQL   SQL   = new PSQL();
            string query = string.Empty;

            //Open SQL connection
            SQL.Open();
            //SQL query string
            query = "UPDATE m_login_password SET password ='******' WHERE user_cd ='" + inItem.user_cd + "' ";
            //Execute non query
            int result = SQL.Command(query).ExecuteNonQuery();

            query = string.Empty;
            SQL.Close();
            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Check user and password
 /// </summary>
 /// <param name="usercd">user code</param>
 /// <param name="pass">password</param>
 /// <returns></returns>
 public m_login_password CheckLogIn(string usercd, string pass)
 {
     try
     {
         EncryptDecrypt endecrypt = new EncryptDecrypt();
         pass = endecrypt.Encrypt(pass);
         //SQL library
         PSQL   SQL   = new PSQL();
         string query = string.Empty;
         //Open SQL connection
         SQL.Open();
         //SQL query string
         query  = @"SELECT user_cd, registration_user_cd, registration_date_time, factory_cd, last_login_time, is_online ";
         query += "FROM m_login_password WHERE user_cd ='" + usercd + "' and password ='******'";
         IDataReader reader;
         //Execute reader for read database
         reader = SQL.Command(query).ExecuteReader();
         query  = string.Empty;
         reader.Read();
         //Get an item
         m_login_password outItem = new m_login_password
         {
             user_cd                = reader["user_cd"].ToString(),
             factory_cd             = reader["factory_cd"].ToString(),
             is_online              = (bool)reader["is_online"],
             last_login_time        = (DateTime)reader["last_login_time"],
             registration_date_time = (DateTime)reader["registration_date_time"],
             registration_user_cd   = reader["registration_user_cd"].ToString(),
         };
         reader.Close();
         //Close SQL connection
         SQL.Close();
         return(outItem);
     }
     catch (InvalidOperationException)
     {
         throw new Exception("Wrong user or password!" + Environment.NewLine + "Please Log In again!");
     }
 }