private int AddData() { if (DAL.ResourcesDownload.Exists(Request["resource"].ToString())) { return(-3); } string savepath = Server.MapPath("~/upload/ResourceDownload/"); string extension = Request.Files[0].FileName.Substring(Request.Files[0].FileName.LastIndexOf('.')); string filename = Request["resource"].ToString() + extension; try { Request.Files[0].SaveAs(savepath + filename); Model.ResourcesDownload rd = new Model.ResourcesDownload(); rd.ResourceName = Request["resource"].ToString(); rd.ResourcePath = savepath + filename; rd.UploadUser = Session["UserName"].ToString(); rd.UploadTime = DateTime.Now; rd.Remark = ""; DAL.ResourcesDownload.Add(rd); return(1); } catch { return(-1); } }
private void UpdateData() { int id = Convert.ToInt32(Request["ID"].ToString()); Model.ResourcesDownload rd = DAL.ResourcesDownload.GetModel(id); rd.ResourceName = Request["resourcename"].Trim(); flag = 1; DAL.ResourcesDownload.Update(rd); Response.ContentType = "text/plain"; Response.Write("0"); Response.End(); }