Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(E_Model.Property model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CMS_PROPERTY(");
            strSql.Append("ID,PROPERTYNAME,PROPERTYTYPE,DESCRIPTION,CREATEDATE,CREATEUSER)");

            strSql.Append(" values (");
            strSql.Append("@ID,@PROPERTYNAME,@PROPERTYTYPE,@DESCRIPTION,@CREATEDATE,@CREATEUSER)");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.AnsiString, model.ID);
            db.AddInParameter(dbCommand, "PROPERTYNAME", DbType.AnsiString, model.PROPERTYNAME);
            db.AddInParameter(dbCommand, "PROPERTYTYPE", DbType.AnsiString, model.PROPERTYTYPE);
            db.AddInParameter(dbCommand, "DESCRIPTION", DbType.AnsiString, model.DESCRIPTION);
            db.AddInParameter(dbCommand, "CREATEDATE", DbType.DateTime, model.CREATEDATE);
            db.AddInParameter(dbCommand, "CREATEUSER", DbType.AnsiString, model.CREATEUSER);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(E_Model.Property model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CMS_PROPERTY set ");
            strSql.Append("PROPERTYNAME=@PROPERTYNAME,");
            strSql.Append("PROPERTYTYPE=@PROPERTYTYPE,");
            strSql.Append("DESCRIPTION=@DESCRIPTION");
            strSql.Append(" where ID=@ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

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

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

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

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