//加载主表单    Written by xf 20110515
    private void DataPlay()
    {
        txtsavefields.Text = "";
        txtsavefields_sx.Text = "";

        if (this.Request.QueryString["op"] != null)
        {
            this.txtop.Value = this.Request.QueryString["op"].ToString();           //新增还是修改
            HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();

            #region 新文档
            if (this.Request.QueryString["op"] == "add")
            {
                this.td_ydry.Visible = false; //新文档时,“已读人员”按钮隐藏

                //文档ID(保存POST到当前页面时,DOCID不重新加载)
                if (!this.IsPostBack)
                {
                    this.txtdocid.Value = Hyoa_global.GetRandom();
                    this.hy_djsj.Text = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                this.hy_djrid.Text = this.Session["hyuid"].ToString();
                this.hy_djrname.Text = this.Session["hyuname"].ToString();
                this.hy_djrbmid.Text = this.Session["hydeptid"].ToString();
                this.hy_djrbmname.Text = this.Session["hydeptname"].ToString();

                this.lblcurtachenameshow.Text = this.lbltablename.Text;
                //如果非流程(授权用户可新建信息、可删除所有信息)
                if (this.txttablerole.Value == "0")
                {
                    if (Hy_IfHaveRole(this.hy_mudelid.Text, Session["hyuid"].ToString()) == "1")
                        this.txtSystemClRight.Value = "1";
                }
                //如果非流程(每个人管理自己的信息)
                if (this.txttablerole.Value == "1")
                {
                    this.txtSystemClRight.Value = "1";
                }
                //如果非流程(每个人管理自己的信息、授权用户可管理所有信息)
                if (this.txttablerole.Value == "2")
                {
                    this.txtSystemClRight.Value = "1";
                }
                //如果非流程(授权用户可新建、只能删自己新建的信息)
                if (this.txttablerole.Value == "3")
                {
                    if (Hy_IfHaveRole(this.hy_mudelid.Text, Session["hyuid"].ToString()) == "1")
                        this.txtSystemClRight.Value = "1";
                }
                if (this.txtSystemClRight.Value == "1")
                {
                    this.td_submit.Visible = true; //保存
                    this.td_continue.Visible = true; //保存并继续新建
                    this.td_xyb.Visible = false;   //下一步

                    if (this.hy_tableid.Text == "Tablekdjrht" || this.hy_tableid.Text == "Tablesyyhfwxy" || this.hy_tableid.Text == "Tablejdhazfwht" || this.hy_tableid.Text == "TableVODfwxy" || this.hy_tableid.Text == "Tableffpdfwht" || this.hy_tableid.Text == "TableDVBazfwdght" || this.hy_tableid.Text == "Tablejwdsjsxy" || this.hy_tableid.Text == "Tablejwdscsxy" || this.hy_tableid.Text == "Tablekdjrht" || this.hy_tableid.Text == "Tablesjcsfwht" || this.hy_tableid.Text == "Tablesjgdcsfwht" || this.hy_tableid.Text == "Tablesjtxyyhzxy" || this.hy_tableid.Text == "Tablezdyht" || this.hy_tableid.Text == "Tablegxhzhht" || this.hy_tableid.Text == "Tableqtht" || this.hy_tableid.Text == "Tablexjsq" || this.hy_tableid.Text == "Tableshd" || this.hy_tableid.Text == "Tableszds")
                    {
                        this.td_continue.Visible = false;
                        this.td_xyb.Visible = true;
                    }
                    if (this.hy_tableid.Text == "Tablesyyhfwxy_new" || this.hy_tableid.Text == "Tableszdsywfwht_new" || this.hy_tableid.Text == "Tablejwdscsxy_new" || this.hy_tableid.Text == "Tablejwdsjm" || this.hy_tableid.Text == "Tablesjcsfwht_new" || this.hy_tableid.Text == "Tablekdjrht_new" || this.hy_tableid.Text == "Tablesjgdcsfwht_new" || this.hy_tableid.Text == "Tablesjtxyyhzxy_new" || this.hy_tableid.Text == "Tablegcsght")
                    {
                        this.td_continue.Visible = false;
                        this.td_xyb.Visible = true;
                    }
                    if (this.hy_tableid.Text == "Tablefpbd")
                    {
                        this.btn_consubmit.Value = "付 款";
                        this.td_consubmit.Visible = true;//确认td_qxsubmit
                    }
                }
                else
                {
                    this.td_submit.Visible = false; //保存
                    this.td_xyb.Visible = false;   //下一步
                    this.td_continue.Visible = false; //保存并继续新建
                }
                //加载页面
                GetMainTableHtml("0", this.txtSystemClRight.Value, "0", "");
                hywebopen_newdoc();     //新文档OPEN时的特殊处理
            }
            #endregion

            #region 旧文档
            if (this.Request.QueryString["op"] == "modify")
            {
                if (this.Request.QueryString["docid"] != null)
                {
                    this.txtdocid.Value = this.Request.QueryString["docid"].ToString();
                    string sql = "select * from hyc_" + this.hy_tableid.Text + " where DOCID='" + this.txtdocid.Value + "' ";

                    DataTable dt = Hyoa_global.GetDataTable(sql);
                    if (dt.Rows.Count > 0)
                    {
                        this.hy_mudelid.Text = dt.Rows[0]["hy_mudelid"].ToString();
                        this.hy_tableid.Text = dt.Rows[0]["hy_tableid"].ToString();
                        this.hy_flowid.Text = dt.Rows[0]["hy_flowid"].ToString();
                        this.hy_flowname.Text = dt.Rows[0]["hy_flowname"].ToString();
                        this.hy_curtacheid.Text = dt.Rows[0]["hy_curtacheid"].ToString();
                        this.hy_curtachename.Text = dt.Rows[0]["hy_curtachename"].ToString();
                        this.lblcurtachenameshow.Text = dt.Rows[0]["hy_curtachename"].ToString();
                        this.hy_curclrid.Text = dt.Rows[0]["hy_curclrid"].ToString();
                        this.hy_curclrname.Text = dt.Rows[0]["hy_curclrname"].ToString();
                        this.hy_djrid.Text = dt.Rows[0]["hy_djrid"].ToString();
                        this.hy_djrname.Text = dt.Rows[0]["hy_djrname"].ToString();
                        this.hy_djrbmid.Text = dt.Rows[0]["hy_djrbmid"].ToString();
                        this.hy_djrbmname.Text = dt.Rows[0]["hy_djrbmname"].ToString();
                        this.hy_djsj.Text = dt.Rows[0]["hy_djsj"].ToString();
                        if (!this.IsPostBack)
                        {
                            this.hy_bt.Text = dt.Rows[0]["hy_bt"].ToString();
                        }
                        this.hy_iftx.Text = dt.Rows[0]["hy_iftx"].ToString();
                        this.hy_zhtxsj.Text = dt.Rows[0]["hy_zhtxsj"].ToString();
                        this.hy_readuserlist.Text = dt.Rows[0]["hy_readuserlist"].ToString();
                        this.hy_readdatelist.Text = dt.Rows[0]["hy_readdatelist"].ToString();
                        this.hy_clrylist.Text = dt.Rows[0]["hy_clrylist"].ToString();
                        this.hy_cyrylist.Text = dt.Rows[0]["hy_cyrylist"].ToString();
                        this.hy_motherid.Text = dt.Rows[0]["hy_motherid"].ToString();
                        this.hy_ifconfirm.Text = dt.Rows[0]["hy_ifconfirm"].ToString();
                        // this.txt_slbh.Value=dt.Rows[0]["hyc_slbh"].ToString();
                        UpdateReadFlag();  //打开时添加阅读情况
                    }
                    dt.Clear();
                    this.lblcurtachenameshow.Text = this.lbltablename.Text;

                    //如果非流程(授权用户统一管理)
                    if (this.txttablerole.Value == "0")
                    {
                        if (Hy_IfHaveRole(this.hy_mudelid.Text, Session["hyuid"].ToString()) == "1")
                            this.txtSystemClRight.Value = "1";
                    }
                    //如果非流程(每个人管理自己的信息)
                    if (this.txttablerole.Value == "1")
                    {
                        //判断是否为当前文档登记人
                        if (this.hy_djrid.Text == Session["hyuid"].ToString())
                            this.txtSystemClRight.Value = "1";
                    }
                    //如果非流程(每个人操作自己的信息、授权用户可管理所有信息)
                    if (this.txttablerole.Value == "2")
                    {
                        if (Hy_IfHaveRole(this.hy_mudelid.Text, Session["hyuid"].ToString()) == "1")
                        {
                            this.txtSystemClRight.Value = "1";
                        }
                        else
                        {
                            if (this.hy_djrid.Text == Session["hyuid"].ToString())
                                this.txtSystemClRight.Value = "1";
                        }
                    }
                    //如果非流程(授权用户可新建、只能删自己新建的信息)
                    if (this.txttablerole.Value == "3")
                    {
                        if (Hy_IfHaveRole(this.hy_mudelid.Text, Session["hyuid"].ToString()) == "1")
                        {
                            if (this.hy_djrid.Text == Session["hyuid"].ToString())
                                this.txtSystemClRight.Value = "1";
                        }
                    }

                    if (this.txtSystemClRight.Value == "1")
                    {
                        this.td_submit.Visible = true; //保存
                        this.td_continue.Visible = false; //保存并继续新建
                        this.td_xyb.Visible = false;   //下一步

                        if (this.hy_tableid.Text == "Tablekdjrht" || this.hy_tableid.Text == "Tablesyyhfwxy" || this.hy_tableid.Text == "Tablejdhazfwht"
                            || this.hy_tableid.Text == "TableVODfwxy" || this.hy_tableid.Text == "Tableffpdfwht" || this.hy_tableid.Text == "TableDVBazfwdght"
                            || this.hy_tableid.Text == "Tablejwdsjsxy" || this.hy_tableid.Text == "Tablejwdscsxy" || this.hy_tableid.Text == "Tablekdjrht"
                            || this.hy_tableid.Text == "Tablesjcsfwht" || this.hy_tableid.Text == "Tablesjgdcsfwht" || this.hy_tableid.Text == "Tablesjtxyyhzxy"
                            || this.hy_tableid.Text == "Tablezdyht" || this.hy_tableid.Text == "Tablegxhzhht" || this.hy_tableid.Text == "Tableqtht"
                            || this.hy_tableid.Text == "Tablexjsq" || this.hy_tableid.Text == "Tableshd" || this.hy_tableid.Text == "Tableszds"
                            //下面新合同  add by ccg 20150617
                            || this.hy_tableid.Text == "Tablesyyhfwxy_new" || this.hy_tableid.Text == "Tableszdsywfwht_new" || this.hy_tableid.Text == "Tablejwdscsxy_new"
                            || this.hy_tableid.Text == "Tablejwdsjm" || this.hy_tableid.Text == "Tablesjcsfwht_new" || this.hy_tableid.Text == "Tablekdjrht_new"
                            || this.hy_tableid.Text == "Tablesjgdcsfwht_new" || this.hy_tableid.Text == "Tablesjtxyyhzxy_new" || this.hy_tableid.Text == "Tablezdyht"
                            || this.hy_tableid.Text == "Tablegcsght" || this.hy_tableid.Text == "Tableqtht" || this.hy_tableid.Text == "Tablegxhzhht")
                        {
                            string sql_wc = "";
                            DataTable dtwc;
                            sql_wc = "select * from hyt_blzt where DOCID='" + this.txtdocid.Value + "' and hy_state='未完成'";
                            dtwc = Hyoa_global.GetDataTable(sql_wc);
                            if (dtwc.Rows.Count > 0)
                            {
                                if (dtwc.Rows[0]["hy_state"].ToString() == "未完成")
                                {
                                    this.td_wcan.Visible = true;   //完成
                                }
                            }

                            this.td_continue.Visible = false;
                            this.td_xyb.Visible = true;
                        }
                        if (this.hy_ifconfirm.Text != "1" && this.hy_tableid.Text == "Tablefpbd")
                        {
                            this.btn_consubmit.Value = "付款";
                            this.td_consubmit.Visible = true;   //确认
                        }
                    }
                    else
                    {
                        this.td_submit.Visible = false; //保存
                        //this.td_wcan.Visible = false;   //完成
                        this.td_xyb.Visible = false;   //下一步
                        this.td_continue.Visible = false; //保存并继续新建
                    }
                    //如果是超级管理员把取消按钮显示出来。用于用户确认后还要修改
                    //if (Hyoa_global.isHaveRole("Role9999", this.Session["hyuid"].ToString()))
                    //{
                    //    this.td_qxsubmit.Visible = true;    //取消按钮
                    //}

                    //加载主表单页面
                    GetMainTableHtml("1", this.txtSystemClRight.Value, "0", "");

                    //----加载评论页面 s add by xf 2011-11-19-----
                    HyoaClass.Hyoa_tableconfig Hyoa_tableconfig_forpinglun = new HyoaClass.Hyoa_tableconfig();
                    DataTable dt_tableconfig_forpinglun = Hyoa_tableconfig_forpinglun.GetTablesbymudelidandtableid(this.hy_mudelid.Text, this.hy_tableid.Text);
                    if (dt_tableconfig_forpinglun.Rows.Count > 0)
                    {
                        if (dt_tableconfig_forpinglun.Rows[0]["hy_ifcomment"] != null)
                        {
                            if (dt_tableconfig_forpinglun.Rows[0]["hy_ifcomment"].ToString() == "是")
                            {
                                this.tb_nbsp.Visible = true;
                                this.tb_pltitle.Visible = true;
                                this.tb_plbody.Visible = true;
                                this.td_pinglun.Visible = true;
                                //得到已经评论的内容
                                HyoaClass.Hyoa_pinglun Hyoa_pinglun = new HyoaClass.Hyoa_pinglun();
                                DataTable dt_pinglun = Hyoa_pinglun.GetcommentByfatherid(this.txtdocid.Value);
                                if (dt_pinglun.Rows.Count > 0)
                                {
                                    //输出评论记录
                                    this.lblbody.Text = "";
                                    for (var i = 0; i < dt_pinglun.Rows.Count; i++)
                                    {
                                        this.lblbody.Text += dt_pinglun.Rows[i]["hy_plbody"].ToString() + "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                                        this.lblbody.Text += "(评论人:" + dt_pinglun.Rows[i]["hy_plusername"].ToString() + "&nbsp;&nbsp;&nbsp;所在部门:" + dt_pinglun.Rows[i]["hy_pldeptname"].ToString();
                                        this.lblbody.Text += "&nbsp;&nbsp;&nbsp;评论时间:" + dt_pinglun.Rows[i]["hy_pltime"].ToString() + "&nbsp;&nbsp;&nbsp;IP:" + dt_pinglun.Rows[i]["hy_plip"].ToString();
                                        this.lblbody.Text += ")<br><hr height=1 color=#DEEEFE></hr>";
                                    }
                                }
                            }
                        }
                    }
                    //----加载评论页面 e-----
                }
                hywebopen_olddoc(); //旧文档OPEN的特殊处理
            }
            #endregion
        }

        // 部门礼品卡  显示导出按键     小潘   2015-12
        if (this.hy_tableid.Text == "Tablelpksqd")
        {
            //if (this.hy_curtacheid.Text == "tache0001" || this.hy_curtacheid.Text == "**")
            //{
            this.td_dc.Visible = true;
            //}
        }
    }
 //评论add by xf 2011-11-19
 protected void Button_PinglunSave_Click(object sender, EventArgs e)
 {
     if (this.txtpinglun.Text.Trim() == "")
     {
         Response.Write("<script>alert('评论内容不能为空!');</script>");
         return;
     }
     else
     {
         //保存评论记录
         HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
         HyoaClass.Hyoa_pinglun Hyoa_pinglun = new HyoaClass.Hyoa_pinglun();
         Hyoa_pinglun.plid = Hyoa_global.GetRandom();
         Hyoa_pinglun.hy_tableid = this.hy_tableid.Text;
         Hyoa_pinglun.hy_fatherid = this.txtdocid.Value;
         Hyoa_pinglun.hy_pluserid = Session["hyuid"].ToString();
         Hyoa_pinglun.hy_plusername = Session["hyuname"].ToString();
         Hyoa_pinglun.hy_pldeptid = Session["hydeptid"].ToString();
         Hyoa_pinglun.hy_pldeptname = Session["hydeptname"].ToString();
         Hyoa_pinglun.hy_pltime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         this.txtpinglun_hidden.Text = ReplaceString_Tszf(this.txtpinglun_hidden.Text);
         Hyoa_pinglun.hy_plbody = this.txtpinglun_hidden.Text;
         Hyoa_pinglun.hy_plip = HttpContext.Current.Request.UserHostAddress;
         Hyoa_pinglun.hy_plifshow = "";
         Hyoa_pinglun.Insert();
         Response.Write("<script>alert('评论成功!');window.location='" + this.Request.Url.ToString() + "'</script>");    //这个返回路径的页面,点返回按钮会有问题.已办转在办用的返回到了列表
     }
 }