public static string OperateRecords(string ids, int op) { string[] array = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); using (BLLComBannerType bll = new BLLComBannerType()) { foreach (string id in array) { switch (op) { case 7: using (BLLComBanner blls1 = new BLLComBanner()) { SearchComBanner con3 = new SearchComBanner(); con3.ComBannerTypeID = Convert.ToInt32(id); if (blls1.GetList(con3).Count > 0) { return("此Banner类型下有相应的Banner,不能删除!"); } } bll.Delete(id); break; } } if (bll.IsFail) { return(ExceptionManager.GetErrorMsg(bll.DevNetException)); } } return(string.Empty); }
public static string OperateRecords(string ids, int op) { string[] array = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); using (BLLComBanner bll = new BLLComBanner()) { foreach (string id in array) { switch (op) { case 7: if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).BannerPic))) { File.Delete(StringPlus.MapPath(bll.GetSingle(id).BannerPic)); bll.Delete(id); } break; } } if (bll.IsFail) { return(ExceptionManager.GetErrorMsg(bll.DevNetException)); } } return(string.Empty); }
private void BannerBind() { SearchComBanner scb = new SearchComBanner(); scb.ComBannerTypeID = 3; using (BLLComBanner bll = new BLLComBanner()) { List <ComBanner> lists = bll.GetList(scb); //rptBanner.DataSource = lists; //rptBanner.DataBind(); } }
private void setInfo() { if (id > 0) { using (BLLComBanner bll = new BLLComBanner()) { ComBanner dwinfor = bll.GetSingle(id); if (dwinfor != null) { ddlNewsType.SelectedValue = dwinfor.ComBannerTypeID.ToString(); txtDLName.Text = dwinfor.BannerTitle; txtLink.Text = dwinfor.BannerLink; Image1.ImageUrl = dwinfor.BannerPic; } } } }
private void bindList() { SearchComBanner con = new SearchComBanner(); Pagination pagina = new Pagination(pager.PageIndex, pager.PageSize, 0); using (BLLComBanner bll = new BLLComBanner()) { List <ComBanner> lists = bll.GetPageList(con, pagina, ComBanner.ID_FieldName, ScriptQuery.SortEnum.ASC); pager.RecordCount = pagina.RecordCount; pager.PageCount = pagina.PageCount; grid_friendlink.DataSource = lists; grid_friendlink.DataBind(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { using (BLLComBanner bll = new BLLComBanner()) { ComBanner obj = new ComBanner(); if (id > 0) { obj = bll.GetSingle(id); obj.ID = id; } obj.ComBannerTypeID = Convert.ToInt32(ddlNewsType.SelectedValue); obj.BannerTitle = txtDLName.Text.Trim().ToString(); obj.BannerLink = txtLink.Text.Trim().ToString(); #region 产品图片(前台产品图片来源于此) try { if (this.UploadImg.HasFile) { string extName = Path.GetExtension(UploadImg.FileName); string virFileFullName; string fileName; WebCommon.GetUploadRandFileName(extName, out virFileFullName, out fileName); UploadImg.SaveAs(StringPlus.MapPath(virFileFullName)); if (IsAllowedExtension(StringPlus.MapPath(virFileFullName))) { if (id > 0) {//新增时无需删除 if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).BannerPic))) { File.Delete(StringPlus.MapPath(bll.GetSingle(id).BannerPic)); } } obj.BannerPic = virFileFullName; } else { if (File.Exists(StringPlus.MapPath(virFileFullName))) { File.Delete(StringPlus.MapPath(virFileFullName)); } ShowMsg("请上传正确的图片(.jpg,.gif,.bmp,.png)"); return; } } else { obj.BannerPic = Image1.ImageUrl.ToString(); } } catch (DevNetException ex) { ExceptionManager.ShowErrorMsg(this, ex); return; } #endregion bll.Save(obj); if (bll.IsFail) { ExceptionManager.ShowErrorMsg(this, bll.DevNetException); } else { JSMsg.ShowWinRedirect(this, "保存成功", "cpBannerSet.aspx"); } } }