Esempio n. 1
0
    void btn_Click(object sender, EventArgs e)
    {
        MapDtls dtl2s = new MapDtls();

        dtl2s.Delete(MapDtlAttr.FK_MapData, this.MyPK);
        Nodes nds = new Nodes(BP.WF.Glo.GenerFlowNo(this.MyPK));

        foreach (BP.WF.Node nd in nds)
        {
            if (nd.IsEndNode == false)
            {
                continue;
            }

            MapDtls dtls = new MapDtls("ND" + nd.NodeID);
            int     i    = 0;

            foreach (MapDtl dtl in dtls)
            {
                if (this.Pub1.GetCBByID("CB_" + dtl.No).Checked == false)
                {
                    continue;
                }

                i++;
                // 生成从表让其可以在单个数据里显示他们。
                MapDtl dtlNew = new MapDtl();
                dtlNew.Copy(dtl);
                dtlNew.No         = this.MyPK + i;
                dtlNew.FK_MapData = this.MyPK;
                dtlNew.GroupID    = this.Pub1.GetDDLByID("DDL_" + dtl.No).SelectedItemIntVal;
                dtlNew.Insert();

                // 删除原来的数据。
                MapAttrs attrsDtl = new MapAttrs();
                attrsDtl.Delete(MapAttrAttr.FK_MapData, dtlNew.No);

                // 复制到新的数据表里。
                MapAttrs attrs = new MapAttrs(dtl.No);
                foreach (MapAttr attr in attrs)
                {
                    MapAttr attrN = new MapAttr();
                    attrN.Copy(attr);
                    attrN.FK_MapData = dtlNew.No;
                    attrN.Insert();
                }
                Cash.Map_Cash.Remove(dtlNew.No);


                #region   制成 主表.让其可以查询。
                // 处理主表。
                MapData md = new MapData();
                md.Copy(dtlNew);
                md.No = "ND" + int.Parse(this.FK_Flow) + "RptDtl" + i.ToString();
                md.Save();

                // 删除原来的属性。
                attrs.Delete(MapAttrAttr.FK_MapData, md.No);

                // 删除分组。
                GroupField gfBase = new GroupField();
                gfBase.Delete(GroupFieldAttr.EnName, md.No);

                // 增加基本信息分组。
                gfBase.EnName = md.No;
                gfBase.Lab    = md.Name;
                gfBase.Idx    = 99;
                gfBase.Insert();


                //生成基本信息属性。
                foreach (MapAttr attr in attrs)
                {
                    MapAttr attrN = new MapAttr();
                    attrN.Copy(attr);
                    attrN.FK_MapData = md.No;
                    attrN.GroupID    = gfBase.OID;
                    attrN.Insert();
                }

                MapAttrs attrNs = new MapAttrs(md.No);

                // 对个别字段进行处理。
                foreach (MapAttr attr in attrNs)
                {
                    switch (attr.KeyOfEn)
                    {
                    case StartWorkAttr.FK_Dept:
                        continue;
                        //if (attr.UIContralType != UIContralType.DDL)
                        //{
                        //attr.UIBindKey = "BP.Port.Depts";
                        //attr.UIContralType = UIContralType.DDL;
                        //attr.LGType = FieldTypeS.FK;
                        //attr.UIVisible = true;
                        //// if (gfs.Contains(attr.GroupID) == false)
                        //attr.GroupID = gfBase.OID;// gfs[0].GetValIntByKey("OID");
                        //attr.Update();
                        //// }
                        break;

                    case "FK_NY":
                        //attr.Delete();
                        ////if (attr.UIContralType != UIContralType.DDL)
                        ////{
                        //attr.UIBindKey = "BP.Pub.NYs";
                        //attr.UIContralType = UIContralType.DDL;
                        //attr.LGType = FieldTypeS.FK;
                        //attr.UIVisible = true;
                        ////   if (gfs.Contains(attr.GroupID) == false)
                        //attr.GroupID = gfBase.OID; // gfs[0].GetValIntByKey("OID");
                        //attr.Update();
                        break;

                    case "Rec":
                        attr.UIBindKey     = "BP.Port.Emps";
                        attr.UIContralType = UIContralType.DDL;
                        attr.LGType        = FieldTypeS.FK;
                        attr.UIVisible     = true;
                        attr.Name          = "最后处理人";
                        attr.GroupID       = gfBase.OID;
                        attr.Update();
                        break;

                    default:
                        break;
                    }
                }

                // 生成流程基本信息属性。
                GroupField gfFlow = new GroupField();
                gfFlow.EnName = md.No;
                gfFlow.Idx    = 0;
                gfFlow.Lab    = "流程信息";
                gfFlow.Insert();


                MapAttr attrFlow = new BP.Sys.MapAttr();

                attrFlow               = new BP.Sys.MapAttr();
                attrFlow.FK_MapData    = md.No;
                attrFlow.HisEditType   = EditType.UnDel;
                attrFlow.KeyOfEn       = "Title";
                attrFlow.Name          = "标题";
                attrFlow.MyDataType    = BP.DA.DataType.AppString;
                attrFlow.UIContralType = UIContralType.TB;
                attrFlow.LGType        = FieldTypeS.Normal;
                attrFlow.UIVisible     = true;
                attrFlow.UIIsEnable    = true;
                attrFlow.UIIsLine      = true;
                attrFlow.MinLen        = 0;
                attrFlow.MaxLen        = 1000;
                attrFlow.IDX           = -100;
                attrFlow.GroupID       = gfFlow.OID;
                attrFlow.Insert();


                attrFlow.FK_MapData    = md.No;
                attrFlow.HisEditType   = EditType.UnDel;
                attrFlow.KeyOfEn       = "FlowStarter";
                attrFlow.Name          = "发起人"; //"发起人";
                attrFlow.MyDataType    = BP.DA.DataType.AppString;
                attrFlow.UIContralType = UIContralType.DDL;
                attrFlow.UIBindKey     = "BP.Port.Emps";
                attrFlow.LGType        = FieldTypeS.FK;
                attrFlow.UIVisible     = true;
                attrFlow.UIIsEnable    = false;
                attrFlow.UIIsLine      = false;
                attrFlow.MaxLen        = 20;
                attrFlow.MinLen        = 0;
                attrFlow.Insert();

                attrFlow               = new BP.Sys.MapAttr();
                attrFlow.FK_MapData    = md.No;
                attrFlow.HisEditType   = EditType.UnDel;
                attrFlow.KeyOfEn       = "FlowStarterDept";
                attrFlow.Name          = "发起人部门";
                attrFlow.MyDataType    = BP.DA.DataType.AppString;
                attrFlow.UIContralType = UIContralType.DDL;
                attrFlow.UIBindKey     = "BP.Port.Depts";
                attrFlow.LGType        = FieldTypeS.FK;
                attrFlow.UIVisible     = true;
                attrFlow.UIIsEnable    = false;
                attrFlow.MaxLen        = 20;
                attrFlow.MinLen        = 0;
                attrFlow.Insert();



                attrFlow               = new BP.Sys.MapAttr();
                attrFlow.FK_MapData    = md.No;
                attrFlow.HisEditType   = EditType.UnDel;
                attrFlow.KeyOfEn       = "FlowEmps";
                attrFlow.Name          = "参与人"; //
                attrFlow.MyDataType    = BP.DA.DataType.AppString;
                attrFlow.UIContralType = UIContralType.TB;
                attrFlow.LGType        = FieldTypeS.Normal;
                attrFlow.UIVisible     = true;
                attrFlow.UIIsEnable    = true;
                attrFlow.UIIsLine      = false;
                attrFlow.MinLen        = 0;
                attrFlow.MaxLen        = 1000;
                attrFlow.IDX           = -100;
                attrFlow.GroupID       = gfFlow.OID;
                attrFlow.Insert();


                attrFlow               = new BP.Sys.MapAttr();
                attrFlow.FK_MapData    = md.No;
                attrFlow.HisEditType   = EditType.UnDel;
                attrFlow.KeyOfEn       = "FlowStartRDT";
                attrFlow.Name          = "发起时间"; //
                attrFlow.MyDataType    = BP.DA.DataType.AppDateTime;
                attrFlow.UIContralType = UIContralType.TB;
                attrFlow.LGType        = FieldTypeS.Normal;
                attrFlow.UIVisible     = true;
                attrFlow.UIIsEnable    = true;
                attrFlow.UIIsLine      = false;
                attrFlow.MinLen        = 0;
                attrFlow.MaxLen        = 1000;
                attrFlow.IDX           = -100;
                attrFlow.GroupID       = gfFlow.OID;
                attrFlow.Insert();

                attrFlow               = new BP.Sys.MapAttr();
                attrFlow.FK_MapData    = md.No;
                attrFlow.HisEditType   = EditType.UnDel;
                attrFlow.KeyOfEn       = "FlowNY";
                attrFlow.Name          = "隶属年月";
                attrFlow.MyDataType    = BP.DA.DataType.AppString;
                attrFlow.UIContralType = UIContralType.DDL;
                attrFlow.UIBindKey     = "BP.Pub.NYs";
                attrFlow.LGType        = FieldTypeS.FK;
                attrFlow.UIVisible     = true;
                attrFlow.UIIsEnable    = false;
                attrFlow.MaxLen        = 20;
                attrFlow.MinLen        = 0;
                attrFlow.Insert();


                attrFlow               = new BP.Sys.MapAttr();
                attrFlow.FK_MapData    = md.No;
                attrFlow.HisEditType   = EditType.UnDel;
                attrFlow.KeyOfEn       = "MyNum";
                attrFlow.Name          = "条"; //
                attrFlow.MyDataType    = BP.DA.DataType.AppInt;
                attrFlow.DefVal        = "1";
                attrFlow.UIContralType = UIContralType.TB;
                attrFlow.LGType        = FieldTypeS.Normal;
                attrFlow.UIVisible     = false;
                attrFlow.UIIsEnable    = false;
                attrFlow.UIIsLine      = false;
                attrFlow.IDX           = -101;
                attrFlow.GroupID       = gfFlow.OID;
                if (attrFlow.IsExits == false)
                {
                    attrFlow.Insert();
                }

                // 清除缓存的map.
                Cash.Map_Cash.Remove(md.No);
                //检查主表的正确性。
                GEEntity ge = new GEEntity(md.No);
                ge.CheckPhysicsTable();
                #endregion   制成 主表.让其可以查询。
            }
        }
        this.WinClose();
    }
        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);
        }