Beispiel #1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Mxm.Model.art_type ReaderBind(IDataReader dataReader)
        {
            Mxm.Model.art_type model = new Mxm.Model.art_type();
            object             ojb;

            ojb = dataReader["type_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.type_id = (int)ojb;
            }
            model.type_name = dataReader["type_name"].ToString();
            return(model);
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Mxm.Model.art_type model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update art_type set ");
            strSql.Append("type_name=@type_name");
            strSql.Append(" where type_id=@type_id ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "type_id", DbType.Int32, model.type_id);
            db.AddInParameter(dbCommand, "type_name", DbType.String, model.type_name);
            db.ExecuteNonQuery(dbCommand);
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Mxm.Model.art_type GetModel(int type_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select type_id,type_name from art_type ");
            strSql.Append(" where type_id=@type_id ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "type_id", DbType.Int32, type_id);
            Mxm.Model.art_type model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Mxm.Model.art_type model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into art_type(");
            strSql.Append("type_name)");

            strSql.Append(" values (");
            strSql.Append("@type_name)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "type_name", DbType.String, model.type_name);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
Beispiel #5
0
 /// <summary>
 /// ����ʵ�������
 /// </summary>
 public Mxm.Model.art_type ReaderBind(IDataReader dataReader)
 {
     Mxm.Model.art_type model=new Mxm.Model.art_type();
     object ojb;
     ojb = dataReader["type_id"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.type_id=(int)ojb;
     }
     model.type_name=dataReader["type_name"].ToString();
     return model;
 }