Exemple #1
0
        /// <summary>
        /// Get an user
        /// </summary>
        /// <param name="inInfo">input info condition</param>
        /// <returns></returns>
        public m_mes_user GetUser(m_mes_user inInfo)
        {
            string query = "SELECT * FROM [mesdb].[dbo].[m_mes_user] WHERE 1=1 ";

            if (inInfo.user_id > 0)
            {
                query += "AND user_id ='" + inInfo.user_id + "' ";
            }
            if (!string.IsNullOrEmpty(inInfo.user_cd))
            {
                query += "AND user_cd ='" + inInfo.user_cd + "' ";
            }
            if (!string.IsNullOrEmpty(inInfo.user_email))
            {
                query += "AND user_email ='" + inInfo.user_email + "' ";
            }
            if (!string.IsNullOrEmpty(inInfo.user_phone))
            {
                query += "AND user_phone ='" + inInfo.user_phone + "' ";
            }
            IDbConnection dbConnection = mESSQL.DbContext();

            dbConnection.Open();
            IDbCommand  dbCommand = mESSQL.DbCommand(query, dbConnection);
            IDataReader reader    = dbCommand.ExecuteReader();

            reader.Read();
            m_mes_user user = new m_mes_user
            {
                user_id        = (int)reader["user_id"],
                user_cd        = reader["user_cd"].ToString(),
                user_name      = reader["user_name"].ToString(),
                user_email     = reader["user_email"].ToString(),
                user_phone     = reader["user_phone"].ToString(),
                user_password  = reader["user_password"].ToString(),
                user_is_active = (bool)reader["user_is_active"],
                user_is_online = (bool)reader["user_is_online"],
                reg_date       = (DateTime)reader["reg_date"],
                factory_cd     = reader["factory_cd"].ToString(),
                last_ipaddress = reader["last_ipaddress"].ToString(),
                last_online    = (DateTime)reader["last_online"],
            };

            reader.Close();
            dbConnection.Close();
            return(user);
        }