示例#1
0
        /// <summary>
        /// Add one record
        /// </summary>
        public int Add(MDLCAdvertisement model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("INSERT INTO [CAdvertisement](");
            strSql.Append("[AdId],[Title],[Image],[Url],[IsValid],[Sequence]");
            strSql.Append(")");
            strSql.Append(" VALUES (");
            strSql.Append("" + model.AdId + ",");
			strSql.Append("" + model.Title + ",");
			strSql.Append("" + model.Image + ",");
			strSql.Append("" + model.Url + ",");
			strSql.Append("" + model.IsValid + ",");
			strSql.Append("" + model.Sequence + "");
			strSql.Append(")");
            strSql.Append(";SELECT @@IDENTITY");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 1;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
示例#2
0
		/// <summary>
        /// Method to get one recoder by primary key
        /// </summary>    	 
        public MDLCAdvertisement GetModel(int AdId)
        {
			//Set up a return value
            MDLCAdvertisement model = null;

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT [AdId], [Title], [Image], [Url], [IsValid], [Sequence] ");
            strSql.Append(" FROM [CAdvertisement] ");
            strSql.Append(" WHERE [AdId]=" + AdId.ToString());
            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                if (sdr.Read())
                    model = new MDLCAdvertisement(sdr.(0), sdr.(1), sdr.(2), sdr.(3), sdr.(4), sdr.(5));
				else
                    model = new MDLCAdvertisement();                
            }
            return model;
        }
示例#3
0
        /// <summary>
        /// Update one record
        /// </summary>
        public void Update(MDLCAdvertisement model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("UPDATE [CAdvertisement] SET ");
            strSql.Append("[AdId]=" + model.AdId + ",");
			strSql.Append("[Title]=" + model.Title + ",");
			strSql.Append("[Image]=" + model.Image + ",");
			strSql.Append("[Url]=" + model.Url + ",");
			strSql.Append("[IsValid]=" + model.IsValid + ",");
			strSql.Append("[Sequence]=" + model.Sequence + "");
			strSql.Append(" WHERE [AdId]=" + model.AdId + "");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
示例#4
0
 /// <summary>
 /// Update one record
 /// </summary>
 public void Update(MDLCAdvertisement model)
 {
 	dal.Update(model);
 }
示例#5
0
 /// <summary>
 /// Add one record
 /// </summary>
 public int Add(MDLCAdvertisement model)
 {
     return dal.Add(model);
 }