private void btnAddDisability_Click(object sender, EventArgs e)
        {
            using (var Dbconnection = new MCDEntities())
            {
                using (System.Data.Entity.DbContextTransaction dbTran = Dbconnection.Database.BeginTransaction())
                {
                    try
                    {
                        //CRUD Operations
                        CurrentStudentDisablity = new StudentDisability()
                        {
                            DisabilityID           = this.DisablityID,
                            StudentID              = this.StudentID,
                            StudentDisabilityNotes = this.txtStudentDisablityNotes.Text
                        };
                        Dbconnection.StudentDisabilities.Add(CurrentStudentDisablity);


                        ////saves all above operations within one transaction
                        Dbconnection.SaveChanges();

                        //commit transaction
                        dbTran.Commit();
                        Dbconnection.Entry(CurrentStudentDisablity).Reference(a => a.LookupDisability).Load();
                    }
                    catch (Exception ex)
                    {
                        if (ex is DbEntityValidationException)
                        {
                            foreach (DbEntityValidationResult entityErr in ((DbEntityValidationException)ex).EntityValidationErrors)
                            {
                                foreach (DbValidationError error in entityErr.ValidationErrors)
                                {
                                    MessageBox.Show(error.ErrorMessage, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        //Rollback transaction if exception occurs
                        dbTran.Rollback();
                    }
                    finally{
                        this.Close();
                    }
                }
            };
        }
        private void perpoulateDisablities()
        {
            flowLayoutPanelDisablitiyCategory.Controls.Clear();
            List <LookupDisability> LDL = new List <LookupDisability>();

            using (var Dbconnection = new MCDEntities())
            {
                if (this.DisablityID == 0)
                {
                    LDL = (from a in Dbconnection.LookupDisabilities
                           select a).Except((from b in Dbconnection.StudentDisabilities
                                             where b.StudentID == this.StudentID
                                             select b.LookupDisability)).ToList <LookupDisability>();
                    txtStudentDisablityNotes.Clear();
                }
                else
                {
                    LDL =
                        (from a in Dbconnection.LookupDisabilities
                         select a).ToList <LookupDisability>();
                    if (CurrentStudentDisablity == null)
                    {
                        CurrentStudentDisablity = Dbconnection.StudentDisabilities
                                                  .Where(a => a.DisabilityID == this.DisablityID && a.StudentID == this.StudentID)
                                                  .Include(a => a.LookupDisability)
                                                  .FirstOrDefault <StudentDisability>();
                    }
                    txtStudentDisablityNotes.Text = CurrentStudentDisablity.StudentDisabilityNotes;
                }

                Boolean isFirstItem = true;
                foreach (LookupDisability LD in LDL)
                {
                    RadioButton Rad = new RadioButton();


                    if (DisablityID == 0)
                    {
                        if (isFirstItem)
                        {
                            Rad.Checked = true;
                            isFirstItem = false;
                        }
                        Rad.Click  += Rad_Click;
                        DisablityID = LD.DisabilityID;

                        this.btnAddDisability.Visible          = true;
                        this.btnUpdateStudentDisablity.Visible = false;
                    }
                    else
                    {
                        if (DisablityID == LD.DisabilityID)
                        {
                            Rad.Click  += Rad_Click;
                            Rad.Checked = true;
                            Rad.Tag     = LD.DisabilityID;
                            Rad.Text    = LD.Disability;
                            flowLayoutPanelDisablitiyCategory.Controls.Add(Rad);
                            DisablityID = LD.DisabilityID;
                            this.btnAddDisability.Visible          = false;
                            this.btnUpdateStudentDisablity.Visible = true;
                        }
                    }
                }
                foreach (Control Con in flowLayoutPanelDisablitiyCategory.Controls)
                {
                    if (Con is RadioButton)
                    {
                        if (((RadioButton)Con).Checked)
                        {
                            this.DisablityID = Convert.ToInt32(((RadioButton)Con).Tag);
                        }
                    }
                }
            };
        }