Beispiel #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            SPR_PQCompleted rpt = new SPR_PQCompleted();

            rpt.Site = this.Site;
            return(rpt);
        }
Beispiel #2
0
        private void SPR_PQCompleted_PrintScreen_Load(object sender, EventArgs e)
        {
            //---MYSQL CONNECTION
            connection = new MySqlConnection(ConnectionStringManager.reicpomsConnection.ConnectionString);
            connection.Open();

            //---SELECT Statements
            reicpomsds = new reicpomsDataSet();

            //Data from PQ Customers (Need DISTINCT, else ConstraintException; for some reason, without DISTINCT, some PQ rows have multiple copies)
            string selectPQCustomers = string.Format("SELECT DISTINCT customer_t.* " +
                                                     "FROM customer_t, pq_t, po_t " +
                                                     "WHERE pq_t.pq_no = po_t.pq_no " +
                                                     "AND pq_t.customer_id = customer_t.customer_id " +
                                                     "ORDER BY pq_t.pq_no DESC;");

            adapter = new MySqlDataAdapter(selectPQCustomers, connection);
            adapter.Fill(reicpomsds, "customer_t");

            //Data from pq_t
            string selectCompletedPQ = string.Format("SELECT DISTINCT pq_t.* " +
                                                     "FROM pq_t, po_t " +
                                                     "WHERE po_t.pq_no = pq_t.pq_no " +
                                                     "ORDER BY pq_t.pq_no DESC;");

            adapter = new MySqlDataAdapter(selectCompletedPQ, connection);
            adapter.Fill(reicpomsds, "pq_t");

            connection.Close();

            //---INSTANTIATE CRYSTAL REPORT
            SPR_PQCompleted pqc = new SPR_PQCompleted();

            pqc.Load();
            pqc.SetDataSource(reicpomsds); //Added a code snippet in app.config file. If else, will result to a System.IOFileNotFoundException error.

            //---EXPORT TO PDF
            string currentDateTime = DateTime.Now.ToString("yyyy-MM-dd hhmmtt");
            string filePath        = "C:\\REIC Files\\Sales Performance Report & Summary\\Price Quotations - Completed\\Completed PQ (" + currentDateTime + ").pdf";

            pqc.ExportToDisk(ExportFormatType.PortableDocFormat, filePath);

            MessageBox.Show("A PDF file of this report on completed price quotations can be found in \nC:\\REIC Files\\Sales Performance Report & Summary\\Price Quotations - Completed.");
            CrystalReportViewer.ReportSource = pqc;
        }