public ActionResult AddFlashSales(FlashSales flashSales) { string kstr = ""; bool IsSuccess = true; if (string.IsNullOrEmpty(flashSales.Name)) { kstr = "模块名称不能为空"; IsSuccess = false; } if (IsSuccess) { if (flashSales.PKID == 0) { manager.AddFlashSales(flashSales); } else { manager.UpdateFlashSales(flashSales); } return(RedirectToAction("FlashSales")); } else { string js = "<script>alert(\"" + kstr + "\");location='FlashSales';</script>"; return(Content(js)); } }
public ActionResult AddFlashSales(int?id, string EnID) { if (id.HasValue && id.Value != 0) { ViewBag.Title = "修改抢购活动"; return(View(manager.GetFlashSalesByID(id.Value))); } else { if (!string.IsNullOrEmpty(EnID)) { ViewBag.Title = "新增抢购活动"; FlashSales _Model = new FlashSales() { PKID = 0, StartTime = DateTime.Now, CountDown = 24, Position = 0, DisplayColumn = 1, IsBanner = false, Status = 0, IsTomorrowTextActive = false }; return(View(_Model)); } else { return(Content("请选择要添加抢购活动的类型")); } } }
/// <summary> /// 修改FlashSales /// </summary> /// <param name="advertise">FlashSales对象</param> public static void UpdateFlashSales(SqlConnection connection, FlashSales flashSales) { var sqlParamters = new[] { new SqlParameter("@PKID", flashSales.PKID), new SqlParameter("@EnID", flashSales.EnID), new SqlParameter("@StartTime", flashSales.StartTime), new SqlParameter("@CountDown", flashSales.CountDown), new SqlParameter("@Name", flashSales.Name ?? string.Empty), new SqlParameter("@PictureUrl", flashSales.PictureUrl ?? string.Empty), new SqlParameter("@Position", flashSales.Position), new SqlParameter("@DisplayColumn", flashSales.DisplayColumn), new SqlParameter("@AppValue", flashSales.AppValue ?? string.Empty), new SqlParameter("@IsBanner", flashSales.IsBanner), new SqlParameter("@BannerUrl", flashSales.BannerUrl ?? string.Empty), new SqlParameter("@BackgoundColor", flashSales.BackgoundColor ?? string.Empty), new SqlParameter("@TomorrowText", flashSales.TomorrowText ?? string.Empty), new SqlParameter("@Status", flashSales.Status), new SqlParameter("@IsTomorrowTextActive", flashSales.IsTomorrowTextActive), }; SqlHelper.ExecuteNonQuery(connection, CommandType.Text, @"update Marketing.dbo.tbl_FlashSales set EnID=@EnID,StartTime=@StartTime,CountDown=@CountDown,Name=@Name ,PictureUrl=@PictureUrl,Position=@Position,DisplayColumn=@DisplayColumn,AppValue=@AppValue,IsBanner=@IsBanner ,BannerUrl=@BannerUrl,BackgoundColor=@BackgoundColor,TomorrowText=@TomorrowText,Status=@Status,IsTomorrowTextActive=@IsTomorrowTextActive where PKID=@PKID", sqlParamters); }
/// <summary> /// 添加FlashSales /// </summary> /// <param name="advertise">FlashSales对象</param> public static void AddFlashSales(SqlConnection connection, FlashSales flashSales) { var sqlParamters = new[] { new SqlParameter("@EnID", flashSales.EnID), new SqlParameter("@StartTime", flashSales.StartTime), new SqlParameter("@CountDown", flashSales.CountDown), new SqlParameter("@Name", flashSales.Name ?? string.Empty), new SqlParameter("@PictureUrl", flashSales.PictureUrl ?? string.Empty), new SqlParameter("@Position", flashSales.Position), new SqlParameter("@DisplayColumn", flashSales.DisplayColumn), new SqlParameter("@AppValue", flashSales.AppValue ?? string.Empty), new SqlParameter("@IsBanner", flashSales.IsBanner), new SqlParameter("@BannerUrl", flashSales.BannerUrl ?? string.Empty), new SqlParameter("@BackgoundColor", flashSales.BackgoundColor ?? string.Empty), new SqlParameter("@TomorrowText", flashSales.TomorrowText ?? string.Empty), new SqlParameter("@Status", flashSales.Status), new SqlParameter("@IsTomorrowTextActive", flashSales.IsTomorrowTextActive), }; SqlHelper.ExecuteNonQuery(connection, CommandType.Text, @"insert into Marketing.dbo.tbl_FlashSales(EnID,StartTime,CountDown,Name,PictureUrl,Position,DisplayColumn,AppValue,IsBanner,BannerUrl,BackgoundColor,TomorrowText,Status,IsTomorrowTextActive) values (@EnID,@StartTime,@CountDown,@Name,@PictureUrl,@Position,@DisplayColumn,@AppValue,@IsBanner,@BannerUrl,@BackgoundColor,@TomorrowText,@Status,@IsTomorrowTextActive)" , sqlParamters); }
/// <summary> /// 根据id获取FlashSales对象 /// </summary> /// <param name="advertise">FlashSales对象</param> public static FlashSales GetFlashSalesByID(SqlConnection connection, int id) { FlashSales _FlashSales = null; var parameters = new[] { new SqlParameter("@PKID", id) }; using (var _DR = SqlHelper.ExecuteReader(connection, CommandType.Text, @"SELECT TOP 1 PKID ,EnID ,StartTime ,CountDown ,Name ,PictureUrl ,Position ,DisplayColumn ,AppValue ,IsBanner ,BannerUrl ,BackgoundColor ,TomorrowText ,Status ,IsTomorrowTextActive FROM Marketing.dbo.tbl_FlashSales WITH (NOLOCK) WHERE PKID=@PKID", parameters)) { if (_DR.Read()) { _FlashSales = new FlashSales(); _FlashSales.PKID = _DR.GetTuhuValue <int>(0); _FlashSales.EnID = _DR.GetTuhuString(1); _FlashSales.StartTime = _DR.GetTuhuValue <System.DateTime>(2); _FlashSales.CountDown = _DR.GetTuhuValue <int>(3); _FlashSales.Name = _DR.GetTuhuString(4); _FlashSales.PictureUrl = _DR.GetTuhuString(5); _FlashSales.Position = _DR.GetTuhuValue <int>(6); _FlashSales.DisplayColumn = _DR.GetTuhuValue <int>(7); _FlashSales.AppValue = _DR.GetTuhuString(8); _FlashSales.IsBanner = _DR.GetTuhuValue <bool>(9); _FlashSales.BannerUrl = _DR.GetTuhuString(10); _FlashSales.BackgoundColor = _DR.GetTuhuString(11); _FlashSales.TomorrowText = _DR.GetTuhuString(12); _FlashSales.Status = _DR.GetTuhuValue <byte>(13); _FlashSales.IsTomorrowTextActive = _DR.GetTuhuValue <bool>(14); } } return(_FlashSales); }
public ActionResult FlashSalesProduct(int?FlashSalesID) { if (FlashSalesID.HasValue) { int _FlashSalesID = FlashSalesID.Value; FlashSales _FlashSales = manager.GetFlashSalesByID(_FlashSalesID); if (_FlashSales != null) { List <FlashSalesProduct> _ProList = manager.GetProListByFlashSalesID(_FlashSalesID); ViewBag.FlashSales = _FlashSales; ViewBag.ProList = _ProList; return(View()); } else { return(Content("<script>alert('该活动不存在,请确认该活动是否被删除');location='/FlashSales/FlashSales';</script>")); } } else { return(Content("<script>alert('该活动不存在,请从正常来源进入');location='/FlashSales/FlashSales'</script>")); } }
public void UpdateFlashSales(FlashSales flashSales) { handler.UpdateFlashSales(flashSales); }
public void AddFlashSales(FlashSales flashSales) { handler.AddFlashSales(flashSales); }
public void UpdateFlashSales(FlashSales flashSales) { Action <SqlConnection> action = (connection) => DalFlashSales.UpdateFlashSales(connection, flashSales); dbManager.Execute(action); }