protected void btnDel_Click(object sender, EventArgs e) { if (grid1.SelectedRowIndexArray != null && grid1.SelectedRowIndexArray.Length > 0) { string strSelectID = "0"; for (int i = 0, count = grid1.SelectedRowIndexArray.Length; i < count; i++) { int rowIndex = grid1.SelectedRowIndexArray[i]; foreach (object key in grid1.DataKeys[rowIndex]) { strSelectID = key.ToString(); } } #region 删除逻辑 zlzw.BLL.BannerListBLL BannerListBLL = new zlzw.BLL.BannerListBLL(); zlzw.Model.BannerListModel bannerListModel = BannerListBLL.GetModel(int.Parse(Get_BannerID(strSelectID))); bannerListModel.IsEnable = 0; BannerListBLL.Update(bannerListModel); BannerList_BindGrid(); #endregion } else { return; } }
protected void btnSaveRefresh_Click(object sender, EventArgs e) { if (Request.QueryString["Type"] == "1") { //编辑保存 zlzw.Model.BannerListModel bannerListModel = new zlzw.Model.BannerListModel(); bannerListModel.BannerTitle = txbBannerTitle.Text; bannerListModel.BannerContent = txbBannerContent.Text; bannerListModel.BannerType = 1; bannerListModel.IsEnable = 1; bannerListModel.BannerLinks = txbBannerLinks.Text; if (btnBannerUpload.PostedFile.ContentLength > 0) { btnBannerUpload.SaveAs(Server.MapPath(ViewState["BannerImage"].ToString())); bannerListModel.BannerImage = ViewState["BannerImage"].ToString();//保存横幅广告路径 } else { bannerListModel.BannerImage = ViewState["BannerImage"].ToString(); } if (ckbIsHot.Checked) { bannerListModel.IsHot = 1; } else { bannerListModel.IsHot = 0; } bannerListModel.PublishDate = DateTime.Parse(ViewState["PublishDate"].ToString()); bannerListModel.BannerGUID = new Guid(ViewState["BannerGUID"].ToString()); bannerListModel.BannerID = int.Parse(Get_BannerID(Request.QueryString["value"])); zlzw.BLL.BannerListBLL bannerListBLL = new zlzw.BLL.BannerListBLL(); bannerListBLL.Update(bannerListModel); } else { //添加保存 zlzw.Model.BannerListModel bannerListModel = new zlzw.Model.BannerListModel(); bannerListModel.BannerTitle = txbBannerTitle.Text; bannerListModel.BannerContent = txbBannerContent.Text; bannerListModel.BannerType = 1; bannerListModel.IsEnable = 1; bannerListModel.BannerLinks = txbBannerLinks.Text; if (btnBannerUpload.PostedFile.ContentLength > 0) { string fileName = DateTime.Now.Ticks.ToString() + "_" + btnBannerUpload.FileName; btnBannerUpload.SaveAs(Server.MapPath("~/BannerImages/" + fileName)); bannerListModel.BannerImage = "~/BannerImages/" + fileName;//保存横幅广告路径 } else { Alert.Show("请上传一张宽度为910的横幅广告", "错误提醒", MessageBoxIcon.Error); return; } if (ckbIsHot.Checked) { bannerListModel.IsHot = 1; } else { bannerListModel.IsHot = 0; } bannerListModel.PublishDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")); bannerListModel.BannerGUID = System.Guid.NewGuid(); zlzw.BLL.BannerListBLL bannerListBLL = new zlzw.BLL.BannerListBLL(); bannerListBLL.Add(bannerListModel); } // 2. Close this window and Refresh parent window PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); }