/// <summary> /// Liste der Kassenabschlüsse aktualisieren /// </summary> private void refreshCashClosureDataGrid() { IEnumerable <CashClosure> cashClosures = CashClosure.GetCashClosures(); IEnumerable <CashClosureReport> cashClosureReports = CashClosureReport.GetCashClosureReports(); IEnumerable <CashClosureReceipt> cashClosureReceipts = CashClosureReceipt.GetCashClosureReceipts(); List <CashClosureManagerDataGridModel> cashClosureDataGridModels = new List <CashClosureManagerDataGridModel>(); foreach (var cashClosure in cashClosures) { if (cashClosure == null) { return; } try { CashClosureReport cashClosureReport = cashClosureReports.Where(c => c.CashClosure.CashClosureID == cashClosure.CashClosureID).FirstOrDefault(); CashClosureReceipt cashClosureReceipt = cashClosureReceipts.Where(c => c.CashClosure.CashClosureID == cashClosure.CashClosureID).FirstOrDefault(); if (cashClosureReport == null || cashClosureReceipt == null) { return; } cashClosureDataGridModels.Add(new CashClosureManagerDataGridModel(cashClosure, cashClosureReport, cashClosureReceipt)); } catch { } } CashClosureDataGrid.ItemsSource = cashClosureDataGridModels; CashClosureDataGrid.Items.Refresh(); }
/// <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> /// Kassenabschlussbericht als erledigt markieren /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReportDone_Checked(object sender, RoutedEventArgs e) { try { CheckBox cbSender = (CheckBox)sender; int closureID = (int)(cbSender).CommandParameter; if (!(closureID >= 0)) { throw new Exception(); } CashClosureReport closureReport = CashClosureReport.GetCashClosureReports().Where(c => c.CashClosure.CashClosureID == closureID).FirstOrDefault(); if (!closureReport.PrintDone) { cbSender.IsChecked = false; MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "cashClosureReportDoneNotPrinted")); return; } CashClosure cashClosure = CashClosure.GetCashClosures(closureID).FirstOrDefault(); DateTime date = cashClosure.ClosureDate; string dateTime = SafeStringParser.safeParseToStr(date, true); bool isReprint = closureReport.PrintDone; MessageBoxResult result = MessageBoxEnhanced.Question(IniParser.GetSetting("CASHCLOSURE", "questionMarkDone").Replace("{0}", dateTime)); if (result == MessageBoxResult.Yes) { int reportID = closureReport.CashClosureReportID; bool printDone = closureReport.PrintDone; DateTime printDate = (DateTime)closureReport.PrintDate; int printUserID = closureReport.PrintUserAccount.UserAccountID; bool reportDone = true; DateTime?reportDoneDate = DateTime.Now; int reportDoneUser = UserSession.userAccountID; CashClosureReport.Update(reportID, closureID, printDone, printDate, printUserID, reportDone, reportDoneDate, reportDoneUser); refreshCashClosureDataGrid(); } } catch { MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "doneCashClosureReport")); } }
/// <summary> /// Kassenabschlussbericht drucken /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void printCashClosureReport_Click(object sender, RoutedEventArgs e) { try { int closureID = (int)(((Button)sender).CommandParameter); if (!(closureID >= 0)) { throw new Exception(); } CashClosureReport closureReport = CashClosureReport.GetCashClosureReports().Where(c => c.CashClosure.CashClosureID == closureID).FirstOrDefault(); CashClosure cashClosure = CashClosure.GetCashClosures(closureID).FirstOrDefault(); DateTime date = cashClosure.ClosureDate; string dateTime = SafeStringParser.safeParseToStr(date, true); bool isReprint = closureReport.PrintDone; MessageBoxResult result; // Wenn bereits das Original gedruckt wurde, drucke automatisch den Nachdruck if (isReprint) { result = MessageBoxEnhanced.Question(IniParser.GetSetting("CASHCLOSURE", "questionReportCopyPrint").Replace("{0}", dateTime)); } else { result = MessageBoxEnhanced.Question(IniParser.GetSetting("CASHCLOSURE", "questionReportOriginalPrint").Replace("{0}", dateTime)); } // Wenn der Benutzer möchte, kann ausgedruckt werden if (result == MessageBoxResult.Yes) { PrintForms.printCashClosureReport(closureID, isReprint); } else { return; } // Wenn Nachdruck, dann ändere nichts an dem Datensatz if (isReprint) { return; } // Damit die Nachfrage nicht sofort aufploppt Thread.Sleep(1000); MessageBoxResult success = MessageBoxEnhanced.Question(IniParser.GetSetting("CASHCLOSURE", "questionPrintReportSuccess")); if (success == MessageBoxResult.Yes) { int reportID = closureReport.CashClosureReportID; bool printDone = true; DateTime printDate = DateTime.Now; int printUserID = UserSession.userAccountID; bool reportDone = closureReport.Done; DateTime?reportDoneDate = closureReport.DoneDate; int?reportDoneUser; if (closureReport.DoneUserAccount != null) { reportDoneUser = closureReport.DoneUserAccount.UserAccountID; } else { reportDoneUser = null; } CashClosureReport.Update(reportID, closureID, printDone, printDate, printUserID, reportDone, reportDoneDate, reportDoneUser); refreshCashClosureDataGrid(); } } catch { MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "printCashClosureReport")); } }