private void ViewAllMembers() { var db = new FamilyMembersManagementEntities(); var members = db.members.ToArray(); var memberView = new MemberView[members.Length]; for (int i = 0; i < members.Length; i++) { memberView[i] = new MemberView(members[i]); } this.dataGridView1.DataSource = memberView; }
public MemberView(member member) { this.id = member.id; this.fullname = member.fullname; this.gender = member.gender == true ? "Male" : "Female"; if (member.birthday != null) { this.birthday = string.Format("{0}/{1}/{2}", member.birthday.Value.Day, member.birthday.Value.Month, member.birthday.Value.Year ); } if (member.status.HasValue) { this.status = member.status.Value == true ? "Living" : "Deceased"; } var db = new FamilyMembersManagementEntities(); if (member.Father_id.HasValue) { var father = db.members.Find(member.Father_id.Value); this.Father_id = father.fullname; } if (member.Mother_id.HasValue) { var mother = db.members.Find(member.Mother_id.Value); this.Mother_id = mother.fullname; } if (member.spouse_id.HasValue) { var spouse = db.members.Find(member.spouse_id.Value); this.spouse_id = spouse.fullname; } this.hometown = member.hometown; this.living = member.living; this.occupation = member.occupation; }