Ejemplo n.º 1
0
        public static DeliveryNotePackage GetDeliveryNotePackage(this DeliveryNote deliveryNote)
        {
            DeliveryNotePackage result = new DeliveryNotePackage();

              if (deliveryNote != null)
              {
            result.DeliveryNote = deliveryNote.GetPrimitive();
            if (deliveryNote.Car != null)
            {
              result.CarAndDriver = new CarAndDriverPackage();
              result.CarAndDriver.Car = deliveryNote.Car.GetPrimitive();
              if (deliveryNote.Car.Driver != null)
              {
            result.CarAndDriver.Driver = deliveryNote.Car.Driver.GetPrimitive();
              }
            }
            if (deliveryNote.Driver != null)
            {
              result.Driver = deliveryNote.Driver.GetPrimitive();
            }
            if (deliveryNote.Order != null)
            {
              result.Order = deliveryNote.Order.GetPrimitive();
            }
            //if (deliveryNote.Building != null)
            //{
            //  result.BuildingAndContractor = deliveryNote.Building.GetBuildingAndContractorPackage();
            //}
              }
              return result;
        }
Ejemplo n.º 2
0
        public static void PrintDeliveryNote(DeliveryNotePackage deliveryNotePackage)
        {
            if (deliveryNotePackage.BuildingAndContractor == null)
              {
            throw new SmartWorkingException("Building and contractor is not defined.");
              }
              if (deliveryNotePackage.BuildingAndContractor.Building == null)
              {
            throw new SmartWorkingException("Building is not defined.");
              }
              if (deliveryNotePackage.BuildingAndContractor.Client == null)
              {
            throw new SmartWorkingException("Contractor is not defined.");
              }
              if (deliveryNotePackage.CarAndDriver == null)
              {
            throw new SmartWorkingException("Car is not defined.");
              }
              if (deliveryNotePackage.Driver == null)
              {
            throw new SmartWorkingException("Driver is not defined.");
              }
              if (deliveryNotePackage.Recipe == null)
              {
            throw new SmartWorkingException("Recipe is not defined.");
              }

              string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "pdf");

              if (!Directory.Exists(path))
              {
            Directory.CreateDirectory(path);
              }

              string filename = Path.Combine(path,
                                     string.Format("WZ_{0}_{1:yyyy-MM-dd_hh-mm-ss-tt}.pdf",
                                                   deliveryNotePackage.DeliveryNote.Id, DateTime.Now));

              var document = new PdfDocument();

              PdfPage page = document.AddPage();
              XGraphics gfx = XGraphics.FromPdfPage(page);

              //DeliveryNote top
              ComposeDeliveryNoteOnPage(deliveryNotePackage, gfx, 0);

              PrintSection(gfx,
                   "...............................................................................................................................................................................................................",
                   string.Empty,
                   new XPoint(0, 400), 500, 0, 12, 12, 12);

              //DeliveryNote bottom
              ComposeDeliveryNoteOnPage(deliveryNotePackage, gfx, 400);

              document.Save(filename);
              Print(filename);
        }
        public static DeliveryNotePackage GetPackageCopy(this DeliveryNotePackage source)
        {
            if (source == null || source.DeliveryNote == null)
            return null;

              DeliveryNotePackage package = new DeliveryNotePackage();
              package.DeliveryNote = source.DeliveryNote;

              package.CarAndDriver = source.CarAndDriver;
              package.Driver = source.Driver;

              return package;
        }
Ejemplo n.º 4
0
        private static void ComposeDeliveryNoteOnPage(DeliveryNotePackage deliveryNotePackage, XGraphics gfx, double shiftY)
        {
            //DeliveryNote
              PrintSection(gfx, "WZ: " + deliveryNotePackage.DeliveryNote.Id, string.Empty, new XPoint(250, 30 + shiftY));

              //Contractor
              string contracotrInfo =
            //((string.IsNullOrEmpty(deliveryNotePackage.BuildingAndContractor.Contractor.FullName))
            //   ? string.Empty
            //   : deliveryNotePackage.BuildingAndContractor.Contractor.FullName + Environment.NewLine) +
            //((string.IsNullOrEmpty(deliveryNotePackage.BuildingAndContractor.Contractor.Name))
            //   ? string.Empty
            //   : deliveryNotePackage.BuildingAndContractor.Contractor.Name + Environment.NewLine) +
            //((string.IsNullOrEmpty(deliveryNotePackage.BuildingAndContractor.Contractor.Surname))
            //   ? string.Empty
            //   : deliveryNotePackage.BuildingAndContractor.Contractor.Surname + Environment.NewLine);
            "";
              PrintSection(gfx, "Klient:", contracotrInfo, new XPoint(30, 70 + shiftY));

              //Building
              string buildingInfo =
            ((string.IsNullOrEmpty(deliveryNotePackage.BuildingAndContractor.Building.City))
               ? string.Empty
               : deliveryNotePackage.BuildingAndContractor.Building.City + Environment.NewLine) +
            ((string.IsNullOrEmpty(deliveryNotePackage.BuildingAndContractor.Building.Street))
               ? string.Empty
               : deliveryNotePackage.BuildingAndContractor.Building.Street + Environment.NewLine) +
            ((string.IsNullOrEmpty(deliveryNotePackage.BuildingAndContractor.Building.HouseNo))
               ? string.Empty
               : deliveryNotePackage.BuildingAndContractor.Building.HouseNo + Environment.NewLine);
              PrintSection(gfx, "Budowa:", buildingInfo, new XPoint(30, 140 + shiftY));

              //Date drawing
              PrintSection(gfx, "Data wystawienia: ",
                   ((deliveryNotePackage.DeliveryNote.DateDrawing.HasValue)
                      ? deliveryNotePackage.DeliveryNote.DateDrawing.Value.ToShortDateString()
                      : string.Empty),
                   new XPoint(300, 60 + shiftY));

              //Date of arrival
              PrintSection(gfx, "Data dostarczenia: ",
                   ((deliveryNotePackage.DeliveryNote.DateOfArrival.HasValue)
                      ? deliveryNotePackage.DeliveryNote.DateOfArrival.Value.ToShortDateString()
                      : string.Empty),
                   new XPoint(300, 110 + shiftY));

              //Recipe
              string recipeInfo =
            ((string.IsNullOrEmpty(deliveryNotePackage.Recipe.Name))
               ? string.Empty
               : "Nazwa: " + deliveryNotePackage.Recipe.Name) +
            ((string.IsNullOrEmpty(deliveryNotePackage.Recipe.InternalName))
               ? string.Empty
               : " (" + deliveryNotePackage.Recipe.InternalName + ")") +
            ((string.IsNullOrEmpty(deliveryNotePackage.DeliveryNote.Amount.ToString()))
               ? string.Empty
               : Environment.NewLine + "Ilość: " + deliveryNotePackage.DeliveryNote.Amount + "m3" + Environment.NewLine);

              PrintSection(gfx, "Recepta:", recipeInfo, new XPoint(200, 180 + shiftY));

              //Car
              PrintSection(gfx, "Samochód: ",
                   ((string.IsNullOrEmpty(deliveryNotePackage.CarAndDriver.Name))
                      ? string.Empty
                      : deliveryNotePackage.CarAndDriver.Name + Environment.NewLine) +
                   ((string.IsNullOrEmpty(deliveryNotePackage.CarAndDriver.RegistrationNumber))
                      ? string.Empty
                      : deliveryNotePackage.CarAndDriver.RegistrationNumber + Environment.NewLine),
                   new XPoint(30, 270 + shiftY));

              //Driver
              PrintSection(gfx, "Kierowca: ",
                   ((string.IsNullOrEmpty(deliveryNotePackage.Driver.Name))
                      ? string.Empty
                      : deliveryNotePackage.Driver.Name + Environment.NewLine) +
                   ((string.IsNullOrEmpty(deliveryNotePackage.Driver.Surname))
                      ? string.Empty
                      : deliveryNotePackage.Driver.Surname + Environment.NewLine) +
                   ((string.IsNullOrEmpty(deliveryNotePackage.Driver.Phone))
                      ? string.Empty
                      : "Tel: " + deliveryNotePackage.Driver.Phone + Environment.NewLine),
                   new XPoint(200, 270 + shiftY));

              //Sign
              PrintSection(gfx, "Wystawiający: ", Environment.NewLine + "................................",
                   new XPoint(400, 310 + shiftY));
        }
 private void PrintDeliveryNote(DeliveryNotePackage deliveryNotePackage)
 {
     string errorCaption = "Drukowanie WZ'tki!";
       try
       {
     PrinterHelper.PrintDeliveryNote(deliveryNotePackage);
       }
       catch (FaultException<ExceptionDetail> f)
       {
     ShowError(errorCaption, f);
     Cancel();
       }
       catch (CommunicationException c)
       {
     ShowError(errorCaption, c);
     Cancel();
       }
       catch (Exception e)
       {
     ShowError(errorCaption, e);
     Cancel();
       }
 }