/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbDel_Click(object sender, CommandEventArgs e) { int pwid = Convert.ToInt32(e.CommandArgument); JumbotOA.Entity.PlanEntity model = new JumbotOA.Entity.PlanEntity(); model = new JumbotOA.BLL.PlanBLL().GetEntity(pwid); string islock = model.Locked; if (islock == "未锁定") { new JumbotOA.BLL.PlanBLL().Delete(Convert.ToInt32(e.CommandArgument)); string dirpath = Server.MapPath("~/Worddoc"); if (Directory.Exists(dirpath) == false) { Directory.CreateDirectory(dirpath); } string FileName = Path.GetFileName(model.Pwpath); string lastpath = dirpath + @"\" + FileName; File.Delete(lastpath); Selectinfo(" and uid = " + UserId + ""); } else { System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler; page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript", "<script language='javascript'>alert('该文件已锁定!');</script>"); } }
/// <summary> /// 获取信息 /// </summary> public void Selectinfo(string str) { int count; JumbotOA.BLL.PlanBLL bll = new JumbotOA.BLL.PlanBLL(); this.Plan_repeater.DataSource = bll.getpage(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, out count, str); this.Plan_repeater.DataBind(); AspNetPager1.RecordCount = count; }
/// <summary> /// 下载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbDown_Click(object sender, CommandEventArgs e) { string path = ""; JumbotOA.Entity.PlanEntity model = new JumbotOA.Entity.PlanEntity(); model = new JumbotOA.BLL.PlanBLL().GetEntity(Convert.ToInt32(e.CommandArgument)); path = model.Pwpath; DownloadFile(path); }
/// <summary> /// 下载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbDown_Click(object sender, CommandEventArgs e) { string path = ""; JumbotOA.Entity.PlanEntity model = new JumbotOA.Entity.PlanEntity(); model = new JumbotOA.BLL.PlanBLL().GetEntity(Convert.ToInt32(e.CommandArgument)); path = model.Pwpath; model.Locked = "锁定"; new JumbotOA.BLL.PlanBLL().Update(model); DownloadFile(path); }
//插入信息 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string dirpath = Server.MapPath("~/Worddoc"); if (Directory.Exists(dirpath) == false) { Directory.CreateDirectory(dirpath); } Random ro = new Random(); int name = 1; string FileName = ""; string FileExtention = ""; FileName = Path.GetFileName(this.fuFile.FileName); string stro = ro.Next(100, 100000000).ToString() + name.ToString();//产生一个随机数用于新命名的文件 string NewName = DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + stro; if (FileName.Length > 0)//有文件才执行上传操作再保存到数据库 { FileExtention = Path.GetExtension(this.fuFile.FileName); string ppath = dirpath + @"\" + NewName + FileExtention; this.fuFile.SaveAs(ppath); JumbotOA.Entity.PlanEntity model = new JumbotOA.Entity.PlanEntity(); model.Uid = UserId; model.Pwtitle = this.txtTitle.Text; model.Pwdate = DateTime.Now; model.Manager = this.ddlManager.SelectedValue; model.Pwpath = "Worddoc/" + NewName + FileExtention; model.Locked = "未锁定"; int i = new JumbotOA.BLL.PlanBLL().Add(model); if (i > 0) { FinalMessage("操作成功", "My_Plan_List.aspx", 0); } else { System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler; page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript", "<script language='javascript'>alert('对不起,操作失败!');</script>"); } } }