Example #1
0
        /// <summary>
        /// Вызов формы для добавления записи с контролем ошибок.
        /// </summary>
        void AddItem()
        {
            var editForm = new EmployeesEditForm(null);

            if (editForm.ShowDialog() == DialogResult.OK)
            {
                LoadData();
                employeesDataGridView.Refresh();
            }
        }
Example #2
0
        /// <summary>
        /// Вызов формы для обновление выбранной записи с контролем ошибок.
        /// </summary>
        void UpdateItem()
        {
            if (employeesDataGridView.CurrentCell == null)
            {
                return;
            }

            if (employeesDataGridView.SelectedRows.Count > 0)
            {
                using (var marketDBEntities = new MarketDBEntities())
                {
                    int      index        = employeesDataGridView.SelectedRows[0].Index;
                    Employee selectedItem = marketDBEntities.Employees.Find(employeesDataGridView[0, index].Value);

                    var editForm = new EmployeesEditForm(selectedItem);
                    if (editForm.ShowDialog() == DialogResult.OK)
                    {
                        LoadData();
                    }
                }
            }
        }