//保存
    protected void Button_Save_Click(object sender, EventArgs e)
    {
        if (this.Session["hyuid"].ToString() == "")
            this.Response.Redirect("../login.aspx");

        string ls_tip = "保存成功!";

        //新文档时
        HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
        HyoaClass.Hyoa_wjcd_class Hyoa_wjcd_class = new HyoaClass.Hyoa_wjcd_class();
        if (this.txtop.Value == "add")
        {
            Hyoa_wjcd_class.ID = Hyoa_global.GetRandom();
            Hyoa_wjcd_class.ClassName = this.txtname.Value;
            Hyoa_wjcd_class.ClassSort = System.Int32.Parse(this.txtsort.Value);
            Hyoa_wjcd_class.Insert();
        }
        else
        {
            Hyoa_wjcd_class.ID = this.txtdocid.Value;
            Hyoa_wjcd_class.ClassName = this.txtname.Value;
            Hyoa_wjcd_class.ClassSort = System.Int32.Parse(this.txtsort.Value);
            Hyoa_wjcd_class.Update();
        }

        //处理完成后的提示及跳转
        if (this.txtifpop.Value == "")
        {
            Response.Write("<script>alert('" + ls_tip + "');window.location='" + this.txturl.Value + "'</script>");
        }
        else
        {
            Response.Write("<script>alert('" + ls_tip + "');self.close();</script>");
        }
    }
 protected void btndelinfo_Click(object sender, EventArgs e)
 {
     HyoaClass.Hyoa_wjcd_class Hyoa_wjcd_class = new HyoaClass.Hyoa_wjcd_class();
     String[] v_uids = this.txtuids.Value.Split(',');
     for (var i = 0; i < v_uids.Length; i++)
     {
         if (v_uids[i] != "")
         {
             Hyoa_wjcd_class.ID = v_uids[i];
             Hyoa_wjcd_class.Delete();
         }
     }
     this.txtuids.Value = "";
     //DataPlay(1);
     DataPlay(System.Int32.Parse(this.curpage.Text));
 }
    private void DataPlay()
    {
        //加载文件分类
        HyoaClass.Hyoa_wjcd_class Hyoa_wjcd_class = new HyoaClass.Hyoa_wjcd_class();
        DataTable dt_class = Hyoa_wjcd_class.Getdocs();
        ddlhy_foldername.DataTextField = "ClassName";
        ddlhy_foldername.DataSource = dt_class;
        ddlhy_foldername.DataBind();
        this.ddlhy_foldername.Items.Insert(0, new ListItem("--请选择--", ""));

        //新文档
        if (this.txtop.Value == "add")
        {
            HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
            this.txtdocid.Value = Hyoa_global.GetRandom();
            this.lblhy_fsrid.Text = Session["hyuid"].ToString();
            this.lblhy_fsrname.Text = Session["hyuname"].ToString();
            this.lblhy_datetime.Text = System.DateTime.Now.ToString();
            //如果是回复
            if (this.Request.QueryString["fhid"] != null)
            {
                HyoaClass.Hyoa_wjcd Hyoa_wjcd = new HyoaClass.Hyoa_wjcd();
                DataTable dt = Hyoa_wjcd.Getdoc(this.Request.QueryString["fhid"].ToString());
                if (dt.Rows.Count > 0)
                {
                    this.txthy_jsrid.Text = dt.Rows[0]["hy_fsrid"].ToString();
                    this.txthy_jsrname.Value = dt.Rows[0]["hy_fsrname"].ToString();
                    this.txthy_title.Text = "回复:"+dt.Rows[0]["hy_title"].ToString();
                }
            }
            //如果是转发
            if (this.Request.QueryString["zfid"] != null)
            {
                HyoaClass.Hyoa_wjcd Hyoa_wjcd = new HyoaClass.Hyoa_wjcd();
                DataTable dt = Hyoa_wjcd.Getdoc(this.Request.QueryString["zfid"].ToString());
                if (dt.Rows.Count > 0)
                {
                    this.txthy_title.Text = "转发:" + dt.Rows[0]["hy_title"].ToString();
                    this.hy_content1.Value = dt.Rows[0]["hy_body"].ToString();
                    this.txtdocid.Value = dt.Rows[0]["docid"].ToString();

                    //附件
                    HyoaClass.Hyoa_fileatt Hyoa_fileatt = new HyoaClass.Hyoa_fileatt();
                    DataTable dt_fileatt = Hyoa_fileatt.GetfileattByFatherid(dt.Rows[0]["DOCID"].ToString());
                    if (dt_fileatt.Rows.Count > 0)
                    {
                        string ls_temp = "";
                        for (var i = 0; i < dt_fileatt.Rows.Count; i++)
                        {
                            ls_temp += (i + 1).ToString() + "、<a href='/" + dt_fileatt.Rows[i]["hy_filepath"].ToString() + "' target='_blank'>" + dt_fileatt.Rows[i]["hy_filename"].ToString() + "</a><br />";
                        }
                        this.lblhy_field2.Text = ls_temp;

                    }
                }
                this.uploadhy_field2.Visible = false;

                this.jzsjtxfs.Visible = false;
            }
        }
        else
        {
            if (this.Request.QueryString["id"] != null)
            {
                this.txtid.Value = this.Request.QueryString["id"].ToString();
            }
            HyoaClass.Hyoa_wjcd Hyoa_wjcd = new HyoaClass.Hyoa_wjcd();
            DataTable dt = Hyoa_wjcd.Getdoc(this.txtid.Value);
            if (dt.Rows.Count > 0)
            {
                this.txtdocid.Value = dt.Rows[0]["DOCID"].ToString();
                this.txtid.Value = dt.Rows[0]["ID"].ToString();

                this.lblhy_fsrid.Text = dt.Rows[0]["hy_fsrid"].ToString();
                this.lblhy_fsrname.Text = dt.Rows[0]["hy_fsrname"].ToString();
                this.lblhy_datetime.Text = dt.Rows[0]["hy_datetime"].ToString();
                this.txthy_jsrname.Value = dt.Rows[0]["hy_jsrname"].ToString();
                this.txthy_jsrid.Text = dt.Rows[0]["hy_jsrid"].ToString();
                this.txthy_title.Text = dt.Rows[0]["hy_title"].ToString();

                //附件
                HyoaClass.Hyoa_fileatt Hyoa_fileatt = new HyoaClass.Hyoa_fileatt();
                DataTable dt_fileatt = Hyoa_fileatt.GetfileattByFatherid(this.txtdocid.Value);
                if (dt_fileatt.Rows.Count > 0)
                {
                    string ls_temp = "";
                    for (var i = 0; i < dt_fileatt.Rows.Count; i++)
                    {
                        ls_temp += (i + 1).ToString() + "、<a href='/" + dt_fileatt.Rows[i]["hy_filepath"].ToString() + "' target='_blank'>" + dt_fileatt.Rows[i]["hy_filename"].ToString() + "</a><br />";
                    }
                    this.lblhy_field2.Text = ls_temp;
                }

                this.hy_content1.Value = dt.Rows[0]["hy_body"].ToString();
                this.ddlifsavetofjx.SelectedValue = dt.Rows[0]["hy_ifsavetofjx"].ToString();
                this.ddlhy_foldername.SelectedValue = dt.Rows[0]["hy_foldername"].ToString();

            }
        }
    }
    private void DataPlay()
    {
        if (this.Request.QueryString["op"] != null)
        {
            this.txtop.Value = this.Request.QueryString["op"].ToString();           //新增还是修改

            //判断当前用户是否有保存的权限
            string ls_role = "";
            HyoaClass.Hyoa_mudel Hyoa_mudel = new HyoaClass.Hyoa_mudel();
            DataTable dt_mudel = Hyoa_mudel.Getmudel(this.hy_mudelid.Text);
            if (dt_mudel.Rows.Count > 0)
            {
                ls_role = dt_mudel.Rows[0]["hy_roleid"].ToString();
            }
            HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
            this.btn_submit.Visible = false; //保存
            if (Hyoa_global.isHaveRole("Role9999", this.Session["hyuid"].ToString()))
            {
                this.btn_submit.Visible = true; //保存
            }
            if (Hyoa_global.isHaveRole(ls_role, this.Session["hyuid"].ToString()))
            {
                this.btn_submit.Visible = true; //保存
            }

            //旧文档
            if (this.Request.QueryString["op"] == "modify")
            {
                if (this.Request.QueryString["id"] != null)
                {
                    //根据id得到信息
                    this.txtdocid.Value = this.Request.QueryString["id"].ToString();
                    HyoaClass.Hyoa_wjcd_class Hyoa_wjcd_class = new HyoaClass.Hyoa_wjcd_class();
                    DataTable dt = Hyoa_wjcd_class.Getdoc(this.txtdocid.Value);
                    if (dt.Rows.Count > 0)
                    {
                        this.txtsort.Value = dt.Rows[0]["ClassSort"].ToString();
                        this.txtname.Value = dt.Rows[0]["ClassName"].ToString();
                    }
                    dt.Clear();
                }
            }
        }
    }
    private void DataPlay(int PageNo)
    {
        //得到当前模块对应的role
        HyoaClass.Hyoa_mudel Hyoa_mudel = new HyoaClass.Hyoa_mudel();
        DataTable dt_mudel = Hyoa_mudel.Getmudel(this.txtmudelid.Value);
        string ls_role = "Role9999";
        if (dt_mudel.Rows.Count > 0)
        {
            ls_role = dt_mudel.Rows[0]["hy_roleid"].ToString();
        }
        HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
        if (Hyoa_global.isHaveRole(ls_role, this.Session["hyuid"].ToString()))
        {
            this.tdnewdoc.Visible = true;
            this.tddeldoc.Visible = true;
        }

        //得到当前页号
        this.curpage.Text = PageNo.ToString();
        HyoaClass.Hyoa_wjcd_class Hyoa_wjcd_class = new HyoaClass.Hyoa_wjcd_class();

        DataTable dt;
        dt = Hyoa_wjcd_class.Getdocs();

        DataTable tempTable = dt.Clone();
        for (int i = (PageNo - 1) * System.Int32.Parse(PageSize.Text); i < PageNo * System.Int32.Parse(PageSize.Text); i++)
        {
            if (i > dt.Rows.Count - 1)
                break;

            DataRow dr = tempTable.NewRow();
            for (int j = 0; j < dt.Columns.Count; j++)
            {
                dr[dt.Columns[j].ColumnName] = dt.Rows[i][j];
            }
            tempTable.Rows.Add(dr);
        }

        int TotalRecord = dt.Rows.Count;
        this.sumts.Text = TotalRecord.ToString();
        this.sumts2.Text = TotalRecord.ToString();
        this.ShowTotalRecord.Text = TotalRecord.ToString();
        //计算及显示总页数
        int TotalPage;
        if (TotalRecord < System.Int32.Parse(PageSize.Text))
        {
            TotalPage = 1;
        }
        else
        {
            if (TotalRecord % System.Int32.Parse(PageSize.Text) != 0)
            {
                TotalPage = TotalRecord / System.Int32.Parse(PageSize.Text) + 1;

            }
            else
            {
                TotalPage = TotalRecord / System.Int32.Parse(PageSize.Text);

            }
        }
        this.ShowTotalPage.Text = TotalPage.ToString();
        this.rptlist.DataSource = tempTable;
        this.rptlist.DataBind();
        dt.Clear();
    }