コード例 #1
0
 private void butUndo_Click(object sender, EventArgs e)
 {
     if (radioFinanceCharge.Checked)
     {
         if (MessageBox.Show(Lan.g(this, "Undo all finance charges for ") + textDateUndo.Text + "?", "", MessageBoxButtons.OKCancel)
             != DialogResult.OK)
         {
             return;
         }
         long rowsAffected = Adjustments.UndoFinanceCharges(PIn.Date(textDateUndo.Text));
         MessageBox.Show(Lan.g(this, "Finance charge adjustments deleted: ") + rowsAffected.ToString());
         Ledgers.RunAging();
         SecurityLogs.MakeLogEntry(Permissions.Setup, 0, "Finance Charges undo. Date " + textDateUndo.Text);
         DialogResult = DialogResult.OK;
     }
     else if (radioBillingCharge.Checked)
     {
         if (MessageBox.Show(Lan.g(this, "Undo all billing charges for ") + textDateUndo.Text + "?", "", MessageBoxButtons.OKCancel)
             != DialogResult.OK)
         {
             return;
         }
         long rowsAffected = Adjustments.UndoBillingCharges(PIn.Date(textDateUndo.Text));
         MessageBox.Show(Lan.g(this, "Billing charge adjustments deleted: ") + rowsAffected.ToString());
         Ledgers.RunAging();
         SecurityLogs.MakeLogEntry(Permissions.Setup, 0, "Billing Charges undo. Date " + textDateUndo.Text);
         DialogResult = DialogResult.OK;
     }
 }
コード例 #2
0
        private void FormFinanceCharges_Load(object sender, System.EventArgs e)
        {
            if (PrefC.GetLong(PrefName.FinanceChargeAdjustmentType) == 0)
            {
                MsgBox.Show(this, "No finance charge adjustment type has been set.  Please go to Setup | Modules to fix this.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (PrefC.GetLong(PrefName.BillingChargeAdjustmentType) == 0)
            {
                MsgBox.Show(this, "No billing charge adjustment type has been set.  Please go to Setup | Modules to fix this.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            Ledgers.RunAging();
            if (DefC.Short[(int)DefCat.BillingTypes].Length == 0)          //highly unlikely that this would happen
            {
                MsgBox.Show(this, "No billing types have been set up or are visible.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            textDate.Text          = DateTime.Today.ToShortDateString();
            textAPR.MaxVal         = 100;
            textAPR.MinVal         = 0;
            textAPR.Text           = PrefC.GetString(PrefName.FinanceChargeAPR);
            textBillingCharge.Text = PrefC.GetString(PrefName.BillingChargeAmount);
            for (int i = 0; i < DefC.Short[(int)DefCat.BillingTypes].Length; i++)
            {
                listBillType.Items.Add(DefC.Short[(int)DefCat.BillingTypes][i].ItemName);
                listBillType.SetSelected(i, true);
            }
            string defaultChargeMethod = PrefC.GetString(PrefName.BillingChargeOrFinanceIsDefault);

            if (defaultChargeMethod == "Finance")
            {
                radioFinanceCharge.Checked = true;
                textDateLastRun.Text       = PrefC.GetDate(PrefName.FinanceChargeLastRun).ToShortDateString();
                textDateUndo.Text          = PrefC.GetDate(PrefName.FinanceChargeLastRun).ToShortDateString();
            }
            else if (defaultChargeMethod == "Billing")
            {
                radioBillingCharge.Checked = true;
                textDateLastRun.Text       = PrefC.GetDate(PrefName.BillingChargeLastRun).ToShortDateString();
                textDateUndo.Text          = PrefC.GetDate(PrefName.BillingChargeLastRun).ToShortDateString();
            }
        }
コード例 #3
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDate.errorProvider1.GetError(textDate) != "" ||
                textAPR.errorProvider1.GetError(textAPR) != "")
            {
                MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
                return;
            }
            DateTime date = PIn.Date(textDate.Text);

            if (PrefC.GetDate(PrefName.FinanceChargeLastRun).AddDays(25) > date)
            {
                if (!MsgBox.Show(this, true, "Warning.  Finance charges should not be run more than once per month.  Continue?"))
                {
                    return;
                }
            }
            else if (PrefC.GetDate(PrefName.BillingChargeLastRun).AddDays(25) > date)
            {
                if (!MsgBox.Show(this, true, "Warning.  Billing charges should not be run more than once per month.  Continue?"))
                {
                    return;
                }
            }
            if (listBillType.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "Please select at least one billing type first.");
                return;
            }
            if (PIn.Long(textAPR.Text) < 2)
            {
                if (!MsgBox.Show(this, true, "The APR is much lower than normal. Do you wish to proceed?"))
                {
                    return;
                }
            }
            if (PrefC.GetBool(PrefName.AgingCalculatedMonthlyInsteadOfDaily) && PrefC.GetDate(PrefName.DateLastAging).AddMonths(1) <= DateTime.Today)
            {
                if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "It has been more than a month since aging has been run.  It is recommended that you update the aging date and run aging before continuing."))
                {
                    return;
                }
                //we might also consider a warning if textDate.Text does not match DateLastAging.  Probably not needed for daily aging, though.
            }
            PatAging[] AgingList = Patients.GetAgingListArray();
            double     OverallBalance;
            int        rowsAffected = 0;
            bool       billingMatch;

            for (int i = 0; i < AgingList.Length; i++) //loop through each guarantor that owes money.
            {
                OverallBalance = 0;                    //this WILL NOT be the same as the patient's total balance
                if (radio30.Checked)
                {
                    OverallBalance = AgingList[i].Bal_31_60 + AgingList[i].Bal_61_90 + AgingList[i].BalOver90;
                }
                else if (radio60.Checked)
                {
                    OverallBalance = AgingList[i].Bal_61_90 + AgingList[i].BalOver90;
                }
                else if (radio90.Checked)
                {
                    OverallBalance = AgingList[i].BalOver90;
                }
                if (OverallBalance <= .01d)
                {
                    continue;
                }
                billingMatch = false;
                for (int b = 0; b < listBillType.SelectedIndices.Count; b++)
                {
                    if (DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[b]].DefNum == AgingList[i].BillingType)
                    {
                        billingMatch = true;
                        break;
                    }
                }
                if (!billingMatch)
                {
                    continue;
                }
                if (radioFinanceCharge.Checked)
                {
                    AddFinanceCharge(AgingList[i].PatNum, date, textAPR.Text, OverallBalance, AgingList[i].PriProv);
                }
                else if (radioBillingCharge.Checked)
                {
                    AddBillingCharge(AgingList[i].PatNum, date, textBillingCharge.Text, AgingList[i].PriProv);
                }
                rowsAffected++;
            }
            if (radioFinanceCharge.Checked)
            {
                if (Prefs.UpdateString(PrefName.FinanceChargeAPR, textAPR.Text)
                    | Prefs.UpdateString(PrefName.FinanceChargeLastRun, POut.Date(date, false)))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                if (Prefs.UpdateString(PrefName.BillingChargeOrFinanceIsDefault, "Finance"))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                MessageBox.Show(Lan.g(this, "Finance Charges Added: ") + rowsAffected.ToString());
                Ledgers.RunAging();
                DialogResult = DialogResult.OK;
            }
            else if (radioBillingCharge.Checked)
            {
                if (Prefs.UpdateString(PrefName.BillingChargeAmount, textBillingCharge.Text)
                    | Prefs.UpdateString(PrefName.BillingChargeLastRun, POut.Date(date, false)))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                if (Prefs.UpdateString(PrefName.BillingChargeOrFinanceIsDefault, "Billing"))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                MessageBox.Show(Lan.g(this, "Billing Charges Added: ") + rowsAffected.ToString());
                Ledgers.RunAging();
                DialogResult = DialogResult.OK;
            }
        }
コード例 #4
0
ファイル: FormRpAging.cs プロジェクト: nampn/ODental
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (!checkBillTypesAll.Checked && listBillType.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one billing type must be selected.");
                return;
            }
            if (!checkProvAll.Checked && listProv.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one provider must be selected.");
                return;
            }
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Invalid date.");
                return;
            }
            DateTime asOfDate = PIn.Date(textDate.Text);

            //The aging report always show historical numbers based on the date entered.
            Ledgers.ComputeAging(0, asOfDate, true);
            ReportSimpleGrid report = new ReportSimpleGrid();
            string           cmd    = "SELECT ";

            if (PrefC.GetBool(PrefName.ReportsShowPatNum))
            {
                cmd += DbHelper.Concat("Cast(PatNum AS CHAR)", "'-'", "LName", "', '", "FName", "' '", "MiddleI");
            }
            else
            {
                cmd += DbHelper.Concat("LName", "', '", "FName", "' '", "MiddleI");
            }
            cmd += ",Bal_0_30,Bal_31_60,Bal_61_90,BalOver90"
                   + ",BalTotal "
                   + ",InsEst"
                   + ",BalTotal-InsEst AS ";            //\"$pat\" ";
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                cmd += "$pat ";
            }
            else               //Oracle needs quotes.
            {
                cmd += "\"$pat\" ";
            }
            cmd += "FROM patient "
                   + "WHERE ";
            if (checkExcludeInactive.Checked)
            {
                cmd += "(patstatus != 2) AND ";
            }
            if (checkBadAddress.Checked)
            {
                cmd += "(zip !='') AND ";
            }
            if (checkOnlyNeg.Checked)
            {
                cmd += "BalTotal < '-.005' ";
            }
            else
            {
                if (radioAny.Checked)
                {
                    cmd +=
                        "(Bal_0_30 > '.005' OR Bal_31_60 > '.005' OR Bal_61_90 > '.005' OR BalOver90 > '.005'";
                }
                else if (radio30.Checked)
                {
                    cmd +=
                        "(Bal_31_60 > '.005' OR Bal_61_90 > '.005' OR BalOver90 > '.005'";
                }
                else if (radio60.Checked)
                {
                    cmd +=
                        "(Bal_61_90 > '.005' OR BalOver90 > '.005'";
                }
                else if (radio90.Checked)
                {
                    cmd +=
                        "(BalOver90 > '.005'";
                }
                if (checkIncludeNeg.Checked)
                {
                    cmd += " OR BalTotal < '-.005'";
                }
                cmd += ") ";
            }
            if (!checkBillTypesAll.Checked)
            {
                for (int i = 0; i < listBillType.SelectedIndices.Count; i++)
                {
                    if (i == 0)
                    {
                        cmd += " AND (billingtype = ";
                    }
                    else
                    {
                        cmd += " OR billingtype = ";
                    }
                    cmd += POut.Long(DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[i]].DefNum);
                }
                cmd += ") ";
            }
            if (!checkProvAll.Checked)
            {
                for (int i = 0; i < listProv.SelectedIndices.Count; i++)
                {
                    if (i == 0)
                    {
                        cmd += " AND (PriProv = ";
                    }
                    else
                    {
                        cmd += " OR PriProv = ";
                    }
                    cmd += POut.Long(ProviderC.ListShort[listProv.SelectedIndices[i]].ProvNum);
                }
                cmd += ") ";
            }
            cmd                += "ORDER BY LName,FName";
            report.Query        = cmd;
            FormQuery2          = new FormQuery(report);
            FormQuery2.IsReport = true;
            FormQuery2.SubmitReportQuery();
            //Recompute aging in a non-historical way, so that the numbers are returned to the way they
            //are normally used in other parts of the program.
            Ledgers.RunAging();
            //if(Prefs.UpdateString(PrefName.DateLastAging",POut.PDate(asOfDate,false))) {
            //	DataValid.SetInvalid(InvalidType.Prefs);
            //}
            report.Title = "AGING REPORT";
            report.SubTitle.Add(PrefC.GetString(PrefName.PracticeTitle));
            report.SubTitle.Add("As of " + textDate.Text);
            if (radioAny.Checked)
            {
                report.SubTitle.Add("Any Balance");
            }
            if (radio30.Checked)
            {
                report.SubTitle.Add("Over 30 Days");
            }
            if (radio60.Checked)
            {
                report.SubTitle.Add("Over 60 Days");
            }
            if (radio90.Checked)
            {
                report.SubTitle.Add("Over 90 Days");
            }
            if (checkBillTypesAll.Checked)
            {
                report.SubTitle.Add("All Billing Types");
            }
            else
            {
                string subt = DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[0]].ItemName;
                for (int i = 1; i < listBillType.SelectedIndices.Count; i++)
                {
                    subt += ", " + DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[i]].ItemName;
                }
                report.SubTitle.Add(subt);
            }
            //report.InitializeColumns(8);
            report.SetColumn(this, 0, "GUARANTOR", 160);
            report.SetColumn(this, 1, "0-30 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 2, "30-60 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 3, "60-90 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 4, "> 90 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 5, "TOTAL", 85, HorizontalAlignment.Right);
            report.SetColumn(this, 6, "-INS EST", 85, HorizontalAlignment.Right);
            report.SetColumn(this, 7, "=PATIENT", 85, HorizontalAlignment.Right);
            FormQuery2.ShowDialog();
            DialogResult = DialogResult.OK;
        }
コード例 #5
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDate.errorProvider1.GetError(textDate) != "" ||
                textAPR.errorProvider1.GetError(textAPR) != "" ||
                textAtLeast.errorProvider1.GetError(textAtLeast) != "" ||
                textOver.errorProvider1.GetError(textOver) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            DateTime date = PIn.Date(textDate.Text);

            if (PrefC.GetDate(PrefName.FinanceChargeLastRun).AddDays(25) > date)
            {
                if (!MsgBox.Show(this, true, "Warning.  Finance charges should not be run more than once per month.  Continue?"))
                {
                    return;
                }
            }
            else if (PrefC.GetDate(PrefName.BillingChargeLastRun).AddDays(25) > date)
            {
                if (!MsgBox.Show(this, true, "Warning.  Billing charges should not be run more than once per month.  Continue?"))
                {
                    return;
                }
            }
            if (listBillType.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "Please select at least one billing type first.");
                return;
            }
            if (PIn.Long(textAPR.Text) < 2)
            {
                if (!MsgBox.Show(this, true, "The APR is much lower than normal. Do you wish to proceed?"))
                {
                    return;
                }
            }
            if (PrefC.GetBool(PrefName.AgingCalculatedMonthlyInsteadOfDaily) && PrefC.GetDate(PrefName.DateLastAging).AddMonths(1) <= DateTime.Today)
            {
                if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "It has been more than a month since aging has been run.  It is recommended that you update the "
                                 + "aging date and run aging before continuing."))
                {
                    return;
                }
                //we might also consider a warning if textDate.Text does not match DateLastAging.  Probably not needed for daily aging, though.
            }
            string      chargeType            = (radioFinanceCharge.Checked?"Finance":"Billing");//For display only
            List <long> listSelectedBillTypes = listBillType.SelectedIndices.OfType <int>().Select(x => _listBillingTypeDefs[x].DefNum).ToList();
            Action      actionCloseProgress   = null;
            int         chargesAdded          = 0;

            try {
                actionCloseProgress = ODProgressOld.ShowProgressStatus("FinanceCharge", this, Lan.g(this, "Gathering patients with aged balances") + "...");
                List <PatAging> listPatAgings = Patients.GetAgingListSimple(listSelectedBillTypes, new List <long> {
                });                                                                                                                //Ordered by PatNum, for thread concurrency
                long adjType = PrefC.GetLong(PrefName.FinanceChargeAdjustmentType);
                Dictionary <long, List <Adjustment> > dictPatAdjustments = new Dictionary <long, List <Adjustment> >();
                if (!checkCompound.Checked)
                {
                    int daysOver = (radio30.Checked ? 30
                                                : radio60.Checked ? 60
                                                : 90);
                    DateTime maxAdjDate = MiscData.GetNowDateTime().Date.AddDays(-daysOver);
                    dictPatAdjustments = Adjustments.GetAdjustForPatsByType(listPatAgings.Select(x => x.PatNum).ToList(), adjType, maxAdjDate);
                }
                int           chargesProcessed = 0;
                List <Action> listActions      = new List <Action>();
                foreach (PatAging patAgingCur in listPatAgings)
                {
                    listActions.Add(new Action(() => {
                        if (++chargesProcessed % 5 == 0)
                        {
                            ODEvent.Fire(new ODEventArgs("FinanceCharge", Lan.g(this, "Processing " + chargeType + " charges") + ": " + chargesProcessed + " out of "
                                                         + listPatAgings.Count));
                        }
                        //This WILL NOT be the same as the patient's total balance. Start with BalOver90 since all options include that bucket. Add others if needed.
                        double overallBalance = patAgingCur.BalOver90 + (radio60.Checked?patAgingCur.Bal_61_90:radio30.Checked?(patAgingCur.Bal_31_60 + patAgingCur.Bal_61_90):0);
                        if (overallBalance <= .01d)
                        {
                            return;
                        }
                        if (radioBillingCharge.Checked)
                        {
                            AddBillingCharge(patAgingCur.PatNum, date, textBillingCharge.Text, patAgingCur.PriProv);
                        }
                        else                                                                                 //Finance charge
                        {
                            if (dictPatAdjustments.ContainsKey(patAgingCur.PatNum))                          //Only contains key if checkCompound is not checked.
                            {
                                overallBalance -= dictPatAdjustments[patAgingCur.PatNum].Sum(x => x.AdjAmt); //Dict always contains patNum as key, but list can be empty.
                            }
                            if (!AddFinanceCharge(patAgingCur.PatNum, date, textAPR.Text, textAtLeast.Text, textOver.Text, overallBalance, patAgingCur.PriProv, adjType))
                            {
                                return;
                            }
                        }
                        chargesAdded++;
                    }));
                }
                ODThread.RunParallel(listActions, TimeSpan.FromMinutes(2));               //each group of actions gets X minutes.
                if (radioFinanceCharge.Checked)
                {
                    if (Prefs.UpdateString(PrefName.FinanceChargeAPR, textAPR.Text)
                        | Prefs.UpdateString(PrefName.FinanceChargeLastRun, POut.Date(date, false))
                        | Prefs.UpdateString(PrefName.FinanceChargeAtLeast, textAtLeast.Text)
                        | Prefs.UpdateString(PrefName.FinanceChargeOnlyIfOver, textOver.Text)
                        | Prefs.UpdateString(PrefName.BillingChargeOrFinanceIsDefault, "Finance"))
                    {
                        DataValid.SetInvalid(InvalidType.Prefs);
                    }
                }
                else if (radioBillingCharge.Checked)
                {
                    if (Prefs.UpdateString(PrefName.BillingChargeAmount, textBillingCharge.Text)
                        | Prefs.UpdateString(PrefName.BillingChargeLastRun, POut.Date(date, false))
                        | Prefs.UpdateString(PrefName.BillingChargeOrFinanceIsDefault, "Billing"))
                    {
                        DataValid.SetInvalid(InvalidType.Prefs);
                    }
                }
            }
            finally {
                actionCloseProgress?.Invoke();                //terminates progress bar
            }
            MessageBox.Show(Lan.g(this, chargeType + " charges added") + ": " + chargesAdded);
            if (PrefC.GetBool(PrefName.AgingIsEnterprise))
            {
                if (!RunAgingEnterprise())
                {
                    MsgBox.Show(this, "There was an error calculating aging after the " + chargeType.ToLower() + " charge adjustments were added.\r\n"
                                + "You should run aging later to update affected accounts.");
                }
            }
            else
            {
                DateTime asOfDate = (PrefC.GetBool(PrefName.AgingCalculatedMonthlyInsteadOfDaily)?PrefC.GetDate(PrefName.DateLastAging):DateTime.Today);
                actionCloseProgress = ODProgressOld.ShowProgressStatus("FinanceCharge", this, Lan.g(this, "Calculating aging for all patients as of") + " "
                                                                       + asOfDate.ToShortDateString() + "...");
                Cursor = Cursors.WaitCursor;
                try {
                    Ledgers.RunAging();
                }
                catch (MySqlException ex) {
                    actionCloseProgress?.Invoke();                    //terminates progress bar
                    Cursor = Cursors.Default;
                    if (ex == null || ex.Number != 1213)              //not a deadlock error, just throw
                    {
                        throw;
                    }
                    MsgBox.Show(this, "There was a deadlock error calculating aging after the " + chargeType.ToLower() + " charge adjustments were added.\r\n"
                                + "You should run aging later to update affected accounts.");
                }
                finally {
                    actionCloseProgress?.Invoke();                    //terminates progress bar
                    Cursor = Cursors.Default;
                }
            }
            DialogResult = DialogResult.OK;
        }
コード例 #6
0
        private void butUndo_Click(object sender, EventArgs e)
        {
            string chargeType = (radioFinanceCharge.Checked?"Finance":"Billing");

            if (MessageBox.Show(Lan.g(this, "Undo all " + chargeType.ToLower() + " charges for") + " " + textDateUndo.Text + "?", "", MessageBoxButtons.OKCancel)
                != DialogResult.OK)
            {
                return;
            }
            Action actionCloseProgress = null;
            int    rowsAffected        = 0;

            try {
                actionCloseProgress = ODProgressOld.ShowProgressStatus(chargeType + "Charge", this,
                                                                       Lan.g(this, "Deleting " + chargeType.ToLower() + " charge adjustments") + "...");
                Cursor       = Cursors.WaitCursor;
                rowsAffected = (int)Adjustments.UndoFinanceOrBillingCharges(PIn.Date(textDateUndo.Text), radioBillingCharge.Checked);
            }
            finally {
                actionCloseProgress?.Invoke();                //effectively terminates progress bar
                Cursor = Cursors.Default;
            }
            MessageBox.Show(Lan.g(this, chargeType + " charge adjustments deleted") + ": " + rowsAffected);
            if (rowsAffected == 0)
            {
                DialogResult = DialogResult.OK;
                return;
            }
            actionCloseProgress = null;
            if (PrefC.GetBool(PrefName.AgingIsEnterprise))
            {
                if (!RunAgingEnterprise())
                {
                    MsgBox.Show(this, "There was an error calculating aging after the " + chargeType.ToLower() + " charge adjustments were deleted.\r\n"
                                + "You should run aging later to update affected accounts.");
                }
            }
            else
            {
                try {
                    DateTime asOfDate = (PrefC.GetBool(PrefName.AgingCalculatedMonthlyInsteadOfDaily)?PrefC.GetDate(PrefName.DateLastAging):DateTime.Today);
                    actionCloseProgress = ODProgressOld.ShowProgressStatus("FinanceCharge", this, Lan.g(this, "Calculating aging for all patients as of") + " "
                                                                           + asOfDate.ToShortDateString() + "...");
                    Cursor = Cursors.WaitCursor;
                    Ledgers.RunAging();
                }
                catch (MySqlException ex) {
                    actionCloseProgress?.Invoke();                    //effectively terminates progress bar
                    Cursor = Cursors.Default;
                    if (ex == null || ex.Number != 1213)              //not a deadlock error, just throw
                    {
                        throw;
                    }
                    MsgBox.Show(this, "There was a deadlock error calculating aging after the " + chargeType.ToLower() + " charge adjustments were deleted.\r\n"
                                + "You should run aging later to update affected accounts.");
                }
                finally {
                    actionCloseProgress?.Invoke();                    //effectively terminates progress bar
                    Cursor = Cursors.Default;
                }
            }
            SecurityLogs.MakeLogEntry(Permissions.Setup, 0, chargeType + " Charges undo. Date " + textDateUndo.Text);
            DialogResult = DialogResult.OK;
        }
コード例 #7
0
        private void FormFinanceCharges_Load(object sender, System.EventArgs e)
        {
            if (PrefC.GetLong(PrefName.FinanceChargeAdjustmentType) == 0)
            {
                MsgBox.Show(this, "No finance charge adjustment type has been set.  Please go to Setup | Account to fix this.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (PrefC.GetLong(PrefName.BillingChargeAdjustmentType) == 0)
            {
                MsgBox.Show(this, "No billing charge adjustment type has been set.  Please go to Setup | Account to fix this.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            _listBillingTypeDefs = Defs.GetDefsForCategory(DefCat.BillingTypes, true);
            if (_listBillingTypeDefs.Count == 0)          //highly unlikely that this would happen
            {
                MsgBox.Show(this, "No billing types have been set up or are visible.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            Action actionCloseAgingProgress = null;

            if (PrefC.GetBool(PrefName.AgingIsEnterprise))
            {
                if (!RunAgingEnterprise(true))
                {
                    DialogResult = DialogResult.Cancel;
                    return;
                }
            }
            else
            {
                try {
                    DateTime asOfDate = (PrefC.GetBool(PrefName.AgingCalculatedMonthlyInsteadOfDaily)?PrefC.GetDate(PrefName.DateLastAging):DateTime.Today);
                    actionCloseAgingProgress = ODProgressOld.ShowProgressStatus("ComputeAging", this, Lan.g(this, "Calculating aging for all patients as of") + " "
                                                                                + asOfDate.ToShortDateString() + "...");
                    Cursor = Cursors.WaitCursor;
                    Ledgers.RunAging();
                }
                catch (MySqlException ex) {
                    actionCloseAgingProgress?.Invoke();                  //effectively terminates progress bar
                    Cursor = Cursors.Default;
                    if (ex == null || ex.Number != 1213)                 //not a deadlock error, just throw
                    {
                        throw;
                    }
                    MsgBox.Show(this, "Deadlock error detected in aging transaction and rolled back. Try again later.");
                    DialogResult = DialogResult.Cancel;
                    return;
                }
                finally {
                    actionCloseAgingProgress?.Invoke();                    //effectively terminates progress bar
                    Cursor = Cursors.Default;
                }
            }
            textDate.Text          = DateTime.Today.ToShortDateString();
            textAPR.MaxVal         = 100;
            textAPR.MinVal         = 0;
            textAPR.Text           = PrefC.GetString(PrefName.FinanceChargeAPR);
            textBillingCharge.Text = PrefC.GetString(PrefName.BillingChargeAmount);
            for (int i = 0; i < _listBillingTypeDefs.Count; i++)
            {
                listBillType.Items.Add(_listBillingTypeDefs[i].ItemName);
                listBillType.SetSelected(i, true);
            }
            string defaultChargeMethod = PrefC.GetString(PrefName.BillingChargeOrFinanceIsDefault);

            if (defaultChargeMethod == "Finance")
            {
                radioFinanceCharge.Checked  = true;
                textDateLastRun.Text        = PrefC.GetDate(PrefName.FinanceChargeLastRun).ToShortDateString();
                textDateUndo.Text           = PrefC.GetDate(PrefName.FinanceChargeLastRun).ToShortDateString();
                textBillingCharge.ReadOnly  = true;
                textBillingCharge.BackColor = System.Drawing.SystemColors.Control;
            }
            else if (defaultChargeMethod == "Billing")
            {
                radioBillingCharge.Checked = true;
                textDateLastRun.Text       = PrefC.GetDate(PrefName.BillingChargeLastRun).ToShortDateString();
                textDateUndo.Text          = PrefC.GetDate(PrefName.BillingChargeLastRun).ToShortDateString();
            }
            textAtLeast.Text = PrefC.GetString(PrefName.FinanceChargeAtLeast);
            textOver.Text    = PrefC.GetString(PrefName.FinanceChargeOnlyIfOver);
        }