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

        string ls_tip = "保存成功!";

        //新文档时
        HyoaClass.Hyoa_tableconfig Hyoa_tableconfig = new HyoaClass.Hyoa_tableconfig();
        Hyoa_tableconfig.ID = this.txtdocid.Text;
        Hyoa_tableconfig.hy_mudelid = this.ddlmudelid.SelectedValue.ToString();
        Hyoa_tableconfig.hy_name = this.txtname.Value;
        Hyoa_tableconfig.hy_onload = this.txthy_onload.Text;
        Hyoa_tableconfig.hy_sort = float.Parse(this.txtsort.Value);
        Hyoa_tableconfig.hy_ifflowdoc = this.ddlifflowdoc.SelectedValue;
        Hyoa_tableconfig.hy_ifdisplayall = this.ddlifdisplayall.SelectedValue;
        Hyoa_tableconfig.hy_ifcomment = this.ddlifcomment.SelectedValue;
        Hyoa_tableconfig.hy_ispuballByflowYB = this.ddlispuballByflowYB.SelectedValue;
        Hyoa_tableconfig.hy_tablerole = this.ddltablerole.SelectedValue;
        Hyoa_tableconfig.hy_colnum = float.Parse(this.ddldisplaycol.SelectedValue);
        Hyoa_tableconfig.hy_field1 = "";
        Hyoa_tableconfig.hy_field2 = "";
        Hyoa_tableconfig.hy_field3 = "";
        Hyoa_tableconfig.hy_field4 = "";
        Hyoa_tableconfig.hy_field5 = "";

        if (this.txtop.Value == "add")
        {
            //先判断是否已经存在
            DataTable dt = Hyoa_tableconfig.GetTable(this.txtdocid.Text);
            if (dt.Rows.Count > 0)
            {
                Response.Write("<script>alert('该表单编号已存在,请重新填写!');history.back();</script>");
                return;
            }
            if (this.txtdocid.Text.Length < 6)
            {
                Response.Write("<script>alert('表单编号长度必须大于5位!');history.back();</script>");
                return;
            }
            if (this.txtdocid.Text.Substring(0, 5) != "Table")
            {
                Response.Write("<script>alert('表单编号必须以Table开头!');history.back();</script>");
                return;
            }
            Hyoa_tableconfig.Insert();
            //创建SQL表
            if (CreateSQLTable()==false)
            {
                ls_tip = "生成表结构失败,请联系管理员!";
            }
        }
        else
        {
            Hyoa_tableconfig.Update();

            //修改时,保存完成后同时更新对应的字段中FLOWID值(如果非流程则置为空,如果是流程则置为值)
            HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield();
            if (this.ddlifflowdoc.SelectedValue == "是")
            {
                HyoaClass.Hyoa_flowinfor Hyoa_flowinfor = new HyoaClass.Hyoa_flowinfor();
                DataTable dt_flow = Hyoa_flowinfor.Getflowinforbymudelid(this.ddlmudelid.SelectedValue);
                if (dt_flow.Rows.Count > 0)
                {
                    Hyoa_flowfield.Updateflowid_For_tacheconfig(dt_flow.Rows[0]["hy_flowid"].ToString(), this.txtdocid.Text);
                }

            }
            else
            {
                Hyoa_flowfield.Updateflowid_For_tacheconfig("", this.txtdocid.Text);
            }

            //修改后,同时更新对应的字段中的模块ID,为了解决当表单中对应的模块修改后,字段中没有更新的BUG
            Hyoa_flowfield.Updatemudelid_For_tableconfig(this.ddlmudelid.SelectedValue, this.txtdocid.Text);
        }

        //处理完成后的提示及跳转
        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 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_tableconfig Hyoa_tableconfig = new HyoaClass.Hyoa_tableconfig();
        string lstableid="";
        HyoaClass.Hyoa_detail Hyoa_detail = new HyoaClass.Hyoa_detail();//主表单显示的列数

        if (this.txtop.Value == "add")
        {
            ////先判断这个模块编号是否已经存在
            //DataTable dt = Hyoa_tableconfig.GetTablesbymudelid(this.ddlmudelid.SelectedValue);
            //if (dt.Rows.Count > 0)
            //{
            //    Response.Write("<script>alert('该模块的表单配置已存在,请重新填写!');history.back();</script>");
            //    return;
            //}
            //else
            //{
            lstableid = Hyoa_global.GetRandom();
            Hyoa_tableconfig.ID = lstableid;
            Hyoa_tableconfig.hy_mudelid = this.ddlmudelid.SelectedValue.ToString();
            Hyoa_tableconfig.hy_name = this.txtname.Value;
            Hyoa_tableconfig.hy_onload = this.txthy_onload.Value;
            Hyoa_tableconfig.hy_sort = float.Parse(this.txtsort.Value);
            Hyoa_tableconfig.hy_ifflowdoc = this.ddlifflowdoc.SelectedValue;
            Hyoa_tableconfig.hy_ifdisplayall = this.ddlifdisplayall.SelectedValue;
            Hyoa_tableconfig.hy_ispuballByflowYB = this.ddlispuballByflowYB.SelectedValue;
            Hyoa_tableconfig.hy_tablerole = this.ddltablerole.SelectedValue;
            Hyoa_tableconfig.Insert();

            //新文档时增加主表显示列数
            Hyoa_detail.hy_fatherid = lstableid;
            Hyoa_detail.hy_colnum = int.Parse(this.ddldisplaycol.SelectedValue);
            Hyoa_detail.hy_field1 = "";
            Hyoa_detail.hy_field2 = "";
            Hyoa_detail.hy_field3 = "";
            Hyoa_detail.hy_field4 = "";
            Hyoa_detail.hy_field5 = "";
            Hyoa_detail.Insert();

            //}
        }
        else
        {
            Hyoa_tableconfig.ID = this.txtdocid.Value;
            Hyoa_tableconfig.hy_mudelid = this.ddlmudelid.SelectedValue;
            Hyoa_tableconfig.hy_name = this.txtname.Value;
            Hyoa_tableconfig.hy_onload = this.txthy_onload.Value;
            Hyoa_tableconfig.hy_sort = float.Parse(this.txtsort.Value);
            Hyoa_tableconfig.hy_ifflowdoc = this.ddlifflowdoc.SelectedValue;
            Hyoa_tableconfig.hy_ifdisplayall = this.ddlifdisplayall.SelectedValue;
            Hyoa_tableconfig.hy_ispuballByflowYB = this.ddlispuballByflowYB.SelectedValue;
            Hyoa_tableconfig.hy_tablerole = this.ddltablerole.SelectedValue;
            Hyoa_tableconfig.Update();

            //更新文档时更新主表显示列数
            Hyoa_detail.hy_fatherid = this.txtdocid.Value;
            Hyoa_detail.hy_colnum = int.Parse(this.ddldisplaycol.SelectedValue);
            Hyoa_detail.hy_field1 = "";
            Hyoa_detail.hy_field2 = "";
            Hyoa_detail.hy_field3 = "";
            Hyoa_detail.hy_field4 = "";
            Hyoa_detail.hy_field5 = "";
            DataTable dt2 = Hyoa_detail.Getdetail(this.txtdocid.Value);
            if (dt2.Rows.Count > 0)
            {
                Hyoa_detail.Update();
            }
            else
            {
                Hyoa_detail.Insert();
            }

            //修改时,保存完成后同时更新对应的字段中FLOWID值(如果非流程则置为空,如果是流程则置为值)
            HyoaClass.DAO db = new HyoaClass.DAO();
            string sql_field = "";
            if (this.ddlifflowdoc.SelectedValue == "是")
            {
                HyoaClass.Hyoa_flowinfor Hyoa_flowinfor = new HyoaClass.Hyoa_flowinfor();
                DataTable dt_flow = Hyoa_flowinfor.Getflowinforbymudelid(this.ddlmudelid.SelectedValue);
                if (dt_flow.Rows.Count > 0)
                {
                    sql_field = "update hyt_flowfield set hy_flowid='" + dt_flow.Rows[0]["hy_flowid"].ToString() + "' where hy_tableid='" + this.txtdocid.Value + "'";
                }

            }
            else
            {
                sql_field = "update hyt_flowfield set hy_flowid='' where hy_tableid='" + this.txtdocid.Value + "'";
            }
            db.Execute(sql_field);
            db.Close();

        }

        //处理完成后的提示及跳转
        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>");
        }
    }