Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     downbll = new DownAttachBLL();
     if (!IsPostBack)
     {
         GridviewDatabind(4);
     }
 }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     downbll  = new DownAttachBLL();
     downbll2 = new DownAttachBLL();
     if (!IsPostBack)
     {
         DateBind();
     }
 }
Ejemplo n.º 3
0
        public void DateBind(object id)//绑定要修改的信息
        {
            DownAttachBLL downbll = new DownAttachBLL();
            DownAttach    da      = new DownAttach();

            da               = downbll.GetDownAttach(id);
            TxtTitle.Text    = da.Title;
            TxtWriter.Text   = da.Writer;
            TxtFileName.Text = da.FileSaveName;
            TxtDate.Text     = da.AddDate.ToString("d");
            this.classification.SelectedValue = da.Cid.ToString();
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Write(Request["num"]);
            //float ab = float.Parse(Context.Request["canshu"]);
            downbll = new DownAttachBLL();
            if (!IsPostBack)
            {
                string b  = Request.Params.Get("type");
                string aa = b.Substring(0, 1);
                if (b == "0")
                {
                    GridviewDatabind2(1);
                }
                else
                {
                    if (b == "1")
                    {
                        int cid = Convert.ToInt32(b); GridviewDatabind2(cid);
                    }
                    else if (b == "2")
                    {
                        int cid = Convert.ToInt32(b); GridviewDatabind2(cid);
                    }

                    else if (aa == "a")
                    {
                        int id = Convert.ToInt32(b.Substring(1));
                        GridviewDatabind3(id);
                    }
                    else
                    {
                        int   year = Convert.ToInt32(b.Substring(0, 4));
                        float a    = (float)System.Convert.ToDouble(b.Substring(4));


                        GridviewDatabind1(year, a);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        protected void DataList1_DeleteCommand(object sender, DataListCommandEventArgs e)
        {
            DownAttachBLL downbll3 = new DownAttachBLL();;
            string        id       = e.CommandArgument.ToString();
            DownAttach    downatt  = new DownAttach();

            downatt = downbll3.GetDownAttach(id);
            string filename = downatt.FileSaveName; //获得所要删除的文件名

            if (downbll3.Delete(id))
            {
                string             url1         = "~/Attach/" + filename;
                string             webFilePath1 = Server.MapPath(url1);//用来删除原有文件资料
                System.IO.FileInfo file1        = new System.IO.FileInfo(webFilePath1);
                if (file1.Exists)
                {
                    file1.Delete();//删除
                }
                Response.Write("<script>alert('删除成功');</script>");
            }
            this.Response.Redirect(this.Request.Url.ToString());
        }
Ejemplo n.º 6
0
 protected void Delete_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < DataList1.Items.Count; i++)
     {
         if (((CheckBox)DataList1.Items[i].FindControl("selected")).Checked == true)
         {
             object        s       = ((System.Web.UI.WebControls.HyperLink)DataList1.Items[i].FindControl("Hyperlink0")).Text;
             DownAttachBLL downbll = new DownAttachBLL();
             if (downbll.Delete(s))
             {
                 string             filename     = ((System.Web.UI.WebControls.Label)DataList1.Items[i].FindControl("filename")).Text;
                 string             url1         = "~/Attach/" + filename;
                 string             webFilePath1 = Server.MapPath(url1);//用来删除原有资料
                 System.IO.FileInfo file1        = new System.IO.FileInfo(webFilePath1);
                 if (file1.Exists)
                 {
                     file1.Delete();//删除
                 }
                 Response.Write("<script>alert('删除成功');history.back();</script>");
             }
         }
     }
     this.Response.Redirect(this.Request.Url.ToString());
 }
Ejemplo n.º 7
0
        protected void uploadbtn_Click(object sender, EventArgs e)
        {
            if (TxtTitle.Text.Trim() == "" || !FileUpload1.HasFile)
            {
                Response.Write("<script>alert('资料名称和文件均不能为空');</script>");
                return;
            }
            string name = "";

            InventionModel.DownAttach da = new InventionModel.DownAttach();
            if (FileUpload1.HasFile)
            {
                FileInfo file = new FileInfo(FileUpload1.PostedFile.FileName);
                if (file.Extension.ToLower() != ".doc" && file.Extension.ToLower() != ".txt" && file.Extension.ToLower() != ".zip" && file.Extension.ToLower() != ".rar")
                {
                    Response.Write("<script>alert('上传的资料格式应为doc/txt/zip/rar格式');</script>");
                    return;
                }
                DownAttachBLL downattachbll = new DownAttachBLL();
                name = FileUpload1.FileName;                  // 客户端文件路径

                string filename = FileUpload1.PostedFile.FileName;
                filename = System.IO.Path.GetFileName(filename);
                //改文件名
                int    index    = filename.LastIndexOf(".");
                string lastName = filename.Substring(index, filename.Length - index);//获得文件后缀类型
                //新文件名称,以时间年月日时分秒作为文件名
                name = TxtTitle.Text.Trim() + DateTime.Now.ToString("hhmmss") + lastName;
                string webFilePath = Server.MapPath("/Attach/" + name);    // 服务器端文件路径
                double size        = FileUpload1.PostedFile.ContentLength; //文件大小
                if (size >= 20480000)
                {
                    Response.Write("<script>alert('上传失败!(资料容量请不要超过20MB)');history.back();</script>");

                    return;
                }
                if (!File.Exists(webFilePath))
                {
                    FileUpload1.SaveAs(webFilePath);                              // 使用 SaveAs 方法保存文件
                }
                else
                {
                    Response.Write("<script>alert('上传失败,请重试!');</script>");
                    return;
                }
            }
            //da.AddDate = DateTime.Now;
            da.Writer       = Session["UserName"].ToString();
            da.Title        = TxtTitle.Text.Trim();
            da.FileSaveName = name;
            da.Cid          = 4;
            string        sql1          = string.Format("insert into DownAttach (addDate,writer,title,filesavename,cid) values ('{0}','{1}','{2}','{3}','{4}')", da.AddDate, da.Writer, da.Title, da.FileSaveName, da.Cid);
            string        sql2          = "update tb_User set UserMark=UserMark+10 where UserName='******'";
            List <string> SQLStringList = new List <string>();

            SQLStringList.Add(sql1);
            SQLStringList.Add(sql2);
            int flag = DbHelperSQL.ExecuteSqlTran(SQLStringList);

            if (flag > 0)
            {
                Response.Write("<script>alert('上传成功!积分加10分');</script>");
                Response.Write(" <script language=javascript>parent.location.href='/Front/BBS/new_index/index2.aspx?comefrom=Uploadindex';</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');history.back();</script>");
            }
        }
Ejemplo n.º 8
0
        protected void Add_Click(object sender, EventArgs e)
        {
            DownAttach    da            = new DownAttach();
            DownAttachBLL downattachbll = new DownAttachBLL();

            string filename = FileUp.PostedFile.FileName;

            filename = System.IO.Path.GetFileName(filename);
            //改文件名
            int    index    = filename.LastIndexOf(".");
            string lastName = filename.Substring(index, filename.Length - index);//获得文件后缀类型
            //新文件名称,以时间年月日时分秒作为文件名
            string name = DateTime.Now.ToString("yyyyMMddhhmmss") + lastName;

            //name = FileUp.FileName;                  // 客户端文件路径
            string webFilePath = Server.MapPath("/Attach/" + name);  // 服务器端文件路径

            if (FileUp.HasFile)
            {
                //以下是上传资料的格式检验
                FileInfo file = new FileInfo(FileUp.PostedFile.FileName);
                if (file.Extension.ToLower() != ".doc" && file.Extension.ToLower() != ".txt" && file.Extension.ToLower() != ".zip" && file.Extension.ToLower() != ".rar" && file.Extension.ToLower() != ".pdf")
                {
                    Response.Write("<script>alert('上传的资料格式应为doc/txt/zip/rar/pdf格式');history.back(-1);</script>");
                    return;
                }
                //double size = FileUp.PostedFile.ContentLength;//文件大小
                //if (size >= 20480000)
                //{
                //    Response.Write("<script>alert('上传失败!(资料容量请不要超过20MB)');history.back();</script>");
                //    return;
                //}
                if (!File.Exists(webFilePath))
                {
                    FileUp.SaveAs(webFilePath);                              // 使用 SaveAs 方法保存文件
                }
                else
                {
                    Response.Write("<script>alert('上传失败,请重试!')</script>");
                }
            }
            else
            {
                Response.Write("文件名称为空,请填写要上传文件的名称");
                return;
            }
            da.AddDate = Convert.ToInt32(TxtDate.Text.Trim()
                                         );
            da.Writer       = Server.HtmlEncode(TxtWriter.Text.Trim());
            da.Title        = Server.HtmlEncode(TxtTitle.Text.Trim());
            da.FileSaveName = name;
            da.FileId       = TextBox1.Text.Trim();

            if (classification.SelectedItem.Text == "自然版过刊")
            {
                da.Cid = 1;
                if (classfenqi.SelectedItem.Text == "第一期")
                {
                    da.Type = 1.1F;
                }
                else if (classfenqi.SelectedItem.Text == "第二期")
                {
                    da.Type = 1.2F;
                }
                else if (classfenqi.SelectedItem.Text == "第三期")
                {
                    da.Type = 1.3F;
                }
                else if (classfenqi.SelectedItem.Text == "第四期")
                {
                    da.Type = 1.4F;
                }
                else if (classfenqi.SelectedItem.Text == "第五期")
                {
                    da.Type = 1.5F;
                }
                else if (classfenqi.SelectedItem.Text == "第六期")
                {
                    da.Type = 1.6F;
                }
            }
            else if (classification.SelectedItem.Text == "社科版过刊")
            {
                da.Cid = 2;
                if (classfenqi.SelectedItem.Text == "第一期")
                {
                    da.Type = 2.1F;
                }
                else if (classfenqi.SelectedItem.Text == "第二期")
                {
                    da.Type = 2.2F;
                }
                else if (classfenqi.SelectedItem.Text == "第三期")
                {
                    da.Type = 2.3F;
                }
                else if (classfenqi.SelectedItem.Text == "第四期")
                {
                    da.Type = 2.4F;
                }
                else if (classfenqi.SelectedItem.Text == "第五期")
                {
                    da.Type = 2.5F;
                }
                else if (classfenqi.SelectedItem.Text == "第六期")
                {
                    da.Type = 2.6F;
                }
            }
            //else if (classification.SelectedItem.Text == "BBS资料")
            //{ da.Cid = 4; }
            else
            {
                da.Cid = 3;
            }
            da.Count = 1;

            if (downattachbll.Add(da))
            {
                Response.Write("<script>alert('添加成功');window.location.href='DownMgr.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');history.back();</script>");
            }
        }
Ejemplo n.º 9
0
        protected void Save_Click(object sender, EventArgs e)
        {
            object        id      = Request.QueryString["id"];//有待改善不安全
            DownAttach    da      = new DownAttach();
            DownAttachBLL downbll = new DownAttachBLL();

            // da.AddDate = Convert.ToInt32(dr["AddDate"].ToString()); ;
            da.Writer = Server.HtmlEncode(TxtWriter.Text.Trim());
            da.Title  = Server.HtmlEncode(TxtTitle.Text.Trim());
            da.Id     = id;
            if (classification.SelectedItem.Text == "自然版过刊")
            {
                da.Cid = 1;
            }
            else if (classification.SelectedItem.Text == "社科版过刊")
            {
                da.Cid = 2;
            }
            //else if (classification.SelectedItem.Text == "TRIZ书籍")
            //{
            //    da.Cid = 3;
            //}
            //else if (classification.SelectedItem.Text == "BBS资料")
            //{
            //    da.Cid = 4;
            //}

            if (FileUp.PostedFile.ContentLength == 0)
            {
                da.FileSaveName = TxtFileName.Text;
            }
            else
            {
                //以下是上传资料的格式检验
                FileInfo file1 = new FileInfo(FileUp.PostedFile.FileName);
                if (file1.Extension.ToLower() != ".doc" && file1.Extension.ToLower() != ".txt" && file1.Extension.ToLower() != ".zip" && file1.Extension.ToLower() != ".rar")
                {
                    Response.Write("<script>alert('上传的资料格式应为doc/txt/zip/rar格式');history.back(-1);</script>");
                    return;
                }

                string filename = FileUp.PostedFile.FileName;
                filename = System.IO.Path.GetFileName(filename);
                //改文件名
                int    index    = filename.LastIndexOf(".");
                string lastName = filename.Substring(index, filename.Length - index);//获得文件后缀类型
                //新文件名称,以时间年月日时分秒作为文件名
                string name = TxtTitle.Text.Trim() + DateTime.Now.ToString("hhmmss") + lastName;

                string             webFilePath = Server.MapPath("~/Attach/" + TxtFileName.Text); //用来删除原有的资料
                string             newpath     = Server.MapPath("~/Attach/" + name);             //用来保存新上传的资料
                System.IO.FileInfo file        = new System.IO.FileInfo(webFilePath);
                if (file.Exists)
                {
                    file.Delete();//删除
                }
                if (!File.Exists(newpath))
                {
                    FileUp.SaveAs(newpath);                            // 使用 SaveAs 方法保存文件
                }
                da.FileSaveName = name;
            }
            if (downbll.Update(da))
            {
                Response.Write("<script>alert('修改成功');window.location.href='DownMgr.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败');history.back();</script>");
            }
        }
Ejemplo n.º 10
0
 public void sheke()//通知通告
 {
     showyear = new DownAttachBLL();
     this.Datalist1.DataSource = showyear.Getlist1();
     this.Datalist1.DataBind();
 }
Ejemplo n.º 11
0
 public void ziran()//通知通告
 {
     showyear = new DownAttachBLL();
     this.DatalistNotice.DataSource = showyear.Getlist();
     this.DatalistNotice.DataBind();
 }