public void PrintRepSalesReport() { frmViewReport oViewReport = new frmViewReport(); //DataSet ds = oMySql.get_summary_reps_sales(this.CompanyID); DataSet ds = new DataSet(); Boolean nView = true; /* * ds.Tables.Add(oMySql.GetDataTable(String.Format("SELECT *, c.Retail/c.NoSellers as Avg_Retail, c.NoItems/c.NoSellers as Av_Units FROM Customer c Where c.CompanyID='{0}'", this.CompanyID), "Summary")); * ds.Tables.Add(oMySql.GetDataTable(String.Format("SELECT * from BrochureByCustomer Where CompanyID='{0}' ", this.CompanyID), "BrochureByCustomer")); * ds.Tables.Add(oMySql.GetDataTable("SELECT * FROM Brochure Where CompanyID ='" + this.CompanyID + "' ", "Brochure")); * ds.Tables.Add(oMySql.GetDataTable("SELECT * FROM Prizes Where CompanyID ='" + this.CompanyID + "' ", "Prize")); * ds.Tables.Add(oMySql.GetDataTable(String.Format("SELECT * FROM Rep r Left Join Reps rs On r.ID = rs.ID Where r.CompanyID ='{0}' and rs.Name is not null Order By rs.Name", this.CompanyID), "Reps")); */ ds.Tables.Add(oMySql.GetDataTable(String.Format("SELECT *, c.Retail/c.NoSellers as Avg_Retail, c.NoItems/c.NoSellers as Av_Units FROM Customer c Left Join BrochureByCustomer bc On c.CompanyID=bc.CompanyID AND c.CustomerID=bc.CustomerID Left Join Reps r On c.Rep_ID=r.ID Where c.CompanyID='{0}' ORDER BY r.Name,c.CustomerID", this.CompanyID), "Summary")); ds.Tables.Add(oMySql.GetDataTable("SELECT * FROM Brochure Where CompanyID ='" + this.CompanyID + "' ", "Brochure")); ds.Tables.Add(oMySql.GetDataTable("SELECT * FROM Prizes Where CompanyID ='" + this.CompanyID + "' ", "Prize")); ds.Tables.Add(oMySql.GetDataTable(String.Format("SELECT r.*,rs.*,sum(c.Retail) as Retail, sum(Signed) as Signed, sum(NoSellers) as NoSellers, sum(NoItems) as NoItems, count(c.CustomerID) as NoCustomers FROM Rep r Left Join Customer c On c.CompanyID=r.CompanyID And r.ID=c.Rep_ID Left Join Reps rs On r.ID = rs.ID Where r.CompanyID ='{0}' Group By c.Rep_ID", this.CompanyID), "Reps")); ds.Tables.Add(oMySql.GetDataTable(String.Format("SELECT c.Rep_ID, c.RepID, bc.BrochureID, Avg(bc.Retail/c.Signed) as Retail FROM BrochureByCustomer bc Left Join Customer c On bc.CompanyID=c.CompanyID And bc.CustomerID=c.CustomerID Where bc.CompanyID='{0}' And Rep_ID > 0 Group By c.Rep_ID, bc.BrochureID", this.CompanyID), "Average")); summary_reps_sales oRpt7 = new summary_reps_sales(); oRpt7.SetDataSource(ds); // ds.WriteXml("RepSalesReport300.xml", XmlWriteMode.WriteSchema); if (nView) { oViewReport.cReport.ReportSource = oRpt7; oViewReport.ShowDialog(); } else { oRpt7.PrintToPrinter(1, true, 1, 100); } }
private void view_report(int nReport, String sCompany, String sCustomerID, bool nView) { DataSet ds1; Signature.Data.MySQL oMySql = new Signature.Data.MySQL(); // Sql Open switch (nReport) { case 1: ds1 = oMySql.get_summary_by_classes(sCompany, sCustomerID); summary_by_classes oRpt2 = new summary_by_classes(); oRpt2.SetDataSource(ds1); if (nView) { cReport.ReportSource = oRpt2; this.Text = "Summary by Classes"; this.Show(); } else { oRpt2.PrintToPrinter(1, true, 1, 100); } break; case 2: ds1 = oMySql.get_ranking_by_student(sCompany, sCustomerID, this.Selection); ranking_by_student oRpt1 = new ranking_by_student(); oRpt1.SetDataSource(ds1); if (nView) { cReport.ReportSource = oRpt1; this.Text = "Ranking by Student"; this.Show(); } else { oRpt1.PrintToPrinter(1, true, 1, 100); } break; case 3: ds1 = oMySql.get_summary_of_products_by_brochure(sCompany, sCustomerID); summary_of_products_by_brochure oRpt3 = new summary_of_products_by_brochure(); oRpt3.SetDataSource(ds1); if (nView) { cReport.ReportSource = oRpt3; this.Text = "Summary of Products by Brochure"; this.Show(); } else { oRpt3.PrintToPrinter(1, true, 1, 100); } break; case 4: ds1 = oMySql.get_detail_by_student_by_class(sCompany, sCustomerID); detail_by_student_by_class oRpt4 = new detail_by_student_by_class(); oRpt4.SetDataSource(ds1); if (nView) { cReport.ReportSource = oRpt4; this.Text = "Detail by Student by Class"; this.Show(); } else { oRpt4.PrintToPrinter(1, true, 1, 100); } break; case 5: ds1 = oMySql.get_detail_by_student(sCompany, sCustomerID); detail_by_student oRpt5 = new detail_by_student(); oRpt5.SetDataSource(ds1); if (nView) { cReport.ReportSource = oRpt5; this.Text = "Order Detail by Student"; this.Show(); } else { oRpt5.PrintToPrinter(1, true, 1, 100); } break; case 6: ds1 = oMySql.get_prize_summary_by_student_by_class(sCompany, sCustomerID); prize_summary_by_student_by_class oRpt6 = new prize_summary_by_student_by_class(); oRpt6.SetDataSource(ds1); if (nView) { cReport.ReportSource = oRpt6; this.Text = "Prize Summary by Student by Class"; this.Show(); } else { oRpt6.PrintToPrinter(1, true, 1, 100); } break; case 7: ds1 = oMySql.get_summary_reps_sales(sCompany); if (ds1 == null) { MessageBox.Show("BAD"); } summary_reps_sales oRpt7 = new summary_reps_sales(); oRpt7.SetDataSource(ds1); //ds1.WriteXml("..\\Reports\\dataset14.xml", XmlWriteMode.WriteSchema); if (nView) { this.Text = "Summary Rep Sales"; cReport.ReportSource = oRpt7; this.Show(); } else { oRpt7.PrintToPrinter(1, true, 1, 100); } break; case 8: { ds1 = oMySql.GetDataSetGAProducByBox(sCompany, sCustomerID); if (ds1 == null) { MessageBox.Show("Please check the database"); } GAInventoryBox oRpt = new GAInventoryBox(); oRpt.SetDataSource(ds1); ds1.WriteXml("dataset00.xml", XmlWriteMode.WriteSchema); if (nView) { this.Text = "Box Inventory"; cReport.ReportSource = oRpt; this.Show(); } else { oRpt.PrintToPrinter(1, true, 1, 100); } } break; case 9: { ds1 = oMySql.GetDataSetGAByBox(sCompany, sCustomerID); if (ds1 == null) { MessageBox.Show("Please check the database"); } FinalBillTally oRpt = new FinalBillTally(); oRpt.SetDataSource(ds1); ds1.WriteXml("dataset19.xml", XmlWriteMode.WriteSchema); if (nView) { this.Text = "Final Bill Tally Sheet"; cReport.ReportSource = oRpt; this.Show(); } else { oRpt.PrintToPrinter(1, true, 1, 100); } } break; case 10: { ds1 = oMySql.GetDiscrepancyLetters(sCompany, sCustomerID); if (ds1 == null) { MessageBox.Show("Please check the database"); } DiscrepancyList oRpt = new DiscrepancyList(); //ds1.WriteXml("dataset22.xml", XmlWriteMode.WriteSchema); oRpt.SetDataSource(ds1); if (nView) { this.Text = "Discrepancy List"; cReport.ReportSource = oRpt; this.Show(); } else { oRpt.PrintToPrinter(1, true, 1, 100); } } break; case 11: { ds1 = oMySql.GetCustomerPallets(sCompany, sCustomerID, Parameter_1); if (ds1 == null) { MessageBox.Show("Please check the database"); } PalletLabels oRpt = new PalletLabels(); //ds1.WriteXml("dataset25.xml", XmlWriteMode.WriteSchema); /*ParameterField ParamField = new ParameterField(); * ParameterDiscreteValue DiscreteVal = new ParameterDiscreteValue(); * * DiscreteVal.Value = "5"; * ParamField.CurrentValues.Add(DiscreteVal); * * //' Add the parameter to the parameter fields collection. * oRpt.ParameterFields.Add(ParamField);*/ /* ParameterFieldDefinitions crParameterFieldDefinitions; * ParameterFieldDefinition crParameterFieldDefinition; * ParameterDiscreteValue crParameterDiscreteValue; * ParameterValues crParameterValues; * * crParameterFieldDefinitions = oRpt.DataDefinition.ParameterFields; * //Access the specified parameter from the collection * * * * crParameterFieldDefinition = crParameterFieldDefinitions["BoxNumber"]; * crParameterValues = crParameterFieldDefinition.CurrentValues; * crParameterDiscreteValue = null; * * crParameterDiscreteValue = new ParameterDiscreteValue(); * crParameterDiscreteValue.Value = "3"; //2nd current value * * //Add the second current value for the parameter field * crParameterValues.Add(crParameterDiscreteValue); * * //All current parameter values must be applied for the parameter field. * crParameterFieldDefinition.ApplyCurrentValues(crParameterValues); * * * oRpt.SetParameterValue(0,Parameter_1); * */ oRpt.SetDataSource(ds1); if (nView) { this.Text = "Pallet Labels"; cReport.ReportSource = oRpt; this.Show(); } else { oRpt.PrintToPrinter(1, true, 1, 100); } } break; case 12: { ds1 = oMySql.GetCustomerStatement(sCompany, sCustomerID); if (ds1 == null) { MessageBox.Show("Please check the database"); } Statement oRpt = new Statement(); ds1.WriteXml("dataset26.xml", XmlWriteMode.WriteSchema); oRpt.SetDataSource(ds1); if (nView) { this.Text = "Statement"; cReport.ReportSource = oRpt; this.Show(); } else { oRpt.PrintToPrinter(1, true, 1, 100); } } break; case 13: { ds1 = oMySql.GetDiscrepancyLetters(sCompany, sCustomerID); if (ds1 == null) { MessageBox.Show("Please check the database"); } DiscrepancyLetters oRpt = new DiscrepancyLetters(); //ds1.WriteXml("dataset27.xml", XmlWriteMode.WriteSchema); oRpt.SetDataSource(ds1); if (nView) { this.Text = "Discrepancy Letters"; cReport.ReportSource = oRpt; this.Show(); } else { oRpt.PrintToPrinter(1, true, 1, 100); } } break; case 14: { ds1 = oMySql.GetPOReceive(sCompany, sParameter_1); if (ds1 == null) { MessageBox.Show("Please check the database"); } ds1.WriteXml("dataset29.xml", XmlWriteMode.WriteSchema); POReceive oRpt = new POReceive(); oRpt.SetDataSource(ds1); if (nView) { this.Text = "PO Receive"; cReport.ReportSource = oRpt; this.Show(); } else { oRpt.PrintToPrinter(1, true, 1, 100); } } break; case 15: { ds1 = oMySql.GetPOReceive(sCompany, sParameter_1); if (ds1 == null) { MessageBox.Show("Please check the database"); } ds1.WriteXml("dataset29.xml", XmlWriteMode.WriteSchema); POReceive oRpt = new POReceive(); oRpt.SetDataSource(ds1); if (nView) { this.Text = "PO Receive"; cReport.ReportSource = oRpt; this.Show(); } else { oRpt.PrintToPrinter(1, true, 1, 100); } } break; default: break; } //oMySql.Close(); }