/// <summary> /// 增加一条数据 /// </summary> public bool AddDownloadCenterReturn(DownloadCenter entity) { try { linqHelper.InsertEntity <DownloadCenter>(entity); return(true); } catch { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="entity"></param> public void UpdateDownloadCenter(DownloadCenter entity) { new DownloadCenterDAL().UpdateDownloadCenter(entity); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="entity"></param> public void AddDownloadCenter(DownloadCenter entity) { service.AddDownloadCenter(entity); }
/// <summary> /// 增加一条数据 /// </summary> public bool AddDownloadCenterReturn(DownloadCenter entity) { return(service.AddDownloadCenterReturn(entity)); }
/// <summary> /// 更新一条数据 /// </summary> public void UpdateDownloadCenter(DownloadCenter entity) { linqHelper.UpdateEntity <DownloadCenter>(entity); }
/// <summary> /// 增加一条数据 /// </summary> public void AddDownloadCenter(DownloadCenter entity) { linqHelper.InsertEntity <DownloadCenter>(entity); }
//保存 protected void btnSave_Click(object sender, EventArgs e) { if (verify()) { string imgurl = "/Image/DownloadCenter/"; DownloadCenterBLL downloadCenterBLL = new DownloadCenterBLL(); DownloadCenter downloadCenter = new DownloadCenter(); downloadCenter.PublishUserCode = PageBase.GetLoginCode(); downloadCenter.Title = this.txtTitle.Text.Trim(); downloadCenter.IsDel = 1; downloadCenter.DownNum = 0; downloadCenter.PublishTime = DateTime.Now; if (string.IsNullOrEmpty(downloadCenter.Title)) { downloadCenter.Title = FileUpload1.FileName; } //修改 if (!string.IsNullOrEmpty(Request.QueryString["id"])) { int id = Check.GetInt32(Request.QueryString["id"]); DownloadCenter model = downloadCenterBLL.GetDownloadCenterEntity(id); if (model != null && model.Id > 0) { downloadCenter.Id = id; downloadCenter.AffixNewName = model.AffixNewName; downloadCenter.AffixOldName = model.AffixOldName; downloadCenter.AffixUrl = model.AffixUrl; downloadCenter.DownNum = model.DownNum; downloadCenter.PublishTime = model.PublishTime; downloadCenter.PublishUserCode = model.PublishUserCode; downloadCenter.Size = model.Size; downloadCenter.Suffix = model.Suffix; bool edit = true; if (FileUpload1.HasFile) { downloadCenter.Size = FileUpload1.PostedFile.ContentLength; downloadCenter.Suffix = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName).ToString(); downloadCenter.AffixUrl = imgurl; //downloadCenter.AffixOldName = FileUpload1.PostedFile.FileName; downloadCenter.AffixOldName = FileUpload1.FileName; //string newName = DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(0, 1000).ToString() + downloadCenter.Suffix; downloadCenter.AffixNewName = FileUpload1.FileName; //if(UploadFiled(FileUpload1,imgurl)) // Response.Redirect("DownloadCenterList.aspx"); string returnStr = UploadFiled(FileUpload1, imgurl, FileUpload1.FileName); if (returnStr != "上传成功") { edit = false; ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + returnStr + "');", true); //Alert(returnStr); } } if (edit) { try { downloadCenterBLL.UpdateDownloadCenter(downloadCenter); Response.Redirect("DownloadCenterList.aspx"); } catch { //Alert("修改失败,请重试"); ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改失败,请重试');", true); } } } } else { downloadCenter.Size = FileUpload1.PostedFile.ContentLength; downloadCenter.Suffix = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName).ToString(); downloadCenter.AffixUrl = imgurl; //downloadCenter.AffixOldName = FileUpload1.PostedFile.FileName; downloadCenter.AffixOldName = FileUpload1.FileName; //string newName = DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(0, 1000).ToString()+downloadCenter.Suffix; downloadCenter.AffixNewName = FileUpload1.FileName; string returnStr = UploadFiled(FileUpload1, imgurl, FileUpload1.FileName); if (returnStr == "上传成功") { if (downloadCenterBLL.AddDownloadCenterReturn(downloadCenter)) { Response.Redirect("DownloadCenterList.aspx"); } else { //Alert("添加失败,请重试"); ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败,请重试');", true); } } else { ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + returnStr + "');", true); //Alert(returnStr); } } } }