private void ChangeLocationControls() { Location location = new Location(QuestionTitle.Location.X, QuestionTitle.Location.Y + QuestionTitle.Size.Height); location.AddY(spaceSize); AnsverControls.ForEach(z => { z.Location = location.GetNextPoint(); location.AddControlY(z, 1); }); location = new Location(0, location.GetNextPoint().Y); buttonAdd.Location = location.GetNextPoint(); location.AddControlX(buttonAdd, 1); buttonDel.Location = location.GetNextPoint(); location.AddControlX(buttonDel, 1); panelQuestionMark.Location = location.GetNextPoint(); location.AddControlY(panelQuestionMark, 1); Height = location.GetNextPoint().Y; }
public void SaveData() { List <Answer> saveList = new List <Answer>(); List <Answer> updateList = new List <Answer>(); List <Answer> deleteList = new List <Answer>(); //Разделение вопросов на группы AnsverControls.ForEach(o => { var z = o as EditAnsverContol; if (z.IsChanged) { bool isUpdate = false; Ansvers.ForEach(p => { if (z.Ansver.Equals(p)) { updateList.Add(z.Ansver); isUpdate = true; } }); if (!isUpdate) { saveList.Add(z.Ansver); } } }); deleteList = GetDeleteList(); //Сохранение, обновление, удаление Save(saveList); Update(updateList); Delete(deleteList); }
private List <Answer> GetDeleteList() { List <Answer> deleteList; List <Answer> answersInControls = new List <Answer>(); AnsverControls.ForEach(o => { var z = o as EditAnsverContol; answersInControls.Add(z.Ansver); }); deleteList = Ansvers.AsQueryable().Except(answersInControls).ToList(); return(deleteList); }