private void FormRpRouting_Load(object sender, System.EventArgs e)
 {
     if (ApptNum != 0)
     {
         Appts = new Appointment[] { Appointments.GetOneApt(ApptNum) };
         if (Appts.Length == 0 || Appts[0] == null)
         {
             MsgBox.Show(this, "Appointment not found");
             return;
         }
         pagesPrinted                   = 0;
         pd                             = new PrintDocument();
         pd.PrintPage                  += new PrintPageEventHandler(this.pd_PrintPage);
         pd.OriginAtMargins             = true;
         pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
         printPreview                   = new OpenDental.UI.PrintPreview(PrintSituation.Default, pd, Appts.Length);
         printPreview.ShowDialog();
         DialogResult = DialogResult.OK;
     }
     for (int i = 0; i < Providers.List.Length; i++)
     {
         listProv.Items.Add(Providers.List[i].Abbr + " - " + Providers.List[i].LName + ", "
                            + Providers.List[i].FName);
         listProv.SetSelected(i, true);
     }
     textDate.Text = DateTime.Today.ToShortDateString();
 }
 private void butOK_Click(object sender, System.EventArgs e)
 {
     //validate user input
     if (textDate.errorProvider1.GetError(textDate) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDate.Text.Length == 0)
     {
         MessageBox.Show(Lan.g(this, "Date is required."));
         return;
     }
     date = PIn.PDate(textDate.Text);
     if (listProv.SelectedIndices.Count == 0)
     {
         MessageBox.Show(Lan.g(this, "You must select at least one provider."));
         return;
     }
     int[] provNums = new int[listProv.SelectedIndices.Count];
     for (int i = 0; i < provNums.Length; i++)
     {
         provNums[i] = Providers.List[listProv.SelectedIndices[i]].ProvNum;
     }
     Appts = Appointments.GetRouting(date, provNums);
     if (Appts.Length == 0)
     {
         MsgBox.Show(this, "There are no appointments scheduled for that date.");
         return;
     }
     pagesPrinted                   = 0;
     pd                             = new PrintDocument();
     pd.PrintPage                  += new PrintPageEventHandler(this.pd_PrintPage);
     pd.OriginAtMargins             = true;
     pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
     printPreview                   = new OpenDental.UI.PrintPreview(PrintSituation.Default, pd, Appts.Length);
     printPreview.ShowDialog();
     if (printPreview.DialogResult != DialogResult.OK)
     {
         return;
     }
     DialogResult = DialogResult.OK;
 }