예제 #1
0
 private void butCancel_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         //no need to worry about deposit links, since none made yet.
         Deposits.Delete(DepositCur);
     }
     DialogResult = DialogResult.Cancel;
 }
예제 #2
0
        private void butDelete_Click(object sender, System.EventArgs e)
        {
            if (IsNew)
            {
                DialogResult = DialogResult.Cancel;
                return;
            }
            //If deposit is attached to a transaction which is more than 48 hours old, then not allowed to delete.
            //This is hard coded.  User would have to delete or detach from within transaction rather than here.
            Transaction trans = Transactions.GetAttachedToDeposit(DepositCur.DepositNum);

            if (trans != null)
            {
                if (trans.DateTimeEntry < MiscData.GetNowDateTime().AddDays(-2))
                {
                    MsgBox.Show(this, "Not allowed to delete.  This deposit is already attached to an accounting transaction.  You will need to detach it from within the accounting section of the program.");
                    return;
                }
                if (Transactions.IsReconciled(trans))
                {
                    MsgBox.Show(this, "Not allowed to delete.  This deposit is attached to an accounting transaction that has been reconciled.  You will need to detach it from within the accounting section of the program.");
                    return;
                }
                try{
                    Transactions.Delete(trans);
                }
                catch (ApplicationException ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            if (!MsgBox.Show(this, true, "Delete?"))
            {
                return;
            }
            Deposits.Delete(DepositCur);
            DialogResult = DialogResult.OK;
        }