//ntko_class db = new ntko_class();//实例ntko_class类
        protected void Page_Load(object sender, EventArgs e)
        {
            //title = db.getdemotitle();
            //attachpath = db.getattachpath();
            if (this.Session["hyuid"].ToString() == "")
                this.Response.Redirect("../login.aspx?url=" + this.Request.RawUrl);

            //加载模板
            HyoaClass.Hyoa_ntkotemplateFile Hyoa_ntkotemplateFile = new HyoaClass.Hyoa_ntkotemplateFile();
            DataTable dt_templateFile = Hyoa_ntkotemplateFile.GettemplateFiles();
            this.templateFile.DataSource = dt_templateFile;
            this.templateFile.DataTextField = "templateFilename";
            this.templateFile.DataValueField = "templateFileurl";
            this.templateFile.DataBind();
            this.templateFile.Items.Insert(0, new ListItem("--请选择模板--", ""));
            this.templateFile.SelectedIndex = 0;

            //加载印章
            HyoaClass.Hyoa_ntkoesp Hyoa_ntkoesp = new HyoaClass.Hyoa_ntkoesp();
            DataTable dt_esp = Hyoa_ntkoesp.Getesps();
            this.SignFileUrl.DataSource = dt_esp;
            this.SignFileUrl.DataTextField = "espname";
            this.SignFileUrl.DataValueField = "espurl";
            this.SignFileUrl.DataBind();
            this.SignFileUrl.Items.Insert(0, new ListItem("--请选择印章--", ""));
            this.SignFileUrl.SelectedIndex = 0;

            //加载红头
            HyoaClass.Hyoa_ntkohongtou Hyoa_ntkohongtou = new HyoaClass.Hyoa_ntkohongtou();
            DataTable dt_hongtou = Hyoa_ntkohongtou.Gethongtous();
            this.redHeadTemplateFile.DataSource = dt_hongtou;
            this.redHeadTemplateFile.DataTextField = "hongtouname";
            this.redHeadTemplateFile.DataValueField = "hongtouurl";
            this.redHeadTemplateFile.DataBind();
            this.redHeadTemplateFile.Items.Insert(0, new ListItem("--请选择红头--", ""));
            this.redHeadTemplateFile.SelectedIndex = 0;

            title = "宁波合益";
            hyusername = this.Session["hyuname"].ToString();
            //设置第一环节是否在痕迹模式下编辑
            tacheByhj = "0";//痕迹模式下编辑
            if (this.Request.QueryString["tacheByhj"] != null)
            {
                if (this.Request.QueryString["tacheByhj"].ToString() == "1")
                {
                    tacheByhj = "1";    //非痕迹模式下编辑
                }
            }
            //是否显示接受修订按钮
            if (this.Request.QueryString["jsxd"] != null)
            {
                if (this.Request.QueryString["jsxd"].ToString() == "1")
                {
                    btnjsxd = "<input id=\"Button2\" type=button style =\"width:70px;height:23px;\" onclick=\"TANGER_OCX_AllRevisions(true);\" runat=\"server\" value=\" 接受修订\"  />";
                }
            }

            newofficetype = Request.QueryString["newofficetype"];
            HyoaClass.Hyoa_ntko Hyoa_ntko = new HyoaClass.Hyoa_ntko();
            if (this.Request.QueryString["fatherid"] != null)
            {
                fatherid = this.Request.QueryString["fatherid"].ToString();

                DataTable dtfatherid = Hyoa_ntko.GetntkofileByfother(fatherid);
                //this.Response.Write("<script>alert('" + dtfatherid.Rows.Count + "');</script>");
                if (dtfatherid.Rows.Count > 0)
                {
                    url = dtfatherid.Rows[0]["fid"].ToString();

                    DataTable dt = Hyoa_ntko.Getntkofile(url);
                    if (dt.Rows.Count > 0)
                    {
                        fileid = dt.Rows[0]["fid"].ToString();
                        filetitle = dt.Rows[0]["ftitle"].ToString();
                        fileother = dt.Rows[0]["fother"].ToString();
                        filename = dt.Rows[0]["fname"].ToString();
                    }
                }
            }

            tableid = "";
            if (this.Request.QueryString["tableid"] != null)
            {
                tableid = Request.QueryString["tableid"].ToString();
            }

            //隐藏控制(根据fatherid)
            string ls_flowid = "";
            string ls_currenttacheid = "";
            HyoaClass.Hyoa_flowtachefield Hyoa_flowtachefield = new HyoaClass.Hyoa_flowtachefield();
            HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
            string sql = "";
            sql = "select * from hyc_" + tableid + " where DOCID='" + fatherid + "' ";
            DataTable dt_flowmain = Hyoa_global.GetDataTable(sql);
            if (dt_flowmain.Rows.Count > 0)
            {
                ls_flowid = dt_flowmain.Rows[0]["hy_flowid"].ToString();
                ls_currenttacheid = dt_flowmain.Rows[0]["hy_curtacheid"].ToString();
                //根据当前环节ID得到对应的隐藏权限
                DataTable dt_flowtachefield = Hyoa_flowtachefield.Getflowtachefield_gl(ls_flowid, ls_currenttacheid);
                if (dt_flowtachefield.Rows.Count > 0)
                {
                    for (var i = 0; i < dt_flowtachefield.Rows.Count; i++)
                    {
                        if (dt_flowtachefield.Rows[i]["hy_fieldname"].ToString() == "选择模板")
                        {
                            xuanzemubangongneng.Visible = true;
                        }
                        if (dt_flowtachefield.Rows[i]["hy_fieldname"].ToString() == "界面设置")
                        {
                            jiemianshezhi.Visible = true;
                        }
                        if (dt_flowtachefield.Rows[i]["hy_fieldname"].ToString() == "打印控制")
                        {
                            dayinkongzhi.Visible = true;
                        }
                        if (dt_flowtachefield.Rows[i]["hy_fieldname"].ToString() == "印章和图片")
                        {
                            yinzhanghetupiangongneng.Visible = true;
                        }
                        if (dt_flowtachefield.Rows[i]["hy_fieldname"].ToString() == "套红功能")
                        {
                            taohonggongneng.Visible = true;
                        }
                        if (dt_flowtachefield.Rows[i]["hy_fieldname"].ToString() == "接受修订")
                        {
                            jieshouxiuding.Visible = true;
                        }
                        if (dt_flowtachefield.Rows[i]["hy_fieldname"].ToString() == "权限控制")
                        {
                            quanxiankongzhi.Visible = true;
                        }
                    }
                }
            }
            else
            {
                //未找到,则默认权限
                xuanzemubangongneng.Visible = true;
                jiemianshezhi.Visible = true;
                dayinkongzhi.Visible = true;
                yinzhanghetupiangongneng.Visible = true;
                taohonggongneng.Visible = true;
                jieshouxiuding.Visible = true;
                quanxiankongzhi.Visible = true;
            }

            //生成痕迹稿start
            //在接受修订环节,打开文档时生成痕迹稿。
            string lsMapPath="";
            string lsMapPathsdec = "";
            if (this.Request.QueryString["jsxd"] != null)
            {
                if (this.Request.QueryString["jsxd"].ToString() == "1")
                {
                    lsMapPath = Server.MapPath("~/")+"/NTKO/uploadOfficeFile/"+filename;    //虚拟目录的位置
                    if (filename.IndexOf(".doc") > 0)
                    {
                        lsMapPathsdec = Server.MapPath("~/") + "/NTKO/uploadOfficeFile/" + filename.Substring(0, filename.IndexOf(".doc")) + "hjbl" + ".doc";//虚拟目录的位置
                    }
                    if (filename.IndexOf(".wps") > 0)
                    {
                        lsMapPathsdec = Server.MapPath("~/") + "/NTKO/uploadOfficeFile/" + filename.Substring(0, filename.IndexOf(".wps")) + "hjbl" + ".wps";//虚拟目录的位置
                    }
                        //File.Delete(lsMapPathsdec);
                    if (File.Exists(lsMapPathsdec))
                    {
                        //如果文件已经存在了,就不用产生痕迹稿了
                    }
                    else
                    {   //如果没有生成则生成痕迹稿
                        File.Copy(lsMapPath, lsMapPathsdec, false);
                    }

                }
            }
            //生成痕迹稿end
        }
    private void DataPlay(int PageNo)
    {
        //判断当前用户是否有新建删除权限
        HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
        string ls_mudelid = "";
        string ls_role = "";
        if (Request.QueryString["mid"] != null)
        {
            ls_mudelid = Request.QueryString["mid"].ToString();
        }
        HyoaClass.Hyoa_mudel Hyoa_mudel = new HyoaClass.Hyoa_mudel();
        DataTable dt_mudel = Hyoa_mudel.Getmudel(ls_mudelid);
        if (dt_mudel.Rows.Count > 0)
        {
            ls_role = dt_mudel.Rows[0]["hy_roleid"].ToString();
        }
        if (Hyoa_global.isHaveRole(ls_role, this.Session["hyuid"].ToString()))
        {
            this.isrole.Value = "1";
            this.tdnewdoc.Visible = true; //新建
            this.tddeldoc.Visible = true; //删除
        }
        else
        {
            this.isrole.Value = "0";
            this.tdnewdoc.Visible = false; //新建
            this.tddeldoc.Visible = false; //删除
        }

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

        DataTable dt;
        dt = Hyoa_ntkotemplateFile.GettemplateFiles();

        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();
    }