private void CopyEntityInTable() { if (ItemIndexInDGM == -1 || DGM.SelectedCells?.Count > 1) { MessageBox.Show("Встаньте на 1 ячейку необходимой строки!", "Maestro: [Фінансування]", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { DGM.Focus(); DBSolom.Financing row = (DBSolom.Financing)DGM.Items.GetItemAt(ItemIndexInDGM); if (row.Головний_розпорядник is null || row.КЕКВ is null || row.КФК is null || row.Мікрофонд is null) { MessageBox.Show("Заполните все данные в строке!", "Maestro: [Фінансування]", MessageBoxButton.OK, MessageBoxImage.Exclamation); }
private void DGM_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (((DBSolom.Financing)e.Row.Item).Id == 0) { ((DBSolom.Financing)e.Row.Item).Створив = db.Users.FirstOrDefault(f => f.Видалено == false && f.Логін == Func.Login); } ((DBSolom.Financing)e.Row.Item).Змінив = db.Users.FirstOrDefault(f => f.Видалено == false && f.Логін == Func.Login); ((DBSolom.Financing)e.Row.Item).Змінено = DateTime.Now; if (e.EditAction != DataGridEditAction.Cancel) { if (((DBSolom.Financing)e.EditingElement.DataContext).Головний_розпорядник != null && ((DBSolom.Financing)e.EditingElement.DataContext).КЕКВ != null && ((DBSolom.Financing)e.EditingElement.DataContext).КФК != null && ((DBSolom.Financing)e.EditingElement.DataContext).Мікрофонд != null) { #region "Fields of Cell" DateTime date = ((DBSolom.Financing)e.Row.Item).Проведено; KFK KFK = ((DBSolom.Financing)e.Row.Item).КФК; Main_manager Main_manager = ((DBSolom.Financing)e.Row.Item).Головний_розпорядник; KEKB KEKB = ((DBSolom.Financing)e.Row.Item).КЕКВ; Foundation FOND = ((DBSolom.Financing)e.Row.Item).Мікрофонд.Фонд; MicroFoundation MicroFond = ((DBSolom.Financing)e.Row.Item).Мікрофонд; #endregion var x = Func.GetCurrentPlanAndRemainderFromDBPerMonth(db, date.Year, KFK, Main_manager, KEKB, FOND); if ((x[TypeOfFinanceData.Remainders][date.Month - 1] < 0)) { DGM.CancelEdit(DataGridEditingUnit.Cell); MessageBox.Show(($"[Дата: {date.ToShortDateString()}] [Фонд: {FOND.Код}] [КПБ: {KFK.Код}]" + $" [Головний розпорядник: {Main_manager.Найменування}] [КЕКВ: {KEKB.Код}]" + $" [Місяць: {Func.names_months[date.Month - 1]}] [Остаток:{x[TypeOfFinanceData.Remainders][date.Month - 1]}]"), "Maestro", MessageBoxButton.OK, MessageBoxImage.Error); return; } } } else { ((DBSolom.Financing)e.Row.Item).Сума = 0; } }