Exemple #1
0
        private void EditPerson()
        {
            if (MainGrid.SelectedRows.Count == 0)
            {
                MessageService.ShowInfo("Нужно выбрать сотрудника для редактирования.");

                return;
            }

            int currentId = (int)MainGrid.SelectedRows[0].Cells[0].Value;

            ActionForm tempForm = new ActionForm(currentId);

            DialogResult result = tempForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                Person returnedPerson = tempForm.MainPerson;

                LogService.Info($"Модель была изменена: #{returnedPerson.Id} {returnedPerson.FirstName} {returnedPerson.LastName}");

                mainTable.Rows.Find(currentId).SetField(1, returnedPerson.FirstName);
                mainTable.Rows.Find(currentId).SetField(2, returnedPerson.LastName);
            }
        }
Exemple #2
0
        private void AddPerson()
        {
            ActionForm tempForm = new ActionForm();

            DialogResult result = tempForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                Person returnedPerson = tempForm.MainPerson;

                LogService.Info($"Модель была добавлена: #{returnedPerson.Id} {returnedPerson.FirstName} {returnedPerson.LastName}");

                mainTable.Rows.Add(returnedPerson.Id, returnedPerson.FirstName, returnedPerson.LastName);
            }
        }