public int GetFactuurNummer() { return(int.Parse(FactuurJaar.ToString() + FactuurID.ToString())); }
internal void PrintText(Selection selection) { Document document = selection.Application.Documents.Add(Properties.Settings.Default.FactuurTemplate); Application app = selection.Application; AddHeader(document); var table = document.Tables[2]; table.Range.ParagraphFormat.KeepWithNext = -1; table.Borders[WdBorderType.wdBorderVertical].LineStyle = WdLineStyle.wdLineStyleDot; table.Borders[WdBorderType.wdBorderHorizontal].LineStyle = WdLineStyle.wdLineStyleDot; AddWages(table); AddLitigation(table); // Remove border of second row table.Rows[2].Borders[WdBorderType.wdBorderBottom].Visible = false; // Add Total Row newRow = table.Rows.Add(); Row BottomRow = newRow; //insert if for not empty newRow.Cells.Borders[WdBorderType.wdBorderTop].Visible = false; newRow.Cells.Borders[WdBorderType.wdBorderBottom].Visible = false; newRow.Cells.Borders[WdBorderType.wdBorderLeft].Visible = false; newRow.Cells.Borders[WdBorderType.wdBorderRight].Visible = false; newRow.Cells.Borders[WdBorderType.wdBorderHorizontal].Visible = false; newRow.Cells.Borders[WdBorderType.wdBorderVertical].Visible = false; newRow.Range.ParagraphFormat.KeepWithNext = -1; if (Subtotal_ExVAT != 0) { newRow = table.Rows.Add(); newRow.Cells[2].Merge(newRow.Cells[5]); newRow.Cells[2].Range.InsertAfter("Subtotaal excl Btw"); newRow.Cells[2].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft; newRow.Cells[3].Range.InsertAfter(Subtotal_ExVAT.ToString("C", Variabelen.Cultuur)); newRow.Range.ParagraphFormat.KeepWithNext = -1; newRow = table.Rows.Add(); newRow.Cells[2].Range.InsertAfter("Subtotaal Btw"); newRow.Cells[3].Range.InsertAfter((Subtotal_ExVAT * BTWpercentage).ToString("C", Variabelen.Cultuur)); newRow.Range.ParagraphFormat.KeepWithNext = -1; } if (Subtotal_NoVat != 0) { newRow = table.Rows.Add(); newRow.Cells[2].Range.InsertAfter("Subtotaal derden en gerechtskosten"); newRow.Cells[3].Range.InsertAfter((Subtotal_NoVat + Subtotal_Derden).ToString("C", Variabelen.Cultuur)); newRow.Range.ParagraphFormat.KeepWithNext = -1; } if (Subtotal_NoVat != 0 || Subtotal_ExVAT != 0) { newRow = table.Rows.Add(); newRow.Cells[2].Range.InsertAfter("Totaal"); newRow.Cells[2].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; newRow.Cells[3].Range.InsertAfter(Totaal.ToString("C", Variabelen.Cultuur)); newRow.Cells[3].Borders[WdBorderType.wdBorderTop].Visible = true; newRow.Cells[2].Range.Font.Bold = -1; newRow.Cells[3].Range.Font.Bold = -1; newRow.Range.ParagraphFormat.KeepWithNext = -1; } var newTable = table.Split(BottomRow); // add border under table table.Borders[WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle; //table.Borders[WdBorderType.wdBorderTop] BottomRow.Borders[WdBorderType.wdBorderTop].Visible = true; BottomRow.Delete(); table.Columns.SetWidth(app.CentimetersToPoints(2.5f), WdRulerStyle.wdAdjustNone); table.Columns[1].SetWidth(app.CentimetersToPoints(5.25f), WdRulerStyle.wdAdjustNone); table.Columns[2].SetWidth(app.CentimetersToPoints(1.5f), WdRulerStyle.wdAdjustNone); table.Columns[6].SetWidth(app.CentimetersToPoints(3f), WdRulerStyle.wdAdjustNone); newTable.Columns.SetWidth(app.CentimetersToPoints(0.47f), WdRulerStyle.wdAdjustNone); newTable.Columns[1].SetWidth(app.CentimetersToPoints(1.47f), WdRulerStyle.wdAdjustNone); newTable.Columns[2].SetWidth(app.CentimetersToPoints(9.5f), WdRulerStyle.wdAdjustNone); newTable.Columns[3].SetWidth(app.CentimetersToPoints(5.25f), WdRulerStyle.wdAdjustNone); document.PrintPreview(); document.SaveAs2(FileName: Properties.Settings.Default.InvoicePath + FactuurJaar.ToString() + FactuurID.ToString()); app.ActivePrinter = "Standaard"; document.PrintOut(Background: true); app.ActivePrinter = "Standaard"; document.Close(SaveChanges: true); }