Ejemplo n.º 1
0
        private void PrintBill()
        {
            PrintFrm print = new PrintFrm();

            DataTable dtb = new DataTable();
            API       api = new API();

            dtb = api.LoadPawn(txtPawnId.Text);
            ReportDataSource rptsrc = new ReportDataSource("DataSet1", dtb);

            print.reportViewer1.LocalReport.DataSources.Clear();
            print.reportViewer1.LocalReport.DataSources.Add(rptsrc);

            print.reportViewer1.LocalReport.Refresh();
            print.Show();
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (Program.Pawn_id == "")
            {
                MessageBox.Show("ກະລຸນາເລືອກການຈຳກ່ອນ");
            }
            else
            {
                PrintFrm  print = new PrintFrm();
                DataTable dtb   = new DataTable();
                API       api   = new API();
                dtb = api.LoadPawn(Program.Pawn_id);
                ReportDataSource rptsrc = new ReportDataSource("DataSet1", dtb);

                print.reportViewer1.LocalReport.DataSources.Clear();
                print.reportViewer1.LocalReport.DataSources.Add(rptsrc);

                print.reportViewer1.LocalReport.Refresh();


                ClearOldFrm();
                ShowNewFrm(print);


                print.pawn_viewTableAdapter.Fill(print.khounthavyDataSet.Pawn_view);

                print.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);

                byte[]     pdfContent = print.reportViewer1.LocalReport.Render(format: "PDF", deviceInfo: "<DeviceInfo><EmbedFonts>None</EmbedFonts></DeviceInfo>");
                String     pdfPath    = Directory.GetCurrentDirectory() + @"\report.PDF";
                FileStream pdfFile    = new FileStream(pdfPath, FileMode.Create);
                pdfFile.Write(pdfContent, 0, pdfContent.Length);
                pdfFile.Close();

                print.axAcroPDF.src = pdfPath;
            }
        }