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

            strSql.Append("insert into SYS_DICTIONARY(");
            strSql.Append("ID,DICTIONARYNAME,DICTIONARYVALUE,PARENTID,SORTLIST,DESCRIPTION,CREATEDATE,CREATEUSER)");

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

            db.AddInParameter(dbCommand, "ID", DbType.String, model.ID);
            db.AddInParameter(dbCommand, "DICTIONARYNAME", DbType.String, model.DICTIONARYNAME);
            db.AddInParameter(dbCommand, "DICTIONARYVALUE", DbType.String, model.DICTIONARYVALUE);
            db.AddInParameter(dbCommand, "PARENTID", DbType.String, model.PARENTID);
            db.AddInParameter(dbCommand, "SORTLIST", DbType.Decimal, model.SORTLIST);
            db.AddInParameter(dbCommand, "DESCRIPTION", DbType.String, model.DESCRIPTION);
            db.AddInParameter(dbCommand, "CREATEDATE", DbType.DateTime, model.CREATEDATE);
            db.AddInParameter(dbCommand, "CREATEUSER", DbType.String, model.CREATEUSER);
            int rows = db.ExecuteNonQuery(dbCommand);

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

            strSql.Append("update SYS_DICTIONARY set ");
            strSql.Append("DICTIONARYNAME=:DICTIONARYNAME,");
            strSql.Append("DICTIONARYVALUE=:DICTIONARYVALUE,");
            strSql.Append("PARENTID=:PARENTID,");
            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, "DICTIONARYNAME", DbType.String, model.DICTIONARYNAME);
            db.AddInParameter(dbCommand, "DICTIONARYVALUE", DbType.String, model.DICTIONARYVALUE);
            db.AddInParameter(dbCommand, "PARENTID", DbType.String, model.PARENTID);
            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);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_Model.Dictionary GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,DICTIONARYNAME,DICTIONARYVALUE,PARENTID,SORTLIST,DESCRIPTION,CREATEDATE,CREATEUSER from SYS_DICTIONARY ");
            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.Dictionary model = new E_Model.Dictionary();
            if (DS.Tables[0].Rows.Count == 1)
            {
                model.ID              = DS.Tables[0].Rows[0]["ID"].ToString();
                model.DICTIONARYNAME  = DS.Tables[0].Rows[0]["DICTIONARYNAME"].ToString();
                model.DICTIONARYVALUE = DS.Tables[0].Rows[0]["DICTIONARYVALUE"].ToString();
                model.PARENTID        = DS.Tables[0].Rows[0]["PARENTID"].ToString();
                model.DESCRIPTION     = DS.Tables[0].Rows[0]["DESCRIPTION"].ToString();
                if (model.SORTLIST != null)
                {
                    model.SORTLIST = decimal.Parse(DS.Tables[0].Rows[0]["SORTLIST"].ToString());
                }
                if (model.CREATEDATE != null)
                {
                    model.CREATEDATE = DateTime.Parse(DS.Tables[0].Rows[0]["CREATEDATE"].ToString());
                }
                model.CREATEUSER = DS.Tables[0].Rows[0]["CREATEUSER"].ToString();
            }
            return(model);
        }
Beispiel #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public E_Model.Dictionary DataRowToModel(DataRow row)
 {
     E_Model.Dictionary model = new E_Model.Dictionary();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.ID = row["ID"].ToString();
         }
         if (row["DICTIONARYNAME"] != null)
         {
             model.DICTIONARYNAME = row["DICTIONARYNAME"].ToString();
         }
         if (row["DICTIONARYVALUE"] != null)
         {
             model.DICTIONARYVALUE = row["DICTIONARYVALUE"].ToString();
         }
         if (row["PARENTID"] != null)
         {
             model.PARENTID = row["PARENTID"].ToString();
         }
         if (row["SORTLIST"] != null && row["SORTLIST"].ToString() != "")
         {
             model.SORTLIST = decimal.Parse(row["SORTLIST"].ToString());
         }
         //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);
 }
Beispiel #5
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public E_Model.Dictionary ReaderBind(IDataReader dataReader)
        {
            E_Model.Dictionary model = new E_Model.Dictionary();
            object             ojb;

            model.ID              = dataReader["ID"].ToString();
            model.DICTIONARYNAME  = dataReader["DICTIONARYNAME"].ToString();
            model.DICTIONARYVALUE = dataReader["DICTIONARYVALUE"].ToString();
            model.PARENTID        = dataReader["PARENTID"].ToString();
            ojb = dataReader["SORTLIST"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SORTLIST = (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);
        }
Beispiel #6
0
 public bool Update(E_Model.Dictionary model)
 {
     return(dal.Update(model));
 }
Beispiel #7
0
 public bool Add(E_Model.Dictionary model)
 {
     return(dal.Add(model));
 }