private void btnSaveWeeklyControl_Click(object sender, EventArgs e) { WeeklyControl weeklyControl = new WeeklyControl(); weeklyControl.WeekName = txtWeeklyControlName.Text; for (int i = 0; i < checkedListBox1.Items.Count; i++) { CheckState checkState = checkedListBox1.GetItemCheckState(i); var student = checkedListBox1.Items[i]; var subItem = new WeeklyControlSubItem(); subItem.Student = (Student)student; subItem.WeeklyControl = weeklyControl; if (checkState == CheckState.Checked) { subItem.IsControl = true; } else { subItem.IsControl = false; } weeklySubItemRepository.AddWeeklyControlSubItem(subItem); } MessageBox.Show("Kaydedildi"); }
private void listBoxWeek_MouseDoubleClick(object sender, MouseEventArgs e) { selectedWeek = (WeeklyControl)listBoxWeek.SelectedItem; var addWeeklycontrolsubitem = new AddWeeklyControlSubItem(); addWeeklycontrolsubitem.OpenWithWeeklyControl(selectedWeek); }
private void btnSaveWeek_Click(object sender, EventArgs e) { var weekName = txtWeekName.Text; if (string.IsNullOrWhiteSpace(weekName)) { MessageBox.Show("Hafta Adını boş bırakmayınız"); } else { if (!isUpdate) { control = new WeeklyControl(); control.WeekName = weekName; control.Lessson = lesson; weeklyControlRepository.AddWeeklyControl(control); MessageBox.Show("Kaydedildi"); } else { if (control != null) { control.WeekName = weekName; weeklyControlRepository.UpdateWeeklyControl(control); MessageBox.Show("Güncellendi"); } } } }
public void OpenInEdit(WeeklyControl weeklyControl) { this.control = weeklyControl; this.isUpdate = true; txtWeekName.Text = control.WeekName; this.btnSaveWeek.Text = "Güncelle"; this.ShowDialog(); }
public void UpdateWeeklyControl(WeeklyControl weeklyControl) { var setWeek = GetById(weeklyControl.Id); if (setWeek != null) { setWeek.WeekName = weeklyControl.WeekName; context.SaveChanges(); } }
public void OpenWithWeeklyControl(WeeklyControl control) { }
public void AddWeeklyControl(WeeklyControl weeklyControl) { context.WeeklyControls.Add(weeklyControl); context.Entry(weeklyControl.Lessson).State = EntityState.Unchanged; context.SaveChanges(); }