コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(E_Model.ECode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CMS_CODE set ");
            strSql.Append("CODENAME=@CODENAME,");
            strSql.Append("CODEIMAGE=@CODEIMAGE,");
            strSql.Append("DESCRIPTION=@DESCRIPTION");
            strSql.Append(" where ID=@ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "CODENAME", DbType.AnsiString, model.CODENAME);
            db.AddInParameter(dbCommand, "CODEIMAGE", DbType.AnsiString, model.CODEIMAGE);
            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);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(E_Model.ECode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CMS_CODE(");
            strSql.Append("ID,CODENAME,CODEIMAGE,STATUS,DESCRIPTION,CREATEDATE)");

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

            db.AddInParameter(dbCommand, "ID", DbType.AnsiString, model.ID);
            db.AddInParameter(dbCommand, "CODENAME", DbType.AnsiString, model.CODENAME);
            db.AddInParameter(dbCommand, "CODEIMAGE", DbType.AnsiString, model.CODEIMAGE);
            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);
            }
        }
コード例 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public E_Model.ECode DataRowToModel(DataRow row)
 {
     E_Model.ECode model = new E_Model.ECode();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.ID = row["ID"].ToString();
         }
         if (row["CODENAME"] != null)
         {
             model.CODENAME = row["CODENAME"].ToString();
         }
         if (row["CODEIMAGE"] != null)
         {
             model.CODEIMAGE = row["CODEIMAGE"].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);
 }
コード例 #4
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public E_Model.ECode ReaderBind(IDataReader dataReader)
        {
            E_Model.ECode model = new E_Model.ECode();
            object        ojb;

            model.ID          = dataReader["ID"].ToString();
            model.CODENAME    = dataReader["CODENAME"].ToString();
            model.CODEIMAGE   = dataReader["CODEIMAGE"].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);
        }
コード例 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_Model.ECode GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

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

            db.AddInParameter(dbCommand, "ID", DbType.AnsiString, ID);
            E_Model.ECode model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
コード例 #6
0
 public bool Update(E_Model.ECode model)
 {
     return(dal.Update(model));
 }
コード例 #7
0
 public bool Add(E_Model.ECode model)
 {
     return(dal.Add(model));
 }