Example #1
0
        //Override the OnPrintPage to provide the printing logic for the document
        protected override void OnPrintPage(PrintPageEventArgs ev)
        {
            base.OnPrintPage(ev) ;

                float lpp = 0 ;
                float yPos =  0 ;
                int count = 0 ;
                float leftMargin = ev.MarginBounds.Left;
                float topMargin = ev.MarginBounds.Top;
                String line=null;

                //Work out the number of lines per page
                //Use the MarginBounds on the event to do this
                lpp = ev.MarginBounds.Height  / printFont.GetHeight(ev.Graphics) ;

                //Now iterate over the file printing out each line
                //NOTE WELL: This assumes that a single line is not wider than the page width
                //Check count first so that we don't read line that we won't print
                while (count < lpp && ((line=streamToPrint.ReadLine()) != null))
                {
                    yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));

                    ev.Graphics.DrawString (line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());

                    count++;
                }

                //If we have more lines then print another page
                if (line != null)
                    ev.HasMorePages = true ;
                else
                    ev.HasMorePages = false ;
        }
Example #2
0
 void printDoc_PrintPage(object sender, PrintPageEventArgs e)
 {
     if (mixRows == null)
         PrintSingle(barcodeRow, e.Graphics);
     else
         PrintMix(barcodeRow, mixRows, e.Graphics);
 }
 public static int Print(this RichTextBox rtb, int charFrom, int charTo, PrintPageEventArgs e)
 {
     CHARRANGE charrange;
     charrange.cpMin = charFrom;
     charrange.cpMax = charTo;
     RECT rect1;
     rect1.Top = checked((int)Math.Round(unchecked((double)e.MarginBounds.Top * 14.4)));
     rect1.Bottom = checked((int)Math.Round(unchecked((double)e.MarginBounds.Bottom * 14.4)));
     rect1.Left = checked((int)Math.Round(unchecked((double)e.MarginBounds.Left * 14.4)));
     rect1.Right = checked((int)Math.Round(unchecked((double)e.MarginBounds.Right * 14.4)));
     RECT rect2;
     rect2.Top = checked((int)Math.Round(unchecked((double)e.PageBounds.Top * 14.4)));
     rect2.Bottom = checked((int)Math.Round(unchecked((double)e.PageBounds.Bottom * 14.4)));
     rect2.Left = checked((int)Math.Round(unchecked((double)e.PageBounds.Left * 14.4)));
     rect2.Right = checked((int)Math.Round(unchecked((double)e.PageBounds.Right * 14.4)));
     IntPtr hdc = e.Graphics.GetHdc();
     FORMATRANGE formatrange;
     formatrange.chrg = charrange;
     formatrange.hdc = hdc;
     formatrange.hdcTarget = hdc;
     formatrange.rc = rect1;
     formatrange.rcPage = rect2;
     IntPtr num1 = IntPtr.Zero;
     IntPtr wp = IntPtr.Zero;
     wp = new IntPtr(1);
     IntPtr num2 = IntPtr.Zero;
     IntPtr num3 = Marshal.AllocCoTaskMem(Marshal.SizeOf((object)formatrange));
     Marshal.StructureToPtr((object)formatrange, num3, false);
     IntPtr num4 = SendMessage(rtb.Handle, 1081, wp, num3);
     Marshal.FreeCoTaskMem(num3);
     e.Graphics.ReleaseHdc(hdc);
     return num4.ToInt32();
 }
        void m_printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            SelectedMealCollection colData = (SelectedMealCollection)this.FindResource("SelectedMealCollectionData");
            float leftMargin = e.MarginBounds.Left;
            float rightMargin = e.MarginBounds.Right;
            float topMargin = e.MarginBounds.Top;
          
            float yPos = leftMargin;
            float xPos = 0;
            float centrePos = 2 * (rightMargin - leftMargin) / 5;
            float rightPos =  4 * (rightMargin - leftMargin) / 5;
            int count = 0;

            System.Drawing.Font printFont = new System.Drawing.Font("Arial", 10);
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            // Work out the number of lines per page, using the MarginBounds.
            float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
            float lineCount = 0;
            foreach (var selectedMeal in colData)
            {
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(selectedMeal.Date, printFont, myBrush, xPos, yPos);
                lineCount++;
   
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(selectedMeal.Meal, printFont, myBrush, xPos + 20, yPos);

                lineCount++;

                if (lineCount > linesPerPage) { break; }
            }

            lineCount = 0;
            count = 0;

            SelectedIngredientsCollection ingredientData = (SelectedIngredientsCollection)this.FindResource("SelectedIngredientsCollectionData");

            foreach (SelectedIngredient ingredient in ingredientData)
            {               
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                xPos = centrePos;
                if (lineCount > linesPerPage) xPos = rightPos;
                e.Graphics.DrawString(ingredient.Ingredient, printFont, myBrush, xPos, yPos);
                lineCount++;
            }

            // If there are more lines, print another page.
            if (lineCount > linesPerPage)
            {
           //     e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                myBrush.Dispose();
            }
        }
Example #5
0
 public override void OnEndPage(
     PrintDocument document,
     PrintPageEventArgs e
     )
 {
     this.OriginController.OnEndPage(document, e);
 }
 protected override void OnPrintPage(PrintPageEventArgs ev)
 {
     base.OnPrintPage(ev);
       PageSettings defaultPageSettings = this.DefaultPageSettings;
       int num1 = checked (defaultPageSettings.PaperSize.Height - defaultPageSettings.Margins.Top - defaultPageSettings.Margins.Bottom);
       int num2 = checked (defaultPageSettings.PaperSize.Width - defaultPageSettings.Margins.Left - defaultPageSettings.Margins.Right);
       int left = defaultPageSettings.Margins.Left;
       int top = defaultPageSettings.Margins.Top;
       if (this.DefaultPageSettings.Landscape)
       {
     int num3 = num1;
     num1 = num2;
     num2 = num3;
       }
       int num4 = checked ((int) Math.Round(unchecked ((double) num1 / (double) this.Font.Height)));
       RectangleF layoutRectangle = new RectangleF((float) left, (float) top, (float) num2, (float) num1);
       StringFormat stringFormat = new StringFormat(StringFormatFlags.LineLimit);
       int charactersFitted;
       int linesFilled;
       ev.Graphics.MeasureString(Strings.Mid(this.strText, this.UpgradeZeros(this.\u0024STATIC\u0024OnPrintPage\u002420111211\u0024intCurrentChar)), this.Font, new SizeF((float) num2, (float) num1), stringFormat, out charactersFitted, out linesFilled);
       ev.Graphics.DrawString(Strings.Mid(this.strText, this.UpgradeZeros(this.\u0024STATIC\u0024OnPrintPage\u002420111211\u0024intCurrentChar)), this.Font, Brushes.Black, layoutRectangle, stringFormat);
       this.\u0024STATIC\u0024OnPrintPage\u002420111211\u0024intCurrentChar = checked (this.\u0024STATIC\u0024OnPrintPage\u002420111211\u0024intCurrentChar + charactersFitted);
       if (this.\u0024STATIC\u0024OnPrintPage\u002420111211\u0024intCurrentChar < this.strText.Length)
       {
     ev.HasMorePages = true;
       }
       else
       {
     ev.HasMorePages = false;
     this.\u0024STATIC\u0024OnPrintPage\u002420111211\u0024intCurrentChar = 0;
       }
 }
Example #7
0
        void pdDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            int x = 10;
            int y = 80;
            e.Graphics.DrawString(binfo.tabName, new Font("Arial", 15), Brushes.Black, 150, 5);
            e.Graphics.DrawString(printType, new Font("Arial", 15), Brushes.Black, 50, 5);
            e.Graphics.DrawString(CommService.GetCompanyName(), new Font("Arial", 10), Brushes.Black, 40, 35);

            e.Graphics.DrawString("商品名称", new Font("Arial", 10), Brushes.Black, x, y);
            e.Graphics.DrawString("数量", new Font("Arial", 10), Brushes.Black, 120, y);
            e.Graphics.DrawString("单价", new Font("Arial", 10), Brushes.Black, 160, y);
            e.Graphics.DrawString("赠送", new Font("Arial", 10), Brushes.Black, 240, y);
            double sum = 0;
            for (int i = 0; i < billDetailInfos.Count; i++)
            {
                BillDetailInfo dInfo = billDetailInfos[i];
                e.Graphics.DrawString(dInfo.FoodCnName, new Font("Arial", 10), Brushes.Black, x, y + i * 25 + 20);
                e.Graphics.DrawString(dInfo.foodCount.ToString(), new Font("Arial", 10), Brushes.Black, 120, y + i * 25 + 20);
                e.Graphics.DrawString(dInfo.FoodPrice.ToString(), new Font("Arial", 10), Brushes.Black, 160, y + i * 25 + 20);
                e.Graphics.DrawString(dInfo.Handsel.ToString(), new Font("Arial", 10), Brushes.Black, 240, y + i * 25 + 20);
                sum += dInfo.FoodPrice * dInfo.foodCount;
            }

            e.Graphics.DrawString(string.Format("总额:{0}", sum + "元"), new Font("Arial", 10), Brushes.Black, 10, 50 + (billDetailInfos.Count + 2) * 25);
            e.Graphics.DrawString(string.Format("账单号:{0}", binfo.billKey), new Font("Arial", 10), Brushes.Black, 10, 50 + (billDetailInfos.Count + 3) * 25);
            e.Graphics.DrawString(string.Format("下单时间:{0}", binfo.billtime), new Font("Arial", 10), Brushes.Black, 10, 50 + (billDetailInfos.Count + 4) * 25);
        }
Example #8
0
        private static int PrintoHeaderinEPorosise(PrintPageEventArgs e, int PozY, Models.Order order)
        {
            System.Drawing.Font font = new System.Drawing.Font("Verdana", 7, FontStyle.Regular);
            e.Graphics.DrawString(string.Format("{0} {1}", order.username, order.Phone), new System.Drawing.Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(0, PozY, 500, 500));
            e.Graphics.DrawString(order.PaymentMethod.name, new System.Drawing.Font("Verdana", 7, FontStyle.Regular), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(200, PozY, 500, 500));
            PozY += 25;
            e.Graphics.DrawString("Address:", new System.Drawing.Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(0, PozY, 500, 500));
            e.Graphics.DrawString(order.Address, new System.Drawing.Font("Verdana", 7, FontStyle.Regular), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(70, PozY, 500, 500));

            PozY += 15;
            e.Graphics.DrawString("Order Nr:", new System.Drawing.Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(0, PozY, 500, 500));
            e.Graphics.DrawString(order.id.ToString(), new System.Drawing.Font("Verdana", 7, FontStyle.Regular), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(70, PozY, 500, 500));

            PozY += 15;
            e.Graphics.DrawString("Time:", new System.Drawing.Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(0, PozY, 500, 500));
            e.Graphics.DrawString(order.datetime.ToShortTimeString(), new System.Drawing.Font("Verdana", 7, FontStyle.Regular), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(70, PozY, 500, 500));

            PozY += 15;
            e.Graphics.DrawString("__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __", new System.Drawing.Font("Verdana", 7, FontStyle.Regular), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(0, PozY, 500, 500));

            PozY += 15;
            e.Graphics.DrawString("Item", new System.Drawing.Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(0, PozY, 500, 500));
            e.Graphics.DrawString("Quantity", new System.Drawing.Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(140, PozY, 500, 500));
            e.Graphics.DrawString("Price", new System.Drawing.Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(190, PozY, 500, 500));
            e.Graphics.DrawString("Total", new System.Drawing.Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(240, PozY, 500, 500));
            PozY += 8;
            e.Graphics.DrawString("__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __", new System.Drawing.Font("Verdana", 7, FontStyle.Regular), new SolidBrush(Color.FromArgb(64, 64, 64)), new Rectangle(0, PozY, 500, 500));
            return PozY;
        }
		//Override the OnPrintPage to provide the printing logic for the document
		protected override void OnPrintPage(PrintPageEventArgs ev) 
		{
			base.OnPrintPage(ev);
			labelDocument.DocumentSizeXPixels = ev.PageBounds.Width;
			labelDocument.DocumentSizeYPixels = ev.PageBounds.Height;

			foreach (Structs.Competitor competitor in competitors)
			{
				PrintLabel label;
				try
				{
					label = labelDocument.GetLabel(labelCount);
				}
				catch (PrintLabelDoesNotExistException)
				{
					labelCount = 0;
					ev.HasMorePages = true;
					return;
				}
				printCompetitor(ev, competitor, label);
				labelCount++;    
			}


			ev.HasMorePages = false;
		}
Example #10
0
        private void printCustomerInformation(PrintPageEventArgs e)
        {
            CustomerCache cache = null;
            Dictionary<CustomerCacheSearchKey, string> searchParam = new Dictionary<CustomerCacheSearchKey, string>();
            if (!string.IsNullOrEmpty(currVehicle.GetValue(PropertyId.SaleCustomerId)))
            {
                searchParam.Add(CustomerCacheSearchKey.Id, currVehicle.GetValue(PropertyId.SaleCustomerId));
                cache = new CustomerCache(searchParam);
            }

            if (cache == null || cache.Count <= 0)
                return;

            using (Font font = new Font("Calibri (Body)", 10))
            {
                CustomerAdminObject customer = cache[0];

                e.Graphics.DrawString(customer.FirstName, font, Brushes.Black, backgroundXPos + 90, backgroundYPos + 115);
                e.Graphics.DrawString(customer.LastName, font, Brushes.Black, backgroundXPos + 280, backgroundYPos + 115);

                string address = "";

                if (string.IsNullOrEmpty(customer.GetValue(PropertyId.HomeUnitNumber)))
                {
                    address = string.Format("{0} {1}",
                    customer.GetValue(PropertyId.HomeStreetNumber),
                    customer.GetValue(PropertyId.HomeStreet));
                }
                else
                {
                    address = string.Format("{0} - {1} {2}",
                        customer.GetValue(PropertyId.HomeUnitNumber),
                        customer.GetValue(PropertyId.HomeStreetNumber),
                        customer.GetValue(PropertyId.HomeStreet));
                }

                e.Graphics.DrawString(address, font, Brushes.Black, backgroundXPos + 30, backgroundYPos + 145);

                e.Graphics.DrawString(customer.GetValue(PropertyId.HomeCity), font, Brushes.Black, backgroundXPos + 30, backgroundYPos + 170);

                e.Graphics.DrawString(customer.GetValue(PropertyId.HomeProvince), font, Brushes.Black, backgroundXPos + 220, backgroundYPos + 170);

                e.Graphics.DrawString(customer.GetValue(PropertyId.HomePostalCode), font, Brushes.Black, backgroundXPos + 330, backgroundYPos + 170);

                //Print phone number
                if (string.IsNullOrEmpty(customer.GetValue(PropertyId.MobilePhone)))
                {
                    e.Graphics.DrawString(customer.GetValue(PropertyId.HomePhone), font, Brushes.Black, backgroundXPos + 30, backgroundYPos + 200);
                }
                else
                {
                    e.Graphics.DrawString(customer.GetValue(PropertyId.MobilePhone) + " (cell)", font, Brushes.Black, backgroundXPos + 30, backgroundYPos + 200);
                }

                e.Graphics.DrawString(customer.GetValue(PropertyId.DriversLicense), font, Brushes.Black, backgroundXPos + 65, backgroundYPos + 225);

                e.Graphics.DrawString(customer.GetValue(PropertyId.LicenseExpiry), font, Brushes.Black, backgroundXPos + 315, backgroundYPos + 225);

            }
        }
Example #11
0
 private static void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
 {
     var g = e.Graphics;
     //欢迎文字
     var y = 0;
     var lineH = 25;
     var config = ConfigProfile.Instance;
     if (!config.Welcome.IsEmpty())
     {
         e.Graphics.DrawString(config.Welcome, printFont, Brushes.Black, new Point(65, y));
         y += lineH;
     }
     if (!config.DateTime.IsEmpty())
     {
         var dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
         e.Graphics.DrawString(dt, printTimeFont, Brushes.Black, new Point(40, y));
         y += lineH;
     }
     if (!config.Guide.IsEmpty())
     {
         e.Graphics.DrawString(config.Guide, printFont, Brushes.Black, new Point(52, y));
         y += lineH;
     }
     //二维码图像
     g.DrawImage(_barcodeImage, new Rectangle(45, y, IMAGE_SIZE, IMAGE_SIZE));
     DisposeImage();
 }
Example #12
0
        private void p_PrintPage(object sender, PrintPageEventArgs ev)
        {
            float linesPerPage = 0;
            float yPos = 0;
            int count = 0;
            float leftMargin = ev.MarginBounds.Left;
            float topMargin = ev.MarginBounds.Top;
            string line = null;

            // Calculate the number of lines per page.
            linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics);

            // Print each line of the file.
            while (count < linesPerPage &&
               ((line = streamToPrint.ReadLine()) != null))
            {
                yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));
                ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
                count++;
            }

            // If more lines exist, print another page.
            if (line != null)
                ev.HasMorePages = true;
            else
                ev.HasMorePages = false;
        }
Example #13
0
            protected override void OnPrintPage(PrintPageEventArgs e)
            {
                base.OnPrintPage(e);

                Stream pageToPrint = m_pages[m_currentPage];
                pageToPrint.Position = 0;

                // Load each page into a Metafile to draw it.
                using (Metafile pageMetaFile = new Metafile(pageToPrint))
                {
                    Rectangle adjustedRect = new Rectangle(
                            e.PageBounds.Left - (int)e.PageSettings.HardMarginX,
                            e.PageBounds.Top - (int)e.PageSettings.HardMarginY,
                            e.PageBounds.Width,
                            e.PageBounds.Height);

                    // Draw a white background for the report
                    e.Graphics.FillRectangle(Brushes.White, adjustedRect);

                    // Draw the report content
                    e.Graphics.DrawImage(pageMetaFile, adjustedRect);

                    // Prepare for next page.  Make sure we haven't hit the end.
                    m_currentPage++;
                    e.HasMorePages = m_currentPage < m_pages.Count;
                }
            }
		private void PreparePrinting(PrintPageEventArgs ev)
		{
			#region Fonts
			_printFont = new Font("Times New Roman", 12,
				FontStyle.Regular);
			_printAllbergFont = new Font("Arial", 8, FontStyle.Regular);
			_printFontClubHeader = new Font("Times New Roman", 14, FontStyle.Bold);
			#endregion

			#region Margins
			_marginLeft = ev.PageSettings.HardMarginX;
			_marginTop = ev.PageSettings.HardMarginY;

			if (_marginLeft < 70)
				_marginLeft = 70;
			if (_marginTop < 20)
				_marginTop = 20;

			_marginRight = ev.PageSettings.Bounds.Width - _marginLeft;
			_marginBottom = ev.PageSettings.Bounds.Height - _marginTop - ev.Graphics.MeasureString("A", _printAllbergFont).Height;
			#endregion

			#region Columns
			_shooterColumnStart = _marginLeft;
			_payedColumnStart = _shooterColumnStart + ShooterColumnWidth;
			_arrivedColumnStart = _payedColumnStart + PayedColumnWidth;
			_numberOfRoundsColumnStart = _arrivedColumnStart + ArrivedColumnWidth;
			#endregion

			_useShouldHavePayed = _commonCode.CompetitionCurrent.UsePriceMoney;
		}
Example #15
0
        private void PrintPage(object o, PrintPageEventArgs e)
        {
            try
            {
            button1.Visible = false;
            int x = SystemInformation.WorkingArea.X;
            int y = SystemInformation.WorkingArea.Y;

            int width = this.Width;
            int height = this.Height;

            Rectangle bounds = new Rectangle(x, y, width, height);

            Bitmap img = new Bitmap(width, height);

            this.DrawToBitmap(img, bounds);
            string date = DateTime.Now.ToString("yyyyMMddhhmmss");

            //img.Save(date + ".bmp");
            //Point loc = new Point(100, 100);
            e.Graphics.DrawImage(img, bounds);
             }
             catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Example #16
0
        private void printDoc_PrintPage(Object sender, PrintPageEventArgs e)
        {
            float leftMargin = e.MarginBounds.Left;
            float topMargin = e.MarginBounds.Top;

            float linesPerPage = e.MarginBounds.Height / PrintFont.GetHeight(e.Graphics);
            float yPosition = 0;
            int count = 0;

            SolidBrush myBrush = new SolidBrush(Color.Black);

            int i = 0;
            for (i = 0; i < LinesPerPage && (i + (PageNumber * LinesPerPage) < PrintLines.Length); ++i)
            {
                string line = PrintLines[i + (PageNumber * LinesPerPage)];

                // calculate the next line position based on the height of the font according to the printing device
                yPosition = topMargin + (count * PrintFont.GetHeight(e.Graphics));

                // draw the next line in the rich edit control
                e.Graphics.DrawString(line, PrintFont, myBrush, leftMargin, yPosition, new StringFormat());
                count++;
            }
            e.HasMorePages = (i + (PageNumber * LinesPerPage) < PrintLines.Length);
            ++PageNumber;
            myBrush.Dispose();
        }
Example #17
0
 private PageContext CreateContext(PrintPageEventArgs document)
 {
     return new PageContext(document) {
         Horizontal = Horizontal,
         Lpi = (float) _lpi.Value,
     };
 }
 protected virtual void OnPrintPage(PrintPageEventArgs e)
 {
     if (this.printPageHandler != null)
     {
         this.printPageHandler(this, e);
     }
 }
Example #19
0
 public int Print(int charFrom, int charTo, PrintPageEventArgs e)
 {
     RECT rect;
     RECT rect2;
     FORMATRANGE formatrange;
     rect.Top = (int)(e.MarginBounds.Top * 14.4);
     rect.Bottom = (int)(e.MarginBounds.Bottom * 14.4);
     rect.Left = (int)(e.MarginBounds.Left * 14.4);
     rect.Right = (int)(e.MarginBounds.Right * 14.4);
     rect2.Top = (int)(e.PageBounds.Top * 14.4);
     rect2.Bottom = (int)(e.PageBounds.Bottom * 14.4);
     rect2.Left = (int)(e.PageBounds.Left * 14.4);
     rect2.Right = (int)(e.PageBounds.Right * 14.4);
     IntPtr hdc = e.Graphics.GetHdc();
     formatrange.chrg.cpMax = charTo;
     formatrange.chrg.cpMin = charFrom;
     formatrange.hdc = hdc;
     formatrange.hdcTarget = hdc;
     formatrange.rc = rect;
     formatrange.rcPage = rect2;
     IntPtr zero = IntPtr.Zero;
     IntPtr wp = IntPtr.Zero;
     wp = new IntPtr(1);
     IntPtr ptr = IntPtr.Zero;
     ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(formatrange));
     Marshal.StructureToPtr(formatrange, ptr, false);
     zero = SendMessage(base.Handle, 0x439, wp, ptr);
     Marshal.FreeCoTaskMem(ptr);
     e.Graphics.ReleaseHdc(hdc);
     return zero.ToInt32();
 }
 private void pDoc_PrintPage(object sender, PrintPageEventArgs e)
 {
     m_Graphics = e.Graphics;
     PX = e.MarginBounds.Left *0.01f * 15.4f;
     PY = e.MarginBounds.Top * 0.01f * 15.4f;
     DrawPaper();
 }
        void printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            printArgs = e;

            precalculateSize();

            dontDrawNow = false;

            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

            if (_CurrentElement == null)
            {
                if (chapterIndex < this.printableDocument.Childs.Count)
                {
                    _CurrentElement = this.printableDocument.Childs[chapterIndex];
                }
                else
                {
                    e.HasMorePages = false;
                    return;
                }
            }

            _CurrentElement.Render(this);
        }
Example #22
0
        protected override void OnPrintPage(PrintPageEventArgs e)
        {
            if (_currentPage < _document.PageCount)
            {
                _document.Render(
                    _currentPage++,
                    e.Graphics,
                    e.PageSettings.PrinterResolution.X,
                    e.PageSettings.PrinterResolution.Y,
                    new Rectangle(
                        0,
                        0,
                        (int)((e.PageBounds.Width / 100.0) * e.PageSettings.PrinterResolution.X),
                        (int)((e.PageBounds.Height / 100.0) * e.PageSettings.PrinterResolution.Y)
                    )
                );
            }

            int pageCount =
                PrinterSettings.ToPage == 0
                ? _document.PageCount
                : Math.Min(PrinterSettings.ToPage, _document.PageCount);

            e.HasMorePages = _currentPage < pageCount;
        }
Example #23
0
 void pdDocument_PrintPage(object sender, PrintPageEventArgs e)
 {
     int x = 10;
     int y = 80;
     //double sx = Convert.ToDouble(tb_Cash.Text) + Convert.ToDouble(tb_Vesa.Text) + Convert.ToDouble(tb_Card.Text) + Convert.ToDouble(tb_cashCoupon.Text);
     e.Graphics.DrawString(bInfo.tabName, new Font("Arial", 20), Brushes.Black, 200, 5);
     e.Graphics.DrawString("消费小票", new Font("Arial", 20), Brushes.Black, 60, 5);
     e.Graphics.DrawString(CommService.GetCompanyName(), new Font("Arial", 10), Brushes.Black, 50, 40);
     //e.Graphics.DrawString(String.Format("房间号码:{0}",bInfo.billRmNo), new Font("Arial", 10), Brushes.Black, 10, 60);
     e.Graphics.DrawString("商品名称", new Font("Arial", 10), Brushes.Black, x, y);
     e.Graphics.DrawString("数量", new Font("Arial", 10), Brushes.Black, 120, y);
     e.Graphics.DrawString("单价", new Font("Arial", 10), Brushes.Black, 180, y);
     e.Graphics.DrawString("赠送", new Font("Arial", 10), Brushes.Black, 240, y);
     for (int i = 0; i < detailInfos.Count; i++)
     {
         BillDetailInfo dInfo = detailInfos[i];
         e.Graphics.DrawString(dInfo.FoodCnName, new Font("Arial", 10), Brushes.Black, x, y + i * 25 + 20);
         e.Graphics.DrawString(dInfo.foodCount.ToString(), new Font("Arial", 10), Brushes.Black, 120, y + i * 25 + 20);
         e.Graphics.DrawString(dInfo.FoodPrice.ToString(), new Font("Arial", 10), Brushes.Black, 190, y + i * 25 + 20);
         e.Graphics.DrawString(dInfo.Handsel.ToString(), new Font("Arial", 10), Brushes.Black, 240, y + i * 25 + 20);
     }
     //domain.RechargeCardInfo cinfo = service.RechargeCardService.GetRechargeCardInfoByCardId(bInfo.cardId);
     e.Graphics.DrawString(string.Format("总金额:{0}元  账单号:{1}", bInfo.billMoney, bInfo.billKey), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 2) * 25);
     e.Graphics.DrawString(string.Format("折扣:{0}  折扣金额:{1} 元", bInfo.discount, bInfo.billMoney - bInfo.SHmoney), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 3) * 25);
     e.Graphics.DrawString(string.Format("应收金额:{0}元 结帐方式:{1} ", bInfo.SHmoney, bInfo.paymethod), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 4) * 25);
     //e.Graphics.DrawString(string.Format("结帐方式:{0}元 ", bInfo.paymethod), new Font("Arial", 10), Brushes.Black, 10, 50 + (bInfo.detailInfos.Count + 5) * 25);
     if (type == 1)
     {
         //e.Graphics.DrawString(string.Format("易享卡卡号:{0}", bInfo.vipNo), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 5) * 25);
         //e.Graphics.DrawString(string.Format("充值卡号:{0} 充值卡余额:{1}元", bInfo.cardId, cinfo == null ? "0.0" : (cinfo.Balance + cinfo.FHBalance).ToString()), new Font("Arial", 10), Brushes.Black, 10, 50 + (bInfo.detailInfos.Count + 6) * 25);
         e.Graphics.DrawString(string.Format("实收金额:{0}元,找零{1}元", bInfo.SHmoney, bInfo.zl), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 5) * 25);
         e.Graphics.DrawString(string.Format("结账时间:{0}", bInfo.checktime), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 6) * 25);
     }
 }
        public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
        {
            Bitmap bmp = new Bitmap(1, 1);

            Graphics bmpg = Graphics.FromImage(bmp);
            IntPtr hdc = bmpg.GetHdc();
            ms = new MemoryStream();
            Metafile meta = new Metafile(ms, hdc, EmfType.EmfPlusDual);
            bmpg.ReleaseHdc(hdc);

            this.pic.Image = meta;

            Graphics g = Graphics.FromImage(meta);

            PaperSize size = e.PageSettings.PaperSize;
            int height = size.Height * dpi / 100;
            int width = size.Width * dpi / 100;

            if (e.PageSettings.Landscape)
            {
                g.FillRectangle(Brushes.White, 0, 0, height, width);
                g.SetClip(new Rectangle(0, 0, height - 16, width - 16));
            }
            else
            {
                g.FillRectangle(Brushes.White, 0, 0, width, height);
                g.SetClip(new Rectangle(0, 0, width - 16, height - 16));
            }

            return g;
        }
Example #25
0
        private void PrintDoc_PrintPage(object sender, PrintPageEventArgs e)
        {
            if (m_currentPrintSet == null)
            {
                m_currentPrintSet = new List<PictureViewBox>(m_pictureViewPanel.GetSelected());
                m_currentPrintSetItem = 0;
            }

            PictureViewBox pvb = m_currentPrintSet[m_currentPrintSetItem];
            Image image = pvb.Image;
            e.Graphics.DrawImage(image, 0, 0);
            image.Dispose();

            m_currentPrintSetItem++;

            if (m_currentPrintSetItem < m_currentPrintSet.Count)
            {
                e.HasMorePages = true;
            }
            else
            {
                m_currentPrintSetItem = 0;
                m_currentPrintSet = null;
                e.HasMorePages = false;
            }
        }
 public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
 {
     this.CheckSecurity();
     this.graphics.Dispose();
     this.graphics = null;
     base.OnEndPage(document, e);
 }
 public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
 {
     //if (ms != null)
     //{
     //    ms.Close();
     //}
 }
Example #28
0
        protected override void OnPrintPage(PrintPageEventArgs ev)
        {
            base.OnPrintPage(ev);

            ev.Graphics.PageUnit = GraphicsUnit.Millimeter;
            Font font; // = new Font(new FontFamily("Arial"), 7.0f, GraphicsUnit.Millimeter);

            Rectangle bodyRect = new Rectangle(3, 3, 184, 272);             // DVD Cover size 272x184
            Rectangle middleRect = new Rectangle(3, 129 + 3, 184, 14);      // DVD Covert side size, 14x184

            // Draw dotted rectable
            Pen borderPen = new Pen(System.Drawing.Color.Black, 0.3f);
            borderPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
            borderPen.DashPattern = new float[] {0.3F, 45F};
            ev.Graphics.DrawRectangle(borderPen, bodyRect);

            // Draw dotted rectable in middle
            //ev.Graphics.DrawRectangle(borderPen, middleRect);

            // Draw small "L" markers on cut positions
            Pen linePen = new Pen(System.Drawing.Color.Black, 0.3f);
            ev.Graphics.DrawLine(linePen, 3, 3, 6, 3);
            ev.Graphics.DrawLine(linePen, 3, 3, 3, 6);

            ev.Graphics.DrawLine(linePen, 184+3, 3, 181+3, 3);
            ev.Graphics.DrawLine(linePen, 184+3, 3, 184+3, 6);

            ev.Graphics.DrawLine(linePen, 3, 272+3, 6, 272+3);
            ev.Graphics.DrawLine(linePen, 3, 272+3, 3, 269+3);

            ev.Graphics.DrawLine(linePen, 184 + 3, 272 + 3, 181+3, 272 + 3);
            ev.Graphics.DrawLine(linePen, 184 + 3, 272 + 3, 184+3, 269 + 3);

            float startpos = middleRect.X + 2.0f;
            if (text1 != null)
            {
                font = new Font(new FontFamily("Arial"), size1, GraphicsUnit.Millimeter);
                startpos += DrawSideText(ev, font, 0, text1, startpos, middleRect.Y + ((middleRect.Height-size1) / 2.0f));
            }
            if (text2 != null)
            {
                font = new Font(new FontFamily("Arial"), size2, GraphicsUnit.Millimeter);
                startpos += DrawSideText(ev, font, 1, text2, startpos, middleRect.Y + ((middleRect.Height - size2) / 2.0f));
            }
            if (text3 != null)
            {
                font = new Font(new FontFamily("Arial"), size3, GraphicsUnit.Millimeter);
                startpos += DrawSideText(ev, font, 2, text3, startpos, middleRect.Y + ((middleRect.Height - size3) / 2.0f));
            }
            if (text4 != null)
            {
                font = new Font(new FontFamily("Arial"), size4, GraphicsUnit.Millimeter);
                startpos += DrawSideText(ev, font, 3, text4, startpos, middleRect.Y + ((middleRect.Height - size4) / 2.0f));
            }
            if (textnumber != null)
            {
                font = new Font(new FontFamily("Arial"), sizenumber, GraphicsUnit.Millimeter);
                startpos += DrawNumberText(ev, font, numbercolor, textnumber, middleRect.X + middleRect.Width - 2.0f, middleRect.Y + ((middleRect.Height - sizenumber) / 2.0f));
            }
        }
Example #29
0
        void pDoc_PrintPage(object sender, PrintPageEventArgs e)
        {
            Graphics g = e.Graphics;
            int x = -110;
            int y = 30;
            int cell_height = 0;
            dGrid.ColumnHeadersVisible = true;
            int colCount = dGrid.ColumnCount;
            int rowCount = dGrid.RowCount;
            int current_col = 0;
            int current_row = 0;
            string value = "";
            Rectangle cell_border;
            SolidBrush brush = new SolidBrush(Color.Black);
            while (current_row < rowCount)
            {
                while (current_col < colCount)
                {
                    x += dGrid[current_col, current_row].Size.Width;
                    cell_height = dGrid[current_col, current_row].Size.Height;
                    cell_border = new Rectangle(x, y, dGrid[current_col, current_row].Size.Width, dGrid[current_col, current_row].Size.Height);
                    value = dGrid[current_col, current_row].Value.ToString();
                    g.DrawRectangle(new Pen(Color.Black), cell_border);
                    g.DrawString(value, new Font("tahoma", 6), brush, x, y);
                    current_col++;      //increment the currnet column
                }

                current_col = 0;
                current_row++;          //increment the current row
                x = -110;
                y += cell_height;
            }
        }
		//Override the OnPrintPage to provide the printing logic for the document
		protected override void OnPrintPage(PrintPageEventArgs ev) 
		{
			_labelDocument.DocumentSizeXPixels = ev.PageBounds.Width;
			_labelDocument.DocumentSizeYPixels = ev.PageBounds.Height;

			for(;_currentCompetitor<_competitors.Length;_currentCompetitor++)
			{
				for(;_currentCompetitorSeries<_nrofseries;_currentCompetitorSeries++)
				{
					PrintLabel label;
					try
					{
						label = _labelDocument.GetLabel(_labelCount);
					}
					catch(PrintLabelDoesNotExistException)
					{
						_labelCount = 0;
						ev.HasMorePages = true;
						return;
					}
					PrintCompetitor(ev,_competitors[_currentCompetitor], _currentCompetitorSeries, label);
					_labelCount ++;
				}
				_currentCompetitorSeries = 0;
			}
			ev.HasMorePages = false;
		}
Example #31
0
        //=====================

        public static void printDocument1_PrintPage(System.Object sender,
                                                    System.Drawing.Printing.PrintPageEventArgs e)
        //==================================================================================
        {
            e.Graphics.DrawImage(mMemoryImage, 0, 0);
        }
        /// <summary>
        /// Implements StartEnd for generating print preview information.
        /// </summary>
        public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
        {
            Debug.Assert(_dc != null && _graphics == null, "PrintController methods called in the wrong order?");

            // For security purposes, don't assume our public methods methods are called in any particular order
            CheckSecurity();

            base.OnStartPage(document, e);

            if (e.CopySettingsToDevMode)
            {
                e.PageSettings.CopyToHdevmode(modeHandle);
            }

            Size size = e.PageBounds.Size;

            // Metafile framing rectangles apparently use hundredths of mm as their unit of measurement,
            // instead of the GDI+ standard hundredth of an inch.
            Size metafileSize = PrinterUnitConvert.Convert(size, PrinterUnit.Display, PrinterUnit.HundredthsOfAMillimeter);

            // Create a Metafile which accepts only GDI+ commands since we are the ones creating
            // and using this ...
            // Framework creates a dual-mode EMF for each page in the preview.
            // When these images are displayed in preview,
            // they are added to the dual-mode EMF. However,
            // GDI+ breaks during this process if the image
            // is sufficiently large and has more than 254 colors.
            // This code path can easily be avoided by requesting
            // an EmfPlusOnly EMF..
            Metafile metafile = new Metafile(_dc.Hdc, new Rectangle(0, 0, metafileSize.Width, metafileSize.Height), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusOnly);

            PreviewPageInfo info = new PreviewPageInfo(metafile, size);

            _list.Add(info);
            PrintPreviewGraphics printGraphics = new PrintPreviewGraphics(document, e);

            _graphics = Graphics.FromImage(metafile);

            if (_graphics != null && document.OriginAtMargins)
            {
                // Adjust the origin of the graphics object to be at the
                // user-specified margin location
                //
                int   dpiX           = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), SafeNativeMethods.LOGPIXELSX);
                int   dpiY           = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), SafeNativeMethods.LOGPIXELSY);
                int   hardMarginX_DU = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), SafeNativeMethods.PHYSICALOFFSETX);
                int   hardMarginY_DU = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), SafeNativeMethods.PHYSICALOFFSETY);
                float hardMarginX    = hardMarginX_DU * 100 / dpiX;
                float hardMarginY    = hardMarginY_DU * 100 / dpiY;

                _graphics.TranslateTransform(-hardMarginX, -hardMarginY);
                _graphics.TranslateTransform(document.DefaultPageSettings.Margins.Left, document.DefaultPageSettings.Margins.Top);
            }


            _graphics.PrintingHelper = printGraphics;


            if (_antiAlias)
            {
                _graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                _graphics.SmoothingMode     = SmoothingMode.AntiAlias;
            }
            return(_graphics);
        }
Example #33
0
 public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
 {
     PMSessionEndPageNoDialog(sessionHandle);
 }
Example #34
0
 public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
 {
 }
        private void _CreateReceipt(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Graphics graphic   = e.Graphics;
            Font     font      = new Font("Courier New", 9);
            Font     smallfont = new Font("Courier New", 8);
            Font     largefont = new Font("Courier New", 10, FontStyle.Bold);

            StringFormat sf = new StringFormat();

            sf.LineAlignment = StringAlignment.Center;
            sf.Alignment     = StringAlignment.Center;

            float FontHeight = font.GetHeight();
            int   startX     = 5;
            int   startY     = 30;

            // int offset = 30;
            //for (int i = 0; i <= 500; i++)
            //{
            //    graphic.DrawString(((char)170).ToString(), smallfont, new SolidBrush(Color.Black), 275, i);
            //}


            //Introduce Vuon hoa kieng ba cang
            graphic.DrawString("                      ", new Font("Courier New", 12, FontStyle.Underline), new SolidBrush(Color.Black), 30, startY);
            startY += 10;
            graphic.DrawString(".                      ", new Font("Courier New", 12, FontStyle.Underline), new SolidBrush(Color.Black), 30, startY);
            startY += 20;
            graphic.DrawString("Vườn Hoa Kiểng BÁ CANG", new Font("Courier New", 12, FontStyle.Underline), new SolidBrush(Color.Black), 30, startY);

            Bitmap original  = (Bitmap)Image.FromFile("imgCay.png");
            Bitmap resized   = new Bitmap(original, new Size(original.Width / 20, original.Height / 20));
            Image  imgBaCang = (Image)resized;

            int startXofIntroduce = startX + 95;

            startY += 30;

            graphic.DrawImage(imgBaCang, 5, startY - 7);
            graphic.DrawString("    Hoa Kiểng, BonSai", smallfont, new SolidBrush(Color.Black), startXofIntroduce, startY);
            graphic.DrawString("\n     Cây trồng, Chậu", smallfont, new SolidBrush(Color.Black), startXofIntroduce, startY);
            graphic.DrawString("\n\n   Phân, Thuốc Các loại", smallfont, new SolidBrush(Color.Black), startXofIntroduce, startY);
            graphic.DrawString("\n\n\n\n     Nhận: Bảo dưỡng,", smallfont, new SolidBrush(Color.Black), startXofIntroduce, startY);
            graphic.DrawString("\n\n\n\n\n    Chăm sóc sân vườn", smallfont, new SolidBrush(Color.Black), startXofIntroduce, startY);
            graphic.DrawString("\n\n\n\n\n\nChỉnh sửa Bonsai cao cấp", smallfont, new SolidBrush(Color.Black), startXofIntroduce, startY);
            startY += 5;
            graphic.DrawString("\n\n\n\n\n\n\n\n     358A Bình Long, p.Phú Thọ Hòa", smallfont, new SolidBrush(Color.Black), 5, startY);

            graphic.DrawString("\n\n\n\n\n\n\n\n\n       q.Tân Phú, tp.Hồ Chí Minh", smallfont, new SolidBrush(Color.Black), 5, startY);
            graphic.DrawString("\n\n\n\n\n\n\n\n\n\n     ĐT: 08.38606121 - DĐ: 0938444010", smallfont, new SolidBrush(Color.Black), 5, startY);

            startY  = startY + (int)smallfont.GetHeight() * 10 + 20;
            startY += 10;
            graphic.DrawString("\t\tHÓA ĐƠN", largefont, new SolidBrush(Color.Black), startX, startY);


            startY += 20;
            graphic.DrawString("          ----------------------", smallfont, new SolidBrush(Color.Black), startX, startY);
            startY = startY + 20;
            graphic.DrawString("Ngày: " + txtNgayHoaDon.Text, smallfont, new SolidBrush(Color.Black), 5, startY);
            graphic.DrawString("\nĐơn số: " + txtSoHoaDon.Text, smallfont, new SolidBrush(Color.Black), 5, startY);
            graphic.DrawString("\n\nKhách hàng: " + txtHoTen.Text, smallfont, new SolidBrush(Color.Black), 5, startY);
            int numberOfXuongHang = 0;



            if (txtDiaChi.Text != null && txtDiaChi.Text != "")
            {
                string        strHoTen   = txtDiaChi.Text;
                List <string> chuoiHoTen = new List <string> {
                };
                while (strHoTen.Length >= 30)
                {
                    string smallTen = "";
                    int    index    = 30;
                    if (strHoTen.Substring(0, 30).Contains(" "))
                    {
                        index = strHoTen.Substring(0, 30).LastIndexOf(' ');
                    }
                    smallTen = strHoTen.Substring(0, index);
                    strHoTen = strHoTen.Substring(index, strHoTen.Length - index);
                    chuoiHoTen.Add(smallTen);
                }
                if (strHoTen.Length > 0)
                {
                    chuoiHoTen.Add(strHoTen);
                }
                graphic.DrawString("\n\n\nĐC : " + chuoiHoTen[0], smallfont, new SolidBrush(Color.Black), 5, startY);
                if (chuoiHoTen.Count > 1)
                {
                    for (int i = 1; i <= chuoiHoTen.Count - 1; i++)
                    {
                        graphic.DrawString("\n\n\n           " + strXuongDong(i - 1) + chuoiHoTen[i], smallfont, new SolidBrush(Color.Black), 5, startY);
                        numberOfXuongHang = i;
                    }
                }
            }
            if (txtDiaChi.Text == "")
            {
                graphic.DrawString(strXuongDong(numberOfXuongHang) + "\n\nĐT: " + txtSoDienThoai.Text, smallfont, new SolidBrush(Color.Black), 5, startY);
            }
            else
            {
                graphic.DrawString(strXuongDong(numberOfXuongHang) + "\n\n\nĐT: " + txtSoDienThoai.Text, smallfont, new SolidBrush(Color.Black), 5, startY);
            }
            startY = startY + (int)smallfont.GetHeight() * (4 + numberOfXuongHang) + 20;
            graphic.DrawString("          ----------------------", smallfont, new SolidBrush(Color.Black), 5, startY);

            //datagrid view cua hoa don

            startY += 20;
            string top = "STT".PadRight(3) + "   TÊN HÀNG".PadRight(18) + "SL".PadRight(4) + "ĐƠN GIÁ";

            graphic.DrawString(top, font, new SolidBrush(Color.Black), startX, startY);
            graphic.DrawString("---------------------------------------------------------------------------------------------------------------------", font, new SolidBrush(Color.Black), startX, startY + 10);
            startY += 20;

            numberOfXuongHang = 0;

            for (int i = 0; i <= gridNhapHoaDon.Rows.Count - 2; i++)
            {
                string strStt     = "";
                string strTenHang = "";
                //string strDvt = "";
                string strSoLuong = "";
                string strDonGia  = "";

                if (gridNhapHoaDon.Rows[i].Cells[0].Value != null)
                {
                    strStt = gridNhapHoaDon.Rows[i].Cells[0].Value.ToString();
                }

                if (gridNhapHoaDon.Rows[i].Cells[1].Value != null)
                {
                    numberOfXuongHang += i;
                    strTenHang         = gridNhapHoaDon.Rows[i].Cells[1].Value.ToString();
                    List <string> chuoiTenHang = new List <string> {
                    };

                    while (strTenHang.Length >= 18)
                    {
                        string smallTen = "";
                        int    index    = 18;

                        if (strTenHang.Substring(0, 18).Contains(" "))
                        {
                            index = strTenHang.Substring(0, 18).LastIndexOf(' ');
                        }
                        smallTen   = strTenHang.Substring(0, index);
                        strTenHang = strTenHang.Substring(index, strTenHang.Length - index);
                        chuoiTenHang.Add(smallTen);
                    }
                    if (strTenHang.Length > 0)
                    {
                        chuoiTenHang.Add(strTenHang);
                    }

                    //if (gridNhapHoaDon.Rows[i].Cells[2].Value != null)
                    //    strDvt = gridNhapHoaDon.Rows[i].Cells[2].Value.ToString();

                    if (gridNhapHoaDon.Rows[i].Cells[3].Value != null)
                    {
                        strSoLuong = gridNhapHoaDon.Rows[i].Cells[3].Value.ToString();
                    }

                    if (gridNhapHoaDon.Rows[i].Cells[4].Value != null)
                    {
                        strDonGia = gridNhapHoaDon.Rows[i].Cells[4].Value.ToString().Replace(" ", ",");
                    }

                    //  if (gridNhapHoaDon.Rows[i].Cells[5].Value != null)
                    //     strThanhTien = gridNhapHoaDon.Rows[i].Cells[5].Value.ToString().Replace(" ", ",");

                    string strItem = strStt.PadRight(3) + chuoiTenHang[0].PadRight(18) + strSoLuong.PadRight(4) + strDonGia;

                    strItem = strXuongDong(numberOfXuongHang) + strItem;

                    graphic.DrawString(strItem, font, new SolidBrush(Color.Black), startX, startY);


                    if (chuoiTenHang.Count > 1)
                    {
                        numberOfXuongHang += 1;

                        for (int j = 1; j <= chuoiTenHang.Count - 1; j++)
                        {
                            graphic.DrawString(strXuongDong(numberOfXuongHang) + "".PadRight(3) + chuoiTenHang[j].PadRight(18), font, new SolidBrush(Color.Black), startX, startY);
                            numberOfXuongHang += 1;
                        }
                    }
                }
            }
            startY = startY + numberOfXuongHang * (int)font.GetHeight() + 50;
            graphic.DrawString("          ----------------------", smallfont, new SolidBrush(Color.Black), 5, startY);

            startY += 20;

            string numberTongCong = txtTongThanhTien.Text.Replace("đồng", "");

            numberTongCong = numberTongCong.TrimEnd();
            numberTongCong = numberTongCong.Replace(" ", ",");
            graphic.DrawString("Tổng: " + numberTongCong + " đ", largefont, new SolidBrush(Color.Black), 5, startY);
            startY += 10;

            string strChuSo = txtChuyenThanhChu.Text;

            List <string> chuoiChu = new List <string> {
            };

            while (strChuSo.Length >= 30)
            {
                string smallTen = "";
                int    index    = 30;

                if (strChuSo.Substring(0, 30).Contains(" "))
                {
                    index = strChuSo.Substring(0, 30).LastIndexOf(' ');
                }
                smallTen = strChuSo.Substring(0, index);
                strChuSo = strChuSo.Substring(index, strChuSo.Length - index);
                chuoiChu.Add(smallTen);
            }
            if (strChuSo.Length > 0)
            {
                chuoiChu.Add(strChuSo);
            }

            numberOfXuongHang = 0;
            graphic.DrawString("\nChữ : " + chuoiChu[0], font, new SolidBrush(Color.Black), 5, startY);
            if (chuoiChu.Count > 1)
            {
                for (int i = 1; i <= chuoiChu.Count - 1; i++)
                {
                    graphic.DrawString("\n             " + strXuongDong(i - 1) + chuoiChu[i], font, new SolidBrush(Color.Black), 5, startY);
                    numberOfXuongHang = i;
                }
            }

            startY = startY + numberOfXuongHang * (int)font.GetHeight() + 50;

            Font fontKiten = new Font("Courier New", 8, FontStyle.Underline);

            graphic.DrawString("          ----------------------", smallfont, new SolidBrush(Color.Black), 5, startY);
            startY += 20;
            graphic.DrawString("Người Nhận Hàng", fontKiten, new SolidBrush(Color.Black), 5, startY);
            graphic.DrawString("Người Viết Hóa Đơn", fontKiten, new SolidBrush(Color.Black), 140, startY);

            startY += 100;
            graphic.DrawString("Đã Nhận Đủ Tiền", fontKiten, new SolidBrush(Color.Black), 5, startY);
            startY += 100;
            graphic.DrawString(".", smallfont, new SolidBrush(Color.Black), 5, startY);
        }
Example #36
0
        //folha de impressao
        void pridoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            var      caiza      = pos.Utilizadores.Where(r => r.id__utilizador == 1).FirstOrDefault();
            Graphics grafco     = e.Graphics;
            float    fontHeight = Font.GetHeight();
            int      star       = 50;
            int      fim        = 55;
            int      ofcet      = 40;
            Font     font       = new Font("Arial Narrow", 12);



            grafco.DrawString(InfoEmpre, new Font("Arial Narrow", 14), new SolidBrush(Color.Black), star, star + ofcet);

            //grafco.DrawString("Cell  :" + Contacto, new Font("Arial Narrow", 10), new SolidBrush(Color.Black), star, fim + ofcet + 15);

            //  grafco.DrawString("Email :" + emailEmpre, new Font("Arial Narrow", 10), new SolidBrush(Color.Black), star, fim + ofcet + 30);

            //  grafco.DrawString("Niut  :" + Nuit, new Font("Arial Narrow", 10), new SolidBrush(Color.Black), star, fim + ofcet + 45);


            ofcet = ofcet + 20;
            grafco.DrawString("Nuit :" + Nuit.ToString(),
                              new Font("Arial Narrow", 12),
                              new SolidBrush(Color.Black), star, star + ofcet);
            ofcet = ofcet + 20;
            grafco.DrawString("Cell :" + Contacto,
                              new Font("Arial Narrow", 12),
                              new SolidBrush(Color.Black), star, star + ofcet);
            // grafco.DrawString("Venda N :" +Idventasgo , new Font("Arial Narrow", 12), new SolidBrush(Color.Black), star, fim + ofcet + 60);
            ofcet = ofcet + 20;
            grafco.DrawString("Ticket Date :" + DateTime.Now.ToShortDateString(),
                              new Font("Arial Narrow", 12),
                              new SolidBrush(Color.Black), star, star + ofcet);
            ofcet = ofcet + 20;
            grafco.DrawString("Venda No:" + +Idventasgo,
                              new Font("Arial Narrow", 14),
                              new SolidBrush(Color.Black), star, star + ofcet);
            ofcet = ofcet + 20;
            String underLine = "--------------------------------------------------------";

            grafco.DrawString(underLine, new Font("Arial Narrow", 10),
                              new SolidBrush(Color.Black), star, star + ofcet);
            ofcet = ofcet + 10;
            //  String lista = "quant" + "  " + " Descricao" + "  " + "Valor";

            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                int idvenda = Convert.ToInt16(Idventasgo);
                int quant   = Convert.ToInt16(dataGridView1[3, i].Value);
                if (quant != 0)
                {
                    String   nome  = Convert.ToString(dataGridView1[1, i].Value).PadRight(30);
                    Decimal  prexo = Convert.ToDecimal(dataGridView1[2, i].Value);
                    int      idpro = Convert.ToInt16(dataGridView1[0, i].Value);
                    DateTime data  = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    Decimal  total = Convert.ToDecimal(dataGridView1[5, i].Value);

                    String listadevendas = quant + "  " + nome + "  :" + total + " Mzn";
                    grafco.DrawString(listadevendas, new Font("Arial Narrow", 12),
                                      new SolidBrush(Color.Black), star, star + ofcet);
                    ofcet += (int)FontHeight + 5;
                    //MessageBox.Show("Problema vou imprimir");
                }
            }
            ofcet = ofcet + 10;
            grafco.DrawString(underLine, new Font("Arial Narrow", 10),
                              new SolidBrush(Color.Black), star, star + ofcet);

            ofcet = ofcet + 20;
            grafco.DrawString("Total pago ".PadRight(30) + valr + " Mzn", font, new SolidBrush(Color.Black), star, fim + ofcet);
            // grafco.DrawString("Data ".PadRight(30) +DateTime .UtcNow .Date.ToShortDateString () , font, new SolidBrush(Color.Black), star, fim + ofcet+15);
            ofcet = ofcet + 20;
            grafco.DrawString("Caixa :" + caiza.nome_utiliza,
                              new Font("Arial Narrow", 12),
                              new SolidBrush(Color.Black), star, star + ofcet);
        }
Example #37
0
        public void CreateReceipt(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //this prints the reciept

            Graphics graphic = e.Graphics;

            Font font = new Font("Courier New", 12); //must use a mono spaced font as the spaces need to line up

            float fontHeight = font.GetHeight();

            int startX = 10;
            int startY = 10;
            int offset = 40;

            graphic.DrawString("Nhà hàng Thiên Bút Restaurant", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY);
            string top = "Tên món".PadRight(20) + "SL".PadRight(10) + "Đ.Giá".PadRight(10) + "Thành tiền";

            graphic.DrawString(top, font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)fontHeight;     //make the spacing consistent
            graphic.DrawString("--------------------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)fontHeight + 5; //make the spacing consistent



            foreach (ListViewItem item in lsvBill.Items)
            {
                string t = item.SubItems[0].Text.ToString();
                if (t.Length >= 13)
                {
                    t  = t.Substring(0, 13);
                    t += "...";
                }
                graphic.DrawString(t.PadRight(20) + item.SubItems[1].Text.ToString().PadRight(10) + item.SubItems[2].Text.ToString().PadRight(10) + item.SubItems[3].Text.ToString(), new Font("Courier New", 12, FontStyle.Italic), new SolidBrush(Color.Red), startX, startY + offset);

                offset = offset + (int)fontHeight + 5; //make the spacing consistent
            }


            graphic.DrawString("--------------------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)fontHeight + 5; //make the spacing consistent
            //when we have drawn all of the items add the total

            offset = offset + 20; //make some room so that the total stands out.

            graphic.DrawString("Total  ".PadRight(40) + txtTotalPrice.Text.ToString(), new Font("Courier New", 12, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

            int discount = (int)nmDisCount.Value;
            //MessageBox.Show(discount.ToString());
            float totalPrice;

            string[] Str_total = txtTotalPrice.Text.ToString().Split('.');
            if (Str_total.Length == 2)
            {
                totalPrice = float.Parse(Str_total[0]);
            }
            else
            {
                totalPrice = float.Parse(Str_total[0]) * 1000 + float.Parse(Str_total[1]);
            }
            //MessageBox.Show(totalPrice.ToString());
            float finalTotalPrice = (1 - (float)discount / 100) * totalPrice * 1000;

            offset = offset + 20; //make some room so that the total stands out.

            graphic.DrawString("Sales ".PadRight(40) + discount.ToString() + "%", new Font("Courier New", 12, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

            CultureInfo culture = new CultureInfo("vi-VN");

            offset = offset + 40; //make some room so that the total stands out.

            graphic.DrawString("Total to pay ".PadRight(40) + finalTotalPrice.ToString("c", culture), new Font("Courier New", 12, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
        }
Example #38
0
        public void    Report_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            float hozPosFloat = 15.0f;
            float verPosFoat  = 15.0f;
            float leftbianJu  = 5;
            float topbianJu   = 5;


            Pen line = new  Pen(Color.Black, 1.0f);


            //Draw  frame  and  blue  patches
            e.Graphics.FillRectangle(Brushes.DarkBlue, leftbianJu, topbianJu, 461, 50);
            e.Graphics.FillRectangle(Brushes.DarkBlue, leftbianJu, topbianJu + 100, 461, 20);


            e.Graphics.DrawRectangle(line, leftbianJu, topbianJu + 122, 460, 60);
            e.Graphics.DrawRectangle(line, leftbianJu, topbianJu + 122, 460, 100);
            e.Graphics.FillRectangle(Brushes.DarkBlue, leftbianJu, topbianJu + 225, 461, 20);


            e.Graphics.DrawRectangle(line, leftbianJu, topbianJu + 247, 460, 60);
            e.Graphics.FillRectangle(Brushes.DarkBlue, leftbianJu, topbianJu + 309, 461, 20);


            e.Graphics.DrawRectangle(line, leftbianJu, topbianJu + 331, 460, 100);
            e.Graphics.FillRectangle(Brushes.DarkBlue, leftbianJu, topbianJu + 434, 461, 20);


            e.Graphics.DrawRectangle(line, leftbianJu, topbianJu + 456, 460, 100);
            e.Graphics.FillRectangle(Brushes.DarkBlue, leftbianJu, topbianJu + 560, 461, 20);


            e.Graphics.DrawRectangle(line, leftbianJu, topbianJu + 581, 460, 50);

            //Paystubs,  2013,Fill  the  form  with  instructions
            e.Graphics.DrawString("Pay    Stubs", new    Font("Kozuka    Mincho    Pro    B", 9, FontStyle.Bold),
                                  Brushes.White, hozPosFloat + 200, verPosFoat + 20);
            e.Graphics.DrawString("Summary", new     Font("Kozuka	Mincho	Pro	B", 6, FontStyle.Bold),
                                  Brushes.White, hozPosFloat, 112);

            e.Graphics.DrawString("Name\t\t\t\t\t\tAddress", new  Font("Kozuka  Mincho  Pro    B", 7, FontStyle.Bold),
                                  Brushes.Black, hozPosFloat, 131);
            e.Graphics.DrawString("Employee	ID\t\tSSN\t\tDate	from\tDate	to", new
                                  Font("Kozuka  Mincho  Pro  B", 7, FontStyle.Bold), Brushes.Black, hozPosFloat, 192);
            e.Graphics.DrawString("Gross    Pay", new    Font("Kozuka    Mincho    Pro    B", 6, FontStyle.Bold),
                                  Brushes.White, hozPosFloat, 237);
            e.Graphics.DrawString("Amount", new     Font("Kozuka	Mincho	Pro	B", 7, FontStyle.Bold),
                                  Brushes.Black, hozPosFloat, 256);
            e.Graphics.DrawString("Taxes", new     Font("Kozuka	Mincho	Pro	B", 6, FontStyle.Bold),
                                  Brushes.White, hozPosFloat, 321);
            e.Graphics.DrawString("Type\t\t\t\t\tAmount", new Font("Kozuka Mincho Pro B",
                                                                   7, FontStyle.Bold),
                                  Brushes.Black, hozPosFloat, 345);
            e.Graphics.DrawString("Social	Security	Tax", new     Font("Arial", 6, FontStyle.Regular),
                                  Brushes.Black, hozPosFloat, 368);
            e.Graphics.DrawString("Fed	Income	Tax", new     Font("Arial", 6, FontStyle.Regular),
                                  Brushes.Black, hozPosFloat, 388);
            e.Graphics.DrawString("State	Income	Tax", new     Font("Arial", 6, FontStyle.Regular),
                                  Brushes.Black, hozPosFloat, 408);
            e.Graphics.DrawString("Deduction", new    Font("Kozuka    Mincho    Pro    B", 6, FontStyle.Regular),
                                  Brushes.White, hozPosFloat, 446);
            e.Graphics.DrawString("Type\t\t\t\t\tAmount", new Font("Kozuka Mincho Pro B",
                                                                   7, FontStyle.Bold),
                                  Brushes.Black, hozPosFloat, 468);
            e.Graphics.DrawString("Net	Pay", new     Font("Kozuka	Mincho	Pro	B", 6, FontStyle.Bold),
                                  Brushes.White, hozPosFloat, 572);
            e.Graphics.DrawString("Amount", new     Font("Kozuka	Mincho	Pro	B", 7, FontStyle.Bold),
                                  Brushes.Black, hozPosFloat, 592);


            //Fill  the  blank  with  data
            e.Graphics.DrawString(nameString, new  Font("Arial", 8, FontStyle.Regular), Brushes.Black, hozPosFloat, 150);

            e.Graphics.DrawString(grossPayDecimal.ToString(), new Font("Arial", 7, FontStyle.Regular), Brushes.Black, hozPosFloat, 280);

            e.Graphics.DrawString(socialSecurityTaxDecimal.ToString(), new Font("Arial", 6, FontStyle.Regular), Brushes.Black, hozPosFloat + 200, 368);


            e.Graphics.DrawString(fedIncomeTaxDecimal.ToString(), new Font("Arial", 6, FontStyle.Regular), Brushes.Black, hozPosFloat + 200, 388);


            e.Graphics.DrawString(stateIncomeTaxDecimal.ToString(), new Font("Arial", 6, FontStyle.Regular), Brushes.Black, hozPosFloat + 200, 408);


            e.Graphics.DrawString(netPayDecimal.ToString(), new Font("Arial", 7, FontStyle.Regular), Brushes.Black, hozPosFloat, 605);
        }
Example #39
0
 /// <summary>
 /// Raises the <see cref='PrintPage'/> event.
 /// </summary>
 protected internal virtual void OnPrintPage(PrintPageEventArgs e)
 {
     _printPageHandler?.Invoke(this, e);
 }
Example #40
0
File: ctlQC.cs Project: ewin66/HIS
 //打印
 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     this.OnPaint(new PaintEventArgs(e.Graphics, e.PageBounds));
 }
 private void PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     //Print the contents.
     e.Graphics.DrawImage(bitmap, 0, 0);
 }
Example #42
0
 protected void printDocument1_PrintPage(System.Object sender,
                                         System.Drawing.Printing.PrintPageEventArgs e)
 {
     e.Graphics.DrawImage(bmp, 0, 0);
 }
Example #43
0
 private void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     e.Graphics.DrawImage(memoryImage, 0, 0);
 }
        private void frmPreview_m_evtPrintFrame(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
//			m_mthPrintTitleInfo(e);
//			m_mthPrintRectangleInfo(e);
//			m_mthPrintHeaderInfo(e);
        }
Example #45
0
        private static void PDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            long                tranId = 0;
            string              client_name = "", client_address = "";
            double              total_price = 0, total_discount = 0;
            DateTime?           tran_datetime = default(DateTime?);
            List <classes.Item> items         = new List <classes.Item>();

            bool             print = false;
            SQLiteDataReader dr    = Database.executeReader("select * from _transaction where tranId=@id", new SQLiteParameter[] { new SQLiteParameter("@id", printTranID) });

            if (dr.Read())
            {
                tranId = long.Parse(dr["tranId"].ToString());
                long clientId = long.Parse(dr["tranClientId"].ToString());
                total_price = double.Parse(dr["tranTotalPrice"].ToString());
                try
                {
                    total_discount = double.Parse(dr["tranTotalDiscount"].ToString());
                }
                catch (Exception) { }

                try
                {
                    tran_datetime = (DateTime?)dr["tranTime"];
                }
                catch (Exception) { }

                if (clientId == 0)
                {
                }
                else
                {
                    SQLiteDataReader dr2 = Database.executeReader("select * from _client where clientId=@id", new SQLiteParameter[] { new SQLiteParameter("@id", clientId) });
                    if (dr2.Read())
                    {
                        client_name    = dr2["clientName"].ToString();
                        client_address = dr2["clientAddress"].ToString();
                    }
                    dr2.Close();
                }

                SQLiteDataReader dr1 = Database.executeReader("select * from _transaction_data,_item where dataItemId=itemId and dataTranId=@id", new SQLiteParameter[] { new SQLiteParameter("@id", printTranID) });
                while (dr1.Read())
                {
                    classes.Item item = new classes.Item();
                    item.itemName = dr1["itemName"].ToString();
                    item.qty      = double.Parse(dr1["dataQty"].ToString());
                    item.itemPPU  = (item.qty * double.Parse(dr1["dataPPU"].ToString())) - double.Parse(dr1["dataDiscount"].ToString());
                    items.Add(item);
                }
                print = true;
            }
            dr.Close();

            if (print)
            {
                Font       baseFont = new Font(FontFamily.GenericSansSerif, 16);
                SolidBrush blackBrush = new SolidBrush(Color.Black);
                SolidBrush grayBrush = new SolidBrush(Color.Gray);
                Graphics   g = e.Graphics;
                float      x = 10, y = 10;
                g.DrawString(Properties.Settings.Default.appOwner, baseFont, blackBrush, x, y);
                y += baseFont.Height + 5;

                baseFont = new Font(FontFamily.GenericSansSerif, 14);
                g.DrawString("SSS AGENCY", baseFont, grayBrush, x, y);
                y += baseFont.Height + 5;

                g.DrawString("MANGALAM", baseFont, grayBrush, x, y);
                y += baseFont.Height + 5;

                g.DrawString("PERAMBALUR", baseFont, grayBrush, x, y);
                //y += baseFont.Height + 5;

                baseFont = new Font(FontFamily.GenericSansSerif, 14);
                //g.DrawString("", baseFont, blackBrush, x, y);
                g.DrawString("INVOICE NUMBER", baseFont, blackBrush, 400, 10);
                g.DrawString("#" + tranId, new Font(baseFont.FontFamily, 10), blackBrush, 400, 10 + baseFont.Height + 5);

                y += baseFont.Height + 15;
                g.DrawLine(new Pen(blackBrush, 10), x, y, e.PageBounds.Width - 10, y);
                y += baseFont.Height;


                baseFont = new Font(FontFamily.GenericSansSerif, 10);

                g.DrawString("Bill To:", new Font(baseFont, FontStyle.Bold), blackBrush, x, y);
                x += g.MeasureString("Bill To: ", baseFont).Width + 5;
                g.DrawString(client_name, baseFont, blackBrush, x, y);


                if (tran_datetime.HasValue)
                {
                    string dateTimeString = tran_datetime.Value.ToString("dd-MM-yyyy hh:mm tt");
                    float  widthOfDTS     = g.MeasureString(dateTimeString, baseFont).Width;
                    g.DrawString(dateTimeString, new Font(baseFont, FontStyle.Italic), blackBrush, e.PageBounds.Width - widthOfDTS - 20, y);
                }

                int gap1 = 10, gap2 = 250, gap3 = 200;

                y += (baseFont.Height * 2);
                x  = gap1;
                g.DrawString("Items", new Font(baseFont, FontStyle.Bold), blackBrush, x, y);
                x += gap2;
                g.DrawString("Qty x Rate", new Font(baseFont, FontStyle.Bold), blackBrush, x, y);
                x += gap3;
                g.DrawString("Amount", new Font(baseFont, FontStyle.Bold), blackBrush, x, y);
                y += baseFont.Height + 5;
                x  = gap1;
                g.DrawLine(new Pen(blackBrush, 1), x, y, e.PageBounds.Width - 10, y);
                y += baseFont.Height;

                foreach (classes.Item item in items)
                {
                    x = gap1;
                    g.DrawString(item.itemName, baseFont, blackBrush, x, y);
                    x += gap2;
                    double itemRate = item.itemPPU / item.qty;
                    g.DrawString(item.qty.ToString("0.00") + " x " + itemRate.ToString("0.00"), baseFont, blackBrush, x, y);
                    x += gap3;
                    g.DrawString(item.itemPPU.ToString("0.00"), baseFont, blackBrush, x, y);
                    y += baseFont.Height + 7;
                    g.DrawLine(new Pen(new SolidBrush(Color.DimGray), 1), 10, y, e.PageBounds.Width - 10, y);
                    y += 7;
                }

                x = gap1;
                //g.DrawLine(new Pen(blackBrush, 5), x, y, e.PageBounds.Width - 10, y);
                y += baseFont.Height + 10;

                x = gap2 + gap1;
                g.DrawString("Total: ", baseFont, blackBrush, x, y);
                x = gap1 + gap2 + gap3;
                g.DrawString((total_discount + total_price).ToString("0.00"), baseFont, blackBrush, x, y);
                y += baseFont.Height + 5;
                g.DrawLine(new Pen(new SolidBrush(Color.DimGray), 1), x - gap3, y, e.PageBounds.Width - 10, y);
                y += 5;


                x = gap1 + gap2;
                g.DrawString("Discount: ", baseFont, blackBrush, x, y);
                x = gap1 + gap2 + gap3;
                g.DrawString(total_discount.ToString("0.00"), baseFont, blackBrush, x, y);
                y += baseFont.Height + 5;
                g.DrawLine(new Pen(new SolidBrush(Color.DimGray), 1), x - gap3, y, e.PageBounds.Width - 10, y);
                y += 5;

                x = gap1 + gap2;
                g.DrawString("Final Amount: ", baseFont, blackBrush, x, y);
                x = gap1 + gap2 + gap3;
                g.DrawString(total_price.ToString("0.00"), baseFont, blackBrush, x, y);
                y += baseFont.Height + 5;
                g.DrawLine(new Pen(new SolidBrush(Color.DimGray), 1), x - gap3, y, e.PageBounds.Width - 10, y);
                y += 5;

                x = 10;
                y = e.PageBounds.Height - baseFont.Height * 4;
                g.DrawLine(new Pen(new SolidBrush(Color.DimGray), 1), x, y, e.PageBounds.Width - 10, y);
                y += 15;

                g.DrawString("SSS", new Font(baseFont, FontStyle.Bold), blackBrush, x, y);
                g.DrawString("SSS", new Font(baseFont, FontStyle.Bold), blackBrush, e.PageBounds.Width - 15 - g.MeasureString("SSS", baseFont).Width, y);
                y += baseFont.Height + 5;
                g.DrawString("###", baseFont, blackBrush, x, y);
                g.DrawString("###", baseFont, blackBrush, e.PageBounds.Width - 10 - g.MeasureString("###", baseFont).Width, y);

                //total_price.ToString("0.00")
                //total_discount.ToString("0.00")
                //double vat = total_price * Properties.Settings.Default.appSettingVAT / 100;
                //g.DrawString("VAT: " + vat.ToString("0.00"), baseFont, blackBrush, x, y);
                //vat += total_price;
            }
        }
Example #46
0
        // The PrintPage event is raised for each page to be printed.
        private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            int   total  = 0;
            float cash   = 0.00f;
            float change = 0.00f;

            //this prints the reciept

            Graphics graphic = e.Graphics;

            Font font = new Font("Courier New", 10); //must use a mono spaced font as the spaces need to line up

            float fontHeight = font.GetHeight();

            int    startX = 20;
            int    startY = 5;
            int    offset = 20 * printFormat.lineBreakOnTop;
            String kotType = "", printCaption = "";

            if (printerNumber == 1)
            {
                printCaption = kotTitle;
            }
            else
            {
                printCaption = kotTitle2;
            }

            if (printFormat.showCompanyName == "Y")
            {
                string companyName = printFormat.companyName;

                graphic.DrawString(companyName, new Font("Courier New", 11, FontStyle.Regular), new SolidBrush(Color.Black), startX, startY + offset);
            }

            offset = offset + (int)fontHeight;//make the spacing consistent

            graphic.DrawString("        ".PadRight(8) + printCaption, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight;

            if (isprint == "Y")
            {
                // kotType = printFormat.normalPrint;
            }

            if (isreprint == "Y")
            {
                kotType = printFormat.rePrint;
            }
            if (iscancelled == "Y")
            {
                kotType = printFormat.cancelledPrint;
            }
            // graphic.DrawString(kotType, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX + 90, startY+ offset );

            // offset = offset + (int)fontHeight;
            graphic.DrawString("-----------------------------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)fontHeight;

            //string kotnoanddate = "KOT No:" + printerPrintData.kotNumber.ToString().PadRight(5) + " Date:" + DateTime.Now.ToString("dd/MM/yy");
            string kotnoanddate = "Date:" + (DateTime.Now.ToString("dd/MMM HH:mm")).ToString().PadRight(15) + " Cap: " + caps;

            graphic.DrawString(kotnoanddate, new Font("Courier New", 10, FontStyle.Regular), new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)fontHeight;

            graphic.DrawString("-----------------------------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)fontHeight;

            // string kottime = "KOT Time: " + DateTime.Now.ToString("h:mm:ss tt");
            // graphic.DrawString(kottime, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
            // offset = offset + (int)fontHeight;

            string wtrandtableid = "Tbl: " + tableName.ToString().PadRight(6) + "PAX: " + printerPrintData.PAX.ToString().PadRight(6) + "Wtr: " + printerPrintData.waiterId;

            graphic.DrawString(wtrandtableid, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)fontHeight;

            //string pax = "PAX :" + printerPrintData.PAX;
            //graphic.DrawString(pax, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

            //offset = offset + (int)fontHeight;
            graphic.DrawString("-----------------------------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 3; //make the spacing consistent
            string top = "Item Name".PadRight(24) + " QTY";

            graphic.DrawString(top, new Font("Courier New", 10, FontStyle.Regular), new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)fontHeight;     //make the spacing consistent
            graphic.DrawString("-----------------------------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)fontHeight + 2; //make the spacing consistent

            int totalprice = 0;

            if (!isCounterCopy)
            {
                foreach (PrintData item in printObject[printObject.Keys.ElementAt(printingIndex)])
                {
                    //create the string to print on the reciept
                    string productDescription = item.ItemName.PadRight(24) + " " + String.Format("{0:0.##}", item.KOTQuantity);
                    // string productTotal = item.Substring(item.Length - 6, 6);

                    //MessageBox.Show(item.Substring(item.Length - 5, 5) + "PROD TOTAL: " + productTotal);

                    totalprice += Convert.ToInt32(item.KOTQuantity);

                    if (productDescription.Contains("  -"))
                    {
                        string productLine = productDescription.Substring(0, 24);

                        graphic.DrawString(productLine, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Red), startX, startY + offset);

                        offset = offset + (int)fontHeight; //make the spacing consistent
                    }
                    else
                    {
                        string productLine = productDescription;

                        graphic.DrawString(productLine, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

                        offset = offset + (int)fontHeight; //make the spacing consistent

                        string additionalInst = "'" + item.AdditionalInstructions + "'";
                        if (additionalInst != "''")
                        {
                            graphic.DrawString(additionalInst, new Font("Courier New", 8, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

                            offset = offset + (int)fontHeight;
                        }
                    }
                }
            }
            else
            {
                foreach (PrintData item in counterPrint)
                {
                    //create the string to print on the reciept
                    string productDescription = item.ItemName.PadRight(24) + " " + String.Format("{0:0.##}", item.KOTQuantity);
                    // string productTotal = item.Substring(item.Length - 6, 6);

                    //MessageBox.Show(item.Substring(item.Length - 5, 5) + "PROD TOTAL: " + productTotal);

                    totalprice += Convert.ToInt32(item.KOTQuantity);

                    if (productDescription.Contains("  -"))
                    {
                        string productLine = productDescription.Substring(0, 24);

                        graphic.DrawString(productLine, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Red), startX, startY + offset);

                        offset = offset + (int)fontHeight; //make the spacing consistent
                    }
                    else
                    {
                        string productLine = productDescription;

                        graphic.DrawString(productLine, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

                        offset = offset + (int)fontHeight; //make the spacing consistent

                        string additionalInst = "'" + item.AdditionalInstructions + "'";
                        if (additionalInst != "''")
                        {
                            graphic.DrawString(additionalInst, new Font("Courier New", 8, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

                            offset = offset + (int)fontHeight;
                        }
                    }
                }
            }

            //offset = offset + (int)fontHeight;
            graphic.DrawString("-----------------------------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);


            // change = (cash - totalprice);

            //when we have drawn all of the items add the total

            offset = offset + 20; //make some room so that the total stands out.

            graphic.DrawString("         Total Qty : ".PadRight(8) + totalprice, new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (20 * printFormat.lineBreakOnBottom);
            graphic.DrawString("         ... ", new Font("Courier New", 12, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
        }
Example #47
0
        private void _printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //try
            //{
            //Set the left margin
            int iLeftMargin = e.MarginBounds.Left;
            //Set the top margin
            int iTopMargin = e.MarginBounds.Top;
            //Whether more pages have to print or not
            bool bMorePagesToPrint = false;
            int iTmpWidth = 0;

            //For the first page to print set the cell width and header height
            if (bFirstPage)
            {
                foreach (DataGridViewColumn GridCol in gw.Columns)
                {
                    iTmpWidth = (int)(Math.Floor((double)((double)GridCol.Width /
                        (double)iTotalWidth * (double)iTotalWidth *
                        ((double)e.MarginBounds.Width / (double)iTotalWidth))));

                    iHeaderHeight = (int)(e.Graphics.MeasureString(GridCol.HeaderText,
                        GridCol.InheritedStyle.Font, iTmpWidth).Height) + 11;

                    // Save width and height of headers
                    arrColumnLefts.Add(iLeftMargin);
                    arrColumnWidths.Add(iTmpWidth);
                    iLeftMargin += iTmpWidth;
                }
            }
            //Loop till all the grid rows not get printed
            while (iRow <= gw.Rows.Count - 1)
            {
                DataGridViewRow GridRow = gw.Rows[iRow];
                //Set the cell height
                iCellHeight = GridRow.Height + 5;
                int iCount = 0;
                //Check whether the current page settings allows more rows to print
                if (iTopMargin + iCellHeight >= e.MarginBounds.Height + e.MarginBounds.Top)
                {
                    bNewPage = true;
                    bFirstPage = false;
                    bMorePagesToPrint = true;
                    break;
                }
                else
                {

                    if (bNewPage)
                    {
                        //Draw Header
                        e.Graphics.DrawString(_ReportHeader,
                            new Font(gw.Font, FontStyle.Bold),
                            Brushes.Black, e.MarginBounds.Left,
                            e.MarginBounds.Top - e.Graphics.MeasureString(_ReportHeader,
                            new Font(gw.Font, FontStyle.Bold),
                            e.MarginBounds.Width).Height - 13);

                        String strDate = "";
                        //Draw Date
                        e.Graphics.DrawString(strDate,
                            new Font(gw.Font, FontStyle.Bold), Brushes.Black,
                            e.MarginBounds.Left +
                            (e.MarginBounds.Width - e.Graphics.MeasureString(strDate,
                            new Font(gw.Font, FontStyle.Bold),
                            e.MarginBounds.Width).Width),
                            e.MarginBounds.Top - e.Graphics.MeasureString(_ReportHeader,
                            new Font(new Font(gw.Font, FontStyle.Bold),
                            FontStyle.Bold), e.MarginBounds.Width).Height - 13);

                        //Draw Columns                 
                        iTopMargin = e.MarginBounds.Top;
                        DataGridViewColumn[] _GridCol = new DataGridViewColumn[gw.Columns.Count];
                        int colcount = 0;
                        //Convert ltr to rtl
                        foreach (DataGridViewColumn GridCol in gw.Columns)
                        {
                            _GridCol[colcount++] = GridCol;
                        }
                        for (int i = (_GridCol.Count() - 1); i >= 0; i--)
                        {
                            e.Graphics.FillRectangle(new SolidBrush(Color.LightGray),
                                new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                                (int)arrColumnWidths[iCount], iHeaderHeight));

                            e.Graphics.DrawRectangle(Pens.Black,
                                new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                                (int)arrColumnWidths[iCount], iHeaderHeight));

                            e.Graphics.DrawString(_GridCol[i].HeaderText,
                                _GridCol[i].InheritedStyle.Font,
                                new SolidBrush(_GridCol[i].InheritedStyle.ForeColor),
                                new RectangleF((int)arrColumnLefts[iCount], iTopMargin,
                                (int)arrColumnWidths[iCount], iHeaderHeight), strFormat);
                            iCount++;
                        }
                        bNewPage = false;
                        iTopMargin += iHeaderHeight;
                    }
                    iCount = 0;
                    DataGridViewCell[] _GridCell = new DataGridViewCell[GridRow.Cells.Count];
                    int cellcount = 0;
                    //Convert ltr to rtl
                    foreach (DataGridViewCell Cel in GridRow.Cells)
                    {
                        _GridCell[cellcount++] = Cel;
                    }
                    //Draw Columns Contents                
                    for (int i = (_GridCell.Count() - 1); i >= 0; i--)
                    {
                        if (_GridCell[i].Value != null)
                        {
                            e.Graphics.DrawString(_GridCell[i].FormattedValue.ToString(),
                                _GridCell[i].InheritedStyle.Font,
                                new SolidBrush(_GridCell[i].InheritedStyle.ForeColor),
                                new RectangleF((int)arrColumnLefts[iCount],
                                (float)iTopMargin,
                                (int)arrColumnWidths[iCount], (float)iCellHeight),
                                strFormat);
                        }
                        //Drawing Cells Borders 
                        e.Graphics.DrawRectangle(Pens.Black,
                            new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                            (int)arrColumnWidths[iCount], iCellHeight));
                        iCount++;
                    }
                }
                iRow++;
                iTopMargin += iCellHeight;
            }
            //If more lines exist, print another page.
            if (bMorePagesToPrint)
                e.HasMorePages = true;
            else
                e.HasMorePages = false;
            //}
            //catch (Exception exc)
            //{
            //    MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK,
            //       MessageBoxIcon.Error);
            //}
        }
Example #48
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            PrinterResolution pr = e.PageSettings.PrinterResolution;

            DrawForm(e.Graphics, pr.X, pr.Y);
        }
 public virtual void OnEndPage(PrintDocument document, PrintPageEventArgs e)
 {
 }
Example #50
0
        //EVENTO PARA IMPRESSÂO DOS DADOS
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            RelatorioEstoque re = new RelatorioEstoque(sender, e);

            re.Relatorio();
        }
Example #51
0
        private void _CreateReceipt(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            double total = 0;
            double sale = 0, custome_pay = 0, custome_return = 0;
            string code_bill = "", created = "", total_price = "", money = "", doitra = "", branchtype = "", address = "", phone = "", website = "", facebook = "", type = "", membername = "", memberphone = "", createdby = "", score = "";
            var    s = db.sp_getBillById(code);
            int    i = 0;

            Graphics graphic = e.Graphics;

            Font   font       = new Font("Tahoma", 8);
            float  FontHeight = font.GetHeight();
            int    startX     = 0;
            int    startY     = 10;
            int    offset     = 40;
            string line       = "-----------------------------------------------------";
            int    font_size  = 7;

            //--detail
            foreach (var item in s.ToList())
            {
                if (i == 0)
                {
                    code_bill   = item.StockCode;
                    created     = item.CreateAt.Value.ToString("dd/MM/yyyy HH:mm:ss");
                    doitra      = item.Doitra;
                    address     = item.BranchName.Split('#')[0];
                    phone       = item.BranchName.Split('#')[1];
                    branchtype  = item.BranchType.Split('#')[0];
                    website     = item.BranchType.Split('#')[1];
                    facebook    = item.BranchType.Split('#')[2];
                    total_price = string.Format("{0:0,0 đ}", item.Total.Value);
                    sale        = item.TotalDiscount;
                    total       = item.TotalPrice.Value;
                    score       = item.Score > 999 ? string.Format("{0:0,0 đ}", item.Score.Value) : item.Score.ToString();

                    custome_pay    = item.CustomePay.Value;
                    custome_return = item.CustomeReturn.Value;

                    if (item.MemberName != "")
                    {
                        membername  = item.MemberName.Split('#')[0];
                        memberphone = item.MemberName.Split('#')[1];
                    }
                    createdby = item.CreatedBy;
                    type      = item.OutputType;

                    graphic.DrawString(branchtype, new Font("Tahoma", 15), new SolidBrush(Color.Black), startX + 50, startY);

                    graphic.DrawString("Địa chỉ: " + address, new Font("Tahoma", 7), new SolidBrush(Color.Black), startX, startY + 30);

                    offset = offset + (int)FontHeight;
                    graphic.DrawString(phone, new Font("Tahoma", 7), new SolidBrush(Color.Black), startX, startY + offset - 5);

                    offset = offset + (int)FontHeight;
                    graphic.DrawString("Website: " + website, new Font("Tahoma", 7), new SolidBrush(Color.Black), startX, startY + offset);

                    offset = offset + (int)FontHeight + 5;
                    graphic.DrawString("Facebook: " + facebook, new Font("Tahoma", 7), new SolidBrush(Color.Black), startX, startY + offset);

                    offset = offset + (int)FontHeight + 10;
                    graphic.DrawString(type, new Font("Tahoma", 10), new SolidBrush(Color.Black), startX + 30, startY + offset);

                    offset = offset + (int)FontHeight + 10;
                    graphic.DrawString("(Số HĐ: " + code_bill + ")", new Font("Tahoma", font_size, FontStyle.Italic), new SolidBrush(Color.Black), startX + 30, startY + offset);


                    offset = offset + (int)FontHeight + 3;
                    graphic.DrawString("Ngày HĐ: " + created, new Font("Tahoma", font_size), new SolidBrush(Color.Black), startX, startY + offset);

                    offset = offset + (int)FontHeight + 3;
                    graphic.DrawString("Thu Ngân: " + createdby, new Font("Tahoma", font_size), new SolidBrush(Color.Black), startX, startY + offset);

                    if (membername != "")
                    {
                        offset = offset + (int)FontHeight + 3;
                        graphic.DrawString("Khách hàng: " + membername, new Font("Tahoma", font_size), new SolidBrush(Color.Black), startX, startY + offset);

                        offset = offset + (int)FontHeight + 3;
                        graphic.DrawString("Điện thoại: " + memberphone, new Font("Tahoma", font_size), new SolidBrush(Color.Black), startX, startY + offset);

                        offset = offset + (int)FontHeight + 5;
                        graphic.DrawString("Tổng tiền tích lũy: " + score, new Font("Tahoma", font_size), new SolidBrush(Color.Black), startX, startY + offset);
                    }

                    offset = offset + (int)FontHeight + 5;
                    graphic.DrawString(line, new Font("Tahoma", 7, FontStyle.Regular), new SolidBrush(Color.Black), startX, startY + offset);

                    offset = offset + (int)FontHeight;
                    string top = "STT".PadRight(4) + "Tên hàng".PadRight(10) + "SL x ĐG".PadRight(15) + "Thành tiền";
                    graphic.DrawString(top, new Font("Tahoma", 7, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

                    offset = offset + (int)FontHeight;
                    graphic.DrawString(line, new Font("Tahoma", 7, FontStyle.Regular), new SolidBrush(Color.Black), startX, startY + offset);
                }

                offset = offset + (int)FontHeight + 3;
                graphic.DrawString((i + 1).ToString(), new Font("Tahoma", 6, FontStyle.Bold), new SolidBrush(Color.Black), startX + 5, startY + offset);
                graphic.DrawString(item.ProductCode + " - " + item.ProductName, new Font("Tahoma", 7, FontStyle.Regular), new SolidBrush(Color.Black), startX + 20, startY + offset);

                if (item.Discount > 0)
                {
                    offset = offset + (int)FontHeight + 5;
                    graphic.DrawString(item.Quantity.Value.ToString("D2") + " x " + string.Format("{0:#,#}", item.Price.Value - item.Discount) + " = " + string.Format("{0:#,#}", item.Quantity.Value * (item.Price.Value - item.Discount)), new Font("Tahoma", 7, FontStyle.Regular), new SolidBrush(Color.Black), startX + 70, startY + offset);

                    offset = offset + (int)FontHeight + 5;
                    if (item.DiscountPercent > 0)
                    {
                        graphic.DrawString("Đơn giá: " + string.Format("{0:#,#}", item.Price.Value) + " chiết khấu " + item.DiscountPercent.ToString() + " %", new Font("Tahoma", 6, FontStyle.Italic), new SolidBrush(Color.Black), startX + 25, startY + offset);
                    }
                    else
                    {
                        graphic.DrawString("Đơn giá: " + string.Format("{0:#,#}", item.Price.Value) + " chiết khấu " + string.Format("{0:#,#}", item.Discount), new Font("Tahoma", 6, FontStyle.Italic), new SolidBrush(Color.Black), startX + 25, startY + offset);
                    }
                }
                else
                {
                    offset = offset + (int)FontHeight + 5;
                    graphic.DrawString(item.Quantity.Value.ToString("D2") + " x " + string.Format("{0:#,#}", item.Price.Value) + " = " + string.Format("{0:#,#}", item.Quantity.Value * item.Price.Value), new Font("Tahoma", 7, FontStyle.Regular), new SolidBrush(Color.Black), startX + 70, startY + offset);
                }
                i++;
            }

            //--end detail

            offset = offset + 10;
            graphic.DrawString(line, new Font("Tahoma", 7, FontStyle.Regular), new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)FontHeight + 5;
            graphic.DrawString("Tổng tiền hàng ", new Font("Tahoma", font_size, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
            graphic.DrawString(total_price, font, new SolidBrush(Color.Black), startX + 125, startY + offset);

            offset = offset + (int)FontHeight + 5;
            graphic.DrawString("Chiết khấu ", new Font("Tahoma", font_size, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
            graphic.DrawString(sale > 0 ? string.Format("{0:0,0 đ}", sale) : "0 đ", font, new SolidBrush(Color.Black), startX + 125, startY + offset);

            offset = offset + (int)FontHeight + 5;
            graphic.DrawString("Tổng thanh toán ", new Font("Tahoma", font_size, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
            graphic.DrawString(total <= 0 ? "0 đ" : string.Format("{0:0,0 đ}", total), font, new SolidBrush(Color.Black), startX + 125, startY + offset);

            offset = offset + (int)FontHeight + 5;
            graphic.DrawString("Khách đưa ", new Font("Tahoma", font_size, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
            graphic.DrawString(custome_pay > 0 ? string.Format("{0:0,0 đ}", custome_pay) : "0 đ", font, new SolidBrush(Color.Black), startX + 125, startY + offset);

            offset = offset + (int)FontHeight + 5;
            graphic.DrawString("Trả lại ", new Font("Tahoma", font_size, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
            graphic.DrawString(custome_return > 0 ? string.Format("{0:0,0 đ}", custome_return) : "0 đ", font, new SolidBrush(Color.Black), startX + 125, startY + offset);

            money = cl.money_code(int.Parse(total.ToString()));

            var    so1 = money.Split(' ');
            string sub = "", sub2 = "";

            if (so1.Length > 8)
            {
                for (int t = 0; t <= 7; t++)
                {
                    sub += so1[t] + " ";
                }
                for (int t = 8; t < so1.Length; t++)
                {
                    sub2 += so1[t] + " ";
                }
            }
            else
            {
                sub = money;
            }

            offset = offset + (int)FontHeight + 5;
            graphic.DrawString("Số tiền bằng chữ:", new Font("Tahoma", font_size, FontStyle.Italic), new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)FontHeight + 5;

            graphic.DrawString(sub, new Font("Tahoma", 7, FontStyle.Italic), new SolidBrush(Color.Black), startX, startY + offset);
            if (so1.Length > 9)
            {
                offset = offset + (int)FontHeight + 5;
                graphic.DrawString(sub2, new Font("Tahoma", 7, FontStyle.Italic), new SolidBrush(Color.Black), startX, startY + offset);
            }

            offset = offset + (int)FontHeight + 2;
            graphic.DrawString(line, new Font("Tahoma", 7, FontStyle.Regular), new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)FontHeight + 2;
            graphic.DrawString("Lưu ý !", new Font("Tahoma", 6, FontStyle.Bold), new SolidBrush(Color.Black), startX + 5, startY + offset);

            if (doitra.Trim() != "")
            {
                var dt = doitra.Trim().Split('#');
                foreach (var b in dt)
                {
                    offset = offset + (int)FontHeight + 2;
                    graphic.DrawString(b, new Font("Tahoma", 6, FontStyle.Italic), new SolidBrush(Color.Black), startX + 5, startY + offset);
                }
            }

            offset = offset + (int)FontHeight + 5;
            graphic.DrawString("XIN CẢM ƠN VÀ HẸN GẶP LẠI QUÝ KHÁCH !", new Font("Tahoma", 6, FontStyle.Bold), new SolidBrush(Color.Black), startX + 5, startY + offset);

            offset = offset + (int)FontHeight + 10;
            graphic.DrawString("Ngày in phiếu: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), new Font("Tahoma", 7, FontStyle.Regular), new SolidBrush(Color.Black), startX + 5, startY + offset);

            offset = offset + (int)FontHeight + 10;
            graphic.DrawString(line, new Font("Tahoma", 7, FontStyle.Regular), new SolidBrush(Color.Black), startX, startY + offset);
        }
 public virtual Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
 {
     return(null);
 }
Example #53
0
        private void PrintDocumentOnPrintPage2(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Cls_Printer p            = new Cls_Printer();
            string      c_NomEmpresa = dtListar.Rows[0]["c_nomemp"].ToString();
            string      c_RUC        = dtListar.Rows[0]["c_numdoccli"].ToString();
            string      c_dir2       = dtListar.Rows[0]["c_diremp"].ToString();

            string c_local = dtListar.Rows[0]["c_locdes"].ToString();
            string c_dir1  = dtListar.Rows[0]["c_dir"].ToString();

            string c_nomcli   = dtListar.Rows[0]["c_clides"].ToString();
            string c_cajero   = dtListar.Rows[0]["c_cajusu"].ToString();
            string c_placa    = dtListar.Rows[0]["c_numpla"].ToString();
            string c_fchemi   = Convert.ToDateTime(dtListar.Rows[0]["d_fchdoc"]).ToString("dd/MM/yyyy");
            string c_tiempo   = dtListar.Rows[0]["c_horini"].ToString();
            string c_servicio = dtListar.Rows[0]["c_serdes"].ToString();;
            string c_glosa    = dtListar.Rows[0]["c_gloserv"].ToString();

            string c_dato = dtListar.Rows[0]["c_numpla"].ToString();
            //c_dato = c_dato + "|" + dtListar.Rows[0]["c_clides"].ToString();
            //c_dato = c_dato + "|" + Convert.ToDateTime(dtListar.Rows[0]["d_fchdoc"]).ToString("dd/MM/yyyy");
            //c_dato = c_dato + "|" + dtListar.Rows[0]["c_horini"].ToString();
            //c_dato = c_dato + "|" + dtListar.Rows[0]["c_locdes"].ToString();
            //c_dato = c_dato + "|" + dtListar.Rows[0]["c_cajnom"].ToString();
            //c_dato = TxtNumPla.Text + "|" + TxtCliente.Text + "|" + DateTime.Now.ToString("dd/MM/yyyy") + "|" + TxtHorIni.Text + "|" + CboLocal.Text + "|" + CboCajero.Text;

            int    n_IdRegistro = Convert.ToInt32(dtListar.Rows[0]["n_id"]);
            string c_archivo    = CodigoBarra2(c_dato).ToString();

            int   n_altocampo      = 16;
            int   n_altoseparacion = 14;
            Color o_colorlinea     = Color.Transparent;
            int   n_tam1           = 11 - 2;
            int   n_tam2           = 10 - 2;
            int   n_tam3           = 9 - 2;
            int   n_tam4           = 8 - 2;

            p.e = e;

            //p.drawFont = new Font("Arial", n_tam1);
            //p.Print_TextoCuadro(c_NomEmpresa, 10, 30, 280, 20, 1, Color.Black, o_colorlinea);
            //p.Print_TextoCuadro(c_RUC, 10, 46, 280, 20, 1, Color.Black, o_colorlinea);
            //p.drawFont = new Font("Arial", n_tam3);
            //p.Print_TextoCuadro(c_dir1, 10, 60, 280, 20, 1, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam1, FontStyle.Bold);
            p.Print_TextoCuadro(c_local, 10, 30, 300, 20, 1, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam1);
            p.drawFont = new Font("Arial", n_tam3);
            p.Print_TextoCuadro(c_dir1, 10, 46, 280, 20, 1, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam1, FontStyle.Bold);
            p.Print_TextoCuadro("TICKET DE INGRESO", 10, 60, 280, 20, 1, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam3);
            int fila    = 76;
            int n_ancho = 70;

            p.Print_TextoCuadro("Cliente", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadroWrap(c_nomcli, 90, ref fila, 210, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + 16;
            p.Print_TextoCuadro("Cajero", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_cajero, 90, fila, 210, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + 16;
            p.Print_Linea(10, fila, 310, fila, 3, Color.Black, 3);

            fila = fila + 5;

            p.Print_TextoCuadro("Nº Placa", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam1);
            p.Print_TextoCuadro(c_placa, 90, fila, 210, n_altocampo, 2, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam3);
            fila       = fila + n_altoseparacion;
            p.Print_TextoCuadro("Fch Emi.", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_fchemi, 90, fila, 210, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("Hota Ing.", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_tiempo, 90, fila, 210, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("Servicio", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadroWrap(c_servicio, 10, ref fila, 210, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + 5;
            p.Print_Linea(10, fila, 310, fila, 3, Color.Black, 3);

            fila = fila + 10;
            p.Print_TextoCuadroWrap(c_glosa, 10, ref fila, 210, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + 10;
            p.Print_Imagen(c_archivo, 80, fila, 150, 60, 1, Color.Transparent, 1);

            string c_datos = "Tolerancia 5 minutos pasada la hora";

            fila       = fila + 70;
            p.drawFont = new Font("Arial", n_tam2);
            p.Print_TextoCuadro(c_datos, 10, fila, 280, n_altocampo, 2, Color.Black, o_colorlinea);
        }
Example #54
0
 private void printDocument1_PrintPage_1(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
 }
Example #55
0
        private void printDocument5_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Graphics g = e.Graphics;

            g.PageUnit = GraphicsUnit.Millimeter;
            Font messageFont = new Font("Times New Roman", 12, System.Drawing.GraphicsUnit.Point);
            int  total;

            if (i == 0)
            {
                g.DrawString("INSTITUTE DISPENSARY", messageFont, Brushes.Black, 75, 9);
                g.DrawString("INDIAN INSTITUTE OF TECHNOLOGY ROORKEE, SAHARANPUR CAMPUS", messageFont, Brushes.Black, 22, 15);
                messageFont = new Font("Times New Roman", 15, System.Drawing.GraphicsUnit.Point);
                g.DrawString("STORE - COMPLETE EXPENSE REPORT ( 05 April, 2013 - " + DateTime.Today.ToString("dd MMMM, yyyy") + ")", messageFont, Brushes.Black, 15, 21);
                Pen blackPen = new Pen(Color.Black, 1);
                g.DrawLine(blackPen, 5, 28, 205, 28);
                messageFont = new Font("Times New Roman", 12, System.Drawing.GraphicsUnit.Point);
                g.DrawString("Dated: " + dateTimePicker1.Value.Date.ToString("dd MMM, yyyy"), messageFont, Brushes.Black, 150, 32);
                total = 30;
            }
            else
            {
                total = 5;
            }
            messageFont = new Font("Times New Roman", 15, System.Drawing.GraphicsUnit.Point);
            g.DrawString("----------------------------------------------------------------------------------------------------------", messageFont, Brushes.Black, 7, total + 7);
            g.DrawString("----------------------------------------------------------------------------------------------------------", messageFont, Brushes.Black, 7, total + 17);
            messageFont = new Font("Times New Roman", 10, System.Drawing.GraphicsUnit.Point);
            g.DrawString("SNo.", messageFont, Brushes.Black, 10, total + 13);
            g.DrawString("Salt Name", messageFont, Brushes.Black, 22, total + 13);
            g.DrawString("Opening", messageFont, Brushes.Black, 127, total + 13);
            g.DrawString("Received", messageFont, Brushes.Black, 147, total + 13);
            g.DrawString("Issued", messageFont, Brushes.Black, 167, total + 13);
            g.DrawString("Current", messageFont, Brushes.Black, 187, total + 13);
            total += 25;
            for (; i < dataGridView1.Rows.Count; i++)
            {
                messageFont = new Font("Times New Roman", 10, System.Drawing.GraphicsUnit.Point);
                if (total >= 265)
                {
                    e.HasMorePages = true;
                    return;
                }
                medicine med = new medicine();
                med.storeMonthlyExpenses("20130404", DateTime.Now.AddDays(1).ToString("yyyyMMdd"), dataGridView1.Rows[i].Cells[0].Value.ToString());
                string issued   = med.issued;
                string received = med.received;
                if (issued == "")
                {
                    issued = "0";
                }
                if (received == "")
                {
                    received = "0";
                }
                g.DrawString((i + 1).ToString() + ".", messageFont, Brushes.Black, 10, total);
                g.DrawString(dataGridView1.Rows[i].Cells[1].Value.ToString(), messageFont, Brushes.Black, 22, total);
                g.DrawString(med.opening, messageFont, Brushes.Black, 130, total);
                g.DrawString(received, messageFont, Brushes.Black, 150, total);
                g.DrawString(issued, messageFont, Brushes.Black, 170, total);
                g.DrawString(med.closing, messageFont, Brushes.Black, 190, total);
                messageFont = new Font("Times New Roman", 5, System.Drawing.GraphicsUnit.Point);
                g.DrawString("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -", messageFont, Brushes.Black, 10, total + 4);
                total         += 6;
                e.HasMorePages = false;
            }

            messageFont = new Font("Times New Roman", 15, System.Drawing.GraphicsUnit.Point);
            g.DrawString("----------------------------------------------------------------------------------------------------------", messageFont, Brushes.Black, 7, total);

            messageFont = new Font("Times New Roman", 8, System.Drawing.GraphicsUnit.Point);
            g.DrawString("© IMG Labs, IIT Roorkee, SRE", messageFont, Brushes.Black, 87, total + 5);
        }
Example #56
0
        private void PrintDocumentOnPrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Helper.Comunes.Funciones fun = new Helper.Comunes.Funciones();
            Cls_Printer p = new Cls_Printer();

            string c_correo     = dtListar.Rows[0]["c_corctaven"].ToString();;
            string c_NomEmpresa = dtListar.Rows[0]["c_nomemp"].ToString();
            string c_NomLocal   = dtListar.Rows[0]["c_locdes"].ToString();
            string c_RUC        = dtListar.Rows[0]["c_numdoc1"].ToString();
            string c_dir1       = "D.F. : " + dtListar.Rows[0]["c_dir"].ToString();
            string c_dir2       = dtListar.Rows[0]["c_locdir"].ToString();
            string c_tipdoc     = dtListar.Rows[0]["c_desabr"].ToString();
            string c_numdoc     = "Nº " + dtListar.Rows[0]["c_numdoc"].ToString();
            string c_ruccli     = dtListar.Rows[0]["c_clinumdoc"].ToString();
            string c_nomcli     = dtListar.Rows[0]["c_clinom"].ToString();
            string c_fchemi     = Convert.ToDateTime(dtListar.Rows[0]["d_fchdoc"]).ToString("dd/MM/yyyy");
            string c_cajero     = dtListar.Rows[0]["c_cajnom"].ToString();
            string c_plasoc     = dtListar.Rows[0]["c_plasoc"].ToString();

            string c_placa    = dtListar.Rows[0]["c_numpla"].ToString();
            string c_horini   = fun.NulosC(dtListar.Rows[0]["c_horini"]).ToString();
            string c_horfin   = fun.NulosC(dtListar.Rows[0]["c_horfin"]).ToString();
            string c_tiempo   = fun.NulosC(dtListar.Rows[0]["c_tiempousu"]).ToString();
            string c_impbru   = Convert.ToDouble(dtListar.Rows[0]["n_impbru"]).ToString("0.00");
            string c_impigv   = Convert.ToDouble(dtListar.Rows[0]["n_impigv"]).ToString("0.00");
            string c_total    = Convert.ToDouble(dtListar.Rows[0]["n_imptotven"]).ToString("0.00");
            string c_totallet = dtListar.Rows[0]["c_numlet"].ToString();

            string c_dato = dtListar.Rows[0]["c_numpla"].ToString();

            c_dato = c_dato + "|" + dtListar.Rows[0]["c_desabr"].ToString();
            c_dato = c_dato + "|" + dtListar.Rows[0]["c_numdoc"].ToString();
            c_dato = c_dato + "|" + dtListar.Rows[0]["c_clinom"].ToString();
            c_dato = c_dato + "|" + Convert.ToDateTime(dtListar.Rows[0]["d_fchdoc"]).ToString("dd/MM/yyyy");
            c_dato = c_dato + "|" + Convert.ToDouble(dtListar.Rows[0]["n_imptotven"]).ToString("0.00");
            c_dato = c_dato + "|" + fun.NulosC(dtListar.Rows[0]["c_horini"]).ToString();
            c_dato = c_dato + "|" + fun.NulosC(dtListar.Rows[0]["c_horfin"]).ToString();
            c_dato = c_dato + "|" + dtListar.Rows[0]["c_locdes"].ToString();
            c_dato = c_dato + "|" + dtListar.Rows[0]["c_cajnom"].ToString();
            //c_dato = TxtNumPla2.Text + "|" + TxtCliente2.Text + "|" + DateTime.Now.ToString("dd/MM/yyyy") + "|" + TxtHorIni2.Text + "|" + TxtHorFin2.Text + "|" + CboLocal.Text + "|" + CboCajero.Text + "|" + TxtNumDoc.Text + "-" + TxtNumDoc.Text + "|" + TxtTotPag.Text + "|" + CboTipDoc.Text;

            int    n_IdRegistro = Convert.ToInt32(dtListar.Rows[0]["n_id"]);
            string c_archivo    = CodigoBarra(n_IdRegistro, c_dato).ToString();

            int   n_altocampo      = 18 - 3;
            int   n_altoseparacion = 20 - 6;
            Color o_colorlinea     = Color.Transparent;
            int   n_dat            = 66;
            int   n_tam_1          = 11 - 2;
            int   n_tam_2          = 10 - 2;
            int   n_tam_3          = 9 - 2;
            int   n_tam_4          = 8 - 2;

            p.e        = e;
            p.drawFont = new Font("Arial", n_tam_1);
            p.Print_TextoCuadro(c_NomEmpresa, 10, 30, 270, 16, 1, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_RUC, 10, 46, 270, 16, 1, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam_3);
            p.Print_TextoCuadro(c_dir1, 10, 60, 270, 16, 1, Color.Black, o_colorlinea);
            //p.Print_TextoCuadro(c_dir1, 10, ref n_dat, 270, 16, 1, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam_2, FontStyle.Bold);
            p.Print_TextoCuadro(c_NomLocal, 10, n_dat + 5, 270, 16, 1, Color.Black, o_colorlinea);
            p.drawFont = new Font("Arial", n_tam_3);
            p.Print_TextoCuadro(c_dir2, 10, n_dat + 20, 270, 16, 1, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam_2, FontStyle.Bold);
            p.Print_TextoCuadro(c_tipdoc, 10, 105, 270, 16, 1, Color.Black, o_colorlinea);
            p.drawFont = new Font("Arial", n_tam_2);
            p.Print_TextoCuadro(c_numdoc, 10, 120, 270, 16, 1, Color.Black, o_colorlinea);

            p.drawFont = new Font("Arial", n_tam_3);
            int fila    = 138;
            int n_ancho = 70;

            p.Print_TextoCuadro("RUC / DNI", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_ruccli, 90, fila, 220, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("Nombre", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadroWrap(c_nomcli, 90, ref fila, 220, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + 10;
            p.Print_TextoCuadro("Fch. Emi.", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_fchemi, 90, fila, 220, n_altocampo, 2, Color.Black, o_colorlinea);

            //p.Print_TextoCuadro("Hora Emi.", 150, fila, n_ancho, n_altocampo, 2, Color.Black, Color.Black);
            //p.Print_TextoCuadro(":", 220, fila, 10, n_altocampo, 2, Color.Black, Color.Black);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("Cajero", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_cajero, 90, fila, 220, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("Placa", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_placa, 90, fila, 220, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("Ingreso", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_horini, 90, fila, 220, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("Salida", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_horfin, 90, fila, 220, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("Tiempo", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_tiempo, 90, fila, 220, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_Linea(10, fila, 270, fila, 3, Color.Black, 3);

            int    n_row      = 0;
            string c_servicio = "";
            string c_imp      = "";

            fila = fila + 7;

            for (n_row = 0; n_row <= dtListar.Rows.Count - 1; n_row++)
            {
                c_imp      = Convert.ToDouble(dtListar.Rows[n_row]["n_detimptotigv"]).ToString("0.00");
                c_servicio = dtListar.Rows[n_row]["c_detdesprousu"].ToString();

                p.Print_TextoCuadro("Servicio", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
                p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
                //o_colorlinea = Color.Black;
                p.Print_TextoCuadroWrap(c_servicio, 90, ref fila, 210, n_altocampo, 2, Color.Black, o_colorlinea);

                fila = fila + 5;
                p.Print_TextoCuadro("Importe", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);
                p.Print_TextoCuadro(":", 80, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
                p.Print_TextoCuadro(c_imp, 90, fila, 210, n_altocampo, 2, Color.Black, o_colorlinea);

                fila = fila + n_altoseparacion;
            }

            fila = fila + 5;
            p.Print_Linea(10, fila, 270, fila, 3, Color.Black, 3);
            fila = fila + 7;
            int n_anchotot = 100;

            if (Convert.ToInt32(dtListar.Rows[0]["n_idtipdoc"]) == 2)
            {
                //fila = fila + n_altoseparacion;
                p.Print_TextoCuadro("Imp. Bruto  S/", 10, fila, n_anchotot, n_altocampo, 2, Color.Black, o_colorlinea);
                p.Print_TextoCuadro(":", 110, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
                p.Print_TextoCuadro(c_impbru, 120, fila, 100, n_altocampo, 3, Color.Black, o_colorlinea);

                fila = fila + n_altoseparacion;
                p.Print_TextoCuadro("IGV (18 %)  S/", 10, fila, n_anchotot, n_altocampo, 2, Color.Black, o_colorlinea);
                p.Print_TextoCuadro(":", 110, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
                p.Print_TextoCuadro(c_impigv, 120, fila, 100, n_altocampo, 3, Color.Black, o_colorlinea);

                fila = fila + n_altoseparacion;
            }

            //fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("Total   S/", 10, fila, n_anchotot, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(":", 110, fila, 10, n_altocampo, 2, Color.Black, o_colorlinea);
            p.Print_TextoCuadro(c_total, 120, fila, 100, n_altocampo, 3, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadro("SON :", 10, fila, n_ancho, n_altocampo, 2, Color.Black, o_colorlinea);

            fila = fila + n_altoseparacion;
            p.Print_TextoCuadroWrap(c_totallet, 10, ref fila, 280, n_altocampo, 2, Color.Black, o_colorlinea);

            if (fun.NulosC(c_plasoc) != "")
            {
                fila     = fila + n_altoseparacion;
                c_plasoc = "Ref. a placas: " + c_plasoc;
                p.Print_TextoCuadroWrap(c_plasoc, 10, ref fila, 280, n_altocampo, 2, Color.Black, o_colorlinea);
            }

            fila = fila + n_altoseparacion;
            //p.Print_Imagen(@"C:\\SSF-NET\\tmp\\101F0010000000002.bmp", 80, fila, 170, 80, 1, Color.Transparent, 1);
            p.Print_Imagen(c_archivo, 70, fila, 150, 60, 1, Color.Transparent, 1);

            p.drawFont = new Font("Arial", n_tam_3);
            if (c_tipdoc == "VALE")
            {
                c_dato = "Este documento provicional podra ser canjeado por una Factura o Boleta dentro del mes";
                p.Print_TextoCuadro(c_dato, 1, fila + 65, 270, 16, 1, Color.Black, o_colorlinea);
            }
            else
            {
                c_dato = "El documento electronico puede ser consultado en Sunat Virtual www.sunat.gob.pe, opciones sin clave SOL, consulta validez de CPE";
                fila   = fila + 65;
                p.Print_TextoCuadro(c_dato, 1, fila, 270, 32, 1, Color.Black, o_colorlinea);

                c_dato = "Solicitar el archivo .pdf y .xml al siguiente correo: " + c_correo;
                fila   = fila + 35;
                p.Print_TextoCuadro(c_dato, 1, fila, 270, 32, 1, Color.Black, o_colorlinea);
            }
        }
Example #57
0
        private void _CreateReceipt(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            try
            {
                var queryServices = from i in Cons.dataContext.Treatments
                                    join st in Cons.dataContext.ServiceTreatments on i.TreatmentId equals st.TreatmentId
                                    join s in Cons.dataContext.Services on st.ServiceId equals s.ServiceId
                                    where Cons.PatientId == i.PatientId && i.dayOfTreatment.Day == Cons.date.Day && i.dayOfTreatment.Month == Cons.date.Month && i.dayOfTreatment.Year == Cons.date.Year
                                    select new
                {
                    TenDichVu = s.nameService,
                    GiaThanh  = s.price
                };
                var queryMedicines = from pre in Cons.dataContext.Prescriptions
                                     join pm in Cons.dataContext.PrescriptionMedicines on pre.PrescriptionId equals pm.PrescriptionId
                                     join m in Cons.dataContext.Medicines on pm.MedicineId equals m.MedicineId
                                     where Cons.PatientId == pre.PatientId && pre.createdDate.Value.Day == Cons.date.Day && pre.createdDate.Value.Month == Cons.date.Month && pre.createdDate.Value.Year == Cons.date.Year
                                     select new
                {
                    TenThuoc = m.nameMedicine,
                    SoLuong  = pm.quantity,
                    DonGia   = m.price,
                    GiaThanh = pm.quantity * m.quantity,
                };


                Graphics graphic    = e.Graphics;
                Font     font       = new Font("Courier New", 12);
                float    FontHeight = font.GetHeight();
                int      startX     = 10;
                int      startY     = 10;
                int      offset     = 40;

                graphic.DrawImage(Properties.Resources.hospital, 10, 10, 50, 50);
                graphic.DrawString("PHÒNG KHÁM PTP", new Font("Courier New", 18), new SolidBrush(Color.Black), startX + 20, startY);
                graphic.DrawString("HỒ CHÍ MINH", new Font("Courier New", 10), new SolidBrush(Color.Black), startX + 30, startY + 25);
                graphic.DrawString("CLINICPTP.VN", new Font("Courier New", 12), new SolidBrush(Color.Black), startX + 30, startY + offset);

                Pen    blackPen = new Pen(Color.Black, 1);
                PointF point1   = new PointF(startX, startY + offset + 20);
                PointF point2   = new PointF(350, startY + offset + 20);
                e.Graphics.DrawLine(blackPen, point1, point2);

                offset = offset + (int)FontHeight;     //make the spacing consistent
                offset = offset + (int)FontHeight + 5; //make the spacing consistent

                graphic.DrawString("PHIẾU THU", new Font("Courier New", 22), new SolidBrush(Color.Black), startX + 95, startY + offset);


                offset = offset + (int)FontHeight;     //make the spacing consistent
                offset = offset + (int)FontHeight + 5; //make the spacing consistent
                string top = "Tên Dịch Vụ".PadRight(24) + "Thành Tiền";
                graphic.DrawString(top, new Font("Courier New", 12, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);

                offset = offset + (int)FontHeight; //make the spacing consistent
                graphic.DrawString("----------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);

                offset = offset + (int)FontHeight;     //make the spacing consistent
                offset = offset + (int)FontHeight + 5; //make the spacing consistent


                foreach (var item in queryServices.ToList())
                {
                    graphic.DrawString(item.TenDichVu, font, new SolidBrush(Color.Black), startX, startY + offset);
                    graphic.DrawString(item.GiaThanh.ToString(), font, new SolidBrush(Color.Black), startX + 250, startY + offset);
                    offset = offset + (int)FontHeight + 5; //make the spacing consistent
                }

                offset = offset + (int)FontHeight; //make the spacing consistent
                                                   //graphic.DrawString("----------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);
                top = "Thuốc".PadRight(24);

                graphic.DrawString(top, new Font("Courier New", 12, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
                offset = offset + (int)FontHeight;     //make the spacing consistent
                graphic.DrawString("----------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);
                offset = offset + (int)FontHeight + 5; //make the spacing consistent


                foreach (var item in queryMedicines.ToList())
                {
                    graphic.DrawString(item.TenThuoc + " x " + item.SoLuong, font, new SolidBrush(Color.Black), startX, startY + offset);
                    graphic.DrawString((decimal.Parse(item.SoLuong.ToString()) * item.DonGia).ToString(), font, new SolidBrush(Color.Black), startX + 250, startY + offset);
                    offset = offset + (int)FontHeight + 5; //make the spacing consistent
                }

                offset = offset + 20; //make some room so that the total stands out.



                graphic.DrawString("TỔNG TIỀN TRẢ ", new Font("Courier New", 12, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
                graphic.DrawString(_DoiSoSangDonViTienTe(total), new Font("Courier New", 12, FontStyle.Bold), new SolidBrush(Color.Black), startX + 210, startY + offset);
                graphic.DrawString(" VNĐ", font, new SolidBrush(Color.Black), startX + 300, startY + offset);

                offset = offset + (int)FontHeight + 5; //make the spacing consistent
                graphic.DrawString("TIỀN MẶT ", font, new SolidBrush(Color.Black), startX, startY + offset);
                graphic.DrawString(_DoiSoSangDonViTienTe(tienMat), font, new SolidBrush(Color.Black), startX + 210, startY + offset);
                graphic.DrawString(" VNĐ", font, new SolidBrush(Color.Black), startX + 300, startY + offset);

                offset = offset + (int)FontHeight + 5; //make the spacing consistent
                graphic.DrawString("TIỀN THỪA ", font, new SolidBrush(Color.Black), startX, startY + offset);
                graphic.DrawString(_DoiSoSangDonViTienTe(tienTra), font, new SolidBrush(Color.Black), startX + 210, startY + offset);
                graphic.DrawString(" VNĐ", font, new SolidBrush(Color.Black), startX + 300, startY + offset);

                offset = offset + (int)FontHeight + 5; //make the spacing consistent

                point1 = new PointF(startX, startY + offset + 20);
                point2 = new PointF(350, startY + offset + 20);
                e.Graphics.DrawLine(blackPen, point1, point2);

                offset = offset + (int)FontHeight + 5; //make the spacing consistent

                graphic.DrawString(" CẢM ƠN BẠN ĐÃ GHÉ THĂM!,", font, new SolidBrush(Color.Black), startX + 10, startY + offset);
                offset = offset + (int)FontHeight + 5; //make the spacing consistent
                graphic.DrawString("HI VỌNG BẠN SẼ GHÉ THĂM LẠI!", font, new SolidBrush(Color.Black), startX, startY + offset);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #58
0
        private void docToPrint_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Font     fontLarge   = new Font("仿宋", 18, FontStyle.Bold);
            Font     fontMiddle  = new Font("仿宋", 12, FontStyle.Bold);
            Font     fontSmall   = new Font("仿宋", 10, FontStyle.Regular);
            Brush    bru         = Brushes.Black;
            Graphics g           = e.Graphics; //先建立画布
            String   companyName = this.txtCompanyName.Text;

            int x = 10;
            int y = 5;

            g.DrawString(companyName, fontLarge, bru, x, y);

            /*--------------------------------------------------------*/
            x  = 150;
            y += 30;
            g.DrawString(this.lblName.Text, fontMiddle, bru, x, y);

            x += 40;
            g.DrawString(this.txtName.Text, fontMiddle, bru, x, y);

            /*--------------------------------------------------------*/
            x  = 150;
            y += 30;
            g.DrawString(this.lblModel.Text, fontMiddle, bru, x, y);
            x += 40;
            g.DrawString(this.txtModel.Text, fontMiddle, bru, x, y);

            /*--------------------------------------------------------*/
            x  = 150;
            y += 30;
            g.DrawString(this.lblCode.Text, fontMiddle, bru, x, y);
            x += 40;
            g.DrawString(this.txtCode.Text, fontMiddle, bru, x, y);

            /*--------------------------------------------------------*/
            x  = 150;
            y += 30;
            g.DrawString(this.lblAddress.Text, fontMiddle, bru, x, y);
            //x += 60;
            y += 25;
            g.DrawString(this.txtAddress.Text, fontMiddle, bru, x, y);

            /*--------------------------------------------------------*/
            x  = 10;
            y += 25;
            g.DrawString(this.lblPeriod.Text, fontSmall, bru, x, y);
            x += 55;
            g.DrawString(this.txtPeriod.Text, fontSmall, bru, x, y);

            Bitmap bt;

            string enCodeString = this.txtUrl.Text;

            if (String.IsNullOrWhiteSpace(enCodeString))
            {
                enCodeString = "该设备没有网站来源";
            }

            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();

            qrCodeEncoder.QRCodeVersion = 0;

            bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8);
            g.DrawImage(bt, 15, 35, 135, 135);


            /*****************测试代码**************************************/
            //Pen pen = new Pen(bru,1);
            //Rectangle test = new Rectangle(0, 0, PRINT_WIDTH, PRINT_HEIGHT);
            //g.DrawRectangle(pen, test);

            /*****************水印**************************************/

            Font fontTest = new Font("仿宋", 20, FontStyle.Underline);

            g.DrawString("这个标签仅用于测试", fontSmall, Brushes.Red, 150, 20);
        }
Example #59
0
 private void printDocument2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     e.Graphics.DrawImage(bmp, 0, 0);
 }
        private void PrintDoc_PrintPage(object sender,
                                        System.Drawing.Printing.PrintPageEventArgs e)
        {
            //if(e.PageBounds.Width!=827||e.PageBounds.Height!=1169)
            //{
            //    MessageBox.Show("打印纸张不合适,请设置打印机打印纸张的大小。");
            //    return;
            //
            //}
            int tmpWidth, i;

            int tmpTop  = e.MarginBounds.Top;
            int tmpLeft = e.MarginBounds.Left;

            try
            {
                double pageWidth = e.PageBounds.Width - e.MarginBounds.Left * 2;
                if (pageWidth < 0)
                {
                    MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("printlist", EnumPromptMessage.warning), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    _printPreviewDialog.Close();
                    return;
                }
                // Before starting first page, it saves Width & Height of Headers and CoulmnType
                if (PageNo == 1)
                {
                    foreach (GridViewColumn GridCol in dgv.Columns)
                    {
                        if (!GridCol.IsVisible)
                        {
                            ColumnWidths.Add(GridCol.Name, 0);
                            continue;
                        }
                        // Skip if the current column not selected
                        if (!SelectedColumns.Contains(GridCol.HeaderText))
                        {
                            continue;
                        }

                        // Detemining whether the columns are fitted to page or not.
                        if (FitToPageWidth)
                        {
                            ;
                            if (pageWidth < TotalWidth)
                            {
                                tmpWidth = (int)(Math.Floor((double)((double)GridCol.Width /
                                                                     (double)TotalWidth * (double)pageWidth)));
                            }
                            else
                            {
                                tmpWidth = (int)(Math.Floor((double)((double)GridCol.Width /
                                                                     (double)TotalWidth * (double)TotalWidth *
                                                                     ((double)e.MarginBounds.Width / (double)TotalWidth))));
                            }
                        }
                        else
                        {
                            if (pageWidth < TotalWidth)
                            {
                                tmpWidth = (int)(Math.Floor((double)((double)GridCol.Width /
                                                                     (double)TotalWidth * (double)pageWidth)));
                            }
                            else
                            {
                                tmpWidth = GridCol.Width;
                            }
                        }
                        HeaderHeight = (int)(e.Graphics.MeasureString(GridCol.HeaderText,
                                                                      this.dgv.Font, tmpWidth).Height) + 20;

                        // Save width & height of headres and ColumnType
                        ColumnLefts.Add(tmpLeft);
                        ColumnWidths.Add(GridCol.Name, tmpWidth);
                        ColumnTypes.Add(GridCol.GetType());
                        tmpLeft += tmpWidth;
                    }
                }

                // Printing Current Page, Row by Row
                while (RowPos <= dgv.Rows.Count - 1)
                {
                    GridViewRowInfo GridRow = dgv.Rows[RowPos];
                    if ((!PrintAllRows && !GridRow.IsSelected))
                    {
                        RowPos++;
                        continue;
                    }
                    // CellHeight = GridRow.Height;

                    if (tmpTop + CellHeight >= e.MarginBounds.Height + e.MarginBounds.Top)
                    {
                        DrawFooter(e, RowsPerPage);
                        NewPage = true;
                        PageNo++;
                        e.HasMorePages = true;
                        return;
                    }
                    else
                    {
                        Font font = new Font(dgv.Font,
                                             FontStyle.Bold);
                        if (NewPage)
                        {
                            // Draw Header
                            //这里开始渲染标题
                            SizeF titleSize = e.Graphics.MeasureString(PrintTitle, TitleFont, e.MarginBounds.Width);
                            e.Graphics.DrawString(PrintTitle, TitleFont,
                                                  FontColor, (int)((pageWidth + e.MarginBounds.Left * 2 - titleSize.Width) / 2), e.MarginBounds.Top -
                                                  titleSize.Height);


                            // 用于记录BarCode有传入的情况下,记录高度
                            int barCodeHeight = 0;

                            if (!string.IsNullOrEmpty(barCodeValue))
                            {
                                //渲染出BarCode在界面上
                                Image barImage = BarCodeHelper.GetBarcodeImage(barCodeValue, barCodeValue, 300, 100);
                                e.Graphics.DrawImage(barImage, (int)((pageWidth + e.MarginBounds.Left * 2 - barImage.Width) / 2), e.MarginBounds.Top -
                                                     titleSize.Height + 50, 300, 100);
                                barCodeHeight = barImage.Height;
                            }

                            String s        = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                            SizeF  timeSize = e.Graphics.MeasureString(s, new Font(dgv.Font,
                                                                                   FontStyle.Bold), e.MarginBounds.Width);

                            tmpTop = e.MarginBounds.Top;
                            if (PageNo == 1)
                            {
                                int topH = 0;
                                if (!string.IsNullOrEmpty(barCodeValue))
                                {
                                    topH = barCodeHeight;
                                }

                                //显示内容部分
                                if (!string.IsNullOrEmpty(PrintContent))
                                {
                                    SizeF contentSize = e.Graphics.MeasureString(PrintContent, ConFont, e.MarginBounds.Width);
                                    e.Graphics.DrawString(PrintContent, ConFont,
                                                          ConFontColor, e.MarginBounds.Left - 18, e.MarginBounds.Top + barCodeHeight);
                                    tmpTop = (int)(e.MarginBounds.Top + contentSize.Height) + barCodeHeight;


                                    //显示时间
                                    e.Graphics.DrawString(s, font,
                                                          Brushes.Red, (int)(pageWidth + e.MarginBounds.Left * 2 - e.MarginBounds.Left - timeSize.Width - 10),
                                                          (e.MarginBounds.Top + e.Graphics.MeasureString(PrintTitle, font, e.MarginBounds.Width).Height
                                                           + e.Graphics.MeasureString(PrintContent, font, e.MarginBounds.Width).Height) + topH);
                                }
                                else
                                {
                                    e.Graphics.DrawString(s, font,
                                                          Brushes.Red, e.MarginBounds.Left + (e.MarginBounds.Width -
                                                                                              e.Graphics.MeasureString(s, new Font(dgv.Font,
                                                                                                                                   FontStyle.Bold), e.MarginBounds.Width).Width), e.MarginBounds.Top -
                                                          e.Graphics.MeasureString(PrintTitle, font, e.MarginBounds.Width).Height + topH);
                                    tmpTop = e.MarginBounds.Top + barCodeHeight;
                                }
                            }

                            if (PageNo != 1)
                            {
                                e.Graphics.DrawString(s, font,
                                                      Brushes.Red, e.MarginBounds.Left + (e.MarginBounds.Width -
                                                                                          e.Graphics.MeasureString(s, new Font(dgv.Font,
                                                                                                                               FontStyle.Bold), e.MarginBounds.Width).Width), e.MarginBounds.Top -
                                                      e.Graphics.MeasureString(PrintTitle, font, e.MarginBounds.Width).Height);

                                tmpTop = e.MarginBounds.Top + barCodeHeight;
                            }

                            // Draw Columns
                            i = 0;
                            foreach (GridViewColumn GridCol in dgv.Columns)
                            {
                                if (!GridCol.IsVisible)
                                {
                                    continue;
                                }
                                if (!SelectedColumns.Contains(GridCol.HeaderText))
                                {
                                    continue;
                                }

                                e.Graphics.FillRectangle(new SolidBrush(Color.LightGray),
                                                         new Rectangle((int)ColumnLefts[i], tmpTop,
                                                                       (int)ColumnWidths[GridCol.Name], HeaderHeight));

                                e.Graphics.DrawRectangle(Pens.Black,
                                                         new Rectangle((int)ColumnLefts[i], tmpTop,
                                                                       (int)ColumnWidths[GridCol.Name], HeaderHeight));

                                e.Graphics.DrawString(GridCol.HeaderText, DgvFont,
                                                      new SolidBrush(Color.Black),
                                                      new RectangleF((int)ColumnLefts[i], tmpTop,
                                                                     (int)ColumnWidths[GridCol.Name], HeaderHeight), StrFormat);
                                i++;
                            }
                            NewPage = false;
                            tmpTop += HeaderHeight;
                        }

                        // Draw Columns Contents
                        i = 0;
                        foreach (GridViewCellInfo Cel in GridRow.Cells)
                        {
                            if (!Cel.ColumnInfo.IsVisible)
                            {
                                continue;
                            }
                            if (!SelectedColumns.Contains(Cel.ColumnInfo.HeaderText))
                            {
                                continue;
                            }

                            int j = 0;
                            foreach (GridViewCellInfo cel in GridRow.Cells)
                            {
                                SizeF maxSize = new SizeF((int)ColumnWidths[cel.ColumnInfo.Name], CellHeight);

                                string celValue = cel.Value != null?cel.Value.ToString() : "";

                                SizeF celSize = e.Graphics.MeasureString(celValue, DgvFont, e.MarginBounds.Width);

                                double celHeight = celSize.Height * Math.Ceiling((double)(celSize.Width / maxSize.Width));
                                if (maxSize.Height < Math.Ceiling(celHeight) && !double.IsInfinity(celHeight))
                                {
                                    maxSize    = new SizeF(maxSize.Width, (float)Math.Ceiling(celHeight));
                                    CellHeight = (int)maxSize.Height + 10;
                                }

                                j++;
                            }
                            string cellValue = Cel.Value != null?Cel.Value.ToString() : "";

                            // For the TextBox Column
                            if (((Type)ColumnTypes[i]).Name == "GridViewTextBoxColumn" ||
                                ((Type)ColumnTypes[i]).Name == "GridViewLinkColumn")
                            {
                                e.Graphics.DrawString(cellValue, DgvFont,
                                                      new SolidBrush(Color.Black),
                                                      new RectangleF((int)ColumnLefts[i], (float)tmpTop,
                                                                     (int)ColumnWidths[Cel.ColumnInfo.Name], (int)CellHeight), StrFormat);
                            }
                            // For the Button Column
                            else if (((Type)ColumnTypes[i]).Name == "GridViewButtonColumn")
                            {
                                CellButton.Text = cellValue;
                                CellButton.Size = new Size((int)ColumnWidths[Cel.ColumnInfo.Name], (int)CellHeight);
                                Bitmap bmp = new Bitmap(CellButton.Width, CellButton.Height);
                                CellButton.DrawToBitmap(bmp, new Rectangle(0, 0,
                                                                           bmp.Width, bmp.Height));
                                e.Graphics.DrawImage(bmp, new Point((int)ColumnLefts[i], tmpTop));
                            }
                            // For the CheckBox Column
                            else if (((Type)ColumnTypes[i]).Name == "GridViewCheckBoxColumn")
                            {
                                CellCheckBox.Size    = new Size(14, 14);
                                CellCheckBox.Checked = (bool)Boolean.Parse(cellValue);
                                Bitmap   bmp         = new Bitmap((int)ColumnWidths[Cel.ColumnInfo.Name], CellHeight);
                                Graphics tmpGraphics = Graphics.FromImage(bmp);
                                tmpGraphics.FillRectangle(Brushes.White, new Rectangle(0, 0,
                                                                                       bmp.Width, bmp.Height));
                                CellCheckBox.DrawToBitmap(bmp,
                                                          new Rectangle((int)((bmp.Width - CellCheckBox.Width) / 2),
                                                                        (int)((bmp.Height - CellCheckBox.Height) / 2),
                                                                        CellCheckBox.Width, CellCheckBox.Height));
                                e.Graphics.DrawImage(bmp, new Point((int)ColumnLefts[i], tmpTop));
                            }
                            // For the ComboBox Column
                            else if (((Type)ColumnTypes[i]).Name == "GridViewComboBoxColumn")
                            {
                                CellComboBox.Size = new Size((int)ColumnWidths[Cel.ColumnInfo.Name], (int)CellHeight);
                                Bitmap bmp = new Bitmap(CellComboBox.Width, (int)CellHeight);
                                CellComboBox.DrawToBitmap(bmp, new Rectangle(0, 0,
                                                                             bmp.Width, bmp.Height));
                                e.Graphics.DrawImage(bmp, new Point((int)ColumnLefts[i], tmpTop));
                                e.Graphics.DrawString(cellValue, TitleFont,
                                                      new SolidBrush(Color.Black),
                                                      new RectangleF((int)ColumnLefts[i] + 1, tmpTop, (int)ColumnWidths[Cel.ColumnInfo.Name]
                                                                     - 16, CellHeight), StrFormatComboBox);
                            }
                            // For the Image Column
                            else if (((Type)ColumnTypes[i]).Name == "GridViewImageColumn")
                            {
                                Rectangle CelSize = new Rectangle((int)ColumnLefts[i],
                                                                  tmpTop, (int)ColumnWidths[Cel.ColumnInfo.Name], CellHeight);
                                Size ImgSize = ((Image)(Cel.Value)).Size;
                                e.Graphics.DrawImage((Image)Cel.Value,
                                                     new Rectangle((int)ColumnLefts[i] + (int)((CelSize.Width - ImgSize.Width) / 2),
                                                                   tmpTop + (int)((CelSize.Height - ImgSize.Height) / 2),
                                                                   ((Image)(Cel.Value)).Width, ((Image)(Cel.Value)).Height));
                            }
                            // For the Decimal
                            else if (((Type)ColumnTypes[i]).Name == "GridViewDecimalColumn")
                            {
                                e.Graphics.DrawString(cellValue, DgvFont,
                                                      new SolidBrush(Color.Black),
                                                      new RectangleF((int)ColumnLefts[i], (float)tmpTop,
                                                                     (int)ColumnWidths[Cel.ColumnInfo.Name], (int)CellHeight), StrFormat);
                            }

                            // Drawing Cells Borders
                            e.Graphics.DrawRectangle(Pens.Black, new Rectangle((int)ColumnLefts[i],
                                                                               tmpTop, (int)ColumnWidths[Cel.ColumnInfo.Name], (int)CellHeight));

                            i++;
                        }
                        tmpTop += CellHeight;
                    }

                    RowPos++;
                    // For the first page it calculates Rows per Page
                    if (PageNo == 1)
                    {
                        RowsPerPage++;
                    }
                }

                if (RowsPerPage == 0)
                {
                    return;
                }

                // Write Footer (Page Number)
                DrawFooter(e, RowsPerPage);

                e.HasMorePages = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }