Exemple #1
0
        public DAO.DeviceDao selectDeviceInfoWithIP(string ip)
        {
            string tablename = "t_device";

            string sql = "select a.id,a.name,b.itemname as devicetype,a.code,a.netaddress,c.position as position" +
                         " from " + tablename + " a " +
                         " left join t_itemcollection b on b.itemvalue=a.type and b.itemtype='DeviceType' " +
                         " left join t_position c on c.id=a.position where a.netaddress='" + ip + "' ";

            DataTable _dt = this.SelectQuery(sql);

            if (_dt == null || _dt.Rows.Count <= 0)
            {
                return(null);
            }
            else
            {
                DAO.DeviceDao dao = new DAO.DeviceDao();

                dao.Devicename     = _dt.Rows[0]["name"].ToString();
                dao.Devicetype     = _dt.Rows[0]["devicetype"].ToString();
                dao.Code           = _dt.Rows[0]["code"].ToString();
                dao.Netaddress     = _dt.Rows[0]["netaddress"].ToString();
                dao.Deviceposition = _dt.Rows[0]["position"].ToString();

                return(dao);
            }
        }
Exemple #2
0
        public bool insertDeviceInfo(DAO.DeviceDao dao)
        {
            string sql = "insert into t_device(`name`,type,code,netaddress,position) values " +
                         " ('" + dao.Devicename + "',(Select itemvalue from t_itemcollection where Itemname='" + dao.Devicetype + "' limit 0,1),'" + dao.Code + "','" + dao.Netaddress + "',(Select id from t_position where position='" + dao.Deviceposition + "' limit 0,1)) ";

            return(this.InsertQuery(sql));
        }
Exemple #3
0
        public bool updateDeviceInfo(string id, DAO.DeviceDao dao)
        {
            string sql = "update t_device set `name`='" + dao.Devicename + "',type=(Select itemvalue from t_itemcollection where Itemname='" + dao.Devicetype + "' limit 0,1),code='" + dao.Code + "',netaddress='" + dao.Netaddress + "',position=(Select id from t_position where position='" + dao.Deviceposition + "' limit 0,1) where id=" + id + " ";

            return(this.updateQuery(sql));
        }