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

            message = ((Subject)item).SubjectCode + " - " + ((Subject)item).Description;

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


                    deletedItem.RowStatus = RecordStatus.DeletedRecord;

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


                    ItemDataCollection.Remove((Subject)currentItem);

                    App.LogAction("Subject", "Deleted Subject : " + deletedItem.SubjectCode);
                }
                catch (Exception ex)
                {
                    MessageDialog.ShowError(ex, this);
                }
            };
        }
示例#2
0
        public bool FileSave()
        {
            Cursor.Current = Cursors.WaitCursor;


            if (!DataIsValid())
            {
                return(false);
            }


            ItemData.SubjectCode = txtSubjectCode.Text;
            ItemData.Description = txtDescription.Text;


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


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

            writer.SaveChanges();


            DialogResult = DialogResult.OK;

            DirtyStatus.Clear();

            return(true);
        }