Example #1
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            frmAddModify secondFrm = new frmAddModify();

            secondFrm.isModify = true;
            int rowNum  = Convert.ToInt32(membershipDataGridView.CurrentCell.RowIndex);
            int membNum = Convert.ToInt32(membershipDataGridView["dataGridViewTextBoxColumn1", rowNum].Value);

            using (MembershipDataContext dbContext = new MembershipDataContext())
            {
                secondFrm.currentMember = (from m in dbContext.Memberships
                                           where m.MemberID == membNum
                                           select m).Single();
            }

            DialogResult result = secondFrm.ShowDialog();

            using (MembershipDataContext dbContext = new MembershipDataContext())
            {
                if (result == DialogResult.OK)
                {
                    membershipDataGridView.DataSource = dbContext.Memberships;
                }
            }
        }
Example #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmAddModify secondFrm = new frmAddModify();

            DialogResult result = secondFrm.ShowDialog();

            using (MembershipDataContext dbContext = new MembershipDataContext())
            {
                if (result == DialogResult.OK)
                {
                    membershipDataGridView.DataSource = dbContext.Memberships;
                }
            }
        }