Beispiel #1
0
		// Fallback to the original GNOME Print API.
		public static void Print (string html) 
		{
			string caption = "Monodoc Printing";

			Gnome.PrintJob pj = new Gnome.PrintJob (PrintConfig.Default ());
			PrintDialog dialog = new PrintDialog (pj, caption, 0);

			Gtk.HTML gtk_html = new Gtk.HTML (html);
			gtk_html.PrintSetMaster (pj);
			
			Gnome.PrintContext ctx = pj.Context;
			gtk_html.Print (ctx);

			pj.Close ();

			// hello user
			int response = dialog.Run ();
		
			if (response == (int) PrintButtons.Cancel) {
				dialog.Hide ();
				dialog.Destroy ();
				return;
			} else if (response == (int) PrintButtons.Print) {
				pj.Print ();
			} else if (response == (int) PrintButtons.Preview) {
				new PrintJobPreview (pj, caption).Show ();
			}
		
			ctx.Close ();
			dialog.Hide ();
			dialog.Destroy ();
		}
    public void Print()
    {
        PrintDialog printDialog1 = new PrintDialog();
        printDialog1.Document = new PrintDocument();
        printDialog1.AllowPrintToFile = true;
        printDialog1.PrintToFile = false;
        if (printDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            printDialog1.Document.DefaultPageSettings.PaperSize = new PaperSize("Letter", 1700, 2339);
            printDialog1.Document.PrinterSettings.PrintToFile = true;

            printDialog1.Document.PrintPage += delegate(object sender1, PrintPageEventArgs e1)
            {
                RectangleF page = printDialog1.Document.DefaultPageSettings.PrintableArea;
                float x = 50;
                float y = 50;
                Font printFont = new Font("Times New Roman", 12);
                int count = 0;

                foreach (var record in PrintArray)
                {
                    count++;
                    if (count != 10)
                    {
                        e1.Graphics.DrawString(record.ToString(), printFont,
                            new SolidBrush(Color.Black),
                            new RectangleF(x, y, page.Width, page.Height));
                        y += printFont.Height;
                    }
                }
            };
            try
            {
                printDialog1.Document.Print();
            }
            catch (Exception ex)
            {
                throw new Exception("Exception occurred while printing", ex);
            }
        }

    }
Beispiel #3
0
        public static Task <DocumentPaginator> PrintOnMultiPage(object parameter, bool canReturn = false)
        {
            return(Task.Run(() =>
            {
                if (parameter is FrameworkElement)
                {
                    FrameworkElement objectToPrint = parameter as FrameworkElement;
                    FixedDocument document = null;
                    objectToPrint.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Transform originalScale = objectToPrint.LayoutTransform;
                        PrintDialog printDialog = new PrintDialog();
                        var determiner = true;
                        if (!canReturn)
                        {
                            determiner = (bool)printDialog.ShowDialog().GetValueOrDefault();
                        }
                        if (determiner)
                        {
                            // Mouse.OverrideCursor = Cursors.Wait;
                            System.Printing.PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
                            double dpiScale = 200.0 / 96.0;
                            document = new FixedDocument();
                            try
                            {
                                // Change the layout of the UI Control to match the width of the printer page
                                double scale = capabilities.PageImageableArea.ExtentWidth / objectToPrint.ActualWidth;

                                objectToPrint.LayoutTransform = new ScaleTransform(scale, scale);
                                // objectToPrint.Width = capabilities.PageImageableArea.ExtentWidth ;
                                objectToPrint.UpdateLayout();
                                objectToPrint.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                                Size size = new Size(capabilities.PageImageableArea.ExtentWidth, objectToPrint.DesiredSize.Height);
                                objectToPrint.Measure(size);
                                //size = new Size(capabilities.PageImageableArea.ExtentWidth, objectToPrint.DesiredSize.Height);
                                //objectToPrint.Measure(size);
                                objectToPrint.Arrange(new Rect(size));
                                // Convert the UI control into a bitmap at 300 dpi
                                double dpiX = 200;
                                double dpiY = 200;
                                RenderTargetBitmap bmp = new RenderTargetBitmap(Convert.ToInt32(capabilities.PageImageableArea.ExtentWidth * dpiScale), Convert.ToInt32(objectToPrint.ActualHeight * dpiScale), dpiX, dpiY, PixelFormats.Pbgra32);
                                bmp.Render(objectToPrint);
                                // Convert the RenderTargetBitmap into a bitmap we can more readily use
                                PngBitmapEncoder png = new PngBitmapEncoder();
                                png.Frames.Add(BitmapFrame.Create(bmp));
                                System.Drawing.Bitmap bmp2;
                                using (MemoryStream memoryStream = new MemoryStream())
                                {
                                    png.Save(memoryStream);
                                    bmp2 = new System.Drawing.Bitmap(memoryStream);
                                }
                                document.DocumentPaginator.PageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);
                                // break the bitmap down into pages
                                int pageBreak = 0;
                                int previousPageBreak = 0;
                                int pageHeight = Convert.ToInt32(capabilities.PageImageableArea.ExtentHeight * dpiScale);
                                while (pageBreak < bmp2.Height - pageHeight)
                                {
                                    pageBreak += pageHeight;
                                    // Where we thing the end of the page should be
                                    // Keep moving up a row until we find a good place to break the page
                                    while (!IsRowGoodBreakingPoint(bmp2, pageBreak))
                                    {
                                        pageBreak--;
                                    }
                                    PageContent pageContent = generatePageContent(bmp2, previousPageBreak, pageBreak, document.DocumentPaginator.PageSize.Width, document.DocumentPaginator.PageSize.Height, capabilities);
                                    document.Pages.Add(pageContent);
                                    previousPageBreak = pageBreak;
                                }
                                // Last Page
                                PageContent lastPageContent = generatePageContent(bmp2, previousPageBreak, bmp2.Height, document.DocumentPaginator.PageSize.Width, document.DocumentPaginator.PageSize.Height, capabilities);

                                document.Pages.Add(lastPageContent);
                            }
                            catch
                            {
                                //  MessageBox.Show(ex.Message, "An Error Occured");
                            }
                            finally
                            {
                                if (!canReturn)
                                {
                                    printDialog.PrintDocument(document.DocumentPaginator, "Print Document Name");
                                    MessageBox.Show("Printing SuccessFul", "Operation Successful", MessageBoxButton.OK, MessageBoxImage.Information);
                                }


                                // Scale UI control back to the original so we don't effect what is on the screen
                                //objectToPrint.Width = double.NaN;
                                //objectToPrint.UpdateLayout();
                                objectToPrint.LayoutTransform = originalScale;
                                Size size = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
                                objectToPrint.Measure(size);
                                objectToPrint.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), size));
                                // Mouse.OverrideCursor = null;
                            }
                        }
                    }));


                    if (!canReturn)
                    {
                        return null;
                    }
                    return document.DocumentPaginator;
                }

                return null;
            }));
        }
        private void printButton_Click(object sender, EventArgs e)
        {
            var document = new PrintDocument();

            document.PrintPage += (s, page) =>
            {
                var lineHeight        = (int)Math.Ceiling(SystemFonts.DefaultFont.GetHeight(page.Graphics));
                var descriptionBounds = new Rectangle(
                    page.MarginBounds.X,
                    page.MarginBounds.Y,
                    page.MarginBounds.Width,
                    lineHeight
                    );

                page.Graphics.DrawString(
                    JoinIfNotEmpty(title, field),
                    SystemFonts.DefaultFont,
                    Brushes.Black,
                    descriptionBounds,
                    new StringFormat
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                }
                    );

                var imageBounds = new Rectangle(
                    page.MarginBounds.X,
                    page.MarginBounds.Y + lineHeight,
                    page.MarginBounds.Width,
                    page.MarginBounds.Height - lineHeight
                    );
                if (qrcode.Width < imageBounds.Width && qrcode.Height < imageBounds.Height)
                {
                    imageBounds = new Rectangle(
                        imageBounds.X + (int)(imageBounds.Width * 0.5f - qrcode.Width * 0.5f),
                        imageBounds.Y,
                        qrcode.Width,
                        qrcode.Height
                        );
                }
                else
                {
                    var scale = Math.Min(
                        imageBounds.Width / (float)qrcode.Width,
                        imageBounds.Height / (float)qrcode.Height
                        );

                    imageBounds = new Rectangle(
                        imageBounds.X + (int)(imageBounds.Width * 0.5f - (qrcode.Width * scale) * 0.5f),
                        imageBounds.Y,
                        (int)(qrcode.Width * scale),
                        (int)(qrcode.Height * scale)
                        );
                }

                page.Graphics.DrawImage(qrcode, imageBounds);
            };

            using (var print = new PrintDialog
            {
                Document = document
            })
            {
                if (print.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        document.Print();
                    }
                    catch (Exception ex)
                    {
                        MessageService.ShowWarning(ex);
                    }
                }
            }
        }
Beispiel #5
0
        public void SDK_PrintDocument(GNPXApp000 GNP00, int mLow, int mHigh, int mStart, int mEnd, bool SortF /*, colorList crList*/)
        {
            this.pGNP00win = GNP00.pGNP00win;
            GNPZ_Graphics SDKGrp = new GNPZ_Graphics(GNP00);
            int           lvl;

            List <UPuzzle> SDKPList = new List <UPuzzle>();

            foreach (var P in GNP00.SDKProbLst)
            {
                lvl = P.DifLevel;
                int n = P.ID;
                if (lvl < mLow || lvl > mHigh || n < mStart || n > mEnd)
                {
                    continue;
                }
                SDKPList.Add(P);
            }
            if (SortF)
            {
                SDKPList.Sort((pa, pb) => (pa.DifLevel - pb.DifLevel));
            }

            WrapPanel WrapPan = new WrapPanel();

            WrapPan.Width = 800;

            //【TBD】Printing of multiple pages can not be controlled。
            var    m_PrtDlg  = new PrintDialog();
            double GrdWidth  = (m_PrtDlg.PrintableAreaWidth - 48.0 * 2) / 2.0;
            double GrdHeight = (m_PrtDlg.PrintableAreaHeight - 48.0 * 2) / 2.0;

            foreach (UPuzzle P in SDKPList)
            {
                try{
                    Grid Grd = new Grid( );
                    Grd.Width  = GrdWidth;
                    Grd.Height = GrdHeight;

                    Label Lblname = new Label();
                    Lblname.Content  = "[" + P.ID + "]  " + P.Name;
                    Lblname.FontSize = 16;
                    Lblname.Margin   = new Thickness();
                    Grd.Children.Add(Lblname);

                    Label Lbldif = new Label();
                    Lbldif.Content             = "Dif:" + P.DifLevel;
                    Lbldif.FontSize            = 14;
                    Lbldif.HorizontalAlignment = HorizontalAlignment.Right;
                    Lbldif.VerticalAlignment   = VerticalAlignment.Top;
                    Lbldif.Margin = new Thickness(0, 10, 8, 0);
                    Grd.Children.Add(Lbldif);

                    var drwVis = new RenderTargetBitmap(338, 338, 96, 96, PixelFormats.Default); //338
                    SDKGrp.GBoardPaintPrint(drwVis, P);
                    Image Img = new Image();
                    Img.Source = drwVis;
                    Img.Margin = new Thickness(0, 35, 10, 0);
                    Img.HorizontalAlignment = HorizontalAlignment.Left;
                    Img.VerticalAlignment   = VerticalAlignment.Top;
                    Grd.Children.Add(Img);

                    WrapPan.Children.Add(Grd);
                }
                catch (Exception ex) {
                    WriteLine(ex.Message);
                    WriteLine(ex.StackTrace);
                }
            }

            VisualPrintDialog printDlg = new VisualPrintDialog(WrapPan);

            printDlg.ShowDialog();
        }
Beispiel #6
0
        //打印
        private void btPrint_Click(object sender, RoutedEventArgs e)
        {
            Cursor = Cursors.Wait;
            if (lvList.Items.Count > 0)
            {
                Drug[] ds = lvList.ItemsSource as Drug[];

                PrintDialog pd = new PrintDialog();

                DrawingVisual dv = new DrawingVisual();
                using (DrawingContext dc = dv.RenderOpen())
                {
                    double space_X = 20;
                    double space_Y = 10;

                    double size_G = 16;
                    double size_L = 14;

                    double wide_Col = 40;
                    //标题
                    FormattedText title = new FormattedText("加药清单-" + DateTime.Now.ToString(),
                                                            CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), size_G, Brushes.Black);
                    dc.DrawText(title, new Point((pd.PrintableAreaWidth - title.Width) / 2, space_Y));//居中
                    space_Y += title.Height;
                    //横线
                    dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X, space_Y), new Point(pd.PrintableAreaWidth - space_X, space_Y));
                    //列标题
                    FormattedText col_1 = new FormattedText("缺药",
                                                            CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), size_L, Brushes.Black);
                    dc.DrawText(col_1, new Point(space_X + (wide_Col - col_1.Width) / 2, space_Y));
                    FormattedText col_2 = new FormattedText("名称/规格/厂家",
                                                            CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), size_L, Brushes.Black);
                    dc.DrawText(col_2, new Point(space_X + wide_Col + 10, space_Y));
                    //3条竖线
                    dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X, space_Y), new Point(space_X, space_Y + col_2.Height));
                    dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X + wide_Col, space_Y), new Point(space_X + wide_Col, space_Y + col_2.Height));
                    dc.DrawLine(new Pen(Brushes.Black, 1), new Point(pd.PrintableAreaWidth - space_X, space_Y), new Point(pd.PrintableAreaWidth - space_X, space_Y + col_2.Height));

                    space_Y += col_2.Height;
                    //横线
                    dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X, space_Y), new Point(pd.PrintableAreaWidth - space_X, space_Y));
                    //循环
                    foreach (Drug d in ds)
                    {
                        //名称
                        FormattedText name = new FormattedText(d.DrugName,
                                                               CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), size_L, Brushes.Black);
                        dc.DrawText(name, new Point(space_X + wide_Col + 10, space_Y));
                        dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X + wide_Col, space_Y), new Point(pd.PrintableAreaWidth - space_X, space_Y));
                        //规格
                        FormattedText spec = new FormattedText(d.DrugSpec,
                                                               CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), size_L, Brushes.Black);
                        dc.DrawText(spec, new Point(space_X + wide_Col + 10, space_Y + name.Height));
                        dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X + wide_Col, space_Y + name.Height), new Point(pd.PrintableAreaWidth - space_X, space_Y + name.Height));
                        //厂家
                        FormattedText fac = new FormattedText(d.DrugFactory,
                                                              CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), size_L, Brushes.Black);
                        dc.DrawText(fac, new Point(space_X + wide_Col + 10, space_Y + name.Height * 2));
                        dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X + wide_Col, space_Y + name.Height * 2), new Point(pd.PrintableAreaWidth - space_X, space_Y + name.Height * 2));
                        //缺药
                        FormattedText num = new FormattedText(d.Short.ToString(),
                                                              CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), 30, Brushes.Black);
                        dc.DrawText(num, new Point(space_X + (wide_Col - num.Width) / 2, space_Y + (name.Height * 3 - num.Height) / 2));
                        //三条竖线
                        dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X, space_Y), new Point(space_X, space_Y + name.Height * 3));
                        dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X + wide_Col, space_Y), new Point(space_X + wide_Col, space_Y + name.Height * 3));
                        dc.DrawLine(new Pen(Brushes.Black, 1), new Point(pd.PrintableAreaWidth - space_X, space_Y), new Point(pd.PrintableAreaWidth - space_X, space_Y + name.Height * 3));
                        //横线
                        dc.DrawLine(new Pen(Brushes.Black, 1), new Point(space_X, space_Y + name.Height * 3), new Point(pd.PrintableAreaWidth - space_X, space_Y + name.Height * 3));

                        space_Y += name.Height * 3;
                    }
                    //空白
                    FormattedText n = new FormattedText(".",
                                                        CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), size_L, Brushes.Black);
                    dc.DrawText(n, new Point(space_X, space_Y + n.Height));

                    dc.DrawText(n, new Point(space_X, space_Y + n.Height * 2));
                }
                pd.PrintVisual(dv, "");
            }
            Cursor = null;
        }
Beispiel #7
0
        // Print out a document to a file which we will pass to ghostscript
        protected static void PrintToGhostscript(string printer, string outputFilename, PrintDocument printFunc)
        {
            String postscriptFilePath = "";
            String postscriptFile     = "";

            try
            {
                // Create a temporary location to output to
                postscriptFilePath = Path.GetTempFileName();
                File.Delete(postscriptFilePath);
                Directory.CreateDirectory(postscriptFilePath);
                postscriptFile = Path.Combine(postscriptFilePath, Guid.NewGuid() + ".ps");

                // Set up the printer
                PrintDialog printDialog = new PrintDialog
                {
                    AllowPrintToFile = true,
                    PrintToFile      = true
                };
                System.Drawing.Printing.PrinterSettings printerSettings = printDialog.PrinterSettings;
                printerSettings.PrintToFile   = true;
                printerSettings.PrinterName   = printer;
                printerSettings.PrintFileName = postscriptFile;

                // Call the appropriate printer function (changes based on the office application)
                printFunc(postscriptFile, printerSettings.PrinterName);
                ReleaseCOMObject(printerSettings);
                ReleaseCOMObject(printDialog);

                // Call ghostscript
                GhostscriptProcessor gsproc = new GhostscriptProcessor();
                List <string>        gsArgs = new List <string>
                {
                    "gs",
                    "-dBATCH",
                    "-dNOPAUSE",
                    "-dQUIET",
                    "-dSAFER",
                    "-dNOPROMPT",
                    "-sDEVICE=pdfwrite",
                    String.Format("-sOutputFile=\"{0}\"", string.Join(@"\\", outputFilename.Split(new string[] { @"\" }, StringSplitOptions.None))),
                    @"-f",
                    postscriptFile
                };
                gsproc.Process(gsArgs.ToArray());
            }
            finally {
                // Clean up the temporary files
                if (!String.IsNullOrWhiteSpace(postscriptFilePath) && Directory.Exists(postscriptFilePath))
                {
                    if (!String.IsNullOrWhiteSpace(postscriptFile) && File.Exists(postscriptFile))
                    {
                        // Make sure ghostscript is not holding onto the postscript file
                        for (var i = 0; i < 60; i++)
                        {
                            try
                            {
                                File.Delete(postscriptFile);
                                break;
                            }
                            catch (IOException)
                            {
                                Thread.Sleep(500);
                            }
                        }
                    }
                    Directory.Delete(postscriptFilePath);
                }
            }
        }
        private void MenuItem_Clicked(object pSender, EventArgs pArgs)
        {
            int    i;
            string signal_file_line;

            if (pSender == printMenuItem)
            {
                PrintDocument pdoc = new PrintDocument();
                PrintDialog   pd   = new PrintDialog();
                pd.Document = pdoc;
                if (pd.ShowDialog() == DialogResult.OK)
                {
                    pdoc.PrintPage += new PrintPageEventHandler(PrintCWT);
                    pdoc.Print();
                }
                else
                {
                    MessageBox.Show("print cancelled", "information");
                }
            }

            if (pSender == fileopenMenuItem)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    sf            = new FileStream(ofd.FileName, FileMode.Open);
                    filename_text = ofd.FileName;
                    StreamReader sr = new StreamReader(sf);
                    signal_file_line = sr.ReadLine();
                    MessageBox.Show(signal_file_line, "File Name");
                    signal_size       = System.Convert.ToInt32(signal_file_line);
                    signal_file_line  = sr.ReadLine();
                    signal_samplerate = Double.Parse(signal_file_line, CultureInfo.InvariantCulture);
                    //signal_samplerate = System.Convert.ToDouble(signal_file_line);
                    dt            = 1.0 / signal_samplerate;
                    signal_length = System.Convert.ToDouble(signal_size) / signal_samplerate;                   // seconds
                    for (i = 0; i < signal_size; i++)
                    {
                        try {
                            signal_file_line = sr.ReadLine();
                            //signal_data[i] = System.Convert.ToDouble(signal_file_line);
                            signal_data[i] = Double.Parse(signal_file_line, CultureInfo.InvariantCulture);
                        } catch (Exception e) {
                            System.Diagnostics.Debug.WriteLine(e);
                        }
                    }
                    sf.Close();
                    this.Invalidate();
                }
            }

            if (pSender == exportEPSMenuItem)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    writeepsfile(sfd.FileName);
                }
            }

            if (pSender == exitMenuItem)
            {
                Application.Exit();
            }

            if (pSender == spectrogramMenuItem)
            {
                ComputeSpectrogram();
            }

            if (pSender == waveletMenuItem)
            {
                Wavelet_Dialog wdlg = new Wavelet_Dialog();
                wdlg.setSigma(sigma);
                wdlg.setUpperFreq(upper_freq);
                wdlg.setLowerFreq(lower_freq);
                wdlg.ShowDialog();
                sigma      = wdlg.sigma;
                upper_freq = wdlg.upperfreq;
                lower_freq = wdlg.lowerfreq;
                this.Invalidate();
            }


            if (pSender == helpMenu)
            {
                MessageBox.Show("help menu item", "Menu");
            }
        }
Beispiel #9
0
        //string getrang(double  setvalue, double rate) {
        //    double tempvalue = setvalue * rate;
        //    double  max = setvalue + tempvalue;
        //    double  min = setvalue - tempvalue;
        //    return min.ToString() + "-" + max.ToString();

        //}

        private void bt_print_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog pd = new PrintDialog();

            pd.PrintVisual(willprint, "校验报告");
        }
        public Nhaphang_ViewModel()
        {
            TaoDS_nhap();
            DeleteList  = new ObservableCollection <Model.CHITIETPHIEUNHAP>();
            ListMathang = new ObservableCollection <Model.MATHANG>(Model.DataProvider.Ins.DB.MATHANGs.Where(x => x.IsDeleted == false));

            ListNCC_Print = new ObservableCollection <Model.NHACUNGCAP>(Model.DataProvider.Ins.DB.NHACUNGCAPs.Where(x => x.IsDeleted == false));

            Active        = false;
            IsOpen        = false;
            IsOpen_insert = false;
            IsOpen_Filter = false;
            IsOpen_prt    = false;

            Active_Command = new RelayCommand <object>(p =>
            {
                if (Active == false)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Active = false;
            });

            CloseDialog_Command = new RelayCommand <object>(p =>
            {
                return(true);
            }, p =>
            {
                IsOpen_prt = false;
            });

            Load_Command = new RelayCommand <object>(p =>
            {
                return(true);
            }, p =>
            {
                TaoDS_nhap();
                DeleteList  = new ObservableCollection <Model.CHITIETPHIEUNHAP>();
                ListMathang = new ObservableCollection <Model.MATHANG>(Model.DataProvider.Ins.DB.MATHANGs.Where(x => x.IsDeleted == false));

                ListNCC_Print = new ObservableCollection <Model.NHACUNGCAP>(Model.DataProvider.Ins.DB.NHACUNGCAPs.Where(x => x.IsDeleted == false));

                ListLoai_Filter       = new ObservableCollection <Model.LOAIHANG>(Model.DataProvider.Ins.DB.LOAIHANGs.Where(x => x.IsDeleted == false));
                ListMathang_Filter    = new ObservableCollection <Model.MATHANG>(Model.DataProvider.Ins.DB.MATHANGs.Where(x => x.IsDeleted == false));
                ListNhacungcap_Filter = new ObservableCollection <Model.NHACUNGCAP>(Model.DataProvider.Ins.DB.NHACUNGCAPs.Where(x => x.IsDeleted == false));

                Active        = false;
                IsOpen        = false;
                IsOpen_insert = false;
                IsOpen_Filter = false;
                IsOpen_prt    = false;
            });

            #region Tao moi
            Reset_Command = new RelayCommand <object>(p =>
            {
                return(true);
            }, p =>
            {
                SMathang        = null;
                Soluongnhap     = "";
                Soluongthucnhap = "";
                Dongianhap      = "";
                Dongiaxuat      = "";
                Phantram        = "";
                SelectedItem    = null;
            });
            #endregion

            #region Phan them

            GetvalueTextbox_Command = new RelayCommand <TextBox>(p =>
            {
                double d;
                if (!double.TryParse((p.Text), out d))
                {
                    return(false);
                }

                if (string.IsNullOrEmpty(p.Text))
                {
                    return(false);
                }

                if (SMathang == null)
                {
                    return(false);
                }

                if (string.IsNullOrEmpty(Soluongnhap) || string.IsNullOrEmpty(Soluongthucnhap) || string.IsNullOrEmpty(Dongianhap))
                {
                    return(false);
                }

                int dongianhap = 0;
                if (!int.TryParse(Dongianhap.Replace(" ", String.Empty), out dongianhap))
                {
                    return(false);
                }

                int soluongnhap = 0;
                if (!int.TryParse(Soluongnhap.Replace(" ", String.Empty), out soluongnhap))
                {
                    return(false);
                }

                int soluongthucnhap = 0;
                if (!int.TryParse(Soluongthucnhap.Replace(" ", String.Empty), out soluongthucnhap))
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Dongiaxuat = String.Empty;

                double phantram   = Convert.ToDouble(Phantram) / 100;
                double dongianhap = Convert.ToDouble(Dongianhap.Replace(" ", String.Empty));
                double dongiaxuat = ((phantram * dongianhap) + dongianhap);

                Dongiaxuat = dongiaxuat.ToString();
            });

            InsertShow_Command = new RelayCommand <object>(p =>
            {
                if (SMathang == null)
                {
                    return(false);
                }

                if (string.IsNullOrEmpty(Soluongnhap) || string.IsNullOrEmpty(Soluongthucnhap) ||
                    string.IsNullOrEmpty(Dongiaxuat) || string.IsNullOrEmpty(Dongianhap) || string.IsNullOrEmpty(Phantram))
                {
                    return(false);
                }

                int dongianhap = 0;
                if (!int.TryParse(Dongianhap.Replace(" ", String.Empty), out dongianhap))
                {
                    return(false);
                }

                int soluongnhap = 0;
                if (!int.TryParse(Soluongnhap.Replace(" ", String.Empty), out soluongnhap))
                {
                    return(false);
                }

                int soluongthucnhap = 0;
                if (!int.TryParse(Soluongthucnhap.Replace(" ", String.Empty), out soluongthucnhap))
                {
                    return(false);
                }

                try
                {
                    if (Convert.ToInt32(Soluongnhap) <= 0 || Convert.ToInt32(Soluongthucnhap) <= 0)
                    {
                        return(false);
                    }

                    if (Convert.ToInt32(Dongianhap) <= 0 || Convert.ToDouble(Phantram) < 0)
                    {
                        return(false);
                    }

                    if (Convert.ToInt32(Dongiaxuat) <= 0)
                    {
                        return(false);
                    }
                }
                catch (Exception) { /*Try catch de sua loi FormatException*/ }


                if (IsOpen_insert == true || IsOpen == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                IsOpen_insert = true;

                string date_str = MyStaticMethods.ConvertDate2Vn_Today();
                Ngay            = date_str;
            });

            Insert_Command = new RelayCommand <object>(p =>
            {
                if (SMathang == null)
                {
                    return(false);
                }

                if (string.IsNullOrEmpty(Soluongnhap) || string.IsNullOrEmpty(Soluongthucnhap) ||
                    string.IsNullOrEmpty(Dongiaxuat) || string.IsNullOrEmpty(Dongianhap) || string.IsNullOrEmpty(Phantram))
                {
                    return(false);
                }

                int dongianhap = 0;
                if (!int.TryParse(Dongianhap.Replace(" ", String.Empty), out dongianhap))
                {
                    return(false);
                }

                int soluongnhap = 0;
                if (!int.TryParse(Soluongnhap.Replace(" ", String.Empty), out soluongnhap))
                {
                    return(false);
                }

                int soluongthucnhap = 0;
                if (!int.TryParse(Soluongthucnhap.Replace(" ", String.Empty), out soluongthucnhap))
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                string date_str       = MyStaticMethods.ConvertDate2Vn_Today();
                Model.PHIEUNHAP Phieu = CheckPhieunhap(date_str);

                Model.CHITIETPHIEUNHAP newPhieu = new Model.CHITIETPHIEUNHAP()
                {
                    ma_ctphieunhap = MyStaticMethods.RandomInt(5) + "-" + SMathang.ma_mathang,
                    MATHANG        = SMathang,
                    ma_phieunhap   = Phieu.ma_phieunhap,

                    soluongnhap = Convert.ToInt32(Soluongnhap.Replace(" ", String.Empty)),
                    soluongthuc = Convert.ToInt32(Soluongthucnhap.Replace(" ", String.Empty)),
                    soluongton  = Convert.ToInt32(Soluongthucnhap.Replace(" ", String.Empty)),

                    gianhap = Convert.ToDouble(Dongianhap.Replace(" ", String.Empty)),
                    giaxuat = Convert.ToDouble(Dongiaxuat.Replace(" ", String.Empty)),

                    nguoitao  = getCurrentUser(),
                    ghichu    = Ghichu != "" ? Ghichu : null,
                    IsDeleted = false,
                };

                Model.Nhaphang_Service.Insert(newPhieu);

                List.Insert(0, newPhieu);
                SelectedItem = newPhieu;

                Active        = true;
                Message       = "Thêm mới thành công !!!";
                IsOpen_insert = false;
            });

            #endregion

            #region Phan xoa

            AddDeleteList_Command = new RelayCommand <CheckBox>(p =>
            {
                return(true);
            }, p =>
            {
                DeleteList.Add(List.Where(x => x.ma_ctphieunhap == p.Uid.ToString()).SingleOrDefault());
            });

            RemoveDeleteList_Command = new RelayCommand <CheckBox>(p =>
            {
                return(true);
            }, p =>
            {
                DeleteList.Remove(List.Where(x => x.ma_ctphieunhap == p.Uid.ToString()).SingleOrDefault());
            });

            DeleteShow_Command = new RelayCommand <object>(p =>
            {
                if (DeleteList.Count() == 0)
                {
                    return(false);
                }

                if (IsOpen_insert == true || IsOpen == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                IsOpen  = true;
                Content = "  Xóa các bản ghi được chọn ???";
            });


            Delete_Command = new RelayCommand <object>(p =>
            {
                if (DeleteList.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                RemoveIteminDb();
                RemoveIteminList();


                DeleteList   = new ObservableCollection <Model.CHITIETPHIEUNHAP>();
                IsOpen       = false;
                SelectedItem = null;
            });
            #endregion

            #region Phan loc

            ListLoai_Filter       = new ObservableCollection <Model.LOAIHANG>(Model.DataProvider.Ins.DB.LOAIHANGs.Where(x => x.IsDeleted == false));
            ListMathang_Filter    = new ObservableCollection <Model.MATHANG>(Model.DataProvider.Ins.DB.MATHANGs.Where(x => x.IsDeleted == false));
            ListNhacungcap_Filter = new ObservableCollection <Model.NHACUNGCAP>(Model.DataProvider.Ins.DB.NHACUNGCAPs.Where(x => x.IsDeleted == false));

            FilterLoai_Command = new RelayCommand <ComboBox>(p =>
            {
                return(true);
            }, p =>
            {
                if (SLoai_Filter != null)
                {
                    string ma = SLoai_Filter.ma_loaihang;
                    FilterMathangby_Loai(ma);
                }
                else
                {
                    ListMathang_Filter = new ObservableCollection <Model.MATHANG>(Model.DataProvider.Ins.DB.MATHANGs.Where(x => x.IsDeleted == false));
                }
            });

            OpenFilter_Command = new RelayCommand <object>(p =>
            {
                if (IsOpen_Filter == true || IsOpen == true || IsOpen_insert == true || IsOpen_prt == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                IsOpen_Filter = true;
            });

            ResetFilter_Command = new RelayCommand <Button>(p =>
            {
                return(true);
            }, p =>
            {
                ListLoai_Filter       = new ObservableCollection <Model.LOAIHANG>(Model.DataProvider.Ins.DB.LOAIHANGs.Where(x => x.IsDeleted == false));
                ListMathang_Filter    = new ObservableCollection <Model.MATHANG>(Model.DataProvider.Ins.DB.MATHANGs.Where(x => x.IsDeleted == false));
                ListNhacungcap_Filter = new ObservableCollection <Model.NHACUNGCAP>(Model.DataProvider.Ins.DB.NHACUNGCAPs.Where(x => x.IsDeleted == false));

                SNhacungcap_Filter = null;
                SMathang_Filter    = null;
                SLoai_Filter       = null;
                Date_Start         = String.Empty;
                Date_End           = String.Empty;

                TaoDS_nhap();

                IsOpen_Filter = false;
            });

            Filter_Command = new RelayCommand <Button>(p =>
            {
                if (string.IsNullOrEmpty(Date_Start) || string.IsNullOrEmpty(Date_End))
                {
                    return(false);
                }

                DateTime date_start = Convert.ToDateTime(Date_Start);
                DateTime date_end   = Convert.ToDateTime(Date_End);
                if ((date_start > date_end) && DateTime.TryParse(Date_Start, out date_start) && DateTime.TryParse(Date_End, out date_end))
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                List = new ObservableCollection <Model.CHITIETPHIEUNHAP>(Model.DataProvider.Ins.DB.CHITIETPHIEUNHAPs.Where(x => x.IsDeleted == false).OrderByDescending(x => x.ma_phieunhap));

                DateTime date_start = Convert.ToDateTime(Date_Start);
                DateTime date_end   = Convert.ToDateTime(Date_End);

                FindByDate(date_start, date_end);

                if (SMathang_Filter != null)
                {
                    FindByMH(SMathang_Filter.ma_mathang);
                }

                if (SNhacungcap_Filter != null)
                {
                    FindByNCC(SNhacungcap_Filter.ma_nhacungcap);
                }

                if (SLoai_Filter != null)
                {
                    FindByLOAI(SLoai_Filter.ma_loaihang);
                }

                IsOpen_Filter = false;
            });
            #endregion

            #region Phan sap xep

            OrderbyTenMathang_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.CHITIETPHIEUNHAP> chkList = new ObservableCollection <Model.CHITIETPHIEUNHAP>(List.OrderByDescending(x => x.MATHANG.ten_mathang));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.CHITIETPHIEUNHAP>(List.OrderBy(x => x.MATHANG.ten_mathang));
                }
                else
                {
                    List = new ObservableCollection <Model.CHITIETPHIEUNHAP>(chkList);
                }
            });

            OrderbyTennhacungcap_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.CHITIETPHIEUNHAP> chkList = new ObservableCollection <Model.CHITIETPHIEUNHAP>(List.OrderByDescending(x => x.MATHANG.NHACUNGCAP.ten_nhacungcap));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.CHITIETPHIEUNHAP>(List.OrderBy(x => x.MATHANG.NHACUNGCAP.ten_nhacungcap));
                }
                else
                {
                    List = new ObservableCollection <Model.CHITIETPHIEUNHAP>(chkList);
                }
            });

            OrderbyNgay_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.CHITIETPHIEUNHAP> chkList = new ObservableCollection <Model.CHITIETPHIEUNHAP>(List.OrderByDescending(x => MyStaticMethods.ConvertStringtoDate(x.PHIEUNHAP.ngaynhap)));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.CHITIETPHIEUNHAP>(List.OrderBy(x => MyStaticMethods.ConvertStringtoDate(x.PHIEUNHAP.ngaynhap)));
                }
                else
                {
                    List = new ObservableCollection <Model.CHITIETPHIEUNHAP>(chkList);
                }
            });

            OrderbyTendonvi_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.CHITIETPHIEUNHAP> chkList = new ObservableCollection <Model.CHITIETPHIEUNHAP>(List.OrderByDescending(x => x.MATHANG.DONVITINH.ten_donvi));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.CHITIETPHIEUNHAP>(List.OrderBy(x => x.MATHANG.DONVITINH.ten_donvi));
                }
                else
                {
                    List = new ObservableCollection <Model.CHITIETPHIEUNHAP>(chkList);
                }
            });

            #endregion

            #region Printer

            PrinterOpen_Command = new RelayCommand <object>(p =>
            {
                if (SNhacungcapPrint == null)
                {
                    return(false);
                }

                if (string.IsNullOrEmpty(DayPrint))
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                List_Print = new ObservableCollection <Model.CHITIETPHIEUNHAP>(List.Where(x => x.MATHANG.NHACUNGCAP == SNhacungcapPrint &&
                                                                                          x.PHIEUNHAP.ngaynhap == MyStaticMethods.FormatDateString(DayPrint)));

                var list_chk = new ObservableCollection <Model.CHITIETPHIEUNHAP>();

                ItemsCount = 0;
                Tongtien   = 0;

                foreach (var item in List_Print)
                {
                    Tongtien += (double)(item.gianhap * item.soluongthuc);

                    if (list_chk.Where(x => x.MATHANG == item.MATHANG).Count() == 0)
                    {
                        list_chk.Add(item);
                    }
                }

                ItemsCount = list_chk.Count();


                DayPrintVN = MyStaticMethods.FormatDateString(DayPrint);

                View.View_Thukho.In_Nhap w = new View.View_Thukho.In_Nhap();
                w.ShowDialog();
            });

            OpenPrintDialog_Command = new RelayCommand <object>(p =>
            {
                if (IsOpen == true)
                {
                    return(false);
                }

                if (IsOpen_insert == true)
                {
                    return(false);
                }

                if (IsOpen_Filter == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                IsOpen_prt = true;
            });

            Print_Command = new RelayCommand <Grid>(p =>
            {
                return(true);
            }, p =>
            {
                try
                {
                    PrintDialog printDialog = new PrintDialog();
                    if (printDialog.ShowDialog() == true)
                    {
                        printDialog.PrintVisual(p, "invoice");
                    }

                    MessageBox.Show("Thành công !!!", "THÔNG BÁO");
                }
                catch (Exception) { MessageBox.Show("Có lỗi xảy ra !!!", "THÔNG BÁO"); };
            });

            PrinterFormClose_Command = new RelayCommand <Window>(p =>
            {
                return(true);
            }, p =>
            {
                if (p != null)
                {
                    p.Close();
                    IsOpen_prt = false;
                }
            });

            #endregion
        }
Beispiel #11
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (clsFormRights.HasFormRight(clsFormRights.Forms.frmBarCode, clsFormRights.Operation.Save) || clsUtility.IsAdmin)
            {
                if (numericUpDown1.Value <= 0)
                {
                    clsUtility.ShowInfoMessage("Please enter QTY greater than 0", clsUtility.strProjectTitle);
                    return;
                }

                if (!IsBarCodeSettings())
                {
                    clsUtility.ShowInfoMessage("Please set the Barcode design before barcode printing." + Environment.NewLine + "To Design Barcode, Open Barcode designer from Barcode menu from main window.");
                    return;
                }

                PrintDialog     pd             = new PrintDialog();
                PrinterSettings printerSetting = new PrinterSettings();
                if (clsBarCodeUtility.GetPrinterName(clsBarCodeUtility.PrinterType.BarCodePrinter).Trim().Length == 0)
                {
                    bool b = clsUtility.ShowQuestionMessage("Printer Not Configured for barcode. Do you want to print on default printer?", clsUtility.strProjectTitle);
                    if (b == false)
                    {
                        return;
                    }
                }
                printerSetting.PrinterName = clsBarCodeUtility.GetPrinterName(clsBarCodeUtility.PrinterType.BarCodePrinter);

                PrintDocument doc = new PrintDocument();
                doc.PrinterSettings = printerSetting;

                doc.PrintPage += Doc_PrintPage;
                pd.Document    = doc;
                //if (pd.ShowDialog() == DialogResult.OK)/
                for (int i = 0; i < dgvProductDetails.Rows.Count; i++)
                {
                    if (dgvProductDetails.Rows[i].Cells["colCHeck"].Value != DBNull.Value && Convert.ToBoolean(dgvProductDetails.Rows[i].Cells["colCHeck"].Value))
                    {
                        _PrintRowData          = dgvProductDetails.Rows[i];
                        _Current_BarCodeNumber = dgvProductDetails.Rows[i].Cells["BarcodeNo"].Value.ToString();

                        #region Manaually BarCode generate
                        //int PID = Convert.ToInt32(dgvProductDetails.Rows[i].Cells["ColProductID"].Value);
                        //int SubProductID = Convert.ToInt32(dgvProductDetails.Rows[i].Cells["SubProductID"].Value);

                        //int QTY = Convert.ToInt32(dgvProductDetails.Rows[i].Cells["ColQTY"].Value);

                        //int SizeID = Convert.ToInt32(dgvProductDetails.Rows[i].Cells["SizeID"].Value);
                        //int ColorID = Convert.ToInt32(dgvProductDetails.Rows[i].Cells["ColColorID"].Value);

                        // check if barcode number exist
                        //DataTable dtBarCodeNumber = ObjCon.ExecuteSelectStatement("SELECT BarcodeNo FROM  " + clsUtility.DBName + ".dbo.ProductStockColorSizeMaster WITH(NOLOCK) WHERE ProductID=" + PID + " AND SubProductID=" + SubProductID + " AND ColorID=" + ColorID + " AND SizeID=" + SizeID);
                        //if (ObjUtil.ValidateTable(dtBarCodeNumber))
                        //{
                        //    if (dtBarCodeNumber.Rows[0]["BarcodeNo"] != DBNull.Value && dtBarCodeNumber.Rows[0]["BarcodeNo"].ToString().Length >= 0)
                        //    {
                        //        _Current_BarCodeNumber = dtBarCodeNumber.Rows[0]["BarcodeNo"].ToString();

                        //        // update the bar code in [ProductStockMaster]
                        //        string strUpdate2 = "UPDATE " + clsUtility.DBName + ".[dbo].[ProductStockMaster] SET BarcodeNo='" + _Current_BarCodeNumber + "' WHERE ProductID=" + PID + " AND SubProductID=" + SubProductID + " AND PurchaseInvoiceID=" + CurrentPurchaseInvoiceID +
                        //     " AND SizeID=" + SizeID + " AND ColorID=" + ColorID;
                        //        ObjCon.ExecuteNonQuery(strUpdate2);
                        //    }
                        //    else
                        //    {
                        //        _Current_BarCodeNumber = GetBarcodeNumber();

                        //        // update the bar code in  ProductStockColorSizeMaster ( main stock table)
                        //        string strUpdat = "UPDATE  " + clsUtility.DBName + ".dbo.ProductStockColorSizeMaster SET BarcodeNo='" + _Current_BarCodeNumber + "' WHERE ProductID=" + PID + " AND SubProductID=" + SubProductID + " AND ColorID=" + ColorID + " AND SizeID=" + SizeID;

                        //        ObjCon.ExecuteNonQuery(strUpdat);

                        //        // update the bar code in [ProductStockMaster]
                        //        string strUpdate2 = "UPDATE " + clsUtility.DBName + ".[dbo].[ProductStockMaster] SET BarcodeNo='" + _Current_BarCodeNumber + "' WHERE ProductID=" + PID + " AND SubProductID=" + SubProductID + " AND PurchaseInvoiceID=" + CurrentPurchaseInvoiceID +
                        //     " AND SizeID=" + SizeID + " AND ColorID=" + ColorID;
                        //        ObjCon.ExecuteNonQuery(strUpdate2);
                        //    }
                        //}
                        //else
                        //{
                        //    _Current_BarCodeNumber = GetBarcodeNumber();

                        //    string strUpdat = "UPDATE  " + clsUtility.DBName + ".dbo.ProductStockColorSizeMaster " +
                        //        " SET BarcodeNo='" + _Current_BarCodeNumber + "' WHERE ProductID=" + PID + " AND SubProductID=" + SubProductID + " AND ColorID=" + ColorID + " AND SizeID=" + SizeID;
                        //    ObjCon.ExecuteNonQuery(strUpdat);
                        //}
                        //UpdateProductBardCodeImageNo(PID.ToString(), _Current_BarCodeNumber);
                        //UpdateSubProductBardCodeImageNo(PID.ToString(), SubProductID.ToString(), _Current_BarCodeNumber);
                        #endregion

                        for (int Q = 0; Q < numericUpDown1.Value; Q++)
                        {
                            doc.Print();
                        }
                        UpdateProductStockMasterStatus(Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(dgvProductDetails.Rows[i].Cells["ProductStockID"].Value));
                    }
                }
                this.Focus();
                this.BringToFront();
                clsUtility.ShowInfoMessage("Operation completed !", clsUtility.strProjectTitle);
                this.Activate();
                RefreshData();

                //try
                //{
                //    if (obj!=null)
                //    {
                //        obj.Dispose();
                //        obj = null;
                //    }
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show("While disposing : " + ex.Message);
                //}
            }
        }
Beispiel #12
0
        private void InitializeComponent()
        {
            DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();

            this.pnlHeader    = new Panel();
            this.btnExit      = new Button();
            this.btnPrint     = new Button();
            this.btnDelete    = new Button();
            this.btnEdit      = new Button();
            this.btnAdd       = new Button();
            this.dgvEmployee  = new DataGridView();
            this.printDialog1 = new PrintDialog();
            this.pnlHeader.SuspendLayout();
            this.dgvEmployee.BeginInit();
            base.SuspendLayout();
            this.pnlHeader.Controls.Add(this.btnExit);
            this.pnlHeader.Controls.Add(this.btnPrint);
            this.pnlHeader.Controls.Add(this.btnDelete);
            this.pnlHeader.Controls.Add(this.btnEdit);
            this.pnlHeader.Controls.Add(this.btnAdd);
            this.pnlHeader.Dock     = DockStyle.Top;
            this.pnlHeader.Location = new Point(0, 0);
            this.pnlHeader.Name     = "pnlHeader";
            this.pnlHeader.Size     = new Size(751, 47);
            this.pnlHeader.TabIndex = 0;
            this.btnExit.Anchor     = AnchorStyles.Top | AnchorStyles.Right;
            this.btnExit.BackColor  = Color.FromArgb(150, 180, 200);
            this.btnExit.FlatAppearance.BorderColor        = Color.Black;
            this.btnExit.FlatAppearance.MouseDownBackColor = Color.FromArgb(90, 180, 200);
            this.btnExit.FlatAppearance.MouseOverBackColor = Color.FromArgb(120, 180, 200);
            this.btnExit.FlatStyle               = FlatStyle.Flat;
            this.btnExit.Image                   = Resources.Exit;
            this.btnExit.ImageAlign              = ContentAlignment.MiddleLeft;
            this.btnExit.Location                = new Point(252, 10);
            this.btnExit.Name                    = "btnExit";
            this.btnExit.Size                    = new Size(84, 27);
            this.btnExit.TabIndex                = 5;
            this.btnExit.Text                    = "خروج";
            this.btnExit.TextImageRelation       = TextImageRelation.ImageBeforeText;
            this.btnExit.UseVisualStyleBackColor = false;
            this.btnExit.add_Click(new EventHandler(this.btnExit_Click));
            this.btnPrint.Anchor    = AnchorStyles.Top | AnchorStyles.Right;
            this.btnPrint.BackColor = Color.FromArgb(150, 180, 200);
            this.btnPrint.FlatAppearance.BorderColor        = Color.Black;
            this.btnPrint.FlatAppearance.MouseDownBackColor = Color.FromArgb(90, 180, 200);
            this.btnPrint.FlatAppearance.MouseOverBackColor = Color.FromArgb(120, 180, 200);
            this.btnPrint.FlatStyle               = FlatStyle.Flat;
            this.btnPrint.Image                   = Resources.Print;
            this.btnPrint.ImageAlign              = ContentAlignment.MiddleLeft;
            this.btnPrint.Location                = new Point(353, 10);
            this.btnPrint.Name                    = "btnPrint";
            this.btnPrint.Size                    = new Size(84, 27);
            this.btnPrint.TabIndex                = 4;
            this.btnPrint.Text                    = "طباعة";
            this.btnPrint.TextImageRelation       = TextImageRelation.ImageBeforeText;
            this.btnPrint.UseVisualStyleBackColor = false;
            this.btnPrint.add_Click(new EventHandler(this.btnPrint_Click));
            this.btnDelete.Anchor    = AnchorStyles.Top | AnchorStyles.Right;
            this.btnDelete.BackColor = Color.FromArgb(150, 180, 200);
            this.btnDelete.FlatAppearance.BorderColor        = Color.Black;
            this.btnDelete.FlatAppearance.MouseDownBackColor = Color.FromArgb(90, 180, 200);
            this.btnDelete.FlatAppearance.MouseOverBackColor = Color.FromArgb(120, 180, 200);
            this.btnDelete.FlatStyle               = FlatStyle.Flat;
            this.btnDelete.Image                   = Resources.Delete;
            this.btnDelete.ImageAlign              = ContentAlignment.MiddleLeft;
            this.btnDelete.Location                = new Point(454, 10);
            this.btnDelete.Name                    = "btnDelete";
            this.btnDelete.Size                    = new Size(84, 27);
            this.btnDelete.TabIndex                = 3;
            this.btnDelete.Text                    = "حذف";
            this.btnDelete.TextImageRelation       = TextImageRelation.ImageBeforeText;
            this.btnDelete.UseVisualStyleBackColor = false;
            this.btnDelete.add_Click(new EventHandler(this.btnDelete_Click));
            this.btnEdit.Anchor    = AnchorStyles.Top | AnchorStyles.Right;
            this.btnEdit.BackColor = Color.FromArgb(150, 180, 200);
            this.btnEdit.FlatAppearance.BorderColor        = Color.Black;
            this.btnEdit.FlatAppearance.MouseDownBackColor = Color.FromArgb(90, 180, 200);
            this.btnEdit.FlatAppearance.MouseOverBackColor = Color.FromArgb(120, 180, 200);
            this.btnEdit.FlatStyle               = FlatStyle.Flat;
            this.btnEdit.Image                   = Resources.Edit;
            this.btnEdit.ImageAlign              = ContentAlignment.MiddleLeft;
            this.btnEdit.Location                = new Point(554, 10);
            this.btnEdit.Name                    = "btnEdit";
            this.btnEdit.Size                    = new Size(84, 27);
            this.btnEdit.TabIndex                = 2;
            this.btnEdit.Text                    = "تعديل";
            this.btnEdit.TextImageRelation       = TextImageRelation.ImageBeforeText;
            this.btnEdit.UseVisualStyleBackColor = false;
            this.btnEdit.add_Click(new EventHandler(this.btnEdit_Click));
            this.btnAdd.Anchor    = AnchorStyles.Top | AnchorStyles.Right;
            this.btnAdd.BackColor = Color.FromArgb(150, 180, 200);
            this.btnAdd.FlatAppearance.BorderColor        = Color.Black;
            this.btnAdd.FlatAppearance.MouseDownBackColor = Color.FromArgb(90, 180, 200);
            this.btnAdd.FlatAppearance.MouseOverBackColor = Color.FromArgb(120, 180, 200);
            this.btnAdd.FlatStyle               = FlatStyle.Flat;
            this.btnAdd.Image                   = Resources.Add;
            this.btnAdd.ImageAlign              = ContentAlignment.MiddleLeft;
            this.btnAdd.Location                = new Point(654, 10);
            this.btnAdd.Name                    = "btnAdd";
            this.btnAdd.Size                    = new Size(84, 27);
            this.btnAdd.TabIndex                = 1;
            this.btnAdd.Text                    = "إضافة";
            this.btnAdd.TextImageRelation       = TextImageRelation.ImageBeforeText;
            this.btnAdd.UseVisualStyleBackColor = false;
            this.btnAdd.add_Click(new EventHandler(this.btnAdd_Click));
            this.dgvEmployee.AllowUserToAddRows          = false;
            this.dgvEmployee.AllowUserToDeleteRows       = false;
            this.dgvEmployee.AutoSizeColumnsMode         = DataGridViewAutoSizeColumnsMode.Fill;
            this.dgvEmployee.BackgroundColor             = SystemColors.ControlDarkDark;
            this.dgvEmployee.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dgvEmployee.Dock                    = DockStyle.Fill;
            this.dgvEmployee.Location                = new Point(0, 47);
            this.dgvEmployee.MultiSelect             = false;
            this.dgvEmployee.Name                    = "dgvEmployee";
            this.dgvEmployee.ReadOnly                = true;
            dataGridViewCellStyle.SelectionBackColor = SystemColors.ControlDark;
            this.dgvEmployee.RowsDefaultCellStyle    = dataGridViewCellStyle;
            this.dgvEmployee.SelectionMode           = DataGridViewSelectionMode.FullRowSelect;
            this.dgvEmployee.Size                    = new Size(751, 383);
            this.dgvEmployee.TabIndex                = 1;
            this.dgvEmployee.add_MouseDoubleClick(new MouseEventHandler(this.dgvEmployee_MouseDoubleClick));
            this.dgvEmployee.add_KeyDown(new KeyEventHandler(this.dgvEmployee_KeyDown));
            this.dgvEmployee.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(this.dgvEmployee_DataBindingComplete);
            this.printDialog1.UseEXDialog         = true;
            base.AutoScaleDimensions              = new SizeF(6, 13);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize    = new Size(751, 430);
            base.Controls.Add(this.dgvEmployee);
            base.Controls.Add(this.pnlHeader);
            base.FormBorderStyle   = FormBorderStyle.Fixed3D;
            base.Name              = "EmployeeForm";
            base.RightToLeft       = RightToLeft.Yes;
            base.RightToLeftLayout = true;
            base.ShowIcon          = false;
            base.Text              = "الموظفون";
            base.Load             += new EventHandler(this.EmployeeForm_Load);
            this.pnlHeader.ResumeLayout(false);
            this.dgvEmployee.EndInit();
            base.ResumeLayout(false);
        }
Beispiel #13
0
        public void ZReport(app_account_session app_account_session)
        {
            string Header = string.Empty;
            string Detail = string.Empty;
            string Footer = string.Empty;

            string      CompanyName = string.Empty;
            string      BranchName  = string.Empty;
            app_company app_company = null;

            if (app_account_session.app_company != null)
            {
                CompanyName = app_account_session.app_company.name;
                app_company = app_account_session.app_company;
            }
            else
            {
                using (db db = new db())
                {
                    if (db.app_company.Where(x => x.id_company == app_account_session.id_company).FirstOrDefault() != null)
                    {
                        app_company = db.app_company.Where(x => x.id_company == app_account_session.id_company).FirstOrDefault();
                        CompanyName = app_company.name;
                    }
                }
            }

            string UserName = "";

            if (app_account_session.security_user != null)
            {
                UserName = app_account_session.security_user.name;
            }
            else
            {
                using (db db = new db())
                {
                    if (db.security_user.Where(x => x.id_user == app_account_session.id_user).FirstOrDefault() != null)
                    {
                        security_user security_user = db.security_user.Where(x => x.id_user == app_account_session.id_user).FirstOrDefault();
                        UserName = security_user.name;
                    }
                }
            }
            using (db db = new db())
            {
                if (db.app_branch.Where(x => x.id_branch == CurrentSession.Id_Branch).FirstOrDefault() != null)
                {
                    app_branch app_branch = db.app_branch.Where(x => x.id_branch == CurrentSession.Id_Branch).FirstOrDefault();
                    BranchName = app_branch.name;
                }
            }

            string   SessionID = app_account_session.id_session.ToString();
            DateTime OpenDate  = app_account_session.op_date;
            DateTime CloseDate = DateTime.Now;

            if (app_account_session.cl_date != null)
            {
                CloseDate = (DateTime)app_account_session.cl_date;
            }

            Header =
                "***Z Report***" + "\n"
                + CompanyName + "\t" + BranchName + "\n"
                + "R.U.C.   :" + app_company.gov_code + "\n"
                + app_company.address + "\n"
                + "***" + app_company.alias + "***" + "\n"
                + "Apertura : " + OpenDate + "\n"
                + "Cierre   : " + CloseDate
                + "\n"
                + "--------------------------------" + "\n"
                + "Hora   Factura      / Valor    Moneda" + "\n"
                + "--------------------------------" + "\n";

            string CustomerName = string.Empty;

            foreach (app_account_detail detail in app_account_session.app_account_detail.GroupBy(x => x.id_currencyfx).Select(x => x.FirstOrDefault()).ToList())
            {
                Detail += "Moneda : " + detail.app_currencyfx.app_currency.name + "\n";

                if (detail.tran_type == app_account_detail.tran_types.Open)
                {
                    Detail += "Balance de Apertura : " + Math.Round(detail.credit, 2) + "\n";
                }
                foreach (app_account_detail d in app_account_session.app_account_detail.Where(x => x.tran_type == app_account_detail.tran_types.Transaction && x.id_currencyfx == detail.id_currencyfx).ToList())
                {
                    string AccountName = string.Empty;

                    if (d.app_account == null)
                    {
                        using (db db = new db())
                        {
                            app_account app_account = db.app_account.Where(x => x.id_account == d.id_account).FirstOrDefault();
                            AccountName = app_account.name;
                        }
                    }

                    string currency = string.Empty;
                    if (d.app_currencyfx == null)
                    {
                        using (db db = new db())
                        {
                            currency = db.app_currencyfx.Where(x => x.id_currencyfx == d.id_currencyfx).FirstOrDefault().app_currency.name;
                        }
                    }

                    string InvoiceNumber = string.Empty;
                    string InvoiceTime   = string.Empty;

                    payment_detail payment_detail = d.payment_detail as payment_detail;
                    foreach (payment_schedual payment_schedual in payment_detail.payment_schedual)
                    {
                        if (payment_schedual.sales_invoice.number != null)
                        {
                            if (!(InvoiceNumber.Contains(payment_schedual.sales_invoice.number)))
                            {
                                InvoiceNumber += payment_schedual.sales_invoice.number;
                                InvoiceTime    = payment_schedual.sales_invoice.trans_date.ToShortTimeString();
                            }
                        }
                    }

                    decimal?value = d.credit - d.debit;
                }

                var listvat = app_account_session.app_account_detail.Where(x => x.tran_type == app_account_detail.tran_types.Transaction && x.id_currencyfx == detail.id_currencyfx)
                              .GroupBy(a => new { a.id_payment_type, a.id_currencyfx })
                              .Select(g => new
                {
                    Currencyname    = g.Max(x => x.app_currencyfx).app_currency.name,
                    paymentname     = g.Max(x => x.payment_type).name,
                    id_currencyfx   = g.Key.id_currencyfx,
                    id_payment_type = g.Key.id_payment_type,
                    value           = g.Sum(a => a.credit)
                }).ToList().OrderBy(x => x.id_currencyfx);
                Detail += "Total de Ventas Neto :" + Math.Round(listvat.Sum(x => x.value), 2) + "\n";

                foreach (dynamic item in listvat)
                {
                    Detail += item.paymentname + "\t" + Math.Round(item.value, 2) + "\n";
                }

                foreach (app_account_detail account_detail in app_account_session.app_account_detail.Where(x => x.tran_type == app_account_detail.tran_types.Close && x.id_currencyfx == detail.id_currencyfx).GroupBy(x => x.id_currencyfx).Select(x => x.FirstOrDefault()).ToList())
                {
                    Detail += "Balance de Cierre : " + Math.Round(account_detail.debit, 2);
                    Detail += "\n--------------------------------" + "\n";
                }

                Detail += "\n--------------------------------" + "\n";
            }

            using (db db = new db())
            {
                decimal amount      = 0M;
                int[]   id_schedual = new int[10];
                int     index       = 0;

                foreach (app_account_detail account_detail in db.app_account_detail.Where(x => x.id_session == app_account_session.id_session && x.tran_type == app_account_detail.tran_types.Transaction).ToList())
                {
                    foreach (payment_schedual payment_schedual in account_detail.payment_detail.payment_schedual.ToList())
                    {
                        if (!id_schedual.Contains(payment_schedual.parent.id_payment_schedual))
                        {
                            if (payment_schedual.parent != null)
                            {
                                id_schedual[index] = payment_schedual.parent.id_payment_schedual;
                                amount            += payment_schedual.parent.debit;
                            }
                            else
                            {
                                amount += payment_schedual.credit;
                            }
                        }
                    }
                }

                Detail += "Total de Ventas Neto : " + Math.Round(amount, 2) + " \n";
            }
            Footer += "Cajero/a : " + UserName + " /n";
            Footer += "--------------------------------" + " \n";

            string Text = Header + Detail + Footer;

            Reciept     Reciept = new Reciept();
            PrintDialog pd      = new PrintDialog();

            FlowDocument document = new FlowDocument(new Paragraph(new Run(Text)));

            document.Name        = "ItemMovement";
            document.FontFamily  = new FontFamily("Courier New");
            document.FontSize    = 11.0;
            document.FontStretch = FontStretches.Normal;
            document.FontWeight  = FontWeights.Normal;

            document.PagePadding = new Thickness(20);

            document.PageHeight = double.NaN;
            document.PageWidth  = double.NaN;
            //document.

            //Specify minimum page sizes. Origintally 283, but was too small.
            document.MinPageWidth = 283;
            //Specify maximum page sizes.
            document.MaxPageWidth = 300;

            IDocumentPaginatorSource idpSource = document;

            try
            {
                Nullable <bool> print = pd.ShowDialog();
                if (print == true)
                {
                    pd.PrintDocument(idpSource.DocumentPaginator, Text);
                }
            }
            catch
            { MessageBox.Show("Output (Reciept Printer) not Found Error", "Error 101"); }
        }
 /// <summary>
 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
 /// 此方法的内容。
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmOutpatientChargeIdetityPrint));
     this.panelTop               = new System.Windows.Forms.Panel();
     this.m_cmdOutExcel          = new PinkieControls.ButtonXP();
     this.label5                 = new System.Windows.Forms.Label();
     this.numericUpDown1         = new System.Windows.Forms.NumericUpDown();
     this.buttonXP2              = new PinkieControls.ButtonXP();
     this.m_cmdQuery             = new PinkieControls.ButtonXP();
     this.m_cboOperator          = new System.Windows.Forms.ComboBox();
     this.label4                 = new System.Windows.Forms.Label();
     this.m_cboIdentity          = new System.Windows.Forms.ComboBox();
     this.label3                 = new System.Windows.Forms.Label();
     this.m_dateTimePickerEnd    = new System.Windows.Forms.DateTimePicker();
     this.label2                 = new System.Windows.Forms.Label();
     this.m_dateTimePickerBegin  = new System.Windows.Forms.DateTimePicker();
     this.label1                 = new System.Windows.Forms.Label();
     this.m_cmdExit              = new PinkieControls.ButtonXP();
     this.panelFill              = new System.Windows.Forms.Panel();
     this.m_printPreviewControl1 = new System.Windows.Forms.PrintPreviewControl();
     this.m_printDocument1       = new System.Drawing.Printing.PrintDocument();
     this.m_printPreviewDialog1  = new System.Windows.Forms.PrintPreviewDialog();
     this.printDialog1           = new System.Windows.Forms.PrintDialog();
     this.panelTop.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
     this.panelFill.SuspendLayout();
     this.SuspendLayout();
     //
     // panelTop
     //
     this.panelTop.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     this.panelTop.Controls.Add(this.m_cmdOutExcel);
     this.panelTop.Controls.Add(this.label5);
     this.panelTop.Controls.Add(this.numericUpDown1);
     this.panelTop.Controls.Add(this.buttonXP2);
     this.panelTop.Controls.Add(this.m_cmdQuery);
     this.panelTop.Controls.Add(this.m_cboOperator);
     this.panelTop.Controls.Add(this.label4);
     this.panelTop.Controls.Add(this.m_cboIdentity);
     this.panelTop.Controls.Add(this.label3);
     this.panelTop.Controls.Add(this.m_dateTimePickerEnd);
     this.panelTop.Controls.Add(this.label2);
     this.panelTop.Controls.Add(this.m_dateTimePickerBegin);
     this.panelTop.Controls.Add(this.label1);
     this.panelTop.Controls.Add(this.m_cmdExit);
     this.panelTop.Dock     = System.Windows.Forms.DockStyle.Top;
     this.panelTop.Location = new System.Drawing.Point(0, 0);
     this.panelTop.Name     = "panelTop";
     this.panelTop.Size     = new System.Drawing.Size(1000, 56);
     this.panelTop.TabIndex = 0;
     //
     // m_cmdOutExcel
     //
     this.m_cmdOutExcel.BackColor     = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
     this.m_cmdOutExcel.DefaultScheme = true;
     this.m_cmdOutExcel.DialogResult  = System.Windows.Forms.DialogResult.None;
     this.m_cmdOutExcel.Hint          = "";
     this.m_cmdOutExcel.Location      = new System.Drawing.Point(784, 11);
     this.m_cmdOutExcel.Name          = "m_cmdOutExcel";
     this.m_cmdOutExcel.Scheme        = PinkieControls.ButtonXP.Schemes.Blue;
     this.m_cmdOutExcel.Size          = new System.Drawing.Size(80, 32);
     this.m_cmdOutExcel.TabIndex      = 75;
     this.m_cmdOutExcel.Text          = "导出(&O)";
     this.m_cmdOutExcel.Click        += new System.EventHandler(this.m_cmdOutExcel_Click);
     //
     // label5
     //
     this.label5.AutoSize = true;
     this.label5.Location = new System.Drawing.Point(944, 18);
     this.label5.Name     = "label5";
     this.label5.Size     = new System.Drawing.Size(42, 14);
     this.label5.TabIndex = 74;
     this.label5.Text     = "页码:";
     //
     // numericUpDown1
     //
     this.numericUpDown1.Location = new System.Drawing.Point(984, 16);
     this.numericUpDown1.Maximum  = new decimal(new int[] {
         1,
         0,
         0,
         0
     });
     this.numericUpDown1.Minimum = new decimal(new int[] {
         1,
         0,
         0,
         0
     });
     this.numericUpDown1.Name      = "numericUpDown1";
     this.numericUpDown1.Size      = new System.Drawing.Size(40, 23);
     this.numericUpDown1.TabIndex  = 73;
     this.numericUpDown1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
     this.numericUpDown1.Value     = new decimal(new int[] {
         1,
         0,
         0,
         0
     });
     this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
     //
     // buttonXP2
     //
     this.buttonXP2.BackColor     = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
     this.buttonXP2.DefaultScheme = true;
     this.buttonXP2.DialogResult  = System.Windows.Forms.DialogResult.None;
     this.buttonXP2.Hint          = "";
     this.buttonXP2.Location      = new System.Drawing.Point(704, 11);
     this.buttonXP2.Name          = "buttonXP2";
     this.buttonXP2.Scheme        = PinkieControls.ButtonXP.Schemes.Blue;
     this.buttonXP2.Size          = new System.Drawing.Size(80, 32);
     this.buttonXP2.TabIndex      = 72;
     this.buttonXP2.Text          = "打印(&F4)";
     this.buttonXP2.Click        += new System.EventHandler(this.buttonXP2_Click);
     //
     // m_cmdQuery
     //
     this.m_cmdQuery.BackColor     = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
     this.m_cmdQuery.DefaultScheme = true;
     this.m_cmdQuery.DialogResult  = System.Windows.Forms.DialogResult.None;
     this.m_cmdQuery.Hint          = "";
     this.m_cmdQuery.Location      = new System.Drawing.Point(624, 11);
     this.m_cmdQuery.Name          = "m_cmdQuery";
     this.m_cmdQuery.Scheme        = PinkieControls.ButtonXP.Schemes.Blue;
     this.m_cmdQuery.Size          = new System.Drawing.Size(80, 32);
     this.m_cmdQuery.TabIndex      = 60;
     this.m_cmdQuery.Text          = "查询(&F6)";
     this.m_cmdQuery.Click        += new System.EventHandler(this.m_cmdQuery_Click);
     //
     // m_cboOperator
     //
     this.m_cboOperator.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     this.m_cboOperator.Location      = new System.Drawing.Point(528, 16);
     this.m_cboOperator.Name          = "m_cboOperator";
     this.m_cboOperator.Size          = new System.Drawing.Size(88, 22);
     this.m_cboOperator.TabIndex      = 40;
     //
     // label4
     //
     this.label4.AutoSize = true;
     this.label4.Location = new System.Drawing.Point(472, 18);
     this.label4.Name     = "label4";
     this.label4.Size     = new System.Drawing.Size(56, 14);
     this.label4.TabIndex = 8;
     this.label4.Text     = "操作员:";
     //
     // m_cboIdentity
     //
     this.m_cboIdentity.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     this.m_cboIdentity.Location      = new System.Drawing.Point(384, 16);
     this.m_cboIdentity.Name          = "m_cboIdentity";
     this.m_cboIdentity.Size          = new System.Drawing.Size(88, 22);
     this.m_cboIdentity.TabIndex      = 30;
     //
     // label3
     //
     this.label3.AutoSize = true;
     this.label3.Location = new System.Drawing.Point(344, 18);
     this.label3.Name     = "label3";
     this.label3.Size     = new System.Drawing.Size(42, 14);
     this.label3.TabIndex = 6;
     this.label3.Text     = "身份:";
     this.label3.Click   += new System.EventHandler(this.label3_Click);
     //
     // m_dateTimePickerEnd
     //
     this.m_dateTimePickerEnd.Location = new System.Drawing.Point(216, 16);
     this.m_dateTimePickerEnd.Name     = "m_dateTimePickerEnd";
     this.m_dateTimePickerEnd.Size     = new System.Drawing.Size(120, 23);
     this.m_dateTimePickerEnd.TabIndex = 20;
     //
     // label2
     //
     this.label2.AutoSize = true;
     this.label2.Location = new System.Drawing.Point(200, 18);
     this.label2.Name     = "label2";
     this.label2.Size     = new System.Drawing.Size(21, 14);
     this.label2.TabIndex = 4;
     this.label2.Text     = "至";
     //
     // m_dateTimePickerBegin
     //
     this.m_dateTimePickerBegin.Location = new System.Drawing.Point(80, 16);
     this.m_dateTimePickerBegin.Name     = "m_dateTimePickerBegin";
     this.m_dateTimePickerBegin.Size     = new System.Drawing.Size(120, 23);
     this.m_dateTimePickerBegin.TabIndex = 0;
     //
     // label1
     //
     this.label1.AutoSize = true;
     this.label1.Location = new System.Drawing.Point(8, 18);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(70, 14);
     this.label1.TabIndex = 2;
     this.label1.Text     = "统计时期:";
     //
     // m_cmdExit
     //
     this.m_cmdExit.BackColor     = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
     this.m_cmdExit.DefaultScheme = true;
     this.m_cmdExit.DialogResult  = System.Windows.Forms.DialogResult.Cancel;
     this.m_cmdExit.Hint          = "";
     this.m_cmdExit.Location      = new System.Drawing.Point(864, 11);
     this.m_cmdExit.Name          = "m_cmdExit";
     this.m_cmdExit.Scheme        = PinkieControls.ButtonXP.Schemes.Blue;
     this.m_cmdExit.Size          = new System.Drawing.Size(80, 32);
     this.m_cmdExit.TabIndex      = 70;
     this.m_cmdExit.Text          = "退出(&ESC)";
     this.m_cmdExit.Click        += new System.EventHandler(this.m_cmdExit_Click);
     //
     // panelFill
     //
     this.panelFill.Controls.Add(this.m_printPreviewControl1);
     this.panelFill.Dock     = System.Windows.Forms.DockStyle.Fill;
     this.panelFill.Location = new System.Drawing.Point(0, 56);
     this.panelFill.Name     = "panelFill";
     this.panelFill.Size     = new System.Drawing.Size(1000, 469);
     this.panelFill.TabIndex = 1;
     //
     // m_printPreviewControl1
     //
     this.m_printPreviewControl1.AutoZoom = false;
     this.m_printPreviewControl1.Dock     = System.Windows.Forms.DockStyle.Fill;
     this.m_printPreviewControl1.Document = this.m_printDocument1;
     this.m_printPreviewControl1.Location = new System.Drawing.Point(0, 0);
     this.m_printPreviewControl1.Name     = "m_printPreviewControl1";
     this.m_printPreviewControl1.Size     = new System.Drawing.Size(1000, 469);
     this.m_printPreviewControl1.TabIndex = 2;
     this.m_printPreviewControl1.Zoom     = 1;
     //
     // m_printDocument1
     //
     this.m_printDocument1.PrintPage  += new System.Drawing.Printing.PrintPageEventHandler(this.m_printDocument1_PrintPage);
     this.m_printDocument1.EndPrint   += new System.Drawing.Printing.PrintEventHandler(this.m_printDocument1_EndPrint);
     this.m_printDocument1.BeginPrint += new System.Drawing.Printing.PrintEventHandler(this.m_printDocument1_BeginPrint);
     //
     // m_printPreviewDialog1
     //
     this.m_printPreviewDialog1.AutoScrollMargin  = new System.Drawing.Size(0, 0);
     this.m_printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
     this.m_printPreviewDialog1.ClientSize        = new System.Drawing.Size(400, 300);
     this.m_printPreviewDialog1.Document          = this.m_printDocument1;
     this.m_printPreviewDialog1.Enabled           = true;
     this.m_printPreviewDialog1.Icon    = ((System.Drawing.Icon)(resources.GetObject("m_printPreviewDialog1.Icon")));
     this.m_printPreviewDialog1.Name    = "m_printPreviewDialog1";
     this.m_printPreviewDialog1.Visible = false;
     //
     // printDialog1
     //
     this.printDialog1.AllowCurrentPage = true;
     this.printDialog1.AllowSelection   = true;
     this.printDialog1.AllowSomePages   = true;
     this.printDialog1.Document         = this.m_printDocument1;
     this.printDialog1.UseEXDialog      = true;
     //
     // frmOutpatientChargeIdetityPrint
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(7, 16);
     this.CancelButton      = this.m_cmdExit;
     this.ClientSize        = new System.Drawing.Size(1000, 525);
     this.Controls.Add(this.panelFill);
     this.Controls.Add(this.panelTop);
     this.Font        = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
     this.Name        = "frmOutpatientChargeIdetityPrint";
     this.Text        = "门诊收费按身份分类统计报表";
     this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
     this.Load       += new System.EventHandler(this.frmOutpatientChargeIdetityPrint_Load);
     this.panelTop.ResumeLayout(false);
     this.panelTop.PerformLayout();
     ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
     this.panelFill.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Beispiel #15
0
 private static Size GetPageSize(PrintDialog printDialog) => new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);
Beispiel #16
0
 public void Print(string name)
 {
     SourceCodePrintDocument printDocument = getPrintDocument(name);
     PrintDialog print = new PrintDialog() {
         Document = printDocument
     };
     if (print.ShowDialog() == DialogResult.OK) {
         printDocument.Print();
     }
 }
        private void mitPrint_Click(object sender, RoutedEventArgs e)
        {
            //this will print the report
            int intCurrentRow = 0;
            int intCounter;
            int intColumns;
            int intNumberOfRecords;


            try
            {
                PrintDialog pdProblemReport = new PrintDialog();

                if (pdProblemReport.ShowDialog().Value)
                {
                    FlowDocument fdProjectReport = new FlowDocument();
                    Thickness    thickness       = new Thickness(50, 50, 50, 50);
                    fdProjectReport.PagePadding = thickness;

                    pdProblemReport.PrintTicket.PageOrientation = System.Printing.PageOrientation.Landscape;

                    //Set Up Table Columns
                    Table ProjectReportTable = new Table();
                    fdProjectReport.Blocks.Add(ProjectReportTable);
                    ProjectReportTable.CellSpacing = 0;
                    intColumns = TheProductivityDataEntryDataSet.dataentry.Columns.Count;
                    fdProjectReport.ColumnWidth           = 10;
                    fdProjectReport.IsColumnWidthFlexible = false;


                    for (int intColumnCounter = 0; intColumnCounter < intColumns; intColumnCounter++)
                    {
                        ProjectReportTable.Columns.Add(new TableColumn());
                    }
                    ProjectReportTable.RowGroups.Add(new TableRowGroup());

                    //Title row
                    ProjectReportTable.RowGroups[0].Rows.Add(new TableRow());
                    TableRow newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow];
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Productivity Data Entry Report"))));
                    newTableRow.Cells[0].FontSize      = 25;
                    newTableRow.Cells[0].FontFamily    = new FontFamily("Times New Roman");
                    newTableRow.Cells[0].ColumnSpan    = intColumns;
                    newTableRow.Cells[0].TextAlignment = TextAlignment.Center;
                    newTableRow.Cells[0].Padding       = new Thickness(0, 0, 0, 10);

                    //Header Row
                    ProjectReportTable.RowGroups[0].Rows.Add(new TableRow());
                    intCurrentRow++;
                    newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow];
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Transaction ID"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("First Name"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Last Name"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Project ID"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Project Name"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Date"))));
                    newTableRow.Cells[0].Padding    = new Thickness(0, 0, 0, 10);
                    newTableRow.Cells[0].ColumnSpan = 1;
                    newTableRow.Cells[1].ColumnSpan = 1;
                    newTableRow.Cells[2].ColumnSpan = 1;
                    newTableRow.Cells[3].ColumnSpan = 1;
                    newTableRow.Cells[4].ColumnSpan = 1;
                    newTableRow.Cells[5].ColumnSpan = 1;


                    //Format Header Row
                    for (intCounter = 0; intCounter < intColumns; intCounter++)
                    {
                        newTableRow.Cells[intCounter].FontSize        = 16;
                        newTableRow.Cells[intCounter].FontFamily      = new FontFamily("Times New Roman");
                        newTableRow.Cells[intCounter].BorderBrush     = Brushes.Black;
                        newTableRow.Cells[intCounter].TextAlignment   = TextAlignment.Center;
                        newTableRow.Cells[intCounter].BorderThickness = new Thickness();
                    }

                    intNumberOfRecords = TheProductivityDataEntryDataSet.dataentry.Rows.Count;

                    //Data, Format Data

                    for (int intReportRowCounter = 0; intReportRowCounter < intNumberOfRecords; intReportRowCounter++)
                    {
                        ProjectReportTable.RowGroups[0].Rows.Add(new TableRow());
                        intCurrentRow++;
                        newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow];
                        for (int intColumnCounter = 0; intColumnCounter < intColumns; intColumnCounter++)
                        {
                            newTableRow.Cells.Add(new TableCell(new Paragraph(new Run(TheProductivityDataEntryDataSet.dataentry[intReportRowCounter][intColumnCounter].ToString()))));

                            newTableRow.Cells[intColumnCounter].FontSize = 12;
                            newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman");
                            newTableRow.Cells[intColumnCounter].BorderBrush     = Brushes.LightSteelBlue;
                            newTableRow.Cells[intColumnCounter].BorderThickness = new Thickness(0, 0, 0, 1);
                            newTableRow.Cells[intColumnCounter].TextAlignment   = TextAlignment.Center;
                            if (intColumnCounter == 5)
                            {
                                newTableRow.Cells[intColumnCounter].ColumnSpan = 2;
                            }
                        }
                    }

                    //Set up page and print
                    fdProjectReport.ColumnWidth = pdProblemReport.PrintableAreaWidth;
                    fdProjectReport.PageHeight  = pdProblemReport.PrintableAreaHeight;
                    fdProjectReport.PageWidth   = pdProblemReport.PrintableAreaWidth;
                    pdProblemReport.PrintDocument(((IDocumentPaginatorSource)fdProjectReport).DocumentPaginator, "Productivity Date Entry Report");
                    intCurrentRow = 0;
                }
            }
            catch (Exception Ex)
            {
                TheMessagesClass.ErrorMessage(Ex.ToString());

                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Productivity Data Entry Reports // Print Button " + Ex.Message);
            }
        }
        private void MenuItem_PrintPreview_Click(object sender, RoutedEventArgs e)
        {
            PrintDocument pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);

            PrintDialog printdlg = new PrintDialog();

            PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
        }
Beispiel #19
0
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TrackForm));
     this.picTrack              = new System.Windows.Forms.PictureBox();
     this.timerClock1           = new System.Windows.Forms.Timer(this.components);
     this.btnStage              = new System.Windows.Forms.Button();
     this.btnReset              = new System.Windows.Forms.Button();
     this.groupControls         = new System.Windows.Forms.GroupBox();
     this.btnPrint              = new System.Windows.Forms.Button();
     this.groupTimeslip         = new System.Windows.Forms.GroupBox();
     this.richTextSlip          = new System.Windows.Forms.RichTextBox();
     this.btnOpen               = new System.Windows.Forms.Button();
     this.btnSave               = new System.Windows.Forms.Button();
     this.printDialog1          = new System.Windows.Forms.PrintDialog();
     this.printDocument         = new System.Drawing.Printing.PrintDocument();
     this.printPreviewDialog    = new System.Windows.Forms.PrintPreviewDialog();
     this.pageSetupDialog       = new System.Windows.Forms.PageSetupDialog();
     this.groupTimeslipControls = new System.Windows.Forms.GroupBox();
     this.groupExport           = new System.Windows.Forms.GroupBox();
     this.btnExportJPEG         = new System.Windows.Forms.Button();
     ((System.ComponentModel.ISupportInitialize)(this.picTrack)).BeginInit();
     this.groupControls.SuspendLayout();
     this.groupTimeslip.SuspendLayout();
     this.groupTimeslipControls.SuspendLayout();
     this.groupExport.SuspendLayout();
     this.SuspendLayout();
     //
     // picTrack
     //
     this.picTrack.Image    = ((System.Drawing.Image)(resources.GetObject("picTrack.Image")));
     this.picTrack.Location = new System.Drawing.Point(0, 0);
     this.picTrack.Name     = "picTrack";
     this.picTrack.Size     = new System.Drawing.Size(588, 115);
     this.picTrack.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
     this.picTrack.TabIndex = 0;
     this.picTrack.TabStop  = false;
     this.picTrack.Visible  = false;
     //
     // timerClock1
     //
     this.timerClock1.Interval = 51;
     this.timerClock1.Tick    += new System.EventHandler(this.timerClock_Tick);
     //
     // btnStage
     //
     this.btnStage.Location = new System.Drawing.Point(12, 23);
     this.btnStage.Name     = "btnStage";
     this.btnStage.Size     = new System.Drawing.Size(156, 29);
     this.btnStage.TabIndex = 1;
     this.btnStage.Text     = "&Stage";
     this.btnStage.Click   += new System.EventHandler(this.btnStage_Click);
     //
     // btnReset
     //
     this.btnReset.Enabled  = false;
     this.btnReset.Location = new System.Drawing.Point(12, 63);
     this.btnReset.Name     = "btnReset";
     this.btnReset.Size     = new System.Drawing.Size(156, 29);
     this.btnReset.TabIndex = 2;
     this.btnReset.Text     = "&Reset";
     this.btnReset.Click   += new System.EventHandler(this.btnReset_Click);
     //
     // groupControls
     //
     this.groupControls.Controls.Add(this.btnReset);
     this.groupControls.Controls.Add(this.btnStage);
     this.groupControls.Location = new System.Drawing.Point(12, 127);
     this.groupControls.Name     = "groupControls";
     this.groupControls.Size     = new System.Drawing.Size(180, 104);
     this.groupControls.TabIndex = 3;
     this.groupControls.TabStop  = false;
     this.groupControls.Text     = "Control";
     //
     // btnPrint
     //
     this.btnPrint.Location = new System.Drawing.Point(12, 104);
     this.btnPrint.Name     = "btnPrint";
     this.btnPrint.Size     = new System.Drawing.Size(156, 29);
     this.btnPrint.TabIndex = 4;
     this.btnPrint.Text     = "&Print";
     this.btnPrint.Click   += new System.EventHandler(this.btnPrint_Click);
     //
     // groupTimeslip
     //
     this.groupTimeslip.Controls.Add(this.richTextSlip);
     this.groupTimeslip.Location = new System.Drawing.Point(204, 127);
     this.groupTimeslip.Name     = "groupTimeslip";
     this.groupTimeslip.Size     = new System.Drawing.Size(378, 335);
     this.groupTimeslip.TabIndex = 4;
     this.groupTimeslip.TabStop  = false;
     //
     // richTextSlip
     //
     this.richTextSlip.BackColor   = System.Drawing.SystemColors.Control;
     this.richTextSlip.BorderStyle = System.Windows.Forms.BorderStyle.None;
     this.richTextSlip.Location    = new System.Drawing.Point(10, 18);
     this.richTextSlip.Name        = "richTextSlip";
     this.richTextSlip.ReadOnly    = true;
     this.richTextSlip.Size        = new System.Drawing.Size(355, 305);
     this.richTextSlip.TabIndex    = 0;
     this.richTextSlip.Text        = "";
     //
     // btnOpen
     //
     this.btnOpen.Location = new System.Drawing.Point(12, 63);
     this.btnOpen.Name     = "btnOpen";
     this.btnOpen.Size     = new System.Drawing.Size(156, 29);
     this.btnOpen.TabIndex = 2;
     this.btnOpen.Text     = "&Open";
     this.btnOpen.Click   += new System.EventHandler(this.btnOpen_Click);
     //
     // btnSave
     //
     this.btnSave.Location = new System.Drawing.Point(12, 23);
     this.btnSave.Name     = "btnSave";
     this.btnSave.Size     = new System.Drawing.Size(156, 29);
     this.btnSave.TabIndex = 1;
     this.btnSave.Text     = "&Save";
     this.btnSave.Click   += new System.EventHandler(this.btnSave_Click);
     //
     // printDialog1
     //
     this.printDialog1.Document = this.printDocument;
     //
     // printDocument1
     //
     this.printDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
     //
     // printPreviewDialog1
     //
     this.printPreviewDialog.AutoScrollMargin  = new System.Drawing.Size(0, 0);
     this.printPreviewDialog.AutoScrollMinSize = new System.Drawing.Size(0, 0);
     this.printPreviewDialog.ClientSize        = new System.Drawing.Size(400, 300);
     this.printPreviewDialog.Document          = this.printDocument;
     this.printPreviewDialog.Enabled           = true;
     this.printPreviewDialog.Icon    = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon")));
     this.printPreviewDialog.Name    = "printPreviewDialog1";
     this.printPreviewDialog.Visible = false;
     //
     // pageSetupDialog1
     //
     this.pageSetupDialog.Document = this.printDocument;
     //
     // groupTimeslipControls
     //
     this.groupTimeslipControls.Controls.Add(this.btnSave);
     this.groupTimeslipControls.Controls.Add(this.btnOpen);
     this.groupTimeslipControls.Controls.Add(this.btnPrint);
     this.groupTimeslipControls.Location = new System.Drawing.Point(12, 242);
     this.groupTimeslipControls.Name     = "groupTimeslipControls";
     this.groupTimeslipControls.Size     = new System.Drawing.Size(180, 145);
     this.groupTimeslipControls.TabIndex = 5;
     this.groupTimeslipControls.TabStop  = false;
     this.groupTimeslipControls.Text     = "Timeslip";
     //
     // groupExport
     //
     this.groupExport.Controls.Add(this.btnExportJPEG);
     this.groupExport.Location = new System.Drawing.Point(12, 398);
     this.groupExport.Name     = "groupExport";
     this.groupExport.Size     = new System.Drawing.Size(180, 64);
     this.groupExport.TabIndex = 6;
     this.groupExport.TabStop  = false;
     this.groupExport.Text     = "Export";
     //
     // btnExportJPEG
     //
     this.btnExportJPEG.Location = new System.Drawing.Point(12, 23);
     this.btnExportJPEG.Name     = "btnExportJPEG";
     this.btnExportJPEG.Size     = new System.Drawing.Size(156, 29);
     this.btnExportJPEG.TabIndex = 6;
     this.btnExportJPEG.Text     = "&JPEG";
     this.btnExportJPEG.Click   += new System.EventHandler(this.btnExportJPEG_Click);
     //
     // TrackForm
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
     this.ClientSize        = new System.Drawing.Size(588, 471);
     this.ControlBox        = false;
     this.Controls.Add(this.groupExport);
     this.Controls.Add(this.groupTimeslipControls);
     this.Controls.Add(this.groupTimeslip);
     this.Controls.Add(this.groupControls);
     this.Controls.Add(this.picTrack);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.Name            = "TrackForm";
     this.Text            = "Race Track Analysis";
     this.Activated      += new System.EventHandler(this.TrackForm_Activated);
     this.Paint          += new System.Windows.Forms.PaintEventHandler(this.TrackForm_Paint);
     this.Resize         += new System.EventHandler(this.TrackForm_Resize);
     ((System.ComponentModel.ISupportInitialize)(this.picTrack)).EndInit();
     this.groupControls.ResumeLayout(false);
     this.groupTimeslip.ResumeLayout(false);
     this.groupTimeslipControls.ResumeLayout(false);
     this.groupExport.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Beispiel #20
0
    void Print(object sender, EventArgs args)
    {
        PrintJob pj = new PrintJob();
        PrintDialog dialog = new PrintDialog (pj, "Print diagram");
        int response = dialog.Run();

        if (response == (int) ResponseType.Cancel ||
            response == (int) ResponseType.DeleteEvent) {
            dialog.Destroy();
            return;
        }

        PrintContext ctx = pj.Context;
        Gnome.Print.Beginpage (ctx, "demo");
        Dia.Global.ExportPrint (pj, canvas);
        Gnome.Print.Showpage (ctx);
        pj.Close();

        switch (response) {
        case (int)PrintButtons.Print:
            if (pj.Config.Get ("Settings.Transport.Backend") == "file")
                pj.PrintToFile (pj.Config.Get ("Settings.Transport.Backend.FileName"));
            pj.Print();
            break;
        case (int) PrintButtons.Preview:
            new PrintJobPreview (pj, "Diagram").Show();
            break;
        }
        dialog.Destroy();
    }
Beispiel #21
0
        private void OnPrintPreview(object sender, ExecutedRoutedEventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();

            printDialog.PageRangeSelection   = PageRangeSelection.AllPages;
            printDialog.UserPageRangeEnabled = true;
            bool?dialogResult = printDialog.ShowDialog();

            if (dialogResult != null && dialogResult.Value == false)
            {
                return;
            }

            FlowDocument printSource = this.CreateFlowDocumentForEditor();

            // Save all the existing settings.
            double    pageHeight  = printSource.PageHeight;
            double    pageWidth   = printSource.PageWidth;
            Thickness pagePadding = printSource.PagePadding;
            double    columnGap   = printSource.ColumnGap;
            double    columnWidth = printSource.ColumnWidth;

            // Make the FlowDocument page match the printed page.
            printSource.PageHeight  = printDialog.PrintableAreaHeight;
            printSource.PageWidth   = printDialog.PrintableAreaWidth;
            printSource.PagePadding = new Thickness(20);
            printSource.ColumnGap   = Double.NaN;
            printSource.ColumnWidth = printDialog.PrintableAreaWidth;

            Size pageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);

            MemoryStream xpsStream        = new MemoryStream();
            Package      package          = Package.Open(xpsStream, FileMode.Create, FileAccess.ReadWrite);
            string       packageUriString = "memorystream://data.xps";

            PackageStore.AddPackage(new Uri(packageUriString), package);

            XpsDocument       xpsDocument = new XpsDocument(package, CompressionOption.Normal, packageUriString);
            XpsDocumentWriter writer      = XpsDocument.CreateXpsDocumentWriter(xpsDocument);

            DocumentPaginator paginator = ((IDocumentPaginatorSource)printSource).DocumentPaginator;

            paginator.PageSize = pageSize;
            paginator.ComputePageCount();

            writer.Write(paginator);

            // Reapply the old settings.
            printSource.PageHeight  = pageHeight;
            printSource.PageWidth   = pageWidth;
            printSource.PagePadding = pagePadding;
            printSource.ColumnGap   = columnGap;
            printSource.ColumnWidth = columnWidth;

            PrintPreviewWindow printPreview = new PrintPreviewWindow();

            printPreview.Width  = this.ActualWidth;
            printPreview.Height = this.ActualHeight;
            printPreview.Owner  = Application.Current.MainWindow;

            printPreview.LoadDocument(xpsDocument, package, packageUriString);

            printPreview.Show();
        }
        private void _Mtd_ImprimirFacturas()
        {
            try
            {
                bool        _Bool_ClickOk      = false;
                string      _Str_PrefijoCorrel = CLASES._Cls_Varios_Metodos._Mtd_ObtenerPrefijoCorrel(Frm_Padre._Str_Comp);
                PrintDialog _Print             = new PrintDialog();
                string      _Str_Sql           = "";
                string[]    _P_Str_Facturas_   = new string[0];
                DataSet     _Ds_DataSet        = new DataSet();
                DataTable   _Dta_Tabla         = new DataTable("Relacion");
                DataColumn  _Dta_Columna;

                _Bool_ClickOk = false;
                if (_rutinasImpresion._Mtd_EstaHabilitadoConfiguracionImpresion())
                {
                    PrinterSettings _ObjetoImpresion = null;
                    Clases._Cls_RutinasImpresion._G_TiposDocumento _Tipo = Clases._Cls_RutinasImpresion._G_TiposDocumento.Factura;
                    //Cargo el Objeto que voy a setear enl dialogos segun compañia
                    _ObjetoImpresion       = _rutinasImpresion._Mtd_ObjetoImpresion(_Tipo, Frm_Padre._Str_Comp);
                    _Print.PrinterSettings = _ObjetoImpresion;
                    _Bool_ClickOk          = true;
                }
                else
                {
                    if (_Print.ShowDialog() == DialogResult.OK)
                    {
                        _Bool_ClickOk = true;
                    }
                }

                Cursor = Cursors.WaitCursor;
                if (_Bool_ClickOk)
                {
                    foreach (DataGridViewRow _Dg_Row in _Dg_Grid.Rows)
                    {
                        if (Convert.ToString(_Dg_Row.Cells["Imprimir"].Value).Trim() == "1")
                        {
                            //---------------------------------------------------------
                            if (_LstBox_DocPrint.Items.Count > 0)
                            {
                                if (_LstBox_DocPrint.FindStringExact(Convert.ToString(_Dg_Row.Cells["Documento"].Value.ToString())) != -1)
                                {
                                    _P_Str_Facturas_ = (string[])CLASES._Cls_Varios_Metodos._Mtd_ArrayRedim(_P_Str_Facturas_, _P_Str_Facturas_.Length + 1);
                                    _P_Str_Facturas_[_P_Str_Facturas_.Length - 1] = Convert.ToString(_Dg_Row.Cells["Documento"].Value.ToString());
                                }
                            }
                            else
                            {
                                _P_Str_Facturas_ = (string[])CLASES._Cls_Varios_Metodos._Mtd_ArrayRedim(_P_Str_Facturas_, _P_Str_Facturas_.Length + 1);
                                _P_Str_Facturas_[_P_Str_Facturas_.Length - 1] = Convert.ToString(_Dg_Row.Cells["Documento"].Value.ToString());
                            }
                            //---------------------------------------------------------
                        }
                    }
                    //-------------------------
                    _LstBox_DocPrint.Items.Clear();
                    //-------------------------
                    Cursor                  = Cursors.WaitCursor;
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "ccompany";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "cfactura";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "ccliente";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "c_rif";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "c_nomb_comer";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "cproducto";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cempaques";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cunidades";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cdesc1";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cdesc2";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "c_monto_si_bs";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "c_impuesto_bs";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "c_impuesto_fact";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "cname";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "c_razsocial_1";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "c_direcc_fiscal";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "c_telefono";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "nombredirecc";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "c_fecha_factura";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cdias";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cporcdes";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "c_montotot_si_bs";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cimpuestofact";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "ctotalfact";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "ctotalcondesc";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cdescuentofact";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cimpdesc";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "cvendedor";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "produc_descrip";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "produc_descrip_2";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "ccostoneto_u1_bs";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "cpedido";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "c_dia_ruta";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "calicuota";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cexento";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cdescexento";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cdescbaseimp";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cdesimpbaseimp";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cmontofactsinexento";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cllevaobs";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cdescpp";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cdescppmonto";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cmontobgrabada";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cmontobexenta";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cmontobgrabadadescpp";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.Double");
                    _Dta_Columna.ColumnName = "cprecioventamax";
                    _Dta_Columna.ReadOnly   = true;
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "cpatente";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "cnamemunicipiopatente";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    _Dta_Columna            = new DataColumn();
                    _Dta_Columna.DataType   = System.Type.GetType("System.String");
                    _Dta_Columna.ColumnName = "cobsfactura";
                    _Dta_Tabla.Columns.Add(_Dta_Columna);
                    foreach (string _Str_String in _P_Str_Facturas_)
                    {
                        _Str_Sql = "SELECT ccompany, '" + _Str_PrefijoCorrel + "'+CONVERT(VARCHAR,cfactura), ccliente, c_rif, c_nomb_comer, cproducto, cempaques, cunidades, cdesc1, cdesc2, c_monto_si_bs, c_impuesto_bs, " +
                                   "c_impuesto_fact, cname, c_razsocial_1, c_direcc_fiscal, c_telefono, nombredirecc, c_fecha_factura, cdias, cporcdes, c_montotot_si_bs, cimpuestofact, " +
                                   "ctotalfact, ctotalcondesc, cdescuentofact, cimpdesc, cvendedor, produc_descrip, produc_descrip_2, ccostoneto_u1_bs, cpedido, c_dia_ruta, calicuota, cexento, cdescexento, cdescbaseimp, cdesimpbaseimp, cmontofactsinexento,cllevaobs,ISNULL(cdescpp,0),ISNULL(cdescppmonto,0),ISNULL(cmontobgrabada,0),ISNULL(cmontobexenta,0),ISNULL(cmontobgrabadadescpp,0), ISNULL(cprecioventamax,0),RTRIM(cpatente),RTRIM(cnamemunicipiopatente),RTRIM(cobsfactura) FROM [VST_FACTURAEMISIONV2] where cgroupcomp='" + Frm_Padre._Str_GroupComp + "' and ccompanypre='" + Frm_Padre._Str_Comp + "' and ccompany='" + Frm_Padre._Str_Comp + "' and cfactura ='" + _Str_String + "'";
                        _Ds_DataSet = Program._MyClsCnn._mtd_conexion._Mtd_RetornarDataset(_Str_Sql);
                        foreach (DataRow _Dtw_Item in _Ds_DataSet.Tables[0].Rows)
                        {
                            _Dta_Tabla.Rows.Add(new object[] { _Dtw_Item[0].ToString().TrimEnd(), _Dtw_Item[1].ToString().TrimEnd(), _Dtw_Item[2].ToString().TrimEnd(), _Dtw_Item[3].ToString().TrimEnd(), _Dtw_Item[4].ToString().TrimEnd(), _Dtw_Item[5].ToString().TrimEnd(), _Dtw_Item[6].ToString().TrimEnd(), _Dtw_Item[7].ToString().TrimEnd(), _Dtw_Item[8].ToString().TrimEnd(), _Dtw_Item[9].ToString().TrimEnd(), _Dtw_Item[10].ToString().TrimEnd(), _Dtw_Item[11].ToString().TrimEnd(), _Dtw_Item[12].ToString().TrimEnd(), _Dtw_Item[13].ToString().TrimEnd(), _Dtw_Item[14].ToString().TrimEnd(), _Dtw_Item[15].ToString().TrimEnd(), _Dtw_Item[16].ToString().TrimEnd(), _Dtw_Item[17].ToString().TrimEnd(), _Dtw_Item[18].ToString().TrimEnd(), _Dtw_Item[19].ToString().TrimEnd(), _Dtw_Item[20].ToString().TrimEnd(), _Dtw_Item[21].ToString().TrimEnd(), _Dtw_Item[22].ToString().TrimEnd(), _Dtw_Item[23].ToString().TrimEnd(), _Dtw_Item[24].ToString().TrimEnd(), _Dtw_Item[25].ToString().TrimEnd(), _Dtw_Item[26].ToString().TrimEnd(), _Dtw_Item[27].ToString().TrimEnd(), _Dtw_Item[28].ToString().TrimEnd(), _Dtw_Item[29].ToString().TrimEnd(), _Dtw_Item[30].ToString().TrimEnd(), _Dtw_Item[31].ToString().TrimEnd(), _Dtw_Item[32].ToString().TrimEnd(), _Dtw_Item[33].ToString().TrimEnd(), _Dtw_Item[34].ToString().TrimEnd(), _Dtw_Item[35].ToString().TrimEnd(), _Dtw_Item[36].ToString().TrimEnd(), _Dtw_Item[37].ToString().TrimEnd(), _Dtw_Item[38].ToString().TrimEnd(), _Dtw_Item[39].ToString().TrimEnd(), _Dtw_Item[40].ToString().TrimEnd(), _Dtw_Item[41].ToString().TrimEnd(), _Dtw_Item[42].ToString().TrimEnd(), _Dtw_Item[43].ToString().TrimEnd(), _Dtw_Item[44].ToString().TrimEnd(), _Dtw_Item[45].ToString().TrimEnd(), _Dtw_Item[46].ToString().TrimEnd(), _Dtw_Item[47].ToString().TrimEnd(), _Dtw_Item[48].ToString().TrimEnd() });
                        }
                    }
                    if (_Dta_Tabla.Rows.Count > 0)
                    {
                        //PQC MCY (Impresora sin margen arriba) -- Ignacio - 19-06-2013 --
                        //PQC PZO (Impresora sin margen arriba) -- Angel - 25-11-2013 --
                        //if ((T3.CLASES._Cls_Conexion._Int_Sucursal == 2) || (T3.CLASES._Cls_Conexion._Int_Sucursal == 5))
                        //{
                        REPORTESS _Frm_Reporte = new REPORTESS("T3.Report.rFacturaEmisionMCY", _Dta_Tabla, _Print, true, "Section2", "", "", "");
                        //}
                        //else
                        //{
                        //    REPORTESS _Frm_Reporte = new REPORTESS("T3.Report.rFacturaEmision", _Dta_Tabla, _Print, true, "Section2", "", "", "");
                        //}
                    }
                    Cursor = Cursors.Default;
                    if (MessageBox.Show("¿La impresión fue realizada correctamente?", "Información", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        _Dg_Grid.Columns["Imprimir"].ReadOnly = true;
                        string _Str_Correlativo = _Mtd_Correlativo();
                        foreach (DataGridViewRow _Dg_RowTem in _Dg_Grid.Rows)
                        {
                            if (Convert.ToString(_Dg_RowTem.Cells["Imprimir"].Value).Trim() == "1")
                            {
                                _Str_Sql = "INSERT INTO TREIMPREFACT (cgroupcomp,ccompany,cidreimprefact,cfactura,cfechahora,cusuario) VALUES ('" + Frm_Padre._Str_GroupComp + "','" + Frm_Padre._Str_Comp + "','" + _Str_Correlativo + "','" + Convert.ToString(_Dg_RowTem.Cells["Documento"].Value).Trim() + "','" + _Cls_Formato._Mtd_fecha(CLASES._Cls_Varios_Metodos._Mtd_SQLGetDate()) + "','" + Frm_Padre._Str_Use + "')";
                                Program._MyClsCnn._mtd_conexion._Mtd_EjecutarSentencia(_Str_Sql);
                            }
                        }
                        _Bt_Imprimir.Enabled = false;
                        _Pnl_Numero.Visible  = true;
                    }
                    else
                    {
                        _Pnl_ReImpresion.Visible = true;
                    }
                }
            }
            catch (Exception _Ex)
            {
                MessageBox.Show(_Ex.Message);
                Cursor = Cursors.Default;
            }
        }
 public PrintBasicPatientInformationViewModel()
 {
     PrintCommand = new RelayCommand(Print, CanPrint);
     PrintDialog  = new PrintDialog();
 }
Beispiel #24
0
 InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ParamEnumSnoop));
     this.m_tvObjs                  = new System.Windows.Forms.TreeView();
     this.m_cntxMenuObjId           = new System.Windows.Forms.ContextMenu();
     this.m_mnuItemCopy             = new System.Windows.Forms.MenuItem();
     this.m_mnuItemBrowseReflection = new System.Windows.Forms.MenuItem();
     this.m_bnOK                   = new System.Windows.Forms.Button();
     this.m_lvData                 = new System.Windows.Forms.ListView();
     this.m_lvCol_label            = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     this.m_lvCol_value            = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     this.listViewContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
     this.copyToolStripMenuItem    = new System.Windows.Forms.ToolStripMenuItem();
     this.toolStrip1               = new System.Windows.Forms.ToolStrip();
     this.toolStripButton1         = new System.Windows.Forms.ToolStripButton();
     this.toolStripButton2         = new System.Windows.Forms.ToolStripButton();
     this.toolStripButton3         = new System.Windows.Forms.ToolStripButton();
     this.m_printDialog            = new System.Windows.Forms.PrintDialog();
     this.m_printDocument          = new System.Drawing.Printing.PrintDocument();
     this.m_printPreviewDialog     = new System.Windows.Forms.PrintPreviewDialog();
     this.listViewContextMenuStrip.SuspendLayout();
     this.toolStrip1.SuspendLayout();
     this.SuspendLayout();
     //
     // m_tvObjs
     //
     this.m_tvObjs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                  | System.Windows.Forms.AnchorStyles.Left)));
     this.m_tvObjs.ContextMenu     = this.m_cntxMenuObjId;
     this.m_tvObjs.HideSelection   = false;
     this.m_tvObjs.Location        = new System.Drawing.Point(11, 38);
     this.m_tvObjs.Name            = "m_tvObjs";
     this.m_tvObjs.Size            = new System.Drawing.Size(248, 415);
     this.m_tvObjs.TabIndex        = 0;
     this.m_tvObjs.AfterSelect    += new System.Windows.Forms.TreeViewEventHandler(this.TreeNodeSelected);
     this.m_tvObjs.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.TreeNodeSelected);
     //
     // m_cntxMenuObjId
     //
     this.m_cntxMenuObjId.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.m_mnuItemCopy,
         this.m_mnuItemBrowseReflection
     });
     //
     // m_mnuItemCopy
     //
     this.m_mnuItemCopy.Index  = 0;
     this.m_mnuItemCopy.Text   = "Copy";
     this.m_mnuItemCopy.Click += new System.EventHandler(this.ContextMenuClick_Copy);
     //
     // m_mnuItemBrowseReflection
     //
     this.m_mnuItemBrowseReflection.Index  = 1;
     this.m_mnuItemBrowseReflection.Text   = "Browse Using Reflection...";
     this.m_mnuItemBrowseReflection.Click += new System.EventHandler(this.ContextMenuClick_BrowseReflection);
     //
     // m_bnOK
     //
     this.m_bnOK.Anchor       = System.Windows.Forms.AnchorStyles.Bottom;
     this.m_bnOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.m_bnOK.FlatStyle    = System.Windows.Forms.FlatStyle.System;
     this.m_bnOK.Location     = new System.Drawing.Point(364, 459);
     this.m_bnOK.Name         = "m_bnOK";
     this.m_bnOK.Size         = new System.Drawing.Size(75, 23);
     this.m_bnOK.TabIndex     = 2;
     this.m_bnOK.Text         = "OK";
     //
     // m_lvData
     //
     this.m_lvData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                   | System.Windows.Forms.AnchorStyles.Left)
                                                                  | System.Windows.Forms.AnchorStyles.Right)));
     this.m_lvData.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
         this.m_lvCol_label,
         this.m_lvCol_value
     });
     this.m_lvData.ContextMenuStrip = this.listViewContextMenuStrip;
     this.m_lvData.FullRowSelect    = true;
     this.m_lvData.GridLines        = true;
     this.m_lvData.Location         = new System.Drawing.Point(284, 38);
     this.m_lvData.Name             = "m_lvData";
     this.m_lvData.Size             = new System.Drawing.Size(504, 415);
     this.m_lvData.TabIndex         = 3;
     this.m_lvData.UseCompatibleStateImageBehavior = false;
     this.m_lvData.View         = System.Windows.Forms.View.Details;
     this.m_lvData.Click       += new System.EventHandler(this.DataItemSelected);
     this.m_lvData.DoubleClick += new System.EventHandler(this.DataItemSelected);
     //
     // m_lvCol_label
     //
     this.m_lvCol_label.Text  = "Field";
     this.m_lvCol_label.Width = 200;
     //
     // m_lvCol_value
     //
     this.m_lvCol_value.Text  = "Value";
     this.m_lvCol_value.Width = 300;
     //
     // listViewContextMenuStrip
     //
     this.listViewContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.copyToolStripMenuItem
     });
     this.listViewContextMenuStrip.Name = "listViewContextMenuStrip";
     this.listViewContextMenuStrip.Size = new System.Drawing.Size(103, 26);
     //
     // copyToolStripMenuItem
     //
     this.copyToolStripMenuItem.Image  = global::RevitLookup.Properties.Resources.Copy;
     this.copyToolStripMenuItem.Name   = "copyToolStripMenuItem";
     this.copyToolStripMenuItem.Size   = new System.Drawing.Size(102, 22);
     this.copyToolStripMenuItem.Text   = "Copy";
     this.copyToolStripMenuItem.Click += new System.EventHandler(this.CopyToolStripMenuItem_Click);
     //
     // toolStrip1
     //
     this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.toolStripButton1,
         this.toolStripButton2,
         this.toolStripButton3
     });
     this.toolStrip1.Location = new System.Drawing.Point(0, 0);
     this.toolStrip1.Name     = "toolStrip1";
     this.toolStrip1.Size     = new System.Drawing.Size(800, 25);
     this.toolStrip1.TabIndex = 5;
     this.toolStrip1.Text     = "toolStrip1";
     //
     // toolStripButton1
     //
     this.toolStripButton1.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton1.Image                 = global::RevitLookup.Properties.Resources.Print;
     this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton1.Name   = "toolStripButton1";
     this.toolStripButton1.Size   = new System.Drawing.Size(23, 22);
     this.toolStripButton1.Text   = "Print";
     this.toolStripButton1.Click += new System.EventHandler(this.PrintMenuItem_Click);
     //
     // toolStripButton2
     //
     this.toolStripButton2.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton2.Image                 = global::RevitLookup.Properties.Resources.Preview;
     this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton2.Name   = "toolStripButton2";
     this.toolStripButton2.Size   = new System.Drawing.Size(23, 22);
     this.toolStripButton2.Text   = "Print Preview";
     this.toolStripButton2.Click += new System.EventHandler(this.PrintPreviewMenuItem_Click);
     //
     // toolStripButton3
     //
     this.toolStripButton3.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton3.Image                 = global::RevitLookup.Properties.Resources.Copy;
     this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton3.Name   = "toolStripButton3";
     this.toolStripButton3.Size   = new System.Drawing.Size(23, 22);
     this.toolStripButton3.Text   = "Copy To Clipboard";
     this.toolStripButton3.Click += new System.EventHandler(this.ContextMenuClick_Copy);
     //
     // m_printDialog
     //
     this.m_printDialog.Document    = this.m_printDocument;
     this.m_printDialog.UseEXDialog = true;
     //
     // m_printDocument
     //
     this.m_printDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.PrintDocument_PrintPage);
     //
     // m_printPreviewDialog
     //
     this.m_printPreviewDialog.AutoScrollMargin  = new System.Drawing.Size(0, 0);
     this.m_printPreviewDialog.AutoScrollMinSize = new System.Drawing.Size(0, 0);
     this.m_printPreviewDialog.ClientSize        = new System.Drawing.Size(400, 300);
     this.m_printPreviewDialog.Document          = this.m_printDocument;
     this.m_printPreviewDialog.Enabled           = true;
     this.m_printPreviewDialog.Icon    = ((System.Drawing.Icon)(resources.GetObject("m_printPreviewDialog.Icon")));
     this.m_printPreviewDialog.Name    = "m_printPreviewDialog";
     this.m_printPreviewDialog.Visible = false;
     //
     // ParamEnumSnoop
     //
     this.AcceptButton      = this.m_bnOK;
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.CancelButton      = this.m_bnOK;
     this.ClientSize        = new System.Drawing.Size(800, 489);
     this.Controls.Add(this.toolStrip1);
     this.Controls.Add(this.m_bnOK);
     this.Controls.Add(this.m_tvObjs);
     this.Controls.Add(this.m_lvData);
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MaximizeBox   = false;
     this.MinimizeBox   = false;
     this.MinimumSize   = new System.Drawing.Size(650, 200);
     this.Name          = "ParamEnumSnoop";
     this.ShowInTaskbar = false;
     this.Text          = "Snoop Built-In Parameters";
     this.listViewContextMenuStrip.ResumeLayout(false);
     this.toolStrip1.ResumeLayout(false);
     this.toolStrip1.PerformLayout();
     this.ResumeLayout(false);
     this.PerformLayout();
 }
Beispiel #25
0
        private void bCobrar_Click(object sender, EventArgs e)
        {
            if (GRD.RowCount == 0)
            {
                MessageBox.Show("Esta Factura no tene articulos para Cobrar", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return;
            }
            vCobro = 0;
            FinalCompra form = new FinalCompra();

            form.vForm = this.Name;
            form.Facturacion(Convert.ToDecimal(TotalNeto.Value));
            form.ShowDialog();

            if (vCobro == 1)
            {
                string sqlString = "";

                sqlString  = "Set nocount on; ";
                sqlString += "Declare @FacturaID int;  set @Facturaid = " + (vFacturaID == 0 ? 0 : vFacturaID);



                foreach (DataRow vRow in dtFactura.Rows)
                {
                    sqlString += " Exec [FACTURA_M] " + vOpt + C.QII + "@FacturaID" + C.QII + vClienteID + C.QIS + Fecha.Value.ToString().Replace("a.m.", "AM").Replace("p.m.", "PM") + C.QSI +
                                 TipodeComprobanteID.SelectedValue + C.QII + C.vUserID + C.QII + vRow["FacturaDetalleID"].ToString() + C.QII + vRow["ArticuloID"].ToString() + C.QII +
                                 vRow["ARTICULOPRECIOID"].ToString() + C.QII + vRow["Cantidad"].ToString() + C.QII + vRow["Descuento"].ToString() + C.QII + vRow["ITBISID"].ToString() + C.QII +
                                 C.vSucursalID + ", @FacturaID output ";
                }

                foreach (DataRow vRow in dtDetallepago.Rows)
                {
                    sqlString += "  Exec [COBRAR_FACTURA_M] " + vOpt + C.QII + "@FacturaID" + C.QII + vRow["TipoFormaPagoID"].ToString() + C.QIS + vRow["NoFormapago"].ToString() + C.QSI +
                                 vRow["Monto"].ToString() + C.QII + (vRow["Reference"].ToString().Length == 0?"NULL": vRow["Reference"].ToString()) + C.QII + vRow["TipodeTransaccion"].ToString() + C.QII +
                                 C.vUserID;
                }



                dtFactura = C.SQL(sqlString + " Select R= @FacturaID");



                if (vImprimir == 1)
                {
                    ReportDocument report = new ReportDocument();

                    DataTable dtReport = new DataTable();

                    dtReport = C.SQL("[FACTURA_T] " + dtFactura.Rows[0][0].ToString());

                    report.Load(Application.StartupPath + "\\Reports\\FacturaMatricial.rpt");

                    report.SetDatabaseLogon("", "");
                    report.SetDataSource(dtReport);

                    PrintDialog pd = new PrintDialog();


                    report.PrintOptions.PrinterName = pd.PrinterSettings.PrinterName.ToString();
                    report.PrintToPrinter(1, true, 0, 0);
                }
                NewFactura();
            }
            else if (vCobro == 0)
            {
                //Cancelado el cobro
            }
        }
Beispiel #26
0
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string        logConfigPath = AppDomain.CurrentDomain.BaseDirectory + "ClientConfig\\通用票据净重模版.xml";
            XmlSerializer configSer     = new XmlSerializer(typeof(Bill));
            StreamReader  sr            = new StreamReader(File.OpenRead(logConfigPath));
            Bill          bill          = (Bill)configSer.Deserialize(sr);

            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("Title", "计量单");
            data.Add("operaname", "物资调拨");
            data.Add("matchid", "80111111");
            data.Add("carno", "陕A12345");
            data.Add("planid", "1111111");

            data.Add("taskcode", "222222");
            data.Add("materialName", "304不锈钢");
            data.Add("ship", "");
            data.Add("sourcename", "虎豹钢厂");
            data.Add("targetname", "853库");

            data.Add("grossweigh", "1号衡器");
            data.Add("grosstime", "051010170800");
            data.Add("gross", "100吨");

            data.Add("tareweigh", "2号衡器");
            data.Add("taretime", "051010170800");
            data.Add("tare", "10吨");

            data.Add("deduction", "0.1吨");

            data.Add("suttleweigh", "3号衡器");
            data.Add("suttletime", "051010170800");
            data.Add("suttle", "7吨");

            data.Add("usermemo", "兆工");
            data.Add("printtime", "051010170800");
            data.Add("printweigh", "7吨");
            data.Add("printset", "净重");
            data.Add("printcount", "1");

            PrintDialog dialog        = new PrintDialog();
            var         pageMediaSize = LocalPrintServer.GetDefaultPrintQueue()

                                        .GetPrintCapabilities()

                                        .PageMediaSizeCapability

                                        .FirstOrDefault(x => x.PageMediaSizeName == PageMediaSizeName.ISOA3);


            //if (pageMediaSize != null)
            //{
            //    pageSize = new Size((double)pageMediaSize.Width, (double)pageMediaSize.Height);
            //}
            DataPaginator dp = new DataPaginator(bill, new Typeface("SimSun"), 12, 96 * 0.35, new Size((double)pageMediaSize.Width, (double)pageMediaSize.Height), data);

            if (dialog.ShowDialog() == true)
            {
                dialog.PrintDocument(dp, "Test Page");
            }
            string ss = "";
        }
        ///<summary>The only instance of this command.</summary>
        ///<param name="doc" RhinoDoc></param>
        ///<param name="mode" Run mode></param>
        ///<returns>returns sucess if doc is successfully created </returns>
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            RhinoApp.RunScript("Save", true); //save file before printing
            String patternFound;

            patternFound = extractToolHit(doc);         //get the pattern

            if (patternFound.Contains("Round Hole 60")) //check if pattern is a round hole 60
            {
                //set the location to round hole 60 pattern
                toolHitLocation = "W:\\Orders Current\\nOOL PDF's\\ROUND HOLE CLUSTERS\\RH60 CLUSTERS";
                //Trim the pattern, so that it only reads the tool hit size
                patternFound = patternFound.Split(new string[] { "Round Hole " }, StringSplitOptions.None)[1];
                patternFound = "RH" + patternFound;
            }

            if (patternFound.Contains("Round Hole 90")) //check if pattern is a round hole 90
            {
                //set the location to round hole 60 pattern
                toolHitLocation = "W:\\Orders Current\\nOOL PDF's\\ROUND HOLE CLUSTERS\\RH90 CLUSTERS";
                //Trim the pattern, so that it only reads the tool hit size
                patternFound = patternFound.Split(new string[] { "Round Hole " }, StringSplitOptions.None)[1];
                patternFound = "RH" + patternFound;
            }

            if (patternFound.Contains("Round Hole 45")) //check if pattern is a round hole 45
            {
                //set the location to round hole 60 pattern
                toolHitLocation = "W:\\Orders Current\\nOOL PDF's\\ROUND HOLE CLUSTERS\\RH45 CLUSTERS";
                //Trim the pattern, so that it only reads the tool hit size
                patternFound = patternFound.Split(new string[] { "Round Hole " }, StringSplitOptions.None)[1];
                patternFound = "RH" + patternFound;
            }

            toolHitPdfLocation = findToolHitPdf(patternFound, toolHitLocation);
            if (toolHitPdfLocation.Equals("Pattern not found"))
            {
                MessageBoxes.Messages.showFileNotFoundForPattern(patternFound);
                return(Result.Failure);
            }


            string fileName = Path.GetFileNameWithoutExtension(doc.Name);

            String[] nameSplit = fileName.Split(new string[] { "_" }, StringSplitOptions.None);

            //Add Nesting part to the file Name
            fileName = nameSplit[0] + "_" + nameSplit[1] + "_Nesting_" + nameSplit[2] + nameSplit[3] + "_" + nameSplit[4];

            System.Windows.Forms.PrintDialog dlg = new PrintDialog();

            if (dlg.PrinterSettings.IsValid == false)
            {
                Messages.showBullzipNotInstalled();
            }
            else
            {
                // If Page Views is 0
                if (doc.Views.GetPageViews().Count() != 0)
                {
                    try
                    {
                        tempPdfPath = Path.GetDirectoryName(doc.Path) + @"\" + "temp" + ".pdf"; //create a temporary pdf with panels
                        oriPdfPath  = Path.GetDirectoryName(doc.Path) + @"\" + fileName + ".pdf";
                        //set the tool hit layer and cluster sample layer to invisible
                        RhinoUtilities.setLayerVisibility("Tool Hit", false);
                        RhinoUtilities.setLayerVisibility("CLUSTER SAMPLE", false);
                        PdfSettings pdfSettings = new PdfSettings();
                        pdfSettings.SetValue("Output", tempPdfPath);
                        pdfSettings.SetValue("ShowPDF", "no");
                        pdfSettings.SetValue("ShowSettings", "never");
                        pdfSettings.SetValue("ShowSaveAS", "never");
                        pdfSettings.SetValue("ShowProgress", "yes");
                        pdfSettings.SetValue("ShowProgressFinished", "no");
                        pdfSettings.SetValue("ConfirmOverwrite", "no");
                        pdfSettings.WriteSettings(PdfSettingsFileType.RunOnce);

                        string command = string.Format("-_Print _Setup _Destination _Printer \"Bullzip PDF Printer\" _PageSize 297.000 210.00 _OutputType=Vector _Enter _View _AllLayout _Enter _Enter _Go");
                        RhinoApp.RunScript(command, true);

                        string[] pdfs = new String[2]; //create a string array to hold the locations of the pdf with panel and agreement form pdf.
                        pdfs[0] = tempPdfPath;
                        pdfs[1] = toolHitPdfLocation;

                        RhinoUtilities.combinePDF(oriPdfPath, pdfs, 0, 1, "Drawings Second"); //pass the array and the target location to save the final pdf
                    }
                    catch (Exception ex)
                    {
                        System.Windows.Forms.MessageBox.Show("Error printing PDF document." + ex.Message);
                    }
                }
            }
            return(Result.Success);
        }
Beispiel #28
0
        //public static void PrintPreview(Window owner, object data,bool IsSinglePage = false)
        //{

        //    using (MemoryStream xpsStream = new MemoryStream())
        //    {

        //        using (Package package = Package.Open(xpsStream, FileMode.Create, FileAccess.ReadWrite))
        //        {

        //            string packageUriString = "memorystream://data.xps";

        //            Uri packageUri = new Uri(packageUriString);


        //            if (PackageStore.GetPackage(packageUri) != null)
        //            {
        //                PackageStore.RemovePackage(packageUri);
        //            }
        //            PackageStore.AddPackage(packageUri, package);



        //            XpsDocument xpsDocument = new XpsDocument(package, CompressionOption.NotCompressed, packageUriString);

        //            XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument);

        //            // Form visual = new Form();



        //            // PrintTicket printTicket = new PrintTicket();

        //            //  printTicket.PageMediaSize = A4PaperSize;
        //            // var d = PrintOnMultiPage(data, true);
        //            //((IDocumentPaginatorSource)data).DocumentPaginator
        //            if (!IsSinglePage)
        //                writer.Write(PrintOnMultiPage(data, true));
        //            else
        //                writer.Write(Print((Visual)data,true));

        //            FixedDocumentSequence document = xpsDocument.GetFixedDocumentSequence();

        //            xpsDocument.Close();



        //            PrintPreviewWindow printPreviewWnd = new PrintPreviewWindow(document);

        //            printPreviewWnd.Owner = owner;

        //            printPreviewWnd.ShowDialog();

        //            PackageStore.RemovePackage(packageUri);

        //        }

        //    }

        //}



        public static Task <Visual> Print(Visual v, bool canReturn = false)
        {
            return(Task <Visual> .Run(() =>
            {
                try
                {
                    System.Windows.FrameworkElement e = v as System.Windows.FrameworkElement;

                    e.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (e == null)
                        {
                            return;
                        }
                        PrintDialog pd = new PrintDialog();

                        bool?determiner = true;

                        if (!canReturn)
                        {
                            determiner = pd.ShowDialog();
                        }


                        if ((bool)determiner)
                        {
                            //store original scale
                            Transform originalScale = e.LayoutTransform;
                            //get selected printer capabilities
                            System.Printing.PrintCapabilities capabilities = pd.PrintQueue.GetPrintCapabilities(pd.PrintTicket);
                            //get scale of the print wrt to screen of WPF visual
                            //double x = capabilities.PageImageableArea.ExtentWidth / e.ActualWidth;
                            //double y = capabilities.PageImageableArea.ExtentHeight / e.ActualHeight;
                            double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / e.ActualWidth, capabilities.PageImageableArea.ExtentHeight / e.ActualHeight);
                            //Transform the Visual to scale
                            e.LayoutTransform = new ScaleTransform(scale, scale);
                            //  e.LayoutTransform = new ScaleTransform(x, y);
                            //get the size of the printer page
                            System.Windows.Size sz = new System.Windows.Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
                            //update the layout of the visual to the printer page size.
                            e.Measure(sz);
                            e.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));
                            //now print the visual to printer to fit on the one page.
                            if (!canReturn)
                            {
                                pd.PrintVisual(v, "My Print");
                                //apply the original transform.
                                e.LayoutTransform = originalScale;
                                MessageBox.Show("Printing SuccessFul", "Operation Successful", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                        }
                    }));

                    if (canReturn)
                    {
                        return v;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                return null;
            }));
        }
Beispiel #29
0
        public void PrintDocument()
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != true)
            {
                return;
            }
            this.UpdateLayout();
            this.InvalidateVisual();

            // Create a document
            FixedDocument document = new FixedDocument();

            document.DocumentPaginator.PageSize = new System.Windows.Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);
            PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);

            // Store some properties of report border, which will be restored after printing report.
            FixedPage Resultspage = new FixedPage();

            Transform oldTransform = PrintStackPanel.LayoutTransform;

            System.Windows.Size oldSize = new System.Windows.Size(PrintStackPanel.ActualWidth, PrintStackPanel.ActualHeight);
            var oldMargin = PrintStackPanel.Margin;
            var oldWidth  = PrintStackPanel.Width;


            try
            {
                double _reportMargin = 30;

                Resultspage.Width  = document.DocumentPaginator.PageSize.Width;
                Resultspage.Height = document.DocumentPaginator.PageSize.Height;

                //PrintArea.Child = null;
                PrintArea.Children.Remove(PrintStackPanel);

                PrintStackPanel.LayoutTransform = new ScaleTransform(1, 1);

                System.Windows.Size sz = new System.Windows.Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);

                PrintStackPanel.Margin = new Thickness(_reportMargin);
                PrintStackPanel.Width  = capabilities.PageImageableArea.ExtentWidth - 2 * _reportMargin;
                PrintStackPanel.Measure(sz);
                PrintStackPanel.Arrange(new Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));
                PrintStackPanel.UpdateLayout();


                Resultspage.Children.Add((UIElement)PrintStackPanel);
                Resultspage.UpdateLayout();

                // add the page to the document
                PageContent ReportPageContent = new PageContent();
                ((IAddChild)ReportPageContent).AddChild(Resultspage);

                document.Pages.Add(ReportPageContent);

                printDialog.PrintDocument(document.DocumentPaginator, "Report");
            }
            catch (Exception caughtException)
            {
                MessageBox.Show(caughtException.Message);
            }
            finally
            {
                PrintStackPanel.Measure(oldSize);
                PrintStackPanel.Width           = oldWidth;
                PrintStackPanel.Margin          = oldMargin;
                PrintStackPanel.LayoutTransform = oldTransform;

                PrintStackPanel.Arrange(new Rect(new System.Windows.Point(0, 0), oldSize));

                Resultspage.Children.Remove(PrintStackPanel);

                //PrintArea.Child = PrintStackPanel;
                PrintArea.Children.Add(PrintStackPanel);
            }
        }
        private void Button_Click_(object sender, RoutedEventArgs e)
        {
            var picturename = new Grid();

            switch (ViewModel.MainViewModel.PassName)
            {
            case "全部":
                picturename = openorclose.IsSelected
                               ? OpenOrClose
                               : fault.IsSelected
                                     ? Fault
                                     : energy.IsSelected ? Energy : online.IsSelected ? Online : OpenOrClose;;
                break;

            case "全年日出日落信息":
                picturename = RadChart1;
                break;

            case "时间表操作信息":
                picturename = timetable;
                break;

            case "集中器1周在线率曲线图":
                picturename = RadChart2;
                break;

            case "单灯亮灯率曲线图":
                picturename = RadChart3;
                break;

            case "现存故障分布图":
                picturename = RadChart4;
                break;

            case "今日报警故障分布图":
                picturename = RadChart5;
                break;

            case "历史故障曲线图":
                picturename = RadChart6;
                break;

            case "系统能耗统计图":
                picturename = RadChart7;
                break;

            case "系统功率曲线图":
                picturename = RadChart8;
                break;

            case "单灯能耗统计图":
                picturename = RadChart9;
                break;

            case "终端24小时在线率曲线图":
                picturename = RadChart10;
                break;

            case "集中器24小时在线率曲线图":
                picturename = RadChart11;
                break;

            case "终端1周在线率曲线图":
                picturename = RadChart12;
                break;
            }

            var dialog = new PrintDialog();

            if (dialog.ShowDialog() == true)
            {
                dialog.PrintVisual(picturename, ViewModel.MainViewModel.PassName);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (IsPrint)
            {
                PrintDialog pDialog1 = new PrintDialog();
                pDialog1.PrintVisual(GridPrint, "会员卡消费打印");
                DialogResult = true;
                this.Close();
                return;
            }
            dynamic d = GridPrint.DataContext;

            decimal dCash   = Convert.ToDecimal(txtCash.Text);
            decimal dChange = Convert.ToDecimal(txtChange.Text);

            if (dCash - dChange < d.Amount)
            {
                throw new ArgumentException("收的钱应不小于消费金额");
            }

            using (TransactionScope transaction = new TransactionScope())
            {
                DXInfo.Models.Consume consume = new DXInfo.Models.Consume();
                consume.Sum         = d.Sum;
                consume.Voucher     = d.Voucher;
                consume.PayVoucher  = d.PayVoucher;
                consume.Discount    = d.Discount;
                consume.Card        = d.Id;
                consume.Amount      = d.Amount;
                consume.CreateDate  = d.CreateDate;
                consume.DeptId      = d.DeptId;
                consume.Point       = d.Point;
                consume.UserId      = d.UserId;
                consume.Point       = d.Point;
                consume.ConsumeType = 3;
                consume.DeskNo      = txtDeskNo.Text;

                consume.Cash   = dCash;
                consume.Change = dChange;

                if (d.PayType != Guid.Empty)
                {
                    consume.PayType = d.PayType;
                }
                uow.Consume.Add(consume);


                DXInfo.Models.Bills bill = new DXInfo.Models.Bills();
                bill.Sum      = d.Sum;
                bill.Voucher  = d.Voucher;
                bill.Discount = d.Discount;

                bill.Amount     = d.Amount;
                bill.BillType   = "CardConsume3Window";
                bill.CardNo     = d.CardNo;
                bill.CreateDate = d.CreateDate;
                bill.DeptName   = d.DeptName;
                bill.FullName   = d.FullName;
                bill.MemberName = d.MemberName;
                bill.DeskNo     = txtDeskNo.Text;

                bill.PayTypeName = d.PayTypeName;
                bill.Cash        = dCash;
                bill.Change      = dChange;
                uow.Bills.Add(bill);

                uow.Commit();

                Guid CardId = d.Id;
                DXInfo.Models.Cards card = uow.Cards.GetById(CardId);//.Where(w => w.Id == CardId).FirstOrDefault();
                if (card == null)
                {
                    throw new ArgumentException("卡信息未找到");
                }

                if (d.CardDonateInventory != null && d.CardDonateInventory.Count > 0)
                {
                    foreach (var cdi in d.CardDonateInventory)
                    {
                        DXInfo.Models.ConsumeDonateInv cdonate = new DXInfo.Models.ConsumeDonateInv();
                        cdonate.Consume   = consume.Id;
                        cdonate.Inventory = cdi.Id;
                        uow.ConsumeDonateInv.Add(cdonate);

                        Guid gInvId = cdi.Id;
                        var  cdi1   = uow.CardDonateInventory.GetAll().Where(w => w.Inventory == gInvId).Where(w => w.CardId == CardId).FirstOrDefault();
                        if (cdi1 != null)
                        {
                            cdi1.IsValidate = false;
                        }

                        DXInfo.Models.BillDonateInvLists bd = new DXInfo.Models.BillDonateInvLists();
                        bd.Bill    = bill.Id;
                        bd.InvName = cdi.Name;

                        uow.BillDonateInvLists.Add(bd);
                    }
                }
                foreach (var si in d.lSelInv)
                {
                    DXInfo.Models.ConsumeList cl = new DXInfo.Models.ConsumeList();
                    cl.Amount     = si.Amount;
                    cl.Consume    = consume.Id;
                    cl.CreateDate = d.CreateDate;
                    cl.Cup        = si.Cup;
                    cl.DeptId     = d.DeptId;
                    cl.Inventory  = si.Id;
                    cl.Price      = si.SalePrice;
                    cl.Quantity   = si.Quantity;
                    cl.UserId     = d.UserId;

                    uow.ConsumeList.Add(cl);

                    DXInfo.Models.BillInvLists bl = new DXInfo.Models.BillInvLists();
                    bl.Amount    = si.Amount;
                    bl.Bill      = bill.Id;
                    bl.CupType   = si.CupType;
                    bl.Name      = si.Name;
                    bl.Quantity  = si.Quantity;
                    bl.SalePrice = si.SalePrice;
                    bl.Tastes    = si.Tastes;

                    uow.BillInvLists.Add(bl);



                    if (si.lTastes.Count > 0)
                    {
                        uow.Commit();
                        foreach (var lt in si.lTastes)
                        {
                            DXInfo.Models.ConsumeTastes ct = new DXInfo.Models.ConsumeTastes();
                            ct.ConsumeList = cl.Id;
                            ct.Taste       = lt.Id;
                            uow.ConsumeTastes.Add(ct);
                        }
                    }
                }

                if (d.Point > 0)
                {
                    var cps = uow.CardPoints.GetAll().Where(w => w.Card == CardId).Where(w => w.PointType == 0).FirstOrDefault();
                    if (cps != null)
                    {
                        cps.Point = cps.Point + d.Point;
                    }
                    else
                    {
                        DXInfo.Models.CardPoints cp = new DXInfo.Models.CardPoints();
                        cp.Card       = d.Id;
                        cp.CreateDate = d.CreateDate;
                        cp.DeptId     = d.DeptId;
                        cp.Point      = d.Point;
                        cp.PointType  = 0;
                        cp.UserId     = d.UserId;

                        uow.CardPoints.Add(cp);
                    }
                }
                uow.Commit();
                transaction.Complete();
            }

            PrintDialog pDialog = new PrintDialog();

            pDialog.PrintVisual(GridPrint, "会员卡消费打印");
            pDialog.PrintVisual(GridPrint2, "会员卡消费打印");
            DialogResult = true;
            this.Close();
        }
            private void GenerateLettersBtn_Click(object sender, EventArgs e)
            {
                PrintDocument document = new PrintDocument();
                document.PrintPage += document_PrintPage;
                document.BeginPrint += document_BeginPrint;
                lettersTupleList = Bounced_Check_Manager_Data_Layer.LetterDAO.generateLetters();

                if (lettersTupleList.Count == 0)
                {
                    MessageBox.Show("No letters to print.");
                    return;
                }

                // Choose printer
                PrintDialog printDialog1 = new PrintDialog();
                printDialog1.Document = document;
                DialogResult result = printDialog1.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return;
                }
                // Print the monster!
                document.Print();
                foreach (var tuple in lettersTupleList)
                {
                    Bounced_Check_Manager_Data_Layer.LetterDAO.create(tuple.Item1);
                }
                MessageBox.Show("Your letters are printing...");
            }
Beispiel #33
0
 // Print from File dropdown
 private void printToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (PrintDialog.ShowDialog() == DialogResult.OK)
     {
     }
 }
Beispiel #34
0
 /*
  *                     if (bingoTable.printCallList == true)
             {
                 printBingoCallList(pt, sz, bingoTable, Color.Black, ref graphicsObj, licenseInfo, "Oranges are pink", false);
                 //print the call list here - msk
             }
             bingoTable.RandSeed = 0;
  * */
 public BingoPrint()
 {
     printBingoDocument = new PrintDocument();
     //printCallList = new PrintDocument();
     printBingoPreviewDialog = new PrintPreviewDialog();
     printBingoDialog = new PrintDialog();
     pageBingoSetupDialog = new PageSetupDialog();
     PrintPageSettings = new PageSettings();
     printBingoDocument.PrintPage += new PrintPageEventHandler(this.PrintPage);
        // printCallList.PrintPage += new PrintPageEventHandler(this.PrintCallList);
        //printBingoDocument.QueryPageSettings += new QueryPageSettingsEventHandler(this.QueryPageSettings);
     numCardsToPrint = 0;
     return;
 }
Beispiel #35
0
        private void btnPrintCSV_Click(object sender, EventArgs e)
        {
            try
            {
                File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\LabelPrint\\Template\\" + guna2ComboBox1.Text);
            }
            catch
            {
                MessageBox.Show("Please select a Template label");
                return;
            }

            Form1 form1  = new Form1();
            int   year   = form1.dtpicker.Value.Year;
            int   month  = form1.dtpicker.Value.Month;
            int   day    = form1.dtpicker.Value.Day;
            int   hour   = form1.dtpicker.Value.Hour;
            int   minute = form1.dtpicker.Value.Minute;


            try
            {
                DataTable dtItem = (DataTable)(dgvImportCSV.DataSource);
                Random    rnd    = new Random();
                string    EPN;

                int    i       = 0;
                int    rowNum  = 0;
                String printer = "";

                foreach (DataRow dr in dtItem.Rows)
                {
                    rowNum++;
                    EPN = Convert.ToString(dr["EPN"]);
                    if (EPN == "" || EPN == null)
                    {
                        MessageBox.Show("You need to add EPN in row :" + rowNum + "", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                foreach (DataRow dr in dtItem.Rows)
                {
                    EPN = Convert.ToString(dr["EPN"]);

                    if (EPN != "" && EPN != null)
                    {
                        int copy = Convert.ToInt32(dr["QUANTITE"]);

                        System.Threading.Thread.Sleep(1500);


                        if (i == 0)
                        {
                            PrintDialog pd = new PrintDialog();

                            pd.PrinterSettings = new PrinterSettings();
                            if (DialogResult.OK == pd.ShowDialog(this))
                            {
                                for (int cp = 0; cp < copy; cp++)
                                {
                                    string str = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\LabelPrint\\Template\\" + guna2ComboBox1.Text);
                                    str = str.Replace("@EPN", Convert.ToString(dr["EPN"]));
                                    str = str.Replace("@CPN1", Convert.ToString(dr["CPN1"]));
                                    str = str.Replace("@CPN2", Convert.ToString(dr["CPN2"]));
                                    str = str.Replace("@CPN3", Convert.ToString(dr["CPN3"]));
                                    str = str.Replace("@ALERT1", Convert.ToString(dr["ALERT1"]));
                                    str = str.Replace("@ALERT2", Convert.ToString(dr["ALERT2"]));
                                    str = str.Replace("@ALERT3", Convert.ToString(dr["ALERT3"]));
                                    str = str.Replace("@RELEASE", Convert.ToString(dr["RELEASE"]));
                                    str = str.Replace("@FIRST_CUSTOMER", Convert.ToString(dr["CUSTOMER"]));
                                    str = str.Replace("@FAMILLE", Convert.ToString(dr["FAMILY"]));
                                    str = str.Replace("@OPERID", Convert.ToString(dr["OPERATOR"]));
                                    str = str.Replace("@OLL", Convert.ToString(dr["OLL"]));
                                    str = str.Replace("@LOT", Convert.ToString(dr["LOT"]));
                                    str = str.Replace("@LEVEL", Convert.ToString(dr["LEVEL"]));
                                    str = str.Replace("@INDICE", Convert.ToString(dr["INDICE"]));
                                    str = str.Replace("@ETOILE", Convert.ToString(dr["ETOILE"]));
                                    str = str.Replace("@PRFX", Convert.ToString(dr["PRFX"]));

                                    str = str.Replace("@JJ", day.ToString());
                                    str = str.Replace("@MM", month.ToString());
                                    str = str.Replace("@YY", year.ToString());
                                    str = str.Replace("@HOURS", form1.dtpicker.Value.ToString("hh:mm"));

                                    str = str.Replace("@COUNTER", rnd.Next(1000, 9999).ToString());

                                    if (form1.jjmmyyyy.Checked == true)
                                    {
                                        str = str.Replace("@DATETIME", form1.dtpicker.Value.ToString("dd/MM/yyyy"));
                                        str = str.Replace("@YY", year.ToString());
                                    }
                                    else
                                    {
                                        str = str.Replace("@DATETIME", form1.dtpicker.Value.ToString("dd/MM/yy"));
                                        str = str.Replace("@YY", year.ToString().Substring(2));
                                    }


                                    RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, str);
                                    form1.dtpicker.Value = form1.dtpicker.Value.AddMinutes(2);
                                }
                                printer = pd.PrinterSettings.PrinterName;
                            }
                        }
                        else
                        {
                            for (int cp = 0; cp < copy; cp++)
                            {
                                string str = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\LabelPrint\\Template\\" + guna2ComboBox1.Text);
                                str = str.Replace("@EPN", Convert.ToString(dr["EPN"]));
                                str = str.Replace("@CPN1", Convert.ToString(dr["CPN1"]));
                                str = str.Replace("@CPN2", Convert.ToString(dr["CPN2"]));
                                str = str.Replace("@CPN3", Convert.ToString(dr["CPN3"]));
                                str = str.Replace("@ALERT1", Convert.ToString(dr["ALERT1"]));
                                str = str.Replace("@ALERT2", Convert.ToString(dr["ALERT2"]));
                                str = str.Replace("@ALERT3", Convert.ToString(dr["ALERT3"]));
                                str = str.Replace("@RELEASE", Convert.ToString(dr["RELEASE"]));
                                str = str.Replace("@FIRST_CUSTOMER", Convert.ToString(dr["CUSTOMER"]));
                                str = str.Replace("@FAMILLE", Convert.ToString(dr["FAMILY"]));
                                str = str.Replace("@OPERID", Convert.ToString(dr["OPERATOR"]));
                                str = str.Replace("@OLL", Convert.ToString(dr["OLL"]));
                                str = str.Replace("@LOT", Convert.ToString(dr["LOT"]));
                                str = str.Replace("@LEVEL", Convert.ToString(dr["LEVEL"]));
                                str = str.Replace("@INDICE", Convert.ToString(dr["INDICE"]));
                                str = str.Replace("@ETOILE", Convert.ToString(dr["ETOILE"]));
                                str = str.Replace("@PRFX", Convert.ToString(dr["PRFX"]));

                                str = str.Replace("@JJ", day.ToString());
                                str = str.Replace("@MM", month.ToString());
                                str = str.Replace("@YY", year.ToString());
                                str = str.Replace("@HOURS", form1.dtpicker.Value.ToString("hh:mm"));


                                str = str.Replace("@COUNTER", rnd.Next(1000, 8000).ToString());

                                if (form1.jjmmyyyy.Checked == true)
                                {
                                    str = str.Replace("@DATETIME", form1.dtpicker.Value.ToString("dd/MM/yyyy"));
                                    str = str.Replace("@YY", year.ToString());
                                }
                                else
                                {
                                    str = str.Replace("@DATETIME", form1.dtpicker.Value.ToString("dd/MM/yy"));
                                    str = str.Replace("@YY", year.ToString().Substring(2));
                                }

                                RawPrinterHelper.SendStringToPrinter(printer, str);
                                form1.dtpicker.Value = form1.dtpicker.Value.AddMinutes(2);
                            }
                        }

                        File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\LabelPrint\\tmp.prn");
                        i++;
                    }
                    else
                    {
                        MessageBox.Show("You need to add EPN in row :" + dtItem.Rows.Count + "", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("here7");
                MessageBox.Show("Exception :  " + ex.Message);
            }
        }
            private void on_print_activate(object obj,
							EventArgs args)
            {
                if (viewer.GameViewerWidget.Games == null)
                    return;
                PrintWrapper printer = new PrintWrapper ();
                PrintDialog dialog =
                    new PrintDialog (printer.PrintJob,
                             Catalog.
                             GetString
                             ("Print PGN File"),
                             0);
                int response = dialog.Run ();

                if (response == (int) PrintButtons.Cancel)
                  {
                      dialog.Hide ();
                      dialog.Dispose ();
                      return;
                  }
                new PrintHandler (viewer,
                          viewer.GameViewerWidget.
                          Games, printer, response);

                dialog.Hide ();
                dialog.Dispose ();
            }
        private void mitPrint_Click(object sender, RoutedEventArgs e)
        {
            //this will print the report
            int intCurrentRow = 0;
            int intCounter;
            int intColumns;
            int intNumberOfRecords;


            try
            {
                PrintDialog pdProblemReport = new PrintDialog();


                if (pdProblemReport.ShowDialog().Value)
                {
                    FlowDocument fdProjectReport = new FlowDocument();
                    Thickness    thickness       = new Thickness(50, 50, 50, 50);
                    fdProjectReport.PagePadding = thickness;

                    //Set Up Table Columns
                    Table ProjectReportTable = new Table();
                    fdProjectReport.Blocks.Add(ProjectReportTable);
                    ProjectReportTable.CellSpacing = 0;
                    intColumns = TheTotalHoursDataSet.totalhours.Columns.Count;
                    fdProjectReport.ColumnWidth           = 10;
                    fdProjectReport.IsColumnWidthFlexible = false;


                    for (int intColumnCounter = 0; intColumnCounter < intColumns; intColumnCounter++)
                    {
                        ProjectReportTable.Columns.Add(new TableColumn());
                    }
                    ProjectReportTable.RowGroups.Add(new TableRowGroup());

                    //Title row
                    ProjectReportTable.RowGroups[0].Rows.Add(new TableRow());
                    TableRow newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow];
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Blue Jay Labor Hour Report"))));
                    newTableRow.Cells[0].FontSize      = 25;
                    newTableRow.Cells[0].FontFamily    = new FontFamily("Times New Roman");
                    newTableRow.Cells[0].ColumnSpan    = intColumns;
                    newTableRow.Cells[0].TextAlignment = TextAlignment.Center;
                    newTableRow.Cells[0].Padding       = new Thickness(0, 0, 0, 10);

                    ProjectReportTable.RowGroups[0].Rows.Add(new TableRow());
                    intCurrentRow++;
                    newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow];
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Date Range " + Convert.ToString(MainWindow.gdatStartDate) + " Thru " + Convert.ToString(MainWindow.gdatEndDate)))));
                    newTableRow.Cells[0].FontSize      = 18;
                    newTableRow.Cells[0].FontFamily    = new FontFamily("Times New Roman");
                    newTableRow.Cells[0].ColumnSpan    = intColumns;
                    newTableRow.Cells[0].TextAlignment = TextAlignment.Center;
                    newTableRow.Cells[0].Padding       = new Thickness(0, 0, 0, 10);


                    //Header Row
                    ProjectReportTable.RowGroups[0].Rows.Add(new TableRow());
                    intCurrentRow++;
                    newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow];
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Employee ID"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("First Name"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Last Name"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Home Office"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Employee Type"))));
                    newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Hours"))));
                    newTableRow.Cells[0].Padding = new Thickness(0, 0, 0, 10);
                    //newTableRow.Cells[0].ColumnSpan = 1;
                    //newTableRow.Cells[1].ColumnSpan = 1;
                    //newTableRow.Cells[2].ColumnSpan = 1;
                    //newTableRow.Cells[3].ColumnSpan = 2;
                    //newTableRow.Cells[4].ColumnSpan = 1;

                    //Format Header Row
                    for (intCounter = 0; intCounter < intColumns; intCounter++)
                    {
                        newTableRow.Cells[intCounter].FontSize        = 16;
                        newTableRow.Cells[intCounter].FontFamily      = new FontFamily("Times New Roman");
                        newTableRow.Cells[intCounter].BorderBrush     = Brushes.Black;
                        newTableRow.Cells[intCounter].TextAlignment   = TextAlignment.Center;
                        newTableRow.Cells[intCounter].BorderThickness = new Thickness();
                    }

                    intNumberOfRecords = TheTotalHoursDataSet.totalhours.Rows.Count;

                    //Data, Format Data

                    for (int intReportRowCounter = 0; intReportRowCounter < intNumberOfRecords; intReportRowCounter++)
                    {
                        ProjectReportTable.RowGroups[0].Rows.Add(new TableRow());
                        intCurrentRow++;
                        newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow];
                        for (int intColumnCounter = 0; intColumnCounter < intColumns; intColumnCounter++)
                        {
                            newTableRow.Cells.Add(new TableCell(new Paragraph(new Run(TheTotalHoursDataSet.totalhours[intReportRowCounter][intColumnCounter].ToString()))));

                            newTableRow.Cells[intColumnCounter].FontSize = 12;
                            newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman");
                            newTableRow.Cells[intColumnCounter].BorderBrush     = Brushes.LightSteelBlue;
                            newTableRow.Cells[intColumnCounter].BorderThickness = new Thickness(0, 0, 0, 1);
                            newTableRow.Cells[intColumnCounter].TextAlignment   = TextAlignment.Center;
                            //if (intColumnCounter == 3)
                            //{
                            //newTableRow.Cells[intColumnCounter].ColumnSpan = 2;
                            //}
                        }
                    }

                    //Set up page and print
                    fdProjectReport.ColumnWidth = pdProblemReport.PrintableAreaWidth;
                    fdProjectReport.PageHeight  = pdProblemReport.PrintableAreaHeight;
                    fdProjectReport.PageWidth   = pdProblemReport.PrintableAreaWidth;
                    pdProblemReport.PrintDocument(((IDocumentPaginatorSource)fdProjectReport).DocumentPaginator, "Total Labor Report");
                    intCurrentRow = 0;
                }
            }
            catch (Exception Ex)
            {
                TheMessagesClass.ErrorMessage(Ex.ToString());

                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Find Labor Hours // Print Menu Item " + Ex.Message);
            }
        }
 //print Method
 private void SendToPrinter()
 {
     try
     {
         PrintDialog printDialog = new PrintDialog();
         printDialog.ShowDialog();
     }
     catch (Exception)
     {
         MessageBox.Show("An error has occured, please speak to your systems admin");
     }
 }
Beispiel #39
0
        private void Print_Click(object sender, EventArgs e)
        {
            // Open MS Word template ready for use
            OpenTemplate(ContractTemplatePath);

            // Ensure the opened document is the currently active one
            wordDoc.Activate();

            // Set the text for each bookmark from the corresponding data in the GUI
            SetBookmarkText(wordDoc, "Hirer", HirerCode.Text);
            SetBookmarkText(wordDoc, "HirerName", HirerName.Text);
            SetBookmarkText(wordDoc, "HirerAddress1", HirerAddressLn1.Text);
            SetBookmarkText(wordDoc, "HirerAddress2", HirerAddressLn2.Text);
            SetBookmarkText(wordDoc, "HirerAddress3", HirerAddressLn3.Text);
            SetBookmarkText(wordDoc, "HirerAddress4", HirerAddressLn4.Text);
            SetBookmarkText(wordDoc, "HirerAddress5", HirerAddressLn5.Text);
            //SetBookmarkText(wordDoc, "SiteName", SiteName.Text); // Bookmark does not exist
            SetBookmarkText(wordDoc, "SiteAddress1", SiteAddressLn1.Text);
            SetBookmarkText(wordDoc, "SiteAddress2", SiteAddressLn2.Text);
            SetBookmarkText(wordDoc, "SiteAddress3", SiteAddressLn3.Text);
            SetBookmarkText(wordDoc, "SiteAddress4", SiteAddressLn4.Text);
            SetBookmarkText(wordDoc, "SiteAddress5", SiteAddressLn5.Text);
            SetBookmarkText(wordDoc, "OrderNo", OrderNumber.Text);
            SetBookmarkText(wordDoc, "CommencementDate", CommencementDate.Text);
            SetBookmarkText(wordDoc, "WeeklyRate", WeeklyRate.Text);
            SetBookmarkText(wordDoc, "DailyRate", DailyRate.Text);
            SetBookmarkText(wordDoc, "DeliveryCharge", DeliveryRate.Text);
            SetBookmarkText(wordDoc, "CollectionCharge", CollectRate.Text);
            SetBookmarkText(wordDoc, "PlantNo", PlantCode.Text);
            SetBookmarkText(wordDoc, "PlantDetail1", PlantDetailLn1.Text);
            SetBookmarkText(wordDoc, "PlantDetail2", PlantDetailLn2.Text);
            SetBookmarkText(wordDoc, "PlantDetail3", PlantDetailLn3.Text);
            SetBookmarkText(wordDoc, "PlantDetail4", PlantDetailLn4.Text);
            SetBookmarkText(wordDoc, "PlantDetail5", PlantDetailLn5.Text);
            SetBookmarkText(wordDoc, "Note", Note.Text);

            // Instantiate and configure the PrintDialog
            var pd = new PrintDialog();

            pd.UseEXDialog      = true;
            pd.AllowSomePages   = false;
            pd.AllowSelection   = false;
            pd.AllowCurrentPage = false;
            pd.AllowPrintToFile = false;

            // Check the response from the PrintDialog
            if (pd.ShowDialog(this) == DialogResult.OK)
            {
                // Attempt to print the document
                try
                {
                    wordApp.ActivePrinter = pd.PrinterSettings.PrinterName;
                    wordDoc.PrintOut(Copies: pd.PrinterSettings.Copies);
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message);
                }
            }

            // Change the cursor to indicate the application is busy
            Cursor.Current = Cursors.WaitCursor;

            // Wait until the printing is done
            while (wordApp.BackgroundPrintingStatus != 0)
            {
                Application.DoEvents();
                Application.DoEvents();
            }

            // Revert the cursor to normal
            Cursor.Current = Cursors.Default;


            // Close the MS Word template document, discarding any changes
            CloseTemplate();
        }
Beispiel #40
0
 private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)
 {
     PrintDialog myPrintDialog = new PrintDialog();
     myPrintDialog.currentTT = currentTT;
     myPrintDialog.ShowDialog();
 }
        public void Print()
        {
            //		if (Html == null || Html == string.Empty) {
            //			Simple.ErrorAlert("Chyba při tisku", "Není co tisknout, prázdný dokument", parentWindow);
            //			return;
            //		}
            //
            string Caption = "Beline Printing";

            PrintJob pj = new PrintJob (PrintConfig.Default ());
            PrintDialog dialog = new PrintDialog (pj, Caption, 0);

            //		Gtk.HTML gtk_html = new Gtk.HTML (Html);
            html_panel.PrintSetMaster (pj);

            PrintContext ctx = pj.Context;
            html_panel.Print (ctx);

            pj.Close ();

            // hello user
            int response = dialog.Run ();

            if (response == (int) PrintButtons.Cancel) {
            dialog.Hide ();
            dialog.Dispose ();
            return;
            } else if (response == (int) PrintButtons.Print) {
            pj.Print ();
            } else if (response == (int) PrintButtons.Preview) {
            new PrintJobPreview (pj, Caption).Show ();
            }

            ctx.Close ();
            dialog.Hide ();
            dialog.Dispose ();
            return;
        }