Exemplo n.º 1
0
        public bool FileSave()
        {
            Cursor.Current = Cursors.WaitCursor;


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

            ItemData.BatchName = txtBatchName.Text;
            ItemData.Semester  = cboSemester.Text;

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

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

            if (!writer.SaveChanges())
            {
                MessageDialog.Show(this, "No Changes Detected", "No changes to be saved.");
                return(false);
            }

            DialogResult = DialogResult.OK;

            DirtyStatus.Clear();

            return(true);
        }
Exemplo n.º 2
0
        protected override void OnDelete(Entity item, out string message, ref Action <Entity> afterConfirm)
        {
            if (afterConfirm == null)
            {
                throw new ArgumentNullException(nameof(afterConfirm));
            }

            message = ((Batch)item).BatchName;

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


                    deletedItem.RowStatus = RecordStatus.DeletedRecord;

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


                    ItemDataCollection.Remove((Dll.SchoolYear.Batch)currentItem);

                    App.LogAction("School Year.Batch", "Deleted Batch : " + deletedItem.BatchName);
                }
                catch (Exception ex)
                {
                    MessageDialog.ShowError(ex, this);
                }
            };
        }
        public bool SaveChanges(string username)
        {
            var writer = new BatchDataWriter(username, ItemDataCollection);

            return(writer.SaveChanges());
        }