/// <summary> /// 控件行命令事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("del")) { int id = Convert.ToInt32(e.CommandArgument); GuangGaoService.Delete(id); sp.InitBindData(repInfo, pager1, "GuangGao", "id", sear()); } if (e.CommandName.Equals("mod")) { int id = Convert.ToInt32(e.CommandArgument); GuangGao item = GuangGaoService.GetModel(id); if (item != null) { ViewState["guangGaoImg1"] = item.imgUrl; txtLinkurl.Text = item.linkurl; txtComName.Text = item.comName; txtRelUser.Text = item.relUser; txtTel.Text = item.tel; txtOrder.Text = item.isNew.ToString(); ddlPlace.SelectedValue = item.placeSite.ToString(); ddlTimeStr.SelectedValue = item.infoType.ToString(); ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "overKeyWordDiv();", true); } ViewState["modId"] = id; } }
/// <summary> /// 添加类型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { if (ViewState["guangGaoImg1"] == null) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('请上传广告图片!');", true); return; } string linkUrl = this.txtLinkurl.Text.Trim(); string comName = this.txtComName.Text.Trim(); string relUser = this.txtRelUser.Text.Trim(); string tel = txtTel.Text.Trim(); string order = txtOrder.Text.Trim(); if (comName.Length == 0 || tel.Length == 0) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('投放企业和联系方式不能为空!');", true); return; } if (!RegExp.IsNumeric(order)) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('顺序号信息有误!');", true); return; } GuangGao item = new GuangGao(); item.imgUrl = ViewState["guangGaoImg1"].ToString(); item.title = comName; item.alt = comName; item.linkurl = linkUrl; item.comName = comName; item.relUser = relUser; item.tel = tel; item.timeStr = ddlTimeStr.SelectedItem.Text; item.infoType = Convert.ToInt32(ddlTimeStr.SelectedValue); item.timeFrom = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); item.timeEnd = Convert.ToDateTime(DateTime.Now.AddMonths(item.infoType).ToString("yyyy-MM-dd")); item.placeSite = Convert.ToInt32(ddlPlace.SelectedValue); item.placeName = ddlPlace.SelectedItem.Text; item.isTj = 0; item.isHot = 0; item.isNew = 0; if (order != "") { item.isNew = Convert.ToInt32(order); } item.views = 0; item.status = 0; item.remark = ""; item.addTime = DateTime.Now; if (Session["loginUser"] == null) { Response.Redirect("/admin/login.aspx"); return; } AdminUser admin = Session["loginUser"] as AdminUser; item.addUser = admin.id; if (ViewState["modId"] != null) { item.id = Convert.ToInt32(ViewState["modId"]); GuangGaoService.Update(item); ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('保存成功!');", true); } else { int num = GuangGaoService.Add(item); } sp.InitBindData(repInfo, pager1, "GuangGao", "id", sear()); ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('保存成功!');", true); }