Beispiel #1
0
        /// <summary>
        /// 通过主机guid,编码,时间得到一个对象实体
        /// </summary>
        public LumluxSSYDB.Model.tMeasureInfoes GetModelByHostGuidAndIdAndTime(string sHostInfoGUID, int iID, DateTime dCreateDate)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 sGUID,iID,fVlotA,fVlotB,fVlotC,iAlarmVlotA,iAlarmVlotB,iAlarmVlotC,dCreateDate,dUpdateTime,sHostInfoGUID,sDesc from tMeasureInfoes ");
            strSql.Append(" where sHostInfoGUID=@sHostInfoGUID and iID=@iID and dCreateDate > @dCreateDate");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sHostInfoGUID", SqlDbType.Char, 36), new SqlParameter("@iID", SqlDbType.Int), new SqlParameter("@dCreateDate", SqlDbType.DateTime)
            };
            parameters[0].Value = sHostInfoGUID;
            parameters[1].Value = iID;
            parameters[2].Value = dCreateDate;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LumluxSSYDB.Model.tMeasureInfoes DataRowToModel(DataRow row)
 {
     LumluxSSYDB.Model.tMeasureInfoes model = new LumluxSSYDB.Model.tMeasureInfoes();
     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["fVlotA"] != null && row["fVlotA"].ToString() != "")
         {
             model.fVlotA = decimal.Parse(row["fVlotA"].ToString());
         }
         if (row["fVlotB"] != null && row["fVlotB"].ToString() != "")
         {
             model.fVlotB = decimal.Parse(row["fVlotB"].ToString());
         }
         if (row["fVlotC"] != null && row["fVlotC"].ToString() != "")
         {
             model.fVlotC = decimal.Parse(row["fVlotC"].ToString());
         }
         if (row["iAlarmVlotA"] != null && row["iAlarmVlotA"].ToString() != "")
         {
             model.iAlarmVlotA = int.Parse(row["iAlarmVlotA"].ToString());
         }
         if (row["iAlarmVlotB"] != null && row["iAlarmVlotB"].ToString() != "")
         {
             model.iAlarmVlotB = int.Parse(row["iAlarmVlotB"].ToString());
         }
         if (row["iAlarmVlotC"] != null && row["iAlarmVlotC"].ToString() != "")
         {
             model.iAlarmVlotC = int.Parse(row["iAlarmVlotC"].ToString());
         }
         if (row["dCreateDate"] != null && row["dCreateDate"].ToString() != "")
         {
             model.dCreateDate = DateTime.Parse(row["dCreateDate"].ToString());
         }
         if (row["dUpdateTime"] != null && row["dUpdateTime"].ToString() != "")
         {
             model.dUpdateTime = DateTime.Parse(row["dUpdateTime"].ToString());
         }
         if (row["sHostInfoGUID"] != null)
         {
             model.sHostInfoGUID = row["sHostInfoGUID"].ToString();
         }
         if (row["sDesc"] != null)
         {
             model.sDesc = row["sDesc"].ToString();
         }
     }
     return(model);
 }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LumluxSSYDB.Model.tMeasureInfoes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tMeasureInfoes set ");
            strSql.Append("iID=@iID,");
            strSql.Append("fVlotA=@fVlotA,");
            strSql.Append("fVlotB=@fVlotB,");
            strSql.Append("fVlotC=@fVlotC,");
            strSql.Append("iAlarmVlotA=@iAlarmVlotA,");
            strSql.Append("iAlarmVlotB=@iAlarmVlotB,");
            strSql.Append("iAlarmVlotC=@iAlarmVlotC,");
            strSql.Append("dCreateDate=@dCreateDate,");
            strSql.Append("dUpdateTime=@dUpdateTime,");
            strSql.Append("sHostInfoGUID=@sHostInfoGUID,");
            strSql.Append("sDesc=@sDesc");
            strSql.Append(" where sGUID=@sGUID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@iID",           SqlDbType.Int,         4),
                new SqlParameter("@fVlotA",        SqlDbType.Float,       8),
                new SqlParameter("@fVlotB",        SqlDbType.Float,       8),
                new SqlParameter("@fVlotC",        SqlDbType.Float,       8),
                new SqlParameter("@iAlarmVlotA",   SqlDbType.Int,         4),
                new SqlParameter("@iAlarmVlotB",   SqlDbType.Int,         4),
                new SqlParameter("@iAlarmVlotC",   SqlDbType.Int,         4),
                new SqlParameter("@dCreateDate",   SqlDbType.DateTime),
                new SqlParameter("@dUpdateTime",   SqlDbType.DateTime),
                new SqlParameter("@sHostInfoGUID", SqlDbType.Char,       36),
                new SqlParameter("@sDesc",         SqlDbType.NVarChar,  500),
                new SqlParameter("@sGUID",         SqlDbType.Char, 36)
            };
            parameters[0].Value  = model.iID;
            parameters[1].Value  = model.fVlotA;
            parameters[2].Value  = model.fVlotB;
            parameters[3].Value  = model.fVlotC;
            parameters[4].Value  = model.iAlarmVlotA;
            parameters[5].Value  = model.iAlarmVlotB;
            parameters[6].Value  = model.iAlarmVlotC;
            parameters[7].Value  = model.dCreateDate;
            parameters[8].Value  = model.dUpdateTime;
            parameters[9].Value  = model.sHostInfoGUID;
            parameters[10].Value = model.sDesc;
            parameters[11].Value = model.sGUID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(LumluxSSYDB.Model.tMeasureInfoes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tMeasureInfoes(");
            strSql.Append("sGUID,iID,fVlotA,fVlotB,fVlotC,iAlarmVlotA,iAlarmVlotB,iAlarmVlotC,dCreateDate,dUpdateTime,sHostInfoGUID,sDesc)");
            strSql.Append(" values (");
            strSql.Append("@sGUID,@iID,@fVlotA,@fVlotB,@fVlotC,@iAlarmVlotA,@iAlarmVlotB,@iAlarmVlotC,@dCreateDate,@dUpdateTime,@sHostInfoGUID,@sDesc)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sGUID",         SqlDbType.Char,      36),
                new SqlParameter("@iID",           SqlDbType.Int,        4),
                new SqlParameter("@fVlotA",        SqlDbType.Float,      8),
                new SqlParameter("@fVlotB",        SqlDbType.Float,      8),
                new SqlParameter("@fVlotC",        SqlDbType.Float,      8),
                new SqlParameter("@iAlarmVlotA",   SqlDbType.Int,        4),
                new SqlParameter("@iAlarmVlotB",   SqlDbType.Int,        4),
                new SqlParameter("@iAlarmVlotC",   SqlDbType.Int,        4),
                new SqlParameter("@dCreateDate",   SqlDbType.DateTime),
                new SqlParameter("@dUpdateTime",   SqlDbType.DateTime),
                new SqlParameter("@sHostInfoGUID", SqlDbType.Char,      36),
                new SqlParameter("@sDesc",         SqlDbType.NVarChar, 500)
            };
            parameters[0].Value  = model.sGUID;
            parameters[1].Value  = model.iID;
            parameters[2].Value  = model.fVlotA;
            parameters[3].Value  = model.fVlotB;
            parameters[4].Value  = model.fVlotC;
            parameters[5].Value  = model.iAlarmVlotA;
            parameters[6].Value  = model.iAlarmVlotB;
            parameters[7].Value  = model.iAlarmVlotC;
            parameters[8].Value  = model.dCreateDate;
            parameters[9].Value  = model.dUpdateTime;
            parameters[10].Value = model.sHostInfoGUID;
            parameters[11].Value = model.sDesc;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }