private void EditActInfo_Click(object sender, EventArgs e) { #region 更新公告相关信息 if (this.CheckCookie()) { ActivityInfo activityInfo = new ActivityInfo(); activityInfo.Id = SASRequest.GetInt("id", 0); if (templatenew.Text == "") { base.RegisterStartupScript("", "<script>alert('请添加活动页面内容,内容不可为空!');</script>"); return; } //获取生效与结束日期 string starttimestr = postdatetimeStart.SelectedDate.ToString(); string endtimestr = postdatetimeEnd.SelectedDate.ToString(); //有发布时间限制的广告,则检查发布日期范围是否合法 if (starttimestr.IndexOf("1900") < 0 && endtimestr.IndexOf("1900") < 0) { if (Convert.ToDateTime(postdatetimeStart.SelectedDate.ToString()) >= Convert.ToDateTime(postdatetimeEnd.SelectedDate.ToString())) { base.RegisterStartupScript("", "<script>alert('开始时间应该早于结束时间');</script>"); return; } } activityInfo.Atype = TypeConverter.StrToInt(typeid.SelectedValue, 0); activityInfo.Atitle = Utils.RemoveHtml(act_title.Text); activityInfo.Stylecode = act_style.Text; activityInfo.Scriptcode = act_script.Text; activityInfo.Desccode = templatenew.Text; activityInfo.Begintime = postdatetimeStart.SelectedDate.ToString(); activityInfo.Endtime = postdatetimeEnd.SelectedDate.ToString(); activityInfo.Seotitle = Utils.RemoveHtml(seotitle.Text); activityInfo.Seokeyword = Utils.RemoveHtml(seokeyword.Text); activityInfo.Seodesc = Utils.RemoveHtml(seodesc.Text); activityInfo.Enabled = TypeConverter.StrToInt(act_status.SelectedValue, 0); activityInfo.RssImg = Utils.RemoveHtml(act_rssimg.Text); AdminActivities.UpdateActivityInfo(activityInfo); if (TypeConverter.StrToInt(typeid.SelectedValue, 0) == Convert.ToInt16(ActivityType.TaobaoActivity)) { SAS.Cache.SASCache.GetCacheService().RemoveObject("/SAS/TaoActivities"); } SAS.Cache.SASCache.GetCacheService().RemoveObject("/SAS/Activity"); SAS.Cache.SASCache.GetCacheService().RemoveObject("/SAS/IndexAct"); SAS.Cache.SASCache.GetCacheService().RemoveObject("/SAS/HYAct"); SAS.Cache.SASCache.GetCacheService().RemoveObject("/SAS/HYTaoAct"); //记录日志 AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "更新活动", "更新活动,标题为:" + act_title.Text); base.RegisterStartupScript("PAGE", "window.location.href='global_searchactivity.aspx';"); } #endregion }
protected override void ShowPage() { ainfo = Activities.GetActivityInfo(aid); if (ainfo == null) { AddErrLine("您的活动已过期或已删除!"); SetMetaRefresh(2, LogicUtils.GetReUrl()); return; } pagetitle = ainfo.Seotitle; seokeyword = ainfo.Seokeyword; seodescription = ainfo.Seodesc; }
protected override void ShowPage() { actinfo = Activities.GetActivityInfo(actid); if (actinfo == null) { AddErrLine("该活动不存在!"); return; } //if (System.DateTime.Parse(actinfo.Endtime) < System.DateTime.Now) //{ // AddErrLine("该活动已结束!"); //} if (actinfo.Enabled == 0) { AddErrLine("该活动已关闭!"); } if (page_err > 0) return; pagetitle = actinfo.Atitle + actinfo.Seotitle; UpdateMetaInfo(actinfo.Seokeyword, actinfo.Seodesc, ""); AddStyleCss(actinfo.Stylecode); AddfootScript(actinfo.Scriptcode); }
/// <summary> /// 创建活动专题 /// </summary> public void CreateActivityInfo(ActivityInfo aif) { DbParameter[] parms = { DbHelper.MakeInParam("@atitle",(DbType)SqlDbType.NVarChar,50,aif.Atitle), DbHelper.MakeInParam("@stylecode",(DbType)SqlDbType.NText,0,aif.Stylecode), DbHelper.MakeInParam("@desccode",(DbType)SqlDbType.NText,0,aif.Desccode), DbHelper.MakeInParam("@scriptcode",(DbType)SqlDbType.NText,0,aif.Scriptcode), DbHelper.MakeInParam("@begintime",(DbType)SqlDbType.DateTime,8,aif.Begintime), DbHelper.MakeInParam("@endtime",(DbType)SqlDbType.DateTime,8,aif.Endtime), DbHelper.MakeInParam("@atype",(DbType)SqlDbType.Int,4,aif.Atype), DbHelper.MakeInParam("@enabled",(DbType)SqlDbType.SmallInt,2,aif.Enabled), DbHelper.MakeInParam("@seotitle",(DbType)SqlDbType.NVarChar,50,aif.Seotitle), DbHelper.MakeInParam("@seodesc",(DbType)SqlDbType.NVarChar,200,aif.Seodesc), DbHelper.MakeInParam("@seokeyword",(DbType)SqlDbType.NVarChar,100,aif.Seokeyword), DbHelper.MakeInParam("@rssimg",(DbType)SqlDbType.VarChar,200,aif.RssImg) }; string commandText = string.Format("INSERT INTO [{0}activity]([atitle],[stylecode],[desccode],[scriptcode],[begintime],[endtime],[atype],[enabled],[seotitle],[seodesc],[seokeyword],[rssimg])" + " VALUES(@atitle,@stylecode,@desccode,@scriptcode,@begintime,@endtime,@atype,@enabled,@seotitle,@seodesc,@seokeyword,@rssimg)", BaseConfigs.GetTablePrefix); DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); }
/// <summary> /// 更新活动专题 /// </summary> /// <param name="aif"></param> /// <returns></returns> public int UpdateActivityInfo(ActivityInfo aif) { DbParameter[] parms = { DbHelper.MakeInParam("@id",(DbType)SqlDbType.Int,4,aif.Id), DbHelper.MakeInParam("@atitle",(DbType)SqlDbType.NVarChar,50,aif.Atitle), DbHelper.MakeInParam("@stylecode",(DbType)SqlDbType.NText,0,aif.Stylecode), DbHelper.MakeInParam("@desccode",(DbType)SqlDbType.NText,0,aif.Desccode), DbHelper.MakeInParam("@scriptcode",(DbType)SqlDbType.NText,0,aif.Scriptcode), DbHelper.MakeInParam("@begintime",(DbType)SqlDbType.DateTime,8,aif.Begintime), DbHelper.MakeInParam("@endtime",(DbType)SqlDbType.DateTime,8,aif.Endtime), DbHelper.MakeInParam("@atype",(DbType)SqlDbType.Int,4,aif.Atype), DbHelper.MakeInParam("@enabled",(DbType)SqlDbType.SmallInt,2,aif.Enabled), DbHelper.MakeInParam("@seotitle",(DbType)SqlDbType.NVarChar,50,aif.Seotitle), DbHelper.MakeInParam("@seodesc",(DbType)SqlDbType.NVarChar,200,aif.Seodesc), DbHelper.MakeInParam("@seokeyword",(DbType)SqlDbType.NVarChar,100,aif.Seokeyword), DbHelper.MakeInParam("@rssimg",(DbType)SqlDbType.VarChar,200,aif.RssImg) }; string commandText = string.Format("UPDATE [{0}activity] SET [atitle] = @atitle,[stylecode] = @stylecode,[desccode] = @desccode,[scriptcode] = @scriptcode,[begintime] = @begintime," + "[endtime] = @endtime,[atype] = @atype,[enabled] = @enabled,[seotitle] = @seotitle,[seodesc] = @seodesc,[seokeyword] = @seokeyword,[rssimg]=@rssimg WHERE id=@id", BaseConfigs.GetTablePrefix); return DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); }
/// <summary> /// 创建活动 /// </summary> /// <param name="aif"></param> public static void CreateActivityInfo(ActivityInfo aif) { DatabaseProvider.GetInstance().CreateActivityInfo(aif); }
/// <summary> /// 装载实体对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> private static ActivityInfo LoadSingleActivityInfo(IDataReader reader) { ActivityInfo activityInfo = new ActivityInfo(); activityInfo.Id = TypeConverter.ObjectToInt(reader["id"]); activityInfo.Atitle = reader["atitle"].ToString(); activityInfo.Stylecode = reader["stylecode"].ToString(); activityInfo.Desccode = reader["desccode"].ToString(); activityInfo.Scriptcode = reader["scriptcode"].ToString(); activityInfo.Begintime = reader["begintime"].ToString(); activityInfo.Endtime = reader["endtime"].ToString(); activityInfo.Atype = TypeConverter.ObjectToInt(reader["atype"]); activityInfo.Enabled = TypeConverter.ObjectToInt(reader["enabled"]); activityInfo.Seotitle = reader["seotitle"].ToString(); activityInfo.Seodesc = reader["seodesc"].ToString(); activityInfo.Seokeyword = reader["seokeyword"].ToString(); activityInfo.Createdate = reader["createdate"].ToString(); activityInfo.RssImg = reader["rssimg"].ToString(); return activityInfo; }
/// <summary> /// 更新活动专题 /// </summary> /// <param name="aif"></param> /// <returns></returns> public static int UpdateActivityInfo(ActivityInfo aif) { return DatabaseProvider.GetInstance().UpdateActivityInfo(aif); }
/// <summary> /// 更新活动 /// </summary> /// <param name="aif"></param> /// <returns></returns> public static int UpdateActivityInfo(ActivityInfo aif) { return SAS.Data.DataProvider.Activities.UpdateActivityInfo(aif); }
/// <summary> /// 创建活动专题 /// </summary> /// <param name="aif"></param> public static void CreateActivity(ActivityInfo aif) { SAS.Data.DataProvider.Activities.CreateActivityInfo(aif); }
/// <summary> /// 加载活动实体信息 /// </summary> /// <returns></returns> private ActivityInfo LoadActivityInfo() { ActivityInfo aif = new ActivityInfo(); aif.Atype = TypeConverter.StrToInt(typeid.SelectedValue, 0); aif.Atitle = Utils.RemoveHtml(act_title.Text); aif.Stylecode = act_style.Text; aif.Scriptcode = act_script.Text; aif.Desccode = templatenew.Text; aif.Begintime = postdatetimeStart.SelectedDate.ToString(); aif.Endtime = postdatetimeEnd.SelectedDate.ToString(); aif.Seotitle = Utils.RemoveHtml(seotitle.Text); aif.Seokeyword = Utils.RemoveHtml(seokeyword.Text); aif.Seodesc = Utils.RemoveHtml(seodesc.Text); aif.Enabled = TypeConverter.StrToInt(act_status.SelectedValue, 0); aif.RssImg = Utils.RemoveHtml(act_rssimg.Text); return aif; }