using MySql.Data.MySqlClient;
using System.Data;

namespace irisDataBase.Service.mysqlImpl
{
    class IrisDeviceServiceImpl:IrisDeviceService
    {

        public string getDevCode(string ip)
        {
            string devCode = "";
            string sql = "select DEV_CODE FROM bus_device where DEV_IP=@DEV_IP";
            MySqlCommand cmd = new MySqlCommand(sql, DatabaseLocal.mySqlConnect);
            cmd.Parameters.Add("@DEV_IP", MySqlDbType.String, 20).Value = ip.Trim();

            MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default);

            if (aReader != null)
            {
                if (aReader.Read())
                {
                    //判断门的状态
                    if (!aReader.IsDBNull(0))
                    {
                        devCode = aReader.GetString(0);
                    }
                }
            }
            aReader.Close();
            aReader.Dispose();
            return devCode;
        }

    }
}
