private void MainGrd_SelectionChanged(object sender, EventArgs e) { IsUserEdit = false; try { if (MainGrdBind.IsOnlyOneSelect) // && MainGrdBind.Current != null) { DisplayEty(MainGrdBind.Current as BaseEntity); var rlns = GrpMbrBF.GetRlns(MainGrdBind.Current as BaseEntity); AttachGrdBind.Binding(rlns == null ? new List <BaseEntity>() : new List <BaseEntity>(rlns)); } else { DisplayEty(null); AttachGrdBind.Binding(new List <BaseEntity>()); } } finally { IsUserEdit = true; } SetControlEnabled(); }
private void tsAttachAdd_Click(object sender, EventArgs e) { //数据准备 BaseEntity MainEty = MainGrdBind.Current as BaseEntity; IList <BaseEntity> OldRlns = new List <BaseEntity>(); ExIList.Append <BaseEntity>(GrpMbrBF.GetRlns(MainEty), OldRlns); IList <BaseEntity> NewRlns = new List <BaseEntity>(); ExIList.Append <BaseEntity>(OldRlns, NewRlns); //交互:用户选择 if (!this.mainDataIsGroup) { NewRlns = SelectIF.GroupSelectMulti(GrpMbrBF, NewRlns); if (NewRlns == null) { return; } } else { NewRlns = SelectIF.MemberSelectMulti(GrpMbrBF, NewRlns); if (NewRlns == null) { return; } } //删除/增加确认 IList <VcEffect> Effects = new List <VcEffect>(); foreach (BaseEntity ety in OldRlns) { if (!NewRlns.Contains(ety)) { ExIList.Append <VcEffect>(this.grpMbrBF.EffectOfReleaseRln(MainEty, ety), Effects); } } foreach (BaseEntity ety in NewRlns) { if (!OldRlns.Contains(ety)) { ExIList.Append <VcEffect>(this.grpMbrBF.EffectOfCreateRln(MainEty, ety), Effects); } } if (!ConfirmEffectFm.Confirm(Effects)) { return; } //删除/增加 foreach (BaseEntity ety in OldRlns) { if (!NewRlns.Contains(ety)) { GrpMbrBF.ReleaseRln(MainEty, ety); } } foreach (BaseEntity ety in NewRlns) { if (!OldRlns.Contains(ety)) { GrpMbrBF.CreateRln(MainEty, ety); } } //界面更新 MainGrd_SelectionChanged(sender, e); }