Example #1
0
        public string SaveWorksheet()
        {
            // Save worksheet in Database
            worksheetRepository.Update(GetWorksheet());

            //After saving to the database, create a PDF and return its path to view.
            BuildPDF buildPDF = new BuildPDF();

            buildPDF.InsertNewLine(24f, BuildPDF.TextAlignment.Center, "Arbejdsseddel nr.: " + WorksheetID);
            buildPDF.InsertNewLine(16f, "  ");
            buildPDF.InsertNewLine(16f, "Kundeinformationer: ");
            buildPDF.InsertNewSplitLine(14f, Customer.Name.FullName, "Startdato: " + StartDate.ToShortDateString());
            buildPDF.InsertNewSplitLine(14f, Customer.Address.Street, "Starttid: " + StartTime);
            buildPDF.InsertNewSplitLine(14f, Customer.Address.ZIPcode + " " + Customer.Address.City, "Slutdato: " + EndDate.ToShortDateString());
            buildPDF.InsertNewSplitLine(14f, "Tel. nr.: " + Customer.PhoneNumber, "Sluttid: " + EndTime);
            buildPDF.InsertNewSplitLine(14f, "Email: " + Customer.Email, "");
            buildPDF.InsertNewSplitLine(14f, "Kundenr.: " + Customer.ID, "Arbejdssted: " + Workplace);
            buildPDF.InsertNewLine(24f, "");
            buildPDF.InsertNewLine(16f, "Ønskes udført: ");
            buildPDF.InsertNewTextBlock(14f, BuildPDF.TextAlignment.Left, WorkDescription);
            buildPDF.InsertNewLine(24f, "");
            buildPDF.InsertNewLine(16f, "Tilknyttede montører: ");
            buildPDF.InsertNewTable(14f, 2,
                                    new List <string> {
                "MedarbejderID", "Navn", "Kvalifikation"
            },
                                    AssignedEmployees.AsEnumerable()
                                    );
            buildPDF.InsertNewLine(24f, "");
            buildPDF.InsertNewLine(16f, "Udførte arbejdstimer: ");
            buildPDF.InsertNewTable(14f, 2,
                                    new List <string> {
                "MedarbejderID", "Navn", "Antal timer", "Type", "Dato"
            },
                                    WorkHours.AsEnumerable()
                                    );
            buildPDF.InsertNewLine(24f, "");
            buildPDF.InsertNewLine(16f, "Brugte materialer: ");
            buildPDF.InsertNewTable(14f, 2,
                                    new List <string> {
                "Varenummer", "Type", "Beskrivelse"
            },
                                    Materials.AsEnumerable()
                                    );

            return(buildPDF.Save("Arbejdsseddel_" + WorksheetID + ".pdf"));
        }