/// <summary> /// 增加一条数据 /// </summary> public void Add(DtCms.Model.Advertising model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Advertising("); strSql.Append("Title,AdType,AdRemark,AdNum,AdPrice,AdWidth,AdHeight,AdTarget)"); strSql.Append(" values ("); strSql.Append("@Title,@AdType,@AdRemark,@AdNum,@AdPrice,@AdWidth,@AdHeight,@AdTarget)"); OleDbParameter[] parameters = { new OleDbParameter("@Title", OleDbType.VarWChar, 100), new OleDbParameter("@AdType", OleDbType.Integer, 4), new OleDbParameter("@AdRemark", OleDbType.VarWChar, 0), new OleDbParameter("@AdNum", OleDbType.Integer, 4), new OleDbParameter("@AdPrice", OleDbType.Decimal, 9), new OleDbParameter("@AdWidth", OleDbType.Integer, 4), new OleDbParameter("@AdHeight", OleDbType.Integer, 4), new OleDbParameter("@AdTarget", OleDbType.VarWChar, 50) }; parameters[0].Value = model.Title; parameters[1].Value = model.AdType; parameters[2].Value = model.AdRemark; parameters[3].Value = model.AdNum; parameters[4].Value = model.AdPrice; parameters[5].Value = model.AdWidth; parameters[6].Value = model.AdHeight; parameters[7].Value = model.AdTarget; DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); }
private void RptBind(string where) { //显示所属的首页图片 DtCms.BLL.Advertising aBll = new DtCms.BLL.Advertising(); DtCms.Model.Advertising aModel = aBll.GetModel(this.pid); lblAdTitle.Text = "【" + aModel.Id + "】" + aModel.Title + "(" + GetAdTypeName(aModel.AdType.ToString()) + ")"; //绑定首页图片列表 if (!int.TryParse(Request.Params["page"] as string, out this.page)) { this.page = 0; } this.txtKeywords.Text = this.keywords; DtCms.BLL.Adbanner bll = new DtCms.BLL.Adbanner(); //利用PAGEDDAGASOURCE类来分页 PagedDataSource pg = new PagedDataSource(); pg.DataSource = bll.GetList(where).Tables[0].DefaultView; pg.AllowPaging = true; pg.PageSize = pagesize; pg.CurrentPageIndex = page; //获得总条数 pcount = bll.GetCount(where); //绑定数据 rptList.DataSource = pg; rptList.DataBind(); }
private void ShowInfo(int sId) { //显示所属的首页图片 DtCms.BLL.Advertising aBll = new DtCms.BLL.Advertising(); DtCms.Model.Advertising aModel = aBll.GetModel(this.pid); lblAdTitle.Text = "【" + aModel.Id + "】" + aModel.Title + "(" + GetAdTypeName(aModel.AdType.ToString()) + ")"; }
protected void Page_Load(object sender, EventArgs e) { if (!int.TryParse(Request.Params["id"] as string, out this.id)) { JscriptMsg(350, 230, "错误提示", "<b>出现错误啦!</b>您要调用的首页图片不存在或参数不正确。", "back", "Error"); return; } if (!Page.IsPostBack) { DtCms.BLL.Advertising bll = new DtCms.BLL.Advertising(); model = bll.GetModel(this.id); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DtCms.Model.Advertising GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,Title,AdType,AdRemark,AdNum,AdPrice,AdWidth,AdHeight,AdTarget from dt_Advertising "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; DtCms.Model.Advertising model = new DtCms.Model.Advertising(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Title = ds.Tables[0].Rows[0]["Title"].ToString(); if (ds.Tables[0].Rows[0]["AdType"].ToString() != "") { model.AdType = int.Parse(ds.Tables[0].Rows[0]["AdType"].ToString()); } model.AdRemark = ds.Tables[0].Rows[0]["AdRemark"].ToString(); if (ds.Tables[0].Rows[0]["AdNum"].ToString() != "") { model.AdNum = int.Parse(ds.Tables[0].Rows[0]["AdNum"].ToString()); } if (ds.Tables[0].Rows[0]["AdPrice"].ToString() != "") { model.AdPrice = decimal.Parse(ds.Tables[0].Rows[0]["AdPrice"].ToString()); } if (ds.Tables[0].Rows[0]["AdWidth"].ToString() != "") { model.AdWidth = int.Parse(ds.Tables[0].Rows[0]["AdWidth"].ToString()); } if (ds.Tables[0].Rows[0]["AdHeight"].ToString() != "") { model.AdHeight = int.Parse(ds.Tables[0].Rows[0]["AdHeight"].ToString()); } model.AdTarget = ds.Tables[0].Rows[0]["AdTarget"].ToString(); return(model); } else { return(null); } }
//赋值操作 private void ShowInfo(int editID) { DtCms.BLL.Advertising bll = new DtCms.BLL.Advertising(); DtCms.Model.Advertising model = bll.GetModel(editID); this.txtTitle.Text = model.Title; this.rblAdType.SelectedValue = model.AdType.ToString(); this.txtAdRemark.Text = model.AdRemark; this.txtAdNum.Text = model.AdNum.ToString(); this.txtAdPrice.Text = model.AdPrice.ToString(); this.txtAdWidth.Text = model.AdWidth.ToString(); this.txtAdHeight.Text = model.AdHeight.ToString(); this.rblAdTarget.SelectedValue = model.AdTarget; }
//保存 protected void btnSave_Click(object sender, EventArgs e) { DtCms.Model.Advertising model = new DtCms.Model.Advertising(); DtCms.BLL.Advertising bll = new DtCms.BLL.Advertising(); model.Title = this.txtTitle.Text.Trim(); model.AdType = int.Parse(this.rblAdType.SelectedValue); model.AdRemark = this.txtAdRemark.Text; model.AdNum = int.Parse(this.txtAdNum.Text.Trim()); model.AdPrice = decimal.Parse(this.txtAdPrice.Text); model.AdWidth = int.Parse(this.txtAdWidth.Text); model.AdHeight = int.Parse(this.txtAdHeight.Text); model.AdTarget = this.rblAdTarget.SelectedValue; bll.Add(model); JscriptPrint("广告位增加成功啦!", "AdvAdd.aspx", "Success"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DtCms.Model.Advertising model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dt_Advertising set "); strSql.Append("Title=@Title,"); strSql.Append("AdType=@AdType,"); strSql.Append("AdRemark=@AdRemark,"); strSql.Append("AdNum=@AdNum,"); strSql.Append("AdPrice=@AdPrice,"); strSql.Append("AdWidth=@AdWidth,"); strSql.Append("AdHeight=@AdHeight,"); strSql.Append("AdTarget=@AdTarget"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@Title", SqlDbType.NVarChar, 100), new SqlParameter("@AdType", SqlDbType.Int, 4), new SqlParameter("@AdRemark", SqlDbType.NVarChar, 250), new SqlParameter("@AdNum", SqlDbType.Int, 4), new SqlParameter("@AdPrice", SqlDbType.Decimal, 9), new SqlParameter("@AdWidth", SqlDbType.Int, 4), new SqlParameter("@AdHeight", SqlDbType.Int, 4), new SqlParameter("@AdTarget", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Id; parameters[1].Value = model.Title; parameters[2].Value = model.AdType; parameters[3].Value = model.AdRemark; parameters[4].Value = model.AdNum; parameters[5].Value = model.AdPrice; parameters[6].Value = model.AdWidth; parameters[7].Value = model.AdHeight; parameters[8].Value = model.AdTarget; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
//修改保存 protected void btnSave_Click(object sender, EventArgs e) { DtCms.BLL.Advertising bll = new DtCms.BLL.Advertising(); DtCms.Model.Advertising model = bll.GetModel(this.Id); model.Title = this.txtTitle.Text.Trim(); model.AdType = int.Parse(this.rblAdType.SelectedValue); model.AdRemark = this.txtAdRemark.Text; model.AdNum = int.Parse(this.txtAdNum.Text.Trim()); model.AdPrice = decimal.Parse(this.txtAdPrice.Text); model.AdWidth = int.Parse(this.txtAdWidth.Text); model.AdHeight = int.Parse(this.txtAdHeight.Text); model.AdTarget = this.rblAdTarget.SelectedValue; bll.Update(model); //保存日志 SaveLogs("[首页图片管理]编辑首页图片:" + model.Title); JscriptPrint("首页图片修改成功啦!", "AdvList.aspx", "Success"); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DtCms.Model.Advertising model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into dt_Advertising("); strSql.Append("Title,AdType,AdRemark,AdNum,AdPrice,AdWidth,AdHeight,AdTarget)"); strSql.Append(" values ("); strSql.Append("@Title,@AdType,@AdRemark,@AdNum,@AdPrice,@AdWidth,@AdHeight,@AdTarget)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Title", SqlDbType.NVarChar, 100), new SqlParameter("@AdType", SqlDbType.Int, 4), new SqlParameter("@AdRemark", SqlDbType.NVarChar, 250), new SqlParameter("@AdNum", SqlDbType.Int, 4), new SqlParameter("@AdPrice", SqlDbType.Decimal, 9), new SqlParameter("@AdWidth", SqlDbType.Int, 4), new SqlParameter("@AdHeight", SqlDbType.Int, 4), new SqlParameter("@AdTarget", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Title; parameters[1].Value = model.AdType; parameters[2].Value = model.AdRemark; parameters[3].Value = model.AdNum; parameters[4].Value = model.AdPrice; parameters[5].Value = model.AdWidth; parameters[6].Value = model.AdHeight; parameters[7].Value = model.AdTarget; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(DtCms.Model.Advertising model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Advertising set "); strSql.Append("Title=@Title,"); strSql.Append("AdType=@AdType,"); strSql.Append("AdRemark=@AdRemark,"); strSql.Append("AdNum=@AdNum,"); strSql.Append("AdPrice=@AdPrice,"); strSql.Append("AdWidth=@AdWidth,"); strSql.Append("AdHeight=@AdHeight,"); strSql.Append("AdTarget=@AdTarget"); strSql.Append(" where Id=@Id "); OleDbParameter[] parameters = { new OleDbParameter("@Title", OleDbType.VarWChar, 100), new OleDbParameter("@AdType", OleDbType.Integer, 4), new OleDbParameter("@AdRemark", OleDbType.VarWChar, 0), new OleDbParameter("@AdNum", OleDbType.Integer, 4), new OleDbParameter("@AdPrice", OleDbType.Decimal, 9), new OleDbParameter("@AdWidth", OleDbType.Integer, 4), new OleDbParameter("@AdHeight", OleDbType.Integer, 4), new OleDbParameter("@AdTarget", OleDbType.VarWChar, 50), new OleDbParameter("@Id", OleDbType.Integer, 4) }; parameters[0].Value = model.Title; parameters[1].Value = model.AdType; parameters[2].Value = model.AdRemark; parameters[3].Value = model.AdNum; parameters[4].Value = model.AdPrice; parameters[5].Value = model.AdWidth; parameters[6].Value = model.AdHeight; parameters[7].Value = model.AdTarget; parameters[8].Value = model.Id; DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); }
public void ProcessRequest(HttpContext context) { int aid; //获得广告位的ID if (!int.TryParse(context.Request.Params["id"] as string, out aid)) { context.Response.Write("document.write('Error,unable to display the ads.');"); return; } //检查广告位是否存在 DtCms.BLL.Advertising abll = new DtCms.BLL.Advertising(); if (!abll.Exists(aid)) { context.Response.Write("document.write('Error, the ad does not exist.');"); return; } //取得该广告位详细信息 DtCms.Model.Advertising aModel = abll.GetModel(aid); //输出该广告位下的广告条,不显示未开始、过期、暂停广告 DtCms.BLL.Adbanner bbll = new DtCms.BLL.Adbanner(); DataSet ds = bbll.GetList("IsLock=0 and datediff('d',StartTime,now())>=0 and datediff('d',EndTime,now())<=0 and Aid=" + aid); if (ds.Tables[0].Rows.Count < 1) { context.Response.Write("document.write('该广告位下暂无广告内容');"); return; } //=================判断广告位类别,输出广告条====================== switch (aModel.AdType) { case 1: //文字 context.Response.Write("document.write('<ul>');\n"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= aModel.AdNum) { break; } DataRow dr = ds.Tables[0].Rows[i]; context.Response.Write("document.write('<li>');"); context.Response.Write("document.write('<a title=\"" + dr["Title"] + "\" target=\"" + aModel.AdTarget + "\" href=\"" + dr["LinkUrl"] + "\">" + dr["Title"] + "</a>');"); context.Response.Write("document.write('</li>');\n"); } context.Response.Write("document.write('</ul>');\n"); break; case 2: //图片 if (ds.Tables[0].Rows.Count == 1) { DataRow dr = ds.Tables[0].Rows[0]; context.Response.Write("document.write('<a title=\"" + dr["Title"] + "\" target=\"" + aModel.AdTarget + "\" href=\"" + dr["LinkUrl"] + "\">');"); context.Response.Write("document.write('<img src=\"" + dr["AdUrl"] + "\" width=" + aModel.AdWidth + " height=" + aModel.AdHeight + " border=0 />');"); context.Response.Write("document.write('</a>');"); } else { context.Response.Write("document.write('<ul>');\n"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= aModel.AdNum) { break; } DataRow dr = ds.Tables[0].Rows[i]; context.Response.Write("document.write('<li>');"); context.Response.Write("document.write('<a title=\"" + dr["Title"] + "\" target=\"" + aModel.AdTarget + "\" href=\"" + dr["LinkUrl"] + "\">');"); context.Response.Write("document.write('<img src=\"" + dr["AdUrl"] + "\" width=" + aModel.AdWidth + " height=" + aModel.AdHeight + " border=0 />');"); context.Response.Write("document.write('</a>');\n"); context.Response.Write("document.write('</li>');\n"); } context.Response.Write("document.write('</ul>');\n"); } break; case 3: //幻灯片 StringBuilder picTitle = new StringBuilder(); StringBuilder picUrl = new StringBuilder(); StringBuilder picLink = new StringBuilder(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= aModel.AdNum) { break; } DataRow dr = ds.Tables[0].Rows[i]; //picTitle.Append(dr["Title"].ToString()); picUrl.Append(dr["AdUrl"].ToString()); picLink.Append(dr["LinkUrl"].ToString()); if (i < ds.Tables[0].Rows.Count - 1) { //picTitle.Append("|"); picUrl.Append("|"); picLink.Append("|"); } } context.Response.Write("document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" d=scriptmain name=scriptmain codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + aModel.AdWidth + "\" height=\"" + aModel.AdHeight + "\">');\n"); context.Response.Write("document.write('<param name=\"movie\" value=\"/images/focus.swf?bcastr_flie=" + picUrl + "&bcastr_link=" + picLink + "&bcastr_title=" + picTitle + "\">');\n"); context.Response.Write("document.write('<param name=\"quality\" value=\"high\">');\n"); context.Response.Write("document.write('<param name=\"loop\" value=\"false\">');\n"); context.Response.Write("document.write('<param name=\"menu\" value=\"false\">');\n"); context.Response.Write("document.write('<param name=\"wmode\" value=\"transparent\">');\n"); context.Response.Write("document.write('<embed src=\"/images/focus.swf?bcastr_flie=" + picUrl + "&bcastr_link=" + picLink + "&bcastr_title=" + picTitle + "\" width=\"" + aModel.AdWidth + "\" height=\"" + aModel.AdHeight + "\" loop=\"false\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" menu=\"false\"></embed>');\n"); context.Response.Write("document.write('</object>');\n"); break; case 4: //动画 if (ds.Tables[0].Rows.Count == 1) { DataRow dr = ds.Tables[0].Rows[0]; context.Response.Write("document.write('<object classid=\"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" width=\"" + aModel.AdWidth + "\" height=\"" + aModel.AdHeight + "\">');\n"); context.Response.Write("document.write('<param name=\"movie\" value=\"" + dr["AdUrl"] + "\">');\n"); context.Response.Write("document.write('<param name=\"quality\" value=\"high\">');\n"); context.Response.Write("document.write('<param name=\"wmode\" value=\"transparent\">');\n"); context.Response.Write("document.write('<param name=\"menu\" value=\"false\">');\n"); context.Response.Write("document.write('<embed src=\"" + dr["AdUrl"] + "\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + aModel.AdWidth + "\" height=\"" + aModel.AdHeight + "\" quality=\"High\" wmode=\"transparent\">');\n"); context.Response.Write("document.write('</embed>');\n"); context.Response.Write("document.write('</object>');\n"); } else { context.Response.Write("document.write('<ul>');\n"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= aModel.AdNum) { break; } DataRow dr = ds.Tables[0].Rows[i]; context.Response.Write("document.write('<li>');"); context.Response.Write("document.write('<object classid=\"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" width=\"" + aModel.AdWidth + "\" height=\"" + aModel.AdHeight + "\">');\n"); context.Response.Write("document.write('<param name=\"movie\" value=\"" + dr["AdUrl"] + "\">');\n"); context.Response.Write("document.write('<param name=\"quality\" value=\"high\">');\n"); context.Response.Write("document.write('<param name=\"wmode\" value=\"transparent\">');\n"); context.Response.Write("document.write('<param name=\"menu\" value=\"false\">');\n"); context.Response.Write("document.write('<embed src=\"" + dr["AdUrl"] + "\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + aModel.AdWidth + "\" height=\"" + aModel.AdHeight + "\" quality=\"High\" wmode=\"transparent\">');\n"); context.Response.Write("document.write('</embed>');\n"); context.Response.Write("document.write('</object>');\n"); context.Response.Write("document.write('</li>');\n"); } context.Response.Write("document.write('</ul>');\n"); } break; case 5: //视频 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= 1) { break; } DataRow dr = ds.Tables[0].Rows[i]; context.Response.Write("document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" width=" + aModel.AdWidth + " height=" + aModel.AdHeight + " viewastext>');\n"); context.Response.Write("document.write('<param name=\"movie\" value=\"/images/Player.swf\" />');\n"); context.Response.Write("document.write('<param name=\"quality\" value=\"high\" />');\n"); context.Response.Write("document.write('<param name=\"allowFullScreen\" value=\"true\" />');\n"); context.Response.Write("document.write('<param name=\"FlashVars\" value=\"vcastr_file=" + dr["AdUrl"].ToString() + "&LogoText=www.auto.cn&BarTransparent=30&BarColor=0xffffff&IsAutoPlay=1&IsContinue=1\" />');\n"); context.Response.Write("document.write('</object>');\n"); } break; case 6: //代码 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= 1) { break; } DataRow dr = ds.Tables[0].Rows[i]; StringBuilder sb = new StringBuilder(dr["AdRemark"].ToString()); sb.Replace("<", "<"); sb.Replace(">", ">"); sb.Replace("\"", "'"); context.Response.Write("document.write(\"" + sb.ToString() + "\")"); } break; } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(DtCms.Model.Advertising model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(DtCms.Model.Advertising model) { dal.Add(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DtCms.Model.Advertising model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DtCms.Model.Advertising model) { return(dal.Add(model)); }