Ejemplo n.º 1
0
        private void FillGrid()
        {
            if (IsSelectionMode)
            {
                DList = Deposits.GetUnattached();
            }
            else
            {
                DList = Deposits.Refresh();
            }
            grid.BeginUpdate();
            grid.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableDepositSlips", "Date"), 80);

            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlips", "Amount"), 90);
            grid.Columns.Add(col);
            grid.Rows.Clear();
            OpenDental.UI.ODGridRow row;
            for (int i = 0; i < DList.Length; i++)
            {
                row = new OpenDental.UI.ODGridRow();
                row.Cells.Add(DList[i].DateDeposit.ToShortDateString());
                row.Cells.Add(DList[i].Amount.ToString("F"));
                grid.Rows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollToEnd();
        }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
        private void FillGrid()
        {
            if (!PrefC.HasClinicsEnabled)
            {
                if (IsSelectionMode)
                {
                    DList = Deposits.GetUnattached();
                }
                else
                {
                    DList = Deposits.Refresh();
                }
            }
            else
            {
                //GetForClinics uses an empty list to indicate "all", which is a loophole if user doesn't select an item.  So:
                if (comboClinics.ListSelectedClinicNums.Count == 0)
                {
                    DList = Deposits.GetForClinics(new List <long>()
                    {
                        Clinics.ClinicNum
                    }, IsSelectionMode);                                                                                   //restrict to current clinic
                }
                else
                {
                    DList = Deposits.GetForClinics(comboClinics.ListSelectedClinicNums, IsSelectionMode);
                }
            }
            grid.BeginUpdate();
            grid.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g("TableDepositSlips", "Date"), 80);

            grid.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableDepositSlips", "Amount"), 90, HorizontalAlignment.Right);
            grid.ListGridColumns.Add(col);
            if (PrefC.HasClinicsEnabled)
            {
                col = new GridColumn(Lan.g("TableDepositSlips", "Clinic"), 150);
                grid.ListGridColumns.Add(col);
            }
            grid.ListGridRows.Clear();
            OpenDental.UI.GridRow row;
            for (int i = 0; i < DList.Length; i++)
            {
                row = new OpenDental.UI.GridRow();
                row.Cells.Add(DList[i].DateDeposit.ToShortDateString());
                row.Cells.Add(DList[i].Amount.ToString("F"));
                if (PrefC.HasClinicsEnabled)
                {
                    row.Cells.Add(" " + DList[i].ClinicAbbr);                  //padding left with space to add separation between amount and clinic abbr
                }
                grid.ListGridRows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollToEnd();
        }
Ejemplo n.º 4
0
        private void FillGrid()
        {
            if (!PrefC.HasClinicsEnabled)
            {
                if (IsSelectionMode)
                {
                    DList = Deposits.GetUnattached();
                }
                else
                {
                    DList = Deposits.Refresh();
                }
            }
            else
            {
                List <long> listSelectedClinicNums = new List <long>();
                if (!Security.CurUser.ClinicIsRestricted && comboClinic.SelectedIndices.Contains(0))                 //All is an option in comboClinic and is selected.
                //Blank by design for Deposits.GetForClinics(...).
                {
                }
                else
                {
                    int listStep = (Security.CurUser.ClinicIsRestricted?0:1);                  //If the All option is available, then all indices are offset by 1.
                    comboClinic.ListSelectedIndices.ForEach(x => listSelectedClinicNums.Add(_listClinics[x - listStep].ClinicNum));
                }
                DList = Deposits.GetForClinics(listSelectedClinicNums, IsSelectionMode);
            }
            grid.BeginUpdate();
            grid.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableDepositSlips", "Date"), 80);

            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlips", "Amount"), 90, HorizontalAlignment.Right);
            grid.Columns.Add(col);
            if (PrefC.HasClinicsEnabled)
            {
                col = new ODGridColumn(Lan.g("TableDepositSlips", "Clinic"), 150);
                grid.Columns.Add(col);
            }
            grid.Rows.Clear();
            OpenDental.UI.ODGridRow row;
            for (int i = 0; i < DList.Length; i++)
            {
                row = new OpenDental.UI.ODGridRow();
                row.Cells.Add(DList[i].DateDeposit.ToShortDateString());
                row.Cells.Add(DList[i].Amount.ToString("F"));
                if (PrefC.HasClinicsEnabled)
                {
                    row.Cells.Add(" " + DList[i].ClinicAbbr);                  //padding left with space to add separation between amount and clinic abbr
                }
                grid.Rows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollToEnd();
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
        ///<summary>Saves the selected rows to database.  MUST close window after this.</summary>
        private bool SaveToDB()
        {
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            //Prevent backdating----------------------------------------------------------------------------------------
            DateTime date = PIn.PDate(textDate.Text);

            if (IsNew)
            {
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            else
            {
                //We enforce security here based on date displayed, not date entered
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            DepositCur.DateDeposit = PIn.PDate(textDate.Text);
            //amount already handled.
            DepositCur.BankAccountInfo = PIn.PString(textBankAccountInfo.Text);
            if (IsNew)
            {
                Deposits.Insert(DepositCur);
                if (Accounts.DepositsLinked() && DepositCur.Amount > 0)
                {
                    //create a transaction here
                    Transaction trans = new Transaction();
                    trans.DepositNum = DepositCur.DepositNum;
                    trans.UserNum    = Security.CurUser.UserNum;
                    Transactions.Insert(trans);
                    //first the deposit entry
                    JournalEntry je = new JournalEntry();
                    je.AccountNum     = DepositAccounts[comboDepositAccount.SelectedIndex];
                    je.CheckNumber    = Lan.g(this, "DEP");
                    je.DateDisplayed  = DepositCur.DateDeposit;                 //it would be nice to add security here.
                    je.DebitAmt       = DepositCur.Amount;
                    je.Memo           = Lan.g(this, "Deposit");
                    je.Splits         = Accounts.GetDescript(PrefB.GetInt("AccountingIncomeAccount"));
                    je.TransactionNum = trans.TransactionNum;
                    JournalEntries.Insert(je);
                    //then, the income entry
                    je            = new JournalEntry();
                    je.AccountNum = PrefB.GetInt("AccountingIncomeAccount");
                    //je.CheckNumber=;
                    je.DateDisplayed  = DepositCur.DateDeposit;                 //it would be nice to add security here.
                    je.CreditAmt      = DepositCur.Amount;
                    je.Memo           = Lan.g(this, "Deposit");
                    je.Splits         = Accounts.GetDescript(DepositAccounts[comboDepositAccount.SelectedIndex]);
                    je.TransactionNum = trans.TransactionNum;
                    JournalEntries.Insert(je);
                }
            }
            else
            {
                Deposits.Update(DepositCur);
            }
            if (IsNew)            //never allowed to change or attach more checks after initial creation of deposit slip
            {
                for (int i = 0; i < gridPat.SelectedIndices.Length; i++)
                {
                    PatPayList[gridPat.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    Payments.Update(PatPayList[gridPat.SelectedIndices[i]]);
                }
                for (int i = 0; i < gridIns.SelectedIndices.Length; i++)
                {
                    ClaimPayList[gridIns.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    ClaimPayments.Update(ClaimPayList[gridIns.SelectedIndices[i]]);
                }
            }
            if (IsNew)
            {
                SecurityLogs.MakeLogEntry(Permissions.DepositSlips, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " New " + DepositCur.Amount.ToString("c"));
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " " + DepositCur.Amount.ToString("c"));
            }
            return(true);
        }
Ejemplo n.º 7
0
        ///<summary>Saves the selected rows to database.  MUST close window after this.</summary>
        private bool SaveToDB()
        {
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            //Prevent backdating----------------------------------------------------------------------------------------
            DateTime date = PIn.Date(textDate.Text);

            if (IsNew)
            {
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            else
            {
                //We enforce security here based on date displayed, not date entered
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            DepositCur.DateDeposit = PIn.Date(textDate.Text);
            //amount already handled.
            DepositCur.BankAccountInfo = PIn.String(textBankAccountInfo.Text);
            if (IsNew)
            {
                if (gridPat.SelectedIndices.Length + gridIns.SelectedIndices.Length > 18)
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "No more than 18 items will fit on a QuickBooks deposit slip. Continue anyway?"))
                    {
                        return(false);
                    }
                }
                Deposits.Insert(DepositCur);
                if (Accounts.DepositsLinked() && DepositCur.Amount > 0)
                {
                    if (PrefC.GetInt(PrefName.AccountingSoftware) == (int)AccountingSoftware.QuickBooks)
                    {
                        //Create a deposit within QuickBooks.
                        try {
                            Cursor.Current = Cursors.WaitCursor;
                            QuickBooks.CreateDeposit(DepositAccountsQB[comboDepositAccount.SelectedIndex]
                                                     , PrefC.GetString(PrefName.QuickBooksIncomeAccount), DepositCur.Amount);
                            Cursor.Current = Cursors.Default;
                        }
                        catch (Exception ex) {
                            Cursor.Current = Cursors.Default;
                            if (MessageBox.Show(ex.Message + "\r\n\r\nA deposit has not been created in QuickBooks, continue anyway?", "QuickBooks Deposit Create Failed", MessageBoxButtons.YesNo) != DialogResult.Yes)
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        //create a transaction here
                        Transaction trans = new Transaction();
                        trans.DepositNum = DepositCur.DepositNum;
                        trans.UserNum    = Security.CurUser.UserNum;
                        Transactions.Insert(trans);
                        //first the deposit entry
                        JournalEntry je = new JournalEntry();
                        je.AccountNum     = DepositAccounts[comboDepositAccount.SelectedIndex];
                        je.CheckNumber    = Lan.g(this, "DEP");
                        je.DateDisplayed  = DepositCur.DateDeposit;                     //it would be nice to add security here.
                        je.DebitAmt       = DepositCur.Amount;
                        je.Memo           = Lan.g(this, "Deposit");
                        je.Splits         = Accounts.GetDescript(PrefC.GetLong(PrefName.AccountingIncomeAccount));
                        je.TransactionNum = trans.TransactionNum;
                        JournalEntries.Insert(je);
                        //then, the income entry
                        je            = new JournalEntry();
                        je.AccountNum = PrefC.GetLong(PrefName.AccountingIncomeAccount);
                        //je.CheckNumber=;
                        je.DateDisplayed  = DepositCur.DateDeposit;                     //it would be nice to add security here.
                        je.CreditAmt      = DepositCur.Amount;
                        je.Memo           = Lan.g(this, "Deposit");
                        je.Splits         = Accounts.GetDescript(DepositAccounts[comboDepositAccount.SelectedIndex]);
                        je.TransactionNum = trans.TransactionNum;
                        JournalEntries.Insert(je);
                    }
                }
            }
            else
            {
                Deposits.Update(DepositCur);
            }
            if (IsNew)            //never allowed to change or attach more checks after initial creation of deposit slip
            {
                for (int i = 0; i < gridPat.SelectedIndices.Length; i++)
                {
                    PatPayList[gridPat.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    Payments.Update(PatPayList[gridPat.SelectedIndices[i]], false);
                }
                for (int i = 0; i < gridIns.SelectedIndices.Length; i++)
                {
                    ClaimPayList[gridIns.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    ClaimPayments.Update(ClaimPayList[gridIns.SelectedIndices[i]]);
                }
            }
            if (IsNew)
            {
                SecurityLogs.MakeLogEntry(Permissions.DepositSlips, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " New " + DepositCur.Amount.ToString("c"));
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " " + DepositCur.Amount.ToString("c"));
            }
            return(true);
        }