Example #1
0
        private void DeleteEvents()
        {
            if (logListView.SelectedItems.Count < 1)
                return;

            if (MessageBox.Show(string.Concat("Sigurno želiš obrisati odabrane unose? (", logListView.SelectedItems.Count, " komad(a))"), "Upozorenje", MessageBoxButtons.OKCancel) != DialogResult.OK)
                return;

            using (var context = new LovroContext(connectionString))
            {
                var toBeDeletedIDs = logListView.SelectedItems.Cast<ListViewItem>().Select(item => (int)item.Tag);
                var toBeDeletedItems = context.BaseEvents.Where(item => toBeDeletedIDs.Contains(item.ID));

                foreach (LovroBaseEvent lovroEvent in toBeDeletedItems)
                    context.BaseEvents.Remove(lovroEvent);

                context.SaveChanges();
            }
        }
Example #2
0
        private void EditEvent(int eventID)
        {
            using (var context = new LovroContext(connectionString))
            {
                LovroBaseEvent eventInEditing = context.BaseEvents.FirstOrDefault(item => item.ID == eventID);

                if (eventInEditing == null)
                    throw new InvalidOperationException("Nepostojeći unos!");

                using (var editForm = new LovroEventEditForm())
                {
                    editForm.EventInEditing = eventInEditing;
                    if (editForm.ShowDialog() == DialogResult.OK) // eventInEditing properties will be changed in the dialog
                        context.SaveChanges();
                }
            }
        }
Example #3
0
        private void AddEvent(LovroBaseEvent lovroEvent)
        {
            if (!AskForDetails(lovroEvent))
            {
                return;
            }

            using (var context = new LovroContext(connectionString))
            {
                //context.AddBaseEvent(lovroEvent);

                context.BaseEvents.Add(lovroEvent);
                context.SaveChanges();
            }
        }