protected override void OnDelete(Entity item, out string message, ref Action <Entity> afterConfirm)
        {
            if (afterConfirm == null)
            {
                throw new ArgumentNullException(nameof(afterConfirm));
            }

            message = ((OfferedClass)item).Id.ToString();

            afterConfirm = currentItem =>
            {
                try
                {
                    var deletedItem = (OfferedClass)currentItem;


                    deletedItem.RowStatus = RecordStatus.DeletedRecord;

                    //Save to Database
                    var dataWriter = new OfferedClassDataWriter(App.CurrentUser.User.Username, deletedItem);
                    dataWriter.SaveChanges();


                    ItemDataCollection.Remove((OfferedClass)currentItem);

                    App.LogAction("OfferedClass", "Deleted OfferedClass : " + deletedItem.Id.ToString());
                }
                catch (Exception ex)
                {
                    MessageDialog.ShowError(ex, this);
                }
            };
        }
Exemplo n.º 2
0
        public bool FileSave()
        {
            try
            {
                if (!DataIsValid())
                {
                    return(false);
                }

                var subject  = (Subject)cboSubject.SelectedItem;
                var section  = (Dll.SchoolYear.Section)txtSection.Tag;
                var employee = (Dll.Employee.Employee)txtEmployee.Tag;

                ItemData.SubjectId    = subject.Id;
                ItemData.SubjectClass = subject;

                ItemData.SectionId    = section.Id;
                ItemData.SectionClass = section;

                ItemData.EmployeeClass = employee;
                ItemData.TeacherId     = employee.Id;



                ItemData.Mon = new DateTime();
                ItemData.Tue = new DateTime();
                ItemData.Wed = new DateTime();
                ItemData.Thu = new DateTime();
                ItemData.Fri = new DateTime();
                ItemData.Sat = new DateTime();



                if (ItemData.Id != 0)
                {
                    ItemData.RowStatus = AiTech.LiteOrm.RecordStatus.ModifiedRecord;
                }


                var writer = new OfferedClassDataWriter(App.CurrentUser.User.Username, ItemData);
                writer.SaveChanges();

                DirtyStatus.Clear();

                DialogResult = DialogResult.OK;

                return(true);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowError(ex, this);
                return(false);
            }
        }