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

            strSql.Append("update tMeasureConfigs set ");
            strSql.Append("fVoltHI=@fVoltHI,");
            strSql.Append("fVoltLO=@fVoltLO,");
            strSql.Append("iAlarmDelayTime=@iAlarmDelayTime,");
            strSql.Append("iMeasureNumber=@iMeasureNumber,");
            strSql.Append("iBranchNumber=@iBranchNumber,");
            strSql.Append("iState_Command=@iState_Command,");
            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("@fVoltHI",         SqlDbType.Float,       8),
                new SqlParameter("@fVoltLO",         SqlDbType.Float,       8),
                new SqlParameter("@iAlarmDelayTime", SqlDbType.Int,         4),
                new SqlParameter("@iMeasureNumber",  SqlDbType.Int,         4),
                new SqlParameter("@iBranchNumber",   SqlDbType.Char,       10),
                new SqlParameter("@iState_Command",  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.fVoltHI;
            parameters[1].Value  = model.fVoltLO;
            parameters[2].Value  = model.iAlarmDelayTime;
            parameters[3].Value  = model.iMeasureNumber;
            parameters[4].Value  = model.iBranchNumber;
            parameters[5].Value  = model.iState_Command;
            parameters[6].Value  = model.dCreateDate;
            parameters[7].Value  = model.dUpdateTime;
            parameters[8].Value  = model.sHostInfoGUID;
            parameters[9].Value  = model.sDesc;
            parameters[10].Value = model.sGUID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LumluxSSYDB.Model.tMeasureConfigs DataRowToModel(DataRow row)
 {
     LumluxSSYDB.Model.tMeasureConfigs model = new LumluxSSYDB.Model.tMeasureConfigs();
     if (row != null)
     {
         if (row["sGUID"] != null)
         {
             model.sGUID = row["sGUID"].ToString();
         }
         if (row["fVoltHI"] != null && row["fVoltHI"].ToString() != "")
         {
             model.fVoltHI = decimal.Parse(row["fVoltHI"].ToString());
         }
         if (row["fVoltLO"] != null && row["fVoltLO"].ToString() != "")
         {
             model.fVoltLO = decimal.Parse(row["fVoltLO"].ToString());
         }
         if (row["iAlarmDelayTime"] != null && row["iAlarmDelayTime"].ToString() != "")
         {
             model.iAlarmDelayTime = int.Parse(row["iAlarmDelayTime"].ToString());
         }
         if (row["iMeasureNumber"] != null && row["iMeasureNumber"].ToString() != "")
         {
             model.iMeasureNumber = int.Parse(row["iMeasureNumber"].ToString());
         }
         if (row["iBranchNumber"] != null)
         {
             model.iBranchNumber = row["iBranchNumber"].ToString();
         }
         if (row["iState_Command"] != null && row["iState_Command"].ToString() != "")
         {
             model.iState_Command = int.Parse(row["iState_Command"].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 Add(LumluxSSYDB.Model.tMeasureConfigs model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tMeasureConfigs(");
            strSql.Append("sGUID,fVoltHI,fVoltLO,iAlarmDelayTime,iMeasureNumber,iBranchNumber,iState_Command,dCreateDate,dUpdateTime,sHostInfoGUID,sDesc)");
            strSql.Append(" values (");
            strSql.Append("@sGUID,@fVoltHI,@fVoltLO,@iAlarmDelayTime,@iMeasureNumber,@iBranchNumber,@iState_Command,@dCreateDate,@dUpdateTime,@sHostInfoGUID,@sDesc)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sGUID",           SqlDbType.Char,      36),
                new SqlParameter("@fVoltHI",         SqlDbType.Float,      8),
                new SqlParameter("@fVoltLO",         SqlDbType.Float,      8),
                new SqlParameter("@iAlarmDelayTime", SqlDbType.Int,        4),
                new SqlParameter("@iMeasureNumber",  SqlDbType.Int,        4),
                new SqlParameter("@iBranchNumber",   SqlDbType.Char,      10),
                new SqlParameter("@iState_Command",  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.fVoltHI;
            parameters[2].Value  = model.fVoltLO;
            parameters[3].Value  = model.iAlarmDelayTime;
            parameters[4].Value  = model.iMeasureNumber;
            parameters[5].Value  = model.iBranchNumber;
            parameters[6].Value  = model.iState_Command;
            parameters[7].Value  = model.dCreateDate;
            parameters[8].Value  = model.dUpdateTime;
            parameters[9].Value  = model.sHostInfoGUID;
            parameters[10].Value = model.sDesc;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 通过主机guid得到一个对象实体
        /// </summary>
        public LumluxSSYDB.Model.tMeasureConfigs GetModelByHostGuid(string sHostInfoGUID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 sGUID,fVoltHI,fVoltLO,iAlarmDelayTime,iMeasureNumber,iBranchNumber,iState_Command,dCreateDate,dUpdateTime,sHostInfoGUID,sDesc from tMeasureConfigs ");
            strSql.Append(" where sHostInfoGUID=@sHostInfoGUID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sHostInfoGUID", SqlDbType.Char, 36)
            };
            parameters[0].Value = sHostInfoGUID;

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

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