예제 #1
0
        public void AddParents()
        {
            AcceptTempData();

            GDMFamilyRecord family = fBase.Context.SelectFamily(fPerson);

            if (family != null && family.IndexOfChild(fPerson) < 0)
            {
                fLocalUndoman.DoOrdinaryOperation(OperationType.otIndividualParentsAttach, fPerson, family);
            }
            UpdateControls();
        }
예제 #2
0
        public override void Modify(object sender, ModifyEventArgs eArgs)
        {
            var iRec = fDataOwner as GDMIndividualRecord;

            if (fBaseWin == null || fSheetList == null || iRec == null)
            {
                return;
            }

            GDMChildToFamilyLink cfLink = eArgs.ItemData as GDMChildToFamilyLink;

            bool result = false;

            switch (eArgs.Action)
            {
            case RecordAction.raAdd:
                GDMFamilyRecord family = fBaseWin.Context.SelectFamily(iRec);
                if (family != null && family.IndexOfChild(iRec) < 0)
                {
                    result = fUndoman.DoOrdinaryOperation(OperationType.otIndividualParentsAttach, iRec, family);
                }
                break;

            case RecordAction.raEdit:
                if (cfLink != null)
                {
                    using (var dlg = AppHost.ResolveDialog <IParentsEditDlg>(fBaseWin)) {
                        dlg.Person = iRec;
                        dlg.Link   = cfLink;
                        result     = AppHost.Instance.ShowModalX(dlg, false);
                    }
                }
                break;

            case RecordAction.raDelete:
                if (AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_DetachParentsQuery)))
                {
                    var famRec = fBaseContext.Tree.GetPtrValue(cfLink);
                    result = fUndoman.DoOrdinaryOperation(OperationType.otIndividualParentsDetach, iRec, famRec);
                }
                break;

            case RecordAction.raMoveUp:
            case RecordAction.raMoveDown:
                int idx = iRec.ChildToFamilyLinks.IndexOf(cfLink);
                switch (eArgs.Action)
                {
                case RecordAction.raMoveUp:
                    iRec.ChildToFamilyLinks.Exchange(idx - 1, idx);
                    break;

                case RecordAction.raMoveDown:
                    iRec.ChildToFamilyLinks.Exchange(idx, idx + 1);
                    break;
                }
                result = true;
                break;
            }

            if (result)
            {
                fBaseWin.Context.Modified = true;
                eArgs.IsChanged           = true;
            }
        }