/// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MDL.DeviceInfoMDL model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into deviceinfo(");
            strSql.Append("TID,DeviceType,DeviceID,DeviceName,DeviceIP,ProductType,DeviceState,StationID,`Desc` )");
            strSql.Append(" values (");
            strSql.Append("@TID,@DeviceType,@DeviceID,@DeviceName,@DeviceIP,@ProductType,@DeviceState,@StationID,@Desc)");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@TID",         model.TID),
                new SQLiteParameter("@DeviceType",  model.DeviceType),
                new SQLiteParameter("@DeviceID",    model.DeviceID),
                new SQLiteParameter("@DeviceName",  model.DeviceName),
                new SQLiteParameter("@DeviceIP",    model.DeviceIP),
                new SQLiteParameter("@ProductType", model.ProductType),
                new SQLiteParameter("@DeviceState", model.DeviceState),
                new SQLiteParameter("@StationID",   model.StationID),
                new SQLiteParameter("@Desc",        model.Desc)
            };

            int rows = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MDL.DeviceInfoMDL DataRowToModel(DataRow row)
 {
     MDL.DeviceInfoMDL model = new MDL.DeviceInfoMDL();
     if (row != null)
     {
         if (row["TID"] != null && row["TID"].ToString() != "")
         {
             model.TID = long.Parse(row["TID"].ToString());
         }
         if (row["DeviceType"] != null)
         {
             model.DeviceType = row["DeviceType"].ToString();
         }
         if (row["DeviceID"] != null)
         {
             model.DeviceID = row["DeviceID"].ToString();
         }
         if (row["DeviceName"] != null)
         {
             model.DeviceName = row["DeviceName"].ToString();
         }
         if (row["DeviceIP"] != null)
         {
             model.DeviceIP = row["DeviceIP"].ToString();
         }
         if (row["ProductType"] != null)
         {
             model.ProductType = row["ProductType"].ToString();
         }
         if (row["DeviceState"] != null && row["DeviceState"].ToString() != "")
         {
             model.DeviceState = int.Parse(row["DeviceState"].ToString());
         }
         if (row["StationID"] != null)
         {
             model.StationID = row["StationID"].ToString();
         }
         if (row["Desc"] != null)
         {
             model.Desc = row["Desc"].ToString();
         }
     }
     return(model);
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MDL.DeviceInfoMDL GetModel(string str)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select TID,DeviceType,DeviceID,DeviceName,DeviceIP,ProductType,DeviceState,StationID,`Desc`  from deviceinfo ");
            if (!string.IsNullOrEmpty(str))
            {
                strSql.Append("where " + str);
            }

            MDL.DeviceInfoMDL model = new MDL.DeviceInfoMDL();
            DataSet           ds    = SQLiteHelper.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MDL.DeviceInfoMDL model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update deviceinfo set ");
            strSql.Append("DeviceType=@DeviceType,");
            strSql.Append("DeviceID=@DeviceID,");
            strSql.Append("DeviceName=@DeviceName,");
            strSql.Append("DeviceIP=@DeviceIP,");
            strSql.Append("ProductType=@ProductType,");
            strSql.Append("DeviceState=@DeviceState,");
            strSql.Append("StationID=@StationID,");
            strSql.Append("Desc=@Desc");
            strSql.Append(" where TID=@TID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@DeviceType",  model.DeviceType),
                new SQLiteParameter("@DeviceID",    model.DeviceID),
                new SQLiteParameter("@DeviceName",  model.DeviceName),
                new SQLiteParameter("@DeviceIP",    model.DeviceIP),
                new SQLiteParameter("@ProductType", model.ProductType),
                new SQLiteParameter("@DeviceState", model.DeviceState),
                new SQLiteParameter("@StationID",   model.StationID),
                new SQLiteParameter("@Desc",        model.Desc),
                new SQLiteParameter("@TID",         model.TID)
            };

            int rows = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MDL.DeviceInfoMDL GetModel(long TID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select TID,DeviceType,DeviceID,DeviceName,DeviceIP,ProductType,DeviceState,StationID,`Desc`  from deviceinfo ");
            strSql.Append(" where TID=@TID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@TID", TID)
            };

            MDL.DeviceInfoMDL model = new MDL.DeviceInfoMDL();
            DataSet           ds    = SQLiteHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MDL.DeviceInfoMDL GetModel(string TID, string DeviceID, string IP)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict.Add("do", "get");
            dict.Add("method", "model");
            dict.Add("TID", TID);
            dict.Add("DeviceID", DeviceID);
            dict.Add("DeviceIP", IP);
            string     str        = Http.POST(requestUrl, dict);
            var        obj        = JsonHelper.JsonDeSerializer <ReturnInfo>(str);
            ReturnInfo ReturnData = (ReturnInfo)obj;

            if (ReturnData != null && ReturnData.Code == "1")
            {
                var data = JsonHelper.JsonDeSerializer <MDL.DeviceInfoMDL>(ReturnData.Data.ToString());
                MDL.DeviceInfoMDL Model = (MDL.DeviceInfoMDL)data;
                return(Model);
            }
            else
            {
                return(null);
            }
        }