public static void DeleteDependencies(long id) { var ctx = new DataClassesDataContext(); // medical service group's dependencies are medical service var medicalServices = from m in ctx.MedicalServices where m.MedicalServiceGroupID == id select m; foreach (var medicalService in medicalServices) { MedicalServiceOperations.DeleteDependencies(medicalService.ID); } ctx.MedicalServices.DeleteAllOnSubmit(medicalServices); // submit changes ctx.SubmitChanges(); }
protected void AllMedicalServicesGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { System.Threading.Thread.Sleep(1000); // delete its dependencies first MedicalServiceOperations.DeleteDependencies(long.Parse(e.Keys["ID"].ToString())); //// delete the medical service //var ctx = new DataClassesDataContext(); //var itemToDelete = from ms in ctx.MedicalServices // where ms.ID == long.Parse(e.Keys["ID"].ToString()) // select ms; //ctx.MedicalServices.DeleteAllOnSubmit(itemToDelete); //try //{ // ctx.SubmitChanges(); // ResultAlert.SetResultAlertReturn("Medical Services deleted successfully!", null); //} //catch (Exception ex) //{ // ResultAlert.SetResultAlertReturn("Medical Services deleted successfully!", ex); //} //BindData(); }
protected void MedicalServiceDetailsFormView_ItemDeleting(object sender, FormViewDeleteEventArgs e) { // delete all dependencies of this medical service first MedicalServiceOperations.DeleteDependencies(long.Parse(e.Keys["ID"].ToString())); }