private void btnShowOwnReports_Click(object sender, RoutedEventArgs e) { if (lvReports.SelectedItem != null) { var row = lvReports.SelectedItem.ToString(); string[] col = row.Split(','); string id = Regex.Match(col[0], @"\d+").Value; string[] nameSplit = col[1].Split('='); string name = nameSplit[1].Trim(); string[] destinationSplit = col[2].Split('='); string destination = destinationSplit[1].Trim(); string[] dateSplit = col[3].Split('='); string date = dateSplit[1].Trim(); string[] stateSplit = col[4].Split('='); string state = stateSplit[1].Trim().Substring(0, stateSplit[1].Length - 2); var verifications = VerificationRepository.GetVerifications(Convert.ToInt32(id)); PdfDocument pdf = new PdfDocument(); pdf.Info.Title = name; PdfPage pdfPage = pdf.AddPage(); XGraphics graph = XGraphics.FromPdfPage(pdfPage); XFont font = new XFont("Verdana", 20, XFontStyle.Bold); XFont minifont = new XFont("Verdana", 15); var y = -160; /*XImage img = * XImage.FromFile( * "C:\\Users\\Peter\\Documents\\GitHub\\ResehanteringsSystem\\vITs\\vITs\\Graphics\\pdfImage.gif");*/ //graph.DrawImage(img, 10, 10, 80, 80); graph.DrawString("Anställd: " + name, font, XBrushes.Black, new XRect(0, -330, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Id: " + id, minifont, XBrushes.Black, new XRect(0, -285, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Destination: " + destination, minifont, XBrushes.Black, new XRect(0, -265, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Datum: " + date, minifont, XBrushes.Black, new XRect(0, -245, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Status :" + state, minifont, XBrushes.Black, new XRect(0, -225, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Utgifter", font, XBrushes.Black, new XRect(0, -180, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); foreach (var v in verifications) { graph.DrawString(ExpencesRepository.GetExpence(v.expenceID) + ", Kostnad: " + v.cost + ", Note: " + v.note, minifont, XBrushes.Black, new XRect(0, y, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); y -= 20; } string pdfFilename = id + ".pdf"; if (pdfFilename != "") { pdf.Save(pdfFilename); } Process.Start(pdfFilename); } }
public ExpencesReciever() { _expencesRepo = new ExpencesRepository(); }
private void LoadReseUtlägg() { fulltrips = Serializer.Load(); cbPickTripExpensesTab.ItemsSource = fulltrips; cbKostnTyp.ItemsSource = ExpencesRepository.GetAll(); }