Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(RS485AddressEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into RS485Addr(");
            strSql.Append("RS485Addr)");
            strSql.Append(" values (");
            strSql.Append("@RS485Addr)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RS485Addr", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RS485Addr;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RS485AddressEntity DataRowToModel(DataRow row)
        {
            RS485AddressEntity model = new RS485AddressEntity();

            if (row != null)
            {
                if (row["RS485Addr"] != null && row["RS485Addr"].ToString() != "")
                {
                    model.RS485Addr = int.Parse(row["RS485Addr"].ToString());
                }
            }
            return(model);
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RS485AddressEntity GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 RS485Addr from RS485Addr ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

            RS485AddressEntity model = new RS485AddressEntity();
            DataSet            ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(RS485AddressEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update RS485Addr set ");
            strSql.Append("RS485Addr=@RS485Addr");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RS485Addr", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RS485Addr;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(RS485AddressEntity model)
 {
     return(dal.Update(model));
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(RS485AddressEntity model)
 {
     return(dal.Add(model));
 }