コード例 #1
0
        /// <summary>
        /// Get list user with department and position
        /// </summary>
        /// <param name="dept_code"></param>
        /// <param name="postion_code"></param>
        public void GetListUser(string dept_code, string postion_code)
        {
            //SQL library
            PSQL   SQL   = new PSQL();
            string query = string.Empty;

            //Open SQL connection
            SQL.Open();
            //SQL query string
            query = @"SELECT user_cd, user_name, locale_id, multi_login_flag, registration_user_cd, registration_date_time,
                      registrated_factory_cd, dept_cd, user_position_cd FROM m_mes_user WHERE 1=1 ";
            if (!string.IsNullOrEmpty(dept_code))
            {
                query += "and dept_cd ='" + dept_code + "' ";
            }
            if (!string.IsNullOrEmpty(postion_code))
            {
                query += "and user_position_cd ='" + postion_code + "' ";
            }
            query += "ORDER BY user_cd";
            //Execute reader for read database
            IDataReader reader = SQL.Command(query).ExecuteReader();

            query = string.Empty;
            while (reader.Read())
            {
                //Get an item
                m_mes_user outItem = new m_mes_user
                {
                    user_cd                = reader["user_cd"].ToString(),
                    user_name              = reader["user_name"].ToString(),
                    locale_id              = (int)reader["locale_id"],
                    multi_login_flag       = reader["multi_login_flag"].ToString(),
                    registration_date_time = (DateTime)reader["registration_date_time"],
                    registration_user_cd   = reader["registration_user_cd"].ToString(),
                    dept_cd                = reader["dept_cd"].ToString(),
                    user_position_cd       = reader["user_position_cd"].ToString(),
                };
                listMesUser.Add(outItem);
            }
            reader.Close();
            //Close SQL connection
            SQL.Close();
        }
コード例 #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 ='******'";
         //Execute reader for read database
         IDataReader 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
     {
         throw new Exception("Wrong user or password!" + Environment.NewLine + "Please Log In again!");
     }
 }
コード例 #3
0
ファイル: m_mes_user_role.cs プロジェクト: n-d-khoa/Nidec_Git
        /// <summary>
        /// Get list role of user
        /// </summary>
        /// <param name="usercode">User code</param>
        /// <returns></returns>
        public List <string> GetListRole(string usercode)
        {
            List <string> list = new List <string>();
            //SQL library
            PSQL   SQL   = new PSQL();
            string query = string.Empty;

            //Open SQL connection
            SQL.Open();
            //SQL query string
            query = "SELECT distinct role_cd FROM m_mes_user_role WHERE user_cd ='" + usercode + "' ORDER BY role_cd";
            //Execute reader for read database
            IDataReader reader = SQL.Command(query).ExecuteReader();

            while (reader.Read())
            {
                list.Add(reader["role_cd"].ToString());
            }
            reader.Close();
            //Close SQL connection
            SQL.Close();
            return(list);
        }