예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.PointRuleDetail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into PointRuleDetail(");
            strSql.Append("RID,UID,AddTime,RxValue,RyValue)");

            strSql.Append(" values (");
            strSql.Append("@RID,@UID,@AddTime,@RxValue,@RyValue)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "RID", DbType.Int32, model.RID);
            db.AddInParameter(dbCommand, "UID", DbType.Int32, model.UID);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "RxValue", DbType.String, model.RxValue);
            db.AddInParameter(dbCommand, "RyValue", DbType.String, model.RyValue);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Model.PointRuleDetail ReaderBind(IDataReader dataReader)
        {
            Model.PointRuleDetail model = new Model.PointRuleDetail();
            object ojb;

            ojb = dataReader["RDID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RDID = Convert.ToInt32(ojb);
            }
            ojb = dataReader["RID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RID = Convert.ToInt32(ojb);
            }
            ojb = dataReader["UID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UID = Convert.ToInt32(ojb);
            }
            ojb = dataReader["AddTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AddTime = Convert.ToDateTime(ojb);
            }
            model.RxValue = dataReader["RxValue"].ToString();
            model.RyValue = dataReader["RyValue"].ToString();
            return(model);
        }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.PointRuleDetail DataRowToModel(DataRow row)
 {
     Model.PointRuleDetail model = new Model.PointRuleDetail();
     if (row != null)
     {
         if (row["RDID"] != null && row["RDID"].ToString() != "")
         {
             model.RDID = Convert.ToInt32(row["RDID"].ToString());
         }
         if (row["RID"] != null && row["RID"].ToString() != "")
         {
             model.RID = Convert.ToInt32(row["RID"].ToString());
         }
         if (row["UID"] != null && row["UID"].ToString() != "")
         {
             model.UID = Convert.ToInt32(row["UID"].ToString());
         }
         if (row["AddTime"] != null && row["AddTime"].ToString() != "")
         {
             model.AddTime = Convert.ToDateTime(row["AddTime"].ToString());
         }
         if (row["RxValue"] != null)
         {
             model.RxValue = row["RxValue"].ToString();
         }
         if (row["RyValue"] != null)
         {
             model.RyValue = row["RyValue"].ToString();
         }
     }
     return(model);
 }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.PointRuleDetail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update PointRuleDetail set ");
            strSql.Append("RID=@RID,");
            strSql.Append("UID=@UID,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("RxValue=@RxValue,");
            strSql.Append("RyValue=@RyValue");
            strSql.Append(" where RDID=@RDID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "RDID", DbType.Int32, model.RDID);
            db.AddInParameter(dbCommand, "RID", DbType.Int32, model.RID);
            db.AddInParameter(dbCommand, "UID", DbType.Int32, model.UID);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "RxValue", DbType.String, model.RxValue);
            db.AddInParameter(dbCommand, "RyValue", DbType.String, model.RyValue);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.PointRuleDetail GetModel(int RDID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select RDID,RID,UID,AddTime,RxValue,RyValue from PointRuleDetail ");
            strSql.Append(" where RDID=@RDID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "RDID", DbType.Int32, RDID);
            Model.PointRuleDetail model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }