Beispiel #1
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;
        }
Beispiel #2
0
 private void FormDepositEdit_Load(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         if (!Security.IsAuthorized(Permissions.DepositSlips, DateTime.Today))
         {
             //we will check the date again when saving
             DialogResult = DialogResult.Cancel;
             return;
         }
     }
     else
     {
         //We enforce security here based on date displayed, not date entered
         if (!Security.IsAuthorized(Permissions.DepositSlips, DepositCur.DateDeposit))
         {
             butOK.Enabled     = false;
             butDelete.Enabled = false;
         }
     }
     if (IsNew)
     {
         textDateStart.Text = PIn.PDate(PrefB.GetString("DateDepositsStarted")).ToShortDateString();
         if (PrefB.GetBool("EasyNoClinics"))
         {
             comboClinic.Visible = false;
             labelClinic.Visible = false;
         }
         comboClinic.Items.Clear();
         comboClinic.Items.Add(Lan.g(this, "all"));
         comboClinic.SelectedIndex = 0;
         for (int i = 0; i < Clinics.List.Length; i++)
         {
             comboClinic.Items.Add(Clinics.List[i].Description);
         }
         for (int i = 0; i < DefB.Short[(int)DefCat.PaymentTypes].Length; i++)
         {
             listPayType.Items.Add(DefB.Short[(int)DefCat.PaymentTypes][i].ItemName);
             listPayType.SetSelected(i, true);
         }
         textDepositAccount.Visible = false;              //this is never visible for new. It's a description if already attached.
         if (Accounts.DepositsLinked())
         {
             DepositAccounts = Accounts.GetDepositAccounts();
             for (int i = 0; i < DepositAccounts.Length; i++)
             {
                 comboDepositAccount.Items.Add(Accounts.GetDescript(DepositAccounts[i]));
             }
             comboDepositAccount.SelectedIndex = 0;
         }
         else
         {
             labelDepositAccount.Visible = false;
             comboDepositAccount.Visible = false;
         }
     }
     else
     {
         groupSelect.Visible   = false;
         gridIns.SelectionMode = GridSelectionMode.None;
         gridPat.SelectionMode = GridSelectionMode.None;
         //we never again let user change the deposit linking again from here.
         //They need to detach it from within the transaction
         //Might be enhanced later to allow, but that's very complex.
         Transaction trans = Transactions.GetAttachedToDeposit(DepositCur.DepositNum);
         if (trans == null)
         {
             labelDepositAccount.Visible = false;
             comboDepositAccount.Visible = false;
             textDepositAccount.Visible  = false;
         }
         else
         {
             comboDepositAccount.Enabled = false;
             labelDepositAccount.Text    = Lan.g(this, "Deposited into Account");
             ArrayList jeAL = JournalEntries.GetForTrans(trans.TransactionNum);
             for (int i = 0; i < jeAL.Count; i++)
             {
                 if (Accounts.GetAccount(((JournalEntry)jeAL[i]).AccountNum).AcctType == AccountType.Asset)
                 {
                     comboDepositAccount.Items.Add(Accounts.GetDescript(((JournalEntry)jeAL[i]).AccountNum));
                     comboDepositAccount.SelectedIndex = 0;
                     textDepositAccount.Text           = ((JournalEntry)jeAL[i]).DateDisplayed.ToShortDateString()
                                                         + " " + ((JournalEntry)jeAL[i]).DebitAmt.ToString("c");
                     break;
                 }
             }
         }
     }
     textDate.Text            = DepositCur.DateDeposit.ToShortDateString();
     textAmount.Text          = DepositCur.Amount.ToString("F");
     textBankAccountInfo.Text = DepositCur.BankAccountInfo;
     FillGrids();
     if (IsNew)
     {
         gridPat.SetSelected(true);
         gridIns.SetSelected(true);
     }
     ComputeAmt();
 }