예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LumluxSSYDB.Model.tMeasurePowerInfoes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tMeasurePowerInfoes set ");
            strSql.Append("iID=@iID,");
            strSql.Append("fValue=@fValue,");
            strSql.Append("sMeasureInfoGUID=@sMeasureInfoGUID,");
            strSql.Append("sDesc=@sDesc");
            strSql.Append(" where sGUID=@sGUID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@iID",              SqlDbType.Int,        4),
                new SqlParameter("@fValue",           SqlDbType.Float,      8),
                new SqlParameter("@sMeasureInfoGUID", SqlDbType.Char,      36),
                new SqlParameter("@sDesc",            SqlDbType.NVarChar, 500),
                new SqlParameter("@sGUID",            SqlDbType.Char, 36)
            };
            parameters[0].Value = model.iID;
            parameters[1].Value = model.fValue;
            parameters[2].Value = model.sMeasureInfoGUID;
            parameters[3].Value = model.sDesc;
            parameters[4].Value = model.sGUID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LumluxSSYDB.Model.tMeasurePowerInfoes DataRowToModel(DataRow row)
 {
     LumluxSSYDB.Model.tMeasurePowerInfoes model = new LumluxSSYDB.Model.tMeasurePowerInfoes();
     if (row != null)
     {
         if (row["sGUID"] != null)
         {
             model.sGUID = row["sGUID"].ToString();
         }
         if (row["iID"] != null && row["iID"].ToString() != "")
         {
             model.iID = int.Parse(row["iID"].ToString());
         }
         if (row["fValue"] != null && row["fValue"].ToString() != "")
         {
             model.fValue = decimal.Parse(row["fValue"].ToString());
         }
         if (row["sMeasureInfoGUID"] != null)
         {
             model.sMeasureInfoGUID = row["sMeasureInfoGUID"].ToString();
         }
         if (row["sDesc"] != null)
         {
             model.sDesc = row["sDesc"].ToString();
         }
     }
     return(model);
 }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(LumluxSSYDB.Model.tMeasurePowerInfoes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tMeasurePowerInfoes(");
            strSql.Append("sGUID,iID,fValue,sMeasureInfoGUID,sDesc)");
            strSql.Append(" values (");
            strSql.Append("@sGUID,@iID,@fValue,@sMeasureInfoGUID,@sDesc)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sGUID",            SqlDbType.Char,     36),
                new SqlParameter("@iID",              SqlDbType.Int,       4),
                new SqlParameter("@fValue",           SqlDbType.Float,     8),
                new SqlParameter("@sMeasureInfoGUID", SqlDbType.Char,     36),
                new SqlParameter("@sDesc",            SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.sGUID;
            parameters[1].Value = model.iID;
            parameters[2].Value = model.fValue;
            parameters[3].Value = model.sMeasureInfoGUID;
            parameters[4].Value = model.sDesc;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LumluxSSYDB.Model.tMeasurePowerInfoes GetModelByHostGuidAndIDAndTime(string MeasureInfoGuid, int iID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 sGUID,iID,fValue,sMeasureInfoGUID,sDesc from tMeasurePowerInfoes ");
            strSql.Append(" where sMeasureInfoGUID=@sMeasureInfoGUID and iID=@iID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sMeasureInfoGUID", SqlDbType.Char, 36),
                new SqlParameter("@iID",              SqlDbType.Int)
            };
            parameters[0].Value = MeasureInfoGuid;
            parameters[1].Value = iID;

            LumluxSSYDB.Model.tMeasurePowerInfoes model = new LumluxSSYDB.Model.tMeasurePowerInfoes();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }