Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(E_Model.WebSite model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CMS_WEBSITE set ");
            strSql.Append("WEBNAME=@WEBNAME,");
            strSql.Append("PARENTID=@PARENTID,");
            strSql.Append("TEMPLATEID=@TEMPLATEID,");
            strSql.Append("DESCRIPTION=@DESCRIPTION");
            strSql.Append(" where ID=@ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "WEBNAME", DbType.AnsiString, model.WEBNAME);
            db.AddInParameter(dbCommand, "PARENTID", DbType.AnsiString, model.PARENTID);
            db.AddInParameter(dbCommand, "TEMPLATEID", DbType.AnsiString, model.TEMPLATEID);
            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);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(E_Model.WebSite model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CMS_WEBSITE(");
            strSql.Append("ID,WEBNAME,PARENTID,TEMPLATEID,STATUS,DESCRIPTION,CREATEDATE,CREATEUSER,WEBCODE)");

            strSql.Append(" values (");
            strSql.Append("@ID,@WEBNAME,@PARENTID,@TEMPLATEID,@STATUS,@DESCRIPTION,@CREATEDATE,@CREATEUSER,@WEBCODE)");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.AnsiString, model.ID);
            db.AddInParameter(dbCommand, "WEBNAME", DbType.AnsiString, model.WEBNAME);
            db.AddInParameter(dbCommand, "PARENTID", DbType.AnsiString, model.PARENTID);
            db.AddInParameter(dbCommand, "TEMPLATEID", DbType.AnsiString, model.TEMPLATEID);
            db.AddInParameter(dbCommand, "STATUS", DbType.AnsiString, model.STATUS);
            db.AddInParameter(dbCommand, "DESCRIPTION", DbType.AnsiString, model.DESCRIPTION);
            db.AddInParameter(dbCommand, "CREATEDATE", DbType.DateTime, model.CREATEDATE);
            db.AddInParameter(dbCommand, "CREATEUSER", DbType.AnsiString, model.CREATEUSER);
            db.AddInParameter(dbCommand, "WEBCODE", DbType.AnsiString, model.WEBCODE);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public E_Model.WebSite DataRowToModel(DataRow row)
 {
     E_Model.WebSite model = new E_Model.WebSite();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.ID = row["ID"].ToString();
         }
         if (row["WEBNAME"] != null)
         {
             model.WEBNAME = row["WEBNAME"].ToString();
         }
         if (row["PARENTID"] != null)
         {
             model.PARENTID = row["PARENTID"].ToString();
         }
         if (row["TEMPLATEID"] != null)
         {
             model.TEMPLATEID = row["TEMPLATEID"].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());
         }
         if (row["CREATEUSER"] != null)
         {
             model.CREATEUSER = row["CREATEUSER"].ToString();
         }
         if (row["WEBCODE"] != null)
         {
             model.WEBCODE = row["WEBCODE"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public E_Model.WebSite ReaderBind(IDataReader dataReader)
        {
            E_Model.WebSite model = new E_Model.WebSite();
            object          ojb;

            model.ID          = dataReader["ID"].ToString();
            model.WEBNAME     = dataReader["WEBNAME"].ToString();
            model.PARENTID    = dataReader["PARENTID"].ToString();
            model.TEMPLATEID  = dataReader["TEMPLATEID"].ToString();
            model.STATUS      = dataReader["STATUS"].ToString();
            model.DESCRIPTION = dataReader["DESCRIPTION"].ToString();
            ojb = dataReader["CREATEDATE"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CREATEDATE = (DateTime)ojb;
            }
            model.CREATEUSER = dataReader["CREATEUSER"].ToString();
            model.WEBCODE    = dataReader["WEBCODE"].ToString();
            return(model);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_Model.WebSite GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

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

            db.AddInParameter(dbCommand, "ID", DbType.AnsiString, ID);
            E_Model.WebSite model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Ejemplo n.º 6
0
 public bool Update(E_Model.WebSite model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 7
0
 public bool Add(E_Model.WebSite model)
 {
     return(dal.Add(model));
 }