public void BindDtl() { BP.Sys.MapDtls dtls = new BP.Sys.MapDtls(); dtls.Retrieve(MapDtlAttr.FK_MapData, this.FK_MapData); this.Pub2.AddTable("width='100%'"); this.Pub2.AddTR(); this.Pub2.AddTDTitle("Idx"); this.Pub2.AddTDTitle("编号"); this.Pub2.AddTDTitle("名称"); this.Pub2.AddTDTitle("原始属性"); this.Pub2.AddTDTitle("编辑"); this.Pub2.AddTDTitle("删除"); this.Pub2.AddTREnd(); int idx = 0; foreach (BP.Sys.MapDtl item in dtls) { if (item.FK_Node != 0) { continue; } idx++; this.Pub2.AddTR(); this.Pub2.AddTDIdx(idx); this.Pub2.AddTD(item.No); this.Pub2.AddTD(item.Name); this.Pub2.AddTD("<a href=\"javascript:EditDtlYuanShi('" + this.FK_MapData + "','" + item.No + "')\">原始属性</a>"); this.Pub2.AddTD("<a href=\"javascript:EditDtl('" + this.FK_Node + "','" + this.FK_MapData + "','" + item.No + "')\">编辑</a>"); MapDtl en = new MapDtl(); en.No = item.No + "_" + this.FK_Node; if (en.RetrieveFromDBSources() == 0) { this.Pub2.AddTD(); } else { this.Pub2.AddTD("<a href=\"javascript:DeleteDtl('" + this.FK_Node + "','" + this.FK_MapData + "','" + item.No + "')\">删除</a>"); } this.Pub2.AddTREnd(); } this.Pub2.AddTableEnd(); }
protected void Page_Load(object sender, EventArgs e) { BP.Sys.MapDtls ens = new BP.Sys.MapDtls(); ens.Retrieve(MapDtlAttr.FK_MapData, this.FK_MapData); this.Pub1.AddTable("width='100%'"); this.Pub1.AddCaptionLeft("表单明细表权限."); this.Pub1.AddTR(); this.Pub1.AddTDTitle("Idx"); this.Pub1.AddTDTitle("编号"); this.Pub1.AddTDTitle("名称"); this.Pub1.AddTDTitle("编辑"); this.Pub1.AddTDTitle("删除"); this.Pub1.AddTREnd(); int idx = 0; foreach (BP.Sys.MapDtl item in ens) { if (item.FK_Node != 0) { continue; } idx++; this.Pub1.AddTR(); this.Pub1.AddTDIdx(idx); this.Pub1.AddTD(item.No); this.Pub1.AddTD(item.Name); this.Pub1.AddTD("<a href=\"javascript:Edit('" + this.FK_Node + "','" + this.FK_MapData + "','" + item.No + "')\">编辑</a>"); MapDtl en = new MapDtl(); if (en.RetrieveFromDBSources() == 0) { this.Pub1.AddTD(); } else { this.Pub1.AddTD("<a href=\"javascript:Delete('" + this.FK_Node + "','" + this.FK_MapData + "','" + item.No + "')\">删除</a>"); } this.Pub1.AddTREnd(); } this.Pub1.AddTableEnd(); }
/// <summary> /// 把当前实体的数据copy到指定的主键数据表里. /// </summary> /// <param name="oid">指定的主键</param> public void CopyToOID(string oid) { //实例化历史数据表单entity. string oidOID = this.MyPK; this.MyPK = oid; this.Save(); //复制从表数据. MapDtls dtls = new MapDtls(this.FK_MapData); foreach (MapDtl dtl in dtls) { //删除旧的数据. BP.DA.DBAccess.RunSQL("DELETE FROM " + dtl.PTable + " WHERE RefPK=" + this.MyPK); GEDtls ensDtl = new GEDtls(dtl.No); ensDtl.Retrieve(GEDtlAttr.RefPK, oidOID); foreach (GEDtl enDtl in ensDtl) { enDtl.RefPK = this.MyPK.ToString(); enDtl.InsertAsNew(); } } //复制附件数据. FrmAttachments aths = new FrmAttachments(this.FK_MapData); foreach (FrmAttachment ath in aths) { //删除可能存在的新oid数据。 DBAccess.RunSQL("DELETE FROM Sys_FrmAttachmentDB WHERE FK_MapData='" + this.FK_MapData + "' AND RefPKVal='" + this.MyPK + "'"); //找出旧数据. FrmAttachmentDBs athDBs = new FrmAttachmentDBs(this.FK_MapData, oidOID.ToString()); foreach (FrmAttachmentDB athDB in athDBs) { FrmAttachmentDB athDB_N = new FrmAttachmentDB(); athDB_N.Copy(athDB); athDB_N.FK_MapData = this.FK_MapData; athDB_N.RefPKVal = this.MyPK.ToString(); if (athDB_N.HisAttachmentUploadType == AttachmentUploadType.Single) { /*如果是单附件.*/ athDB_N.MyPK = athDB_N.FK_FrmAttachment + "_" + this.MyPK; if (athDB_N.IsExits == true) { continue; /*说明上一个节点或者子线程已经copy过了, 但是还有子线程向合流点传递数据的可能,所以不能用break.*/ } athDB_N.Insert(); } else { athDB_N.MyPK = DBAccess.GenerGUID(); athDB_N.Insert(); } } } }
/// <summary> /// 从另外的一个实体来copy数据. /// </summary> /// <param name="en"></param> public void CopyFromFrm(GEEntityMyPK en) { //先求出来旧的OID. string oldOID = this.MyPK; //复制主表数据. this.Copy(en); this.Save(); this.MyPK = oldOID; //复制从表数据. MapDtls dtls = new MapDtls(this.FK_MapData); //被copy的明细集合. MapDtls dtlsFrom = new MapDtls(en.FK_MapData); if (dtls.Count != dtls.Count) { throw new Exception("@复制的两个表单从表不一致..."); } //序号. int i = 0; foreach (MapDtl dtl in dtls) { //删除旧的数据. BP.DA.DBAccess.RunSQL("DELETE FROM " + dtl.PTable + " WHERE RefPK=" + this.MyPK); //求对应的Idx的,从表配置. MapDtl dtlFrom = dtlsFrom[i] as MapDtl; GEDtls ensDtlFrom = new GEDtls(dtlFrom.No); ensDtlFrom.Retrieve(GEDtlAttr.RefPK, oldOID); //创建一个实体. GEDtl dtlEnBlank = new GEDtl(dtl.No); // 遍历数据,执行copy. foreach (GEDtl enDtlFrom in ensDtlFrom) { dtlEnBlank.Copy(enDtlFrom); dtlEnBlank.RefPK = this.MyPK.ToString(); dtlEnBlank.SaveAsNew(); } i++; } //复制附件数据. FrmAttachments aths = new FrmAttachments(this.FK_MapData); FrmAttachments athsFrom = new FrmAttachments(en.FK_MapData); foreach (FrmAttachment ath in aths) { //删除数据,防止copy重复 DBAccess.RunSQL("DELETE FROM Sys_FrmAttachmentDB WHERE FK_MapData='" + this.FK_MapData + "' AND RefPKVal='" + this.MyPK + "'"); foreach (FrmAttachment athFrom in athsFrom) { if (athFrom.NoOfObj != ath.NoOfObj) { continue; } FrmAttachmentDBs athDBsFrom = new FrmAttachmentDBs(); athDBsFrom.Retrieve(FrmAttachmentDBAttr.FK_FrmAttachment, athFrom.MyPK, FrmAttachmentDBAttr.RefPKVal, en.MyPK.ToString()); foreach (FrmAttachmentDB athDBFrom in athDBsFrom) { athDBFrom.MyPK = BP.DA.DBAccess.GenerGUID(); athDBFrom.FK_FrmAttachment = ath.MyPK; athDBFrom.RefPKVal = this.MyPK.ToString(); athDBFrom.Insert(); } } } }