//Обновление строки private void UpdateCardStatus() { if (dgvCardStatus.CurrentRow == null) { return; } CardStatus cardStatus = dgvCardStatus.CurrentRow.DataBoundItem as v_CardStatus; if (cardStatus == null) { MessageBox.Show("Не знайдений рядок для оновлення", "Помилка"); return; } fmPersCardStatusEdit fmCardStatusEdit = new fmPersCardStatusEdit(EnumFormMode.Edit, "Зміна інтервалу"); fmCardStatusEdit.AddControlPeriod(cardStatuses); fmCardStatusEdit.SetData(cardStatus); if (fmCardStatusEdit.ShowDialog() == DialogResult.OK) { cardStatus = fmCardStatusEdit.GetData(); CardStatus findCardStatus = cardStatuses.FirstOrDefault(rec => rec.CardStatus_Id == cardStatus.CardStatus_Id); if (findCardStatus == null) { MessageBox.Show("Не знайдений рядок для оновлення", "Помилка"); return; } findCardStatus.CardStatus_PerBeg = cardStatus.CardStatus_PerBeg; findCardStatus.CardStatus_PerEnd = cardStatus.CardStatus_PerEnd; findCardStatus.CardStatus_Type = cardStatus.CardStatus_Type; RefreshTableCardStatus(); } }
//============================================================================================================================= // Статус //============================================================================================================================= //Вставка строки private void InsertCardStatus() { fmPersCardStatusEdit fmStatusEdit = new fmPersCardStatusEdit(EnumFormMode.Insert, "Створення інтервалу"); fmStatusEdit.AddControlPeriod(cardStatuses); if (fmStatusEdit.ShowDialog() == DialogResult.OK) { CardStatus getCardStatus = fmStatusEdit.GetData(); if (cardStatuses.Count == 0) { getCardStatus.CardStatus_Id = 1; } else { getCardStatus.CardStatus_Id = cardStatuses.Max(rec => rec.CardStatus_Id) + 1; } getCardStatus.CardStatus_PersCard_Id = id; cardStatuses.Add(getCardStatus); RefreshTableCardStatus(); } }