예제 #1
0
        private void PreviewDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            GC.Collect();
            e.Graphics.DrawImage(RecDrawImg, 0, 0, 1094, 1546);
            //ΕΚΤΥΠΩΣΗ ΣΤΟΙΧΕΙΩΝ ΑΠΟΔΕΙΞΗΣ
            e.Graphics.DrawString("Απόδειξη Πληρωμής", new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 160, 250);
            e.Graphics.DrawString(SeriesReceiptTxt.Text, new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 588, 250);
            e.Graphics.DrawString(IdReceiptTxt.Text, new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 690, 250);
            e.Graphics.DrawString(DateTimeReceiptPicker.Value.Day.ToString() + '/' + DateTimeReceiptPicker.Value.Month.ToString() + '/' + DateTimeReceiptPicker.Value.Year.ToString(), new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 821, 250);
            //ΕΚΤΥΠΩΣΗ ΣΤΟΙΧΕΙΩΝ ΠΡΟΜΗΘΕΥΤΗ
            e.Graphics.DrawString(IdSupplierTxt.Text, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 220, 329);
            e.Graphics.DrawString(NameSupplierTxt.Text, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 356);
            e.Graphics.DrawString(SupplierAddress, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 383);
            e.Graphics.DrawString(SupplierRegion, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 410);
            e.Graphics.DrawString(SupplierOccupation, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 438);
            e.Graphics.DrawString(AfmSupplierTxt.Text, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 466);
            e.Graphics.DrawString(SupplierEmail, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 493);
            e.Graphics.DrawString(SupplierPhone.Substring(0, 10), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 329);
            e.Graphics.DrawString(SupplierPhone2.Substring(0, 10), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 356);
            e.Graphics.DrawString(SupplierTk, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 411);
            e.Graphics.DrawString(SupplierTax_office, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 466);
            //ΕΚΤΥΠΩΣΗ ΣΤΟΙΧΕΙΩΝ ΑΠΟΔΕΙΞΗΣ
            DateTime dt;

            for (int i = 1; i <= Convert.ToInt16(ValueDocItemsTxt.Text); i++)
            {
                if (ProductsPanel.Controls.Find("ValueDocIdTxt" + i, true).First().Text != "" && ProductsPanel.Controls.Find("ValueDocIssuerTxt" + i, true).First().Text != "")
                {
                    if (ProductsPanel.Controls.Find("ValueDocPriceTxt" + i, true).First().Text != "" && ProductsPanel.Controls.Find("ValueDocPriceTxt" + i, true).First().Text != "0")
                    {
                        dt = ((DateTimePicker)ProductsPanel.Controls.Find("ValueDocDatePkr" + i, true).First()).Value;
                        e.Graphics.DrawString(ProductsPanel.Controls.Find("ValueDocIdTxt" + i, true).First().Text, new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 110, 560 + i * 25);
                        e.Graphics.DrawString(dt.Day.ToString() + '/' + dt.Month.ToString() + '/' + dt.Year.ToString(), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 375, 560 + i * 25);
                        e.Graphics.DrawString(chk.GrNumber(ProductsPanel.Controls.Find("ValueDocPriceTxt" + i, true).First().Text), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(585, 560 + i * 25, 100, 25), format);
                        e.Graphics.DrawString(ProductsPanel.Controls.Find("ValueDocIssuerTxt" + i, true).First().Text, new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 725, 560 + i * 25);
                    }
                }
            }
            //ΕΚΤΥΠΩΣΗ ΣΥΝΟΛΩΝ ΑΠΟΔΕΙΞΗΣ
            e.Graphics.DrawString(chk.GrNumber(CashTxt.Text), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(828, 1105, 100, 25), format);
            e.Graphics.DrawString(chk.GrNumber(PriceReceiptTxt.Text), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(828, 1178, 100, 25), format);
            string fullname1 = "";
            string fullname2 = "";

            if (PriceReceiptTxt.Text != "")
            {
                try
                {
                    int     decim = 0;
                    decimal price = decimal.Parse(PriceReceiptTxt.Text);
                    if (price != Math.Truncate(price))
                    {
                        decim = (int)((price - Math.Truncate(price)) * 100);
                    }
                    fullname1 = chk.Number_fullname(Convert.ToInt32(Math.Truncate(price))) + " ευρώ";
                    fullname2 = (decim == 0 ? "" : " και " + chk.Number_fullname(decim) + " λεπτά");
                }
                catch (Exception)
                {
                }
            }
            if (NotesTxt.Text != "")
            {
                string Note1 = NotesTxt.Text;
                string Note2 = "";
                if (Note1.Length > 70)
                {
                    Note2 = Note1.Substring(70);
                    Note1 = Note1.Substring(0, 70);
                    if (Note2.Length > 70)
                    {
                        Note2 = Note2.Substring(0, 70);
                    }
                }
                e.Graphics.DrawString(Note1, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 39, 1180);
                e.Graphics.DrawString(Note2, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 39, 1205);
            }
            e.Graphics.DrawString(fullname1, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 43, 1080);
            e.Graphics.DrawString(fullname2, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 43, 1108);
        }
예제 #2
0
파일: Form1.cs 프로젝트: nipa0827/Metrics
 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     e.Graphics.DrawString(receipt.Text, new Font("Arial", 14, FontStyle.Regular), Brushes.Black, 120, 120);
 }
예제 #3
0
        private void PrintDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            string   pan = "", nshi = "", claim = "";
            string   pname = "", paddress = "", pcontact = "";
            string   hname = "", hmuni = "", haddress = "";
            string   pmuni = "", pward = "", pdistrict = "", year = "";
            string   referred = "";
            string   sex = "", weight = "";
            Boolean  isFirsttime = false;
            DateTime datet       = DateTime.Now;
            int      age         = 0;

            if (LoggedInUser.IsOnline == true)
            {
                var patient = db.patientInformations.Where(x => x.Id == selectedId).FirstOrDefault();
                var opd     = db.OPDs.Where(x => x.PatientInformationId == selectedId).OrderByDescending(p => p.AddedDate).FirstOrDefault();
                // var opd=from n in db.OPDs group n by n.PatientInformationId into g select new {g}
                var hd    = db.hospitalDetails.FirstOrDefault();
                var mainr = db.mainRegisterss.Where(x => x.PatientInformationId == selectedId).OrderByDescending(p => p.AddedDate).FirstOrDefault();
                pname    = patient.FullName;
                pmuni    = patient.Municipality;
                paddress = patient.Municipality + "-" + patient.Ward + "," + patient.District;
                age      = patient.Age;
                weight   = patient.Weight;
                sex      = patient.Sex;
                pcontact = patient.ContactNumber;
                hname    = hd.HospitalName;
                haddress = hd.MuniOrRuralMuni + "-" + hd.Ward + "," + hd.District;
                hmuni    = hd.MuniOrRuralMuni;
                pan      = opd.PAN;
                nshi     = opd.NSHI_Number;
                claim    = opd.Claim_Code;
                referred = mainr.ReferredFrom;
                if (patient.IsLessThan5Years == true)
                {
                    year = "Months";
                }
                else
                {
                    year = "Years";
                }
            }
            else
            {
                hname    = "Jibjibe Gramin Hospital";
                hmuni    = "Kalika";
                haddress = "Kalika-5,Rasuwa";
                con      = new SQLiteConnection("Data Source=hospitalDb.db);Version=3");
                string cstring2 = "select * from patientInfo  where Id=@id";
                cmd = new SQLiteCommand(cstring2, con);
                con.Open();
                cmd.Parameters.AddWithValue("@id", selectedId);
                SQLiteDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    pname       = reader.GetString(4);
                    pmuni       = reader.GetString(10);
                    pward       = reader.GetString(11);
                    pdistrict   = reader.GetString(9);
                    pcontact    = reader.GetString(15);
                    age         = reader.GetInt32(6);
                    sex         = reader.GetString(8);
                    weight      = reader.GetString(7);
                    datet       = reader.GetDateTime(16);
                    isFirsttime = reader.GetBoolean(5);
                }
                paddress = pmuni + "-" + pward + "," + pdistrict;
                if (isFirsttime == true)
                {
                    year = "Months";
                }
                else
                {
                    year = "Years";
                }
                string cstring1 = "select * from OPDTable where PID=@id  AND Id = (SELECT MAX(Id)  FROM OPDTable) ";
                cmd = new SQLiteCommand(cstring1, con);

                cmd.Parameters.AddWithValue("@id", selectedId);
                SQLiteDataReader reader1 = cmd.ExecuteReader();
                while (reader1.Read())
                {
                    pan   = reader1.GetString(13);
                    claim = reader1.GetString(12);
                    nshi  = reader1.GetString(11);
                }
                string cstring3 = "select * from MainTable where PID=@id1  AND Id = (SELECT MAX(Id)  FROM MainTable)";
                cmd = new SQLiteCommand(cstring3, con);

                cmd.Parameters.AddWithValue("@id1", true);
                SQLiteDataReader reader3 = cmd.ExecuteReader();
                while (reader3.Read())
                {
                    referred = reader3.GetString(6);
                }
                con.Close();
            }

            Pen blackpen = new Pen(Color.Black, 3);


            e.Graphics.DrawString(hname, new Font("Arial", 16, FontStyle.Bold), Brushes.Black, new Point(287, 35));
            e.Graphics.DrawString(haddress, new Font("Arial", 16, FontStyle.Bold), Brushes.Black, new Point(320, 65));
            int ypos = 65;

            e.Graphics.DrawString("Invoice", new Font("Arial", 14, FontStyle.Bold), Brushes.Black, new Point(375, ypos + 80));
            e.Graphics.DrawString("Patient Id:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(100, ypos + 30));
            e.Graphics.DrawString("Invoice No:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(100, ypos + 60));
            e.Graphics.DrawString("Date", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(570, ypos + 60));
            e.Graphics.DrawString(DateTime.Now.ToString(), new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(620, ypos + 60));
            e.Graphics.DrawString(selectedId.ToString(), new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(230, ypos + 30));

            e.Graphics.DrawString("Name:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(100, ypos + 110));
            e.Graphics.DrawString(pname, new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(230, ypos + 110));
            e.Graphics.DrawString("Address:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(100, ypos + 130));
            e.Graphics.DrawString(paddress, new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(230, ypos + 130));
            e.Graphics.DrawString("PAN:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(100, ypos + 150));

            e.Graphics.DrawString(pan, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(230, ypos + 150));
            e.Graphics.DrawString(nshi, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(230, ypos + 170));
            e.Graphics.DrawString(claim, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(230, ypos + 190));


            e.Graphics.DrawString("NSHI Number:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(100, ypos + 170));

            e.Graphics.DrawString("Claim Code:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(100, ypos + 190));

            e.Graphics.DrawString("Age/Sex", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(570, ypos + 110));
            e.Graphics.DrawString(sex + "/" + age.ToString() + year, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(650, ypos + 110));
            e.Graphics.DrawString("Referred By:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(570, ypos + 130));
            e.Graphics.DrawString("Contact:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(570, ypos + 150));
            e.Graphics.DrawString(pcontact, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(650, ypos + 150));

            e.Graphics.DrawString(referred, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(670, ypos + 130));

            e.Graphics.DrawLine(blackpen, 190, 300, 600, 300);
            e.Graphics.DrawLine(blackpen, 190, 332, 600, 332);
            e.Graphics.DrawString("S.N.", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(190, ypos + 244));
            e.Graphics.DrawString("Particular", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(240, ypos + 244));
            e.Graphics.DrawString("Rate", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(390, ypos + 244));
            e.Graphics.DrawString("Qty.", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(460, ypos + 244));
            e.Graphics.DrawString("Type", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(530, ypos + 244));


            int y = ypos + 280;

            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                e.Graphics.DrawString(i.ToString(), new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(200, ypos + 280));
                e.Graphics.DrawString(dataGridView1.Rows[i].Cells[0].Value.ToString(), new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(255, ypos + 280));
                e.Graphics.DrawString(dataGridView1.Rows[i].Cells[1].Value.ToString(), new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(405, ypos + 280));
                e.Graphics.DrawString(dataGridView1.Rows[i].Cells[2].Value.ToString(), new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(480, ypos + 280));
                e.Graphics.DrawString(dataGridView1.Rows[i].Cells[3].Value.ToString(), new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(535, ypos + 280));
                ypos = ypos + 25;
                y    = y + 25;
            }
            e.Graphics.DrawLine(blackpen, 190, y + 10, 600, y + 10);
            e.Graphics.DrawString("Sub Total:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(620, y + 40));
            e.Graphics.DrawString("Rs " + SubtotalTextBox.Text, new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(730, y + 40));
            e.Graphics.DrawString("Discount:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(620, y + 70));
            e.Graphics.DrawString("RS " + DiscountTextbox.Text, new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(730, y + 70));
            e.Graphics.DrawString("Grand Total:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(620, y + 100));
            e.Graphics.DrawString("Rs " + GrandTotalTextBox.Text, new Font("Arial", 11, FontStyle.Bold), Brushes.Black, new Point(730, y + 100));
        }
예제 #4
0
        public void DibujaDocumento(System.Drawing.Printing.PrintPageEventArgs e)
        {
            Font _Fuente8      = new Font("Arial", 8);
            Font _Fuente10     = new Font("Arial", 10);
            Font _Fuente12     = new Font("Arial", 12);
            Font _Fuente10Bold = new Font("Arial", 10, FontStyle.Bold);
            Font _Fuente12Bold = new Font("Arial", 12, FontStyle.Bold);
            Font _Fuente14Bold = new Font("Arial", 14, FontStyle.Bold);
            Font _FuenteCodBar = new Font("Code 39", 12);

            Bitmap img = new Bitmap(global::SICASv20.Properties.Resources.CSC, 114, 73);

            var _with2 = e.Graphics;

            float x1 = 0;
            float y  = 0;
            float x2 = 0;
            float x3 = 0;
            float x4 = 0;
            float x5 = 0;

            y  = 10;
            x1 = 10;
            x2 = 300;
            x3 = 475;
            x4 = 550;
            x5 = 625;

            _with2.DrawLine(Pens.Black, x1, y, 700, y);
            _with2.DrawImage(img, x1 + 1, y + 1);
            _with2.DrawLine(Pens.Black, x1, y + 105, 700, y + 105);

            _with2.DrawString("CASCO SERVICE CENTER", _Fuente14Bold, Brushes.Black, 300, y + 30);
            _with2.DrawString("ORDEN DE COMPRA", _Fuente12Bold, Brushes.Black, 350, y + 50);
            _with2.DrawString("FOLIO: " + Convert.ToString(OrdenCompra.OrdenCompra_ID), _Fuente12Bold, Brushes.Black, 380, y + 65);
            _with2.DrawString(DateAndTime.Now.ToShortDateString(), _Fuente10, Brushes.Black, 350, y + 80);
            _with2.DrawString(DateAndTime.Now.ToShortTimeString(), _Fuente10, Brushes.Black, 450, y + 80);


            _with2.DrawString("PROVEEDOR:", _Fuente10Bold, Brushes.Black, x1, y + 130);
            _with2.DrawString(Entities.Empresas.Read(OrdenCompra.Proveedor_ID).RazonSocial.ToUpper(), _Fuente10, Brushes.Black, x2, y + 130);
            //// .DrawString("FACTURA DE PROVEEDOR:", _Fuente10Bold, Brushes.Black, x1, y + 145)
            //// .DrawString(Me.txtFactura.Text, _Fuente10, Brushes.Black, x2, y + 145)


            _with2.DrawLine(Pens.Black, x1, y + 160, 700, y + 160);
            _with2.DrawString("REFACCION", _Fuente10, Brushes.Black, x1, y + 161);
            _with2.DrawString("MARCA", _Fuente10, Brushes.Black, x2, y + 161);
            _with2.DrawString("COSTO", _Fuente10, Brushes.Black, x3, y + 161);
            _with2.DrawString("CANTIDAD", _Fuente10, Brushes.Black, x4, y + 161);
            _with2.DrawString("TOTAL", _Fuente10, Brushes.Black, x5, y + 161);
            _with2.DrawLine(Pens.Black, x1, y + 175, 700, y + 175);

            y = y + 176;
            foreach (Entities.Compras compra in OrdenCompra.Compras)
            {
                _with2.DrawString(Strings.UCase(compra.Refaccion_Descripcion), _Fuente10, Brushes.Black, x1, y);
                _with2.DrawString(Entities.MarcasRefacciones.Read(compra.MarcaRefaccion_ID).Nombre.ToUpper(), _Fuente10, Brushes.Black, x2, y);
                _with2.DrawString(Strings.Format(compra.CostoUnitario, "$ #,###.00"), _Fuente10, Brushes.Black, x3, y);
                _with2.DrawString(Strings.Format(compra.Cantidad, "$ #,###.00"), _Fuente10, Brushes.Black, x4, y);
                _with2.DrawString(Strings.Format(compra.Cantidad * compra.CostoUnitario, "$ #,###.00"), _Fuente10, Brushes.Black, x5, y);
                y += 15;
            }

            _with2.DrawLine(Pens.Black, x1, y + 15, 700, y + 15);
            _with2.DrawString("SUBTOTAL:", _Fuente10, Brushes.Black, x2 + 150, y + 16);
            _with2.DrawString(Strings.Format(OrdenCompra.Subtotal, "$ ##,###.00"), _Fuente10Bold, Brushes.Black, x5, y + 16);

            _with2.DrawString("IVA:", _Fuente10, Brushes.Black, x2 + 150, y + 31);
            _with2.DrawString(Strings.Format(OrdenCompra.IVA, "$ ##,###.00"), _Fuente10Bold, Brushes.Black, x5, y + 31);

            _with2.DrawString("TOTAL:", _Fuente10, Brushes.Black, x2 + 150, y + 46);
            _with2.DrawString(Strings.Format(OrdenCompra.Total, "$ ##,###.00"), _Fuente10Bold, Brushes.Black, x5, y + 46);

            _with2.DrawString("_________________________________________", _Fuente10, Brushes.Black, x2 + 150, y + 100);
            _with2.DrawString("JEFE ALMACEN", _Fuente10, Brushes.Black, x2 + 150, y + 120);
        }
예제 #5
0
 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     e.Graphics.DrawImage(bmp, 0, 0);
 }
예제 #6
0
파일: Form1.cs 프로젝트: Beran1353/Notepad
 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     e.Graphics.DrawString(txtnotepad.Text, txtnotepad.Font, Brushes.Black, 0, 0);
 }
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Rectangle destRect = new Rectangle(0, 0, 1150, 770);

            e.Graphics.DrawImage(memoryImage, destRect, 0, 0, memoryImage.Width, memoryImage.Height, System.Drawing.GraphicsUnit.Pixel);             //.Pixel像素
        }
        protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
        {
            baseOnPrintPage(e);
            int printHeight;
            int printWidth;
            int leftMargin;
            int rightMargin;

            //Set print area size and margins
            {
                printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
                printWidth  = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
                leftMargin  = base.DefaultPageSettings.Margins.Left;
                //X
                rightMargin = base.DefaultPageSettings.Margins.Top;
                //Y
            }

            int startwidth  = 0;
            int startheight = 50;

            for (int i = 0; i < 96; i++)
            {
                int eachheight = 60, eachwidth = 130;
                if (keys.Count == 0)
                {
                    break;
                }

                KeyCollectionItem kci     = keys[0];
                string            address = kci.GetAddressBase58();

                string privkey = kci.PrivateKey;

                keys.RemoveAt(0);

                int thiscodeX = startwidth + eachwidth * (i / 16);
                int thiscodeY = startheight + eachheight * (i % 16);

                // ----------------------------------------------------------------
                // Coin insert with public and private QR codes.  Fits 8 to a page.
                // ----------------------------------------------------------------


                float CircleDiameterInches = (7F / 16F); // 7/16"

                // draw the private key circle
                using (Pen blackpen = new Pen(Color.Black)) {
                    // print some alignment marks for use in laser cutting
                    if (i == 0)
                    {
                        e.Graphics.FillRectangle(Brushes.Black, startwidth + eachwidth * 3F, startheight, 0.01F, 0.01F);
                        e.Graphics.FillRectangle(Brushes.Black, startwidth + eachwidth * 3F, (float)startheight + (float)eachheight * 8.5F, 0.01F, 0.01F);
                        e.Graphics.FillRectangle(Brushes.Black, startwidth + eachwidth * 3F, (float)startheight + (float)eachheight * 17F, 0.01F, 0.01F);
                    }


                    blackpen.Width = (1F / 72F);

                    e.Graphics.DrawEllipse(blackpen, thiscodeX + 30F, thiscodeY + 10F, CircleDiameterInches * 100F, CircleDiameterInches * 100F);

                    // Over 30 characters? do a folding insert at 95% diameter away
                    if (privkey.Length > 30)
                    {
                        e.Graphics.DrawEllipse(blackpen, thiscodeX + 30F, thiscodeY + 10F + (CircleDiameterInches * 95F), CircleDiameterInches * 100F, CircleDiameterInches * 100F);
                        e.Graphics.FillEllipse(Brushes.White, thiscodeX + 30F, thiscodeY + 10F + (CircleDiameterInches * 95F), CircleDiameterInches * 100F, CircleDiameterInches * 100F);
                    }
                    e.Graphics.FillEllipse(Brushes.White, thiscodeX + 30F, thiscodeY + 10F, CircleDiameterInches * 100F, CircleDiameterInches * 100F);
                }



                int[]  charsPerLine = new int[] { 4, 7, 8, 7, 4, 0, 4, 7, 8, 7, 4 };
                string privkeyleft  = privkey;
                // if it's going to take two circles, add hyphens
                if (privkeyleft.Length > 30)
                {
                    privkeyleft = privkeyleft.Substring(0, 29) + "--" + privkeyleft.Substring(29);
                }
                string privkeytoprint = "";
                for (int c = 0; c < 11; c++)
                {
                    if (charsPerLine[c] == 0)
                    {
                        privkeytoprint += "\r\n";
                    }
                    else
                    {
                        if (privkeyleft.Length > charsPerLine[c])
                        {
                            privkeytoprint += privkeyleft.Substring(0, charsPerLine[c]) + "\r\n";
                            privkeyleft     = privkeyleft.Substring(charsPerLine[c]);
                        }
                        else
                        {
                            privkeytoprint += privkeyleft + "\r\n";
                            privkeyleft     = "";
                        }
                    }
                }
                using (StringFormat sfcenter = new StringFormat()) {
                    sfcenter.Alignment = StringAlignment.Center;
                    e.Graphics.DrawString(privkeytoprint, fontsmall, Brushes.Black, thiscodeX + 30F + (CircleDiameterInches * 100F / 2F), thiscodeY + 14F, sfcenter);
                }

                // draw the address QR code
                using (Bitmap b2 = QR.EncodeQRCode(address)) {
                    e.Graphics.DrawImage(b2, thiscodeX + 80, thiscodeY + 10, 50, 50);
                }

                e.Graphics.RotateTransform(-90F);
                // transform 90 degrees changes our coordinate space so we can do sideways text.
                // must swap xy and value supplied as x parameter must be negative
                // instead of             it's now
                //        -Y                  +X
                //        |                   |
                //  -X-------+X        -Y----------+Y
                //        | PRINT             | PRINT
                //        +Y                  -X


                using (StringFormat sfright = new StringFormat()) {
                    sfright.Alignment = StringAlignment.Far;
                    e.Graphics.DrawString(address.Substring(0, 12) + "\r\n" + address.Substring(12, 12) + "\r\n" + address.Substring(24), fontsmall, Brushes.Black,
                                          -(float)(thiscodeY + 10),
                                          (float)(thiscodeX + 130), sfright);
                }
                // get out of sideways mode
                e.Graphics.RotateTransform(90F);
            }
            if (keys.Count != 0)
            {
                e.HasMorePages = true;
            }
        }
예제 #9
0
 /// <summary>
 /// 打印每一页时
 /// </summary>
 void pdocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     e.Graphics.DrawImage(this.P_bgimg.BackgroundImage, 0, 0, this.P_bgimg.Width, P_bgimg.Height); //底图
     PrintEditData(e);                                                                             //数据
 }
예제 #10
0
        private void printDocument1_PrintPage(object sender,
                                              System.Drawing.Printing.PrintPageEventArgs e)
        {
            // Display the invoice in a Print Preview dialog box.

            Font   printFont       = new Font("Arial", 12);
            Font   headingFont     = new Font("Arial", 14, FontStyle.Bold);
            float  lineHeightFloat = (float)printFont.GetHeight() + 2f;
            float  column1Float    = e.MarginBounds.Left;
            float  yFloat          = e.MarginBounds.Top;
            float  column2Float    = 200f;
            float  column3Float    = 250f;
            float  column4Float    = 500f;
            float  column5Float    = 600f;
            string lineString;

            // Set up heading lines.
            lineString = "Look Sharp Fitness Center";
            e.Graphics.DrawString(lineString, headingFont, Brushes.Black,
                                  column3Float, yFloat);
            yFloat    += (lineHeightFloat * 2);
            lineString = "Drink Sales Receipt  " + DateTime.Today.ToString("d");
            e.Graphics.DrawString(lineString, printFont, Brushes.Black,
                                  column3Float, yFloat);
            yFloat += (lineHeightFloat * 2);
            e.Graphics.DrawString("Quantity", headingFont, Brushes.Black,
                                  column1Float, yFloat);
            e.Graphics.DrawString("Size", headingFont, Brushes.Black,
                                  column2Float, yFloat);
            e.Graphics.DrawString("Drink Type", headingFont, Brushes.Black,
                                  column3Float, yFloat);
            e.Graphics.DrawString("Unit Price", headingFont, Brushes.Black,
                                  column4Float, yFloat);
            e.Graphics.DrawString("Extended Price", headingFont, Brushes.Black,
                                  column5Float, yFloat);
            column5Float += 30;
            yFloat       += (lineHeightFloat * 2);

            // Loop through the transactions.
            foreach (OrderItem oneOrder in drinkOrder)
            {
                // Only print valid orders.
                if (oneOrder.quantityInteger != 0)
                {
                    // Set up a line.
                    // Quantity.
                    e.Graphics.DrawString(oneOrder.quantityInteger.ToString(),
                                          printFont, Brushes.Black, column1Float, yFloat);

                    // Size.
                    e.Graphics.DrawString(oneOrder.sizeString,
                                          printFont, Brushes.Black, column2Float, yFloat);

                    // Drink type.
                    e.Graphics.DrawString(oneOrder.drinkString, printFont,
                                          Brushes.Black, column3Float, yFloat);

                    // Unit Price.
                    e.Graphics.DrawString(oneOrder.priceDecimal.ToString("c"),
                                          printFont, Brushes.Black, column4Float, yFloat);

                    // Extended Price.
                    decimal extendedPriceDecimal = oneOrder.priceDecimal
                                                   * oneOrder.quantityInteger;
                    e.Graphics.DrawString(extendedPriceDecimal.ToString("c"),
                                          printFont, Brushes.Black, column5Float, yFloat);

                    // Increment the Y position for the next line.
                    yFloat += (lineHeightFloat * 2);
                }
            }

            // Print total.
            e.Graphics.DrawString("Total: ", headingFont, Brushes.Black,
                                  column1Float, yFloat);
            e.Graphics.DrawString(totalOrderDecimal.ToString("c"), printFont,
                                  Brushes.Black, column5Float, yFloat);
        }
예제 #11
0
        protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
        {
            base.OnPrintPage(e);
            int   printHeight;
            int   printWidth;
            int   leftMargin;
            int   rightMargin;
            Int32 lines;
            Int32 chars;

            //Set print area size and margins
            {
                printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
                printWidth  = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
                leftMargin  = base.DefaultPageSettings.Margins.Left;
                //X
                rightMargin = base.DefaultPageSettings.Margins.Top;
                //Y
            }


            for (int i = 0; i < 16; i++)
            {
                int eachheight = 120;

                switch (PrintMode)
                {
                case PrintModes.PubPrivQR:
                    if (i >= 8)
                    {
                        i = 999;
                    }
                    eachheight = 120;
                    break;

                case PrintModes.PsyBanknote:
                    if (i >= 3)
                    {
                        i = 999;
                    }
                    eachheight = 365;
                    break;
                }

                if (i == 999)
                {
                    break;
                }



                if (PrintMode == PrintModes.PubPrivQR && i >= 8)
                {
                    break;
                }

                if (PrintMode == PrintModes.PsyBanknote && i >= NotesPerPage)
                {
                    break;
                }

                if (keys.Count == 0)
                {
                    break;
                }

                int thiscodeX = 50;
                int thiscodeY = 50 + eachheight * i;
                if (i >= 8)
                {
                    thiscodeX = 450;
                    thiscodeY = 50 + eachheight * (i - 8);
                }

                //    T-------------------------------|
                //    |                               |
                //    |                               |
                //    |                               |
                //    |                               |
                //    |                               |
                //    |-------------------------------|
                //
                //    T = thiscodeX,thiscodeY
                //


                // Load the Ubuntu font directly from a file so it doesn't need to be installed on the system.
                if (UbuntuFontLoaded == false)
                {
                    UbuntuFontLoaded = true;
                    try {
                        System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
                        pfc.AddFontFile("Ubuntu-R.ttf");
                    } catch { }
                }

                ubuntufont = new Font("Ubuntu", 6);
                ubuntumid  = new Font("Ubuntu", 9);
                ubuntubig  = new Font("Ubuntu", 17);


                KeyCollectionItem k = (KeyCollectionItem)keys[0];
                keys.RemoveAt(0);

                string privkey = k.PrivateKey;
                if (PreferUnencryptedPrivateKeys)
                {
                    if (k.EncryptedKeyPair != null && k.EncryptedKeyPair.IsUnencryptedPrivateKeyAvailable())
                    {
                        privkey = k.EncryptedKeyPair.GetUnencryptedPrivateKey().PrivateKey;
                    }
                }

                Bitmap b = QR.EncodeQRCode(privkey);

                if (PrintMode == PrintModes.PsyBanknote)
                {
                    if (BitcoinNote == null)
                    {
                        BitcoinNote = Image.FromFile(ImageFilename);
                    }

                    float desiredScale = 550F;

                    float scalefactor = (desiredScale / 650.0F);
                    float leftOffset  = (float)printWidth - desiredScale;


                    // draw the note
                    e.Graphics.DrawImage(BitcoinNote,
                                         leftOffset + scalefactor * (float)thiscodeX,
                                         scalefactor * (float)thiscodeY, (float)650F * scalefactor,
                                         (float)650F * scalefactor * (float)BitcoinNote.Height / (float)BitcoinNote.Width);

                    // draw the private QR
                    e.Graphics.DrawImage(b, leftOffset + scalefactor * (float)(thiscodeX + 472),
                                         scalefactor * (float)(thiscodeY + 140),
                                         scalefactor * 145F,
                                         scalefactor * 147F);

                    // draw the public QR
                    Bitmap b2 = QR.EncodeQRCode(k.GetAddressBase58());
                    e.Graphics.DrawImage(b2,
                                         leftOffset + scalefactor * (float)(thiscodeX + 39),
                                         scalefactor * (float)(thiscodeY + 90), scalefactor * 128F, scalefactor * 128F);

                    // write bitcoin address
                    StringFormat sf = new StringFormat();
                    //sf.FormatFlags |= StringFormatFlags.DirectionVertical | StringFormatFlags.DirectionRightToLeft;

                    e.Graphics.RotateTransform(-90F);
                    e.Graphics.DrawString("Bitcoin Address\r\n" + k.GetAddressBase58(), ubuntumid, Brushes.Black,
                                          -scalefactor * (float)(thiscodeY + 338),
                                          leftOffset + scalefactor * (float)(thiscodeX + 170),

                                          sf);

                    // write private key
                    string whattoprint;
                    if (privkey.Length > 30)
                    {
                        whattoprint = privkey.Substring(0, 25) + "\r\n" + privkey.Substring(25);
                    }
                    else
                    {
                        whattoprint = "\r\n" + privkey;
                    }
                    float xpos = 444;
                    if (privkey.StartsWith("6"))
                    {
                        whattoprint = "Password Required\r\n" + whattoprint;
                        xpos       -= 10;
                    }

                    e.Graphics.DrawString(whattoprint, ubuntufont, Brushes.Black,
                                          -scalefactor * (float)(thiscodeY + 290),
                                          leftOffset + scalefactor * (float)(thiscodeX + xpos),
                                          sf);


                    e.Graphics.RotateTransform(90F);

                    // write denomination, if any
                    if ((Denomination ?? "") != "")
                    {
                        e.Graphics.DrawString(Denomination, ubuntubig, Brushes.Black,
                                              leftOffset + scalefactor * (float)(thiscodeX + 330),
                                              scalefactor * (float)(thiscodeY + 310)

                                              );
                    }

                    if (PrintMiniKeysWith1DBarcode && k.Address is MiniKeyPair)
                    {
                        Bitmap barcode1d = Barcode128b.GetBarcode(k.PrivateKey);
                        float  aspect1d  = (float)barcode1d.Width / (float)barcode1d.Height;
                        e.Graphics.DrawImage(barcode1d, leftOffset + scalefactor * (float)(thiscodeX + 231F),
                                             scalefactor * (float)(thiscodeY + 293),
                                             scalefactor * 420F,
                                             scalefactor * 50F);
                    }
                }
                else if (PrintMode == PrintModes.PrivQR)
                {
                    // ----------------------------------------------------------------
                    // Paper wallet with only private key QR code.  Fits 16 to a page.
                    // ----------------------------------------------------------------
                    e.Graphics.DrawImage(b, thiscodeX, thiscodeY, 100, 100);

                    e.Graphics.DrawString("Bitcoin address: " + k.GetAddressBase58(), fontsmall, Brushes.Black, thiscodeX + 110, thiscodeY);

                    string whattowrite;
                    if (privkey.Length > 30)
                    {
                        whattowrite = privkey.Substring(0, 25) + "\r\n" + privkey.Substring(25);
                    }
                    else
                    {
                        whattowrite = "\r\n" + privkey;
                    }
                    if (privkey.StartsWith("6"))
                    {
                        whattowrite = whattowrite + "\r\nPassword Required";
                    }


                    e.Graphics.DrawString(whattowrite, font, Brushes.Black, thiscodeX + 110, thiscodeY + 15);

                    if ((Denomination ?? "") != "")
                    {
                        e.Graphics.DrawString(Denomination + " BTC", fontbig, Brushes.Black, thiscodeX + 110, thiscodeY + 75);
                    }
                }
                else if (PrintMode == PrintModes.PubPrivQR)
                {
                    // ----------------------------------------------------------------
                    // Paper wallet with public and private QR codes.  Fits 8 to a page.
                    // ----------------------------------------------------------------

                    e.Graphics.DrawImage(b, thiscodeX + 600, thiscodeY, 100, 100);
                    QRCodeEncoder qr2 = new QRCodeEncoder();
                    qr2.QRCodeVersion = 3;

                    Bitmap b2 = qr2.Encode(k.GetAddressBase58());
                    e.Graphics.DrawImage(b2, thiscodeX, thiscodeY, 100, 100);

                    e.Graphics.DrawString("Bitcoin address:\r\n" + k.GetAddressBase58(), font, Brushes.Black, thiscodeX + 110, thiscodeY);

                    StringFormat sf = new StringFormat();
                    sf.Alignment = StringAlignment.Far; // right justify
                    string whattoprint = privkey;
                    if (privkey.StartsWith("6"))
                    {
                        whattoprint = whattoprint + "\r\nPassword Required";
                    }

                    e.Graphics.DrawString("Private key:\r\n" + whattoprint, font, Brushes.Black, thiscodeX + 597, thiscodeY + 65, sf);
                }
            }

            e.HasMorePages = keys.Count > 0;
        }
예제 #12
0
 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     e.Graphics.DrawString(textBox3.Text, new Font("Segoe UI Emoji", 12), Brushes.Black, 1, 1);
 }
예제 #13
0
        private void pDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            DataGridViewRow reg_grid;

            reg_grid = dgv_disc.CurrentRow;



            e.Graphics.DrawImage(Image.FromFile("logo_ete.jpg"), 50, 5);
            // texto = objimpressao.DrawString(string,fonte,cor,coluna,linha)
            e.Graphics.DrawString("RELATÓRIO GERAL DE ALUNOS", new System.Drawing.Font("Consolas", 14, FontStyle.Bold), Brushes.Black, 800, 55);
            //linha – cor, espessura, posição x – ponto inicial(coluna e linha), posição y – ponto final (coluna e linha)
            linha = 100;

            // cabeçalho de colunas
            e.Graphics.DrawString("Mat.  ", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 50, linha);
            e.Graphics.DrawString("Nome   ", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 100, linha);
            e.Graphics.DrawString("Data Nasc.", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 240, linha);
            e.Graphics.DrawString("Endereço", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 330, linha);
            e.Graphics.DrawString("Nº", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 490, linha);
            e.Graphics.DrawString("Bairro", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 550, linha);
            e.Graphics.DrawString("Cidade", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 630, linha);
            e.Graphics.DrawString("CEP", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 710, linha);
            e.Graphics.DrawString("RG", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 800, linha);
            e.Graphics.DrawString("CPF", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 900, linha);
            e.Graphics.DrawString("Telefone", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 1010, linha);
            e.Graphics.DrawString("Sexo", new System.Drawing.Font("Consola", 10, FontStyle.Bold), Brushes.Black, 1110, linha);
            linha = 130;

            e.Graphics.DrawLine(new Pen(Color.Black, 2), 50, 85, 1150, 85);

            while ((linha < 730) & (registro != fim))
            {
                // matricula
                e.Graphics.DrawString(reg_grid.Cells["Matricula"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 50, linha);
                // nome
                e.Graphics.DrawString(reg_grid.Cells["Nome"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 100, linha);
                // nasc
                e.Graphics.DrawString(String.Format("{0:dd/MM/yyyy}", reg_grid.Cells["Nasc"].Value), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 240, linha);
                // nasc
                e.Graphics.DrawString(reg_grid.Cells["Endereco"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 330, linha);
                // nasc
                e.Graphics.DrawString(reg_grid.Cells["numero"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 490, linha);
                // nasc
                e.Graphics.DrawString(reg_grid.Cells["bairro"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 550, linha);
                // nasc
                e.Graphics.DrawString(reg_grid.Cells["cidade"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 630, linha);
                // nasc
                e.Graphics.DrawString(reg_grid.Cells["cep"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 710, linha);
                // nasc
                e.Graphics.DrawString(reg_grid.Cells["RG"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 800, linha);
                // nasc
                e.Graphics.DrawString(reg_grid.Cells["cpf"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 900, linha);
                // nasc
                e.Graphics.DrawString(reg_grid.Cells["telefone"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 1010, linha);
                // nasc
                e.Graphics.DrawString(reg_grid.Cells["sexo"].Value.ToString(), new System.Drawing.Font("Consola", 10, FontStyle.Regular), Brushes.Black, 1110, linha);



                bs_disc.MoveNext();
                reg_grid = dgv_disc.CurrentRow; // atualizando a linha da grid para impressão

                registro += 1;                  // incrementando a variável contadora de registros

                linha += 30;                    // incrementando a variável para pular linha
            }

            //*****************************
            //imprime o rodapé do relatório
            //*****************************
            e.Graphics.DrawString("Total de Registros: " + registro.ToString(), new System.Drawing.Font("Consola", 9, FontStyle.Bold), Brushes.Black, 1000, 750);
            e.Graphics.DrawLine(new Pen(Color.Black, 1), 50, 770, 1150, 770);
            e.Graphics.DrawString("Data: " + System.DateTime.Now.ToString("dd/MM/yyyy"), new System.Drawing.Font("Consola", 9, FontStyle.Bold), Brushes.Black, 50, 790);
            e.Graphics.DrawString("Pág: " + pag.ToString(), new System.Drawing.Font("Consola", 9, FontStyle.Bold), Brushes.Black, 1000, 785);

            pag += 1;  // reajustando contadores de pag

            // trocando de página
            if ((pag > 1) & (registro < fim))
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;

                pag = 1; // variável para controlar o salto de página

                registro = 0;
                linha    = 0;
                bs_disc.MoveFirst();
            }
        }
예제 #14
0
 private void PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     //Print the contents.
     e.Graphics.DrawString(this.ProjectNameTextBox.Text, this.ProjectNameTextBox.Font, Brushes.Black, 10, 25);
     //e.Graphics.DrawImage(this.dataGridView1.Text, this.dataGridView1.Font, Brushes.Black, 10, 25);
 }
예제 #15
0
 private void PatientDailyDebt_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     ((clsCtl_DailyDebtReport)this.objController).PrintPage(e);
 }
예제 #16
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            try
            {
                int  iLeftMargin       = e.MarginBounds.Left;
                int  iTopMargin        = e.MarginBounds.Top;
                bool bMorePagesToPrint = false;
                int  iTmpWidth         = 0;
                bFirstPage = true;

                if (bFirstPage)
                {
                    foreach (DataGridViewColumn GridCol in dataGridView1.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;


                        arrColumnLefts.Add(iLeftMargin);
                        arrColumnWidths.Add(iTmpWidth);
                        iLeftMargin += iTmpWidth;
                    }
                }

                while (iRow <= dataGridView1.Rows.Count - 1)
                {
                    DataGridViewRow GridRow = dataGridView1.Rows[iRow];

                    iCellHeight = GridRow.Height + 30;
                    int iCount = 0;

                    if (iTopMargin + iCellHeight >= e.MarginBounds.Height + e.MarginBounds.Top)
                    {
                        bNewPage          = true;
                        bFirstPage        = false;
                        bMorePagesToPrint = true;
                        break;
                    }
                    else
                    {
                        if (bNewPage)
                        {
                            //Satılan biletler kelimesini sayfa sol yukarısına ekler
                            e.Graphics.DrawString("Satılan Biletler", new Font(buttonSorgu.Font, FontStyle.Bold),
                                                  Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top -
                                                  e.Graphics.MeasureString("Satılan Biletler", new Font(buttonSorgu.Font,
                                                                                                        FontStyle.Bold), e.MarginBounds.Width).Height - 5);


                            String strDate = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString();
                            //bugünün tarihini sayfanın sağına ekler
                            e.Graphics.DrawString(strDate + "  ", new Font(buttonSorgu.Font, FontStyle.Bold),
                                                  Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width -
                                                                                        e.Graphics.MeasureString(strDate + "  ", new Font(buttonSorgu.Font,
                                                                                                                                          FontStyle.Bold), e.MarginBounds.Width).Width - 10), e.MarginBounds.Top -
                                                  e.Graphics.MeasureString("Satılan Biletler", new Font(new Font(buttonSorgu.Font,
                                                                                                                 FontStyle.Bold), FontStyle.Bold), e.MarginBounds.Width).Height - 5);

                            //toplam ücreti sayfa sol altına ekler
                            e.Graphics.DrawString("Toplam ücret: " + toplam + "TL", new Font(buttonSorgu.Font, FontStyle.Bold),
                                                  Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width -
                                                                                        e.Graphics.MeasureString("TOPLAM ÜCRET: " + toplam + "TL", new Font(buttonSorgu.Font,
                                                                                                                                                            FontStyle.Bold), e.MarginBounds.Width).Width - 10), e.MarginBounds.Bottom -
                                                  e.Graphics.MeasureString("Satılan Biletler", new Font(new Font(buttonSorgu.Font,
                                                                                                                 FontStyle.Bold), FontStyle.Bold), e.MarginBounds.Width).Height - 5);


                            iTopMargin = e.MarginBounds.Top;
                            foreach (DataGridViewColumn GridCol in dataGridView1.Columns)
                            {
                                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.HeaderText, GridCol.InheritedStyle.Font,
                                                      new SolidBrush(GridCol.InheritedStyle.ForeColor),
                                                      new RectangleF((int)arrColumnLefts[iCount], iTopMargin,
                                                                     (int)arrColumnWidths[iCount], iHeaderHeight), strFormat);
                                iCount++;
                            }
                            bNewPage    = false;
                            iTopMargin += iHeaderHeight;
                        }
                        iCount = 0;

                        foreach (DataGridViewCell Cel in GridRow.Cells)
                        {
                            if (Cel.Value != null)
                            {
                                e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font,
                                                      new SolidBrush(Cel.InheritedStyle.ForeColor),
                                                      new RectangleF((int)arrColumnLefts[iCount], (float)iTopMargin,
                                                                     (int)arrColumnWidths[iCount], (float)iCellHeight), strFormat);
                            }

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

                            iCount++;
                        }
                    }
                    iRow++;
                    iTopMargin += iCellHeight;
                }


                if (bMorePagesToPrint)
                {
                    e.HasMorePages = true;
                }
                else
                {
                    e.HasMorePages = false;
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #17
0
 private void rptChargeView_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     ((clsCtl_DailyDebtReport)this.objController).PrintvChargeView(sender, e);
 }
예제 #18
0
 public void Imprimir(System.Drawing.Printing.PrintPageEventArgs e)
 {
     _ticket.setControlador(e);
     _ticket.Reporte(_lista);
 }
예제 #19
0
        private void printDocx_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //Inicio del encabezado del Documento.
            Conexion   r     = new Conexion();
            string     query = "SELECT * FROM Empresa ; ";
            SqlCommand sqlQ  = new SqlCommand(query, r.GetCONN());

            r.OpenCnn();
            SqlDataReader read;
            Image         img  = null; //Variables Guardar los Datos de la Empresa.
            String        name = "";
            String        nit  = "";
            String        tel  = "";
            String        cel  = "";
            String        dir  = "";
            String        web  = "";

            int width       = 0;
            int height      = 0;
            int x           = 0;
            int y           = 0;
            int rowheight   = 0;
            int columnwidth = 0;

            StringFormat str = new StringFormat();

            str.Alignment     = StringAlignment.Near;
            str.LineAlignment = StringAlignment.Center;
            str.Trimming      = StringTrimming.EllipsisCharacter;
            Pen p = new Pen(Color.Black, 2.5f);

            try
            {
                read = sqlQ.ExecuteReader();

                while (read.Read())
                { // El campo productImage primero se almacena en un buffer
                    byte[] imageBuffer = (byte[])(read[9]);
                    name = read.GetString(1);
                    nit  = read.GetString(0);
                    tel  = read.GetInt32(3).ToString();
                    cel  = read.GetInt32(4).ToString();
                    dir  = read.GetString(2);
                    web  = read.GetString(8);

                    if (imageBuffer == null || read[9] == null)
                    {
                        img = null;
                    }
                    else
                    {
                        System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer);
                        img = Image.FromStream(ms); //Logotipo
                    }
                }                                   //Datos de la Empresa.
                e.Graphics.DrawImage(img, 20, 20, img.Width, img.Height);
                e.Graphics.DrawString(name, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 20);
                e.Graphics.DrawString(nit, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 50);
                e.Graphics.DrawString(tel, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 80);
                e.Graphics.DrawString(cel, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 130, 80);
                e.Graphics.DrawString(dir, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 100);
                e.Graphics.DrawString(web, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 130);
                e.Graphics.DrawString("Registro de Ventas", new Font("Lucida Sans", 18), new SolidBrush(Color.DarkBlue), img.Width + 400, 60);
                //fin Encabezado Documento.

                //Insert DataGrid Print.
                #region Draw Column 1
                e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(10, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height));
                e.Graphics.DrawRectangle(Pens.Black, 10, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height);
                e.Graphics.DrawString(dataGridClientes.Columns[0].HeaderText, dataGridClientes.Font, Brushes.Black, new RectangleF(10, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height), str);
                #endregion

                #region Draw column 2
                e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(10 + dataGridClientes.Columns[0].Width - 30, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height));
                e.Graphics.DrawRectangle(Pens.Black, 10 + dataGridClientes.Columns[0].Width - 30, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height);
                e.Graphics.DrawString(dataGridClientes.Columns[1].HeaderText, dataGridClientes.Font, Brushes.Black, new RectangleF(10 + dataGridClientes.Columns[0].Width - 30, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height), str);
                #endregion

                #region Draw column 3
                e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(95 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height));
                e.Graphics.DrawRectangle(Pens.Black, 95 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height);
                e.Graphics.DrawString(dataGridClientes.Columns[16].HeaderText, dataGridClientes.Font, Brushes.Black, new RectangleF(95 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height), str);
                #endregion

                #region Draw column 4
                e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(185 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height));
                e.Graphics.DrawRectangle(Pens.Black, 185 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height);
                e.Graphics.DrawString(dataGridClientes.Columns[5].HeaderText, dataGridClientes.Font, Brushes.Black, new RectangleF(185 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height), str);
                #endregion

                #region Draw column 5
                e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(265 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height));
                e.Graphics.DrawRectangle(Pens.Black, 265 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height);
                e.Graphics.DrawString(dataGridClientes.Columns[9].HeaderText, dataGridClientes.Font, Brushes.Black, new RectangleF(265 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width, dataGridClientes.Rows[0].Height), str);
                #endregion

                #region Draw column 6
                e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(365 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width + 10, dataGridClientes.Rows[0].Height));
                e.Graphics.DrawRectangle(Pens.Black, 365 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width + 10, dataGridClientes.Rows[0].Height);
                e.Graphics.DrawString(dataGridClientes.Columns[11].HeaderText, dataGridClientes.Font, Brushes.Black, new RectangleF(365 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width + 10, dataGridClientes.Rows[0].Height), str);
                #endregion

                #region Draw column 7
                e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(465 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width - 20, dataGridClientes.Rows[0].Height));
                e.Graphics.DrawRectangle(Pens.Black, 465 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width - 20, dataGridClientes.Rows[0].Height);
                e.Graphics.DrawString(dataGridClientes.Columns[14].HeaderText, dataGridClientes.Font, Brushes.Black, new RectangleF(465 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width - 20, dataGridClientes.Rows[0].Height), str);
                #endregion

                #region Draw column 8
                e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(565 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width - 20, dataGridClientes.Rows[0].Height));
                e.Graphics.DrawRectangle(Pens.Black, 565 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width - 20, dataGridClientes.Rows[0].Height);
                e.Graphics.DrawString(dataGridClientes.Columns[15].HeaderText, dataGridClientes.Font, Brushes.Black, new RectangleF(565 + dataGridClientes.Columns[0].Width, 200, dataGridClientes.Columns[0].Width - 20, dataGridClientes.Rows[0].Height), str);
                #endregion

                #region Draw Rows N
                width  = 10 + dataGridClientes.Columns[0].Width;
                height = 200;
                //variable i is declared at class level to preserve the value of i if e.hasmorepages is true
                while (i < dataGridClientes.Rows.Count)
                {
                    if (height > e.MarginBounds.Height)
                    {
                        height         = 200;
                        width          = 10;
                        e.HasMorePages = true;
                        return;
                    }

                    height += dataGridClientes.Rows[i].Height;
                    //Draw Row 1
                    e.Graphics.DrawRectangle(Pens.Black, 10, height, dataGridClientes.Columns[0].Width - 30, dataGridClientes.Rows[0].Height);
                    e.Graphics.DrawString(dataGridClientes.Rows[i].Cells[0].FormattedValue.ToString(), dataGridClientes.Font, Brushes.Black, new RectangleF(10, height, dataGridClientes.Columns[0].Width - 30, dataGridClientes.Rows[0].Height), str);
                    //Draw Row 2
                    e.Graphics.DrawRectangle(Pens.Black, 10 + dataGridClientes.Columns[0].Width - 30, height, dataGridClientes.Columns[0].Width - 25, dataGridClientes.Rows[0].Height);
                    e.Graphics.DrawString(dataGridClientes.Rows[i].Cells[1].Value.ToString(), dataGridClientes.Font, Brushes.Black, new RectangleF(10 + dataGridClientes.Columns[0].Width - 30, height, dataGridClientes.Columns[0].Width - 25, dataGridClientes.Rows[0].Height), str);
                    //Draw Row 3
                    e.Graphics.DrawRectangle(Pens.Black, 95 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 50, dataGridClientes.Rows[0].Height);
                    e.Graphics.DrawString(dataGridClientes.Rows[i].Cells[16].Value.ToString(), dataGridClientes.Font, Brushes.Black, new RectangleF(95 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 50, dataGridClientes.Rows[0].Height), str);
                    //Draw Row 4
                    e.Graphics.DrawRectangle(Pens.Black, 165 + dataGridClientes.Columns[0].Width + 20, height, dataGridClientes.Columns[0].Width - 60, dataGridClientes.Rows[0].Height);
                    e.Graphics.DrawString(dataGridClientes.Rows[i].Cells[5].Value.ToString(), dataGridClientes.Font, Brushes.Black, new RectangleF(165 + dataGridClientes.Columns[0].Width + 20, height, dataGridClientes.Columns[0].Width - 60, dataGridClientes.Rows[0].Height), str);
                    //Draw Row 5
                    e.Graphics.DrawRectangle(Pens.Black, 265 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 40, dataGridClientes.Rows[0].Height);
                    e.Graphics.DrawString(dataGridClientes.Rows[i].Cells[9].Value.ToString(), dataGridClientes.Font, Brushes.Black, new RectangleF(265 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 40, dataGridClientes.Rows[0].Height), str);
                    //Draw Row 6
                    e.Graphics.DrawRectangle(Pens.Black, 365 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 40, dataGridClientes.Rows[0].Height);
                    e.Graphics.DrawString(dataGridClientes.Rows[i].Cells[11].Value.ToString(), dataGridClientes.Font, Brushes.Black, new RectangleF(365 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 40, dataGridClientes.Rows[0].Height), str);
                    //Draw Row 7
                    e.Graphics.DrawRectangle(Pens.Black, 465 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 40, dataGridClientes.Rows[0].Height);
                    e.Graphics.DrawString(dataGridClientes.Rows[i].Cells[14].Value.ToString(), dataGridClientes.Font, Brushes.Black, new RectangleF(465 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 40, dataGridClientes.Rows[0].Height), str);
                    //Draw Row 8
                    e.Graphics.DrawRectangle(Pens.Black, 565 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 20, dataGridClientes.Rows[0].Height);
                    e.Graphics.DrawString(dataGridClientes.Rows[i].Cells[15].Value.ToString(), dataGridClientes.Font, Brushes.Black, new RectangleF(565 + dataGridClientes.Columns[0].Width, height, dataGridClientes.Columns[0].Width - 20, dataGridClientes.Rows[0].Height), str);

                    width += dataGridClientes.Columns[0].Width;
                    i++;
                }

                #endregion

                r.CerrarCnn();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #20
0
        private void printDocument1_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 dbGridView.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 <= dbGridView.Rows.Count - 1)
                {
                    DataGridViewRow GridRow = dbGridView.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("Fleet Tracking SQL Report Output",
                                                  new Font(dbGridView.Font, FontStyle.Bold),
                                                  Brushes.Black, e.MarginBounds.Left,
                                                  e.MarginBounds.Top - e.Graphics.MeasureString("Fleet Tracking SQL Report Output",
                                                                                                new Font(dbGridView.Font, FontStyle.Bold),
                                                                                                e.MarginBounds.Width).Height - 13);

                            String strDate = DateTime.Now.ToLongDateString() + " " +
                                             DateTime.Now.ToShortTimeString();
                            //Draw Date
                            e.Graphics.DrawString(strDate,
                                                  new Font(dbGridView.Font, FontStyle.Bold), Brushes.Black,
                                                  e.MarginBounds.Left +
                                                  (e.MarginBounds.Width - e.Graphics.MeasureString(strDate,
                                                                                                   new Font(dbGridView.Font, FontStyle.Bold),
                                                                                                   e.MarginBounds.Width).Width),
                                                  e.MarginBounds.Top - e.Graphics.MeasureString("Customer Summary",
                                                                                                new Font(new Font(dbGridView.Font, FontStyle.Bold),
                                                                                                         FontStyle.Bold), e.MarginBounds.Width).Height - 13);

                            //Draw Columns
                            iTopMargin = e.MarginBounds.Top;
                            foreach (DataGridViewColumn GridCol in dbGridView.Columns)
                            {
                                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.HeaderText,
                                                      GridCol.InheritedStyle.Font,
                                                      new SolidBrush(GridCol.InheritedStyle.ForeColor),
                                                      new RectangleF((int)arrColumnLefts[iCount], iTopMargin,
                                                                     (int)arrColumnWidths[iCount], iHeaderHeight), strFormat);
                                iCount++;
                            }
                            bNewPage    = false;
                            iTopMargin += iHeaderHeight;
                        }
                        iCount = 0;
                        //Draw Columns Contents
                        foreach (DataGridViewCell Cel in GridRow.Cells)
                        {
                            if (Cel.Value != null)
                            {
                                e.Graphics.DrawString(Cel.Value.ToString(),
                                                      Cel.InheritedStyle.Font,
                                                      new SolidBrush(Cel.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);
            }
        }
예제 #21
0
        private void SetInvoiceData(Graphics g, System.Drawing.Printing.PrintPageEventArgs e)
        {// Set Invoice Table:
            string  FieldValue     = "";
            int     CurrentRecord  = 0;
            int     RecordsPerPage = 0; // twenty items in a page
            decimal Amount         = 0;
            bool    StopReading    = false;
            // Set Table Head:
            //            int xProductID = leftMargin;
            int xProductID = leftMargin - 90;

            for (int i = 10; i <= 250; i++)
            {
                g.DrawString("-", InvoiceTitle, BlueBrush, i, CurrentY);
            }
            CurrentY = CurrentY + InvoiceFontHeight;
            g.DrawString("Sr", InvoiceTitle, BlueBrush, xProductID, CurrentY);

            int xProductName = xProductID + (int)g.MeasureString("Products", InvoiceFont).Width + 4;

            g.DrawString("Products", InvoiceTitle, BlueBrush, xProductName - 30, CurrentY);

            int xQuantity = xProductName + (int)g.MeasureString("Qty", InvoiceFont).Width + 72;

            g.DrawString("Qty", InvoiceTitle, BlueBrush, xQuantity - 50, CurrentY);


            int xUnit = xQuantity + (int)g.MeasureString("Unit", InvoiceFont).Width + 4;

            g.DrawString("Unit", InvoiceTitle, BlueBrush, xUnit - 55, CurrentY);

            int xRate = xUnit + (int)g.MeasureString("Rate", InvoiceFont).Width + 4;

            g.DrawString("Rate", InvoiceTitle, BlueBrush, xRate - 60, CurrentY);

            AmountPosition = xRate + (int)g.MeasureString("Amount", InvoiceFont).Width + 4;
            g.DrawString("Amount", InvoiceTitle, BlueBrush, AmountPosition - 50, CurrentY);
            // Set Invoice Table:
            CurrentY = CurrentY + InvoiceFontHeight + 8;

            for (int i = 10; i <= 250; i++)
            {
                g.DrawString("-", InvoiceTitle, BlueBrush, i, CurrentY);
            }

            CurrentY = CurrentY + InvoiceFontHeight + 8;

            AppConfiguration a              = new AppConfiguration();
            float            TotalQuantity  = 0;
            float            TotalAmount    = 0;
            float            TotalTaxAmount = 0;

            try
            {
                using (SqlConnection con = new SqlConnection(ConnString))
                {
                    using (SqlCommand cmd = new SqlCommand("GetOrderForPrintingByOrderID", con))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@OrderID", a.OrderID);
                        cmd.CommandTimeout = 0;
                        con.Open();
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        DataTable      dt = new DataTable();
                        da.Fill(dt);
                        ItemValue = 0;
                        if (dt.Rows.Count > 0)
                        {
                            RecordsPerPage = Convert.ToInt32(dt.Rows.Count);
                            while (CurrentRecord < RecordsPerPage)
                            {
                                DataRow dr = (DataRow)dt.Rows[CurrentRecord];
                                FieldValue = "" + dr["SNO"];
                                g.DrawString(FieldValue, InvoiceFont, BlackBrush, xProductID, CurrentY);
                                FieldValue = "" + dr["ItemName"];
                                // if Length of (Product Name) > 20, Draw 20 character only
                                //if (FieldValue.Length > 50)
                                //    FieldValue = FieldValue.Remove(50, FieldValue.Length - 50);
                                g.DrawString(FieldValue, InvoiceFont, BlackBrush, xProductName - 30, CurrentY);
                                CurrentY   = CurrentY + InvoiceFontHeight;
                                FieldValue = "" + dr["Qty"];
                                float  Quantity       = float.Parse(FieldValue);
                                string taxamount      = "" + dr["TaxAmount"];
                                string amount         = "" + dr["Amount"];
                                float  QuantityAmount = float.Parse(taxamount) + float.Parse(amount);
                                TotalAmount = TotalAmount + float.Parse(taxamount) + float.Parse(amount);
                                ItemValue   = ItemValue + float.Parse(amount);
                                float RateAmount = QuantityAmount / Quantity;
                                TotalQuantity = TotalQuantity + float.Parse(FieldValue);
                                g.DrawString(FieldValue, InvoiceFont, BlackBrush, xQuantity - 50, CurrentY);
                                FieldValue = "" + dr["Unit"];
                                g.DrawString(FieldValue, InvoiceFont, BlackBrush, xUnit - 55, CurrentY);
                                FieldValue = String.Format("{0:0.00}", RateAmount);
                                g.DrawString(FieldValue, InvoiceFont, BlackBrush, xRate - 60, CurrentY);

                                // Format Extended Price and Align to Right:
                                FieldValue = String.Format("{0:0.00}", (float.Parse(amount) + float.Parse(taxamount)));

                                int xAmount = AmountPosition + (int)g.MeasureString("Amount", InvoiceFont).Width;
                                xAmount    = xAmount - (int)g.MeasureString(FieldValue, InvoiceFont).Width;
                                FieldValue = String.Format("{0:0.00}", QuantityAmount);
                                g.DrawString(FieldValue, InvoiceFont, BlackBrush, xAmount - 50, CurrentY);
                                CurrentY = CurrentY + InvoiceFontHeight;

                                int xTax = leftMargin - 60;
                                TotalTaxAmount = TotalTaxAmount + float.Parse(taxamount);
                                //                                TotalAmount = TotalAmount + TotalTaxAmount;
                                FieldValue = "T " + String.Format("{0:0.00}", dr["TaxRate"]) + "% " + String.Format("{0:0.00}", dr["TaxAmount"]);
                                g.DrawString(FieldValue, InvoiceFont, BlackBrush, xTax, CurrentY);


                                CurrentY = CurrentY + InvoiceFontHeight;
                                if (CurrentRecord == RecordsPerPage)
                                {
                                    StopReading = true;
                                    break;
                                }

                                CurrentRecord++;
                            }
                            for (int i = 10; i <= 250; i++)
                            {
                                g.DrawString("-", InvoiceTitle, BlueBrush, i, CurrentY);
                            }

                            CurrentY = CurrentY + InvoiceFontHeight;

                            int xTotal = leftMargin - 90;
                            FieldValue = "Total Qty:           " + String.Format("{0:0.00}", TotalQuantity) + "  Amt:              " + String.Format("{0:0.00}", TotalAmount);
                            g.DrawString(FieldValue, InvoiceTitle, BlueBrush, xTotal, CurrentY);

                            CurrentY = CurrentY + InvoiceFontHeight;
                            int    xCurrency   = leftMargin - 90;
                            string FieldValue1 = "";
                            FieldValue = CurrencyConverter.AmountInWords(Convert.ToDecimal(TotalAmount));
                            if (FieldValue.Length > 40)
                            {
                                FieldValue1 = FieldValue.Substring(41, FieldValue.Length - 41);
                                FieldValue  = FieldValue.Substring(0, 41);
                            }
                            g.DrawString(FieldValue, InvoiceFont, BlueBrush, xTotal, CurrentY);
                            CurrentY = CurrentY + InvoiceFontHeight;
                            g.DrawString(FieldValue1, InvoiceFont, BlueBrush, xTotal, CurrentY);
                            CurrentY = CurrentY + InvoiceFontHeight;
                            for (int i = 10; i <= 250; i++)
                            {
                                g.DrawString("-", InvoiceTitle, BlueBrush, i, CurrentY);
                            }
                            CurrentY = CurrentY + InvoiceFontHeight;

                            int xTaxAmount = leftMargin - 90;
                            FieldValue = "Item Value:                                            " + String.Format("{0:0.00}", ItemValue);
                            g.DrawString(FieldValue, InvoiceFont, BlackBrush, xTotal, CurrentY);
                            CurrentY = CurrentY + InvoiceFontHeight;


                            try
                            {
                                using (SqlConnection con1 = new SqlConnection(ConnString))
                                {
                                    using (SqlCommand cmd1 = new SqlCommand("GetTaxGroupingDetailsForPrintingByOrderID", con1))
                                    {
                                        cmd1.CommandType = CommandType.StoredProcedure;
                                        cmd1.Parameters.AddWithValue("@OrderID", a.OrderID);
                                        cmd1.CommandTimeout = 0;
                                        con1.Open();
                                        SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
                                        DataTable      dt1 = new DataTable();
                                        da1.Fill(dt1);
                                        CurrentRecord = 0;
                                        if (dt1.Rows.Count > 0)
                                        {
                                            RecordsPerPage = Convert.ToInt32(dt1.Rows.Count);
                                            while (CurrentRecord < RecordsPerPage)
                                            {
                                                int     xTaxType = leftMargin - 90;
                                                DataRow dr       = (DataRow)dt1.Rows[CurrentRecord];
                                                FieldValue = String.Format("{0:0.00}", dr["TaxType"]) + "%                                            " + String.Format("{0:0.00}", dr["TaxAmount"]);
                                                g.DrawString(FieldValue, InvoiceFont, BlackBrush, xTaxType, CurrentY);
                                                CurrentRecord = CurrentRecord + 1;
                                                CurrentY      = CurrentY + InvoiceFontHeight;
                                                if (CurrentRecord == RecordsPerPage)
                                                {
                                                    break;
                                                }
                                            }

                                            CurrentY = CurrentY + InvoiceFontHeight;
                                            int CurrentX = leftMargin;
                                            for (int i = 10; i <= 250; i++)
                                            {
                                                g.DrawString("-", InvoiceTitle, BlueBrush, i, CurrentY);
                                            }
                                            CurrentY   = CurrentY + InvoiceFontHeight;
                                            CurrentY   = CurrentY + InvoiceFontHeight;
                                            CurrentY   = CurrentY + InvoiceFontHeight;
                                            CurrentY   = CurrentY + InvoiceFontHeight;
                                            CurrentY   = CurrentY + InvoiceFontHeight;
                                            CurrentY   = CurrentY + InvoiceFontHeight;
                                            CurrentY   = CurrentY + InvoiceFontHeight;
                                            FieldValue = "||  THANK YOU VISIT AGAIN ||";
                                            int lenSalutation = (int)g.MeasureString(FieldValue, InvSalutation).Width;
                                            // Set Titles Left:
                                            int xSalutation = CurrentX + (InvoiceWidth - lenSalutation) / 2;
                                            g.DrawString(FieldValue, InvSalutation, BlueBrush, xSalutation, CurrentY);
                                        }
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }



                            g.Dispose();

                            if (CurrentRecord < RecordsPerPage)
                            {
                                e.HasMorePages = false;
                            }
                            else
                            {
                                e.HasMorePages = true;
                            }

                            if (StopReading)
                            {
                                SetInvoiceTotal(g);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Alert Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #22
0
 private void docPrint_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
 }
예제 #23
0
 private void entree_print_Document_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
 }
예제 #24
0
 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
 }
예제 #25
0
 PrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     m_currentPrintItem = Utils.Print(m_tvObjs.SelectedNode.Text, m_lvData, e, m_maxWidths[0], m_maxWidths[1], m_currentPrintItem);
 }
예제 #26
0
파일: PrintClass.cs 프로젝트: hkiaipc/jsb
        /// <summary>
        /// 
        /// </summary>
        public void Print( System.Drawing.Printing.PrintPageEventArgs e1)
        {
            this.e = e1;

            Console.WriteLine("Print()");
            StringFormat ss = new StringFormat();
            //ss.Alignment = StringAlignment.Center;      //居中位置
            ss.LineAlignment = StringAlignment.Center;

            e.Graphics.DrawString(_title, TitleFont, this.Brush, this.TitlePoint, ss);

            //显示打印日期
            e.Graphics.DrawString(PrintDateTime, this.TextFont, this.Brush, this.DateTimePoint,ss);

            //显示列标题
            //
            int x = 0;
            int y = 0;
            int w = 0;
            int h = 0;

            x = XStart;
            y = YStart;
            h = Height;

            for (int i = 0; i < this.PrintColumns; i++)
            {
                w = GetWidth(i);

                // 获取列中的标题文本内容
                //
                string str = this.lvDatas.Columns[i].Text;
                Rectangle rect = new Rectangle(x, y, w, h);
                e.Graphics.DrawRectangle(Pen, rect);

                // 框的中点
                //
                Point textPoint = new Point(x, y + Height / 2);

                e.Graphics.DrawString(str, TextFont, this.Brush, textPoint,ss);
                x += w;
            }

            y += Height;

            //显示列内容
            //for (i = 0; i < this.lvDatas.Items.Count; i++)
            for (; _lviIndex < this.lvDatas.Items.Count; _lviIndex++)
            {
                ListViewItem lvi = this.lvDatas.Items[_lviIndex];
                x = XStart;
                for (int k = 0; k < this.PrintColumns; k++)
                {
                    string str = lvi.SubItems[k].Text;
                    w = this.GetWidth(k);
                    Rectangle rect = new Rectangle(x, y, w, h);

                    e.Graphics.DrawRectangle(this.Pen, rect);

                    Point pt = new Point(x, y + Height / 2);
                    e.Graphics.DrawString(str, this.TextFont, this.Brush, pt, ss);

                    x += w;
                }
                y += Height;

                //
                //
                if (y >  e.MarginBounds.Bottom)
                {
                    e.HasMorePages = true;
                    y = YStart;
                    //return;
                    break;
                }
                else
                {
                    e.HasMorePages = false;
                }
            }
        }
예제 #27
0
        int iHeaderHeight = 0;                       //Used for the header height


        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            // try
            //{
            //Set the left margin
            int iLeftMargin = e.MarginBounds.Left;
            //MessageBox.Show("" + iLeftMargin);
            //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)
            {
                DataGridViewColumn tempCol;
                //DataGridViewColumn temp;

                //foreach (DataGridViewColumn GridCol in dGridV_InvenLog.Columns)
                //MessageBox.Show("Itmp loop");
                for (int w = (dGridV_InvenLog.Columns.Count - 1); w >= 0; w--)
                {
                    tempCol = dGridV_InvenLog.Columns[w];
                    //temp = dGridV_InvenLog.Columns[w];

                    iTmpWidth = (int)(Math.Floor((double)((double)tempCol.Width /
                                                          (double)iTotalWidth * (double)iTotalWidth *
                                                          ((double)e.MarginBounds.Width / (double)iTotalWidth))));

                    //MessageBox.Show("iTMP" + iTmpWidth);
                    iHeaderHeight = (int)(e.Graphics.MeasureString(tempCol.HeaderText,
                                                                   tempCol.InheritedStyle.Font, iTmpWidth).Height) + 11;

                    // Save width and height of headres
                    arrColumnLefts.Add(iLeftMargin);
                    arrColumnWidths.Add(iTmpWidth);
                    iLeftMargin += iTmpWidth;
                }
            }

            //Loop till all the grid rows not get printed

            while (iRow <= dGridV_InvenLog.Rows.Count - 1)
            {
                DataGridViewRow GridRow = dGridV_InvenLog.Rows[iRow];
                //Set the cell height
                iCellHeight = GridRow.Height + 5;
                int iCount = 5;
                //Check whether the current page settings allo 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(supplierNameComboBox.Text + ":" + "اسم المورد \n" + "  تقرير حسابات الموردين ", new Font(dGridV_InvenLog.Font, FontStyle.Bold),
                                              Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top -
                                              e.Graphics.MeasureString(supplierNameComboBox.Text + ":" + "اسم المورد \n" + "  تقرير حسابات الموردين ", new Font(dGridV_InvenLog.Font,
                                                                                                                                                                FontStyle.Bold), e.MarginBounds.Width).Height - 13);

                        String strDate = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
                        //Draw Date
                        e.Graphics.DrawString(strDate, new Font(dGridV_InvenLog.Font, FontStyle.Bold),
                                              Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width -
                                                                                    e.Graphics.MeasureString(strDate, new Font(dGridV_InvenLog.Font,
                                                                                                                               FontStyle.Bold), e.MarginBounds.Width).Width), e.MarginBounds.Top -
                                              e.Graphics.MeasureString(supplierNameComboBox.Text + ":" + "اسم المورد \n" + "  تقرير حسابات الموردين ", new Font(new Font(dGridV_InvenLog.Font,
                                                                                                                                                                         FontStyle.Bold), FontStyle.Bold), e.MarginBounds.Width).Height - 13);

                        //Draw Columns
                        iTopMargin = e.MarginBounds.Top;
                        foreach (DataGridViewColumn GridCol in dGridV_InvenLog.Columns)
                        {
                            if (GridCol.Index == 0)
                            {
                            }
                            else
                            {
                                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.HeaderText, GridCol.InheritedStyle.Font,
                                                      new SolidBrush(GridCol.InheritedStyle.ForeColor),
                                                      new RectangleF((int)arrColumnLefts[iCount], iTopMargin,
                                                                     (int)arrColumnWidths[iCount], iHeaderHeight), strFormat);
                                iCount--;
                            }
                        }
                        bNewPage    = false;
                        iTopMargin += iHeaderHeight;
                    }
                    iCount = 5;
                    //Draw Columns Contents
                    foreach (DataGridViewCell Cel in GridRow.Cells)
                    {
                        if (Cel.ColumnIndex == 0)
                        {
                        }
                        else
                        {
                            if (Cel.Value != null)
                            {
                                e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font,
                                                      new SolidBrush(Cel.InheritedStyle.ForeColor),
                                                      new RectangleF((int)arrColumnLefts[iCount], (float)iTopMargin,
                                                                     (int)arrColumnWidths[iCount], (float)iCellHeight), strFormat);
                            }
                            //MessageBox.Show("" + iCount);
                            //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, "2", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
        }