public bool FileSave()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

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

                ItemData.Code        = txtCode.Text.Trim();
                ItemData.Description = txtDescription.Text.Trim();

                ItemData.Mandatory = swMandatory.Value;
                ItemData.Priority  = swPriority.Value;
                ItemData.Active    = swActive.Value;

                //Save to Database
                var dataWriter = new DeductionDataWriter(App.CurrentUser.User.Username, ItemData);
                var isSaved    = dataWriter.SaveChanges();

                DirtyStatus.Clear();

                DialogResult = DialogResult.OK;

                return(isSaved);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowError(ex, this);
                return(false);
            }
        }
示例#2
0
        protected override void OnDelete(Entity item, out string message, ref Action <Entity> afterConfirm)
        {
            if (afterConfirm == null)
            {
                throw new ArgumentNullException(nameof(afterConfirm));
            }

            message = ((Deduction)item).Description;

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


                    deletedItem.RowStatus = RecordStatus.DeletedRecord;

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

                    App.LogAction("Deduction", "Deleted Deduction: " + deletedItem.Description);

                    ItemDataCollection.Remove((Deduction)currentItem);
                }
                catch (Exception ex)
                {
                    MessageDialog.ShowError(ex, this);
                }
            };
        }