public override void button1_Click(object sender, EventArgs e) { if (checkBoxPrintDriverList.Checked) { ActiveDriver DriverRpt = new ActiveDriver(); DriverRpt.Load(); DriverRpt.SetDataSource(DataManager.getActiveDriverList()); PrintPreview myPPvw = new PrintPreview(DriverRpt); myPPvw.ShowDialog(); return; } base.button1_Click(sender, e); }
/// <summary> /// Prepares and launches the PrintPreview class and its containing report. /// </summary> private void launchprintpreview() { PrintPreview myPPvw; myReport = new CrystalReport1(); myReport.Load(); if (textBoxDriverPoolPerc.Text != "") { DataSet myDS = new DataSet("DnAPRESA Schema"); myDS.Tables.Add(myEmpList.getTable()); myDS.Tables[0].TableName = "DrugPool"; myDS.Tables.Add("CountData"); myDS.Tables["CountData"].Columns.Add("TotalActive"); myDS.Tables["CountData"].Columns.Add("PoolPerc"); myDS.Tables["CountData"].Columns.Add("AlchPerc"); myDS.Tables["CountData"].Rows.Add(new object[] { this.EmpTable.Rows.Count, textBoxDriverPoolPerc.Text, textBoxAlchoholPerc.Text }); //myDS.WriteXml("c:\\dnadata.xml"); //myDS.WriteXmlSchema("c:\\dnaschema.xsd"); myReport.SetDataSource(myDS); if (myDS.Tables["DrugPool"].Rows[0]["emplclas"].ToString() == "Driver") { ((CrystalDecisions.CrystalReports.Engine.TextObject) this.myReport.Section3.ReportObjects["Text4"]).Text = "Driver ID"; } else if (myDS.Tables["DrugPool"].Rows[0]["emplclas"].ToString() == "Carter Logistics Employee") { ((CrystalDecisions.CrystalReports.Engine.TextObject) this.myReport.Section3.ReportObjects["Text19"]).Text = ""; } myDS.Tables["DrugPool"].DefaultView.Sort = "lastname asc"; myPPvw = new PrintPreview(myReport); myPPvw.ShowDialog(); } ConfirmPrompt myCP = new ConfirmPrompt(); if (myCP.ShowDialog() == DialogResult.OK) { DataManager.insertHistory(myEmpList.getTable()); } }