Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(E_Model.Link model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CMS_LINK set ");
            strSql.Append("LINKENAME=@LINKENAME,");
            strSql.Append("LINKURL=@LINKURL,");
            strSql.Append("LINKIMAGE=@LINKIMAGE,");
            strSql.Append("DESCRIPTION=@DESCRIPTION");
            strSql.Append(" where ID=@ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "LINKENAME", DbType.AnsiString, model.LINKENAME);
            db.AddInParameter(dbCommand, "LINKURL", DbType.AnsiString, model.LINKURL);
            db.AddInParameter(dbCommand, "LINKIMAGE", DbType.AnsiString, model.LINKIMAGE);
            db.AddInParameter(dbCommand, "DESCRIPTION", DbType.AnsiString, model.DESCRIPTION);
            db.AddInParameter(dbCommand, "ID", DbType.AnsiString, model.ID);
            int rows = db.ExecuteNonQuery(dbCommand);

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

            strSql.Append("insert into CMS_LINK(");
            strSql.Append("ID,LINKENAME,LINKURL,LINKIMAGE,STATUS,DESCRIPTION,CREATEDATE)");

            strSql.Append(" values (");
            strSql.Append("@ID,@LINKENAME,@LINKURL,@LINKIMAGE,@STATUS,@DESCRIPTION,@CREATEDATE)");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.AnsiString, model.ID);
            db.AddInParameter(dbCommand, "LINKENAME", DbType.AnsiString, model.LINKENAME);
            db.AddInParameter(dbCommand, "LINKURL", DbType.AnsiString, model.LINKURL);
            db.AddInParameter(dbCommand, "LINKIMAGE", DbType.AnsiString, model.LINKIMAGE);
            db.AddInParameter(dbCommand, "STATUS", DbType.AnsiString, model.STATUS);
            db.AddInParameter(dbCommand, "DESCRIPTION", DbType.AnsiString, model.DESCRIPTION);
            db.AddInParameter(dbCommand, "CREATEDATE", DbType.DateTime, model.CREATEDATE);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public E_Model.Link ReaderBind(IDataReader dataReader)
        {
            E_Model.Link model = new E_Model.Link();
            object       ojb;

            model.ID          = dataReader["ID"].ToString();
            model.LINKENAME   = dataReader["LINKENAME"].ToString();
            model.LINKURL     = dataReader["LINKURL"].ToString();
            model.LINKIMAGE   = dataReader["LINKIMAGE"].ToString();
            model.STATUS      = dataReader["STATUS"].ToString();
            model.DESCRIPTION = dataReader["DESCRIPTION"].ToString();
            ojb = dataReader["CREATEDATE"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CREATEDATE = (DateTime)ojb;
            }
            return(model);
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_Model.Link GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from CMS_LINK ");
            strSql.Append(" where ID=@ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.AnsiString, ID);
            E_Model.Link model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Example #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public E_Model.Link DataRowToModel(DataRow row)
 {
     E_Model.Link model = new E_Model.Link();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.ID = row["ID"].ToString();
         }
         if (row["LINKENAME"] != null)
         {
             model.LINKENAME = row["LINKENAME"].ToString();
         }
         if (row["LINKURL"] != null)
         {
             model.LINKURL = row["LINKURL"].ToString();
         }
         if (row["LINKIMAGE"] != null)
         {
             model.LINKIMAGE = row["LINKIMAGE"].ToString();
         }
         if (row["STATUS"] != null)
         {
             model.STATUS = row["STATUS"].ToString();
         }
         if (row["DESCRIPTION"] != null)
         {
             model.DESCRIPTION = row["DESCRIPTION"].ToString();
         }
         if (row["CREATEDATE"] != null && row["CREATEDATE"].ToString() != "")
         {
             model.CREATEDATE = DateTime.Parse(row["CREATEDATE"].ToString());
         }
     }
     return(model);
 }
Example #6
0
 public bool Update(E_Model.Link model)
 {
     return(dal.Update(model));
 }
Example #7
0
 public bool Add(E_Model.Link model)
 {
     return(dal.Add(model));
 }