Exemple #1
0
        public ProductBarcodePrintTemplateForm()
        {
            InitializeComponent();

            DataSet dsTempReport = new DataSet();

            try
            {
                string appPath = Directory.GetCurrentDirectory() + "\\" + globalConstants.ProductBarcodeXML;
                dsTempReport.ReadXml(@appPath);
                //prepare report for preview
                ProductBarcodePrintTemplate rptXMLReport = new ProductBarcodePrintTemplate();
                rptXMLReport.Database.Tables[0].SetDataSource(dsTempReport.Tables[0]);

                globalPrinterUtility gPrinter = new globalPrinterUtility();
                rptXMLReport.PrintOptions.PrinterName      = gPrinter.getConfigPrinterName(2);
                rptXMLReport.PrintOptions.PaperSize        = (CrystalDecisions.Shared.PaperSize)gPrinter.getReportPaperSize(globalPrinterUtility.LETTER_PAPER_SIZE);
                rptXMLReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                crystalReportViewer1.ReportSource = rptXMLReport;
                crystalReportViewer1.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void penerimaanBarangPrintOutForm_Load(object sender, EventArgs e)
        {
            DataSet dsTempReport = new DataSet();

            try
            {
                string appPath = Directory.GetCurrentDirectory() + "\\" + globalConstants.penerimaanBarangXML;
                dsTempReport.ReadXml(@appPath);

                //prepare report for preview
                penerimaanBarangPrintOut rptXMLReport = new penerimaanBarangPrintOut();
                CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader1, txtReportHeader2;
                txtReportHeader1 = rptXMLReport.ReportDefinition.ReportObjects["NamaTokoLabel"] as TextObject;
                txtReportHeader2 = rptXMLReport.ReportDefinition.ReportObjects["InfoTokoLabel"] as TextObject;
                String nama, alamat, telepon, email;
                if (!gUtil.loadinfotoko(2, out nama, out alamat, out telepon, out email))
                {
                    //reset default optsi = 1
                    if (!gUtil.loadinfotoko(1, out nama, out alamat, out telepon, out email))
                    {
                        nama    = "TOKO DEFAULT";
                        alamat  = "ALAMAT DEFAULT";
                        telepon = "0271-XXXXXXX";
                        email   = "*****@*****.**";
                    }
                }
                txtReportHeader1.Text = nama;
                txtReportHeader2.Text = alamat + Environment.NewLine + telepon + Environment.NewLine + email;
                rptXMLReport.Database.Tables[0].SetDataSource(dsTempReport.Tables[0]);

                globalPrinterUtility gPrinter = new globalPrinterUtility();
                rptXMLReport.PrintOptions.PrinterName = gPrinter.getConfigPrinterName(2);
                if (gUtil.getPaper() == 1)
                {
                    rptXMLReport.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)gPrinter.getReportPaperSize(globalPrinterUtility.HALF_KUARTO_PAPER_SIZE);
                }
                else
                {
                    rptXMLReport.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)gPrinter.getReportPaperSize(globalPrinterUtility.LETTER_PAPER_SIZE);
                }
                rptXMLReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                crystalReportViewer1.ReportSource = rptXMLReport;
                crystalReportViewer1.Refresh();

                if (gUtil.getPaper() == 1)
                {
                    rptXMLReport.PrintToPrinter(1, false, 0, 0);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void ReportProductInformationForm_Load(object sender, EventArgs e)
        {
            //on load
            DataSet dsTempReport          = new DataSet();
            globalPrinterUtility gPrinter = new globalPrinterUtility();

            try
            {
                string appPath = Directory.GetCurrentDirectory() + "\\" + globalConstants.ProductInformationXML;
                dsTempReport.ReadXml(@appPath);
                CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader1, txtReportHeader2;

                //prepare report for preview
                ReportProductInformation rptXMLReport = new ReportProductInformation();
                txtReportHeader1 = rptXMLReport.ReportDefinition.ReportObjects["NamaTokoLabel"] as TextObject;
                txtReportHeader2 = rptXMLReport.ReportDefinition.ReportObjects["InfoTokoLabel"] as TextObject;
                rptXMLReport.Database.Tables[0].SetDataSource(dsTempReport.Tables[0]);

                rptXMLReport.PrintOptions.PrinterName      = gPrinter.getConfigPrinterName(2);
                rptXMLReport.PrintOptions.PaperSize        = (CrystalDecisions.Shared.PaperSize)gPrinter.getReportPaperSize(globalPrinterUtility.LETTER_PAPER_SIZE);
                rptXMLReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                crystalReportViewer1.ReportSource = rptXMLReport;

                //baca database untuk nama toko
                String nama, alamat, telepon, email;
                if (!gutil.loadinfotoko(2, out nama, out alamat, out telepon, out email))
                {
                    //reset default optsi = 1
                    if (!gutil.loadinfotoko(1, out nama, out alamat, out telepon, out email))
                    {
                        nama    = "TOKO DEFAULT";
                        alamat  = "ALAMAT DEFAULT";
                        telepon = "0271-XXXXXXX";
                        email   = "*****@*****.**";
                    }
                }
                txtReportHeader1.Text = nama;
                txtReportHeader2.Text = alamat + Environment.NewLine + telepon + Environment.NewLine + email;
                //rptXMLReport.SetDataSource(dsTempReport);

                //crystalReportViewer1.DisplayGroupTree = false;
                crystalReportViewer1.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void ReportProductForm_Load(object sender, EventArgs e)
        {
            DataSet dsTempReport = new DataSet();
            string  appPath;
            //if (originModuleID == globalConstants.REPORT_STOCK_AGING)
            //{
            //    createAgingStockXML();
            //    try
            //    {
            //        appPath = Directory.GetCurrentDirectory() + "\\" + globalConstants.StockAgingXML;
            //        dsTempReport.ReadXml(@appPath);

            //        //prepare report for preview
            //        ReportProductAging rptXMLReport = new ReportProductAging();
            //        CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader1, txtReportHeader2;
            //        txtReportHeader1 = rptXMLReport.ReportDefinition.ReportObjects["NamaTokoLabel"] as TextObject;
            //        txtReportHeader2 = rptXMLReport.ReportDefinition.ReportObjects["InfoTokoLabel"] as TextObject;
            //        //baca database untuk nama toko
            //        String nama, alamat, telepon, email;
            //        if (!gutil.loadinfotoko(2, out nama, out alamat, out telepon, out email))
            //        {
            //            //reset default optsi = 1
            //            if (!gutil.loadinfotoko(1, out nama, out alamat, out telepon, out email))
            //            {
            //                nama = "TOKO DEFAULT";
            //                alamat = "ALAMAT DEFAULT";
            //                telepon = "0271-XXXXXXX";
            //                email = "*****@*****.**";
            //            }
            //        }
            //        txtReportHeader1.Text = nama;
            //        txtReportHeader2.Text = alamat + Environment.NewLine + telepon + Environment.NewLine + email;
            //        //rptXMLReport.SetDataSource(dsTempReport);
            //        rptXMLReport.Database.Tables[0].SetDataSource(dsTempReport.Tables[0]);
            //        crystalReportViewer1.ReportSource = rptXMLReport;
            //        crystalReportViewer1.Refresh();
            //    }
            //    catch (Exception ex)
            //    {
            //        MessageBox.Show(ex.Message);
            //    }
            //}
            //else
            {
                try
                {
                    appPath = Directory.GetCurrentDirectory() + "\\" + globalConstants.ProductXML;
                    dsTempReport.ReadXml(@appPath);

                    //prepare report for preview
                    ReportProduct rptXMLReport = new ReportProduct();
                    CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader1, txtReportHeader2;
                    txtReportHeader1 = rptXMLReport.ReportDefinition.ReportObjects["NamaTokoLabel"] as TextObject;
                    txtReportHeader2 = rptXMLReport.ReportDefinition.ReportObjects["InfoTokoLabel"] as TextObject;
                    //baca database untuk nama toko
                    String nama, alamat, telepon, email;
                    if (!gutil.loadinfotoko(2, out nama, out alamat, out telepon, out email))
                    {
                        //reset default optsi = 1
                        if (!gutil.loadinfotoko(1, out nama, out alamat, out telepon, out email))
                        {
                            nama    = "TOKO DEFAULT";
                            alamat  = "ALAMAT DEFAULT";
                            telepon = "0271-XXXXXXX";
                            email   = "*****@*****.**";
                        }
                    }
                    txtReportHeader1.Text = nama;
                    txtReportHeader2.Text = alamat + Environment.NewLine + telepon + Environment.NewLine + email;
                    //rptXMLReport.SetDataSource(dsTempReport);
                    rptXMLReport.Database.Tables[0].SetDataSource(dsTempReport.Tables[0]);

                    globalPrinterUtility gPrinter = new globalPrinterUtility();
                    rptXMLReport.PrintOptions.PrinterName      = gPrinter.getConfigPrinterName(2);
                    rptXMLReport.PrintOptions.PaperSize        = (CrystalDecisions.Shared.PaperSize)gPrinter.getReportPaperSize(globalPrinterUtility.LETTER_PAPER_SIZE);
                    rptXMLReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                    crystalReportViewer1.ReportSource = rptXMLReport;
                    crystalReportViewer1.Refresh();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        private void ReportTopSalesGlobalForm_Load(object sender, EventArgs e)
        {
            DataSet dsTempReport = new DataSet();

            if (originmoduleID == globalConstants.REPORT_TOPSALES_GLOBAL)
            {
                try
                {
                    string appPath = "";
                    appPath = Directory.GetCurrentDirectory() + "\\" + globalConstants.TopSalesGlobalXML;
                    dsTempReport.ReadXml(@appPath);
                    //prepare report for preview
                    ReportTopSalesGlobal rptXMLReport = new ReportTopSalesGlobal();
                    CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader1, txtReportHeader2, txtReportHeader3;
                    txtReportHeader1 = rptXMLReport.ReportDefinition.ReportObjects["NamaTokoLabel"] as TextObject;
                    txtReportHeader2 = rptXMLReport.ReportDefinition.ReportObjects["InfoTokoLabel"] as TextObject;
                    txtReportHeader3 = rptXMLReport.ReportDefinition.ReportObjects["TitleLabel"] as TextObject;
                    //baca database untuk nama toko
                    String nama, alamat, telepon, email;
                    if (!gutil.loadinfotoko(2, out nama, out alamat, out telepon, out email))
                    {
                        //reset default opsi = 1
                        if (!gutil.loadinfotoko(1, out nama, out alamat, out telepon, out email))
                        {
                            nama    = "TOKO DEFAULT";
                            alamat  = "ALAMAT DEFAULT";
                            telepon = "0271-XXXXXXX";
                            email   = "*****@*****.**";
                        }
                    }
                    txtReportHeader1.Text = nama;
                    txtReportHeader2.Text = alamat + Environment.NewLine + telepon + Environment.NewLine + email;
                    txtReportHeader3.Text = "GLOBAL";
                    rptXMLReport.Database.Tables[0].SetDataSource(dsTempReport.Tables[0]);

                    globalPrinterUtility gPrinter = new globalPrinterUtility();
                    rptXMLReport.PrintOptions.PrinterName      = gPrinter.getConfigPrinterName(2);
                    rptXMLReport.PrintOptions.PaperSize        = (CrystalDecisions.Shared.PaperSize)gPrinter.getReportPaperSize(globalPrinterUtility.LETTER_PAPER_SIZE);
                    rptXMLReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                    crystalReportViewer1.ReportSource = rptXMLReport;
                    crystalReportViewer1.Refresh();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                try
                {
                    string appPath = "";
                    appPath = Directory.GetCurrentDirectory() + "\\" + globalConstants.TopSalesbyDateXML;
                    dsTempReport.ReadXml(@appPath);
                    //prepare report for preview
                    ReportTopSalesGlobal rptXMLReport = new ReportTopSalesGlobal();
                    CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader1, txtReportHeader2, txtReportHeader3;
                    txtReportHeader1 = rptXMLReport.ReportDefinition.ReportObjects["NamaTokoLabel"] as TextObject;
                    txtReportHeader2 = rptXMLReport.ReportDefinition.ReportObjects["InfoTokoLabel"] as TextObject;
                    txtReportHeader3 = rptXMLReport.ReportDefinition.ReportObjects["TitleLabel"] as TextObject;
                    //baca database untuk nama toko
                    String nama, alamat, telepon, email;
                    if (!gutil.loadinfotoko(2, out nama, out alamat, out telepon, out email))
                    {
                        //reset default opsi = 1
                        if (!gutil.loadinfotoko(1, out nama, out alamat, out telepon, out email))
                        {
                            nama    = "TOKO DEFAULT";
                            alamat  = "ALAMAT DEFAULT";
                            telepon = "0271-XXXXXXX";
                            email   = "*****@*****.**";
                        }
                    }
                    txtReportHeader1.Text = nama;
                    txtReportHeader2.Text = alamat + Environment.NewLine + telepon + Environment.NewLine + email;
                    dateTo   = dateTo.Substring(0, 4) + "/" + dateTo.Substring(4, 2) + "/" + dateTo.Substring(6, 2);
                    dateFrom = dateFrom.Substring(0, 4) + "/" + dateFrom.Substring(4, 2) + "/" + dateFrom.Substring(6, 2);
                    txtReportHeader3.Text = "DARI TANGGAL " + dateFrom + " SAMPAI TANGGAL " + dateTo;
                    rptXMLReport.Database.Tables[0].SetDataSource(dsTempReport.Tables[0]);
                    crystalReportViewer1.ReportSource = rptXMLReport;
                    crystalReportViewer1.Refresh();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }