private void button1_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            PrinterSettings ps = new PrinterSettings();
            pd.PrinterSettings = ps;
            DialogResult dr = pd.ShowDialog();

            if (dr == DialogResult.OK) {
                QRPrint printer = new QRPrint();
                printer.PrintMode = QRPrint.PrintModes.PsyBanknote;
                printer.NotesPerPage = (int)numVouchersPerPage.Value;
                switch (cboArtworkStyle.Text.ToLower()) {
                    case "yellow":
                    case "green":
                    case "blue":
                    case "purple":
                    case "greyscale":
                        printer.ImageFilename = "note-" + cboArtworkStyle.SelectedItem.ToString().ToLowerInvariant() + ".png";
                        break;
                }
                printer.Denomination = txtDenomination.Text;
                printer.keys = new List<KeyCollectionItem>(Items.Count);
                printer.PreferUnencryptedPrivateKeys = chkPrintUnencrypted.Checked;
                foreach (KeyCollectionItem a in Items) printer.keys.Add(a);
                printer.PrinterSettings = pd.PrinterSettings;
                printer.Print();
                PrintAttempted = true;
            }
        }
Ejemplo n.º 2
0
        public static bool GetPrinterInfo(ref PrinterInfo printerInfo)
        {
            printerInfo.Status = Status.None;

            string query = string.Format("SELECT * from Win32_Printer WHERE Name LIKE '%{0}'", printerInfo.Caption);
            var searcher = new ManagementObjectSearcher(query);
            var coll = searcher.Get();

            foreach (ManagementObject printer in coll)
            {
                var ps = new PrinterSettings {PrinterName = printerInfo.Caption};
                if (ps.IsValid)
                {
                    printerInfo.Status = Status.OK;
                    printerInfo.Port = printer.Properties["PortName"].Value.ToString();
                    printerInfo.Driver = printer.Properties["DeviceID"].Value.ToString();
                    printerInfo.Color = ps.SupportsColor;
                    printerInfo.Name = printer.Properties["DeviceID"].Value.ToString();
                    printerInfo.Network = Convert.ToBoolean(printer.Properties["Network"].Value);
                }
                else
                {
                    printerInfo.Status = Status.Error;
                }
            }
            return true;
        }
Ejemplo n.º 3
0
        ////Lay thong tin ve kho giay
        public PaperSize GetPaperSize()
        {
            PrinterSettings printSet = new PrinterSettings();
            printSet.PrinterName = this.cboPrinter.Text;

            return printSet.PaperSizes[this.cboPaperSize.SelectedIndex];
        }
Ejemplo n.º 4
0
        public static void PrintReceiptForTransaction()
        {
            try
            {
                PrintDocument recordDoc = new PrintDocument();

                recordDoc.DocumentName    = "Transaction Receipt!";
                recordDoc.PrintPage      += new PrintPageEventHandler(PrintReceiptPage); // function below
                recordDoc.PrintController = new StandardPrintController();               // hides status dialog popup
                                                                                         // Comment if debugging
                PrinterSettings ps = new PrinterSettings();
                ps.PrinterName            = "POS";
                recordDoc.PrinterSettings = ps;
                recordDoc.Print();
                // --------------------------------------

                // Uncomment if debugging - shows dialog instead
                //PrintPreviewDialog printPrvDlg = new PrintPreviewDialog();
                //printPrvDlg.Document = recordDoc;
                //printPrvDlg.Width = 1200;
                //printPrvDlg.Height = 800;
                //printPrvDlg.ShowDialog();
                // --------------------------------------

                recordDoc.Dispose();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.UserSkins.BonusSkins.Register();
            UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");

            cashier = null;
            userAuthenticate = false;

            fruitsList = new ImageList();
            fruitsList.ImageSize = new Size(64, 64);
            fruitsList.Images.Clear();

            printTemplate = AppDomain.CurrentDomain.BaseDirectory + "printtemplate\\nutrition.png";

            printSetting = null;
            billingOder = null;
            Program.getFruitPool();
            

            if (!userAuthenticate)
            {
                Application.Run(new frmLogin());
            }

            if (userAuthenticate)
            {
                Application.Run(new frmMain());
            }
        }
Ejemplo n.º 6
0
    private void GenerateReport()
    {
        //dataTable

        ReportViewer1.Reset();

        DataTable        dt         = GetData();
        ReportDataSource dataSource = new ReportDataSource("DataSet1", dt);



        ReportViewer1.LocalReport.DataSources.Add(dataSource);
        ReportViewer1.LocalReport.ReportPath = "Laporan/InvRusak.rdlc";

        PageSettings pg = new System.Drawing.Printing.PageSettings();

        pg.Margins.Top    = 0;
        pg.Margins.Bottom = 0;
        pg.Margins.Left   = 0;
        pg.Margins.Right  = 0;

        PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();

        ps.PrinterName = "Microsoft XPS Document Writer";

        PaperSize size = new PaperSize();

        size.RawKind       = (int)PaperKind.A4;
        pg.PaperSize       = size;
        pg.PrinterSettings = ps;
        ReportViewer1.SetPageSettings(pg);

        ReportViewer1.LocalReport.Refresh();
    }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                PrinterSettings printSet = new PrinterSettings();//打印机设置

                if (this.pageSet != null)
                {
                    printDocument.DefaultPageSettings = this.pageSet;
                }

                printD.PrinterSettings = printSet;

                printD.Document = printDocument;
                printDocument.DocumentName = "NavicertCard";

                if (printD.ShowDialog() == DialogResult.OK)
                {
                    printDocument.Print();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 프린터 설정 관련 객체
            PrinterSettings ps = new PrinterSettings();

            // 프린터 설정 관련 다이얼로그
            PrintDialog pdlg = new PrintDialog();

            // 설정 내용을 ps에 담음
            pdlg.PrinterSettings = ps;

            // PrintDialog 대화상자 출력
            pdlg.ShowDialog();

            string info = String.Format(" PrinterName = {0} \r\n PaperSizes = {1}",
                                          ps.PrinterName, ps.Copies);
            MessageBox.Show(info);

            /*
            // 프린트 설정내용을 PrintDocument 객체에 설정
            PrintDocument pd1 = new PrintDocument();
            pd1.PrinterSettings = ps;
            ...
            */
        }
Ejemplo n.º 9
0
        public void print()
        {
            PrintDialog pd = new PrintDialog();
            PrintDocument pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font =new Font("Arial",12);
            PaperSize psize = new PaperSize("Custome", 100, 200);
            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;
            pdoc.DefaultPageSettings.PaperSize.Height = 320;
            pdoc.DefaultPageSettings.PaperSize.Width = 200;
            pdoc.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog ppd = new PrintPreviewDialog();
                ppd.Document = pdoc;
                result = ppd.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();

                }
            }



        }
        static void Test2()
        {
            var s1 = Marshal.SizeOf(typeof(FormInfo1));


            string p0 = null;
            var    p1 = @"\\ZZ-PC\Brother HL-1110 series";
            var    p2 = @"\\ZZ-PC\Jolimark 24-pin printer";
            var    p3 = "Microsoft XPS Document Writer";

            SetForm(p3);
            //var ps1 = GetForms(p1).Cast<FormInfo1>().Where(p => p.Flags == FormInfoFlags.Printer).ToArray();
            //var ps2 = GetForms(p2).Cast<FormInfo1>().Where(p => p.Flags == FormInfoFlags.Printer).ToArray();

            //var ps3 = GetForms(p3).Cast<FormInfo1>().Where(p => p.Flags == FormInfoFlags.Printer).ToArray();
            //var ps0 = GetForms(p0).Cast<FormInfo1>().Where(p => p.Flags == FormInfoFlags.Printer).ToArray();



            var w2 = (int)(215.9f * 1000);
            var h2 = (int)(139.7f * 1000);
            //AddCustomPaperSize(p3, "Test241/2", w2, h2);


            var ps32 = GetPrinterFormsWithLevel1(p3).Cast <FormInfo2>().Where(p => p.Flags == FormInfoFlags.User).ToArray();
            //var ps32 = GetForms(p3).Cast<FormInfo1>().Where(p => p.Flags == FormInfoFlags.User).ToArray();
            //var ps02 = GetForms(p0).Cast<FormInfo1>().Where(p => p.Flags == FormInfoFlags.User).ToArray();

            var settings3 = new System.Drawing.Printing.PrinterSettings();

            settings3.PrinterName = p3;
            var papers3 = settings3.PaperSizes.Cast <PaperSize>().Where(p => p.Kind == PaperKind.Custom).ToArray();

            var papers4 = GetPrinterPapers(p3).Where(p => p.Kind == PaperKind.Custom).ToArray();
        }
Ejemplo n.º 11
0
        public void print()
        {
            PrintDialog pd = new PrintDialog();
            pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font = new Font("Courier New", 15);

             //PaperSize psize = new PaperSize("Custom", 219, 1000);
            pd.Document = pdoc;
            //pd.Document.DefaultPageSettings.PaperSize = psize;

            if (pd.Document.DefaultPageSettings.PaperSize.Width <= 284)
            {
                k = Convert.ToDouble(pd.Document.DefaultPageSettings.PaperSize.Width) / 284;
            }

            pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog pp = new PrintPreviewDialog();
                pp.Document = pdoc;
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
                pp.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
                pp.PrintPreviewControl.Zoom = 1f;
                result = pp.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();
                }
            }
        }
Ejemplo n.º 12
0
        public void printDataTable(DataTable dt, PrintInfo p)
        {
            this.printDt = dt;
            this.pInfo   = p;
            PrintDocument   pd  = new System.Drawing.Printing.PrintDocument();
            PrinterSettings pss = new System.Drawing.Printing.PrinterSettings();

            pss.DefaultPageSettings.Landscape = pInfo.landscape;
            pd.PrinterSettings = pss;

            pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage);

            PrintDialog ppd = new PrintDialog();

            ppd.Document = pd;
            if (printDt == null)
            {
                MessageBox.Show("出错", "没有可以打印的数据", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (ppd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    pd.Print();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("出错", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 13
0
		internal void LoadDefaultResolutions (PrinterSettings.PrinterResolutionCollection col)
		{
			col.Add (new PrinterResolution ((int) PrinterResolutionKind.High, -1, PrinterResolutionKind.High));
			col.Add (new PrinterResolution ((int) PrinterResolutionKind.Medium, -1, PrinterResolutionKind.Medium));
			col.Add (new PrinterResolution ((int) PrinterResolutionKind.Low, -1, PrinterResolutionKind.Low));
			col.Add (new PrinterResolution ((int) PrinterResolutionKind.Draft, -1, PrinterResolutionKind.Draft));
		}
Ejemplo n.º 14
0
        private void comboBoxPaperSizes_SelectedIndexChanged(object sender, EventArgs e)
        {
            var ps = this.GetCurentPrinterSettings();

            var selected_papername = this.comboBoxPaperSizes.SelectedItem.ToString();

            if (ps.DefaultPageSettings.PaperSize.PaperName == selected_papername)
            {
                return;
            }

            var papersizes_dic = ps.PaperSizes.AsEnumerable().ToDictionary(size => size.PaperName);

            if (papersizes_dic.ContainsKey(selected_papername))
            {
                ps.DefaultPageSettings.PaperSize = papersizes_dic[selected_papername];

                this.m_printsettings = ps;
                this.UpdateUI();
                this.panelRenderBox.Invalidate();
            }
            else
            {
                MessageBox.Show("ERROR");
            }
        }
Ejemplo n.º 15
0
        ///<summary>
        /// Creates a new instance of the Page Setup Form
        ///</summary>
        ///<param name="settings"></param>
        public PageSetupForm(PrinterSettings settings)
        {
            //This call is required by the Windows Form Designer.
            InitializeComponent();

            //Store the printer settings
            _printerSettings = settings;

            //Gets the list of available paper sizes
            ComboPaperSizes.SuspendLayout();
            PrinterSettings.PaperSizeCollection paperSizes = _printerSettings.PaperSizes;
            foreach (PaperSize ps in paperSizes)
                ComboPaperSizes.Items.Add(ps.PaperName);
            ComboPaperSizes.SelectedItem = settings.DefaultPageSettings.PaperSize.PaperName;
            if (ComboPaperSizes.SelectedIndex == -1) ComboPaperSizes.SelectedIndex = 1;
            ComboPaperSizes.ResumeLayout();

            //Gets the paper orientation
            if (_printerSettings.DefaultPageSettings.Landscape)
                _rdbLandscape.Checked = true;
            else
                _rdbPortrait.Checked = true;

            //Gets the margins
            _left = settings.DefaultPageSettings.Margins.Left / 100.0;
            txtBoxLeft.Text = String.Format("{0:0.00}", _left);
            _top = settings.DefaultPageSettings.Margins.Top / 100.0;
            txtBoxTop.Text = String.Format("{0:0.00}", _top);
            _bottom = settings.DefaultPageSettings.Margins.Bottom / 100.0;
            txtBoxBottom.Text = String.Format("{0:0.00}", _bottom);
            _right = settings.DefaultPageSettings.Margins.Right / 100.0;
            txtBoxRight.Text = String.Format("{0:0.00}", _right);
        }
Ejemplo n.º 16
0
 public StrukPrint()
 {
     printDocObatBebas.PrintPage += new PrintPageEventHandler(printDoc_obatBebas_PrintPage);
     printDocResepDokter.PrintPage += new PrintPageEventHandler(printDoc_resepDokter_PrintPage);
     printDocGantiOperator.PrintPage += new PrintPageEventHandler(printDoc_gantiOperator_PrintPage);
     System.OperatingSystem osInfo = System.Environment.OSVersion;
     //MessageBox.Show(osInfo.Version.ToString());
     PrinterSettings setttt = new PrinterSettings();
     foreach(string printer in PrinterSettings.InstalledPrinters)
     {
         setttt.PrinterName = printer;
         if (setttt.IsDefaultPrinter)
         {
             if (printer.ToLower().Contains("220"))
             {
                 this.fontSize = 8.55F;
                 this.paperWidth = 32;
                 this.strips = "================================\n";
                 this.singleStrips = "--------------------------------\n";
                 this.marginLeftSubs = 90;
             }
             else
             {
                 this.fontSize = 8.5F;
                 this.paperWidth = 34;
                 this.strips = "==================================\n";
                 this.singleStrips = "----------------------------------\n";
                 this.marginLeftSubs = 85;
             }
         }
     }
 }
	protected InvalidPrinterException
				(SerializationInfo info, StreamingContext ctxt)
			: base(info, ctxt)
			{
				settings = (PrinterSettings)
					info.GetValue("settings", typeof(PrinterSettings));
			}
Ejemplo n.º 18
0
        public JsonResult CancelPrinttoPrinters(string PrintDate, int LocKy, int OrdKy)
        {
            bool success = true;

            try
            {
                string   TempDate  = PrintDate.Replace("-", "/");
                string[] afdate    = TempDate.Split('/');
                string   Date      = afdate.GetValue(0).ToString();
                string   ddlfmonth = afdate.GetValue(1).ToString();
                string   ddlfyear  = afdate.GetValue(2).ToString();
                string   sDlydate  = ddlfyear + "/" + ddlfmonth + "/" + Date;

                int UsrKy = HTNSession.UsrKy;
                int CKy   = HTNSession.CKy;
                List <SplLocWithPrinter> list = new List <SplLocWithPrinter>();
                list = apiOpr.AmendedPrintToLoc(HTNSession.Environment, CKy, OrdKy, UsrKy, sDlydate, LocKy);

                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].PrinterNm == "error")
                    {
                    }
                    else
                    {
                        try
                        {
                            System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

                            printerSettings.PrinterName = list[i].PrinterNm;
                            if (printerSettings.IsValid)
                            {
                                Telerik.Reporting.UriReportSource uriReportSource = new Telerik.Reporting.UriReportSource();
                                uriReportSource.Uri = AppDomain.CurrentDomain.BaseDirectory + "\\Amendedpnssplorder_report.trdx";

                                uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter("OrdKy", OrdKy));
                                uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter("UsrKy", UsrKy));
                                uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter("PrinterLoc", list[i].ProdLocCd));
                                uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter("ProdLocKy", LocKy));
                                uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter("DlryDt", sDlydate));

                                PrintController printController = new StandardPrintController();

                                ReportProcessor reportProcessor = new ReportProcessor();
                                reportProcessor.PrintController = printController;
                                reportProcessor.PrintReport(uriReportSource, printerSettings);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 19
0
 public PrintEnrollmentAction(PrinterSettings settings, string idEnrollments, string course)
 {
     this.settings = settings;
     theSet = createDataSet(idEnrollments);
     division = Database.Row("division", "DivisionAbrev = '" + GlobalProperties.loggedOnUserDivison + "'");
     this.course = course;
 }
Ejemplo n.º 20
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font = new Font("Courier New", 15);

            PaperSize psize = new PaperSize("Custom", 100, 200);

            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;
            pdoc.DefaultPageSettings.PaperSize.Height = 720;

            pdoc.DefaultPageSettings.PaperSize.Width = 620;

            pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog pp = new PrintPreviewDialog();
                pp.Document = pdoc;
                result = pp.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();
                }
            }
        }
Ejemplo n.º 21
0
        void Print(Bitmap Image)
        {
            printDocument1            = new System.Drawing.Printing.PrintDocument();
            printDocument1.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage);
            printDocument1.EndPrint  += new PrintEventHandler(this.printDocument1_EndPrint);
            System.Drawing.Printing.PrintController printController = new System.Drawing.Printing.StandardPrintController();
            printDocument1.PrintController = printController;
            if (!File.Exists("data.bin"))
            {
                PrintDialog  printDialog1 = new PrintDialog();
                DialogResult dr           = printDialog1.ShowDialog();
                using (Stream stream = System.IO.File.Open("data.bin", FileMode.Create))
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    bin.Serialize(stream, printDialog1.PrinterSettings);
                }
            }
            using (Stream stream = File.Open("data.bin", FileMode.Open))
            {
                BinaryFormatter bin = new BinaryFormatter();

                System.Drawing.Printing.PrinterSettings setting = (System.Drawing.Printing.PrinterSettings)bin.Deserialize(stream);
                printDocument1.PrinterSettings = setting;
            }
            printDocument1.Print();
        }
Ejemplo n.º 22
0
        public static PageSettings GetPrinterPageInfo(String printerName)
        {
            System.Drawing.Printing.PrinterSettings settings;

            // If printer name is not set, look for default printer
            if (String.IsNullOrEmpty(printerName))
            {
                foreach (var printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
                {
                    settings = new System.Drawing.Printing.PrinterSettings();

                    settings.PrinterName = printer.ToString();

                    if (settings.IsDefaultPrinter)
                    {
                        return(settings.DefaultPageSettings);
                    }
                }

                return(null); // <- No default printer
            }

            // printer by its name
            settings = new System.Drawing.Printing.PrinterSettings();

            settings.PrinterName = printerName;

            return(settings.DefaultPageSettings);
        }
    public static void Print2(string wordfile, string printer = null)
    {
        oWord.Application wordApp = new oWord.Application();
        wordApp.Visible = false;

        wordApp.Documents.Open(wordfile);
        wordApp.DisplayAlerts = oWord.WdAlertLevel.wdAlertsNone;

        System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();

        if (printer == null) // print to all installed printers
        {
            foreach (string p in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            {
                try
                {
                    settings.PrinterName = p;
                    wordApp.ActiveDocument.PrintOut(false);
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex, true);
                }
            }
        }
        else
        {
            settings.PrinterName = printer;
            wordApp.ActiveDocument.PrintOut(false);
        }

        wordApp.Quit(oWord.WdSaveOptions.wdDoNotSaveChanges);
    }
Ejemplo n.º 24
0
        private void btStampa_Click(object sender, EventArgs e)
        {
            // SE IL RADIOBUTTON E' SU LOCAL USA QUELLA STAMPANTE SELEZIONATA
            if (rdStampantiLocali.Checked)
                nomeStampante = cbStampantiLocali.SelectedItem.ToString();
            // ALTRIMENTI USA QUELLA DI RETE
            else
                nomeStampante = cbStampantiRete.SelectedItem.ToString();

            PrinterSettings printerSettings = new PrinterSettings();
            printerSettings.PrinterName = nomeStampante;

            // SE E' VALIDA -> STAMPA
            if (printerSettings.IsValid)
            {
                printDoc.PrinterSettings = printerSettings;

                // PROVIAMO A STAMPARE
                try
                {
                    printDoc.Print();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 25
0
        public void print1(string printerName, string filePath)
        {
            // string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
            // Create PdfViewer object
            PdfViewer viewer = new PdfViewer();

            // Open input PDF file
            viewer.BindPdf(filePath);
            // Set attributes for printing
            viewer.AutoResize      = true;    // Print the file with adjusted size
            viewer.AutoRotate      = true;    // Print the file with adjusted rotation
            viewer.PrintPageDialog = false;   // Do not produce the page number dialog when printing
            // Create objects for printer and page settings and PrintDocument
            System.Drawing.Printing.PrinterSettings ps     = new System.Drawing.Printing.PrinterSettings();
            System.Drawing.Printing.PageSettings    pgs    = new System.Drawing.Printing.PageSettings();
            System.Drawing.Printing.PrintDocument   prtdoc = new System.Drawing.Printing.PrintDocument();
            // Set printer name
            ps.PrinterName = prtdoc.PrinterSettings.PrinterName;
            // Set PageSize (if required)
            pgs.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 280, 826);
            // Set PageMargins (if required)
            pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
            // ExStart:PrintDialog
            //System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
            //if (printDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            //{
            // Document printing code goes here
            // Print document using printer and page settings
            viewer.PrintDocumentWithSettings(pgs, ps);
            //}
            // ExEnd:PrintDialog
            // Close the PDF file after priting
            viewer.Close();
        }
Ejemplo n.º 26
0
        private void printForm_Load(object sender, EventArgs e)
        {
            //
            try
            {

                PrinterSettings settings = new PrinterSettings();
                string strDefaultPrint = settings.PrinterName;
                foreach (String printer in PrinterSettings.InstalledPrinters)
                {
                    printersList.Items.Add(printer.ToString());
                    if (printer.ToString().Equals(strDefaultPrint))
                    {
                        printersList.SelectedIndex = (printersList.Items.Count - 1);
                    }
                }
                cmbStyle.SelectedIndex = 0;
                this.Focus();

            }
            catch (Exception ex)
            {
                MessageBox.Show("An error accoured while loading the printers! \nPlease try again or restart the program", "Error", MessageBoxButtons.OK);
            }
                
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                PrinterSettings printSet = new PrinterSettings();//打印机设置

                if (this.pageSet != null)
                {
                    printDocument.DefaultPageSettings = this.pageSet;
                }

                printD.PrinterSettings = printSet;

                printD.Document = printDocument;
                printDocument.DocumentName = "CheckBang";

                if (printD.ShowDialog() == DialogResult.OK)
                {
                    printDocument.Print();
                }

                //添加二次打印日志
                try
                {
                    string strLogID = Guid.NewGuid().ToString().Replace("-", "").ToLower();
                    string strPrintDate = DateTime.Now.ToString();
                    BLL.TT_TwoPrintLog bllEmpty = new CoalTraffic.BLL.TT_TwoPrintLog();
                    if (bllEmpty.AddTwoPrint(strLogID, StaticParameter.UserName, strPrintDate, "TT_LoadWeight", _strWeightCode))
                    {
                        #region 断网时,添加二次打印日志sql语句
                        string isConnection = ini.IniReadValue("Connection", "isConnection");
                        if (isConnection == "1")
                        {
                            StringBuilder strSql = new StringBuilder();
                            strSql.Append("insert TT_TwoPrintLog(LogID,LogType,Operator,PrintDate,PrintTable,PrintWeightCode) Values('" + strLogID + "','散煤过磅',");
                            strSql.Append("'" + StaticParameter.UserName + "','" + strPrintDate + "','TT_LoadWeight','" + _strWeightCode + "')");
                            string id = DateTime.Now.ToString("yyyyMMddHHmmss");
                            StringBuilder sbsqlcontext = new StringBuilder();
                            sbsqlcontext.Append("insert into NetWorkDisconnection (ID, SQLcontext, DateTime) values(@id,@sqlcontext,@datetime)");
                            SqlParameter[] parameters = new SqlParameter[] {
                                                                                            new SqlParameter("@id",id),
                                                                                            new SqlParameter("@sqlcontext",strSql.ToString()),
                                                                                            new SqlParameter("@datetime",DateTime.Now)
                                                                                             };
                            DbHelperSQL.ExecuteSql(sbsqlcontext.ToString(), parameters);
                        }
                        #endregion
                    }

                    this.Close();
                }
                catch
                { }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 28
0
    private void GenerateReport()
    {
        //dataTable
        string idPengajuan = Request.QueryString["IdPengajuan"];

        ReportViewer1.Reset();
        ReportViewer1.LocalReport.ReportPath = "Laporan/PengajuanInvDetail.rdlc";

        PengajuanDomain peDomain = GeneratePengajuan(idPengajuan);

        ReportParameter[] parameters = new ReportParameter[5];
        parameters[0] = new ReportParameter("IDPengajuan", peDomain.IDPengajuan);
        parameters[1] = new ReportParameter("TglPengajuan", peDomain.Tgl);
        // parameters[2] = new ReportParameter("Judul", peDomain.Hal);
        parameters[2] = new ReportParameter("Judul", peDomain.Judul);
        parameters[3] = new ReportParameter("Keterangan", peDomain.Keterangan);

        if (peDomain.Prioritas.Equals("3"))
        {
            parameters[4] = new ReportParameter("Prioritas", "Normal");
        }
        else if (peDomain.Prioritas.Equals("2"))
        {
            parameters[4] = new ReportParameter("Prioritas", "Penting");
        }
        else if (peDomain.Prioritas.Equals("1"))
        {
            parameters[4] = new ReportParameter("Prioritas", "Urgen");
        }
        ReportViewer1.LocalReport.SetParameters(parameters);

        DataTable        dt         = GetData(peDomain.IDPengajuan);
        ReportDataSource dataSource = new ReportDataSource("DataSet1", dt);

        ReportViewer1.LocalReport.DataSources.Add(dataSource);
        ReportViewer1.ShowPrintButton = true;



        PageSettings pg = new System.Drawing.Printing.PageSettings();

        pg.Margins.Top    = 0;
        pg.Margins.Bottom = 0;
        pg.Margins.Left   = 0;
        pg.Margins.Right  = 0;

        PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();

        ps.PrinterName = "Microsoft XPS Document Writer";

        PaperSize size = new PaperSize();

        size.RawKind       = (int)PaperKind.A4;
        pg.PaperSize       = size;
        pg.PrinterSettings = ps;
        ReportViewer1.SetPageSettings(pg);

        ReportViewer1.LocalReport.Refresh();
    }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                PrinterSettings printSet = new PrinterSettings();//打印机设置

                if (this.pageSet != null)
                {
                    printDocument.DefaultPageSettings = this.pageSet;
                }

                printD.PrinterSettings = printSet;

                printD.Document = printDocument;
                printDocument.DocumentName = "CheckBang";

                if (printD.ShowDialog() == DialogResult.OK)
                {
                    printDocument.Print();
                }

                //添加二次打印日志
                try
                {
                    string strLogID = Guid.NewGuid().ToString().Replace("-", "").ToLower();
                    string strPrintDate = DateTime.Now.ToString();
                    BLL.TT_TwoPrintLog bllEmpty = new CoalTraffic.BLL.TT_TwoPrintLog();
                    if (bllEmpty.AddTwoPrint(strLogID, StaticParameter.UserName, strPrintDate, "TT_LoadWeight", _strWeightCode))
                    {
                        #region 数据上传
                        string isConnection = ini.IniReadValue("Connection", "isConnection");
                        MSMQserver mqServer = new MSMQserver();
                        MSMQClient MC = new MSMQClient();
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert TT_TwoPrintLog(LogID,LogType,Operator,PrintDate,PrintTable,PrintWeightCode) Values('" + strLogID + "','散煤过磅',");
                        strSql.Append("'" + StaticParameter.UserName + "','" + strPrintDate + "','TT_LoadWeight','" + _strWeightCode + "')");
                        if (isConnection == "0")
                        {
                            mqServer.AddMsmq(MC.ServerStation + MC.Prefix + "TT_TwoPrintLog" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + strSql.ToString());
                        }
                        else
                        {
                            MC.AddNewSqlText(MC.ServerStation + MC.Prefix + "TT_TwoPrintLog" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + strSql.ToString());
                        }
                        //CoalTraffic.MessagingService.LocalWeightServiceClient loalclient = new CoalTraffic.MessagingService.LocalWeightServiceClient();
                        //loalclient.AddTwoPrint(strLogID, StaticParameter.UserName, strPrintDate, "TT_CheckBang", _strWeightCode);
                        #endregion
                    }

                    this.Close();
                }
                catch
                { }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 30
0
	// Constructor.
	public PrintDocument()
			{
				this.documentName = "document";
				this.originAtMargins = false;
				this.printController = null;
				this.printerSettings = new PrinterSettings();
				this.defaultPageSettings = new PageSettings(printerSettings);
			}
Ejemplo n.º 31
0
        public WorkSpaceViewModel(WorkspaceControl workspaceControl)
        {
            _view = workspaceControl;
            //default to whatever the printer's default is
            PrinterSettings printer = new System.Drawing.Printing.PrinterSettings();

            PaperTarget = new PaperTarget(printer.DefaultPageSettings.PaperSize.PaperName, printer.DefaultPageSettings.PaperSize);
        }
Ejemplo n.º 32
0
 public static PrintSettings ToEto(this sdp.PrinterSettings settings, Eto.Generator generator)
 {
     if (settings == null)
     {
         return(null);
     }
     return(new PrintSettings(generator, new PrintSettingsHandler(settings)));
 }
Ejemplo n.º 33
0
 private System.Drawing.Printing.PrinterSettings GetCurentPrinterSettings()
 {
     if (m_printsettings == null)
     {
         m_printsettings = new System.Drawing.Printing.PrinterSettings();
     }
     return(m_printsettings);
 }
Ejemplo n.º 34
0
 public DatasetPrintingView()
 {
     InitializeComponent();
     _dataContext = new DatasetPrintingViewModel(Token);
     DataContext = _dataContext;
     AddKeyBindings<BaseEntity>();
     SettingsOfPrinter = new PrinterSettings();
 }
Ejemplo n.º 35
0
		public DicomPrintConfig() {
			AETitle = "PRINT_SCP";
			PreviewOnly = false;

			PrintDocument document = new PrintDocument();
			PrinterSettings = document.PrinterSettings;
			PaperSource = PrinterSettings.PaperSources[0].SourceName;
		}
Ejemplo n.º 36
0
 /// <summary>
 /// Gets the global printer settings
 /// </summary> 
 public static PrinterSettings GetPrinterSettings()
 {
     if (PrinterSettings == null)
     {
         PrinterSettings = new PrinterSettings();
     }
     return PrinterSettings;
 }
Ejemplo n.º 37
0
 public Printer(PrinterSettings printSettings)
 {
     this.printer = new PrintDocument();
     this.printer.PrintPage += new PrintPageEventHandler(printPage);
     this.imagePrinted = null;
     if (printSettings != null)
         this.printer.PrinterSettings = printSettings;
 }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                PrinterSettings printSet = new PrinterSettings();//打印机设置

                if (this.pageSet != null)
                {
                    printDocument.DefaultPageSettings = this.pageSet;
                }

                printD.PrinterSettings = printSet;

                printD.Document = printDocument;
                printDocument.DocumentName = "CarInfo";

                if (printD.ShowDialog() == DialogResult.OK)
                {
                    printDocument.Print();
                }

                //添加二次打印日志
                try
                {
                    string strLogID = Guid.NewGuid().ToString().Replace("-", "").ToLower();
                    string strPrintDate = DateTime.Now.ToString();
                    //BLL.TT_EmptyWeight bllEmpty = new CoalTraffic.BLL.TT_EmptyWeight();
                    BLL.TT_TwoPrintLog bblTwoPrint = new CoalTraffic.BLL.TT_TwoPrintLog();
                    if (bblTwoPrint.AddTwoPrint(strLogID, StaticParameter.UserName, strPrintDate, "TT_CarInfo", _strWeightCode))
                    {
                        #region 数据上传
                        try
                        {
                            MSMQClient MC = new MSMQClient();
                            StringBuilder strSql = new StringBuilder();
                            strSql.Append("insert TT_TwoPrintLog(LogID,LogType,Operator,PrintDate,PrintTable,PrintWeightCode) Values('" + strLogID + "','空车过磅',");
                            strSql.Append("'" + StaticParameter.UserName + "','" + strPrintDate + "','TT_CarInfo','" + _strWeightCode + "')");

                            MC.AddNewSqlText(MC.ServerStation + MC.Prefix + "TT_TwoPrintLog" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + strSql.ToString());

                        }
                        catch
                        { }
                        #endregion

                        this.Close();
                    }
                }
                catch
                { }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 39
0
		// used by PrinterSettings.DefaultPageSettings
		internal PageSettings(PrinterSettings printerSettings, bool color, bool landscape, PaperSize paperSize, PaperSource paperSource, PrinterResolution printerResolution)
		{
			PrinterSettings = printerSettings;
			this.color = color;
			this.landscape = landscape;
			this.paperSize = paperSize;
			this.paperSource = paperSource;
			this.printerResolution = printerResolution;
		}
Ejemplo n.º 40
0
    public void PreviewDocument(Document document, PrinterSettings printerSettings)
    {
      fDocument = document;
      fPrintDocument.PrinterSettings = printerSettings;

      PrintPreviewDialog dlg = new PrintPreviewDialog();
      dlg.Document = fPrintDocument;
      dlg.ShowDialog();
    }
Ejemplo n.º 41
0
 protected void SetPrinterSettings()
 {
     var key = string.Format("{0}:PrinterSettings", CurrentPrinterName);
     if (!CacheHelper.Contains(key))
     {
         CacheHelper.Add(key, new System.Drawing.Printing.PrinterSettings { PrinterName = CurrentPrinterName });
     }
     _printerSettings = (System.Drawing.Printing.PrinterSettings)CacheHelper.GetData(key);
 }
Ejemplo n.º 42
0
 private void PrinterSettings()
 {
     System.Windows.Forms.PrintDialog d = new System.Windows.Forms.PrintDialog();
     var result = d.ShowDialog();
     if (result == System.Windows.Forms.DialogResult.OK || result == System.Windows.Forms.DialogResult.Yes)
     {
         SettingsOfPrinter = d.PrinterSettings;
     }
 }
Ejemplo n.º 43
0
        private void buttonSwitchOrientation_Click(object sender, EventArgs e)
        {
            var ps = this.GetCurentPrinterSettings();

            ps.DefaultPageSettings.Landscape = !ps.DefaultPageSettings.Landscape;

            this.m_printsettings = ps;
            this.UpdateUI();
            this.panelRenderBox.Invalidate();
        }
Ejemplo n.º 44
0
        public JsonResult PrintPendingInvoice(string OrdKy)
        {
            bool success = true;

            int    CKy             = HTNSession.CKy;
            int    UsrKy           = HTNSession.UsrKy;
            string EnvironmentName = HTNSession.Environment;

            String printerName = WebConfigurationManager.AppSettings["PendingInvoicePrinterName"];
            String PendingInvoiceReportPath = WebConfigurationManager.AppSettings["PendingInvoiceReportPath"];

            try
            {
                System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();


                List <UsrMasPrinter_Select> list = new List <UsrMasPrinter_Select>();
                list = apiOpr.GetUsrMasPrinter_Select(CKy, UsrKy, 1, 1, EnvironmentName);

                if (list.Count > 0)
                {
                    printerName = list[0].PrinterNm;
                }

                printerSettings.PrinterName = printerName;

                if (printerSettings.IsValid)
                {
                    Telerik.Reporting.UriReportSource uriReportSource = new Telerik.Reporting.UriReportSource();
                    uriReportSource.Uri = AppDomain.CurrentDomain.BaseDirectory + PendingInvoiceReportPath;
                    uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter("OrdKy", OrdKy));
                    uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter("UsrKy", UsrKy));
                    uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter("CKy", CKy));

                    PrintController printController = new StandardPrintController();

                    ReportProcessor reportProcessor = new ReportProcessor();
                    reportProcessor.PrintController = printController;
                    reportProcessor.PrintReport(uriReportSource, printerSettings);

                    apiOpr.PrintLog_Insert(HTNSession.Environment, CKy, UsrKy, 1, Convert.ToInt32(OrdKy), printerName, DateTime.Now.ToString(), "Pending Invoice Done");

                    return(Json("Success", JsonRequestBehavior.AllowGet));
                }

                apiOpr.PrintLog_Insert(HTNSession.Environment, CKy, UsrKy, 1, Convert.ToInt32(OrdKy), printerName, DateTime.Now.ToString(), "Pending Invoice Valid Fail");

                return(Json("Printer Not valid", JsonRequestBehavior.AllowGet));
            }

            catch
            {
                throw;
            }
        }
Ejemplo n.º 45
0
        private void button1_Click(object sender, EventArgs e)
        {
            PrintDocument printer = new PrintDocument();

            printer.PrinterFont = new Font("Verdana", 18);

            printer.TextToPrint = " Hello World";
            System.Drawing.Printing.PrinterSettings newSettings = new System.Drawing.Printing.PrinterSettings();
            printer.PrinterSettings.PrinterName = "HP209535 (HP Photosmart 7510 series)";
            printer.Print();
        }
Ejemplo n.º 46
0
        /// <summary>
        /// 打印Excel
        /// </summary>
        /// <param name="bs"></param>
        /// <param name="printName"></param>
        ///  <param name="orientation">打印方向,默认纵向</param>
        public static void PrintExcel(byte[] bs, string printName, PageOrientationType orientation)
        {
            string       printArea = "";//默认
            MemoryStream ms        = null;

            try
            {
                ms = new MemoryStream(bs);
                Workbook  workbook  = new Workbook(ms);
                Worksheet worksheet = workbook.Worksheets[0];
                //打印设置
                PageSetup pageSetup = worksheet.PageSetup;
                pageSetup.CenterHorizontally = true;  //水平居中
                pageSetup.CenterVertically   = false; //不需要垂直居中
                if (printArea != "")
                {
                    //pageSetup.PrintArea = "A1:I22";
                }

                pageSetup.Orientation = orientation;
                // pageSetup.Orientation = PageOrientationType.Landscape;//横向
                // pageSetup.Orientation = PageOrientationType.Portrait;//纵向

                ImageOrPrintOptions options = new ImageOrPrintOptions();
                System.Drawing.Printing.PrinterSettings printSettings = new System.Drawing.Printing.PrinterSettings();

                defaultPrint = fPrintDocument.PrinterSettings.PrinterName;
                //defaultPrint = @"\\prtsvr\MP 3054 PCL 6 jszx";
                //new Log4netHelper().AddLog("默认打印机名称是:"+defaultPrint);

                SheetRender sr = new SheetRender(worksheet, options);
                if (printName != "")
                {
                    sr.ToPrinter(printName);
                }
                else
                {
                    sr.ToPrinter(defaultPrint);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                GC.Collect(); //垃圾回收机制
                if (ms != null)
                {
                    ms.Close();
                }
            }
        }
Ejemplo n.º 47
0
 public override void Reset()
 {
     this.allowCurrentPage = false;
     this.allowPages       = false;
     this.allowPrintToFile = true;
     this.allowSelection   = false;
     this.printDocument    = null;
     this.printToFile      = false;
     this.settings         = null;
     this.showHelp         = false;
     this.showNetwork      = true;
 }
Ejemplo n.º 48
0
        protected void SetPrinterSettings()
        {
            var key = string.Format("{0}:PrinterSettings", CurrentPrinterName);

            if (!CacheHelper.Contains(key))
            {
                CacheHelper.Add(key, new System.Drawing.Printing.PrinterSettings {
                    PrinterName = CurrentPrinterName
                });
            }
            _printerSettings = (System.Drawing.Printing.PrinterSettings)CacheHelper.GetData(key);
        }
 public override void Reset()
 {
     this.allowMargins     = true;
     this.allowOrientation = true;
     this.allowPaper       = true;
     this.allowPrinter     = true;
     this.MinMargins       = null;
     this.pageSettings     = null;
     this.printDocument    = null;
     this.printerSettings  = null;
     this.showHelp         = false;
     this.showNetwork      = true;
 }
Ejemplo n.º 50
0
    private void GenerateReport()
    {
        //dataTable
        string idPengajuan = Request.QueryString["IdPembelian"];

        ReportViewer1.Reset();
        ReportViewer1.LocalReport.ReportPath = "Laporan/PembelianDetail.rdlc";

        PembelianDomain peDomain = GeneratePembelian(idPengajuan);

        ReportParameter[] parameters = new ReportParameter[6];
        parameters[0] = new ReportParameter("NoPembelian", peDomain.IDPembelian);
        parameters[1] = new ReportParameter("TglBeli", peDomain.Tgl);
        // parameters[2] = new ReportParameter("Judul", peDomain.Hal);
        parameters[2] = new ReportParameter("Keterangan", peDomain.Keterangan);
        parameters[3] = new ReportParameter("RefPengajuan", peDomain.RefPengajuan);
        parameters[4] = new ReportParameter("HargaTotal", peDomain.HargaTotal);
        parameters[5] = new ReportParameter("Status", peDomain.status);
        ReportViewer1.LocalReport.SetParameters(parameters);

        DataTable        dt         = GetData(peDomain.RefPengajuan);
        ReportDataSource dataSource = new ReportDataSource("DataSet1", dt);

        ReportViewer1.LocalReport.DataSources.Add(dataSource);
        ReportViewer1.ShowPrintButton = true;



        PageSettings pg = new System.Drawing.Printing.PageSettings();

        pg.Margins.Top    = 0;
        pg.Margins.Bottom = 0;
        pg.Margins.Left   = 0;
        pg.Margins.Right  = 0;

        PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();

        ps.PrinterName = "Microsoft XPS Document Writer";

        PaperSize size = new PaperSize();

        size.RawKind       = (int)PaperKind.A4;
        pg.PaperSize       = size;
        pg.PrinterSettings = ps;
        ReportViewer1.SetPageSettings(pg);

        ReportViewer1.LocalReport.Refresh();
    }
Ejemplo n.º 51
0
        public System.Drawing.Printing.PaperSize GetPrintForm(string printerName, string paperName)
        {
            System.Drawing.Printing.PaperSize       paper   = null;
            System.Drawing.Printing.PrinterSettings printer = new System.Drawing.Printing.PrinterSettings();
            printer.PrinterName = printerName;

            foreach (System.Drawing.Printing.PaperSize ps in printer.PaperSizes)
            {
                if (ps.PaperName.ToLower() == paperName.ToLower())
                {
                    paper = ps;
                    break;
                }
            }
            return(paper);
        }
Ejemplo n.º 52
0
    private void GenerateReport()
    {
        //dataTable

        ReportViewer1.Reset();
        ReportViewer1.LocalReport.ReportPath = "Laporan/ServiceKeluarDetail.rdlc";

        ServiceKeluar peDomain = GenerateService(TbIDNoPengajuan.Text);

        ReportParameter[] parameters = new ReportParameter[6];
        parameters[0] = new ReportParameter("IDService", peDomain.id);
        parameters[1] = new ReportParameter("JudulService", peDomain.Judul);
        parameters[2] = new ReportParameter("Status", peDomain.Status);
        parameters[3] = new ReportParameter("TglService", peDomain.TglService);
        parameters[4] = new ReportParameter("RefService", peDomain.RefService);
        parameters[5] = new ReportParameter("Keterangan", peDomain.Keterangan);
        ReportViewer1.LocalReport.SetParameters(parameters);

        DataTable        dt         = GetData(peDomain.RefService);
        ReportDataSource dataSource = new ReportDataSource("DataSet1", dt);

        ReportViewer1.LocalReport.DataSources.Add(dataSource);
        ReportViewer1.ShowPrintButton = true;



        PageSettings pg = new System.Drawing.Printing.PageSettings();

        pg.Margins.Top    = 0;
        pg.Margins.Bottom = 0;
        pg.Margins.Left   = 0;
        pg.Margins.Right  = 0;

        PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();

        ps.PrinterName = "Microsoft XPS Document Writer";

        PaperSize size = new PaperSize();

        size.RawKind       = (int)PaperKind.A4;
        pg.PaperSize       = size;
        pg.PrinterSettings = ps;
        ReportViewer1.SetPageSettings(pg);

        ReportViewer1.LocalReport.Refresh();
    }
Ejemplo n.º 53
0
        public static void PrintPage(string json)
        {
            SetTextData(json);
            PrintDialog  PD           = new PrintDialog();
            PageSettings pageSettings = new PageSettings();
            //pageSettings.PaperSize = new PaperSize("Size", 30, 40);
            string Name = fPrintDocument.PrinterSettings.PrinterName;

            System.Drawing.Printing.PrinterSettings Ps = new System.Drawing.Printing.PrinterSettings();
            //SetDefaultPrinter("Deli DL-888B(NEW)");
            fPrintDocument.DefaultPageSettings.PaperSize = new PaperSize("Size", 157, 118); //单位1/100英寸
            SetDefaultPrinter(Name);
            PD.PrinterSettings        = Ps;
            fPrintDocument.PrintPage += document_PrintPage;
            PD.Document = fPrintDocument;
            fPrintDocument.Print();
        }
Ejemplo n.º 54
0
    private void GenerateReport()
    {
        //dataTable

        ReportViewer1.Reset();
        ReportViewer1.LocalReport.ReportPath = "Laporan/PengajuanInvDetail.rdlc";

        PengajuanDomain peDomain = GeneratePengajuan(TbIDNoPengajuan.Text);

        ReportParameter[] parameters = new ReportParameter[6];
        parameters[0] = new ReportParameter("No", peDomain.No);
        parameters[1] = new ReportParameter("TglPengajuan", peDomain.TglPengajuan);
        parameters[2] = new ReportParameter("Hal", peDomain.Hal);
        parameters[3] = new ReportParameter("Keterangan", peDomain.Keterangan);
        parameters[4] = new ReportParameter("Prioritas", peDomain.Prioritas);
        parameters[5] = new ReportParameter("Pengaju", peDomain.Pengaju);
        ReportViewer1.LocalReport.SetParameters(parameters);

        DataTable        dt         = GetData(peDomain.id);
        ReportDataSource dataSource = new ReportDataSource("DS_V_Pengajuan_report_detail", dt);

        ReportViewer1.LocalReport.DataSources.Add(dataSource);
        ReportViewer1.ShowPrintButton = true;



        PageSettings pg = new System.Drawing.Printing.PageSettings();

        pg.Margins.Top    = 0;
        pg.Margins.Bottom = 0;
        pg.Margins.Left   = 0;
        pg.Margins.Right  = 0;

        PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();

        ps.PrinterName = "Microsoft XPS Document Writer";

        PaperSize size = new PaperSize();

        size.RawKind       = (int)PaperKind.A4;
        pg.PaperSize       = size;
        pg.PrinterSettings = ps;
        ReportViewer1.SetPageSettings(pg);

        ReportViewer1.LocalReport.Refresh();
    }
Ejemplo n.º 55
0
    private void GenerateReport()
    {
        //dataTable

        ReportViewer1.Reset();

        DataTable        dt         = GetData();
        ReportDataSource dataSource = new ReportDataSource("DSet_V_Pengajuan_Report", dt);



        ReportViewer1.LocalReport.DataSources.Add(dataSource);
        ReportViewer1.LocalReport.ReportPath = "Laporan/PengajuanInv.rdlc";
        ReportViewer1.ShowPrintButton        = true;

        ReportParameter[] parameters = new ReportParameter[2];
        parameters[0] = new ReportParameter("TglDari", TbTanggalDari.Text);
        parameters[1] = new ReportParameter("TglKe", TbTanggalKe.Text);
        ReportViewer1.LocalReport.SetParameters(parameters);


        PageSettings pg = new System.Drawing.Printing.PageSettings();

        pg.Margins.Top    = 0;
        pg.Margins.Bottom = 0;
        pg.Margins.Left   = 0;
        pg.Margins.Right  = 0;

        PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();

        ps.PrinterName = "Microsoft XPS Document Writer";

        PaperSize size = new PaperSize();

        size.RawKind       = (int)PaperKind.A4;
        pg.PaperSize       = size;
        pg.PrinterSettings = ps;
        ReportViewer1.SetPageSettings(pg);

        ReportViewer1.LocalReport.Refresh();
    }
Ejemplo n.º 56
0
        /// <summary>
        /// The default constructor initializes and kicks of worker thread
        /// </summary>
        public Automation()
        {
            InitializeComponent();

            try
            {
                //status = new RiskApps3Automation.org.partners.dipr.hra.Service1();
                string url = Configurator.getAutomationHeartbeatServiceURL();
                if (url.Length == 0)
                {
                    status = null;
                }
                else
                {
                    status = new AutomationHeartbeat.Service1(url);
                }
            }
            catch (Exception e)
            {
                Logger.Instance.WriteToLog(e.ToString());
            }

            System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();
            defaultPrinter = settings.PrinterName;

            GetDbName();

            string sAutoInt = Configurator.getNodeValue("Globals", "AutomationInterval");

            int.TryParse(sAutoInt, out automation_interval);
            if (!(automation_interval > 0))
            {
                automation_interval = 1000;
            }

            timer1.Interval = 60000;

            button1.Text = "Cancel";
            label1.Text  = "Running";
            backgroundWorker1.RunWorkerAsync();
        }
        static void Test4()
        {
            //var p1 = "Jolimark 24-pin printer";
            //var w1 = (int)(215.9f * 1000);
            //var h1 = (int)(139.7f * 1000);
            //AddCustomPaperSize(p1, "Werp241/2", w1, h1);
            //var settings1 = new System.Drawing.Printing.PrinterSettings();
            //settings1.PrinterName = p1;
            //var papers1 = settings1.PaperSizes.Cast<PaperSize>().ToArray();

            var p2 = @"\\ZZ-PC\Jolimark 24-pin printer";
            var w2 = 215.9;
            var h2 = 139.7;

            AddFormOfServer(p2, "TestWerp241/2", w2, h2, PrintSystemUnit.Millimeter);

            var settings2 = new System.Drawing.Printing.PrinterSettings();

            settings2.PrinterName = p2;
            var papers2 = settings2.PaperSizes.Cast <PaperSize>().ToArray();
        }
Ejemplo n.º 58
0
    private void GenerateReport()
    {
        string id = Request.QueryString["IdPenugasan"];

        //dataTable

        ReportViewer1.Reset();

        DataTable        dt          = GetData(id);
        DataTable        dt2         = GetDetail(id);
        DataTable        dt3         = GetDetailLain(id);
        ReportDataSource dataSource  = new ReportDataSource("DSPenugasan", dt);
        ReportDataSource dataSource2 = new ReportDataSource("DSPerbaikanDetail", dt2);
        ReportDataSource dataSource3 = new ReportDataSource("DSPenugasanLain", dt3);

        ReportViewer1.LocalReport.DataSources.Add(dataSource);
        ReportViewer1.LocalReport.DataSources.Add(dataSource2);
        ReportViewer1.LocalReport.DataSources.Add(dataSource3);
        ReportViewer1.LocalReport.ReportPath = "Laporan/PerbaikanBarang.rdlc";

        PageSettings pg = new System.Drawing.Printing.PageSettings();

        pg.Margins.Top    = 0;
        pg.Margins.Bottom = 0;
        pg.Margins.Left   = 0;
        pg.Margins.Right  = 0;

        PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();

        ps.PrinterName = "Microsoft XPS Document Writer";

        PaperSize size = new PaperSize();

        size.RawKind       = (int)PaperKind.A4;
        pg.PaperSize       = size;
        pg.PrinterSettings = ps;
        ReportViewer1.SetPageSettings(pg);

        ReportViewer1.LocalReport.Refresh();
    }
Ejemplo n.º 59
0
        public string DefaultPrinterName()
        {
            System.Drawing.Printing.PrinterSettings oPS = new System.Drawing.Printing.PrinterSettings();
            string defaultprintername = "";

            try
            {
                defaultprintername = oPS.PrinterName;
            }
            catch (Exception ex)
            {
                defaultprintername = "";
            }
            finally
            {
                oPS = null;
            }



            return(defaultprintername);
        }
Ejemplo n.º 60
-2
        public void print()
        {
            PrintDialog pd = new PrintDialog();
            pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font = new Font("Courier New", 15);

            PaperSize psize = new PaperSize("Custom", 300, 100);
            ps.DefaultPageSettings.PaperSize = psize;

            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;

            pdoc.DefaultPageSettings.PaperSize = psize;

            pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog pp = new PrintPreviewDialog();
                pp.Document = pdoc;

                result = pp.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();
                }
            }
        }