Exemple #1
0
        // Body
        public void Body()
        {
            // Loop through each row of the recordset
            using (var _rs = new StaticRS(string.Format("select dd.HU,dd.InContainer,hd.Finis,hd.qty from DeliveriesDet dd inner join HUDet hd on hd.HU=dd.HU and hd.cod3=dd.cod3 where dd.DeliveryCode='{0}' and dd.cod3='{1}' order by dd.InContainer,dd.HU,hd.finis", Program.fDeliveries.Delivery, Values.COD3), Values.gDatos))
            {
                _rs.Open();
                if (_rs.RecordCount != 0)
                {
                    // Set font & add column names
                    this.CurrentFont = new Font("Courier New", 12, FontStyle.Bold);
                    NewLine(true);
                    Add(string.Format(" {0,-12} {1,-10} {2,-7} {3,5} ", "HU", "CONTAINER", "FINIS", "QTY"));

                    // Set font & add data lines
                    this.CurrentFont = new Font("Courier New", 12, FontStyle.Regular);
                    while (!_rs.EOF)
                    {
                        NewLine(true);
                        Add(string.Format(" {0,-12} {1,-10} {2,-7} {3,5:G} ", _rs["HU"], _rs["INCONTAINER"], _rs["FINIS"], _rs["QTY"]));
                        _rs.MoveNext();
                    }
                }
            }
        }
Exemple #2
0
            // Definition for the document. It will be called on any new page, so we just define the Header and the query for the Body once. The Footer is cleared and created on each call, as the
            // page number has to change.
            protected override void OnPrintPage(PrintPageEventArgs e)
            {
                Graphics _g = e.Graphics;

                // Page counter
                PageNumber++;

                // Just for the first time
                if (PageNumber == 1)
                {
                    // Define the Header
                    Header();

                    // Define the Body columns
                    NewLine(false, EnumDocumentParts.BODY);
                    Add($"{"LN",2} {"PARTNUMBER",-18} {"DESCRIPTION",-30} {"DESTINATION",-30} {"ORD.",5} {"SENT",5}", new Font("Courier New", 8, FontStyle.Bold));


                    // Change the font and run the query for the Body data
                    this.CurrentFont = new Font("Courier New", 8);
                    using (var _rs = new StaticRS(string.Format("Select Line,Partnumber,Description,Destination=isnull((select top 1 s.planta+' ('+s.Descripcion2+') '+s.Descripcion1 from servicios_destinos s inner join referencias_destinos rd on rd.servicio=s.servicio and rd.ruta=s.ruta where rd.servicio=v.service and rd.partnumber=v.partnumber order by s.planta),''),OrderedQty,SentQty from vSimpleDeliveriesDet v where DeliveryNumber='{0}' and Service='{1}'", DeliveryNumber, Service), Values.gDatos))
                    {
                        _rs.Open();

                        _dontPrintSignature = (_rs.RecordCount > 48);

                        if (_rs.RecordCount != 0)
                        {
                            // Loop through the recordset results
                            while (!_rs.EOF)
                            {
                                //for (int i = 1; i < 25; i++)
                                //{
                                NewLine(true);
                                Add(string.Format("{0,2} {1,-18} {2,-30} {3,-30} {4,5} {5,5}", _rs["Line"], _rs["Partnumber"], _rs["Description"].ToString().Length > 30 ? _rs["Description"].ToString().Substring(0, 30) : _rs["Description"], _rs["Destination"].ToString().Length > 30 ? _rs["Destination"].ToString().Substring(0, 30) : _rs["Destination"], _rs["OrderedQty"], _rs["SentQty"]));
                                //    Add(string.Format("{0,5} {1,-20} {2,-30} {3,7} {4,6}", i, _rs["Partnumber"], _rs["Description"].ToString().Length > 30 ? _rs["Description"].ToString().Substring(0, 30) : _rs["Description"], _rs["OrderedQty"], _rs["SentQty"]));
                                //}
                                _rs.MoveNext();
                            }
                            //NewLine(true);
                            //Add(string.Format("{0,5} {1,-20} {2,-30} {3,7} {4,6}", "xx", "Partnumber", "Description","OrderedQty", "SentQty"));
                        }
                        else
                        {
                            NewLine(true);
                            Add("--- NO DATA FOUND ---");
                        }
                    }
                }
                else
                {
                    _dontPrintSignature = !((BodyList.Lines.Count() - BodyList.LastPrintedLine - 50) < 1);
                }

                // Print the footer (changes on each new page)
                Footer();

                // Draw graphics
                _g.DrawRectangle(new Pen(Color.Black, 0.5F), 25F, 65F, 725F, 75F); // Header box
                _g.DrawImage(Resources.Logo_Espack_transparente, 27F, 67F, 140F, 55F);
                _g.DrawLine(new Pen(Color.Black, 0.5F), 50F, 1010F, 750F, 1010F);  // Footer separator

                // Signature boxes when last page is reached
                if (!_dontPrintSignature) //BodyList.LastPrintedLine+)
                {
                    _g.DrawRectangle(new Pen(Color.Black, 0.5F), 250F, 1020F, 235F, 100F);
                    _g.DrawRectangle(new Pen(Color.Black, 0.5F), 485F, 1020F, 235F, 100F);
                    _g.DrawString("Carrier Signature", new Font("Courier New", 6), new SolidBrush(Color.Black), new PointF(255F, 1022F));
                    _g.DrawString("Forklift Driver Signature", new Font("Courier New", 6), new SolidBrush(Color.Black), new PointF(490F, 1022F));
                }

                // Base object: it has to be the last to be called as it prints the results
                base.OnPrintPage(e);
            }