Пример #1
0
 /// <summary>
 /// 添加或编辑广告信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static AdDeliveryInfo Create(AdDeliveryInfo model) {
     if (model.Id == 0)
     {
         int id = AdDeliveryManage.Insert(model);
     }
     else {
         AdDeliveryManage.Update(model);
     }
     return model;
 }
Пример #2
0
 /// <summary>
 /// 更新广告
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Update(AdDeliveryInfo model) {
     string strSQL = "UPDATE dbo.AdDelivery SET AdPositionId = @AdPositionId ,Name = @Name WHERE Id = @Id";
     SqlParameter[] parms = { 
                             new SqlParameter("AdPositionId",SqlDbType.Int),
                             new SqlParameter("Name",SqlDbType.NVarChar),
                             new SqlParameter("Id",SqlDbType.Int),
                            };
     parms[0].Value = model.AdPositionId;
     parms[1].Value = model.Name;
     parms[2].Value = model.Id;
     return Goodspeed.Library.Data.SQLPlus.ExecuteNonQuery(CommandType.Text,strSQL,parms);
 }
Пример #3
0
 /// <summary>
 /// 新建广告
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Insert(AdDeliveryInfo model) {
     string strSQL = "INSERT INTO dbo.AdDelivery(AdPositionId,Name) VALUES(@AdPositionId,@Name);SELECT @@IDENTITY;";
     SqlParameter[] parms = { 
                             new SqlParameter("AdPositionId",SqlDbType.Int),
                             new SqlParameter("Name",SqlDbType.NVarChar),
                             
                            };
     parms[0].Value = model.AdPositionId;
     parms[1].Value = model.Name;
     
     return Convert.ToInt32(Goodspeed.Library.Data.SQLPlus.ExecuteScalar(CommandType.Text,strSQL,parms));
 }
Пример #4
0
        private void Update(AdDeliveryInfo model) {
            bool errors = false;
            if (string.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError("Name", "广告名称不能为空");
                errors = true;
            }
            if(model.AdPositionId ==0){
                ModelState.AddModelError("AdPositionId", "请选择目标广告位");
                errors = true;
            }
            if (ModelState.IsValid && !errors)
            {
                AdDeliveryService.Create(model);

                ViewBag.Msg = "保存成功!<a href=\"list\">返回</a>";
            }
            var adPositionModel = AdPositionService.Get(model.AdPositionId);
            ViewBag.AdPositionModel = adPositionModel;
        }
Пример #5
0
 private static AdDeliveryInfo GetByRow(DataRow dr) {
     if (dr == null) { return new AdDeliveryInfo(); }
     var model = new AdDeliveryInfo() { 
         Id = dr.Field<int>("Id"),
         AdPositionId = dr.Field<int>("AdPositionId"),
         Name = dr.Field<string>("Name"),
         BeginTime = dr.Field<string>("BeginTime"),
         EndTime = dr.Field<string>("EndTime"),
         CreateDateTime = dr.Field<DateTime>("CreateDateTime")
     };
     return model;
 }
Пример #6
0
        public ActionResult Modify(AdDeliveryInfo model) {
            Update(model);

            return View("Create",model);
        }
Пример #7
0
 public ActionResult Create(AdDeliveryInfo model) {
     Update(model);
     return View(model);
 }