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

            strSql.Append("update SYS_MAIN set ");
            strSql.Append("MAINNAME=:MAINNAME,");
            strSql.Append("MAINICON=:MAINICON,");
            strSql.Append("PARENTID=:PARENTID,");
            strSql.Append("MAINURL=:MAINURL,");
            strSql.Append("SORTLIST=:SORTLIST,");
            strSql.Append("DESCRIPTION=:DESCRIPTION ");
            strSql.Append(" where ID=:ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "MAINNAME", DbType.String, model.MAINNAME);
            db.AddInParameter(dbCommand, "MAINICON", DbType.String, model.MAINICON);
            db.AddInParameter(dbCommand, "PARENTID", DbType.String, model.PARENTID);
            db.AddInParameter(dbCommand, "MAINURL", DbType.String, model.MAINURL);
            db.AddInParameter(dbCommand, "SORTLIST", DbType.Decimal, model.SORTLIST);
            db.AddInParameter(dbCommand, "DESCRIPTION", DbType.String, model.DESCRIPTION);
            db.AddInParameter(dbCommand, "ID", DbType.String, model.ID);
            int rows = db.ExecuteNonQuery(dbCommand);

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

            model.ID       = dataReader["ID"].ToString();
            model.MAINNAME = dataReader["MAINNAME"].ToString();
            model.MAINICON = dataReader["MAINICON"].ToString();
            model.PARENTID = dataReader["PARENTID"].ToString();
            model.MAINURL  = dataReader["MAINURL"].ToString();
            ojb            = dataReader["SORTLIST"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SORTLIST = (decimal)ojb;
            }
            ojb = dataReader["STATUS"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.STATUS = (decimal)ojb;
            }
            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);
        }
예제 #3
0
        public bool Add(E_Model.Main model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SYS_MAIN(");
            strSql.Append("ID,MAINNAME,MAINICON,PARENTID,MAINURL,SORTLIST,STATUS,DESCRIPTION,CREATEDATE,CREATEUSER)");

            strSql.Append(" values (");
            strSql.Append(":ID,:MAINNAME,:MAINICON,:PARENTID,:MAINURL,:SORTLIST,:STATUS,:DESCRIPTION,:CREATEDATE,:CREATEUSER)");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.String, model.ID);
            db.AddInParameter(dbCommand, "MAINNAME", DbType.String, model.MAINNAME);
            db.AddInParameter(dbCommand, "MAINICON", DbType.String, model.MAINICON);
            db.AddInParameter(dbCommand, "PARENTID", DbType.String, model.PARENTID);
            db.AddInParameter(dbCommand, "MAINURL", DbType.String, model.MAINURL);
            db.AddInParameter(dbCommand, "SORTLIST", DbType.Decimal, model.SORTLIST);
            db.AddInParameter(dbCommand, "STATUS", DbType.Decimal, model.STATUS);
            db.AddInParameter(dbCommand, "DESCRIPTION", DbType.String, model.DESCRIPTION);
            db.AddInParameter(dbCommand, "CREATEDATE", DbType.Date, model.CREATEDATE);
            db.AddInParameter(dbCommand, "CREATEUSER", DbType.String, model.CREATEUSER);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_Model.Main GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,MAINNAME,MAINICON,PARENTID,MAINURL,SORTLIST,STATUS,DESCRIPTION,CREATEDATE,CREATEUSER from SYS_MAIN ");
            strSql.Append(" where ID= '" + ID + "' ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            DataSet   DS        = db.ExecuteDataSet(CommandType.Text, strSql.ToString());

            E_Model.Main model = new E_Model.Main();
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
예제 #5
0
 public bool Update(E_Model.Main model)
 {
     return(dal.Update(model));
 }
예제 #6
0
 public bool Add(E_Model.Main model)
 {
     return(dal.Add(model));
 }