Пример #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            RFQ_Printout rpt = new RFQ_Printout();

            rpt.Site = this.Site;
            return(rpt);
        }
Пример #2
0
        private void RFQ_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();

            //---SELECT Statements
            //Why I didn't use MySQLDatabaseDriver: MySqlDataAdapter needs the select statement strings as one of its parameters (MySqlDataAdapter needed to fill the datasets)

            reicpomsds = new reicpomsDataSet();

            //Data from supplier_t (RFQ's Supplier)
            string selectRFQSupplier = string.Format("SELECT supplier_t.* " +
                                                     "FROM rfq_t, supplier_t " +
                                                     "WHERE rfq_no = '{0}' " +
                                                     "AND rfq_t.supplier_id = supplier_t.supplier_id;", rfqNo);

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

            //Further data from supplier_t (Supplier of all the items in the RFQ OrderLine | For some reason, if an item's supplier changes, the item won't appear in the RFQ anymore)
            string selectAllItemSupplier = string.Format("SELECT DISTINCT supplier_t.* " +
                                                         "FROM rfq_order_line_t, item_t, supplier_t " +
                                                         "WHERE rfq_no = '{0}' " +
                                                         "AND rfq_order_line_t.part_number = item_t.part_number " +
                                                         "AND item_t.supplier_id = supplier_t.supplier_id;", rfqNo);

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

            //Data from rfq_order_line_t, inserted into item_t
            string selectRFQOrderLineItems = 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 " +
                "SELECT item_t.*" +
                "FROM rfq_order_line_t, item_t " +
                "WHERE rfq_no = '{0}' " +
                "AND rfq_order_line_t.part_number = item_t.part_number;", rfqNo);

            //Will use only item_name, item_description, unit_of_measurement
            adapter = new MySqlDataAdapter(selectRFQOrderLineItems, connection);
            adapter.Fill(reicpomsds, "item_t"); //Inserted into item_t, since it's where item_name, item_description, and unit_of_measurement can be found

            //Data from rfq_t
            string selectRFQ = string.Format("SELECT * FROM rfq_t WHERE rfq_no='{0}';", rfqNo);

            adapter = new MySqlDataAdapter(selectRFQ, connection);
            adapter.Fill(reicpomsds, "rfq_t");

            //Data from rfq_order_line_t
            string selectRFQOrderLine = string.Format("SELECT * FROM rfq_order_line_t WHERE rfq_no='{0}';", rfqNo);

            adapter = new MySqlDataAdapter(selectRFQOrderLine, connection);
            adapter.Fill(reicpomsds, "rfq_order_line_t");

            connection.Close();

            //---INSTANTIATE CRYSTAL REPORT
            RFQ_Printout rfq = new RFQ_Printout();

            rfq.Load();
            rfq.SetDataSource(reicpomsds); //Added a code snippet in app.config file. If else, will result to a System.IOFileNotFoundException error.
            string fileName = "C:\\REIC Files\\Requests for Price Quotation\\RFQ " + RFQNo + ".pdf";

            if (FirstTime == true)
            {
                rfq.ExportToDisk(ExportFormatType.PortableDocFormat, fileName);
                MessageBox.Show("A PDF file of this Request for Price Quotation can be found in \nC:\\REIC Files\\Requests for Price Quotation.");
            }
            CrystalReportViewer.ReportSource = rfq; //Display RFQPrintout.rpt in the print preview
        }