Esempio n. 1
0
        public void DeleteStudentRecord(Models.StudentInformation_Result studentcontactperson)
        {
            //List<StudentInformation_Result> students = new List<StudentInformation_Result>();
            //using (SqlConnection myCon = new SqlConnection("Data Source=DESKTOP-50L3KE8\\SQLEXPRESS;Initial Catalog=DB_Class;Integrated Security=True"))
            //{

            //    SqlCommand cmd = new SqlCommand("Delete FROM Student where StudentID = " + studentcontactperson.StudentID);

            //        cmd.Connection = myCon;
            //        myCon.Open();
            //        cmd.ExecuteNonQuery();
            //        myCon.Close();


            //}

            DB_ClassEntities db_dlt = new DB_ClassEntities();
            var students            = db_dlt.Students.FirstOrDefault(s => s.StudentID == studentcontactperson.StudentID);

            if (students != null)
            {
                db_dlt.Students.Remove(students);
                db_dlt.SaveChanges();
            }
        }
Esempio n. 2
0
        public void DeleteParentRecord(int id)
        {
            DB_ClassEntities db_dlt = new DB_ClassEntities();
            var students            = db_dlt.Contact_Person.FirstOrDefault(s => s.Contact_PersonID == id);

            if (students != null)
            {
                db_dlt.Contact_Person.Remove(students);
                db_dlt.SaveChanges();
            }
        }