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

            rpt.Site = this.Site;
            return(rpt);
        }
        private void btnPrintInvoice_Click(object sender, EventArgs e)
        {
            DataTable dt = main.ExecuteQuery("SELECT psh.printingSalesID, salesTime, "
                                             + "parentCompanyName, companyName, customerName, "
                                             + "tempo, purchaseOrderID as noPO, psd.printingType, psd.printingTitle, "
                                             + "jobType, CONCAT(quantity, ' ', quantityType) as quantity, "
                                             + "CONCAT(material, '; ', imageSize, '; ', sidePrint, '; ', psd.description) as description, "
                                             + "hargaMaterial, hargaOngkosCetak "
                                             + "FROM PrintingSalesHeader psh "
                                             + "LEFT JOIN PrintingSalesDetail psd ON psh.printingSalesID = psd.printingSalesID "
                                             + "LEFT JOIN MsCustomer cu ON cu.customerID = psh.customerID "
                                             + "LEFT JOIN MsCompany co ON co.companyID = cu.companyID "
                                             + "LEFT JOIN MsParentCompany pc ON co.parentCompanyID = pc.parentCompanyID "
                                             + "WHERE psh.printingSalesID = '" + salesID + "'");

            DataTable dtSub  = main.ExecuteQuery("SELECT * FROM PrintingSalesPayment WHERE printingSalesID = '" + salesID + "'");
            DataTable dtSub2 = main.ExecuteQuery("SELECT printingSalesID, printingType, printingTitle, finishingType, detail as descriptionFinishing FROM PrintingSalesDetailFinishing WHERE printingSalesID = '" + salesID + "'");

            if (dt == null)
            {
                MessageBox.Show("ERROR PRINT REPORT (LAPORAN HARIAN DI CLOSING FORM STATIONERY)");
                this.Dispose();
            }
            else
            {
                if (dt.Rows.Count > 0)
                {
                    Rahayu_Program.Report.PrintingSales.PrintingSalesInvoice laporan = new Rahayu_Program.Report.PrintingSales.PrintingSalesInvoice();

                    laporan.SetDataSource(dt);
                    laporan.SetParameterValue("SubjekPPH", rbPPh21.Checked ? "Subjek PPh 21" : "Subjek PPh 23");

                    laporan.Subreports["PrintingSalesSubReportPayment.rpt"].DataSourceConnections.Clear();
                    if (dtSub.Rows.Count > 0)
                    {
                        laporan.Subreports["PrintingSalesSubReportPayment.rpt"].SetDataSource(dtSub);
                    }
                    laporan.Subreports["PrintingSalesSubReportFinishing.rpt"].DataSourceConnections.Clear();
                    if (dtSub2.Rows.Count > 0)
                    {
                        laporan.Subreports["PrintingSalesSubReportFinishing.rpt"].SetDataSource(dtSub2);
                    }

                    buatLaporanByQuery(laporan, rbPPh21.Checked ? "Subjek PPh 21" : "Subjek PPh 23");

                    //direct print

                    /*laporan.PrintOptions.PrinterName = System.IO.File.ReadAllText(Application.StartupPath + @"\config\printer\printing-sales-notasetengah.is");
                     * laporan.PrintToPrinter(1, false, 0, 0);*/
                }
                else
                {
                    MessageBox.Show("DATA TIDAK ADA (LAPORAN HARIAN DI CLOSING FORM STATIONERY)");
                }
            }
        }