Exemple #1
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableChartOfAccounts", "Type"), 70);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableChartOfAccounts", "Description"), 170);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableChartOfAccounts", "Balance"), 65, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableChartOfAccounts", "Bank Number"), 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableChartOfAccounts", "Inactive"), 70);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow      row;
            List <Account> listAccounts = Accounts.GetDeepCopy(false);

            for (int i = 0; i < listAccounts.Count; i++)
            {
                if (!checkInactive.Checked && listAccounts[i].Inactive)
                {
                    continue;
                }
                row = new ODGridRow();
                row.Cells.Add(Lan.g("enumAccountType", listAccounts[i].AcctType.ToString()));
                row.Cells.Add(listAccounts[i].Description);
                if (listAccounts[i].AcctType == AccountType.Asset)
                {
                    row.Cells.Add(Accounts.GetBalance(listAccounts[i].AccountNum, listAccounts[i].AcctType).ToString("n"));
                }
                else
                {
                    row.Cells.Add("");
                }
                row.Cells.Add(listAccounts[i].BankNumber);
                if (listAccounts[i].Inactive)
                {
                    row.Cells.Add("X");
                }
                else
                {
                    row.Cells.Add("");
                }
                if (i < listAccounts.Count - 1 &&        //if not the last row
                    listAccounts[i].AcctType != listAccounts[i + 1].AcctType)
                {
                    row.ColorLborder = Color.Black;
                }
                row.Tag        = listAccounts[i].Clone();
                row.ColorBackG = listAccounts[i].AccountColor;
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #2
0
        private void FormGraphics_Load(object sender, EventArgs e)
        {
            gridFormats.BeginUpdate();
            gridFormats.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g(this, "FormatNum"), 80);

            gridFormats.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "OpenGL"), 60);
            gridFormats.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Windowed"), 80);
            gridFormats.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Bitmapped"), 80);
            gridFormats.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Palette"), 75);
            gridFormats.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Accelerated"), 80);
            gridFormats.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Buffered"), 75);
            gridFormats.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "ColorBits"), 75);
            gridFormats.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "DepthBits"), 75);
            gridFormats.Columns.Add(col);
            gridFormats.EndUpdate();
            if (Environment.OSVersion.Platform == PlatformID.Unix)           //Force simple mode on Unix systems.
            {
                MsgBox.Show(this, "Linux users must use simple graphics mode.");
                radio3DChart.Enabled      = false;
                group3DToothChart.Enabled = false;
                return;
            }
            ComputerPref computerPref = ComputerPrefs.GetForLocalComputer();

            if (computerPref.GraphicsSimple)
            {
                radioSimpleChart.Checked  = true;
                group3DToothChart.Enabled = false;
            }
            else
            {
                radio3DChart.Checked = true;
            }
            checkHardwareAccel.Checked   = computerPref.GraphicsUseHardware;
            checkDoubleBuffering.Checked = computerPref.GraphicsDoubleBuffering;
            selectedFormatNum            = computerPref.PreferredPixelFormatNum;
            textSelected.Text            = selectedFormatNum.ToString();
            RefreshFormats();
        }
        private void FillGrid()
        {
            //does not refresh from database.
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g("TableLabTurnaround", "Service Description"), 300);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableLabTurnaround", "Days Published"), 120);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableLabTurnaround", "Actual Days"), 120);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow row;

            for (int i = 0; i < turnaroundList.Count; i++)
            {
                row = new GridRow();
                row.Cells.Add(turnaroundList[i].Description);
                if (turnaroundList[i].DaysPublished == 0)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(turnaroundList[i].DaysPublished.ToString());
                }
                row.Cells.Add(turnaroundList[i].DaysActual.ToString());
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #4
0
        private void FillGrid()
        {
            SecurityLog[] logList = SecurityLogs.Refresh(PatNum, PermTypes, FKey);
            grid.BeginUpdate();
            grid.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn(Lan.g("TableAudit", "Date Time"), 120);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "User"), 70);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "Permission"), 110);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "Log Text"), 569);
            grid.Columns.Add(col);
            grid.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < logList.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(logList[i].LogDateTime.ToShortDateString() + " " + logList[i].LogDateTime.ToShortTimeString());
                row.Cells.Add(Userods.GetUser(logList[i].UserNum).UserName);
                row.Cells.Add(logList[i].PermType.ToString());
                row.Cells.Add(logList[i].LogText);
                grid.Rows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollToEnd();
        }
        private void FillGrid()
        {
            AutomationConditions.RefreshCache();
            autoList = AutomationConditions.GetListByAutomationNum(AutoCur.AutomationNum);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("AutomationCondition", "Field"), 200);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("AutomationCondition", "Comparison"), 75);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("AutomationCondition", "Text"), 100);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < autoList.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(autoList[i].CompareField.ToString());
                row.Cells.Add(autoList[i].Comparison.ToString());
                row.Cells.Add(autoList[i].CompareString);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
        private void FillMeds()
        {
            Medications.Refresh();
            MedicationPats.Refresh(PatCur.PatNum);
            gridMeds.BeginUpdate();
            gridMeds.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableMedications", "Drug Name"), 100);

            gridMeds.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableMedications", "Generic Name"), 100);
            gridMeds.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableMedications", "Notes"), 370);
            gridMeds.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableMedications", "Notes for Patient"), 370);
            gridMeds.Columns.Add(col);
            gridMeds.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < MedicationPats.List.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(Medications.GetMedication(MedicationPats.List[i].MedicationNum).MedName);
                row.Cells.Add(Medications.GetGeneric(MedicationPats.List[i].MedicationNum).MedName);
                row.Cells.Add(Medications.GetGeneric(MedicationPats.List[i].MedicationNum).Notes);
                row.Cells.Add(MedicationPats.List[i].PatNote);
                gridMeds.Rows.Add(row);
            }
            gridMeds.EndUpdate();
        }
        private void FillGrid()
        {
            AnesthMedSuppliers.RefreshCache();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            textAlign = HorizontalAlignment.Center;
            ODGridColumn col = new ODGridColumn(Lan.g(this, "SupplierName"), 200, textAlign);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Phone"), 100, textAlign);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Fax"), 100, textAlign);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "City"), 140, textAlign);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "State"), 160, textAlign);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "WebSite"), 140, textAlign);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < AnesthMedSupplierC.Listt.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(AnesthMedSupplierC.Listt[i].SupplierName);
                row.Cells.Add(AnesthMedSupplierC.Listt[i].Phone);
                row.Cells.Add(AnesthMedSupplierC.Listt[i].Fax);
                row.Cells.Add(AnesthMedSupplierC.Listt[i].City);
                row.Cells.Add(AnesthMedSupplierC.Listt[i].State);
                row.Cells.Add(AnesthMedSupplierC.Listt[i].WebSite);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableProviders", "Abbrev"), 90);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableProviders", "Last Name"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableProviders", "First Name"), 90);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < ProviderC.ListShort.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(ProviderC.ListShort[i].Abbr);
                row.Cells.Add(ProviderC.ListShort[i].LName);
                row.Cells.Add(ProviderC.ListShort[i].FName);
                //wanted to do a background color here, but grid couldn't handle it.
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
        private void FillUsers()
        {
            UserGroups.Refresh();
            Userods.Refresh();
            SelectedGroupNum = 0;
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableSecurity", "Username"), 90);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableSecurity", "Group"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableSecurity", "Employee"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableSecurity", "Provider"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableSecurity", "Clinic"), 90);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;
            string    usertype = "all";

            if (comboUsers.SelectedIndex == 1)
            {
                usertype = "prov";
            }
            if (comboUsers.SelectedIndex == 2)
            {
                usertype = "emp";
            }
            if (comboUsers.SelectedIndex == 3)
            {
                usertype = "other";
            }
            int classNum = 0;

            if (comboSchoolClass.Visible && comboSchoolClass.SelectedIndex > 0)
            {
                classNum = SchoolClasses.List[comboSchoolClass.SelectedIndex - 1].SchoolClassNum;
            }
            table = Userods.RefreshSecurity(usertype, classNum);
            string userdesc;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                row      = new ODGridRow();
                userdesc = table.Rows[i]["UserName"].ToString();
                if (table.Rows[i]["IsHidden"].ToString() == "1")
                {
                    userdesc += Lan.g(this, "(hidden)");
                }
                row.Cells.Add(userdesc);
                row.Cells.Add(UserGroups.GetGroup(PIn.PInt(table.Rows[i]["UserGroupNum"].ToString())).Description);
                row.Cells.Add(Employees.GetNameFL(PIn.PInt(table.Rows[i]["EmployeeNum"].ToString())));
                row.Cells.Add(Providers.GetNameLF(PIn.PInt(table.Rows[i]["ProvNum"].ToString())));
                row.Cells.Add(Clinics.GetDesc(PIn.PInt(table.Rows[i]["ClinicNum"].ToString())));
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #10
0
        private void FillGrid()
        {
            table = RegistrationKeys.GetAllWithoutCharges();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Family", 160);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("RegKey", 140);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Repeating Charge", 150);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(table.Rows[i]["family"].ToString());
                row.Cells.Add(table.Rows[i]["RegKey"].ToString());
                row.Cells.Add(table.Rows[i]["dateStop"].ToString());
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
        private void FillGrid()
        {
            RxDefList = RxDefs.Refresh();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableRxSetup", "Drug"), 140);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRxSetup", "Sig"), 320);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRxSetup", "Disp"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRxSetup", "Refills"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRxSetup", "Notes"), 300);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < RxDefList.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(RxDefList[i].Drug);
                row.Cells.Add(RxDefList[i].Sig);
                row.Cells.Add(RxDefList[i].Disp);
                row.Cells.Add(RxDefList[i].Refills);
                row.Cells.Add(RxDefList[i].Notes);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #12
0
        private void FillGrid()
        {
            AppointmentRules.RefreshCache();
            _listAppointmentRules = AppointmentRules.GetDeepCopy();
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn("Description", 200);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Start Code", 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("End Code", 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Enabled", 50, HorizontalAlignment.Center);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            UI.GridRow row;
            for (int i = 0; i < _listAppointmentRules.Count; i++)
            {
                row = new OpenDental.UI.GridRow();
                row.Cells.Add(_listAppointmentRules[i].RuleDesc);
                row.Cells.Add(_listAppointmentRules[i].CodeStart);
                row.Cells.Add(_listAppointmentRules[i].CodeEnd);
                if (_listAppointmentRules[i].IsEnabled)
                {
                    row.Cells.Add("X");
                }
                else
                {
                    row.Cells.Add("");
                }
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
        private void FillGrid()
        {
            Employees.Refresh();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("FormEmployeeSelect", "FName"), 75);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormEmployeeSelect", "LName"), 75);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormEmployeeSelect", "MiddleI"), 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormEmployeeSelect", "Hidden"), 50, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < Employees.ListLong.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(Employees.ListLong[i].FName);
                row.Cells.Add(Employees.ListLong[i].LName);
                row.Cells.Add(Employees.ListLong[i].MiddleI);
                if (Employees.ListLong[i].IsHidden)
                {
                    row.Cells.Add("X");
                }
                else
                {
                    row.Cells.Add("");
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
        ///<summary>This does not make any calls to db (except one tiny one).  Simply refreshes screen for SplitList.</summary>
        private void FillMain()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("FormProviderIncTrans", "Date"), 70);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormProviderIncTrans", "Prov"), 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormProviderIncTrans", "Patient"), 130);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormProviderIncTrans", "Amount"), 60, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;
            Procedure proc;

            for (int i = 0; i < SplitList.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(SplitList[i].ProcDate.ToShortDateString());
                row.Cells.Add(Providers.GetAbbr(SplitList[i].ProvNum));
                row.Cells.Add(FamCur.GetNameInFamFL(SplitList[i].PatNum));
                row.Cells.Add(SplitList[i].SplitAmt.ToString("F"));
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            FillGridBal();
        }
Exemple #15
0
        private void FillGrid()
        {
            medList = Medications.GetList(textSearch.Text);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Drug Name"), 120);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Generic Name"), 120);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Notes for Generic"), 250);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < medList.Count; i++)
            {
                row = new ODGridRow();
                if (medList[i].MedicationNum == medList[i].GenericNum)               //isGeneric
                {
                    row.Cells.Add(medList[i].MedName);
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(medList[i].MedName);
                    row.Cells.Add(Medications.GetGenericName(medList[i].GenericNum));
                }
                row.Cells.Add(medList[i].Notes);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
        private void FillGrid()
        {
            InsFilingCodes.RefreshCache();
            _listInsFilingCodes = InsFilingCodes.GetDeepCopy();
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g("TableInsFilingCodes", "Description"), 250);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsFilingCodes", "Group"), 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsFilingCodes", "EclaimCode"), 100);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow row;

            for (int i = 0; i < _listInsFilingCodes.Count; i++)
            {
                row = new GridRow();
                row.Cells.Add(_listInsFilingCodes[i].Descript);
                string group = "";
                if (_listInsFilingCodes[i].GroupType > 0)
                {
                    group = Defs.GetDef(DefCat.InsuranceFilingCodeGroup, _listInsFilingCodes[i].GroupType)?.ItemName ?? "";
                }
                row.Cells.Add(group);
                row.Cells.Add(_listInsFilingCodes[i].EclaimCode);
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
        private void FillGrid()
        {
            table = ReqStudents.RefreshOneStudent(ProvNum);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableReqStudentOne", "Course"), 100);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableReqStudentOne", "Requirement"), 200);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableReqStudentOne", "Done"), 40);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableReqStudentOne", "Patient"), 140);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableReqStudentOne", "Appointment"), 190);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(table.Rows[i]["course"].ToString());
                row.Cells.Add(table.Rows[i]["requirement"].ToString());
                row.Cells.Add(table.Rows[i]["done"].ToString());
                row.Cells.Add(table.Rows[i]["patient"].ToString());
                row.Cells.Add(table.Rows[i]["appointment"].ToString());
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
        private void FillFees()
        {
            //This line will be added later for speed:
            //DataTable feeList=Fees.GetListForCode(ProcCode.ADACode);
            gridFees.BeginUpdate();
            gridFees.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableProcFee", "Sched"), 120);

            gridFees.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableProcFee", "Amount"), 60, HorizontalAlignment.Right);
            gridFees.Columns.Add(col);
            gridFees.Rows.Clear();
            ODGridRow row;
            Fee       fee;

            for (int i = 0; i < DefB.Short[(int)DefCat.FeeSchedNames].Length; i++)
            {
                fee = Fees.GetFeeByOrder(ProcCode.ADACode, i);
                row = new ODGridRow();
                row.Cells.Add(DefB.Short[(int)DefCat.FeeSchedNames][i].ItemName);
                if (fee == null)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(fee.Amount.ToString("n"));
                }
                gridFees.Rows.Add(row);
            }
            gridFees.EndUpdate();
        }
Exemple #19
0
        private void FillStudents()
        {
            if (comboClass.SelectedIndex == -1)
            {
                return;
            }
            long schoolClass = _listSchoolClasses[comboClass.SelectedIndex].SchoolClassNum;

            //int schoolCourse=SchoolCourses.List[comboCourse.SelectedIndex].SchoolCourseNum;
            StudentList = ReqStudents.GetStudents(schoolClass);
            gridStudents.BeginUpdate();
            gridStudents.Columns.Clear();
            ODGridColumn col = new ODGridColumn("", 100);

            gridStudents.Columns.Add(col);
            gridStudents.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < StudentList.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(StudentList[i].LName + ", " + StudentList[i].FName);
                gridStudents.Rows.Add(row);
            }
            gridStudents.EndUpdate();
        }
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g(this, "Date"), 100);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Category"), 120);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Description"), 300);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow row;

            Docs = Documents.GetAllWithPat(PatNum);
            for (int i = 0; i < Docs.Length; i++)
            {
                row = new GridRow();
                row.Cells.Add(Docs[i].DateCreated.ToString());
                row.Cells.Add(Defs.GetName(DefCat.ImageCats, Docs[i].DocCategory));
                row.Cells.Add(Docs[i].Description);
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #21
0
        private void FillGrid()
        {
            PayPeriods.RefreshCache();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Start Date", 80);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("End Date", 80);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Paycheck Date", 100);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            UI.ODGridRow row;
            for (int i = 0; i < PayPeriods.List.Length; i++)
            {
                row = new OpenDental.UI.ODGridRow();
                row.Cells.Add(PayPeriods.List[i].DateStart.ToShortDateString());
                row.Cells.Add(PayPeriods.List[i].DateStop.ToShortDateString());
                if (PayPeriods.List[i].DatePaycheck.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(PayPeriods.List[i].DatePaycheck.ToShortDateString());
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #22
0
        private void FillGrid()
        {
            RecallTypes.RefreshCache();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableRecallTypes", "Description"), 110);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallTypes", "Special Type"), 110);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallTypes", "Triggers"), 190);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallTypes", "Interval"), 60);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallTypes", "Time Pattern"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallTypes", "Procedures"), 190);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //string txt;
            for (int i = 0; i < RecallTypeC.Listt.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(RecallTypeC.Listt[i].Description);
                row.Cells.Add(RecallTypes.GetSpecialTypeStr(RecallTypeC.Listt[i].RecallTypeNum));
                row.Cells.Add(GetStringForType(RecallTypeC.Listt[i].RecallTypeNum));
                row.Cells.Add(RecallTypeC.Listt[i].DefaultInterval.ToString());
                row.Cells.Add(RecallTypeC.Listt[i].TimePattern);
                row.Cells.Add(RecallTypeC.Listt[i].Procedures);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
        private void FillGrid()
        {
            Cursor.Current = Cursors.WaitCursor;
            TableRegKeys   = RegistrationKeys.GetAllWithoutCharges();
            Cursor.Current = Cursors.Default;
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("PatNum", 60);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("RegKey", 140);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Family", 200);
            gridMain.Columns.Add(col);
            //col=new ODGridColumn("Repeating Charge",150);
            //gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < TableRegKeys.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(TableRegKeys.Rows[i]["PatNum"].ToString());
                row.Cells.Add(TableRegKeys.Rows[i]["RegKey"].ToString());
                row.Cells.Add(TableRegKeys.Rows[i]["LName"].ToString() + ", " + TableRegKeys.Rows[i]["FName"].ToString());
                //row.Cells.Add(table.Rows[i]["dateStop"].ToString());
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
        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();
        }
        private void FillGrid()
        {
            if (comboClass.SelectedIndex == -1 || comboCourse.SelectedIndex == -1)
            {
                return;
            }
            long schoolClass  = _listSchoolClasses[comboClass.SelectedIndex].SchoolClassNum;
            long schoolCourse = _listSchoolCourses[comboCourse.SelectedIndex].SchoolCourseNum;

            table = ReqStudents.RefreshManyStudents(schoolClass, schoolCourse);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableReqStudentMany", "Last"), 100);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableReqStudentMany", "First"), 100);
            gridMain.Columns.Add(col);
            //col=new ODGridColumn(Lan.g("TableReqStudentMany","Total"),50);
            //gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableReqStudentMany", "Done"), 50);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(table.Rows[i]["LName"].ToString());
                row.Cells.Add(table.Rows[i]["FName"].ToString());
                //row.Cells.Add(table.Rows[i]["totalreq"].ToString());
                row.Cells.Add(table.Rows[i]["donereq"].ToString());
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #26
0
        private void FillProblems()
        {
            DiseaseList = Diseases.Refresh(PatCur.PatNum);
            gridDiseases.BeginUpdate();
            gridDiseases.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableDiseases", "Name"), 140);        //total is about 325

            gridDiseases.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDiseases", "Patient Note"), 145);
            gridDiseases.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableDisease", "Status"), 40);
            gridDiseases.Columns.Add(col);
            gridDiseases.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < DiseaseList.Count; i++)
            {
                row = new ODGridRow();
                if (DiseaseList[i].DiseaseDefNum != 0)
                {
                    row.Cells.Add(DiseaseDefs.GetName(DiseaseList[i].DiseaseDefNum));
                }
                else
                {
                    row.Cells.Add(ICD9s.GetDescription(DiseaseList[i].ICD9Num));
                }
                row.Cells.Add(DiseaseList[i].PatNote);
                row.Cells.Add(DiseaseList[i].ProbStatus.ToString());
                gridDiseases.Rows.Add(row);
            }
            gridDiseases.EndUpdate();
        }
Exemple #27
0
        private void FillGrid()
        {
            AppointmentRules.Refresh();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Description", 200);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("Start Code", 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("End Code", 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Enabled", 50, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            UI.ODGridRow row;
            for (int i = 0; i < AppointmentRules.List.Length; i++)
            {
                row = new OpenDental.UI.ODGridRow();
                row.Cells.Add(AppointmentRules.List[i].RuleDesc);
                row.Cells.Add(AppointmentRules.List[i].ADACodeStart);
                row.Cells.Add(AppointmentRules.List[i].ADACodeEnd);
                if (AppointmentRules.List[i].IsEnabled)
                {
                    row.Cells.Add("X");
                }
                else
                {
                    row.Cells.Add("");
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #28
0
        private void FillGrid()
        {
            labCaseList = LabCases.GetForPat(PatNum, IsPlanned);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableLabCaseSelect", "Date Created"), 80);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableLabCaseSelect", "Lab"), 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableLabCaseSelect", "Phone"), 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableLabCaseSelect", "Instructions"), 200);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow  row;
            DateTime   dateCreated;
            Laboratory lab;

            for (int i = 0; i < labCaseList.Count; i++)
            {
                row         = new ODGridRow();
                dateCreated = labCaseList[i].DateTimeCreated;
                row.Cells.Add(dateCreated.ToString("ddd") + " " + dateCreated.ToShortDateString() + " " + dateCreated.ToShortTimeString());
                lab = Laboratories.GetOne(labCaseList[i].LaboratoryNum);
                row.Cells.Add(lab.Description);
                row.Cells.Add(lab.Phone);
                row.Cells.Add(labCaseList[i].Instructions);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #29
0
        private void FillGrid()
        {
            RefAttachList = RefAttaches.RefreshFiltered(PatNum, checkShowAll.Checked, ProcNum);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableRefList", "From/To"), 50);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Name"), 120);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Date"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Status"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Proc"), 120);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Note"), 200);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //Referral referral;
            for (int i = 0; i < RefAttachList.Count; i++)
            {
                row = new ODGridRow();
                if (RefAttachList[i].IsFrom)
                {
                    row.Cells.Add(Lan.g(this, "From"));
                }
                else
                {
                    row.Cells.Add(Lan.g(this, "To"));
                }
                row.Cells.Add(Referrals.GetNameFL(RefAttachList[i].ReferralNum));
                //referral=ReferralL.GetReferral(RefAttachList[i].ReferralNum);
                if (RefAttachList[i].RefDate.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(RefAttachList[i].RefDate.ToShortDateString());
                }
                row.Cells.Add(Lan.g("enumReferralToStatus", RefAttachList[i].RefToStatus.ToString()));
                if (RefAttachList[i].ProcNum == 0)
                {
                    row.Cells.Add("");
                }
                else
                {
                    Procedure proc = Procedures.GetOneProc(RefAttachList[i].ProcNum, false);
                    string    str  = Procedures.GetDescription(proc);
                    row.Cells.Add(str);
                }
                row.Cells.Add(RefAttachList[i].Note);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemple #30
0
        private void FillGrid()
        {
            int  sortedColumnIdx = gridMain.SortedByColumnIdx;
            bool isSortAsc       = gridMain.SortedIsAscending;

            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn("EmployeeNum", 80, GridSortingStrategy.AmountParse);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("EmpName", 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("IsGraphed", 65, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("HasColor", 60, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Queue", 65);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("PhoneExt", 55, GridSortingStrategy.AmountParse);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("StatusOverride", 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Notes", 250);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Private", 50, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Triage", 50, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            ListPED = PhoneEmpDefaults.Refresh();
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < ListPED.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(ListPED[i].EmployeeNum.ToString());
                row.Cells.Add(ListPED[i].EmpName);
                row.Cells.Add(ListPED[i].IsGraphed?"X":"");
                row.Cells.Add(ListPED[i].HasColor?"X":"");
                row.Cells.Add(ListPED[i].RingGroups.ToString());
                row.Cells.Add(ListPED[i].PhoneExt.ToString());
                if (ListPED[i].StatusOverride == PhoneEmpStatusOverride.None)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(ListPED[i].StatusOverride.ToString());
                }
                row.Cells.Add(ListPED[i].Notes);
                row.Cells.Add(ListPED[i].IsPrivateScreen?"X":"");
                row.Cells.Add(ListPED[i].IsTriageOperator?"X":"");
                row.Tag = ListPED[i];
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            gridMain.SortForced(sortedColumnIdx, isSortAsc);
        }
Exemple #31
0
			private void DrawGridHelper(Graphics g,int i) {
				if(listFields.SelectedIndices.Contains(i)) {
					_argsDF.pen=_argsDF.penRed;
					_argsDF.brush=_argsDF.brushRed;
				}
				else {
					_argsDF.pen=_argsDF.penBlack;
					_argsDF.brush=_argsDF.brushBlue;
				}
				List<DisplayField> Columns=SheetUtil.GetGridColumnsAvailable(SheetDefCur.SheetFieldDefs[i].FieldName);
				//fGrid.Columns=SheetGridDefs.GetColumnsAvailable(fGrid.GridType);
				ODGrid odGrid=new ODGrid();
				odGrid.Width=0;
				for(int c=0;c<Columns.Count;c++){
					odGrid.Width+=Columns[c].ColumnWidth;
				}
				odGrid.HideScrollBars=true;
				#region  Fill Grid
				odGrid.BeginUpdate();
				odGrid.Columns.Clear();
				ODGridColumn col;
				for(int c=0;c<Columns.Count;c++) {
					col=new ODGridColumn(Columns[c].Description,Columns[c].ColumnWidth);
					odGrid.Columns.Add(col);
				}
				ODGridRow row=new ODGridRow();//Add dummy row
				for(int c=0;c<Columns.Count;c++) {
					row.Cells.Add(" ");//add dummy row.
				}
				odGrid.Rows.Add(row);
				odGrid.EndUpdate();//Calls ComputeRows and ComputeColumns, meaning the RowHeights int[] has been filled.
				#endregion
				int yPosGrid=SheetDefCur.SheetFieldDefs[i].YPos;
				if(SheetDefCur.SheetFieldDefs[i].FieldName=="StatementPayPlan") {
					SizeF sSize=g.MeasureString("Payment Plans",new Font(FontFamily.GenericSansSerif,10,FontStyle.Bold));
					g.FillRectangle(Brushes.White,SheetDefCur.SheetFieldDefs[i].XPos,yPosGrid,odGrid.Width,odGrid.TitleHeight);
					g.DrawString("Payment Plans",new Font(FontFamily.GenericSansSerif,10,FontStyle.Bold),new SolidBrush(Color.Black),SheetDefCur.SheetFieldDefs[i].XPos+(SheetDefCur.SheetFieldDefs[i].Width-sSize.Width)/2,yPosGrid);
					yPosGrid+=odGrid.TitleHeight;
				}
				odGrid.PrintHeader(g,SheetDefCur.SheetFieldDefs[i].XPos,yPosGrid);
				yPosGrid+=odGrid.HeaderHeight;
				odGrid.PrintRow(0,g,SheetDefCur.SheetFieldDefs[i].XPos,yPosGrid,false,true);//a single dummy row.
				yPosGrid+=odGrid.RowHeights[0]+2;
				#region drawFooter
				if(SheetDefCur.SheetFieldDefs[i].FieldName=="StatementPayPlan") {
					RectangleF rf=new RectangleF(SheetDefCur.Width-SheetDefCur.SheetFieldDefs[i].Width-60,yPosGrid,SheetDefCur.SheetFieldDefs[i].Width,odGrid.TitleHeight);
					g.FillRectangle(Brushes.White,rf);
					StringFormat sf=new StringFormat();
					sf.Alignment=StringAlignment.Far;
					g.DrawString("Payment Plan Amount Due: "+"0.00",new Font(FontFamily.GenericSansSerif,10,FontStyle.Bold),new SolidBrush(Color.Black),rf,sf);
				}
				#endregion
				if(listFields.SelectedIndices.Contains(i)) {
					g.DrawRectangle(_argsDF.penRedThick,
						SheetDefCur.SheetFieldDefs[i].XPos,
						SheetDefCur.SheetFieldDefs[i].YPos,
						SheetDefCur.SheetFieldDefs[i].Width,
						SheetDefCur.SheetFieldDefs[i].Height);
				}
				//g.DrawRectangle(_argsDF.pen,SheetDefCur.SheetFieldDefs[i].XPos,SheetDefCur.SheetFieldDefs[i].YPos,
				//	SheetDefCur.SheetFieldDefs[i].Width,SheetDefCur.SheetFieldDefs[i].Height);
				//g.DrawString("Grid:"+SheetGridDefs.GetName(SheetDefCur.SheetFieldDefs[i].GridDef),Font,_argsDF.brush,SheetDefCur.SheetFieldDefs[i].XPos,SheetDefCur.SheetFieldDefs[i].YPos);
			}
Exemple #32
0
		public static void drawFieldGrid(SheetField field,Sheet sheet,Graphics g,XGraphics gx,Statement stmt=null,MedLab medLab=null) {
			_printMargin.Top=40;
			if(sheet.SheetType==SheetTypeEnum.MedLabResults) {
				_printMargin.Top=120;
			}
			UI.ODGrid odGrid=new UI.ODGrid();//Only used for measurements, also contains printing/drawing logic.
			odGrid.FontForSheets=new Font(field.FontName,field.FontSize,field.FontIsBold?FontStyle.Bold:FontStyle.Regular);
			int _yAdjCurRow=0;//used to adjust for Titles, Headers, Rows, and footers (all considered part of the same row).
			odGrid.Width=0;
			List<DisplayField> Columns=SheetUtil.GetGridColumnsAvailable(field.FieldName);
			foreach(DisplayField Col in Columns) {
				odGrid.Width+=Col.ColumnWidth;
			}
			odGrid.Height=field.Height;
			odGrid.HideScrollBars=true;
			odGrid.YPosField=field.YPos;
			odGrid.Title=field.FieldName;
			if(stmt!=null) {
				odGrid.Title+=(stmt.Intermingled?".Intermingled":".NotIntermingled");//Important for calculating heights.
			}
			odGrid.TopMargin=_printMargin.Top;
			odGrid.BottomMargin=_printMargin.Bottom;
			odGrid.PageHeight=sheet.HeightPage;
			DataTable Table=SheetUtil.GetDataTableForGridType(field.FieldName,stmt,medLab);
			#region  Fill Grid, Set Text Alignment
			odGrid.BeginUpdate();
			odGrid.Columns.Clear();
			ODGridColumn col;
			for(int i=0;i<Columns.Count;i++) {
				col=new ODGridColumn(Columns[i].Description,Columns[i].ColumnWidth);
				switch(field.FieldName+"."+Columns[i].InternalName) {//Unusual switch statement to differentiate similar column names in different grids.
					case "StatementMain.charges":
					case "StatementMain.credits":
					case "StatementMain.balance":
					case "StatementPayPlan.charges":
					case "StatementPayPlan.credits":
					case "StatementPayPlan.balance":
						col.TextAlign=HorizontalAlignment.Right;
						break;
					case "StatementAging.Age00to30":
					case "StatementAging.Age31to60":
					case "StatementAging.Age61to90":
					case "StatementAging.Age90plus":
					case "StatementEnclosed.AmountDue":
					case "StatementEnclosed.DateDue":
						col.TextAlign=HorizontalAlignment.Center;
						break;
					default:
						col.TextAlign=HorizontalAlignment.Left;
						break;
				}
				odGrid.Columns.Add(col);
			}
			ODGridRow row;
			for(int i=0;i<Table.Rows.Count;i++) {
				row=new ODGridRow();
				for(int c=0;c<Columns.Count;c++) {//Selectively fill columns from the dataTable into the odGrid.
					row.Cells.Add(Table.Rows[i][Columns[c].InternalName].ToString());
				}
				if(Table.Columns.Contains("PatNum")) {//Used for statments to determine account splitting.
					row.Tag=Table.Rows[i]["PatNum"].ToString();
				}
				odGrid.Rows.Add(row);
			}
			odGrid.EndUpdate(true);//Calls ComputeRows and ComputeColumns, meaning the RowHeights int[] has been filled.
			#endregion
			for(int i=0;i<odGrid.RowHeights.Length;i++) {
				if(_isPrinting
					&& (odGrid.PrintRows[i].YPos-_printMargin.Top<_yPosPrint //rows at the end of previous page
						|| odGrid.PrintRows[i].YPos-sheet.HeightPage+_printMargin.Bottom>_yPosPrint)) 
				{
					continue;//continue because we do not want to draw rows from other pages.
				}
				_yAdjCurRow=0;
				//if(odGrid.PrintRows[i].YPos<_yPosPrint
				//	|| odGrid.PrintRows[i].YPos-_yPosPrint>sheet.HeightPage) {
				//	continue;//skip rows on previous page and rows on next page.
				//}
				#region Draw Title
				if(odGrid.PrintRows[i].IsTitleRow) {
					switch(field.FieldName) {//Draw titles differently for different grids.
						case "StatementMain":
							Patient pat=Patients.GetPat(PIn.Long(Table.Rows[i]["PatNum"].ToString()));
							string patName="";
							if(pat!=null) {//should always be true
								patName=pat.GetNameFLnoPref();
							}
							if(gx==null) {
								g.FillRectangle(Brushes.White,field.XPos-10,odGrid.PrintRows[i].YPos-_yPosPrint,odGrid.Width,odGrid.TitleHeight);
								g.DrawString(patName,new Font("Arial",10,FontStyle.Bold),new SolidBrush(Color.Black),field.XPos-10,odGrid.PrintRows[i].YPos-_yPosPrint);
							}
							else {
								gx.DrawRectangle(Brushes.White,p(field.XPos-10),p(odGrid.PrintRows[i].YPos-_yPosPrint-1),p(odGrid.Width),p(odGrid.TitleHeight));
								using(Font _font=new Font("Arial",10,FontStyle.Bold)) {
									GraphicsHelper.DrawStringX(gx,Graphics.FromImage(new Bitmap(100,100)),(double)((1d)/p(1)),patName,new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),XBrushes.Black,new XRect(p(field.XPos-10),p(odGrid.PrintRows[i].YPos-_yPosPrint-1),p(300),p(100)),XStringAlignment.Near);
									//gx.DrawString(patName,new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),new SolidBrush(Color.Black),field.XPos-10,yPosGrid);
								}
							}
							break;
						case "StatementPayPlan":
							SizeF sSize=new SizeF();
							using(Graphics f= Graphics.FromImage(new Bitmap(100,100))) {//using graphics f because g is null when gx is not.
								sSize=f.MeasureString("Payment Plans",new Font("Arial",10,FontStyle.Bold));
							}
							if(gx==null) {
								g.FillRectangle(Brushes.White,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint,odGrid.Width,odGrid.TitleHeight);
								g.DrawString("Payment Plans",new Font("Arial",10,FontStyle.Bold),new SolidBrush(Color.Black),field.XPos+(field.Width-sSize.Width)/2,odGrid.PrintRows[i].YPos-_yPosPrint);
							}
							else {
								gx.DrawRectangle(Brushes.White,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint-1,odGrid.Width,odGrid.TitleHeight);
								using(Font _font=new Font("Arial",10,FontStyle.Bold)) {
									GraphicsHelper.DrawStringX(gx,Graphics.FromImage(new Bitmap(100,100)),(double)((1d)/p(1)),"Payment Plans",new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),XBrushes.Black,new XRect(p(field.XPos+field.Width/2),p(odGrid.PrintRows[i].YPos-_yPosPrint-1),p(300),p(100)),XStringAlignment.Center);
									//gx.DrawString("Payment Plans",new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),new SolidBrush(Color.Black),field.XPos+(field.Width-sSize.Width)/2,yPosGrid);
								}
							}
							break;
						default:
							if(gx==null) {
								odGrid.PrintTitle(g,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint);
							}
							else {
								odGrid.PrintTitleX(gx,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint);
							}
							break;
					}
					_yAdjCurRow+=odGrid.TitleHeight;
				}
				#endregion
				#region Draw Header
				if(odGrid.PrintRows[i].IsHeaderRow) {
					if(gx==null) {
						odGrid.PrintHeader(g,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow);
					}
					else {
						odGrid.PrintHeaderX(gx,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow);
					}
					_yAdjCurRow+=odGrid.HeaderHeight;
				}
				#endregion
				#region Draw Row
				if(gx==null) {
					odGrid.PrintRow(i,g,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow,odGrid.PrintRows[i].IsBottomRow,true);
				}
				else {
					odGrid.PrintRowX(i,gx,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow,odGrid.PrintRows[i].IsBottomRow,true);
				}
				_yAdjCurRow+=odGrid.RowHeights[i];
				#endregion
				#region Draw Footer (rare)
				if(odGrid.PrintRows[i].IsFooterRow) {
					_yAdjCurRow+=2;
					switch(field.FieldName) {
						case "StatementPayPlan":
							DataTable tableMisc=AccountModules.GetStatementDataSet(stmt).Tables["misc"];
							if(tableMisc==null) {
								tableMisc=new DataTable();
							}
							Double payPlanDue=0;
							for(int m=0;m<tableMisc.Rows.Count;m++) {
								if(tableMisc.Rows[m]["descript"].ToString()=="payPlanDue") {
									payPlanDue=PIn.Double(tableMisc.Rows[m]["value"].ToString());
								}
							}
							if(gx==null) {
								RectangleF rf=new RectangleF(sheet.Width-60-field.Width,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow,field.Width,odGrid.TitleHeight);
								g.FillRectangle(Brushes.White,rf);
								StringFormat sf=new StringFormat();
								sf.Alignment=StringAlignment.Far;
								g.DrawString("Payment Plan Amount Due: "+payPlanDue.ToString("c"),new Font("Arial",9,FontStyle.Bold),new SolidBrush(Color.Black),rf,sf);
							}
							else {
								gx.DrawRectangle(Brushes.White,p(sheet.Width-field.Width-60),p(odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow),p(field.Width),p(odGrid.TitleHeight));
								using(Font _font=new Font("Arial",9,FontStyle.Bold)) {
									GraphicsHelper.DrawStringX(gx,Graphics.FromImage(new Bitmap(100,100)),(double)((1d)/p(1)),"Payment Plan Amount Due: "+payPlanDue.ToString("c"),new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),XBrushes.Black,new XRect(p(sheet.Width-60),p(odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow),p(field.Width),p(odGrid.TitleHeight)),XStringAlignment.Far);
								}
							}
							break;
					}
				}
				#endregion
			}
		}
Exemple #33
0
		///<summary>This is a modified version of FormTimeCard.FillMain().  It fills one time card per employee.</summary>
		private ODGrid GetGridForPrinting(Employee emp) {
			ODGrid gridTimeCard=new ODGrid();
			List<ClockEvent> clockEventList=ClockEvents.Refresh(emp.EmployeeNum,PIn.Date(textDateStart.Text),PIn.Date(textDateStop.Text),false);
			List<TimeAdjust> timeAdjustList=TimeAdjusts.Refresh(emp.EmployeeNum,PIn.Date(textDateStart.Text),PIn.Date(textDateStop.Text));
			ArrayList mergedAL=new ArrayList();
			for(int i=0;i<clockEventList.Count;i++) {
				mergedAL.Add(clockEventList[i]);
			}
			for(int i=0;i<timeAdjustList.Count;i++) {
				mergedAL.Add(timeAdjustList[i]);
			}
			IComparer myComparer=new ObjectDateComparer();
			mergedAL.Sort(myComparer);
			gridTimeCard.BeginUpdate();
			gridTimeCard.Columns.Clear();
			ODGridColumn col=new ODGridColumn(Lan.g(this,"Date"),70);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Weekday"),70);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"In"),60,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Out"),60,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Total"),50,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Adjust"),55,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Rate2"),55,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Overtime"),55,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Daily"),50,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Weekly"),50,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Note"),5);
			gridTimeCard.Columns.Add(col);
			gridTimeCard.Rows.Clear();
			ODGridRow row;
			TimeSpan[] weeklyTotals=new TimeSpan[mergedAL.Count];
			TimeSpan alteredSpan=new TimeSpan(0);//used to display altered times
			TimeSpan oneSpan=new TimeSpan(0);//used to sum one pair of clock-in/clock-out
			TimeSpan oneAdj;
			TimeSpan oneOT;
			TimeSpan daySpan=new TimeSpan(0);//used for daily totals.
			TimeSpan weekSpan=new TimeSpan(0);//used for weekly totals.
			if(mergedAL.Count>0){
				weekSpan=ClockEvents.GetWeekTotal(emp.EmployeeNum,GetDateForRow(0,mergedAL));
			}
			TimeSpan periodSpan=new TimeSpan(0);//used to add up totals for entire page.
			TimeSpan otspan=new TimeSpan(0);//overtime for the entire period
			TimeSpan rate2span=new TimeSpan(0);//rate2 hours total
			Calendar cal=CultureInfo.CurrentCulture.Calendar;
			CalendarWeekRule rule=CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule;
			DateTime curDate=DateTime.MinValue;
			DateTime previousDate=DateTime.MinValue;
			Type type;
			ClockEvent clock;
			TimeAdjust adjust;
			for(int i=0;i<mergedAL.Count;i++){
				row=new ODGridRow();
				type=mergedAL[i].GetType();
				row.Tag=mergedAL[i];
				previousDate=curDate;
				//clock event row---------------------------------------------------------------------------------------------
				if(type==typeof(ClockEvent)){
					clock=(ClockEvent)mergedAL[i];
					curDate=clock.TimeDisplayed1.Date;
					if(curDate==previousDate){
						row.Cells.Add("");
						row.Cells.Add("");
					}
					else{
						row.Cells.Add(curDate.ToShortDateString());
						row.Cells.Add(curDate.DayOfWeek.ToString());
					}
					//altered--------------------------------------
					//deprecated
					//status--------------------------------------
					//row.Cells.Add(clock.ClockStatus.ToString());
					//in------------------------------------------
					row.Cells.Add(clock.TimeDisplayed1.ToShortTimeString());
					if(clock.TimeEntered1!=clock.TimeDisplayed1){
						row.Cells[row.Cells.Count-1].ColorText = Color.Red;
					}
					//out-----------------------------
					if(clock.TimeDisplayed2.Year<1880){
						row.Cells.Add("");//not clocked out yet
					}
					else{
						row.Cells.Add(clock.TimeDisplayed2.ToShortTimeString());
						if (clock.TimeEntered2!=clock.TimeDisplayed2)
						{
							row.Cells[row.Cells.Count-1].ColorText = Color.Red;
						}
					}
					//total-------------------------------
					if(clock.TimeDisplayed2.Year<1880){
						row.Cells.Add("");
					}
					else{
						oneSpan=clock.TimeDisplayed2-clock.TimeDisplayed1;
						row.Cells.Add(ClockEvents.Format(oneSpan));
						daySpan+=oneSpan;
						weekSpan+=oneSpan;
						periodSpan+=oneSpan;
					}
					//Adjust---------------------------------
					oneAdj=TimeSpan.Zero;
					if(clock.AdjustIsOverridden) {
						oneAdj+=clock.Adjust;
					}
					else {
						oneAdj+=clock.AdjustAuto;//typically zero
					}
					daySpan+=oneAdj;
					weekSpan+=oneAdj;
					periodSpan+=oneAdj;
					row.Cells.Add(ClockEvents.Format(oneAdj));
					if(clock.AdjustIsOverridden) {
						row.Cells[row.Cells.Count-1].ColorText = Color.Red;
					}
					//Rate2---------------------------------
					if(clock.Rate2Hours!=TimeSpan.FromHours(-1)) {
						rate2span+=clock.Rate2Hours;
						row.Cells.Add(ClockEvents.Format(clock.Rate2Hours));
						row.Cells[row.Cells.Count-1].ColorText = Color.Red;
					}
					else {
						rate2span+=clock.Rate2Auto;
						row.Cells.Add(ClockEvents.Format(clock.Rate2Auto));
					}
					//Overtime------------------------------
					oneOT=TimeSpan.Zero;
					if(clock.OTimeHours!=TimeSpan.FromHours(-1)) {//overridden
						oneOT=clock.OTimeHours;
					}
					else {
						oneOT=clock.OTimeAuto;//typically zero
					}
					otspan+=oneOT;
					daySpan-=oneOT;
					weekSpan-=oneOT;
					periodSpan-=oneOT;
					row.Cells.Add(ClockEvents.Format(oneOT));
					if(clock.OTimeHours!=TimeSpan.FromHours(-1)) {//overridden
						row.Cells[row.Cells.Count-1].ColorText = Color.Red;
					}
					//Daily-----------------------------------
					//if this is the last entry for a given date
					if(i==mergedAL.Count-1//if this is the last row
						|| GetDateForRow(i+1,mergedAL) != curDate)//or the next row is a different date
					{
						row.Cells.Add(ClockEvents.Format(daySpan));
						daySpan=new TimeSpan(0);
					}
					else{//not the last entry for the day
						row.Cells.Add("");
					}
					//Weekly-------------------------------------
					weeklyTotals[i]=weekSpan;
					//if this is the last entry for a given week
					if(i==mergedAL.Count-1//if this is the last row 
						|| cal.GetWeekOfYear(GetDateForRow(i+1,mergedAL),rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek))//or the next row has a
						!= cal.GetWeekOfYear(clock.TimeDisplayed1.Date,rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek)))//different week of year
					{
						row.Cells.Add(ClockEvents.Format(weekSpan));
						weekSpan=new TimeSpan(0);
					}
					else {
						//row.Cells.Add(ClockEvents.Format(weekSpan));
						row.Cells.Add("");
					}
					//Note-----------------------------------------
					row.Cells.Add(clock.Note);
				}
				//adjustment row--------------------------------------------------------------------------------------
				else if(type==typeof(TimeAdjust)){
					adjust=(TimeAdjust)mergedAL[i];
					curDate=adjust.TimeEntry.Date;
					if(curDate==previousDate){
						row.Cells.Add("");
						row.Cells.Add("");
					}
					else{
						row.Cells.Add(curDate.ToShortDateString());
						row.Cells.Add(curDate.DayOfWeek.ToString());
					}
					//altered--------------------------------------
					//Deprecated
					//status--------------------------------------
					//row.Cells.Add("");//3
					//in/out------------------------------------------
					row.Cells.Add("");//4
					//time-----------------------------
					row.Cells.Add(adjust.TimeEntry.ToShortTimeString());//5
					//total-------------------------------
					row.Cells.Add("");//
					//Adjust------------------------------
					daySpan+=adjust.RegHours;//might be negative
					weekSpan+=adjust.RegHours;
					periodSpan+=adjust.RegHours;
					row.Cells.Add(ClockEvents.Format(adjust.RegHours));//6
					//Rate2-------------------------------
					row.Cells.Add("");//
					//Overtime------------------------------
					otspan+=adjust.OTimeHours;
					row.Cells.Add(ClockEvents.Format(adjust.OTimeHours));//7
					//Daily-----------------------------------
					//if this is the last entry for a given date
					if(i==mergedAL.Count-1//if this is the last row
						|| GetDateForRow(i+1,mergedAL) != curDate)//or the next row is a different date
					{
						row.Cells.Add(ClockEvents.Format(daySpan));//
						daySpan=new TimeSpan(0);
					}
					else{
						row.Cells.Add("");
					}
					//Weekly-------------------------------------
					weeklyTotals[i]=weekSpan;
					//if this is the last entry for a given week
					if(i==mergedAL.Count-1//if this is the last row 
						|| cal.GetWeekOfYear(GetDateForRow(i+1,mergedAL),rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek))//or the next row has a
						!= cal.GetWeekOfYear(adjust.TimeEntry.Date,rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek)))//different week of year
					{
						ODGridCell cell=new ODGridCell(ClockEvents.Format(weekSpan));
						cell.ColorText=Color.Black;
						row.Cells.Add(cell);
						weekSpan=new TimeSpan(0);
					}
					else {
						row.Cells.Add("");
					}
					//Note-----------------------------------------
					row.Cells.Add("(Adjust)"+adjust.Note);//used to indicate adjust rows.
					row.Cells[row.Cells.Count-1].ColorText=Color.Red;
				}
				gridTimeCard.Rows.Add(row);
			}
			gridTimeCard.EndUpdate();
			totalTime=periodSpan.ToStringHmm();
			overTime=otspan.ToStringHmm();
			rate2Time=rate2span.ToStringHmm();
			totalTime2=periodSpan.TotalHours.ToString("n");
			overTime2=otspan.TotalHours.ToString("n");
			rate2Time2=rate2span.TotalHours.ToString("n");
			return gridTimeCard;
		}
		///<summary>Supply pd so that we know the paper size and margins.</summary>
		private MigraDoc.DocumentObjectModel.Document CreateDocument(PrintDocument pd,Family fam,Patient pat,DataSet dataSet){
			MigraDoc.DocumentObjectModel.Document doc= new MigraDoc.DocumentObjectModel.Document();
			if(Plugins.HookMethod(this,"FormRpStatement.CreateDocument",doc,pd,fam,pat,dataSet,Stmt)) {
				return doc;
			}
			doc.DefaultPageSetup.PageWidth=Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Width/100);
			doc.DefaultPageSetup.PageHeight=Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Height/100);
			doc.DefaultPageSetup.TopMargin=Unit.FromInch((double)pd.DefaultPageSettings.Margins.Top/100);
			doc.DefaultPageSetup.LeftMargin=Unit.FromInch((double)pd.DefaultPageSettings.Margins.Left/100);
			doc.DefaultPageSetup.RightMargin=Unit.FromInch((double)pd.DefaultPageSettings.Margins.Right/100);
			doc.DefaultPageSetup.BottomMargin=Unit.FromInch((double)pd.DefaultPageSettings.Margins.Bottom/100);
			MigraDoc.DocumentObjectModel.Section section=doc.AddSection();//so that Swiss will have different footer for each patient.
			string text;
			MigraDoc.DocumentObjectModel.Font font;
			//GetPatGuar(PatNums[famIndex][0]);
			//Family fam=Patients.GetFamily(Stmt.PatNum);
			Patient PatGuar=fam.ListPats[0];//.Clone();
			//Patient pat=fam.GetPatient(Stmt.PatNum);
			DataTable tableMisc=dataSet.Tables["misc"];
			//HEADING------------------------------------------------------------------------------
			#region Heading
			Paragraph par=section.AddParagraph();
			ParagraphFormat parformat=new ParagraphFormat();
			parformat.Alignment=ParagraphAlignment.Center;
			par.Format=parformat;
			font=MigraDocHelper.CreateFont(14,true);
			if(Stmt.IsInvoice) {
				if(CultureInfo.CurrentCulture.Name=="en-NZ" || CultureInfo.CurrentCulture.Name=="en-AU") {//New Zealand and Australia
					text=Lan.g(this,"TAX INVOICE");
				}
				else {
					text=Lan.g(this,"INVOICE");
					text+=" #"+Stmt.StatementNum.ToString();//Some larger customers of OD need this to show in order to properly pay.
				}
			}
			else if(Stmt.IsReceipt) {
				text=Lan.g(this,"RECEIPT");
				if(CultureInfo.CurrentCulture.Name.EndsWith("SG")) {//SG=Singapore
					text+=" #"+Stmt.StatementNum.ToString();
				}
			}
			else {
				text=Lan.g(this,"STATEMENT");
			}
			par.AddFormattedText(text,font);
			text=DateTime.Today.ToShortDateString();
			font=MigraDocHelper.CreateFont(10);
			par.AddLineBreak();
			par.AddFormattedText(text,font);
			text=Lan.g(this,"Account Number")+" ";
			if(PrefC.GetBool(PrefName.StatementAccountsUseChartNumber)) {
				text+=PatGuar.ChartNumber;
			}
			else {
				text+=PatGuar.PatNum;
			}
			par.AddLineBreak();
			par.AddFormattedText(text,font);
			TextFrame frame;
			#endregion Heading
			//"COPY" for foreign countries' TAX INVOICES----------------------------------------------
			#region Tax Invoice Copy
			if(Stmt.IsInvoiceCopy && CultureInfo.CurrentCulture.Name!="en-US") {//We don't show this for US.
				font=MigraDocHelper.CreateFont(28,true,System.Drawing.Color.Red);
				frame=section.AddTextFrame();
				frame.RelativeVertical=RelativeVertical.Page;
				frame.RelativeHorizontal=RelativeHorizontal.Page;
				frame.MarginLeft=Unit.Zero;
				frame.MarginTop=Unit.Zero;
				frame.Top=TopPosition.Parse("0.35 in");
				frame.Left=LeftPosition.Parse("5.4 in");
				frame.Width=Unit.FromInch(3);
				par=frame.AddParagraph();
				par.Format.Font=font;
				par.AddText("COPY");
			}
			#endregion Tax Invoice Copy
			//Practice Address----------------------------------------------------------------------
			#region Practice Address
			if(PrefC.GetBool(PrefName.StatementShowReturnAddress)) {
				font=MigraDocHelper.CreateFont(10);
				frame=section.AddTextFrame();
				frame.RelativeVertical=RelativeVertical.Page;
				frame.RelativeHorizontal=RelativeHorizontal.Page;
				frame.MarginLeft=Unit.Zero;
				frame.MarginTop=Unit.Zero;
				frame.Top=TopPosition.Parse("0.5 in");
				frame.Left=LeftPosition.Parse("0.3 in");
				frame.Width=Unit.FromInch(3);
				if(!PrefC.GetBool(PrefName.EasyNoClinics) && Clinics.List.Length>0 //if using clinics
						&& Clinics.GetClinic(PatGuar.ClinicNum)!=null)//and this patient assigned to a clinic
					{
					Clinic clinic=Clinics.GetClinic(PatGuar.ClinicNum);
					par=frame.AddParagraph();
					par.Format.Font=font;
					par.AddText(clinic.Description);
					par.AddLineBreak();
					if(CultureInfo.CurrentCulture.Name=="en-AU") {//Australia
						Provider defaultProv=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
						par.AddText("ABN: "+defaultProv.NationalProvID);
						par.AddLineBreak();
					}
					if(CultureInfo.CurrentCulture.Name=="en-NZ") {//New Zealand
						Provider defaultProv=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
						par.AddText("GST: "+defaultProv.SSN);
						par.AddLineBreak();
					}
					par.AddText(clinic.Address);
					par.AddLineBreak();
					if(clinic.Address2!="") {
						par.AddText(clinic.Address2);
						par.AddLineBreak();
					}
					if(CultureInfo.CurrentCulture.Name.EndsWith("CH")) {//CH is for switzerland. eg de-CH
						par.AddText(clinic.Zip+" "+clinic.City);
					}
					else if(CultureInfo.CurrentCulture.Name.EndsWith("SG")) {//SG=Singapore
						par.AddText(clinic.City+" "+clinic.Zip);
					}
					else {
						par.AddText(clinic.City+", "+clinic.State+" "+clinic.Zip);
					}
					par.AddLineBreak();
					text=clinic.Phone;
					if(text.Length==10){
						text="("+text.Substring(0,3)+")"+text.Substring(3,3)+"-"+text.Substring(6);
					}
					par.AddText(text);
					par.AddLineBreak();
				}
				else {
					par=frame.AddParagraph();
					par.Format.Font=font;
					par.AddText(PrefC.GetString(PrefName.PracticeTitle));
					par.AddLineBreak();
					if(CultureInfo.CurrentCulture.Name=="en-AU"){//Australia
						Provider defaultProv=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
						par.AddText("ABN: "+defaultProv.NationalProvID);
						par.AddLineBreak();
					}
					if(CultureInfo.CurrentCulture.Name=="en-NZ") {//New Zealand
						Provider defaultProv=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
						par.AddText("GST: "+defaultProv.SSN);
						par.AddLineBreak();
					}
					par.AddText(PrefC.GetString(PrefName.PracticeAddress));
					par.AddLineBreak();
					if(PrefC.GetString(PrefName.PracticeAddress2)!="") {
						par.AddText(PrefC.GetString(PrefName.PracticeAddress2));
						par.AddLineBreak();
					}
					if(CultureInfo.CurrentCulture.Name.EndsWith("CH")) {//CH is for switzerland. eg de-CH
						par.AddText(PrefC.GetString(PrefName.PracticeZip)+" "+PrefC.GetString(PrefName.PracticeCity));
					}
					else if(CultureInfo.CurrentCulture.Name.EndsWith("SG")) {//SG=Singapore
						par.AddText(PrefC.GetString(PrefName.PracticeCity)+" "+PrefC.GetString(PrefName.PracticeZip));
					}
					else {
						par.AddText(PrefC.GetString(PrefName.PracticeCity)+", "+PrefC.GetString(PrefName.PracticeST)+" "+PrefC.GetString(PrefName.PracticeZip));
					}
					par.AddLineBreak();
					text=PrefC.GetString(PrefName.PracticePhone);
					if(text.Length==10){
						text="("+text.Substring(0,3)+")"+text.Substring(3,3)+"-"+text.Substring(6);
					}
					par.AddText(text);
					par.AddLineBreak();
				}
			}
			#endregion
			//AMOUNT ENCLOSED------------------------------------------------------------------------------------------------------
			#region Amount Enclosed
			Table table;
			Column col;
			Row row;
			Cell cell;
			frame=MigraDocHelper.CreateContainer(section,450,110,330,29);
			if(!Stmt.HidePayment) {
				table=MigraDocHelper.DrawTable(frame,0,0,29);
				col=table.AddColumn(Unit.FromInch(1.1));
				col=table.AddColumn(Unit.FromInch(1.1));
				col=table.AddColumn(Unit.FromInch(1.1));				
				row=table.AddRow();
				row.Format.Alignment=ParagraphAlignment.Center;
				row.Borders.Color=Colors.Black;
				row.Shading.Color=Colors.LightGray;
				row.TopPadding=Unit.FromInch(0);
				row.BottomPadding=Unit.FromInch(0);
				font=MigraDocHelper.CreateFont(8,true);
				cell=row.Cells[0];
				par=cell.AddParagraph();
				par.AddFormattedText(Lan.g(this,"Amount Due"),font);
				cell=row.Cells[1];
				par=cell.AddParagraph();
				par.AddFormattedText(Lan.g(this,"Date Due"),font);
				cell=row.Cells[2];
				par=cell.AddParagraph();
				par.AddFormattedText(Lan.g(this,"Amount Enclosed"),font);
				row=table.AddRow();
				row.Format.Alignment=ParagraphAlignment.Center;
				row.Borders.Left.Color=Colors.Gray;
				row.Borders.Bottom.Color=Colors.Gray;
				row.Borders.Right.Color=Colors.Gray;
				font=MigraDocHelper.CreateFont(9);
				double balTotal=PatGuar.BalTotal;
				if(!PrefC.GetBool(PrefName.BalancesDontSubtractIns)) {//this is typical
					balTotal-=PatGuar.InsEst;
				}
				for(int m=0;m<tableMisc.Rows.Count;m++){
					if(tableMisc.Rows[m]["descript"].ToString()=="payPlanDue"){
						balTotal+=PIn.Double(tableMisc.Rows[m]["value"].ToString());
						//payPlanDue;//PatGuar.PayPlanDue;
					}
				}
				InstallmentPlan installPlan=InstallmentPlans.GetOneForFam(PatGuar.PatNum);
				if(installPlan!=null){
					//show lesser of normal total balance or the monthly payment amount.
					if(installPlan.MonthlyPayment < balTotal) {
						text=installPlan.MonthlyPayment.ToString("F");
					}
					else {
						text=balTotal.ToString("F");
					}
				}
				else {//no installmentplan
					text=balTotal.ToString("F");
				}
				cell=row.Cells[0];
				par=cell.AddParagraph();
				par.AddFormattedText(text,font);
				if(PrefC.GetLong(PrefName.StatementsCalcDueDate)==-1) {
					text=Lan.g(this,"Upon Receipt");
				}
				else {
					text=DateTime.Today.AddDays(PrefC.GetLong(PrefName.StatementsCalcDueDate)).ToShortDateString();
				}
				cell=row.Cells[1];
				par=cell.AddParagraph();
				par.AddFormattedText(text,font);
			}
			#endregion
			//Credit Card Info--------------------------------------------------------------------------------------------------------
			#region Credit Card Info
			if(!Stmt.HidePayment) {
				if(PrefC.GetBool(PrefName.StatementShowCreditCard)) {
					float yPos=60;
					font=MigraDocHelper.CreateFont(7,true);
					text=Lan.g(this,"CREDIT CARD TYPE");
					MigraDocHelper.DrawString(frame,text,font,0,yPos);
					float rowHeight=26;
					System.Drawing.Font wfont=new System.Drawing.Font("Arial",7,FontStyle.Bold);
					Graphics g=this.CreateGraphics();//just to measure strings
					MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width,
						yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g));
					yPos+=rowHeight;
					text=Lan.g(this,"#");
					MigraDocHelper.DrawString(frame,text,font,0,yPos);
					MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width,
						yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g));
					yPos+=rowHeight;
					text=Lan.g(this,"3 DIGIT CSV");
					MigraDocHelper.DrawString(frame,text,font,0,yPos);
					MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width,
						yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g));
					yPos+=rowHeight;
					text=Lan.g(this,"EXPIRES");
					MigraDocHelper.DrawString(frame,text,font,0,yPos);
					MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width,
						yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g));
					yPos+=rowHeight;
					text=Lan.g(this,"AMOUNT APPROVED");
					MigraDocHelper.DrawString(frame,text,font,0,yPos);
					MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width,
						yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g));
					yPos+=rowHeight;
					text=Lan.g(this,"NAME");
					MigraDocHelper.DrawString(frame,text,font,0,yPos);
					MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width,
						yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g));
					yPos+=rowHeight;
					text=Lan.g(this,"SIGNATURE");
					MigraDocHelper.DrawString(frame,text,font,0,yPos);
					MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width,
						yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g));
					yPos-=rowHeight;
					text=Lan.g(this,"(As it appears on card)");
					wfont=new System.Drawing.Font("Arial",5);
					font=MigraDocHelper.CreateFont(5);
					MigraDocHelper.DrawString(frame,text,font,625-g.MeasureString(text,wfont).Width/2+5,yPos+13);
				}
			}
			#endregion
			//Patient's Billing Address---------------------------------------------------------------------------------------------
			#region Patient Billing Address
			font=MigraDocHelper.CreateFont(11);
			frame=MigraDocHelper.CreateContainer(section,62.5f+12.5f,225+1,300,200);
			par=frame.AddParagraph();
			par.Format.Font=font;
			if(Stmt.SinglePatient){
				par.AddText(fam.GetNameInFamFLnoPref(Stmt.PatNum));
			}
			else{
				par.AddText(PatGuar.GetNameFLFormal());
			}
			par.AddLineBreak();
			par.AddText(PatGuar.Address);
			par.AddLineBreak();
			if(PatGuar.Address2!="") {
				par.AddText(PatGuar.Address2);
				par.AddLineBreak();
			}
			if(CultureInfo.CurrentCulture.Name.EndsWith("CH")) {//CH is for switzerland. eg de-CH
				par.AddText(PatGuar.Zip+" "+PatGuar.City);
			}
			else if(CultureInfo.CurrentCulture.Name.EndsWith("SG")) {//SG=Singapore
				par.AddText(PatGuar.City+" "+PatGuar.Zip);
			}
			else {
				par.AddText(PatGuar.City+", "+PatGuar.State+" "+PatGuar.Zip);
			}
			if(PatGuar.Country!="") {
				par.AddLineBreak();
				par.AddText(PatGuar.Country);
			}
			//perforated line------------------------------------------------------------------------------------------------------
			//yPos=350;//3.62 inches from top, 1/3 page down
			frame=MigraDocHelper.CreateContainer(section,0,350,850,30);
			if(!Stmt.HidePayment) {
				MigraDocHelper.DrawLine(frame,System.Drawing.Color.LightGray,0,0,850,0);
				text=Lan.g(this,"PLEASE DETACH AND RETURN THE UPPER PORTION WITH YOUR PAYMENT");
				font=MigraDocHelper.CreateFont(6,true,System.Drawing.Color.Gray);
				par=frame.AddParagraph();
				par.Format.Alignment=ParagraphAlignment.Center;
				par.Format.Font=font;
				par.AddText(text);
			}
			#endregion
			//Australian Provider Legend
			#region Australian Provider Legend
			int legendOffset=0;
			if(CultureInfo.CurrentCulture.Name=="en-AU") {//English (Australia)
				Providers.RefreshCache();
				legendOffset=25+15*(1+ProviderC.ListShort.Count);
				MigraDocHelper.InsertSpacer(section,legendOffset);
				frame=MigraDocHelper.CreateContainer(section,45,390,250,legendOffset);
				par=frame.AddParagraph();
				par.Format.Font=MigraDocHelper.CreateFont(8,true);
				par.AddLineBreak();
				par.AddText("PROVIDERS:");
				par=frame.AddParagraph();
				par.Format.Font=MigraDocHelper.CreateFont(8,false);
				for(int i=0;i<ProviderC.ListShort.Count;i++) {//All non-hidden providers are added to the legend.
					Provider prov=ProviderC.ListShort[i];
					string suffix="";
					if(prov.Suffix.Trim()!=""){
						suffix=", "+prov.Suffix.Trim();
					}
					par.AddText(prov.Abbr+" - "+prov.FName+" "+prov.LName+suffix+" - "+prov.MedicaidID);
					par.AddLineBreak();
				}
				par.AddLineBreak();
			}
			#endregion
			//Aging-----------------------------------------------------------------------------------
			#region Aging
			MigraDocHelper.InsertSpacer(section,275);
			frame=MigraDocHelper.CreateContainer(section,55,390+legendOffset,250,29);
			if (!Stmt.HidePayment)
			{
				table = MigraDocHelper.DrawTable(frame, 0, 0, 29);
				col = table.AddColumn(Unit.FromInch(1.1));
				col = table.AddColumn(Unit.FromInch(1.1));
				col = table.AddColumn(Unit.FromInch(1.1));
				col = table.AddColumn(Unit.FromInch(1.1));
				row = table.AddRow();
				row.Format.Alignment = ParagraphAlignment.Center;
				row.Borders.Color = Colors.Black;
				row.Shading.Color = Colors.LightGray;
				row.TopPadding = Unit.FromInch(0);
				row.BottomPadding = Unit.FromInch(0);
				font = MigraDocHelper.CreateFont(8, true);
				cell = row.Cells[0];
				par = cell.AddParagraph();
				par.AddFormattedText(Lan.g(this, "0-30"), font);
				cell = row.Cells[1];
				par = cell.AddParagraph();
				par.AddFormattedText(Lan.g(this, "31-60"), font);
				cell = row.Cells[2];
				par = cell.AddParagraph();
				par.AddFormattedText(Lan.g(this, "61-90"), font);
				cell = row.Cells[3];
				par = cell.AddParagraph();
				par.AddFormattedText(Lan.g(this, "over 90"), font);
				row = table.AddRow();
				row.Format.Alignment = ParagraphAlignment.Center;
				row.Borders.Left.Color = Colors.Gray;
				row.Borders.Bottom.Color = Colors.Gray;
				row.Borders.Right.Color = Colors.Gray;
				font = MigraDocHelper.CreateFont(9);
				text= PatGuar.Bal_0_30.ToString("F");
				cell = row.Cells[0];
				par = cell.AddParagraph();
				par.AddFormattedText(text, font);
				text = PatGuar.Bal_31_60.ToString("F");
				cell = row.Cells[1];
				par = cell.AddParagraph();
				par.AddFormattedText(text, font);
				text = PatGuar.Bal_61_90.ToString("F");
				cell = row.Cells[2];
				par = cell.AddParagraph();
				par.AddFormattedText(text, font);
				text = PatGuar.BalOver90.ToString("F");
				cell = row.Cells[3];
				par = cell.AddParagraph();
				par.AddFormattedText(text, font);
			}
			/*
			ODGridColumn gcol;
			ODGridRow grow;
			if(!Stmt.HidePayment) {
				ODGrid gridAging=new ODGrid();
				this.Controls.Add(gridAging);
				gridAging.BeginUpdate();
				gridAging.Columns.Clear();
				gcol=new ODGridColumn(Lan.g(this,"0-30"),70,HorizontalAlignment.Center);
				gridAging.Columns.Add(gcol);
				gcol=new ODGridColumn(Lan.g(this,"31-60"),70,HorizontalAlignment.Center);
				gridAging.Columns.Add(gcol);
				gcol=new ODGridColumn(Lan.g(this,"61-90"),70,HorizontalAlignment.Center);
				gridAging.Columns.Add(gcol);
				gcol=new ODGridColumn(Lan.g(this,"over 90"),70,HorizontalAlignment.Center);
				gridAging.Columns.Add(gcol);
				if(PrefC.GetBool(PrefName.BalancesDontSubtractIns")) {//less common
					gcol=new ODGridColumn(Lan.g(this,"Balance"),70,HorizontalAlignment.Center);
					gridAging.Columns.Add(gcol);
					gcol=new ODGridColumn(Lan.g(this,"InsPending"),70,HorizontalAlignment.Center);
					gridAging.Columns.Add(gcol);
					gcol=new ODGridColumn(Lan.g(this,"AfterIns"),70,HorizontalAlignment.Center);
					gridAging.Columns.Add(gcol);
				}
				else{//more common
					gcol=new ODGridColumn(Lan.g(this,"Total"),70,HorizontalAlignment.Center);
					gridAging.Columns.Add(gcol);
					gcol=new ODGridColumn(Lan.g(this,"- InsEst"),70,HorizontalAlignment.Center);
					gridAging.Columns.Add(gcol);
					gcol=new ODGridColumn(Lan.g(this,"= Balance"),70,HorizontalAlignment.Center);
					gridAging.Columns.Add(gcol);
				}
				gridAging.Rows.Clear();
				//Annual max--------------------------
				grow=new ODGridRow();
				grow.Cells.Add(PatGuar.Bal_0_30.ToString("F"));
				grow.Cells.Add(PatGuar.Bal_31_60.ToString("F"));
				grow.Cells.Add(PatGuar.Bal_61_90.ToString("F"));
				grow.Cells.Add(PatGuar.BalOver90.ToString("F"));
				grow.Cells.Add(PatGuar.BalTotal.ToString("F"));
				grow.Cells.Add(PatGuar.InsEst.ToString("F"));
				grow.Cells.Add((PatGuar.BalTotal-PatGuar.InsEst).ToString("F"));
				gridAging.Rows.Add(grow);
				gridAging.EndUpdate();
				MigraDocHelper.DrawGrid(section,gridAging);
				gridAging.Dispose();
			*/
			#endregion
			//Floating Balance, Ins info-------------------------------------------------------------------
			#region FloatingBalance
			frame=MigraDocHelper.CreateContainer(section,460,380+legendOffset,250,200);
			//table=MigraDocHelper.DrawTable(frame,0,0,90);
			par = frame.AddParagraph();
			parformat = new ParagraphFormat();
			parformat.Alignment = ParagraphAlignment.Right;
			par.Format = parformat;
			font = MigraDocHelper.CreateFont(10,false);
			MigraDoc.DocumentObjectModel.Font fontBold=MigraDocHelper.CreateFont(10, true);
			if(Stmt.IsInvoice) {
				text=Lan.g(this,"Procedures:");
				par.AddFormattedText(text,font);
				par.AddLineBreak();
				text=Lan.g(this,"Adjustments:");
				par.AddFormattedText(text,font);
				par.AddLineBreak();
				text=Lan.g(this,"Total:");
				par.AddFormattedText(text,font);
				par.AddLineBreak();
			}
			else if(PrefC.GetBool(PrefName.BalancesDontSubtractIns)){
				text = Lan.g(this, "Balance:");
				par.AddFormattedText(text, fontBold);
				//par.AddLineBreak();
				//text = Lan.g(this, "Ins Pending:");
				//par.AddFormattedText(text, font);
				//par.AddLineBreak();
				//text = Lan.g(this, "After Ins:");
				//par.AddFormattedText(text, font);
				//par.AddLineBreak();
			}
			else{//this is more common
				if (PrefC.GetBool(PrefName.FuchsOptionsOn)) {
					text = Lan.g(this, "Balance:");
					par.AddFormattedText(text, font);
					par.AddLineBreak();
					text = Lan.g(this, "-Ins Estimate:");
					par.AddFormattedText(text, font);
					par.AddLineBreak();
					text = Lan.g(this, "=Owed Now:");
					par.AddFormattedText(text, fontBold);
					par.AddLineBreak();
				}
				else {
					text = Lan.g(this, "Total:");
					par.AddFormattedText(text, font);
					par.AddLineBreak();
					text = Lan.g(this, "-Ins Estimate:");
					par.AddFormattedText(text, font);
					par.AddLineBreak();
					text = Lan.g(this, "=Balance:");
					par.AddFormattedText(text, fontBold);
					par.AddLineBreak();
				}
			}
			frame=MigraDocHelper.CreateContainer(section,730,380+legendOffset,100,200);
			//table=MigraDocHelper.DrawTable(frame,0,0,90);
			par = frame.AddParagraph();
			parformat = new ParagraphFormat();
			parformat.Alignment = ParagraphAlignment.Left;
			par.Format = parformat;
			font = MigraDocHelper.CreateFont(10,false);
			//numbers:
			if(Stmt.IsInvoice) {
				double adjAmt=0;
				double procAmt=0;
				DataTable tableAcct;
				string tableName;
				for(int i=0;i<dataSet.Tables.Count;i++) {
					tableAcct=dataSet.Tables[i];
					tableName=tableAcct.TableName;
					if(!tableName.StartsWith("account")) {
						continue;
					}
					for(int p=0;p<tableAcct.Rows.Count;p++) {
						if(tableAcct.Rows[p]["AdjNum"].ToString()!="0") {
							adjAmt-=PIn.Double(tableAcct.Rows[p]["creditsDouble"].ToString());
							adjAmt+=PIn.Double(tableAcct.Rows[p]["chargesDouble"].ToString());
						}
						else {//must be a procedure
							procAmt+=PIn.Double(tableAcct.Rows[p]["chargesDouble"].ToString());
						}
					}
				}
				text=procAmt.ToString("c");
				par.AddFormattedText(text,font);
				par.AddLineBreak();
				text=adjAmt.ToString("c");
				par.AddFormattedText(text,font);
				par.AddLineBreak();
				text=(procAmt+adjAmt).ToString("c");
				par.AddFormattedText(text,fontBold);
			}
			else if(PrefC.GetBool(PrefName.BalancesDontSubtractIns)) {
				if(Stmt.SinglePatient) {
					//Show the current patient's balance without subtracting insurance estimates.
					text = pat.EstBalance.ToString("c");
					par.AddFormattedText(text,font);
				}
				else {
					//Show the current family's balance without subtracting insurance estimates.
					text = PatGuar.BalTotal.ToString("c");
					par.AddFormattedText(text,fontBold);
				}
			}
			else {//more common
				if(Stmt.SinglePatient) {
					double patInsEst=0;
					for(int m=0;m<tableMisc.Rows.Count;m++) {
						if(tableMisc.Rows[m]["descript"].ToString()=="patInsEst") {
							patInsEst=PIn.Double(tableMisc.Rows[m]["value"].ToString());
						}
					}
					double patBal=pat.EstBalance-patInsEst;
					text = pat.EstBalance.ToString("c");
					par.AddFormattedText(text,font);
					par.AddLineBreak();
					text = patInsEst.ToString("c");
					par.AddFormattedText(text,font);
					par.AddLineBreak();
					text = patBal.ToString("c");
					par.AddFormattedText(text,fontBold);
				}
				else {
					text = PatGuar.BalTotal.ToString("c");
					par.AddFormattedText(text,font);
					par.AddLineBreak();
					text = PatGuar.InsEst.ToString("c");
					par.AddFormattedText(text,font);
					par.AddLineBreak();
					text = (PatGuar.BalTotal - PatGuar.InsEst).ToString("c");
					par.AddFormattedText(text,fontBold);
					par.AddLineBreak();
				}
			}
			MigraDocHelper.InsertSpacer(section, 80);
			#endregion FloatingBalance
			//Bold note-------------------------------------------------------------------------------
			#region Bold note
			if(Stmt.NoteBold!=""){
				MigraDocHelper.InsertSpacer(section,7);
				font=MigraDocHelper.CreateFont(10,true,System.Drawing.Color.DarkRed);
				par=section.AddParagraph();
				par.Format.Font=font;
				par.AddText(Stmt.NoteBold);
				MigraDocHelper.InsertSpacer(section,8);
			}
			#endregion Bold note
			//Payment plan grid definition---------------------------------------------------------------------------------
			#region PayPlan grid definition
			ODGridColumn gcol;
			ODGridRow grow;
			ODGrid gridPP = new ODGrid();
			this.Controls.Add(gridPP);
			gridPP.BeginUpdate();
			gridPP.Columns.Clear();
			gcol=new ODGridColumn(Lan.g(this,"Date"),73);
			gridPP.Columns.Add(gcol);
			gcol=new ODGridColumn(Lan.g(this,"Description"),270);
			gridPP.Columns.Add(gcol);
			gcol=new ODGridColumn(Lan.g(this,"Charges"),60,HorizontalAlignment.Right);
			gridPP.Columns.Add(gcol);
			gcol=new ODGridColumn(Lan.g(this,"Credits"),60,HorizontalAlignment.Right);
			gridPP.Columns.Add(gcol);
			gcol=new ODGridColumn(Lan.g(this,"Balance"),60,HorizontalAlignment.Right);
			gridPP.Columns.Add(gcol);
			gridPP.Width=gridPP.WidthAllColumns+20;
			gridPP.EndUpdate();
			#endregion PayPlan grid definition
			//Payment plan grid.  There will be only one, if any-----------------------------------------------------------------
			#region PayPlan grid
			DataTable tablePP=dataSet.Tables["payplan"];
			ODGridCell gcell;
			if(tablePP.Rows.Count>0){
				//MigraDocHelper.InsertSpacer(section,5);
				par=section.AddParagraph();
				par.Format.Font=MigraDocHelper.CreateFont(10,true);
				par.Format.Alignment=ParagraphAlignment.Center;
				//par.Format.SpaceBefore=Unit.FromInch(.05);
				//par.Format.SpaceAfter=Unit.FromInch(.05);
				par.AddText(Lan.g(this,"Payment Plans"));
				MigraDocHelper.InsertSpacer(section,2);
				gridPP.BeginUpdate();
				gridPP.Rows.Clear();
				for(int p=0;p<tablePP.Rows.Count;p++){
					grow=new ODGridRow();
					grow.Cells.Add(tablePP.Rows[p]["date"].ToString());
					grow.Cells.Add(tablePP.Rows[p]["description"].ToString());
					grow.Cells.Add(tablePP.Rows[p]["charges"].ToString());
					grow.Cells.Add(tablePP.Rows[p]["credits"].ToString());
					gcell=new ODGridCell(tablePP.Rows[p]["balance"].ToString());
					if(p==tablePP.Rows.Count-1){
						gcell.Bold=YN.Yes;
					}
					else if(tablePP.Rows[p+1]["balance"].ToString()==""){//if next row balance is blank.
						gcell.Bold=YN.Yes;
					}
					grow.Cells.Add(gcell);
					gridPP.Rows.Add(grow);
				}
				gridPP.EndUpdate();
				MigraDocHelper.DrawGrid(section,gridPP);
				MigraDocHelper.InsertSpacer(section,2);
				par=section.AddParagraph();
				par.Format.Font=MigraDocHelper.CreateFont(10,true);
				par.Format.Alignment=ParagraphAlignment.Right;
				par.Format.RightIndent=Unit.FromInch(0.25);
				double payPlanDue=0;
				for(int m=0;m<tableMisc.Rows.Count;m++){
					if(tableMisc.Rows[m]["descript"].ToString()=="payPlanDue"){
						payPlanDue=PIn.Double(tableMisc.Rows[m]["value"].ToString());
					}
				}
				par.AddText(Lan.g(this,"Payment Plan Amount Due: ")+payPlanDue.ToString("c"));//PatGuar.PayPlanDue.ToString("c"));
				MigraDocHelper.InsertSpacer(section,10);
			}
			#endregion PayPlan grid
			//Body Table definition--------------------------------------------------------------------------------------------------------
			#region Body Table definition
			ODGrid gridPat = new ODGrid();
			this.Controls.Add(gridPat);
			gridPat.BeginUpdate();
			gridPat.Columns.Clear();
			gcol=new ODGridColumn(Lan.g(this,"Date"),73);
			gridPat.Columns.Add(gcol);
			gcol=new ODGridColumn(Lan.g(this,"Patient"),100);
			gridPat.Columns.Add(gcol);
			//prov
			gcol=new ODGridColumn(Lan.g(this,"Code"),45);
			gridPat.Columns.Add(gcol);
			gcol=new ODGridColumn(Lan.g(this,"Tooth"),42);
			gridPat.Columns.Add(gcol);
			gcol=new ODGridColumn(Lan.g(this,"Description"),270);
			gridPat.Columns.Add(gcol);
			gcol=new ODGridColumn(Lan.g(this,"Charges"),60,HorizontalAlignment.Right);
			gridPat.Columns.Add(gcol);
			gcol=new ODGridColumn(Lan.g(this,"Credits"),60,HorizontalAlignment.Right);
			gridPat.Columns.Add(gcol);
			if(Stmt.IsInvoice) {
				gcol=new ODGridColumn(Lan.g(this,"Total"),60,HorizontalAlignment.Right);
				gridPat.Columns.Add(gcol);
			}
			else {
				gcol=new ODGridColumn(Lan.g(this,"Balance"),60,HorizontalAlignment.Right);
				gridPat.Columns.Add(gcol);
			}
			gridPat.Width=gridPat.WidthAllColumns+20;
			gridPat.EndUpdate();
			#endregion Body Table definition
			//Loop through each table.  Could be one intermingled, or one for each patient-----------------------------------------
			DataTable tableAccount;
			string tablename;
			long patnum;
			for(int i=0;i<dataSet.Tables.Count;i++){
				tableAccount=dataSet.Tables[i];
				tablename=tableAccount.TableName;
				if(!tablename.StartsWith("account")){
					continue;
				}
				par=section.AddParagraph();
				par.Format.Font=MigraDocHelper.CreateFont(10,true);
				par.Format.SpaceBefore=Unit.FromInch(.05);
				par.Format.SpaceAfter=Unit.FromInch(.05);
				patnum=0;
				if(tablename!="account"){//account123 etc.
					patnum=PIn.Long(tablename.Substring(7));
				}
				if(patnum!=0){
					par.AddText(fam.GetNameInFamFLnoPref(patnum));
				}
				//if(FamilyStatementDataList[famIndex].PatAboutList[i].ApptDescript!=""){
				//	par=section.AddParagraph();
				//	par.Format.Font=MigraDocHelper.CreateFont(9);//same as body font
				//	par.AddText(FamilyStatementDataList[famIndex].PatAboutList[i].ApptDescript);
				//}
				gridPat.BeginUpdate();
				gridPat.Rows.Clear();
				//lineData=FamilyStatementDataList[famIndex].PatDataList[i].PatData;
				for(int p=0;p<tableAccount.Rows.Count;p++) {
					if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
						if(Stmt.IsReceipt) {
							if(tableAccount.Rows[p]["StatementNum"].ToString()!="0") {//Hide statement rows for Canadian receipts.
								continue;
							}
							if(tableAccount.Rows[p]["ClaimNum"].ToString()!="0") {//Hide claim rows and claim payment rows for Canadian receipts.
								continue;
							}
						}
					}
					if(CultureInfo.CurrentCulture.Name=="en-US") {
						if(Stmt.IsReceipt) {
							if(tableAccount.Rows[p]["PayNum"].ToString()=="0") {//Hide everything except patient payments
								continue;
							}
						}
						//js Some additional features would be nice for receipts, such as hiding the bal column, the aging, and the amount due sections.
					}
					grow=new ODGridRow();
					grow.Cells.Add(tableAccount.Rows[p]["date"].ToString());
					grow.Cells.Add(tableAccount.Rows[p]["patient"].ToString());
					if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
						if(Stmt.IsReceipt) {
							grow.Cells.Add("");//Code: blank in Canada normally because this information is used on taxes and is considered a security concern.
							grow.Cells.Add("");//Tooth: blank in Canada normally because this information is used on taxes and is considered a security concern.
						}
						else {
							grow.Cells.Add(tableAccount.Rows[p]["ProcCode"].ToString());
							grow.Cells.Add(tableAccount.Rows[p]["tth"].ToString());
						}
					}
					else {
						grow.Cells.Add(tableAccount.Rows[p]["ProcCode"].ToString());
						grow.Cells.Add(tableAccount.Rows[p]["tth"].ToString());
					}
					if(CultureInfo.CurrentCulture.Name=="en-AU") {//English (Australia)
						if(tableAccount.Rows[p]["prov"].ToString().Trim()!="") {
							grow.Cells.Add(tableAccount.Rows[p]["prov"].ToString()+" - "+tableAccount.Rows[p]["description"].ToString());
						}
						else {//No provider on this account row item, so don't put the extra leading characters.
							grow.Cells.Add(tableAccount.Rows[p]["description"].ToString());
						}
					}
					else if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
						if(Stmt.IsReceipt) {
							if(PIn.Long(tableAccount.Rows[p]["ProcNum"].ToString())==0) {
								grow.Cells.Add(tableAccount.Rows[p]["description"].ToString());
							}
							else {//Only clear description for procedures.
								grow.Cells.Add("");//Description: blank in Canada normally because this information is used on taxes and is considered a security concern.
							}
						}
						else {
							grow.Cells.Add(tableAccount.Rows[p]["description"].ToString());
						}
					}
					else {//Assume English (United States)
						grow.Cells.Add(tableAccount.Rows[p]["description"].ToString());
					}
					grow.Cells.Add(tableAccount.Rows[p]["charges"].ToString());
					grow.Cells.Add(tableAccount.Rows[p]["credits"].ToString());
					grow.Cells.Add(tableAccount.Rows[p]["balance"].ToString());
					gridPat.Rows.Add(grow);
				}
				gridPat.EndUpdate();
				MigraDocHelper.DrawGrid(section,gridPat);
				//Total
				frame=MigraDocHelper.CreateContainer(section);
				font=MigraDocHelper.CreateFont(9,true);
				float totalPos=((float)(doc.DefaultPageSetup.PageWidth.Inch//-doc.DefaultPageSetup.LeftMargin.Inch
					//-doc.DefaultPageSetup.RightMargin.Inch)
					)*100f)/2f+(float)gridPat.WidthAllColumns/2f+7;
				RectangleF rectF=new RectangleF(0,0,totalPos,16);
				if(patnum!=0){
					MigraDocHelper.DrawString(frame," ",
						//I decided this was unnecessary:
						//dataSet.Tables["patient"].Rows[fam.GetIndex(patnum)]["balance"].ToString(),
						font,rectF,ParagraphAlignment.Right);
					//MigraDocHelper.DrawString(frame,FamilyStatementDataList[famIndex].PatAboutList[i].Balance.ToString("F"),font,rectF,
					//	ParagraphAlignment.Right);
				}
			}
			gridPat.Dispose();
			//Future appointments---------------------------------------------------------------------------------------------
			#region Future appointments
			if(!Stmt.IsReceipt && !Stmt.IsInvoice) {
				font=MigraDocHelper.CreateFont(9);
				DataTable tableAppt=dataSet.Tables["appts"];
				if(tableAppt.Rows.Count>0) {
					par=section.AddParagraph();
					par.Format.Font=font;
					par.AddText(Lan.g(this,"Scheduled Appointments:"));
				}
				for(int i=0;i<tableAppt.Rows.Count;i++) {
					par.AddLineBreak();
					par.AddText(tableAppt.Rows[i]["descript"].ToString());
				}
				if(tableAppt.Rows.Count>0) {
					MigraDocHelper.InsertSpacer(section,10);
				}
			}
			#endregion Future appointments
			//Region specific static notes------------------------------------------------------------------------------------
			if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
				if(Stmt.IsReceipt) {
					font=MigraDocHelper.CreateFont(9);
					par=section.AddParagraph();
					par.Format.Font=font;
					par.AddText("KEEP THIS RECEIPT FOR INCOME TAX PURPOSES");
					MigraDocHelper.InsertSpacer(section,10);
				}
			}
			//Note------------------------------------------------------------------------------------------------------------
			font=MigraDocHelper.CreateFont(9);
			par=section.AddParagraph();
			par.Format.Font=font;
			par.AddText(Stmt.Note);
			//bold note
			if(Stmt.NoteBold!=""){
				MigraDocHelper.InsertSpacer(section,10);
				font=MigraDocHelper.CreateFont(10,true,System.Drawing.Color.DarkRed);
				par=section.AddParagraph();
				par.Format.Font=font;
				par.AddText(Stmt.NoteBold);
			}
			#region SwissBanking
			if(CultureInfo.CurrentCulture.Name.EndsWith("CH")){//CH is for switzerland. eg de-CH
				//&& pagesPrinted==0)//only on the first page
			//{
				//float yred=744;//768;//660 for testing
				//Red line (just temp)
				//g.DrawLine(Pens.Red,0,yred,826,yred);
				MigraDoc.DocumentObjectModel.Font swfont=MigraDocHelper.CreateFont(10);
					//new Font(FontFamily.GenericSansSerif,10);
				//Bank Address---------------------------------------------------------
				HeaderFooter footer=section.Footers.Primary;
				footer.Format.Borders.Color=Colors.Black;
				//footer.AddParagraph(PrefC.GetString(PrefName.BankAddress"));
				frame=footer.AddTextFrame();
				frame.RelativeVertical=RelativeVertical.Line;
				frame.RelativeHorizontal=RelativeHorizontal.Page;
				frame.MarginLeft=Unit.Zero;
				frame.MarginTop=Unit.Zero;
				frame.Top=TopPosition.Parse("0 in");
				frame.Left=LeftPosition.Parse("0 in");
				frame.Width=Unit.FromInch(8.3);
				frame.Height=300;
				//RectangleF=new RectangleF(0,0,
				MigraDocHelper.DrawString(frame,PrefC.GetString(PrefName.BankAddress),swfont,30,30);
				MigraDocHelper.DrawString(frame,PrefC.GetString(PrefName.BankAddress),swfont,246,30);
				//Office Name and Address----------------------------------------------
				text=PrefC.GetString(PrefName.PracticeTitle)+"\r\n"
					+PrefC.GetString(PrefName.PracticeAddress)+"\r\n";
				if(PrefC.GetString(PrefName.PracticeAddress2)!="") {
					text+=PrefC.GetString(PrefName.PracticeAddress2)+"\r\n";
				}
				text+=PrefC.GetString(PrefName.PracticeZip)+" "+PrefC.GetString(PrefName.PracticeCity);
				MigraDocHelper.DrawString(frame,text,swfont,30,89);
				MigraDocHelper.DrawString(frame,text,swfont,246,89);
				//Bank account number--------------------------------------------------
				string origBankNum=PrefC.GetString(PrefName.PracticeBankNumber);//must be exactly 9 digits. 2+6+1.
				//the 6 digit portion might have 2 leading 0's which would not go into the dashed bank num.
				string dashedBankNum="?";
				//examples: 01-200027-2
				//          01-4587-1  (from 010045871)
				if(origBankNum.Length==9) {
					dashedBankNum=origBankNum.Substring(0,2)+"-"
						+origBankNum.Substring(2,6).TrimStart(new char[] { '0' })+"-"
						+origBankNum.Substring(8,1);
				}
				swfont=MigraDocHelper.CreateFont(9,true);
					//new Font(FontFamily.GenericSansSerif,9,FontStyle.Bold);
				MigraDocHelper.DrawString(frame,dashedBankNum,swfont,95,169);
				MigraDocHelper.DrawString(frame,dashedBankNum,swfont,340,169);
				//Amount------------------------------------------------------------
				double amountdue=PatGuar.BalTotal-PatGuar.InsEst;
				text=amountdue.ToString("F2");
				text=text.Substring(0,text.Length-3);
				swfont=MigraDocHelper.CreateFont(10);
				MigraDocHelper.DrawString(frame,text,swfont,new RectangleF(50,205,100,25),ParagraphAlignment.Right);
				MigraDocHelper.DrawString(frame,text,swfont,new RectangleF(290,205,100,25),ParagraphAlignment.Right);
				text=amountdue.ToString("F2");//eg 92.00
				text=text.Substring(text.Length-2,2);//eg 00
				MigraDocHelper.DrawString(frame,text,swfont,185,205);
				MigraDocHelper.DrawString(frame,text,swfont,425,205);
				//Patient Address-----------------------------------------------------
				string patAddress=PatGuar.FName+" "+PatGuar.LName+"\r\n"
					+PatGuar.Address+"\r\n";
				if(PatGuar.Address2!="") {
					patAddress+=PatGuar.Address2+"\r\n";
				}
				patAddress+=PatGuar.Zip+" "+PatGuar.City;
				patAddress+=((PatGuar.Country=="")?"":"\r\n"+PatGuar.Country);
				MigraDocHelper.DrawString(frame,text,swfont,495,218);//middle left
				MigraDocHelper.DrawString(frame,text,swfont,30,263);//Lower left
				//Compute Reference#------------------------------------------------------
				//Reference# has exactly 27 digits
				//First 6 numbers are what we are calling the BankRouting number.
				//Next 20 numbers represent the invoice #.
				//27th number is the checksum
				string referenceNum=PrefC.GetString(PrefName.BankRouting);//6 digits
				if(referenceNum.Length!=6) {
					referenceNum="000000";
				}
				referenceNum+=PatGuar.PatNum.ToString().PadLeft(12,'0')
					//"000000000000"//12 0's
					+DateTime.Today.ToString("yyyyMMdd");//+8=20
				//for testing:
				//referenceNum+="09090271100000067534";
				//"00000000000000037112";
				referenceNum+=Modulo10(referenceNum).ToString();
				//at this point, the referenceNum will always be exactly 27 digits long.
				string spacedRefNum=referenceNum.Substring(0,2)+" "+referenceNum.Substring(2,5)+" "+referenceNum.Substring(7,5)
					+" "+referenceNum.Substring(12,5)+" "+referenceNum.Substring(17,5)+" "+referenceNum.Substring(22,5);
				//text=spacedRefNum.Substring(0,15)+"\r\n"+spacedRefNum.Substring(16)+"\r\n";
				//reference# at lower left above address.  Small
				swfont=MigraDocHelper.CreateFont(7);
				MigraDocHelper.DrawString(frame,spacedRefNum,swfont,30,243);
				//Reference# at upper right---------------------------------------------------------------
				swfont=MigraDocHelper.CreateFont(10);
				MigraDocHelper.DrawString(frame,spacedRefNum,swfont,490,140);
				//Big long number at the lower right--------------------------------------------------
				/*The very long number on the bottom has this format:
				>13 numbers > 27 numbers + 9 numbers >
				>Example: 0100000254306>904483000000000000000371126+ 010045871>
				>
				>The first group of 13 numbers would begin with either 01 or only have 
				>042 without any other following numbers.  01 would be used if there is 
				>a specific amount, and 042 would be used if there is not a specific 
				>amount billed. So in the example, the billed amount is 254.30.  It has 
				>01 followed by leading zeros to fill in the balance of the digits 
				>required.  The last digit is a checksum done by the program.  If the 
				>amount would be 1,254.30 then the example should read 0100001254306.
				>
				>There is a > separator, then the reference number made up previously.
				>
				>Then a + separator, followed by the bank account number.  Previously, 
				>the number printed without the zeros, but in this case it has the zeros 
				>and not the dashes.*/
				swfont=new MigraDoc.DocumentObjectModel.Font("OCR-B 10 BT",12);
				text="01"+amountdue.ToString("F2").Replace(".","").PadLeft(10,'0');
				text+=Modulo10(text).ToString()+">"
					+referenceNum+"+ "+origBankNum+">";
				MigraDocHelper.DrawString(frame,text,swfont,255,345);
			}
			#endregion SwissBanking
			return doc;
		}
		private MigraDoc.DocumentObjectModel.Document CreateDocument(){
			MigraDoc.DocumentObjectModel.Document doc= new MigraDoc.DocumentObjectModel.Document();
			doc.DefaultPageSetup.PageWidth=Unit.FromInch(8.5);
			doc.DefaultPageSetup.PageHeight=Unit.FromInch(11);
			doc.DefaultPageSetup.TopMargin=Unit.FromInch(.5);
			doc.DefaultPageSetup.LeftMargin=Unit.FromInch(.5);
			doc.DefaultPageSetup.RightMargin=Unit.FromInch(.5);
			MigraDoc.DocumentObjectModel.Section section=doc.AddSection();
			string text;
			MigraDoc.DocumentObjectModel.Font headingFont=MigraDocHelper.CreateFont(13,true);
			MigraDoc.DocumentObjectModel.Font bodyFontx=MigraDocHelper.CreateFont(9,false);
			MigraDoc.DocumentObjectModel.Font nameFontx=MigraDocHelper.CreateFont(9,true);
			MigraDoc.DocumentObjectModel.Font totalFontx=MigraDocHelper.CreateFont(9,true);
			//Heading---------------------------------------------------------------------------------------------------------------
			#region printHeading
			Paragraph par=section.AddParagraph();
			ParagraphFormat parformat=new ParagraphFormat();
			parformat.Alignment=ParagraphAlignment.Center;
			parformat.Font=MigraDocHelper.CreateFont(10,true);
			par.Format=parformat;
			if(gridPlans.SelectedIndices[0]==0) {//current TP
				text=Lan.g(this,"Proposed Treatment Plan");
			}
			else {
				text=PlanList[gridPlans.SelectedIndices[0]-1].Heading;
			}
			par.AddFormattedText(text,headingFont);
			par.AddLineBreak();
			if(PatCur.ClinicNum==0) {
				text=PrefC.GetString(PrefName.PracticeTitle);
				par.AddText(text);
				par.AddLineBreak();
				text=PrefC.GetString(PrefName.PracticePhone);
			}
			else {
				Clinic clinic=Clinics.GetClinic(PatCur.ClinicNum);
				text=clinic.Description;
				par.AddText(text);
				par.AddLineBreak();
				text=clinic.Phone;
			}
			if(text.Length==10 && Application.CurrentCulture.Name=="en-US") {
				text="("+text.Substring(0,3)+")"+text.Substring(3,3)+"-"+text.Substring(6);
			}
			par.AddText(text);
			par.AddLineBreak();
			text=PatCur.GetNameFL()+", DOB "+PatCur.Birthdate.ToShortDateString();
			par.AddText(text);
			par.AddLineBreak();
			if(gridPlans.SelectedIndices[0]>0){//not the default plan
				if(PlanList[gridPlans.SelectedIndices[0]-1].ResponsParty!=0){
					text=Lan.g(this,"Responsible Party: ")
						+Patients.GetLim(PlanList[gridPlans.SelectedIndices[0]-1].ResponsParty).GetNameFL();
					par.AddText(text);
					par.AddLineBreak();
				}
			}
			if(gridPlans.SelectedIndices[0]==0) {//default TP
				text=DateTime.Today.ToShortDateString();
			}
			else {
				text=PlanList[gridPlans.SelectedIndices[0]-1].DateTP.ToShortDateString();
			}
			par.AddText(text);
			#endregion
			//Graphics---------------------------------------------------------------------------------------------------------------
			#region PrintGraphics
			TextFrame frame;
			int widthDoc=MigraDocHelper.GetDocWidth();
			if(PrefC.GetBool(PrefName.TreatPlanShowGraphics)) {	
				frame=MigraDocHelper.CreateContainer(section);
				MigraDocHelper.DrawString(frame,Lan.g(this,"Your")+"\r\n"+Lan.g(this,"Right"),bodyFontx,
					new RectangleF(widthDoc/2-toothChart.Width/2-50,toothChart.Height/2-10,50,100));
				MigraDocHelper.DrawBitmap(frame,chartBitmap,widthDoc/2-toothChart.Width/2,0);
				MigraDocHelper.DrawString(frame,Lan.g(this,"Your")+"\r\n"+Lan.g(this,"Left"),bodyFontx,
					new RectangleF(widthDoc/2+toothChart.Width/2+17,toothChart.Height/2-10,50,100));
				if(checkShowCompleted.Checked) {
					float yPos=toothChart.Height+15;
					float xPos=225;
					MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][3].ItemColor,xPos,yPos,14,14);
					xPos+=16;
					MigraDocHelper.DrawString(frame,Lan.g(this,"Existing"),bodyFontx,xPos,yPos);
					Graphics g=this.CreateGraphics();//for measuring strings.
					xPos+=(int)g.MeasureString(Lan.g(this,"Existing"),bodyFont).Width+23;
					//The Complete work is actually a combination of EC and C. Usually same color.
					//But just in case they are different, this will show it.
					MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][2].ItemColor,xPos,yPos,7,14);
					xPos+=7;
					MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][1].ItemColor,xPos,yPos,7,14);
					xPos+=9;
					MigraDocHelper.DrawString(frame,Lan.g(this,"Complete"),bodyFontx,xPos,yPos);
					xPos+=(int)g.MeasureString(Lan.g(this,"Complete"),bodyFont).Width+23;
					MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][4].ItemColor,xPos,yPos,14,14);
					xPos+=16;
					MigraDocHelper.DrawString(frame,Lan.g(this,"Referred Out"),bodyFontx,xPos,yPos);
					xPos+=(int)g.MeasureString(Lan.g(this,"Referred Out"),bodyFont).Width+23;
					MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][0].ItemColor,xPos,yPos,14,14);
					xPos+=16;
					MigraDocHelper.DrawString(frame,Lan.g(this,"Treatment Planned"),bodyFontx,xPos,yPos);
					g.Dispose();
				}
			}	
			#endregion
			MigraDocHelper.InsertSpacer(section,10);
			MigraDocHelper.DrawGrid(section,gridMain);
			//Print benefits----------------------------------------------------------------------------------------------------
			#region printBenefits
			if(checkShowIns.Checked) {
				ODGrid gridFamIns=new ODGrid();
				this.Controls.Add(gridFamIns);
				gridFamIns.BeginUpdate();
				gridFamIns.Columns.Clear();
				ODGridColumn col=new ODGridColumn("",140);
				gridFamIns.Columns.Add(col);
				col=new ODGridColumn(Lan.g(this,"Primary"),70,HorizontalAlignment.Right);
				gridFamIns.Columns.Add(col);
				col=new ODGridColumn(Lan.g(this,"Secondary"),70,HorizontalAlignment.Right);
				gridFamIns.Columns.Add(col);
				gridFamIns.Rows.Clear();
				ODGridRow row;
				//Annual Family Max--------------------------
				row=new ODGridRow();
				row.Cells.Add(Lan.g(this,"Family Maximum"));
				row.Cells.Add(textFamPriMax.Text);
				row.Cells.Add(textFamSecMax.Text);
				gridFamIns.Rows.Add(row);
				//Family Deductible--------------------------
				row=new ODGridRow();
				row.Cells.Add(Lan.g(this,"Family Deductible"));
				row.Cells.Add(textFamPriDed.Text);
				row.Cells.Add(textFamSecDed.Text);
				gridFamIns.Rows.Add(row);
				//Print Family Insurance-----------------------
				MigraDocHelper.InsertSpacer(section,15);
				par=section.AddParagraph();
				par.Format.Alignment=ParagraphAlignment.Center;
				par.AddFormattedText(Lan.g(this,"Family Dental Insurance Benefits"),totalFontx);
				MigraDocHelper.InsertSpacer(section,2);
				MigraDocHelper.DrawGrid(section,gridFamIns);
				gridFamIns.Dispose();
				//Individual Insurance---------------------
				ODGrid gridIns=new ODGrid();
				this.Controls.Add(gridIns);
				gridIns.BeginUpdate();
				gridIns.Columns.Clear();
				col=new ODGridColumn("",140);
				gridIns.Columns.Add(col);
				col=new ODGridColumn(Lan.g(this,"Primary"),70,HorizontalAlignment.Right);
				gridIns.Columns.Add(col);
				col=new ODGridColumn(Lan.g(this,"Secondary"),70,HorizontalAlignment.Right);
				gridIns.Columns.Add(col);
				gridIns.Rows.Clear();
				//Annual Max--------------------------
				row=new ODGridRow();
				row.Cells.Add(Lan.g(this,"Annual Maximum"));
				row.Cells.Add(textPriMax.Text);
				row.Cells.Add(textSecMax.Text);
				gridIns.Rows.Add(row);
				//Deductible--------------------------
				row=new ODGridRow();
				row.Cells.Add(Lan.g(this,"Deductible"));
				row.Cells.Add(textPriDed.Text);
				row.Cells.Add(textSecDed.Text);
				gridIns.Rows.Add(row);
				//Deductible Remaining--------------------------
				row=new ODGridRow();
				row.Cells.Add(Lan.g(this,"Deductible Remaining"));
				row.Cells.Add(textPriDedRem.Text);
				row.Cells.Add(textSecDedRem.Text);
				gridIns.Rows.Add(row);
				//Insurance Used--------------------------
				row=new ODGridRow();
				row.Cells.Add(Lan.g(this,"Insurance Used"));
				row.Cells.Add(textPriUsed.Text);
				row.Cells.Add(textSecUsed.Text);
				gridIns.Rows.Add(row);
				//Pending--------------------------
				row=new ODGridRow();
				row.Cells.Add(Lan.g(this,"Pending"));
				row.Cells.Add(textPriPend.Text);
				row.Cells.Add(textSecPend.Text);
				gridIns.Rows.Add(row);
				//Remaining--------------------------
				row=new ODGridRow();
				row.Cells.Add(Lan.g(this,"Remaining"));
				row.Cells.Add(textPriRem.Text);
				row.Cells.Add(textSecRem.Text);
				gridIns.Rows.Add(row);
				gridIns.EndUpdate();
				//Print Individual Insurance-------------------------
				MigraDocHelper.InsertSpacer(section,15);
				par=section.AddParagraph();
				par.Format.Alignment=ParagraphAlignment.Center;
				par.AddFormattedText(Lan.g(this,"Individual Dental Insurance Benefits"),totalFontx);
				MigraDocHelper.InsertSpacer(section,2);
				MigraDocHelper.DrawGrid(section,gridIns);
				gridIns.Dispose();
			}
			#endregion
			//Note------------------------------------------------------------------------------------------------------------
			#region printNote
			string note="";
			if(gridPlans.SelectedIndices[0]==0) {//current TP
				note=PrefC.GetString(PrefName.TreatmentPlanNote);
			}
			else {
				note=PlanList[gridPlans.SelectedIndices[0]-1].Note;
			}
			char nbsp='\u00A0';
			//to prevent collapsing of multiple spaces to single spaces.  We only do double spaces to leave single spaces in place.
			note=note.Replace("  ",nbsp.ToString()+nbsp.ToString());
			MigraDocHelper.InsertSpacer(section,20);
			par=section.AddParagraph(note);
			par.Format.Font=bodyFontx;
			par.Format.Borders.Color=Colors.Gray;
			par.Format.Borders.DistanceFromLeft=Unit.FromInch(.05);
			par.Format.Borders.DistanceFromRight=Unit.FromInch(.05);
			par.Format.Borders.DistanceFromTop=Unit.FromInch(.05);
			par.Format.Borders.DistanceFromBottom=Unit.FromInch(.05);
			#endregion
			//Signature-----------------------------------------------------------------------------------------------------------
			#region signature
			if(gridPlans.SelectedIndices[0]!=0//can't be default TP
				&& PlanList[gridPlans.SelectedIndices[0]-1].Signature!="")
			{
				System.Drawing.Bitmap sigBitmap=null;
				List<ProcTP> proctpList=ProcTPs.RefreshForTP(PlanList[gridPlans.SelectedIndices[0]-1].TreatPlanNum);
				if(PlanList[gridPlans.SelectedIndices[0]-1].SigIsTopaz){
					Control sigBoxTopaz=CodeBase.TopazWrapper.GetTopaz();
					sigBoxTopaz.Size=new System.Drawing.Size(362,79);
					Controls.Add(sigBoxTopaz);
					CodeBase.TopazWrapper.ClearTopaz(sigBoxTopaz);
					CodeBase.TopazWrapper.SetTopazCompressionMode(sigBoxTopaz,0);
					CodeBase.TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz,0);					
					string keystring=TreatPlans.GetHashString(PlanList[gridPlans.SelectedIndices[0]-1],proctpList);
					CodeBase.TopazWrapper.SetTopazKeyString(sigBoxTopaz,keystring);
					CodeBase.TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz,2);//high encryption
					CodeBase.TopazWrapper.SetTopazCompressionMode(sigBoxTopaz,2);//high compression
					CodeBase.TopazWrapper.SetTopazSigString(sigBoxTopaz,PlanList[gridPlans.SelectedIndices[0]-1].Signature);
					sigBoxTopaz.Refresh();
					//If sig is not showing, then try encryption mode 3 for signatures signed with old SigPlusNet.dll.
					if(CodeBase.TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz)==0) {
						CodeBase.TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz,3);//Unknown mode (told to use via TopazSystems)
						CodeBase.TopazWrapper.SetTopazSigString(sigBoxTopaz,PlanList[gridPlans.SelectedIndices[0]-1].Signature);
					}
					sigBitmap=new Bitmap(362,79);
					sigBoxTopaz.DrawToBitmap(sigBitmap,new Rectangle(0,0,362,79));//GetBitmap would probably work.
					Controls.Remove(sigBoxTopaz);
					sigBoxTopaz.Dispose();
				}
				else{
					SignatureBox sigBox=new SignatureBox();
					sigBox.Size=new System.Drawing.Size(362,79);
					sigBox.ClearTablet();
					//sigBox.SetSigCompressionMode(0);
					//sigBox.SetEncryptionMode(0);
					sigBox.SetKeyString(TreatPlans.GetHashString(PlanList[gridPlans.SelectedIndices[0]-1],proctpList));
					//"0000000000000000");
					//sigBox.SetAutoKeyData(ProcCur.Note+ProcCur.UserNum.ToString());
					//sigBox.SetEncryptionMode(2);//high encryption
					//sigBox.SetSigCompressionMode(2);//high compression
					sigBox.SetSigString(PlanList[gridPlans.SelectedIndices[0]-1].Signature);
					//if(sigBox.NumberOfTabletPoints()==0) {
					//	labelInvalidSig.Visible=true;
					//}
					//sigBox.SetTabletState(0);//not accepting input.  To accept input, change the note, or clear the sig.
					sigBitmap=(Bitmap)sigBox.GetSigImage(true);
				}
				if(sigBitmap!=null){
					frame=MigraDocHelper.CreateContainer(section);
					MigraDocHelper.DrawBitmap(frame,sigBitmap,widthDoc/2-sigBitmap.Width/2,20);
				}
			}
			#endregion
			return doc;
		}
Exemple #36
0
		///<summary>Calculates height of grid taking into account page breaks, word wrapping, cell width, font size, and actual data to be used to fill this grid.</summary>
		private static int CalculateGridHeightHelper(SheetField field,Sheet sheet,Graphics g,Statement stmt,int topMargin,int bottomMargin,MedLab medLab) {
			UI.ODGrid odGrid=new UI.ODGrid();
			odGrid.FontForSheets=new Font(field.FontName,field.FontSize,field.FontIsBold?FontStyle.Bold:FontStyle.Regular);
			odGrid.Width=field.Width;
			odGrid.HideScrollBars=true;
			odGrid.YPosField=field.YPos;
			odGrid.TopMargin=topMargin;
			odGrid.BottomMargin=bottomMargin;
			odGrid.PageHeight=sheet.HeightPage;
			odGrid.Title=field.FieldName;
			if(stmt!=null) {
				odGrid.Title+=(stmt.Intermingled?".Intermingled":".NotIntermingled");//Important for calculating heights.
			}
			DataTable Table=SheetUtil.GetDataTableForGridType(field.FieldName,stmt,medLab);
			List<DisplayField> Columns=SheetUtil.GetGridColumnsAvailable(field.FieldName);
			#region  Fill Grid
			odGrid.BeginUpdate();
			odGrid.Columns.Clear();
			ODGridColumn col;
			for(int i=0;i<Columns.Count;i++) {
				col=new ODGridColumn(Columns[i].InternalName,Columns[i].ColumnWidth);
				odGrid.Columns.Add(col);
			}
			ODGridRow row;
			for(int i=0;i<Table.Rows.Count;i++) {
				row=new ODGridRow();
				for(int c=0;c<Columns.Count;c++) {//Selectively fill columns from the dataTable into the odGrid.
					row.Cells.Add(Table.Rows[i][Columns[c].InternalName].ToString());
				}
				if(Table.Columns.Contains("PatNum")) {//Used for statments to determine account splitting.
					row.Tag=Table.Rows[i]["PatNum"].ToString();
				}
				odGrid.Rows.Add(row);
			}
			odGrid.EndUpdate(true);//Calls ComputeRows and ComputeColumns, meaning the RowHeights int[] has been filled.
			#endregion
			return odGrid.PrintHeight;
		}