📄 adadd.cs
字号:
namespace PowerEasy.WebSite.Admin.AD
{
using PowerEasy.AccessManage;
using PowerEasy.AD;
using PowerEasy.Common;
using PowerEasy.Controls;
using PowerEasy.Enumerations;
using PowerEasy.Model.AD;
using PowerEasy.ModelControls;
using PowerEasy.Web.UI;
using System;
using System.Collections;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class ADAdd : AdminPage
{
protected HtmlGenericControl ADContent;
protected HtmlTable ADContent_1;
protected HtmlTable ADContent_2;
protected HtmlTable ADContent_3;
protected HtmlTable ADContent_4;
protected HtmlTable ADContent_5;
protected CheckBox ChkCountClick;
protected CheckBox ChkCountView;
protected CheckBox ChkPassed;
protected DatePicker DpkOverdueDate;
protected Button EBtnSubmit;
protected FileUploadControl ExtenFileUpload;
protected FileUploadControl FileUploadControl1;
protected HiddenField HdnAction;
protected HiddenField HdnAdId;
protected AlternateLiteral LblTitle;
protected ListBox LstZoneName;
protected RadioButtonList RadlADType;
protected RadioButtonList RadlFlashMode;
protected RadioButtonList RadlLinkTarget;
protected ExtendedSiteMapPath SmpNavigator;
protected TextBox TxtADCode;
protected TextBox TxtADIntro;
protected TextBox TxtADName;
protected TextBox TxtADText;
protected TextBox TxtClicks;
protected TextBox TxtFlashHeight;
protected TextBox TxtFlashWidth;
protected TextBox TxtImgHeight;
protected TextBox TxtImgWidth;
protected TextBox TxtLinkAlt;
protected TextBox TxtLinkUrl;
protected TextBox TxtPriority;
protected TextBox TxtViews;
protected TextBox TxtWebFileUrl;
protected PowerEasy.Controls.RequiredFieldValidator ValrADName;
protected void EBtnSubmit_Click(object sender, EventArgs e)
{
string adZoneIdList = this.GetAdZoneIdList();
if (this.Page.IsValid)
{
DataActionState state;
AdvertisementInfo advertisementInfo = new AdvertisementInfo();
advertisementInfo.UserId = 0;
advertisementInfo.ADName = DataSecurity.HtmlEncode(this.TxtADName.Text.Trim());
advertisementInfo.ADType = DataConverter.CLng(this.RadlADType.SelectedValue);
advertisementInfo.Priority = DataConverter.CLng(this.TxtPriority.Text.Trim());
advertisementInfo.Passed = this.ChkPassed.Checked;
advertisementInfo.CountView = this.ChkCountView.Checked;
advertisementInfo.Views = DataConverter.CLng(this.TxtViews.Text.Trim());
advertisementInfo.CountClick = this.ChkCountClick.Checked;
advertisementInfo.Clicks = DataConverter.CLng(this.TxtClicks.Text.Trim());
advertisementInfo.ZoneId = adZoneIdList;
advertisementInfo.ADId = DataConverter.CLng(this.HdnAdId.Value.Trim());
advertisementInfo.OverdueDate = this.DpkOverdueDate.Date;
switch (advertisementInfo.ADType)
{
case 1:
{
advertisementInfo.ImgUrl = this.FileUploadControl1.FilePath;
if (string.IsNullOrEmpty(advertisementInfo.ImgUrl))
{
AdminPage.WriteErrMsg("图片广告请上传图片!");
}
advertisementInfo.ImgHeight = DataConverter.CLng(this.TxtImgHeight.Text.Trim());
advertisementInfo.ImgWidth = DataConverter.CLng(this.TxtImgWidth.Text.Trim());
string str2 = this.TxtLinkUrl.Text.Trim();
advertisementInfo.LinkUrl = str2;
advertisementInfo.LinkTarget = DataConverter.CLng(this.RadlLinkTarget.SelectedValue);
advertisementInfo.LinkAlt = this.TxtLinkAlt.Text.Trim();
advertisementInfo.ADIntro = this.TxtADIntro.Text.Trim();
break;
}
case 2:
advertisementInfo.ImgUrl = this.ExtenFileUpload.FilePath;
if (string.IsNullOrEmpty(advertisementInfo.ImgUrl))
{
AdminPage.WriteErrMsg("Flash广告请上传Flash!");
}
advertisementInfo.ImgHeight = DataConverter.CLng(this.TxtFlashHeight.Text.Trim());
advertisementInfo.ImgWidth = DataConverter.CLng(this.TxtFlashWidth.Text.Trim());
advertisementInfo.FlashWmode = DataConverter.CLng(this.RadlFlashMode.SelectedValue);
break;
case 3:
advertisementInfo.ADIntro = this.TxtADText.Text.Trim();
break;
case 4:
advertisementInfo.ADIntro = this.TxtADCode.Text.Trim();
break;
case 5:
advertisementInfo.ADIntro = this.TxtWebFileUrl.Text.Trim();
break;
}
if (this.HdnAction.Value.Trim() == "Modify")
{
state = Advertisement.Update(advertisementInfo);
}
else
{
state = Advertisement.Add(advertisementInfo);
}
switch (state)
{
case DataActionState.Successed:
if (!string.IsNullOrEmpty(adZoneIdList))
{
ADZone.CreateJS(adZoneIdList);
}
AdminPage.WriteSuccessMsg("保存操作广告成功!", "AdManage.aspx");
return;
case DataActionState.Unknown:
AdminPage.WriteErrMsg("操作失败!", "Advertisement.aspx?AdId=" + advertisementInfo.ADId + "&Action=Modify");
return;
}
BasePage.ResponseRedirect("AdManage.aspx");
}
}
private string GetAdZoneIdList()
{
StringBuilder builder = new StringBuilder();
int count = this.LstZoneName.Items.Count;
for (int i = 0; i < count; i++)
{
if (this.LstZoneName.Items[i].Selected)
{
builder.Append(this.LstZoneName.Items[i].Value);
builder.Append(",");
}
}
return builder.ToString();
}
private void InitJSScript()
{
StringBuilder builder = new StringBuilder();
builder.Append("<script type=text/javascript>\n");
builder.Append("function Change_ADType()\n");
builder.Append("{\n");
builder.Append(" for (var j=1;j<=document.getElementsByName('" + this.RadlADType.UniqueID + "').length;j++){\n");
builder.Append(" var ot = eval(document.getElementById('" + this.ADContent.ClientID + "_'+ j +''));\n");
builder.Append("if(document.getElementById('" + this.RadlADType.ClientID + "_'+(j-1)+'').checked){\n");
builder.Append("ot.style.display = '';\n");
builder.Append(" if(j==1){\n");
builder.Append("document.getElementById('" + this.ChkCountClick.ClientID + "').disabled = false;\n");
builder.Append("document.getElementById('" + this.TxtClicks.ClientID + "').disabled = false;\n");
builder.Append(" }else{\n");
builder.Append("document.getElementById('" + this.ChkCountClick.ClientID + "').disabled = true;\n");
builder.Append("document.getElementById('" + this.TxtClicks.ClientID + "').disabled = true;\n");
builder.Append(" }\n");
builder.Append(" }else{\n");
builder.Append(" ot.style.display = 'none';\n");
builder.Append(" }\n");
builder.Append(" }\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -