Beispiel #1
0
 void btn_Del_Click(object sender, EventArgs e)
 {
     try
     {
         MapM2M dtl = new MapM2M();
         dtl.MyPK = this.FK_MapData + "_" + this.NoOfObj;
         dtl.Delete();
         this.WinClose();
     }
     catch (Exception ex)
     {
         this.Alert(ex.Message);
     }
 }
Beispiel #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (this.OID == 0)
            {
                return;
            }

            MapM2M mapM2M = new MapM2M(this.FK_MapData, this.NoOfObj);

            BP.Sys.M2M m2m = new BP.Sys.M2M();
            m2m.FK_MapData = this.FK_MapData;
            m2m.EnOID      = this.OID;
            m2m.M2MNo      = this.NoOfObj;

            DataTable dtObj         = BP.DA.DBAccess.RunSQLReturnTable(mapM2M.DBOfObjsRun);
            string    str           = ",";
            string    strT          = "";
            int       numOfselected = 0;

            foreach (DataRow dr in dtObj.Rows)
            {
                string   id = dr[0].ToString();
                CheckBox cb = this.Pub1.GetCBByID("CB_" + id);
                if (cb == null)
                {
                    continue;
                }

                if (cb.Checked == false)
                {
                    continue;
                }

                str  += id + ",";
                strT += "@" + id + "," + cb.Text;
                numOfselected++;
            }
            m2m.Vals     = str;
            m2m.ValsName = strT;
            m2m.InitMyPK();
            m2m.NumSelected = numOfselected;
            m2m.Save();
        }
Beispiel #3
0
        void btn_Save_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            try
            {
                MapM2M m2m = new MapM2M(this.FK_MapData, this.NoOfObj);
                m2m            = (MapM2M)this.Pub1.Copy(m2m);
                m2m.FK_MapData = this.FK_MapData;
                m2m.ShowWay    = (FrmShowWay)this.Pub1.GetDDLByID("DDL_ShowWay").SelectedItemIntVal;
                m2m.FK_MapData = this.FK_MapData;
                if (string.IsNullOrEmpty(m2m.NoOfObj))
                {
                    m2m.NoOfObj = this.NoOfObj;
                }

                if (string.IsNullOrEmpty(m2m.NoOfObj))
                {
                    m2m.NoOfObj = DataType.ParseStringToPinyin(m2m.Name);
                }

                GroupFields gfs = new GroupFields(m2m.FK_MapData);
                m2m.GroupID    = this.Pub1.GetDDLByID("DDL_GroupField").SelectedItemIntVal;
                m2m.HisM2MType = M2MType.M2M;
                m2m.Save();

                if (btn.ID.Contains("AndC"))
                {
                    this.WinClose();
                    return;
                }
                this.Response.Redirect("MapM2M.aspx?DoType=Edit&NoOfObj=" + m2m.NoOfObj + "&FK_MapData=" + this.FK_MapData, true);
            }
            catch (Exception ex)
            {
                this.Alert(ex.Message);
            }
        }
Beispiel #4
0
        public bool BindLeft(MapM2M mapM2M)
        {
            BP.Sys.M2Ms m2ms = new BP.Sys.M2Ms();
            m2ms.Retrieve(M2MAttr.FK_MapData, this.FK_MapData,
                          M2MAttr.M2MNo, this.NoOfObj, M2MAttr.EnOID, this.OID);
            DataTable dtList;

            if (mapM2M.DBOfLists.Substring(0, 1) == "@")
            {
                dtList = new DataTable();
                dtList.Columns.Add("No", typeof(string));
                dtList.Columns.Add("Name", typeof(string));
                string     myNo = mapM2M.DBOfLists.Replace("@", "");
                BP.Sys.M2M m2m  = new BP.Sys.M2M();
                m2m.MyPK = this.FK_MapData + "_" + myNo + "_" + this.OID + "_";
                if (m2m.RetrieveFromDBSources() == 0)
                {
                    return(false);
                }

                string[] vals = m2m.ValsName.Split('@');
                this.Left.AddUL();
                foreach (string val in vals)
                {
                    if (string.IsNullOrEmpty(val))
                    {
                        continue;
                    }
                    string[] strs = val.Split(',');
                    if (this.OperObj == null)
                    {
                        this.OperObj = strs[0];
                    }

                    if (this.OperObj == strs[0])
                    {
                        this.Left.AddLi("<a href='M2MM.aspx?FK_MapData=" + this.FK_MapData + "&NoOfObj=" + this.NoOfObj + "&OID=" + this.OID + "&OperObj=" + strs[0] + "'><b>" + strs[1] + "(" + GetNum(m2ms, strs[0]) + ")</b></a><br>");
                    }
                    else
                    {
                        this.Left.AddLi("<a href='M2MM.aspx?FK_MapData=" + this.FK_MapData + "&NoOfObj=" + this.NoOfObj + "&OID=" + this.OID + "&OperObj=" + strs[0] + "'>" + strs[1] + "(" + GetNum(m2ms, strs[0]) + ")</a><br>");
                    }
                }
                this.Left.AddULEnd();
                return(true);
            }
            else
            {
                dtList = DBAccess.RunSQLReturnTable(mapM2M.DBOfListsRun);
            }
            if (dtList.Rows.Count == 0)
            {
                return(false);
            }

            this.Left.AddUL();
            foreach (DataRow dr in dtList.Rows)
            {
                if (this.OperObj == null)
                {
                    this.OperObj = dr[0].ToString();
                }

                if (this.OperObj == dr[0].ToString())
                {
                    this.Left.AddLi("<a href='M2MM.aspx?FK_MapData=" + this.FK_MapData + "&NoOfObj=" + this.NoOfObj + "&OID=" + this.OID + "&OperObj=" + dr[0].ToString() + "'><b>" + dr[1].ToString() + "(" + GetNum(m2ms, dr[0].ToString()) + ")</b></a><br>");
                }
                else
                {
                    this.Left.AddLi("<a href='M2MM.aspx?FK_MapData=" + this.FK_MapData + "&NoOfObj=" + this.NoOfObj + "&OID=" + this.OID + "&OperObj=" + dr[0].ToString() + "'>" + dr[1].ToString() + "(" + GetNum(m2ms, dr[0].ToString()) + ")</a><br>");
                }
            }
            this.Left.AddULEnd();
            return(true);
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Page.RegisterClientScriptBlock("s",
                                                "<link href='/WF/Comm/Style/Table" + BP.Web.WebUser.Style + ".css' rel='stylesheet' type='text/css' />");

            MapM2M mapM2M = new MapM2M(this.FK_MapData, this.NoOfObj);

            this.OperObj = this.Request.QueryString["OperObj"];

            if (string.IsNullOrEmpty(mapM2M.DBOfLists) == true)
            {
                this.Pub1.AddFieldSetYellow("提示");
                this.Pub1.Add("表单设计错误:没有设置列表数据源.");
                this.Pub1.AddFieldSetEnd();
                this.Button1.Enabled = false;
                return;
            }

            if (this.BindLeft(mapM2M) == false)
            {
                this.Pub1.AddFieldSetYellow("提示");
                this.Pub1.Add("列表数据源为空.");
                this.Pub1.AddFieldSetEnd();
                return;
            }

            BP.Sys.M2M m2m = new BP.Sys.M2M();
            m2m.MyPK = this.FK_MapData + "_" + this.NoOfObj + "_" + this.OID + "_" + this.OperObj;
            m2m.RetrieveFromDBSources();
            DataTable dtGroup = new DataTable();

            if (mapM2M.DBOfGroups.Length > 5)
            {
                dtGroup = BP.DA.DBAccess.RunSQLReturnTable(mapM2M.DBOfGroupsRun);
            }
            else
            {
                dtGroup.Columns.Add("No", typeof(string));
                dtGroup.Columns.Add("Name", typeof(string));
                DataRow dr = dtGroup.NewRow();
                dr["No"]   = "01";
                dr["Name"] = "全部选择";
                dtGroup.Rows.Add(dr);
            }

            DataTable dtObj = BP.DA.DBAccess.RunSQLReturnTable(mapM2M.DBOfObjsRun);

            if (dtObj.Columns.Count == 2)
            {
                dtObj.Columns.Add("Group", typeof(string));
                foreach (DataRow dr in dtObj.Rows)
                {
                    dr["Group"] = "01";
                }
            }
            bool isInsert = mapM2M.IsInsert;
            bool isDelete = mapM2M.IsDelete;

            if (isDelete == false && isInsert == false)
            {
                this.Button1.Enabled = false;
            }

            if ((isDelete || isInsert) && string.IsNullOrEmpty(this.IsOpen) == false)
            {
                this.Button1.Visible = true;
            }


            this.Pub1.Add("<Table style='border:none;' >");
            foreach (DataRow drGroup in dtGroup.Rows)
            {
                string ctlIDs  = "";
                string groupNo = drGroup[0].ToString();
                this.Pub1.AddTR();

                CheckBox cbx = new CheckBox();
                cbx.ID   = "CBs_" + drGroup[0].ToString();
                cbx.Text = drGroup[1].ToString();
                this.Pub1.AddTDTitle("align=left", cbx);
                this.Pub1.AddTREnd();

                this.Pub1.AddTR();
                this.Pub1.AddTDBegin("nowarp=false");

                this.Pub1.AddTable();
                int colIdx = -1;
                foreach (DataRow drObj in dtObj.Rows)
                {
                    string no    = drObj[0].ToString();
                    string name  = drObj[1].ToString();
                    string group = drObj[2].ToString();
                    if (group != groupNo)
                    {
                        continue;
                    }

                    colIdx++;
                    if (colIdx == 0)
                    {
                        this.Pub1.AddTR();
                    }

                    CheckBox cb = new CheckBox();
                    cb.ID   = "CB_" + no;
                    ctlIDs += cb.ID + ",";
                    cb.Attributes["onclick"] = "isChange=true;";
                    cb.Text    = name;
                    cb.Checked = m2m.Vals.Contains("," + no + ",");
                    if (cb.Checked)
                    {
                        cb.Text = "<font color=green>" + cb.Text + "</font>";
                    }

                    this.Pub1.AddTD(cb);

                    if (mapM2M.Cols - 1 == colIdx)
                    {
                        this.Pub1.AddTREnd();
                        colIdx = -1;
                    }
                }
                cbx.Attributes["onclick"] = "SetSelected(this,'" + ctlIDs + "')";
                if (colIdx != -1)
                {
                    while (colIdx != mapM2M.Cols - 1)
                    {
                        colIdx++;
                        this.Pub1.AddTD();
                    }
                    this.Pub1.AddTREnd();
                }
                this.Pub1.AddTableEnd();
                this.Pub1.AddTDEnd();
                this.Pub1.AddTREnd();
            }

            #region 处理未分组的情况.
            bool isHaveUnGroup = false;
            if (dtObj.Columns.Count > 2)
            {
                foreach (DataRow drObj in dtObj.Rows)
                {
                    string group = drObj[2].ToString();
                    isHaveUnGroup = true;
                    foreach (DataRow drGroup in dtGroup.Rows)
                    {
                        string groupNo = drGroup[0].ToString();
                        if (group == groupNo)
                        {
                            isHaveUnGroup = false;
                            break;
                        }
                    }
                    if (isHaveUnGroup == false)
                    {
                        continue;
                    }
                }
            }

            if (isHaveUnGroup == true)
            {
                this.Pub1.AddTR();
                this.Pub1.AddTDBigDocBegain(); // ("nowarp=true");


                this.Pub1.AddTable();
                int    colIdx = -1;
                string ctlIDs = "";
                foreach (DataRow drObj in dtObj.Rows)
                {
                    string group = drObj[2].ToString();
                    isHaveUnGroup = true;
                    foreach (DataRow drGroup in dtGroup.Rows)
                    {
                        string groupNo = drGroup[0].ToString();
                        if (group != groupNo)
                        {
                            isHaveUnGroup = true;
                            break;
                        }
                    }

                    if (isHaveUnGroup == false)
                    {
                        continue;
                    }

                    string no   = drObj[0].ToString();
                    string name = drObj[1].ToString();

                    colIdx++;
                    if (colIdx == 0)
                    {
                        this.Pub1.AddTR();
                    }

                    CheckBox cb = new CheckBox();
                    cb.ID      = "CB_" + no;
                    ctlIDs    += cb.ID + ",";
                    cb.Text    = name;
                    cb.Checked = m2m.Vals.Contains("," + no + ",");
                    if (cb.Checked)
                    {
                        cb.Text = "<font color=green>" + cb.Text + "</font>";
                    }

                    this.Pub1.AddTD(cb);

                    if (mapM2M.Cols - 1 == colIdx)
                    {
                        this.Pub1.AddTREnd();
                        colIdx = -1;
                    }
                }
                if (colIdx != -1)
                {
                    while (colIdx != mapM2M.Cols - 1)
                    {
                        colIdx++;
                        this.Pub1.AddTD();
                    }
                    this.Pub1.AddTREnd();
                }
                this.Pub1.AddTableEnd();

                //cbx.Attributes["onclick"] = "SetSelected(this,'" + ctlIDs + "')";
                this.Pub1.AddTDEnd();
                this.Pub1.AddTREnd();
            }
            #endregion 处理未分组的情况.

            this.Pub1.AddTableEnd();
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MapData md = new MapData(this.FK_MapData);

            this.Title = md.Name + " - 设计一对多";
            MapM2M m2m = new MapM2M(this.FK_MapData, this.NoOfObj);

            if (m2m.HisM2MType == M2MType.M2MM)
            {
                this.Response.Redirect("MapM2MM.aspx?FK_MapData=" + this.FK_MapData + "&NoOfObj=" + this.NoOfObj, true);
                return;
            }

            this.Pub1.AddTable();
            this.Pub1.AddCaptionLeft("一对多属性");
            int idx = 1;

            this.Pub1.AddTR();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("编号");
            TB tb = new TB();

            tb.ID   = "TB_" + MapM2MAttr.NoOfObj;
            tb.Text = m2m.NoOfObj;
            if (m2m.IsExits)
            {
                tb.Enabled = false;
            }

            this.Pub1.AddTD(tb);
            this.Pub1.AddTD();
            this.Pub1.AddTREnd();

            this.Pub1.AddTR1();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("描述");
            tb         = new TB();
            tb.ID      = "TB_" + MapM2MAttr.Name;
            tb.Text    = m2m.Name;
            tb.Columns = 50;
            this.Pub1.AddTD("colspan=2", tb);
            this.Pub1.AddTREnd();
            this.Pub1.AddTREnd();

            this.Pub1.AddTR();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("主体数据源<font color=red>*</font>");
            tb          = new TB();
            tb.TextMode = TextBoxMode.MultiLine;
            tb.Rows     = 3;
            tb.ID       = "TB_" + MapM2MAttr.DBOfObjs;
            tb.Text     = m2m.DBOfObjs;
            tb.Columns  = 50;

            this.Pub1.AddTD("colspan=2", tb);
            this.Pub1.AddTREnd();
            this.Pub1.AddTREnd();


            this.Pub1.AddTR1();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("分组数据源");
            tb          = new TB();
            tb.ID       = "TB_" + MapM2MAttr.DBOfGroups;
            tb.Text     = m2m.DBOfGroups;
            tb.Columns  = 50;
            tb.TextMode = TextBoxMode.MultiLine;
            tb.Rows     = 3;
            this.Pub1.AddTD("colspan=2", tb);
            this.Pub1.AddTREnd();
            this.Pub1.AddTREnd();


            this.Pub1.AddTR();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("框架宽度");
            tb          = new TB();
            tb.ID       = "TB_" + MapM2MAttr.W;
            tb.ShowType = TBType.Num;
            tb.Text     = m2m.W.ToString();
            this.Pub1.AddTD(tb);
            this.Pub1.AddTD();
            this.Pub1.AddTREnd();

            this.Pub1.AddTR1();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("框架高度");
            tb          = new TB();
            tb.ID       = "TB_" + MapM2MAttr.H;
            tb.ShowType = TBType.Num;
            tb.Text     = m2m.H.ToString();
            this.Pub1.AddTD(tb);
            this.Pub1.AddTD();
            this.Pub1.AddTREnd();

            this.Pub1.AddTR1();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("记录呈现列数");
            tb          = new TB();
            tb.ID       = "TB_" + MapM2MAttr.Cols;
            tb.ShowType = TBType.Num;
            tb.Text     = m2m.Cols.ToString();
            this.Pub1.AddTD(tb);
            this.Pub1.AddTD();
            this.Pub1.AddTREnd();

            this.Pub1.AddTR();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("显示方式");
            DDL ddl = new DDL();

            ddl.ID = "DDL_" + MapM2MAttr.ShowWay;
            ddl.BindSysEnum("FrmUrlShowWay", (int)m2m.ShowWay);
            this.Pub1.AddTD(ddl);
            this.Pub1.AddTD("请参考手册");
            this.Pub1.AddTREnd();

            this.Pub1.AddTR();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("权限");
            this.Pub1.AddTDBegin("colspan=2");

            CheckBox cb = new CheckBox();

            cb.Checked = m2m.IsDelete;
            cb.Text    = "是否可以删除?";
            cb.ID      = "CB_IsDelete";
            this.Pub1.Add(cb);

            cb         = new CheckBox();
            cb.Checked = m2m.IsDelete;
            cb.Text    = "是否可以增加?";
            cb.ID      = "CB_IsInsert";
            this.Pub1.Add(cb);
            this.Pub1.AddTDEnd();
            this.Pub1.AddTREnd();

            GroupFields gfs = new GroupFields(md.No);

            this.Pub1.AddTR1();
            this.Pub1.AddTDIdx(idx++);
            this.Pub1.AddTD("显示在分组");
            ddl    = new DDL();
            ddl.ID = "DDL_GroupField";
            ddl.BindEntities(gfs, GroupFieldAttr.OID, GroupFieldAttr.Lab, false, AddAllLocation.None);
            ddl.SetSelectItem(m2m.GroupID);
            this.Pub1.AddTD("colspan=2", ddl);
            this.Pub1.AddTREnd();

            this.Pub1.AddTRSum();
            this.Pub1.AddTDBegin("colspan=4 align=center");

            Button btn = new Button();

            btn.ID       = "Btn_Save";
            btn.CssClass = "Btn";
            btn.Text     = " 保存 ";
            btn.Click   += new EventHandler(btn_Save_Click);
            this.Pub1.Add(btn);

            btn          = new Button();
            btn.CssClass = "Btn";
            btn.ID       = "Btn_SaveAndClose";
            btn.Text     = " 保存并关闭 ";
            btn.Click   += new EventHandler(btn_Save_Click);
            this.Pub1.Add(btn);

            if (m2m.IsExits)
            {
                btn          = new Button();
                btn.CssClass = "Btn";
                btn.ID       = "Btn_Del";
                btn.Text     = "删除";
                btn.Attributes["onclick"] = " return confirm('您确认吗?');";
                btn.Click += new EventHandler(btn_Del_Click);
                this.Pub1.Add(btn);
            }

            this.Pub1.AddTDEnd();
            this.Pub1.AddTREnd();
            this.Pub1.AddTableEnd();

            this.Pub1.AddFieldSet("SQL事例");
            this.Pub1.Add("主体数据源:");
            this.Pub1.AddBR("SELECT No,Name,FK_Dept FROM Port_Emp");
            this.Pub1.AddBR();
            this.Pub1.Add("分组数据源:");
            this.Pub1.AddBR("SELECT No,Name FROM Port_Dept ");
            this.Pub1.AddFieldSetEnd();
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //this.Page.RegisterClientScriptBlock("s",
            //    "<link href='/WF/Comm/Style/Table" + BP.Web.WebUser.Style + ".css' rel='stylesheet' type='text/css' />");

            MapM2M mapM2M = new MapM2M(this.FK_MapData, this.NoOfObj);

            if (mapM2M.HisM2MType == M2MType.M2MM)
            {
                this.Response.Redirect("M2MM.aspx?FK_MapData=" + this.FK_MapData + "&NoOfObj=" + this.NoOfObj + "&IsOpen=" + this.IsOpen + "&OID=" + this.OID, true);
                return;
            }

            BP.Sys.M2M m2m = new BP.Sys.M2M();
            m2m.MyPK = this.FK_MapData + "_" + this.NoOfObj + "_" + this.OID + "_";
            m2m.RetrieveFromDBSources();
            DataTable dtGroup = new DataTable();

            if (mapM2M.DBOfGroups.Length > 5)
            {
                dtGroup = BP.DA.DBAccess.RunSQLReturnTable(mapM2M.DBOfGroupsRun);
            }
            else
            {
                dtGroup.Columns.Add("No", typeof(string));
                dtGroup.Columns.Add("Name", typeof(string));
                DataRow dr = dtGroup.NewRow();
                dr["No"]   = "01";
                dr["Name"] = "全部选择";
                dtGroup.Rows.Add(dr);
            }

            DataTable dtObj = BP.DA.DBAccess.RunSQLReturnTable(mapM2M.DBOfObjsRun);

            if (dtObj.Columns.Count == 2)
            {
                dtObj.Columns.Add("Group", typeof(string));
                foreach (DataRow dr in dtObj.Rows)
                {
                    dr["Group"] = "01";
                }
            }

            bool isInsert = mapM2M.IsInsert;
            bool isDelete = mapM2M.IsDelete;

            if ((isDelete || isInsert) && string.IsNullOrEmpty(this.IsOpen) == false)
            {
                this.Button1.Visible = true;
            }

            this.Pub1.AddTable(" width='100%' border=0 ");
            foreach (DataRow drGroup in dtGroup.Rows)
            {
                string ctlIDs  = "";
                string groupNo = drGroup[0].ToString();

                //增加全部选择.
                this.Pub1.AddTR();
                CheckBox cbx = new CheckBox();
                cbx.ID   = "CBs_" + drGroup[0].ToString();
                cbx.Text = drGroup[1].ToString();

                // this.Pub1.AddTDTitle("align=left", cbx);

                this.Pub1.Add("<TD class=Title >");
                this.Pub1.Add("<div style='float:left'>");
                this.Pub1.Add(cbx);
                this.Pub1.Add("</div>");
                this.Pub1.Add("<div style='float:right' ><img onclick=\"GroupBarClick('" + cbx.ID + "')\"  src='../Img/Min.gif' id='I" + cbx.ID + "' alt = 'Min' ></div>");
                this.Pub1.Add("</TD>");
                this.Pub1.AddTREnd();

                if (this.IsPostBack == false)
                {
                    this.Pub1.AddTR("ID='TR" + cbx.ID + "' style='display:none'");
                }
                else
                {
                    this.Pub1.AddTR("ID='TR" + cbx.ID + "'  ");
                }

                this.Pub1.AddTDBegin("nowarp=false");
                this.Pub1.Add("<table width=50% border=0  >");
                int colIdx = -1;
                foreach (DataRow drObj in dtObj.Rows)
                {
                    string no    = drObj[0].ToString();
                    string name  = drObj[1].ToString();
                    string group = drObj[2].ToString();
                    if (group.Trim() != groupNo.Trim())
                    {
                        continue;
                    }

                    colIdx++;
                    if (colIdx == 0)
                    {
                        this.Pub1.Add("<TR>");
                    }

                    CheckBox cb = new CheckBox();
                    cb.ID   = "CB_" + no;
                    ctlIDs += cb.ID + ",";
                    cb.Attributes["onclick"] = "isChange=true;";
                    cb.Text    = name;
                    cb.Checked = m2m.Vals.Contains("," + no + ",");
                    if (cb.Checked)
                    {
                        cb.Text = "<font color=green>" + cb.Text + "</font>";
                    }
                    this.Pub1.Add("<TD>");
                    this.Pub1.Add(cb);
                    this.Pub1.Add("</TD>");

                    if (mapM2M.Cols - 1 == colIdx)
                    {
                        this.Pub1.Add("</TR>");
                        colIdx = -1;
                    }
                }
                cbx.Attributes["onclick"] = "SetSelected(this,'" + ctlIDs + "')";

                if (colIdx != -1)
                {
                    while (colIdx != mapM2M.Cols - 1)
                    {
                        colIdx++;
                        this.Pub1.Add("<TD ></TD>");
                    }
                    this.Pub1.Add("</TR>");
                }
                this.Pub1.AddTableEnd();

                this.Pub1.AddTDEnd();
                this.Pub1.AddTREnd();
            }


            #region 处理未分组的情况.
            bool isHaveUnGroup = false;
            foreach (DataRow drObj in dtObj.Rows)
            {
                string group = drObj[2].ToString();
                isHaveUnGroup = true;
                foreach (DataRow drGroup in dtGroup.Rows)
                {
                    string groupNo = drGroup[0].ToString();
                    if (group == groupNo)
                    {
                        isHaveUnGroup = false;
                        break;
                    }
                }
                if (isHaveUnGroup == false)
                {
                    continue;
                }
            }


            if (isHaveUnGroup == true)
            {
                this.Pub1.AddTR();
                this.Pub1.AddTDBigDocBegain(); // ("nowarp=true");
                this.Pub1.AddTable();
                int    colIdx = -1;
                string ctlIDs = "";
                foreach (DataRow drObj in dtObj.Rows)
                {
                    string group = drObj[2].ToString();
                    isHaveUnGroup = true;
                    foreach (DataRow drGroup in dtGroup.Rows)
                    {
                        string groupNo = drGroup[0].ToString();
                        if (group != groupNo)
                        {
                            isHaveUnGroup = true;
                            break;
                        }
                    }

                    if (isHaveUnGroup == false)
                    {
                        continue;
                    }

                    string no   = drObj[0].ToString();
                    string name = drObj[1].ToString();

                    colIdx++;
                    if (colIdx == 0)
                    {
                        this.Pub1.AddTR();
                    }

                    CheckBox cb = new CheckBox();
                    cb.ID      = "CB_" + no;
                    ctlIDs    += cb.ID + ",";
                    cb.Text    = name + group;
                    cb.Checked = m2m.Vals.Contains("," + no + ",");
                    if (cb.Checked)
                    {
                        cb.Text = "<font color=green>" + cb.Text + "</font>";
                    }

                    this.Pub1.AddTD(cb);

                    if (mapM2M.Cols - 1 == colIdx)
                    {
                        this.Pub1.AddTREnd();
                        colIdx = -1;
                    }
                }
                if (colIdx != -1)
                {
                    while (colIdx != mapM2M.Cols - 1)
                    {
                        colIdx++;
                        this.Pub1.AddTD();
                    }
                    this.Pub1.AddTREnd();
                }
                this.Pub1.AddTableEnd();
                //cbx.Attributes["onclick"] = "SetSelected(this,'" + ctlIDs + "')";
                this.Pub1.AddTDEnd();
                this.Pub1.AddTREnd();
            }
            #endregion 处理未分组的情况.

            this.Pub1.AddTableEnd();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                switch (this.DoType)
                {
                case "DownTempFrm":
                    MapData md   = new MapData(this.FK_MapData);
                    DataSet ds   = md.GenerHisDataSet();
                    string  name = "ccflow表单模板." + md.Name + "." + md.No + ".xml";
                    string  file = this.Request.PhysicalApplicationPath + "\\Temp\\" + this.FK_MapData + ".xml";
                    ds.WriteXml(file);
                    this.Response.Redirect("../../Temp/" + this.FK_MapData + ".xml", true);
                    this.WinClose();
                    break;

                case "CCForm":
                    this.Application.Clear();
                    if (WebUser.NoOfRel != "admin")
                    {
                        BP.Port.Emp emp = new BP.Port.Emp("admin");
                        BP.Web.WebUser.SignInOfGener(emp);
                    }

                    MapAttr mattr = new MapAttr();
                    mattr.MyPK = this.Request.QueryString["MyPK"];
                    int i = mattr.RetrieveFromDBSources();
                    mattr.KeyOfEn    = this.Request.QueryString["KeyOfEn"];
                    mattr.FK_MapData = this.Request.QueryString["FK_MapData"];
                    mattr.MyDataType = int.Parse(this.Request.QueryString["DataType"]);

                    if (!string.IsNullOrEmpty(this.Request.QueryString["UIBindKey"] + ""))
                    {
                        mattr.UIBindKey = this.Request.QueryString["UIBindKey"];
                    }
                    mattr.UIContralType = (UIContralType)int.Parse(this.Request.QueryString["UIContralType"]);
                    mattr.LGType        = (BP.En.FieldTypeS) int.Parse(this.Request.QueryString["LGType"]);
                    if (i == 0)
                    {
                        mattr.Name       = System.Web.HttpUtility.UrlDecode(this.Request.QueryString["KeyName"], System.Text.Encoding.GetEncoding("GB2312"));
                        mattr.UIIsEnable = true;
                        mattr.UIVisible  = true;
                        if (mattr.LGType == FieldTypeS.Enum)
                        {
                            mattr.DefVal = "0";
                        }
                        mattr.Insert();
                    }
                    else
                    {
                        mattr.Update();
                    }

                    switch (mattr.LGType)
                    {
                    case BP.En.FieldTypeS.Enum:
                        this.Response.Redirect("EditEnum.aspx?MyPK=" + mattr.FK_MapData + "&RefNo=" + mattr.MyPK, true);
                        return;

                    case BP.En.FieldTypeS.Normal:
                        this.Response.Redirect("EditF.aspx?DoType=Edit&MyPK=" + mattr.FK_MapData + "&RefNo=" + mattr.MyPK + "&FType=" + mattr.MyDataType + "&GroupField=0", true);
                        return;

                    case BP.En.FieldTypeS.FK:
                        this.Response.Redirect("EditTable.aspx?DoType=Edit&MyPK=" + mattr.FK_MapData + "&RefNo=" + mattr.MyPK + "&FType=" + mattr.MyDataType + "&GroupField=0", true);
                        return;

                    default:
                        break;
                    }
                    break;

                case "DobackToF":
                    MapAttr ma = new MapAttr(this.RefNo);
                    switch (ma.LGType)
                    {
                    case FieldTypeS.Normal:
                        this.Response.Redirect("EditF.aspx?RefNo=" + this.RefNo, true);
                        return;

                    case FieldTypeS.FK:
                        this.Response.Redirect("EditTable.aspx?RefNo=" + this.RefNo, true);
                        return;

                    case FieldTypeS.Enum:
                        this.Response.Redirect("EditEnum.aspx?RefNo=" + this.RefNo, true);
                        return;

                    default:
                        return;
                    }
                    break;

                case "AddEnum":
                    SysEnumMain sem1    = new SysEnumMain(this.Request.QueryString["EnumKey"]);
                    MapAttr     attrAdd = new MapAttr();
                    attrAdd.KeyOfEn = sem1.No;
                    if (attrAdd.IsExit(MapAttrAttr.FK_MapData, this.MyPK, MapAttrAttr.KeyOfEn, sem1.No))
                    {
                        BP.Sys.PubClass.Alert("字段已经存在 [" + sem1.No + "]。");
                        BP.Sys.PubClass.WinClose();
                        return;
                    }

                    attrAdd.FK_MapData    = this.MyPK;
                    attrAdd.Name          = sem1.Name;
                    attrAdd.UIContralType = UIContralType.DDL;
                    attrAdd.UIBindKey     = sem1.No;
                    attrAdd.MyDataType    = BP.DA.DataType.AppInt;
                    attrAdd.LGType        = FieldTypeS.Enum;
                    attrAdd.DefVal        = "0";
                    attrAdd.UIIsEnable    = true;
                    if (this.Idx == null || this.Idx == "")
                    {
                        MapAttrs attrs1 = new MapAttrs(this.MyPK);
                        attrAdd.Idx = 0;
                    }
                    else
                    {
                        attrAdd.Idx = int.Parse(this.Idx);
                    }
                    attrAdd.Insert();
                    this.Response.Redirect("EditEnum.aspx?MyPK=" + this.MyPK + "&RefNo=" + attrAdd.MyPK, true);
                    this.WinClose();
                    return;

                case "DelEnum":
                    string      eKey = this.Request.QueryString["EnumKey"];
                    SysEnumMain sem  = new SysEnumMain();
                    sem.No = eKey;
                    sem.Delete();
                    this.WinClose();
                    return;

                case "AddSysEnum":
                    this.AddFEnum();
                    break;

                case "AddSFTable":
                    this.AddSFTable();
                    break;

                case "AddSFTableAttr":
                    SFTable sf = new SFTable(this.Request.QueryString["RefNo"]);
                    this.Response.Redirect("EditTable.aspx?MyPK=" + this.MyPK + "&SFKey=" + sf.No, true);
                    this.WinClose();
                    return;

                case "AddFG":     /*执行一个插入列组的命令.*/
                    switch (this.RefNo)
                    {
                    case "IsPass":
                        MapDtl dtl = new MapDtl(this.FK_MapData);
                        dtl.IsEnablePass = true;         /*更新是否启动审核分组字段.*/
                        MapAttr attr = new MapAttr();
                        attr.FK_MapData    = this.FK_MapData;
                        attr.KeyOfEn       = "Check_Note";
                        attr.Name          = "审核意见";
                        attr.MyDataType    = DataType.AppString;
                        attr.UIContralType = UIContralType.TB;
                        attr.DefVal        = "同意";
                        attr.UIIsEnable    = true;
                        attr.UIIsLine      = true;
                        attr.MaxLen        = 4000;
                        attr.ColSpan       = 4;   // 默认为4列。
                        attr.Idx           = 1;
                        attr.Insert();

                        attr               = new MapAttr();
                        attr.FK_MapData    = this.FK_MapData;
                        attr.KeyOfEn       = "Checker";
                        attr.Name          = "审核人";// "审核人";
                        attr.MyDataType    = DataType.AppString;
                        attr.UIContralType = UIContralType.TB;
                        attr.MaxLen        = 50;
                        attr.MinLen        = 0;
                        attr.UIIsEnable    = true;
                        attr.UIIsLine      = false;
                        attr.DefVal        = "@WebUser.Name";
                        attr.UIIsEnable    = false;
                        attr.IsSigan       = true;
                        attr.Idx           = 2;
                        attr.Insert();

                        attr               = new MapAttr();
                        attr.FK_MapData    = this.FK_MapData;
                        attr.KeyOfEn       = "IsPass";
                        attr.Name          = "通过否?";// "审核人";
                        attr.MyDataType    = DataType.AppBoolean;
                        attr.UIContralType = UIContralType.CheckBok;
                        attr.UIIsEnable    = true;
                        attr.UIIsLine      = false;
                        attr.UIIsEnable    = false;
                        attr.IsSigan       = true;
                        attr.DefVal        = "1";
                        attr.Idx           = 2;
                        attr.DefVal        = "0";
                        attr.Insert();

                        attr               = new MapAttr();
                        attr.FK_MapData    = this.FK_MapData;
                        attr.KeyOfEn       = "Check_RDT";
                        attr.Name          = "审核日期"; // "审核日期";
                        attr.MyDataType    = DataType.AppDateTime;
                        attr.UIContralType = UIContralType.TB;
                        attr.UIIsEnable    = true;
                        attr.UIIsLine      = false;
                        attr.DefVal        = "@RDT";
                        attr.UIIsEnable    = false;
                        attr.Idx           = 3;
                        attr.Insert();

                        /* 处理批次ID*/
                        attr            = new MapAttr();
                        attr.FK_MapData = this.FK_MapData;
                        attr.KeyOfEn    = "BatchID";
                        attr.Name       = "BatchID";  // this.ToE("IsPass", "是否通过");// "审核人";
                        attr.MyDataType = DataType.AppInt;
                        attr.UIIsEnable = false;
                        attr.UIIsLine   = false;
                        attr.UIIsEnable = false;
                        attr.UIVisible  = false;
                        attr.Idx        = 2;
                        attr.DefVal     = "0";
                        attr.Insert();

                        dtl.Update();
                        this.WinClose();
                        return;

                    case "Eval":         /* 质量评价 */
                        attr               = new MapAttr();
                        attr.FK_MapData    = this.FK_MapData;
                        attr.KeyOfEn       = "EvalEmpNo";
                        attr.Name          = "被评价人员编号";
                        attr.MyDataType    = DataType.AppString;
                        attr.UIContralType = UIContralType.TB;
                        attr.MaxLen        = 50;
                        attr.MinLen        = 0;
                        attr.UIIsEnable    = true;
                        attr.UIIsLine      = false;
                        attr.UIIsEnable    = false;
                        attr.IsSigan       = true;
                        attr.Idx           = 1;
                        attr.Insert();

                        attr               = new MapAttr();
                        attr.FK_MapData    = this.FK_MapData;
                        attr.KeyOfEn       = "EvalEmpName";
                        attr.Name          = "被评价人员名称";
                        attr.MyDataType    = DataType.AppString;
                        attr.UIContralType = UIContralType.TB;
                        attr.MaxLen        = 50;
                        attr.MinLen        = 0;
                        attr.UIIsEnable    = true;
                        attr.UIIsLine      = false;
                        attr.UIIsEnable    = false;
                        attr.IsSigan       = true;
                        attr.Idx           = 2;
                        attr.Insert();

                        attr               = new MapAttr();
                        attr.FK_MapData    = this.FK_MapData;
                        attr.KeyOfEn       = "EvalCent";
                        attr.Name          = "工作得分";
                        attr.MyDataType    = DataType.AppFloat;
                        attr.UIContralType = UIContralType.TB;
                        attr.MaxLen        = 50;
                        attr.MinLen        = 0;
                        attr.UIIsEnable    = true;
                        attr.UIIsLine      = false;
                        attr.UIIsEnable    = true;
                        attr.Idx           = 3;
                        attr.Insert();

                        attr               = new MapAttr();
                        attr.FK_MapData    = this.FK_MapData;
                        attr.KeyOfEn       = "EvalNote";
                        attr.Name          = "评价信息";
                        attr.MyDataType    = DataType.AppString;
                        attr.UIContralType = UIContralType.TB;
                        attr.MaxLen        = 50;
                        attr.MinLen        = 0;
                        attr.UIIsEnable    = true;
                        attr.UIIsEnable    = true;
                        attr.Idx           = 4;
                        attr.Insert();
                        this.WinClose();
                        return;

                    default:
                        break;
                    }
                    break;

                case "AddFGroup":
                    this.AddFGroup();
                    return;

                case "AddF":
                case "ChoseFType":
                    this.AddF();
                    break;

                case "Up":
                    MapAttr attrU = new MapAttr(this.RefNo);
                    if (this.Request.QueryString["IsDtl"] != null)
                    {
                        attrU.DoDtlUp();
                    }
                    else
                    {
                        attrU.DoUp();
                    }

                    this.WinClose();
                    break;

                case "Down":     //让一个字段下移动.
                    MapAttr attrD = new MapAttr(this.RefNo);
                    attrD.DoDown();
                    this.WinClose();
                    break;

                case "DownAttr":     //让一个字段下移动.
                    MapAttr attrAttr = new MapAttr(this.RefNo);
                    attrAttr.DoDtlDown();
                    this.WinClose();
                    break;

                case "Jump":
                    MapAttr attrFrom = new MapAttr(this.Request.QueryString["FromID"]);
                    MapAttr attrTo   = new MapAttr(this.Request.QueryString["ToID"]);
                    attrFrom.DoJump(attrTo);
                    this.WinClose();
                    break;

                case "MoveTo":
                    string  toID     = this.Request.QueryString["ToID"];
                    int     toGFID   = int.Parse(this.Request.QueryString["ToGID"]);
                    int     fromGID  = int.Parse(this.Request.QueryString["FromGID"]);
                    string  fromID   = this.Request.QueryString["FromID"];
                    MapAttr fromAttr = new MapAttr();
                    fromAttr.MyPK = fromID;
                    fromAttr.Retrieve();
                    if (toGFID == fromAttr.GroupID && fromAttr.MyPK == toID)
                    {
                        /* 如果没有移动. */
                        this.WinClose();
                        return;
                    }
                    if (toGFID != fromAttr.GroupID && fromAttr.MyPK == toID)
                    {
                        MapAttr toAttr = new MapAttr(toID);
                        fromAttr.Update(MapAttrAttr.GroupID, toAttr.GroupID, MapAttrAttr.Idx, toAttr.Idx);
                        this.WinClose();
                        return;
                    }
                    this.Response.Redirect(this.Request.RawUrl.Replace("MoveTo", "Jump"), true);
                    return;

                case "Edit":
                    Edit();
                    break;

                case "Del":
                    MapAttr attrDel = new MapAttr();
                    attrDel.MyPK = this.RefNo;
                    attrDel.Delete();
                    this.WinClose();
                    break;

                case "GFDoUp":
                    GroupField gf = new GroupField(this.RefOID);
                    gf.DoUp();
                    gf.Retrieve();
                    if (gf.Idx == 0)
                    {
                        this.WinClose();
                        return;
                    }
                    int oidIdx = gf.Idx;
                    gf.Idx = gf.Idx - 1;
                    GroupField gfUp = new GroupField();
                    if (gfUp.Retrieve(GroupFieldAttr.EnName, gf.EnName, GroupFieldAttr.Idx, gf.Idx) == 1)
                    {
                        gfUp.Idx = oidIdx;
                        gfUp.Update();
                    }
                    gf.Update();
                    this.WinClose();
                    break;

                case "GFDoDown":
                    GroupField mygf = new GroupField(this.RefOID);
                    mygf.DoDown();
                    mygf.Retrieve();
                    int oidIdx1 = mygf.Idx;
                    mygf.Idx = mygf.Idx + 1;
                    GroupField gfDown = new GroupField();
                    if (gfDown.Retrieve(GroupFieldAttr.EnName, mygf.EnName, GroupFieldAttr.Idx, mygf.Idx) == 1)
                    {
                        gfDown.Idx = oidIdx1;
                        gfDown.Update();
                    }
                    mygf.Update();
                    this.WinClose();
                    break;

                case "AthDoUp":
                    FrmAttachment frmAth = new FrmAttachment(this.MyPK);
                    if (frmAth.RowIdx > 0)
                    {
                        frmAth.RowIdx = frmAth.RowIdx - 1;
                        frmAth.Update();
                    }
                    this.WinClose();
                    break;

                case "AthDoDown":
                    FrmAttachment frmAthD = new FrmAttachment(this.MyPK);
                    if (frmAthD.RowIdx < 10)
                    {
                        frmAthD.RowIdx = frmAthD.RowIdx + 1;
                        frmAthD.Update();
                    }
                    this.WinClose();
                    break;

                case "DtlDoUp":
                    MapDtl dtl1 = new MapDtl(this.MyPK);
                    if (dtl1.RowIdx > 0)
                    {
                        dtl1.RowIdx = dtl1.RowIdx - 1;
                        dtl1.Update();
                    }
                    this.WinClose();
                    break;

                case "DtlDoDown":
                    MapDtl dtl2 = new MapDtl(this.MyPK);
                    if (dtl2.RowIdx < 10)
                    {
                        dtl2.RowIdx = dtl2.RowIdx + 1;
                        dtl2.Update();
                    }
                    this.WinClose();
                    break;

                case "M2MDoUp":
                    MapM2M ddtl1 = new MapM2M(this.MyPK);
                    if (ddtl1.RowIdx > 0)
                    {
                        ddtl1.RowIdx = ddtl1.RowIdx - 1;
                        ddtl1.Update();
                    }
                    this.WinClose();
                    break;

                case "M2MDoDown":
                    MapM2M ddtl2 = new MapM2M(this.MyPK);
                    if (ddtl2.RowIdx < 10)
                    {
                        ddtl2.RowIdx = ddtl2.RowIdx + 1;
                        ddtl2.Update();
                    }
                    this.WinClose();
                    break;

                case "FrameDoUp":
                    MapFrame frame1 = new MapFrame(this.MyPK);
                    if (frame1.RowIdx > 0)
                    {
                        frame1.RowIdx = frame1.RowIdx - 1;
                        frame1.Update();
                    }
                    this.WinClose();
                    break;

                case "FrameDoDown":
                    MapFrame frame2 = new MapFrame(this.MyPK);
                    if (frame2.RowIdx < 10)
                    {
                        frame2.RowIdx = frame2.RowIdx + 1;
                        frame2.Update();
                    }
                    this.WinClose();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                this.Pub1.AddMsgOfWarning("错误:", ex.Message + " <br>" + this.Request.RawUrl);
            }
        }
        void btn_Copy_Click(object sender, EventArgs e)
        {
            BP.WF.Node nd  = new BP.WF.Node(this.FK_Node);
            Node       sNd = new Node(this.NodeOfSelect);

            BP.En.Attrs attrs     = sNd.HisWork.EnMap.Attrs;
            BP.En.Attrs attrsCopy = nd.HisWork.EnMap.Attrs;

            // 开始copy 分组的节点。
            GroupFields gfs  = new GroupFields(this.NodeOfSelect);
            MapDtls     dtls = new MapDtls(this.NodeOfSelect);
            MapM2Ms     m2ms = new MapM2Ms(this.NodeOfSelect);
            MapFrames   frms = new MapFrames(this.NodeOfSelect);

            foreach (GroupField gf in gfs)
            {
                CheckBox cb = this.Pub2.GetCBByID("CB" + gf.OID);
                if (cb.Checked == false)
                {
                    continue;
                }

                // 生成一个分组实体.
                GroupField mygf = new GroupField();
                mygf.Lab    = gf.Lab;
                mygf.EnName = this.FK_Node;
                mygf.Idx    = gf.Idx;
                mygf.Insert();

                foreach (MapM2M m2m in m2ms)
                {
                    if (m2m.GroupID != gf.OID)
                    {
                        continue;
                    }

                    MapM2M mym2m = new MapM2M();
                    mym2m.MyPK = m2m.MyPK.Replace(this.NodeOfSelect, this.FK_Node);
                    //  mym2m.FK_MapData =this
                    if (mym2m.IsExits)
                    {
                        continue;
                    }

                    mym2m.Copy(m2m);
                    mym2m.FK_MapData = this.FK_Node;
                    mym2m.GroupID    = mygf.OID;
                    mym2m.MyPK       = m2m.MyPK.Replace(this.NodeOfSelect, this.FK_Node);
                    mym2m.Insert();
                }

                foreach (MapFrame frm in frms)
                {
                    if (frm.GroupID != gf.OID)
                    {
                        continue;
                    }

                    MapFrame myen = new MapFrame();
                    myen.MyPK = frm.MyPK.Replace(this.NodeOfSelect, this.FK_Node);
                    if (myen.IsExits)
                    {
                        continue;
                    }

                    myen.Copy(frm);
                    myen.FK_MapData = this.FK_Node;
                    myen.GroupID    = mygf.OID;
                    myen.MyPK       = frm.MyPK.Replace(this.NodeOfSelect, this.FK_Node);
                    myen.Insert();
                }

                // 复制从表.
                foreach (MapDtl dtl in dtls)
                {
                    cb = this.Pub2.GetCBByID("CB_" + dtl.No + gf.OID);
                    MapDtl dtlNew = new MapDtl();
                    dtlNew.No = dtl.No.Replace(this.NodeOfSelect, this.FK_Node);
                    if (dtlNew.IsExits)
                    {
                        continue;
                    }

                    dtlNew.Copy(dtl);
                    dtlNew.FK_MapData = this.FK_Node;
                    dtlNew.No         = dtl.No.Replace(this.NodeOfSelect, this.FK_Node);

                    //  dtlNew.No = this.FK_Node + "Dtl";
                    // dtlNew.No = dtl.No.Replace(this.FK_Node, this.NodeOfSelect);

                    dtlNew.IsInsert = false;
                    dtlNew.IsUpdate = false;
                    dtlNew.IsDelete = false;

                    dtlNew.GroupID = mygf.OID;
                    dtlNew.PTable  = dtlNew.No;

                    dtlNew.Insert();

                    // 复制从表里面的明细。
                    int      idx    = 0;
                    MapAttrs mattrs = new MapAttrs(dtl.No);
                    foreach (MapAttr attr in mattrs)
                    {
                        MapAttr attrNew = new MapAttr();
                        attrNew.Copy(attr);
                        attrNew.FK_MapData = dtlNew.No;
                        attrNew.UIIsEnable = false;
                        if (attrNew.DefVal.Contains("@"))
                        {
                            attrNew.DefVal = "";
                        }

                        dtlNew.RowIdx       = idx;
                        attrNew.HisEditType = EditType.Edit;
                        attrNew.Insert();
                    }
                }

                // copy his fields.
                MapAttrs willCopyAttrs = new MapAttrs();
                willCopyAttrs.Retrieve(MapAttrAttr.GroupID, gf.OID, MapAttrAttr.Idx);
                int idx1 = 0;
                foreach (MapAttr attr in willCopyAttrs)
                {
                    MapAttr attrNew = new MapAttr();
                    if (attrNew.IsExit(MapAttrAttr.FK_MapData, this.FK_Node,
                                       MapAttrAttr.KeyOfEn, attr.KeyOfEn) == true)
                    {
                        continue;
                    }

                    if (attr.UIVisible == false)
                    {
                        continue;
                    }

                    idx1++;
                    attrNew.Copy(attr);
                    attrNew.GroupID    = mygf.OID;
                    attrNew.FK_MapData = this.FK_Node;
                    attrNew.UIIsEnable = false;
                    attrNew.Idx        = idx1;
                    if (attrNew.KeyOfEn == "Title")
                    {
                        attrNew.HisEditType = EditType.Edit;
                    }

                    attrNew.HisEditType = EditType.Edit;
                    attrNew.DefVal      = "";
                    attrNew.Insert();
                }
            }


            int GroupField = this.Pub2.GetDDLByID("DDL_GroupField").SelectedItemIntVal;

            foreach (Attr attr in attrs)
            {
                if (this.Pub2.IsExit(attr.Key) == false)
                {
                    continue;
                }
                CheckBox cb = this.Pub2.GetCBByID(attr.Key);
                if (cb.Checked == false)
                {
                    continue;
                }

                BP.Sys.MapAttr ma = new BP.Sys.MapAttr();
                int            i  = ma.Retrieve(BP.Sys.MapAttrAttr.KeyOfEn, attr.Key,
                                                BP.Sys.MapAttrAttr.FK_MapData, this.NodeOfSelect);

                BP.Sys.MapAttr ma1     = new BP.Sys.MapAttr();
                bool           ishavle = ma1.IsExit(BP.Sys.MapAttrAttr.KeyOfEn, attr.Key,
                                                    BP.Sys.MapAttrAttr.FK_MapData, this.FK_Node);

                if (ishavle)
                {
                    continue;
                }


                ma1.Copy(ma);

                ma1.FK_MapData = this.FK_Node;
                ma1.KeyOfEn    = ma.KeyOfEn;
                ma1.Name       = ma.Name;
                ma1.GroupID    = GroupField;
                ma1.UIIsEnable = false;

                ma1.HisEditType = EditType.Edit;

                if (ma1.DefVal != null && ma1.DefVal.Contains("@"))
                {
                    ma1.DefVal = "";
                }
                ma1.Insert();
            }

            if (this.Pub2.IsExit("CB_Table"))
            {
                if (this.Pub2.GetCBByID("CB_Table").Checked)
                {
                    MapData md1 = new MapData(this.NodeOfSelect);
                    MapData md2 = new MapData(this.FK_Node);
                    //md2.CellsX = md1.CellsX;
                    //md2.CellsY = md1.CellsY;
                    md2.Update();

                    //MapAttrs ma1 = md1.GenerHisTableCells;
                    // 删除历史数据。

                    //ma1.Delete(MapAttrAttr.FK_MapData, this.FK_Node + "T");
                    //foreach (MapAttr attr in ma1)
                    //{
                    //    MapAttr attr2 = new MapAttr();
                    //    attr2.Copy(attr);
                    //    // attr2.OID = 0;
                    //    attr2.GroupID = 0;
                    //    attr2.Idx = 0;
                    //    attr2.FK_MapData = this.FK_Node + "T";
                    //    attr2.UIIsEnable = false;
                    //    attr2.Insert();
                    //}
                }
            }

            this.WinClose();
            //this.WinCloseWithMsg("复制成功");
            //this.Response.Redirect("MapDef.aspx?PK=" + this.FK_Node + "&NodeOfSelect=" + this.NodeOfSelect);
        }
Beispiel #10
0
        public string DoType(string dotype, string v1, string v2, string v3, string v4, string v5)
        {
            string sql = "";

            try
            {
                switch (dotype)
                {
                case "CreateCheckGroup":
                    string gKey    = v1;
                    string gName   = v2;
                    string enName1 = v3;

                    MapAttr attrN = new MapAttr();
                    int     i     = attrN.Retrieve(MapAttrAttr.FK_MapData, enName1, MapAttrAttr.KeyOfEn, gKey + "_Note");
                    i += attrN.Retrieve(MapAttrAttr.FK_MapData, enName1, MapAttrAttr.KeyOfEn, gKey + "_Checker");
                    i += attrN.Retrieve(MapAttrAttr.FK_MapData, enName1, MapAttrAttr.KeyOfEn, gKey + "_RDT");
                    if (i > 0)
                    {
                        return("前缀已经使用:" + gKey + " , 请确认您是否增加了这个审核分组或者,请您更换其他的前缀。");
                    }

                    GroupField gf = new GroupField();
                    gf.Lab    = gName;
                    gf.EnName = enName1;
                    gf.Insert();

                    attrN               = new MapAttr();
                    attrN.FK_MapData    = enName1;
                    attrN.KeyOfEn       = gKey + "_Note";
                    attrN.Name          = "审核意见";
                    attrN.MyDataType    = DataType.AppString;
                    attrN.UIContralType = UIContralType.TB;
                    attrN.UIIsEnable    = true;
                    attrN.UIIsLine      = true;
                    attrN.MaxLen        = 4000;
                    attrN.GroupID       = gf.OID;
                    attrN.UIHeight      = 23 * 3;
                    attrN.IDX           = 1;
                    attrN.Insert();

                    attrN               = new MapAttr();
                    attrN.FK_MapData    = enName1;
                    attrN.KeyOfEn       = gKey + "_Checker";
                    attrN.Name          = "审核人";// "审核人";
                    attrN.MyDataType    = DataType.AppString;
                    attrN.UIContralType = UIContralType.TB;
                    attrN.MaxLen        = 50;
                    attrN.MinLen        = 0;
                    attrN.UIIsEnable    = true;
                    attrN.UIIsLine      = false;
                    attrN.DefVal        = "@WebUser.Name";
                    attrN.UIIsEnable    = false;
                    attrN.GroupID       = gf.OID;
                    attrN.IsSigan       = true;
                    attrN.IDX           = 2;
                    attrN.Insert();

                    attrN               = new MapAttr();
                    attrN.FK_MapData    = enName1;
                    attrN.KeyOfEn       = gKey + "_RDT";
                    attrN.Name          = "审核日期"; // "审核日期";
                    attrN.MyDataType    = DataType.AppDateTime;
                    attrN.UIContralType = UIContralType.TB;
                    attrN.UIIsEnable    = true;
                    attrN.UIIsLine      = false;
                    attrN.DefVal        = "@RDT";
                    attrN.UIIsEnable    = false;
                    attrN.GroupID       = gf.OID;
                    attrN.IDX           = 3;
                    attrN.Insert();
                    return(null);

                case "NewDtl":
                    MapDtl dtlN = new MapDtl();
                    dtlN.No = v1;
                    if (dtlN.RetrieveFromDBSources() != 0)
                    {
                        return("从表已存在");
                    }
                    dtlN.Name       = v1;
                    dtlN.FK_MapData = v2;
                    dtlN.PTable     = v1;
                    dtlN.Insert();
                    dtlN.IntMapAttrs();
                    return(null);

                case "DelM2M":
                    MapM2M m2mDel = new MapM2M();
                    m2mDel.MyPK = v1;
                    m2mDel.Delete();
                    //M2M m2mData = new M2M();
                    //m2mData.Delete(M2MAttr.FK_MapData, v1);
                    return(null);

                case "NewAthM":     // 新建 NewAthM.
                    string fk_mapdataAth = v1;
                    string athName       = v2;

                    BP.Sys.FrmAttachment athM = new FrmAttachment();
                    athM.MyPK = athName;
                    if (athM.IsExits)
                    {
                        return("多选名称:" + athName + ",已经存在。");
                    }

                    athM.X          = float.Parse(v3);
                    athM.Y          = float.Parse(v4);
                    athM.Name       = "多文件上传";
                    athM.FK_MapData = fk_mapdataAth;
                    athM.Insert();
                    return(null);

                case "NewM2M":
                    string fk_mapdataM2M = v1;
                    string m2mName       = v2;
                    MapM2M m2m           = new MapM2M();
                    m2m.FK_MapData = v1;
                    m2m.NoOfObj    = v2;
                    if (v3 == "0")
                    {
                        m2m.HisM2MType = M2MType.M2M;
                        m2m.Name       = "新建一对多";
                    }
                    else
                    {
                        m2m.HisM2MType = M2MType.M2MM;
                        m2m.Name       = "新建一对多多";
                    }

                    m2m.X    = float.Parse(v4);
                    m2m.Y    = float.Parse(v5);
                    m2m.MyPK = m2m.FK_MapData + "_" + m2m.NoOfObj;
                    if (m2m.IsExits)
                    {
                        return("多选名称:" + m2mName + ",已经存在。");
                    }
                    m2m.Insert();
                    return(null);

                case "DelEnum":
                    // 检查这个物理表是否被使用。
                    sql = "SELECT  * FROM Sys_MapAttr WHERE UIBindKey='" + v1 + "'";
                    DataTable dtEnum     = DBAccess.RunSQLReturnTable(sql);
                    string    msgDelEnum = "";
                    foreach (DataRow dr in dtEnum.Rows)
                    {
                        msgDelEnum += "\n 表单编号:" + dr["FK_MapData"] + " , 字段:" + dr["KeyOfEn"] + ", 名称:" + dr["Name"];
                    }

                    if (msgDelEnum != "")
                    {
                        return("该枚举已经被如下字段所引用,您不能删除它。" + msgDelEnum);
                    }

                    sql  = "DELETE FROM Sys_EnumMain WHERE No='" + v1 + "'";
                    sql += "@DELETE FROM Sys_Enum WHERE EnumKey='" + v1 + "' ";
                    DBAccess.RunSQLs(sql);
                    return(null);

                case "DelSFTable":     /* 删除自定义的物理表. */
                    // 检查这个物理表是否被使用。
                    sql = "SELECT  * FROM Sys_MapAttr WHERE UIBindKey='" + v1 + "'";
                    DataTable dt     = DBAccess.RunSQLReturnTable(sql);
                    string    msgDel = "";
                    foreach (DataRow dr in dt.Rows)
                    {
                        msgDel += "\n 表单编号:" + dr["FK_MapData"] + " , 字段:" + dr["KeyOfEn"] + ", 名称:" + dr["Name"];
                    }

                    if (msgDel != "")
                    {
                        return("该数据表已经被如下字段所引用,您不能删除它。" + msgDel);
                    }

                    SFTable sfDel = new SFTable();
                    sfDel.No = v1;
                    sfDel.DirectDelete();
                    return(null);

                case "SaveSFTable":
                    string enName = v2;
                    string chName = v1;
                    if (string.IsNullOrEmpty(v1) || string.IsNullOrEmpty(v2))
                    {
                        return("视图中的中英文名称不能为空。");
                    }

                    SFTable sf = new SFTable();
                    sf.No   = enName;
                    sf.Name = chName;

                    sf.No   = enName;
                    sf.Name = chName;

                    sf.FK_Val = enName;
                    sf.Save();
                    if (DBAccess.IsExitsObject(enName) == true)
                    {
                        /*已经存在此对象,检查一下是否有No,Name列。*/
                        sql = "SELECT No,Name FROM " + enName;
                        try
                        {
                            DBAccess.RunSQLReturnTable(sql);
                        }
                        catch (Exception ex)
                        {
                            return("您指定的表或视图(" + enName + "),不包含No,Name两列,不符合ccflow约定的规则。技术信息:" + ex.Message);
                        }
                        return(null);
                    }
                    else
                    {
                        /*创建这个表,并且插入基础数据。*/
                        try
                        {
                            // 如果没有该表或者视图,就要创建它。
                            sql = "CREATE TABLE " + enName + "(No varchar(30) NOT NULL,Name varchar(50) NULL)";
                            DBAccess.RunSQL(sql);
                            DBAccess.RunSQL("INSERT INTO " + enName + " (No,Name) VALUES('001','Item1')");
                            DBAccess.RunSQL("INSERT INTO " + enName + " (No,Name) VALUES('002','Item2')");
                            DBAccess.RunSQL("INSERT INTO " + enName + " (No,Name) VALUES('003','Item3')");
                        }
                        catch (Exception ex)
                        {
                            sf.DirectDelete();
                            return("创建物理表期间出现错误,可能是非法的物理表名.技术信息:" + ex.Message);
                        }
                    }
                    return(null);      /*创建成功后返回空值*/

                case "FrmTempleteExp": //导出表单.
                    MapData mdfrmtem = new MapData();
                    mdfrmtem.No = v1;
                    if (mdfrmtem.RetrieveFromDBSources() == 0)
                    {
                        if (v1.Contains("ND"))
                        {
                            int  nodeId = int.Parse(v1.Replace("ND", ""));
                            Node nd     = new Node(nodeId);
                            mdfrmtem.Name   = nd.Name;
                            mdfrmtem.PTable = v1;
                            mdfrmtem.EnPK   = "OID";
                            mdfrmtem.Insert();
                        }
                    }

                    DataSet ds   = mdfrmtem.GenerHisDataSet();
                    string  file = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "\\Temp\\" + v1 + ".xml";
                    if (System.IO.File.Exists(file))
                    {
                        System.IO.File.Delete(file);
                    }
                    ds.WriteXml(file);

                    // BP.PubClass.DownloadFile(file, mdfrmtem.Name + ".xml");
                    //this.DownLoadFile(System.Web.HttpContext.Current, file, mdfrmtem.Name);
                    return(null);

                case "FrmTempleteImp":     //导入表单.
                    DataSet dsImp   = new DataSet();
                    string  fileImp = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "\\Temp\\" + v1 + ".xml";
                    dsImp.ReadXml(fileImp);     //读取文件.
                    MapData.ImpMapData(v1, dsImp, true);
                    return(null);

                case "NewHidF":
                    string  fk_mapdataHid = v1;
                    string  key           = v2;
                    string  name          = v3;
                    int     dataType      = int.Parse(v4);
                    MapAttr mdHid         = new MapAttr();
                    mdHid.MyPK        = fk_mapdataHid + "_" + key;
                    mdHid.FK_MapData  = fk_mapdataHid;
                    mdHid.KeyOfEn     = key;
                    mdHid.Name        = name;
                    mdHid.MyDataType  = dataType;
                    mdHid.HisEditType = EditType.Edit;
                    mdHid.MaxLen      = 100;
                    mdHid.MinLen      = 0;
                    mdHid.LGType      = FieldTypeS.Normal;
                    mdHid.UIVisible   = false;
                    mdHid.UIIsEnable  = false;
                    mdHid.Insert();
                    return(null);

                case "DelDtl":
                    MapDtl dtl = new MapDtl(v1);
                    dtl.Delete();
                    return(null);

                case "DeleteFrm":
                    string  delFK_Frm = v1;
                    MapData mdDel     = new MapData(delFK_Frm);
                    mdDel.Delete();
                    sql = "@DELETE FROM Sys_MapData WHERE No='" + delFK_Frm + "'";
                    sql = "@DELETE FROM WF_FrmNode WHERE FK_Frm='" + delFK_Frm + "'";
                    DBAccess.RunSQLs(sql);
                    return(null);

                case "FrmUp":
                case "FrmDown":
                    FrmNode myfn = new FrmNode();
                    myfn.Retrieve(FrmNodeAttr.FK_Node, v1, FrmNodeAttr.FK_Frm, v2);
                    if (dotype == "FrmUp")
                    {
                        myfn.DoUp();
                    }
                    else
                    {
                        myfn.DoDown();
                    }
                    return(null);

                case "SaveFlowFrm":
                    // 转化参数意义.
                    string vals    = v1;
                    string fk_Node = v2;
                    string fk_flow = v3;
                    bool   isPrint = false;
                    if (v5 == "1")
                    {
                        isPrint = true;
                    }

                    bool isReadonly = false;
                    if (v4 == "1")
                    {
                        isReadonly = true;
                    }

                    string msg = this.SaveEn(vals);
                    if (msg.Contains("Error"))
                    {
                        return(msg);
                    }

                    string fk_frm = msg;
                    Frm    fm     = new Frm();
                    fm.No = fk_frm;
                    fm.Retrieve();

                    FrmNode fn = new FrmNode();
                    if (fn.Retrieve(FrmNodeAttr.FK_Frm, fk_frm,
                                    FrmNodeAttr.FK_Node, fk_Node) == 1)
                    {
                        fn.IsEdit  = !isReadonly;
                        fn.IsPrint = isPrint;
                        fn.FK_Flow = fk_flow;
                        fn.Update();
                        BP.DA.DBAccess.RunSQL("UPDATE Sys_MapData SET FK_FrmSort='01',AppType=1  WHERE No='" + fk_frm + "'");
                        return(fk_frm);
                    }

                    fn.FK_Frm  = fk_frm;
                    fn.FK_Flow = fk_flow;
                    fn.FK_Node = int.Parse(fk_Node);
                    fn.IsEdit  = !isReadonly;
                    fn.IsPrint = isPrint;
                    fn.Idx     = 100;
                    fn.FK_Flow = fk_flow;
                    fn.Insert();

                    MapData md = new MapData();
                    md.No = fm.No;
                    if (md.RetrieveFromDBSources() == 0)
                    {
                        md.Name = fm.Name;
                        md.EnPK = "OID";
                        md.Insert();
                    }

                    MapAttr attr = new MapAttr();
                    attr.FK_MapData    = md.No;
                    attr.KeyOfEn       = "OID";
                    attr.Name          = "WorkID";
                    attr.MyDataType    = BP.DA.DataType.AppInt;
                    attr.UIContralType = UIContralType.TB;
                    attr.LGType        = FieldTypeS.Normal;
                    attr.UIVisible     = false;
                    attr.UIIsEnable    = false;
                    attr.DefVal        = "0";
                    attr.HisEditType   = BP.En.EditType.Readonly;
                    attr.Insert();

                    attr               = new MapAttr();
                    attr.FK_MapData    = md.No;
                    attr.KeyOfEn       = "FID";
                    attr.Name          = "FID";
                    attr.MyDataType    = BP.DA.DataType.AppInt;
                    attr.UIContralType = UIContralType.TB;
                    attr.LGType        = FieldTypeS.Normal;
                    attr.UIVisible     = false;
                    attr.UIIsEnable    = false;
                    attr.DefVal        = "0";
                    attr.HisEditType   = BP.En.EditType.Readonly;
                    attr.Insert();

                    attr               = new MapAttr();
                    attr.FK_MapData    = md.No;
                    attr.KeyOfEn       = "RDT";
                    attr.Name          = "记录日期";
                    attr.MyDataType    = BP.DA.DataType.AppDateTime;
                    attr.UIContralType = UIContralType.TB;
                    attr.LGType        = FieldTypeS.Normal;
                    attr.UIVisible     = false;
                    attr.UIIsEnable    = false;
                    attr.DefVal        = "@RDT";
                    attr.HisEditType   = BP.En.EditType.Readonly;
                    attr.Insert();
                    return(fk_frm);

                default:
                    return("Error:" + dotype + " , 未设置此标记.");
                }
            }
            catch (Exception ex)
            {
                return("Error:" + ex.Message);
            }
        }