Пример #1
0
        public void LoadFamilyMembers()
        {
            if (familiesDataGridView.Rows.Count <= 0)
            {
                return;
            }
            if (familiesDataGridView.SelectedRows.Count <= 0)
            {
                return;
            }
            FamiliesController fc      = new FamiliesController();
            List <Member>      members = fc.Show((int)familiesDataGridView.SelectedRows[0].Cells["familyId"].Value).Members();

            //setup
            membersDataGridView.Rows.Clear();
            membersDataGridView.Columns.Clear();
            membersDataGridView.Refresh();
            //columns

            membersDataGridView.Columns.Add("memberId", "ID");
            membersDataGridView.Columns.Add("name", "Name");

            membersDataGridView.Columns["memberId"].Visible = false;
            //rows
            if (members.Count > 0)
            {
                foreach (Member member in members)
                {
                    membersDataGridView.Rows.Add(
                        member.id,
                        member.FullName());
                }
            }
        }
Пример #2
0
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            if (familiesDataGridView.Rows.Count <= 0)
            {
                return;
            }
            if (familiesDataGridView.SelectedRows.Count <= 0)
            {
                return;
            }

            if (membersDataGridView.Rows.Count <= 0)
            {
                return;
            }
            if (membersDataGridView.SelectedRows.Count <= 0)
            {
                return;
            }


            FamiliesController fc     = new FamiliesController();
            MembersController  mc     = new MembersController();
            Family             family = fc.Show((int)familiesDataGridView.SelectedRows[0].Cells["familyId"].Value);
            Member             member = mc.Show((int)membersDataGridView.SelectedRows[0].Cells["memberId"].Value);

            if (MessageBox.Show($"Delete member:{member.firstName} from family:{family.familyName}?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;
            }
            family.DeleteMember(member);
            LoadFamilyMembers();
        }
Пример #3
0
        private void BtnAddMember_Click(object sender, EventArgs e)
        {
            FamiliesController fc = new FamiliesController();

            if (familiesDataGridView.Rows.Count <= 0)
            {
                return;
            }
            if (familiesDataGridView.SelectedRows.Count <= 0)
            {
                return;
            }
            AddFamilyMemberFrm addFamilyMember = new AddFamilyMemberFrm(fc.Show((int)familiesDataGridView.SelectedRows[0].Cells["familyId"].Value));

            addFamilyMember.FormClosing += new FormClosingEventHandler(this.FamilyMembersUpdated);

            addFamilyMember.ShowDialog();
        }
        public Family ShowMembersFamily(Member member)
        {
            FamiliesController fc     = new FamiliesController();
            Family             family = null;

            if (member == null)
            {
                return(null);
            }
            DataTable dt = FinanceDbManager.BasicQuery(FinanceDbManager.QueryMode.SELECT_ALL, tableName, null,
                                                       new QueryBuilder().Where("memberId").EqualsTo(member.id)
                                                       );

            if (dt.Rows.Count > 0)
            {
                family = fc.Show((int)dt.Rows[0]["familyId"]);
            }

            return(family);
        }