Exemple #1
0
        private void btnDeleteItem_Click(object sender, EventArgs e)
        {
            DebugWriteLine("Deleting item.");

            ItemViewModel selectedItem = dataGridLibrary.GetSelectedItem();

            if (null != selectedItem)
            {
                if (MessageBox.Show(string.Format("You are about to delete {0}. All transactions pertaining to this item will also be deleted.  Are you sure?", selectedItem.Title), "Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    LendingTransaction trans = ServiceTransactions.GetItemCurrentTransaction(Transactions, selectedItem.Id);

                    if (null != trans)
                    {
                        trans.ReturnDate = DateTime.Now;
                        ServicePeople.UpdatePersonStatus(ServicePeople.GetPeoplePerson(People, trans.Borrower), trans);
                    }

                    Transactions.LendingTransactions.RemoveAll(x => x.Item == selectedItem.Id);
                    Transactions.IsModified = true;
                    Library.Items.Remove(selectedItem);
                    Library.IsModified = true;
                    DataBindLibrary();
                    DebugWriteLine(string.Format("{0} deleted.", selectedItem.Title));
                }
                else
                {
                    DebugWriteLine(string.Format("{0} NOT deleted.", selectedItem.Title));
                }
            }
        }
Exemple #2
0
        private void UpdatePerson(BaseModel person)
        {
            if (Error.None == ServicePeople.UpdatePeople(People, (PersonViewModel)person))
            {
                ServicePeople.SortPeople(People);
                DataBindPeople((PersonViewModel)person);
            }

            DebugWriteLine(string.Format("UpdatePerson({0}) - updated.", ((PersonViewModel)person).Id));
        }