Example #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LumluxSSYDB.Model.tCMDRevs DataRowToModel(DataRow row)
 {
     LumluxSSYDB.Model.tCMDRevs model = new LumluxSSYDB.Model.tCMDRevs();
     if (row != null)
     {
         if (row["sGUID"] != null)
         {
             model.sGUID = row["sGUID"].ToString();
         }
         if (row["iContentType"] != null && row["iContentType"].ToString() != "")
         {
             model.iContentType = int.Parse(row["iContentType"].ToString());
         }
         if (row["sContent"] != null)
         {
             model.sContent = row["sContent"].ToString();
         }
         if (row["iState"] != null && row["iState"].ToString() != "")
         {
             model.iState = int.Parse(row["iState"].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["iHostIDType"] != null && row["iHostIDType"].ToString() != "")
         {
             model.iHostIDType = int.Parse(row["iHostIDType"].ToString());
         }
         if (row["sHostIDAddr"] != null)
         {
             model.sHostIDAddr = row["sHostIDAddr"].ToString();
         }
         if (row["sHostIDID"] != null)
         {
             model.sHostIDID = row["sHostIDID"].ToString();
         }
         if (row["sHostIDSIM"] != null)
         {
             model.sHostIDSIM = row["sHostIDSIM"].ToString();
         }
         if (row["sHostIDIP"] != null)
         {
             model.sHostIDIP = row["sHostIDIP"].ToString();
         }
         if (row["sHostIDMAC"] != null)
         {
             model.sHostIDMAC = row["sHostIDMAC"].ToString();
         }
     }
     return(model);
 }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LumluxSSYDB.Model.tCMDRevs model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tCMDRevs set ");
            strSql.Append("iContentType=@iContentType,");
            strSql.Append("sContent=@sContent,");
            strSql.Append("iState=@iState,");
            strSql.Append("dCreateDate=@dCreateDate,");
            strSql.Append("dUpdateTime=@dUpdateTime,");
            strSql.Append("iHostIDType=@iHostIDType,");
            strSql.Append("sHostIDAddr=@sHostIDAddr,");
            strSql.Append("sHostIDID=@sHostIDID,");
            strSql.Append("sHostIDSIM=@sHostIDSIM,");
            strSql.Append("sHostIDIP=@sHostIDIP,");
            strSql.Append("sHostIDMAC=@sHostIDMAC");
            strSql.Append(" where sGUID=@sGUID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@iContentType", SqlDbType.Int,         4),
                new SqlParameter("@sContent",     SqlDbType.NVarChar,  500),
                new SqlParameter("@iState",       SqlDbType.Int,         4),
                new SqlParameter("@dCreateDate",  SqlDbType.DateTime),
                new SqlParameter("@dUpdateTime",  SqlDbType.DateTime),
                new SqlParameter("@iHostIDType",  SqlDbType.Int,         4),
                new SqlParameter("@sHostIDAddr",  SqlDbType.NVarChar,  100),
                new SqlParameter("@sHostIDID",    SqlDbType.NVarChar,  100),
                new SqlParameter("@sHostIDSIM",   SqlDbType.NVarChar,  100),
                new SqlParameter("@sHostIDIP",    SqlDbType.NVarChar,  100),
                new SqlParameter("@sHostIDMAC",   SqlDbType.NVarChar,  100),
                new SqlParameter("@sGUID",        SqlDbType.Char, 36)
            };
            parameters[0].Value  = model.iContentType;
            parameters[1].Value  = model.sContent;
            parameters[2].Value  = model.iState;
            parameters[3].Value  = model.dCreateDate;
            parameters[4].Value  = model.dUpdateTime;
            parameters[5].Value  = model.iHostIDType;
            parameters[6].Value  = model.sHostIDAddr;
            parameters[7].Value  = model.sHostIDID;
            parameters[8].Value  = model.sHostIDSIM;
            parameters[9].Value  = model.sHostIDIP;
            parameters[10].Value = model.sHostIDMAC;
            parameters[11].Value = model.sGUID;

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

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

            strSql.Append("insert into tCMDRevs(");
            strSql.Append("sGUID,iContentType,sContent,iState,dCreateDate,dUpdateTime,iHostIDType,sHostIDAddr,sHostIDID,sHostIDSIM,sHostIDIP,sHostIDMAC)");
            strSql.Append(" values (");
            strSql.Append("@sGUID,@iContentType,@sContent,@iState,@dCreateDate,@dUpdateTime,@iHostIDType,@sHostIDAddr,@sHostIDID,@sHostIDSIM,@sHostIDIP,@sHostIDMAC)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sGUID",        SqlDbType.Char,       36),
                new SqlParameter("@iContentType", SqlDbType.Int,         4),
                new SqlParameter("@sContent",     SqlDbType.NVarChar,  500),
                new SqlParameter("@iState",       SqlDbType.Int,         4),
                new SqlParameter("@dCreateDate",  SqlDbType.DateTime),
                new SqlParameter("@dUpdateTime",  SqlDbType.DateTime),
                new SqlParameter("@iHostIDType",  SqlDbType.Int,         4),
                new SqlParameter("@sHostIDAddr",  SqlDbType.NVarChar,  100),
                new SqlParameter("@sHostIDID",    SqlDbType.NVarChar,  100),
                new SqlParameter("@sHostIDSIM",   SqlDbType.NVarChar,  100),
                new SqlParameter("@sHostIDIP",    SqlDbType.NVarChar,  100),
                new SqlParameter("@sHostIDMAC",   SqlDbType.NVarChar, 100)
            };
            parameters[0].Value  = model.sGUID;
            parameters[1].Value  = model.iContentType;
            parameters[2].Value  = model.sContent;
            parameters[3].Value  = model.iState;
            parameters[4].Value  = model.dCreateDate;
            parameters[5].Value  = model.dUpdateTime;
            parameters[6].Value  = model.iHostIDType;
            parameters[7].Value  = model.sHostIDAddr;
            parameters[8].Value  = model.sHostIDID;
            parameters[9].Value  = model.sHostIDSIM;
            parameters[10].Value = model.sHostIDIP;
            parameters[11].Value = model.sHostIDMAC;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 获得某类型的返回数据
        /// </summary>
        /// <param name="ContentType">数据类型</param>
        /// <param name="hostidid">主机idid</param>
        /// <param name="second">提前的时间</param>
        /// <returns></returns>
        public Model.tCMDRevs GetCMDRecive(int?ContentType, string hostidid, int second)
        {
            DateTime      dtNow  = DateTime.Now.AddSeconds(-second);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 sGUID,iContentType,sContent,iState,dCreateDate,dUpdateTime,iHostIDType,sHostIDAddr,sHostIDID,sHostIDSIM,sHostIDIP,sHostIDMAC from tCMDRevs ");
            strSql.Append(" where iState = 0 and dCreateDate > '" + dtNow.ToString() + "' and sHostIDID = '" + hostidid + "' and iContentType = '" + ContentType.ToString() + "'");

            LumluxSSYDB.Model.tCMDRevs model = new LumluxSSYDB.Model.tCMDRevs();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LumluxSSYDB.Model.tCMDRevs GetModel(string sGUID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 sGUID,iContentType,sContent,iState,dCreateDate,dUpdateTime,iHostIDType,sHostIDAddr,sHostIDID,sHostIDSIM,sHostIDIP,sHostIDMAC from tCMDRevs ");
            strSql.Append(" where sGUID=@sGUID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sGUID", SqlDbType.Char, 36)
            };
            parameters[0].Value = sGUID;

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

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