Beispiel #1
0
        /// <summary>
        /// Usunięcie zaznaczonej pozycji z listy
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void DeleteEntity <T>(object sender, EventArgs eventArgs) where T : class, IDBModel, new()
        {
            AddEditFormController addEditFormController = new AddEditFormController();
            T entity = _mainForm.SelectedEntity as T;

            if (MessageBox.Show("Usunąć zaznaczoną pozycję?", "Potwierdzeniu usunięcia", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                string errorMessage = _dataSourceManager.Delete(entity);
                if (errorMessage != null)
                {
                    MessageBox.Show(errorMessage);
                }
                RefreshDataGrids <T>();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handler dodawania obiektu. Otwiera formularz do wypełnienia danych.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void AddEntity <T>(object sender, EventArgs eventArgs) where T : class, IDBModel, new()
        {
            AddEditFormController addEditFormController = new AddEditFormController();
            T newEntity = addEditFormController.OpenForm(new T()) as T;

            if (newEntity != null)
            {
                string errorMessage = _dataSourceManager.Add(newEntity);
                if (errorMessage != null)
                {
                    MessageBox.Show(errorMessage);
                }
                RefreshDataGrids <T>();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Handler edycji obiektu. Otwiera formularz i wypełnia go aktualnymi danymi.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void UpdateEntity <T>(object sender, EventArgs eventArgs) where T : class, IDBModel, new()
        {
            AddEditFormController addEditFormController = new AddEditFormController();
            T entity         = _mainForm.SelectedEntity as T;
            T modifiedEntity = addEditFormController.OpenForm(entity) as T;

            if (modifiedEntity != null)
            {
                string errorMessage = _dataSourceManager.Update(modifiedEntity, entity);
                if (errorMessage != null)
                {
                    MessageBox.Show(errorMessage);
                }
                RefreshDataGrids <T>();
            }
        }