//保存
    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>");
        }
    }
Beispiel #2
0
    //得到表单的HTML pi_flag 0:不赋值  1:需赋值    Written by xf 20110515
    //docid:旧文档使用时,文档ID
    //ifhavarole:是否有权限  0:lable输出 1:input输出
    //ifflowdoc:是否流程表单 0:非流程 1:流程
    //curtacheid:当前环节ID,用于判断字段是否在当前环节有权限
    public DataTable GetDataTableFieldHtml(string hy_mudelid, string hy_tableid, string pi_flag, string ifsearch, string docid, string ifhavarole, string ifflowdoc, string curtacheid)
    {
        //加载表单
        HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield();
        //根据模块ID和表单ID得到对应的配置字段
        DataTable dt_gettablecolumns = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid(hy_mudelid, hy_tableid);
        string ls_html = "";
        Int32 li_tdnums = 0;    //TDS数(colspan的值相加)

        DataTable tempTable = new DataTable();
        DataColumn col = new DataColumn("displaycol", typeof(String)); //定义新的一列  add
        tempTable.Columns.Add(col);  //追加一列  add

        if (dt_gettablecolumns.Rows.Count > 0)
        {
            //先从配置表中将配置的列数取出,如果配置表中找不到,则默认为4列,并且设置相应的宽度start
            HyoaClass.Hyoa_detail Hyoa_detail = new HyoaClass.Hyoa_detail();
            int li_col = 4;//一行显示几列
            string ls_leftwidth = "15";//左侧列宽
            string ls_rightwidth = "35";//右侧列宽
            DataTable detaildt = Hyoa_detail.Getdetail(hy_tableid);
            if (detaildt.Rows.Count > 0)
            {
                li_col = int.Parse(detaildt.Rows[0]["hy_colnum"].ToString());
                if (detaildt.Rows[0]["hy_colnum"].ToString() == "6")
                {
                    ls_leftwidth = "10";
                    ls_rightwidth = "23";
                }
                else
                {
                    if (detaildt.Rows[0]["hy_colnum"].ToString() == "8")
                    {
                        ls_leftwidth = "5";
                        ls_rightwidth = "7";
                    }
                    else
                    {
                        if (detaildt.Rows[0]["hy_colnum"].ToString() == "10")
                        {
                            ls_leftwidth = "4";
                            ls_rightwidth = "6";
                        }
                    }
                }
            }
            //先从配置表中将配置的列数取出,如果配置表中找不到,则默认为4列,并且设置相应的宽度end

            //开始加载字段信息到DT中,用于前台显示
            for (int i = 0; i < dt_gettablecolumns.Rows.Count; i++)
            {
                if (i == 0)
                {
                    ls_html += "<TR height=\"30\">";
                }
                //输出字段说明列(文字说明除外)
                if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() != "说明文字")
                {
                    //20120724
                    //如果是隐藏字段,则隐藏(增加display)   added by xf 20120217
                    if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是")
                        ls_html += "<TD width=\"" + ls_leftwidth + "%\" align=\"center\" class=\"Tdcellleft\">" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "</TD>";
                    else
                        ls_html += "<div style=\"display:none\">" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "</div>";
                    //ls_html += "<TD width=\"" + ls_leftwidth + "%\" align=\"center\" class=\"Tdcellleft\">" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "</TD>";
                }
                //得到当前字段的值
                HyoaClass.Hyoa_flowmain Hyoa_flowmain = new HyoaClass.Hyoa_flowmain();
                DataTable dt_flowmain = Hyoa_flowmain.Getflowmain(docid);
                string field_docvalue = "&nbsp;";
                if (dt_flowmain.Rows.Count > 0)
                {
                    if (dt_gettablecolumns.Rows[i]["hy_defaultvalue"].ToString() == "yyyy-mm-dd")
                    {
                        field_docvalue = System.DateTime.Parse(dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString()).ToShortDateString() + field_docvalue;
                    }
                    else
                    {
                        //如果SQL为数值的字段部分,则需要截取小数点后边两位
                        if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "数值")
                        {
                            if (dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString().Contains(".") == true)
                                field_docvalue = float.Parse(dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString()).ToString("F2") + field_docvalue;
                            else
                                field_docvalue = dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString() + field_docvalue;
                        }
                        else
                        {
                            field_docvalue = dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString() + field_docvalue;
                        }
                    }
                }
                //输出字段列
                //this.Response.Write("<script>alert('" + ifhavarole + "');</script>");
                if (ifhavarole == "0")  //无权限(当前表单来讲)
                {
                    //附件组件的值需要特定读取(附件需要特殊处理) Added by xf 20110607
                    if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "附件组件")
                    {

                        field_docvalue = "";
                        //根据docid得到目前已上传的附件信息
                        HyoaClass.Hyoa_user Hyoa_user = new HyoaClass.Hyoa_user();
                        HyoaClass.Hyoa_fileatt Hyoa_fileatt = new HyoaClass.Hyoa_fileatt();
                        DataTable dt_fileatt = Hyoa_fileatt.GetfileattByFatherid(docid);
                        if (dt_fileatt.Rows.Count > 0)
                        {
                            for (var ii = 0; ii < dt_fileatt.Rows.Count; ii++)
                            {
                                string ls_name = "";
                                DataTable dt_user = Hyoa_user.Getuser(dt_fileatt.Rows[ii]["hy_userid"].ToString());
                                if (dt_user.Rows.Count > 0)
                                {
                                    ls_name = dt_user.Rows[0]["hy_username"].ToString();
                                }
                                field_docvalue += (ii + 1).ToString() + "、<a href=\"" + dt_fileatt.Rows[ii]["hy_filepath"].ToString() + "\" target=_blank>" + dt_fileatt.Rows[ii]["hy_filename"].ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;" + ls_name + "&nbsp;&nbsp;[" + dt_fileatt.Rows[ii]["hy_djsj"].ToString() + "]" + "</a><br />";
                            }
                        }
                        if (field_docvalue == "")
                            field_docvalue = "&nbsp;";
                    }
                    //痕迹保留组件的值需要读取(需要特殊处理) Added by xf 20110705
                    if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "痕迹保留")
                    {
                        field_docvalue = "";
                        field_docvalue += "<input type=button id=\"btn_zwxg\" value='正  文' class=btn3 onclick=\"window.open('ntko/readoffice.aspx?newofficetype=1&fatherid=" + docid + "&tacheByhj=1&jsxd=1','newwindow','height=768,width=1024,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=no');\" ";
                        if (field_docvalue == "")
                            field_docvalue = "&nbsp;";
                    }
                    //ztmztmztmstart
                    //this.Response.Write("<script>alert('" + field_docvalue + "');</script>");
                    if (field_docvalue.Length > 7)
                    {

                        if (field_docvalue.Substring(0, 8) == "1900-1-1")
                        {
                            field_docvalue = "&nbsp;";
                        }
                    }
                    //ztmztmztmend
                    if (dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() == "1")
                    {
                        //如果是隐藏字段,则隐藏(增加display)   added by xf 20120217
                        if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是")
                            ls_html += "<TD width=\"" + ls_rightwidth + "%\" height=\"30px\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\">" + field_docvalue + "</TD>";
                        else
                            ls_html += "<div style=\"display:none\">" + field_docvalue + "</div>";
                        //ls_html += "<TD width=\"" + ls_rightwidth + "%\" height=\"30px\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\">" + field_docvalue + "</TD>";
                    }
                    else
                    {
                        //如果是隐藏字段,则隐藏(增加display)   added by xf 20120217
                        if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是")
                            ls_html += "<TD width=\"" + ls_rightwidth + "%\" height=\"30px\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\" colspan=" + dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() + ">" + field_docvalue + "</TD>";
                        else
                            ls_html += "<div style=\"display:none\">" + field_docvalue + "</div>";
                        //ls_html += "<TD width=\"" + ls_rightwidth + "%\" height=\"30px\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\" colspan=" + dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() + ">" + field_docvalue + "</TD>";
                    }
                }
                else
                {
                    //有权限(当前表单来讲)时,判断当前流程+当前环节对于这个字段是否有权限操作
                    string ls_ifhavarole = "0";    //默认没有权限(当前字段来讲)---该功能仅对于流程模块起作用
                    //非流程直接就有权限了
                    //this.Response.Write("<script>alert('" + ifflowdoc + "');</script>");
                    if (ifflowdoc == "0")
                    {
                        ls_ifhavarole = "1";
                    }
                    else
                    {
                        //判断当前字段是否有权限
                        HyoaClass.Hyoa_flowtachefield Hyoa_flowtachefield = new HyoaClass.Hyoa_flowtachefield();
                        ls_ifhavarole = Hyoa_flowtachefield.IfHaveRolebyflowidandtacheidandfieldid(dt_gettablecolumns.Rows[i]["hy_flowid"].ToString(), curtacheid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString());
                    }

                    if (dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() == "1")
                    {
                        //如果是隐藏字段,则隐藏(增加display)   added by xf 20120217
                        if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是")
                            ls_html += "<TD width=\"" + ls_rightwidth + "%\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</TD>";
                        else
                            ls_html += "<div style=\"display:none\">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</div>";
                        //ls_html += "<TD width=\"" + ls_rightwidth + "%\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</TD>";
                    }
                    else
                    {
                        //如果是隐藏字段,则隐藏(增加display)   added by xf 20120217
                        if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是")
                            ls_html += "<TD width=\"" + ls_rightwidth + "%\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\" colspan=" + dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() + ">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</TD>";
                        else
                            ls_html += "<div style=\"display:none\">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</div>";
                        //ls_html += "<TD width=\"" + ls_rightwidth + "%\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\" colspan=" + dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() + ">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</TD>";

                    }
                }
                //开始colspan值累加,如果是隐藏字段,不计算在内
                if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是")
                {
                    if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "说明文字")
                        li_tdnums += System.Int32.Parse(dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString());
                    else
                        li_tdnums += System.Int32.Parse(dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString()) + 1;
                }
                //this.lbtest.Text += "," + li_tdnums;
                if (li_tdnums % li_col == 0 && dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是")
                {
                    ls_html += "</tr>";
                    DataRow dr = tempTable.NewRow();
                    dr["displaycol"] = ls_html;  //将新值赋给相应的列  add
                    tempTable.Rows.Add(dr);
                    ls_html = "";
                    if (i != (dt_gettablecolumns.Rows.Count - 1))
                        ls_html += "<tr>";
                }
                //先从配置表中将配置的列数取出,如果配置表中找不到,则默认为4列end
            }
        }
        return tempTable;
    }
    private void DataPlay()
    {
        //是否流程文档
        this.ddlifflowdoc.Items.Insert(0, "否");
        this.ddlifflowdoc.Items.Insert(1, "是");
        //是否显示所有文档非流程
        this.ddlifdisplayall.Items.Insert(0, "否");
        this.ddlifdisplayall.Items.Insert(1, "是");
        //主表单显示的列数
        this.ddldisplaycol.Items.Insert(0, "4");
        this.ddldisplaycol.Items.Insert(1, "6");
        this.ddldisplaycol.Items.Insert(2, "8");
        this.ddldisplaycol.Items.Insert(3, "10");
        //只对流程模块起作用,流程完成后是否公开,是表示大家都能看,否表示不公开
        this.ddlispuballByflowYB.Items.Insert(0, "否");
        this.ddlispuballByflowYB.Items.Insert(1, "是");

        //加载模块
        HyoaClass.Hyoa_mudel Hyoa_mudel = new HyoaClass.Hyoa_mudel();
        DataTable dtmudel = Hyoa_mudel.Getmudels();
        if (dtmudel.Rows.Count > 0)
        {
            this.ddlmudelid.DataSource = dtmudel;
            this.ddlmudelid.DataTextField = "hy_mudelname";
            this.ddlmudelid.DataValueField = "hy_mudelid";
            this.ddlmudelid.DataBind();
            this.ddlmudelid.Items.Insert(0, "--请选择--");
            this.ddlmudelid.SelectedIndex = 0;
        }

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

            //判断当前用户是否有保存的权限
            HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
            if (Hyoa_global.isHaveRole("Role9999", this.Session["hyuid"].ToString()))
            {
                this.btn_submit.Visible = true; //保存
            }
            else
            {
                this.btn_submit.Visible = false; //保存
            }

            //旧文档
            if (this.Request.QueryString["op"] == "modify")
            {
                if (this.Request.QueryString["id"] != null)
                {
                    //根据id得到信息
                    this.txtdocid.Value = this.Request.QueryString["id"].ToString();
                    HyoaClass.Hyoa_tableconfig Hyoa_tableconfig = new HyoaClass.Hyoa_tableconfig();
                    DataTable dt = Hyoa_tableconfig.GetTable(this.txtdocid.Value);
                    if (dt.Rows.Count > 0)
                    {
                        this.ddlmudelid.SelectedValue = dt.Rows[0]["hy_mudelid"].ToString();
                        this.txtname.Value = dt.Rows[0]["hy_name"].ToString();
                        this.txtsort.Value = dt.Rows[0]["hy_sort"].ToString();
                        this.ddlifflowdoc.SelectedValue = dt.Rows[0]["hy_ifflowdoc"].ToString();
                        this.ddlifdisplayall.SelectedValue = dt.Rows[0]["hy_ifdisplayall"].ToString();
                        this.ddlispuballByflowYB.SelectedValue = dt.Rows[0]["hy_ispuballByflowYB"].ToString();
                        this.txthy_onload.Value = dt.Rows[0]["hy_onload"].ToString();
                        this.ddltablerole.SelectedValue = dt.Rows[0]["hy_tablerole"].ToString();
                    }
                    //得到列数
                    HyoaClass.Hyoa_detail Hyoa_detail = new HyoaClass.Hyoa_detail();
                    DataTable detaildt = Hyoa_detail.Getdetail(this.txtdocid.Value);
                    if (detaildt.Rows.Count > 0)
                    {
                        this.ddldisplaycol.SelectedValue = detaildt.Rows[0]["hy_colnum"].ToString();
                    }

                    dt.Clear();
                }
            }
        }
    }