private void detach_FilledSections(FilledSection entity)
		{
			this.SendPropertyChanging();
			entity.BlankSection = null;
		}
        public void create_filled_section()
        {
            if (this.FilledSections.Count == 0)
            {
                Document document = DocumentorDBM.Documents.Where(a => a.id == this.document_id).First();
                Assignment assignment = DocumentorDBM.Assignments.Where(a => a.id == this.assignment_id).First();
                CaseStudy case_study = assignment.CaseStudy;
                List<Page> pages = document.Pages.ToList();
                List<BlankSection> blank_sections = new List<BlankSection>();
                foreach (Page page in pages)
                {
                    blank_sections.AddRange(page.BlankSections);
                }
                foreach (BlankSection blank_section in blank_sections)
                {

                    FilledSection filled_section = new FilledSection();
                    filled_section.docucheck_id = this.id;
                    filled_section.blank_section_id = blank_section.id;
                    Component component = blank_section.Component;

                    //if the document is a reference document,everything should be correct

                    ReferenceSet reference_set;
                    if (DocumentorDBM.DocketDocuments.Where(a => a.docket_id == this.docket_id && a.document_id == this.document_id).First().reference_document ?? false)
                    {
                        reference_set = this.ReferenceSet;
                        filled_section.has_no_error = true;
                    }
                    else
                    {
                        Random r_id = new Random();
                        int new_no = r_id.Next(100);
                        //decide what reference set to use
                        if (new_no > 50)
                        {
                            reference_set = this.ReferenceSet;
                            filled_section.has_no_error = true;
                        }
                        else
                        {
                            reference_set = this.Docket.SuperSet.ReferenceSets.Where(a => a.id != this.reference_set_id).ToArray()[r_id.Next(this.Docket.SuperSet.ReferenceSets.ToList().Count - 1)];
                            filled_section.has_no_error = false;
                        }
                        if (reference_set.correct!=true && reference_set.id!=this.reference_set_id)
                        {

                            reference_set = this.Docket.SuperSet.ReferenceSets.Where(a => a.id != this.reference_set_id).ToList()[r_id.Next(this.Docket.SuperSet.ReferenceSets.Count - 1)];
                            filled_section.has_no_error = false;
                        }

                    }
                    List<Example> examples = DocumentorDBM.Examples.Where(a => a.reference_set_id == reference_set.id && a.component_id == component.id).ToList();
                    Example example;
                    if (examples.Count==0)
                    {
                        example = DocumentorDBM.Examples.Where(a => a.reference_set_id == this.Docket.SuperSet.ReferenceSets.Where(b => b.name == "blank_set").First().id && a.component_id == component.id).First();
                        filled_section.has_no_error = false;
                    }
                    else
                    {
                        example = examples.First();
                    }
                    filled_section.example_id = example.id;
                    DocumentorDBM.FilledSections.InsertOnSubmit(filled_section);
                    DocumentorDBM.SubmitChanges();
                }
            }
        }
 partial void DeleteFilledSection(FilledSection instance);
 partial void UpdateFilledSection(FilledSection instance);
 partial void InsertFilledSection(FilledSection instance);
		private void detach_FilledSections(FilledSection entity)
		{
			this.SendPropertyChanging();
			entity.Docucheck = null;
		}
		private void attach_FilledSections(FilledSection entity)
		{
			this.SendPropertyChanging();
			entity.Example = this;
		}