/// <summary> /// Druck des Kassenabschlussberichts /// </summary> /// <param name="cashClosureID">Kassenabschluss-ID</param> /// <param name="reprint">Nachdruck</param> public static void printCashClosureReport(int cashClosureID, bool reprint) { if (!LibreOffice.isLibreOfficeInstalled()) { string warning = IniParser.GetSetting("ERRORMSG", "libre"); MessageBoxEnhanced.Error(warning); } CashClosureReport report; try { var reports = CashClosureReport.GetCashClosureReports(null, cashClosureID); report = reports.FirstOrDefault(); } catch { return; } string currentDir = System.IO.Directory.GetCurrentDirectory(); string path = IniParser.GetSetting("DOCUMENTS", "path").Replace("%PROGRAMPATH%", currentDir) + "\\" + IniParser.GetSetting("DOCUMENTS", "cashClosureReport"); List <string> toReplace = new List <string>(); List <string> replaceSt = new List <string>(); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachdruck></text:placeholder>"); if (reprint) { replaceSt.Add(SafeStringParser.safeParseToStr(IniParser.GetSetting("DOCUMENTS", "reprint"))); } else { replaceSt.Add(""); } toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kassenabschlussdatum></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(report.CashClosure.ClosureDate)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kassenabschlussnummer></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(report.CashClosure.CashClosureID)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Einnahmen></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Revenue, true)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Ausgaben></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Expense, true)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Saldo></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Sum, true)); string tmpFilePath; bool success = LibreOffice.replaceXMLstringInODT(path, toReplace, replaceSt, out tmpFilePath); if (success) { LibreOffice.openWithWriter(tmpFilePath, true, true); } }
/// <summary> /// Druck des Berechtigungsnachweises /// </summary> public static void printCredential() { //Berechtigungsnachweis drucken if (!LibreOffice.isLibreOfficeInstalled()) { string warning = IniParser.GetSetting("ERRORMSG", "libre"); MessageBoxEnhanced.Error(warning); return; } try { KöTaf.Utils.Printer.PrintModul pM = new Utils.Printer.PrintModul(PrintType.LopOffList, null); } catch (Exception ex) { MessageBoxEnhanced.Error(ex.Message); } }
/// <summary> /// Druck der Kassenabrechnung /// </summary> /// <param name="cashClosureID">Kassenabschluss-ID</param> /// <param name="reprint">Nachdruck</param> public static void printCashClosureReceipt(int cashClosureID, bool reprint) { if (!LibreOffice.isLibreOfficeInstalled()) { string warning = IniParser.GetSetting("ERRORMSG", "libre"); MessageBoxEnhanced.Error(warning); } CashClosureReceipt receipt; try { IEnumerable <CashClosureReceipt> receipts = CashClosureReceipt.GetCashClosureReceipts(null, cashClosureID); receipt = receipts.FirstOrDefault(); } catch { return; } string currentDir = System.IO.Directory.GetCurrentDirectory(); string path = IniParser.GetSetting("DOCUMENTS", "path").Replace("%PROGRAMPATH%", currentDir) + "\\" + IniParser.GetSetting("DOCUMENTS", "cashClosureReceipt"); List <string> toReplace = new List <string>(); List <string> replaceSt = new List <string>(); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kassenabschlussdatum></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(receipt.CashClosure.ClosureDate)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Einnahmen></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(receipt.CashClosure.Revenue, true)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Ausgaben></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(receipt.CashClosure.Expense, true)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Saldo></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(receipt.CashClosure.Sum, true)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><abgerechnet_durch></text:placeholder>"); try { // Hole CashClosure Objekt direkt aus der DB, da die Referenz von CashClosureReceipt auf CashClosure manchmal nicht gültig ist(?) CashClosure cashClosure = CashClosure.GetCashClosures(cashClosureID).FirstOrDefault(); string username = cashClosure.ClosureUserAccount.Username; replaceSt.Add(SafeStringParser.safeParseToStr(username)); } catch { replaceSt.Add("-"); } toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachdruck></text:placeholder>"); if (reprint) { replaceSt.Add(SafeStringParser.safeParseToStr(IniParser.GetSetting("DOCUMENTS", "reprint"))); } else { replaceSt.Add(""); } string tmpFilePath; bool success = LibreOffice.replaceXMLstringInODT(path, toReplace, replaceSt, out tmpFilePath); if (success) { LibreOffice.openWithWriter(tmpFilePath, true, true); } }
/// <summary> /// Druck des Aufnahmeformulars /// </summary> /// <param name="personID">ID der Person</param> public static void printClientEnrolmentForm(int personID) { if (!LibreOffice.isLibreOfficeInstalled()) { string warning = IniParser.GetSetting("ERRORMSG", "libre"); MessageBoxEnhanced.Error(warning); } Person person; try { var persons = Person.GetPersons(personID).ToList(); person = persons.FirstOrDefault(); } catch { return; } string currentDir = System.IO.Directory.GetCurrentDirectory(); string path = IniParser.GetSetting("DOCUMENTS", "path").Replace("%PROGRAMPATH%", currentDir) + "\\" + IniParser.GetSetting("DOCUMENTS", "enrolmentForm"); List <string> toReplace = new List <string>(); List <string> replaceSt = new List <string>(); int rowsChildren = 6; int rowsRevenues = 8; if (person == null) { return; } toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Vorname></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.FirstName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachname></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.LastName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Strasse></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.Street)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><PLZ></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.ZipCode)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Ort></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.City)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Geburtstag></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.DateOfBirth)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Staatsangehoerigkeit></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.Nationality)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Geburtsland></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.CountryOfBirth)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Familienstand></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.FamilyState.Name)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Vorname_Partner></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalFirstName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachname_Partner></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalLastName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Geburtstag_Partner></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalBirthday)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Staatsangehoerigkeit_Partner></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalNationality)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Datum></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(DateTime.Now)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Gueltigkeitsende></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.ValidityEnd)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><KNR></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.TableNo)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Erfasser></text:placeholder>"); if (person.UserAccount != null) { replaceSt.Add(SafeStringParser.safeParseToStr(person.UserAccount.Username)); } else { replaceSt.Add(""); } // fülle Kinder IEnumerable <Child> children = Child.GetChildren(null, person.PersonID); int childIndex = 1; foreach (var child in children) { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Index_" + childIndex + "></text:placeholder>"); replaceSt.Add("#" + childIndex); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Vorname_" + childIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(child.FirstName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Nachname_" + childIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(child.LastName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Geburtstag_" + childIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(child.DateOfBirth)); childIndex++; } // Sorge dafür, dass die übrigen Zeilen beim Druck leer sind for (int i = childIndex; i <= rowsChildren; i++) { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Index_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Vorname_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Nachname_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Geburtstag_" + i + "></text:placeholder>"); replaceSt.Add(""); } // fülle Einkünfte IEnumerable <Revenue> revenues = Revenue.GetRevenues(null, person.PersonID); int revenueIndex = 1; foreach (var revenue in revenues) { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Einkunft_" + revenueIndex + "></text:placeholder>"); replaceSt.Add(revenue.RevenueType.Name + ": " + revenue.Description); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Bescheid_" + revenueIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(revenue.StartDate)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Bewilligt_" + revenueIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(revenue.EndDate)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Hoehe_" + revenueIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(revenue.Amount, true)); revenueIndex++; } // Sorge dafür, dass die übrigen Zeilen beim Druck leer sind for (int i = revenueIndex; i <= rowsRevenues; i++) { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Einkunft_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Bescheid_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Bewilligt_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Hoehe_" + i + "></text:placeholder>"); replaceSt.Add(""); } string tmpFilePath; bool success = LibreOffice.replaceXMLstringInODT(path, toReplace, replaceSt, out tmpFilePath); if (success) { LibreOffice.openWithWriter(tmpFilePath, true, true); } }
/// <summary> /// Druck des Haftungsausschlusses /// </summary> /// <param name="personID">ID der Person</param> public static void printClientDisclaimer(int?personID = null) { if (!LibreOffice.isLibreOfficeInstalled()) { string warning = IniParser.GetSetting("ERRORMSG", "libre"); MessageBoxEnhanced.Error(warning); } string currentDir = System.IO.Directory.GetCurrentDirectory(); string path = IniParser.GetSetting("DOCUMENTS", "path").Replace("%PROGRAMPATH%", currentDir) + "\\" + IniParser.GetSetting("DOCUMENTS", "disclaimer"); List <string> toReplace = new List <string>(); List <string> replaceSt = new List <string>(); if (personID.HasValue) { Person person; try { person = Person.GetPersons(personID).FirstOrDefault(); } catch { return; } toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachname></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.LastName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Vorname></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.FirstName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Ausweisnummer></text:placeholder>"); if (person.TableNo.HasValue) { replaceSt.Add(SafeStringParser.safeParseToStr(person.TableNo)); } else { return; } toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Datum></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(DateTime.Now)); } else { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachname></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Vorname></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Ausweisnummer></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Datum></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:span text:style-name=\"T3\">, </text:span>"); replaceSt.Add(""); } string tmpFilePath; bool success = LibreOffice.replaceXMLstringInODT(path, toReplace, replaceSt, out tmpFilePath); if (success) { LibreOffice.openWithWriter(tmpFilePath, true, true); } }