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

            strSql.Append("update InfoLabel set ");
            strSql.Append("IID=@IID,");
            strSql.Append("ALID=@ALID");
            strSql.Append(" where ILID=@ILID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ILID", DbType.Int32, model.ILID);
            db.AddInParameter(dbCommand, "IID", DbType.Int32, model.IID);
            db.AddInParameter(dbCommand, "ALID", DbType.Int32, model.ALID);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.InfoLabel DataRowToModel(DataRow row)
 {
     Model.InfoLabel model = new Model.InfoLabel();
     if (row != null)
     {
         if (row["ILID"] != null && row["ILID"].ToString() != "")
         {
             model.ILID = Convert.ToInt32(row["ILID"].ToString());
         }
         if (row["IID"] != null && row["IID"].ToString() != "")
         {
             model.IID = Convert.ToInt32(row["IID"].ToString());
         }
         if (row["ALID"] != null && row["ALID"].ToString() != "")
         {
             model.ALID = Convert.ToInt32(row["ALID"].ToString());
         }
     }
     return(model);
 }
예제 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.InfoLabel GetModel(int ILID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ILID,IID,ALID from InfoLabel ");
            strSql.Append(" where ILID=@ILID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ILID", DbType.Int32, ILID);
            Model.InfoLabel model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
예제 #4
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Model.InfoLabel ReaderBind(IDataReader dataReader)
        {
            Model.InfoLabel model = new Model.InfoLabel();
            object          ojb;

            ojb = dataReader["ILID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ILID = Convert.ToInt32(ojb);
            }
            ojb = dataReader["IID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IID = Convert.ToInt32(ojb);
            }
            ojb = dataReader["ALID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ALID = Convert.ToInt32(ojb);
            }
            return(model);
        }
예제 #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.InfoLabel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into InfoLabel(");
            strSql.Append("IID,ALID)");

            strSql.Append(" values (");
            strSql.Append("@IID,@ALID)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "IID", DbType.Int32, model.IID);
            db.AddInParameter(dbCommand, "ALID", DbType.Int32, model.ALID);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }