Exemplo n.º 1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            POPrintout rpt = new POPrintout();

            rpt.Site = this.Site;
            return(rpt);
        }
Exemplo n.º 2
0
        private void PO_PrintScreen_Load(object sender, EventArgs e)
        { //When screen loads, details of the RFQ Printout should already be displayed.
            //---MYSQL CONNECTION
            connection = new MySqlConnection(ConnectionStringManager.reicpomsConnection.ConnectionString);
            connection.Open();

            //DEBUG MESSAGES
            if (connection.State == System.Data.ConnectionState.Open)
            {
                MessageBox.Show("Crystal Report: Connection to SQL successful!");
            }
            else
            {
                MessageBox.Show("Crystal Report: Connection to SQL failed!");
            }

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

            //Data from supplier_t
            string selectRFQSupplier = string.Format("SELECT supplier_t.supplier_id, supplier_name, contact_person, contact_number, email_address, address " +
                                                     "FROM po_t, supplier_t " +
                                                     "WHERE po_t = '{0}' " +
                                                     "AND po_t.supplier_id = supplier_t.supplier_id;", PONo);

            adapter = new MySqlDataAdapter(selectRFQSupplier, connection);
            adapter.Fill(reicpomsds, "supplier_t");

            //Data from po_order_line_t, inserted into item_t
            string selectPOOrderLineItems = string.Format("SELECT item_t.part_number, item_name, item_description, supplier_unit_price, mark_up_percentage, reic_unit_price, minimum_order_quantity, unit_of_measurement, from_date, to_date, supplier_id " +
                                                          "FROM po_order_line_t, item_t " +
                                                          "WHERE po_no = '{0}' " +
                                                          "AND po_order_line_t.part_number = item_t.part_number;", PONo);

            adapter = new MySqlDataAdapter(selectPOOrderLineItems, connection);
            adapter.Fill(reicpomsds, "item_t");

            //Data from po_t
            string selectPO = string.Format("SELECT * FROM po_t WHERE po_no='{0}';", PONo);

            adapter = new MySqlDataAdapter(selectPO, connection);
            adapter.Fill(reicpomsds, "po_t");

            //Data from po_order_line_t
            string selectPOOrderLine = string.Format("SELECT * FROM po_order_line_t WHERE po_no='{0}';", PONo);

            adapter = new MySqlDataAdapter(selectPOOrderLine, connection);
            adapter.Fill(reicpomsds, "po_order_line_t");

            connection.Close();

            //---INSTANTIATE CRYSTAL REPORT
            POPrintout po = new POPrintout();

            po.Load();
            po.SetDataSource(reicpomsds); //Added a code snippet in app.config file. If else, will result to a System.IOFileNotFoundException error.
            string fileName = "C:\\REIC Files\\Purchase Orders\\PO " + PONo + ".pdf";

            if (FirstTime == true)
            {
                po.ExportToDisk(ExportFormatType.PortableDocFormat, fileName);
                MessageBox.Show("A PDF file of this Purchase Order can be found in \nC:\\REIC Files\\Purchase Orders.");
            }
            CrystalReportViewer.ReportSource = po; //Display POPrintout.rpt in the print preview
        }