private void AddSpecificYearToolStripMenuItem_Click(object sender, EventArgs e) { var selectYearDialog = new SelectYearForm(); if (selectYearDialog.ShowDialog() == DialogResult.OK) { int selectedYear = selectYearDialog.Year; using (var db = new FeeStatusesDBContext()) { if (db.Member.Any(m => m.MustPay && m.FeeLogs.Any(fl => fl.Year == selectedYear))) { MessageBox.Show( string.Format(WindowMessages.RECORDS_FOR_YEAR_EXIST_MSG, selectedYear), WindowMessages.RECORDS_FOR_YEAR_EXIST_TITLE, MessageBoxButtons.OK ); return; } } SaveChanges(true); using (var db = new FeeStatusesDBContext()) { if (!db.Member.Where(m => m.MustPay).All(m => m.FeeLogs.Any(fl => fl.Year == selectedYear))) { db.Member.ToList().ForEach(m => m.AddDefaultFeeLogForYear(selectedYear)); db.SaveChanges(); } } BindPaymentsDataGridView(onlyMustPayers, includeDeleted); ScrollHorizontallyToEnd(); } }
private void PrepareDataForSelectedYearToolStripMenuItem_Click(object sender, EventArgs e) { var selectYear = new SelectYearForm(); if (selectYear.ShowDialog() == DialogResult.OK) { InitializeDataGridView(selectYear.Year, false); } }