Exemple #1
0
        private void butPrint_Click(object sender, System.EventArgs e)
        {
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (IsNew)
            {
                if (!SaveToDB())
                {
                    return;
                }
            }
            else             //not new
                             //Only allowed to change date and bank account info, NOT attached checks.
                             //We enforce security here based on date displayed, not date entered.
                             //If user is trying to change date without permission:
            {
                DateTime date = PIn.PDate(textDate.Text);
                if (Security.IsAuthorized(Permissions.DepositSlips, date, true))
                {
                    if (!SaveToDB())
                    {
                        return;
                    }
                }
                //if security.NotAuthorized, then it simply skips the save process before printing
            }
            //refresh the lists because some items may not be highlighted
            PatPayList     = Payments.GetForDeposit(DepositCur.DepositNum);
            ClaimPayList   = ClaimPayments.GetForDeposit(DepositCur.DepositNum);
            Queries.TableQ = new DataTable();
            for (int i = 0; i < 5; i++)                                   //add 5 columns
            {
                Queries.TableQ.Columns.Add(new System.Data.DataColumn()); //blank columns
            }
            Queries.CurReport          = new ReportOld();
            Queries.CurReport.ColTotal = new double[Queries.TableQ.Columns.Count];
            DataRow   row;
            ArrayList patNumAL = new ArrayList();

            for (int i = 0; i < PatPayList.Length; i++)
            {
                patNumAL.Add(PatPayList[i].PatNum);
            }
            int[] patNums = new int[patNumAL.Count];
            patNumAL.CopyTo(patNums);
            Patient[] pats = Patients.GetMultPats(patNums);
            for (int i = 0; i < PatPayList.Length; i++)
            {
                row    = Queries.TableQ.NewRow();
                row[0] = PatPayList[i].PayDate.ToShortDateString();
                row[1] = Patients.GetOnePat(pats, PatPayList[i].PatNum).GetNameLF();
                row[2] = PatPayList[i].CheckNum;
                row[3] = PatPayList[i].BankBranch;
                row[4] = PatPayList[i].PayAmt.ToString("F");
                Queries.TableQ.Rows.Add(row);
                Queries.CurReport.ColTotal[4] += PatPayList[i].PayAmt;
            }
            for (int i = 0; i < ClaimPayList.Length; i++)
            {
                row    = Queries.TableQ.NewRow();
                row[0] = ClaimPayList[i].CheckDate.ToShortDateString();
                row[1] = ClaimPayList[i].CarrierName;
                row[2] = ClaimPayList[i].CheckNum;
                row[3] = ClaimPayList[i].BankBranch;
                row[4] = ClaimPayList[i].CheckAmt.ToString("F");
                Queries.TableQ.Rows.Add(row);
                Queries.CurReport.ColTotal[4] += ClaimPayList[i].CheckAmt;
            }
            //done filling now set up table
            Queries.CurReport.ColWidth   = new int[Queries.TableQ.Columns.Count];
            Queries.CurReport.ColPos     = new int[Queries.TableQ.Columns.Count + 1];
            Queries.CurReport.ColPos[0]  = 0;
            Queries.CurReport.ColCaption = new string[Queries.TableQ.Columns.Count];
            Queries.CurReport.ColAlign   = new HorizontalAlignment[Queries.TableQ.Columns.Count];
            FormQuery FormQuery2 = new FormQuery();

            FormQuery2.IsReport = true;
            FormQuery2.ResetGrid();            //necessary won't work without
            Queries.CurReport.Title         = "Deposit Slip";
            Queries.CurReport.SubTitle      = new string[2];
            Queries.CurReport.SubTitle[0]   = ((Pref)PrefB.HList["PracticeTitle"]).ValueString;
            Queries.CurReport.SubTitle[1]   = DepositCur.DateDeposit.ToShortDateString();
            Queries.CurReport.Summary       = new string[1];
            Queries.CurReport.Summary[0]    = DepositCur.BankAccountInfo;
            Queries.CurReport.ColPos[0]     = 20;
            Queries.CurReport.ColPos[1]     = 110;
            Queries.CurReport.ColPos[2]     = 260;
            Queries.CurReport.ColPos[3]     = 350;
            Queries.CurReport.ColPos[4]     = 440;
            Queries.CurReport.ColPos[5]     = 530;
            Queries.CurReport.ColCaption[0] = "Date";
            Queries.CurReport.ColCaption[1] = "Name";
            Queries.CurReport.ColCaption[2] = "Check Number";
            Queries.CurReport.ColCaption[3] = "Bank-Branch";
            Queries.CurReport.ColCaption[4] = "Amount";
            Queries.CurReport.ColAlign[4]   = HorizontalAlignment.Right;
            FormQuery2.ShowDialog();
            DialogResult = DialogResult.OK;          //this is imporant, since we don't want to insert the deposit slip twice.
        }
Exemple #2
0
        ///<summary></summary>
        private void FillGrids()
        {
            if (IsNew)
            {
                DateTime dateStart = PIn.PDate(textDateStart.Text);
                int      clinicNum = 0;
                if (comboClinic.SelectedIndex != 0)
                {
                    clinicNum = Clinics.List[comboClinic.SelectedIndex - 1].ClinicNum;
                }
                int[] payTypes = new int[listPayType.SelectedIndices.Count];
                for (int i = 0; i < payTypes.Length; i++)
                {
                    payTypes[i] = DefB.Short[(int)DefCat.PaymentTypes][listPayType.SelectedIndices[i]].DefNum;
                }
                PatPayList   = Payments.GetForDeposit(dateStart, clinicNum, payTypes);
                ClaimPayList = ClaimPayments.GetForDeposit(dateStart, clinicNum);
            }
            else
            {
                PatPayList   = Payments.GetForDeposit(DepositCur.DepositNum);
                ClaimPayList = ClaimPayments.GetForDeposit(DepositCur.DepositNum);
            }
            //Fill Patient Payment Grid---------------------------------------
            ArrayList patNumAL = new ArrayList();

            for (int i = 0; i < PatPayList.Length; i++)
            {
                patNumAL.Add(PatPayList[i].PatNum);
            }
            int[] patNums = new int[patNumAL.Count];
            patNumAL.CopyTo(patNums);
            Patient[] pats = Patients.GetMultPats(patNums);
            gridPat.BeginUpdate();
            gridPat.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableDepositSlipPat", "Date"), 80);

            gridPat.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlipPat", "Patient"), 130);
            gridPat.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlipPat", "Type"), 90);
            gridPat.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlipPat", "Check Number"), 95);
            gridPat.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlipPat", "Bank-Branch"), 80);
            gridPat.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlipPat", "Amount"), 80);
            gridPat.Columns.Add(col);
            gridPat.Rows.Clear();
            OpenDental.UI.ODGridRow row;
            for (int i = 0; i < PatPayList.Length; i++)
            {
                row = new OpenDental.UI.ODGridRow();
                row.Cells.Add(PatPayList[i].PayDate.ToShortDateString());
                row.Cells.Add(Patients.GetOnePat(pats, PatPayList[i].PatNum).GetNameLF());
                row.Cells.Add(DefB.GetName(DefCat.PaymentTypes, PatPayList[i].PayType));
                row.Cells.Add(PatPayList[i].CheckNum);
                row.Cells.Add(PatPayList[i].BankBranch);
                row.Cells.Add(PatPayList[i].PayAmt.ToString("F"));
                gridPat.Rows.Add(row);
            }
            gridPat.EndUpdate();
            //Fill Insurance Payment Grid-------------------------------------
            gridIns.BeginUpdate();
            gridIns.Columns.Clear();
            col = new ODGridColumn(Lan.g("TableDepositSlipIns", "Date"), 80);
            gridIns.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlipIns", "Carrier"), 220);
            gridIns.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlipIns", "Check Number"), 95);
            gridIns.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlipIns", "Bank-Branch"), 80);
            gridIns.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDepositSlipIns", "Amount"), 90);
            gridIns.Columns.Add(col);
            gridIns.Rows.Clear();
            for (int i = 0; i < ClaimPayList.Length; i++)
            {
                row = new OpenDental.UI.ODGridRow();
                row.Cells.Add(ClaimPayList[i].CheckDate.ToShortDateString());
                row.Cells.Add(ClaimPayList[i].CarrierName);
                row.Cells.Add(ClaimPayList[i].CheckNum);
                row.Cells.Add(ClaimPayList[i].BankBranch);
                row.Cells.Add(ClaimPayList[i].CheckAmt.ToString("F"));
                gridIns.Rows.Add(row);
            }
            gridIns.EndUpdate();
        }