Пример #1
0
        public MemberFormVM(StudyUnitVM studyUnit) : base(studyUnit)
        {
            members       = new ObservableCollection <MemberVM>();
            organizations = new ObservableCollection <OrganizationVM>();

            //Create the list of OrganizationVM(showed at the bottom of the window and used by Organization of Members combo)
            int i = 1;

            foreach (Organization organizationModel in studyUnit.OrganizationModels)
            {
                OrganizationVM organization = new OrganizationVM(organizationModel);
                InitExistOrganization(organization, i++);
                organizations.Add(organization);
            }

            //Create MemberVM list
            i = 1;
            foreach (Member memberModel in studyUnit.MemberModels)
            {
                OrganizationVM organization = OrganizationVM.Find(organizations, memberModel.OrganizationId);
                MemberVM       member       = new MemberVM(memberModel, organization.OrganizationName);
                InitExistMember(member, i++);
                members.Add(member);
            }
            memberSyncher       = new ModelSyncher <MemberVM, Member>(this, members, studyUnit.MemberModels);
            organizationSyncher = new ModelSyncher <OrganizationVM, Organization>(this, organizations, studyUnit.OrganizationModels);
        }
Пример #2
0
        public MemberFormVM(StudyUnitVM studyUnit)
            : base(studyUnit)
        {
            members = new ObservableCollection<MemberVM>();
            organizations = new ObservableCollection<OrganizationVM>();

            //OrganizationVMのリストを生成する(画面下部に表示される他、メンバーの組織選択コンボで使われる)
            int i = 1;
            foreach (Organization organizationModel in studyUnit.OrganizationModels)
            {
                OrganizationVM organization = new OrganizationVM(organizationModel);
                InitExistOrganization(organization, i++);
                organizations.Add(organization);
            }

            //MemberVMのリストを生成する
            i = 1;
            foreach (Member memberModel in studyUnit.MemberModels)
            {
                OrganizationVM organization = OrganizationVM.Find(organizations, memberModel.OrganizationId);
                MemberVM member = new MemberVM(memberModel, organization.OrganizationName);
                InitExistMember(member, i++);
                members.Add(member);
            }
            memberSyncher = new ModelSyncher<MemberVM, Member>(this, members, studyUnit.MemberModels);
            organizationSyncher = new ModelSyncher<OrganizationVM, Organization>(this, organizations, studyUnit.OrganizationModels);
        }
Пример #3
0
        public void member_ItemEndEdit(IEditableObject x)
        {
            ///// Process after ending of editing MemberVM
            MemberVM editedMember = (MemberVM)x;

            if (string.IsNullOrEmpty(editedMember.OrganizationName))
            {
                return;
            }
            OrganizationVM existOrganization = FindOrganizationByName(editedMember.OrganizationName);

            if (existOrganization == null)
            {
                ////Create and add to VM if there is no match to existing organization.
                existOrganization = new OrganizationVM(editedMember.OrganizationName);
                InitNewOrganization(existOrganization);
                organizations.Add(existOrganization);
            }
            editedMember.OrganizationId = existOrganization.Id;

            //The screen also displays to follow because there may be members that refer to the same organization
            //List<MemberVM> relatedMembers = this.GetSameOrganizationMemberVMs(editedMember);
            //foreach (MemberVM member in relatedMembers)
            //{
            //    member.NotifyPropertyChanged("OrganizationName");
            //}
        }
Пример #4
0
        public void organization_ItemEndEdit(IEditableObject x)
        {
            OrganizationVM  organization   = (OrganizationVM)x;
            List <MemberVM> relatedMembers = MemberVM.FindByOrganizationId(Members, organization.Id);

            foreach (MemberVM member in relatedMembers)
            {
                member.OrganizationName = organization.OrganizationName;
            }
        }
Пример #5
0
        public OrganizationVM AppendOrganization(string memberId, string organizationName)
        {
            if (string.IsNullOrEmpty(organizationName))
            {
                return(null);
            }

            OrganizationVM existOrganization = OrganizationVM.FindByName(organizations, organizationName);

            if (existOrganization != null)
            {
                return(existOrganization);
            }

            OrganizationVM organization = new OrganizationVM();

            organizations.Add(organization);
            organization.OrganizationName = organizationName;
            return(organization);
        }
Пример #6
0
 private void InitOrganization(OrganizationVM organization, int no)
 {
     organization.Parent = this;
     organization.No = no;
 }
Пример #7
0
 private void InitNewOrganization(OrganizationVM organization)
 {
     InitOrganization(organization, NextOrganizationNo);
 }
Пример #8
0
 private void InitExistOrganization(OrganizationVM organization, int no)
 {
     InitOrganization(organization, no);
 }
Пример #9
0
        public void member_ItemEndEdit(IEditableObject x)
        {
            ///// MemberVMの編集終了後の処理
            MemberVM editedMember = (MemberVM)x;
            if (string.IsNullOrEmpty(editedMember.OrganizationName))
            {
                return;
            }
            OrganizationVM existOrganization = FindOrganizationByName(editedMember.OrganizationName);
            if (existOrganization == null)
            {
                ////既存の組織に一致するものがない場合は新しく作りVMに追加しておく。
                existOrganization = new OrganizationVM(editedMember.OrganizationName);
                InitNewOrganization(existOrganization);
                organizations.Add(existOrganization);
            }
            editedMember.OrganizationId = existOrganization.Id;

            //同じ組織を参照しているメンバーがあるかもしれないのでその画面表示も追随させる
            //List<MemberVM> relatedMembers = this.GetSameOrganizationMemberVMs(editedMember);
            //foreach (MemberVM member in relatedMembers)
            //{
            //    member.NotifyPropertyChanged("OrganizationName");
            //}
        }
Пример #10
0
 private OrganizationVM FindOrganizationByName(string name)
 {
     return(OrganizationVM.FindByName(organizations, name));
 }
Пример #11
0
 private void InitNewOrganization(OrganizationVM organization)
 {
     InitOrganization(organization, NextOrganizationNo);
 }
Пример #12
0
 private void InitExistOrganization(OrganizationVM organization, int no)
 {
     InitOrganization(organization, no);
 }
Пример #13
0
 private void InitOrganization(OrganizationVM organization, int no)
 {
     organization.Parent        = this;
     organization.No            = no;
     organization.EndEditAction = new Action <IEditableObject>(organization_ItemEndEdit);
 }