private void updateAmount()
        {
            dtgRevenue2.CommitEdit();
            double amount = 0;

            for (int rowIdx = 0; rowIdx < dtgRevenue2.Items.Count; rowIdx++)
            {
                var currentRow = dtgRevenue2.GetRow(rowIdx);
                if (currentRow == null)
                {
                    continue;
                }
                var actualRevenue = (RevenueModel)currentRow.Item;

                if (!actualRevenue.revAmount.Equals(""))
                {
                    try
                    {
                        amount += Convert.ToDouble(actualRevenue.revAmount.Replace(".", ","));
                    }
                    catch
                    { }
                    lblAmount.Content = SafeStringParser.safeParseToMoney(amount, true);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Wandelt ein FilterSet der Datenbank in eine Instanz von FilterSetModel um
        /// </summary>
        /// <param name="filterSet">DataModel.FilterSet</param>
        /// <returns>FilterSetModel</returns>
        public static FilterSetModel getFilterSetModelFromFilterSet(FilterSet filterSet)
        {
            if (filterSet == null)
            {
                return(null);
            }

            IEnumerable <Filter> filters = Filter.GetFilters(null, filterSet.FilterSetID);

            // Name des FilterSets
            FilterSetModel filterSetModel = new FilterSetModel(filterSet.Linking);

            filterSetModel.name = filterSet.Name;

            // füge diesem filterSet alle filter hinzu
            foreach (var filter in filters)
            {
                FilterModel filterModel = new FilterModel();
                // konvertiere die strings aus der datenbank in enums
                filterModel.group     = (FilterModel.Groups)Enum.Parse(typeof(FilterModel.Groups), filter.Table);
                filterModel.criterion = (FilterModel.Criterions)Enum.Parse(typeof(FilterModel.Criterions), filter.Type);
                filterModel.operation = (FilterModel.Operations)Enum.Parse(typeof(FilterModel.Operations), filter.Operation);
                filterModel.value     = SafeStringParser.safeParseToStr(filter.Value);
                filterSetModel.filterList.Add(filterModel);
            }
            return(filterSetModel);
        }
Beispiel #3
0
        /// <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\">&lt;Nachdruck&gt;</text:placeholder>");
            if (reprint)
            {
                replaceSt.Add(SafeStringParser.safeParseToStr(IniParser.GetSetting("DOCUMENTS", "reprint")));
            }
            else
            {
                replaceSt.Add("");
            }

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kassenabschlussdatum&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(report.CashClosure.ClosureDate));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kassenabschlussnummer&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(report.CashClosure.CashClosureID));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Einnahmen&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Revenue, true));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Ausgaben&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Expense, true));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Saldo&gt;</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);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Füllt die Felder aus
        /// Benötigt Kassenabschluss-Instanz und die zugehörigen Kassenabrechnung-Instanz und Kassenabschlussbeleg-Instanz
        /// </summary>
        /// <param name="cashClosure">Kassenabschluss-Instanz</param>
        /// <param name="cashClosureReport">Kassenabschlussbeleg-Instanz</param>
        /// <param name="cashClosureReceipt">Kassenabrechnung-Instanz</param>
        public CashClosureManagerDataGridModel(CashClosure cashClosure, CashClosureReport cashClosureReport, CashClosureReceipt cashClosureReceipt)
        {
            this.cashClosure        = cashClosure;
            this.cashClosureReport  = cashClosureReport;
            this.cashClosureReceipt = cashClosureReceipt;

            this.cashClosureID        = cashClosure.CashClosureID;
            this.closureDate          = SafeStringParser.safeParseToStr(cashClosure.ClosureDate, true);
            this.comment              = SafeStringParser.safeParseToStr(cashClosure.Comment);
            this.revenues             = SafeStringParser.safeParseToMoney(cashClosure.Revenue, true);
            this.expenses             = SafeStringParser.safeParseToMoney(cashClosure.Expense, true);
            this.sum                  = SafeStringParser.safeParseToMoney(cashClosure.Sum, true);
            this.reportPrinted        = cashClosureReport.PrintDone;
            this.reportPrintDate      = SafeStringParser.safeParseToStr(cashClosureReport.PrintDate, true);
            this.reportDone           = cashClosureReport.Done;
            this.reportDoneBoxEnabled = !(cashClosureReport.Done);
            this.reportDoneDate       = SafeStringParser.safeParseToStr(cashClosureReport.DoneDate, true);
            this.receiptPrinted       = cashClosureReceipt.PrintDone;
            this.receiptPrintedDate   = SafeStringParser.safeParseToStr(cashClosureReceipt.PrintDate, true);

            if (cashClosure.ClosureUserAccount != null)
            {
                this.closureUser = SafeStringParser.safeParseToStr(cashClosure.ClosureUserAccount.Username);
            }
            else
            {
                this.closureUser = "";
            }

            if (cashClosureReport.PrintUserAccount != null)
            {
                this.reportPrintUser = SafeStringParser.safeParseToStr(cashClosureReport.PrintUserAccount.Username);
            }
            else
            {
                this.reportPrintUser = "";
            }

            if (cashClosureReport.DoneUserAccount != null)
            {
                this.reportDoneUser = SafeStringParser.safeParseToStr(cashClosureReport.DoneUserAccount.Username);
            }
            else
            {
                this.reportDoneUser = "";
            }

            if (cashClosureReceipt.PrintUserAccount != null)
            {
                this.receiptPrintedUser = SafeStringParser.safeParseToStr(cashClosureReceipt.PrintUserAccount.Username);
            }
            else
            {
                this.receiptPrintedUser = "";
            }
        }
Beispiel #5
0
 /// <summary>
 /// Erzeugt eigenen String
 /// </summary>
 /// <returns>string</returns>
 public override string ToString()
 {
     if (account != null)
     {
         return(SafeStringParser.safeParseToStr(this.accountName) + " (" + SafeStringParser.safeParseToStr(accountNumber) + ")");
     }
     else
     {
         return(SafeStringParser.safeParseToStr(this.accountName));
     }
 }
Beispiel #6
0
        /// <summary>
        /// Speicher Button Klick Event
        /// </summary>
        /// <param name="button"></param>
        private void SaveButton_Click(Button button)
        {
            if (ValidateUserInput())
            {
                var name        = NameTextBox.Text;
                var description = SafeStringParser.safeParseToStr(DescriptionTextBox.Text);

                Note.Update(_CurrentNote.NoteID, name, description);

                KPage      pageNoteAdmin = new KöTaf.WPFApplication.Views.pNoteAdministration();;
                SinglePage singlePage    = new SinglePage(IniParser.GetSetting("NOTES", "notes"), pageNoteAdmin);
            }
        }
 /// <summary>
 /// Füllt die Felder
 /// </summary>
 /// <param name="account">Konto-Referenz</param>
 /// <param name="oldBalance">bisheriger Kontostand</param>
 /// <param name="revenues">Einnahmen</param>
 /// <param name="expenses">Ausgaben</param>
 /// <param name="newBalance">Neuer Kontostand</param>
 public CashClosureAccountsDataGridModel(Account account, double oldBalance, double revenues, double expenses, double newBalance)
 {
     this.account          = account;
     this.name             = SafeStringParser.safeParseToStr(account.Name);
     this.number           = SafeStringParser.safeParseToStr(account.Number);
     this.description      = SafeStringParser.safeParseToStr(account.Description);
     this.zeroPeriod       = zeroPeriodToString(account.ZeroPeriodEnum);
     this.oldBalance       = SafeStringParser.safeParseToMoney(oldBalance, true);
     this.revenues         = SafeStringParser.safeParseToMoney(revenues, true);
     this.expenses         = SafeStringParser.safeParseToMoney(expenses, true);
     this.newBalance       = SafeStringParser.safeParseToMoney(newBalance, true);
     this.newBalanceDOUBLE = newBalance;
 }
        /// <summary>
        /// Füllt Attribute
        /// </summary>
        /// <param name="person">Person</param>
        public QuickBookingDataGridModel(Person person)
        {
            if (!(person.TableNo.HasValue))
            {
                return;
            }

            this.person       = person;
            this.tableNo      = (int)person.TableNo;
            this.lastName     = person.LastName;
            this.firstName    = person.FirstName;
            this.validityEnd  = SafeStringParser.safeParseToStr(person.ValidityEnd);
            this.dateOfBirth  = SafeStringParser.safeParseToStr(person.DateOfBirth);
            this.lastPurchase = SafeStringParser.safeParseToStr(person.LastPurchase);
            this.group        = person.Group;
        }
Beispiel #9
0
        /// <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>
        /// Erzeugt neues Datenmodell für ein Konto
        /// </summary>
        /// <param name="account">Konto</param>
        public AccountManagerDataGridModel(Account account)
        {
            this.accountID     = account.AccountID;
            this.accountName   = SafeStringParser.safeParseToStr(account.Name);
            this.accountNumber = SafeStringParser.safeParseToStr(account.Number);
            this.description   = SafeStringParser.safeParseToStr(account.Description);
            this.isOfficial    = SafeStringParser.safeParseToStr(account.IsOfficial);
            this.isCapital     = SafeStringParser.safeParseToStr(account.IsCapital);

            switch (account.ZeroPeriodEnum)
            {
            case ZeroPeriod.EveryCashClosure:
                this.zeroPeriod = IniParser.GetSetting("ZEROPERIODS", "everyCashClosure");
                break;

            case ZeroPeriod.Annually:
                this.zeroPeriod = IniParser.GetSetting("ZEROPERIODS", "annually");
                break;

            case ZeroPeriod.Monthly:
                this.zeroPeriod = IniParser.GetSetting("ZEROPERIODS", "monthly");
                break;

            case ZeroPeriod.Never:
                this.zeroPeriod = IniParser.GetSetting("ZEROPERIODS", "never");
                break;

            default:
                this.zeroPeriod = "";
                break;
            }

            if (account.IsFixed)
            {
                this.isFixed     = IniParser.GetSetting("PARSING", "yes");
                visibilityEdit   = Visibility.Hidden;
                visibilityDelete = Visibility.Hidden;
            }
            else
            {
                this.isFixed     = IniParser.GetSetting("PARSING", "no");
                visibilityEdit   = Visibility.Visible;
                visibilityDelete = Visibility.Visible;
            }
        }
        /// <summary>
        /// Setzt in der GUI die Ausgaben dieses und des letzten Jahres.
        /// </summary>
        private void SetExpenses()
        {
            CashClosureHelper helper = new CashClosureHelper(false);
            int currentYear          = DateTime.Now.Year;

            //Expenses of this year
            DateTime from = BookingsHelper.makeDateSmall(new DateTime(currentYear, 1, 1));
            DateTime to   = BookingsHelper.makeDateGreat(DateTime.Today);

            expensesThisYear = helper.getAllExpensesForPeriod(from, to);

            //Expenses of last year
            from             = BookingsHelper.makeDateSmall(new DateTime(currentYear - 1, 1, 1));
            to               = BookingsHelper.makeDateGreat(new DateTime(currentYear - 1, 12, 31));
            expensesLastYear = helper.getAllExpensesForPeriod(from, to);

            lExpensesThisYear.Content = SafeStringParser.safeParseToMoney(expensesThisYear, true);
            lExpensesLastYear.Content = SafeStringParser.safeParseToMoney(expensesLastYear, true);
        }
Beispiel #12
0
        /// <summary>
        /// Löscht eine Buchung
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int            bookingID      = (int)((Button)sender).CommandParameter;
                List <Booking> booking        = Booking.GetBookings(bookingID).ToList();
                Booking        currentBooking = booking[0];

                if (currentBooking == null)
                {
                    throw new Exception();
                }

                string date    = SafeStringParser.safeParseToStr(currentBooking.Date, true);
                string warning = IniParser.GetSetting("ACCOUNTING", "warningBookingDelete").Replace("{0}", date);

                if (MessageBoxEnhanced.Warning(warning) == MessageBoxResult.No)
                {
                    return;
                }

                if (currentBooking.Date <= BookingsHelper.getDateOfLastCashClosure())
                {
                    throw new Exception(IniParser.GetSetting("ERRORMSG", "bookingBeforeLastClosure"));
                }

                Booking.Delete(currentBooking.BookingID);

                // Refresh page
                generateDataGridDataUnfiltered();
                refreshDataGrid(this.bookingModelsUnchanged);
            }
            catch
            {
                MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "deleteBooking"));
            }
        }
        /// <summary>
        /// DataGrid aktualisieren
        /// </summary>
        private void refreshDataGrid()
        {
            CashClosureHelper cashClosureHelper = new CashClosureHelper();
            List <Account>    closureAccounts   = cashClosureHelper.closureAccounts;

            this.accountModels.Clear();

            double sumRevenues    = 0;
            double sumExpenses    = 0;
            double sumNewBalances = 0;

            // Berechne für jedes Kassenschluss-Konto die Summen
            foreach (var account in closureAccounts)
            {
                double oldBalance = cashClosureHelper.getOldBalanceForAccount(account.AccountID);
                double revenues   = cashClosureHelper.getRevenuesForAccount(account.AccountID);
                double expenses   = cashClosureHelper.getExpensesForAccount(account.AccountID);
                double newBalance = oldBalance + revenues - expenses;

                CashClosureAccountsDataGridModel model = new CashClosureAccountsDataGridModel(account, oldBalance, revenues, expenses, newBalance);
                accountModels.Add(model);

                sumRevenues    += revenues;
                sumExpenses    += expenses;
                sumNewBalances += newBalance;
            }
            AccountsDataGrid.ItemsSource = accountModels;
            AccountsDataGrid.Items.Refresh();

            // Zeige Gesamt-Summen an
            lbRevenues.Content = SafeStringParser.safeParseToMoney(sumRevenues, true);
            lbExpenses.Content = SafeStringParser.safeParseToMoney(sumExpenses, true);
            lbSum.Content      = SafeStringParser.safeParseToMoney(sumNewBalances, true);

            this.expensesTotal = sumExpenses;
            this.revenuesTotal = sumRevenues;
        }
Beispiel #14
0
        /// <summary>
        /// Summen berechnen
        /// </summary>
        /// <param name="bookingModels"></param>
        private void calculateAndShowSums(List <BookingDataGridModel> bookingModels)
        {
            double revenues, sum, expenses;

            // Wenn "alle Eigenkapitalkonten" ausgewählt, dann summiere alle Eigenkapitalkonten
            if (this.currentAccountNumber == -1)
            {
                // Einnahmen: Buchungen mit Eigenkapital-Konto als Zielkonto
                revenues = bookingModels.Where(b => b.targetAccountIsCapital).Sum(b => b.amountDOUBLE);

                // Ausgaben: Buchungen mit Eigenkapital-Konto als QuellKonto
                expenses = bookingModels.Where(b => b.sourceAccountIsCapital).Sum(b => b.amountDOUBLE);

                sum = revenues - expenses;
            }
            // Ansonsten summiere für das ausgewählte Konto
            else
            {
                // Einnahmen: Buchungen mit Filter-Konto als Zielkonto
                revenues = bookingModels.Where(b => b.targetAccountNumberINT == this.currentAccountNumber).Sum(b => b.amountDOUBLE);

                // Ausgaben: Buchungen mit Filter-Konto als QuellKonto
                expenses = bookingModels.Where(b => b.sourceAccountNumberINT == this.currentAccountNumber).Sum(b => b.amountDOUBLE);

                sum = revenues - expenses;
            }

            // Zeige Beträge an
            lbExpenses.Content = SafeStringParser.safeParseToMoney(expenses, true);
            lbRevenues.Content = SafeStringParser.safeParseToMoney(revenues, true);
            lbSum.Content      = SafeStringParser.safeParseToMoney(sum, true);

            Account currentAccount = Account.GetAccounts(null, null, this.currentAccountNumber).FirstOrDefault();

            lbLatestBalance.Content = SafeStringParser.safeParseToMoney(currentAccount.LatestBalance, true);
        }
Beispiel #15
0
        /// <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"));
            }
        }
Beispiel #16
0
        /// <summary>
        /// Lege neues Modell an
        /// </summary>
        /// <param name="booking">zugehörige Buchung</param>
        /// <param name="lastCashClosure">Datum letzter Kassenabschluss</param>
        public BookingDataGridModel(Booking booking, DateTime lastCashClosure)
        {
            this.booking                 = booking;
            this.bookingID               = booking.BookingID;
            this.amount                  = SafeStringParser.safeParseToMoney(booking.Amount, true);
            this.amountDOUBLE            = booking.Amount;
            this.date                    = booking.Date;
            this.dateString              = SafeStringParser.safeParseToStr(booking.Date, true);
            this.description             = SafeStringParser.safeParseToStr(booking.Description);
            this.sourceAccountString     = SafeStringParser.safeParseToStr(booking.SourceAccount.Name) + " (" + SafeStringParser.safeParseToStr(booking.SourceAccount.Number) + ")";
            this.targetAccountString     = SafeStringParser.safeParseToStr(booking.TargetAccount.Name) + " (" + SafeStringParser.safeParseToStr(booking.TargetAccount.Number) + ")";
            this.sourceAccountNumber     = SafeStringParser.safeParseToStr(booking.SourceAccount.Number);
            this.targetAccountNumber     = SafeStringParser.safeParseToStr(booking.TargetAccount.Number);
            this.sourceAccountNumberINT  = booking.SourceAccount.Number;
            this.targetAccountNumberINT  = booking.TargetAccount.Number; this.sourceAccountName = SafeStringParser.safeParseToStr(booking.SourceAccount.Name);
            this.targetAccountName       = SafeStringParser.safeParseToStr(booking.TargetAccount.Name);
            this.sourceAccountIsOfficial = booking.SourceAccount.IsOfficial;
            this.targetAccountIsOfficial = booking.TargetAccount.IsOfficial;
            this.sourceAccountIsCapital  = booking.SourceAccount.IsCapital;
            this.targetAccountIsCapital  = booking.TargetAccount.IsCapital;

            if (booking.UserAccount != null)
            {
                this.user = SafeStringParser.safeParseToStr(booking.UserAccount.Username);
            }
            else
            {
                this.user = "";
            }

            if (booking.Person != null)
            {
                this.customer = SafeStringParser.safeParseToStr(booking.Person.TableNo);
            }
            else
            {
                this.customer = "";
            }

            // Korrekturbuchung-Button wird nur angezeigt wenn Datum vor dem letzten Kassenschluss
            if (booking.Date <= lastCashClosure)
            {
                this.visibilityCorrection = Visibility.Visible;
            }
            else
            {
                this.visibilityCorrection = Visibility.Hidden;
            }

            // Löschen/Edit-Button wird nur angezeigt wenn Datum nach dem letzten Kassenschluss
            if (booking.Date > lastCashClosure)
            {
                this.visibilityDelete = Visibility.Visible;
                this.visibilityEdit   = Visibility.Visible;
            }
            else
            {
                this.visibilityDelete = Visibility.Hidden;
                this.visibilityEdit   = Visibility.Hidden;
            }

            // Korrekturbuchungen sind nicht editierbar/korrigierbar
            if (booking.IsCorrection)
            {
                this.visibilityEdit       = Visibility.Hidden;
                this.visibilityCorrection = Visibility.Hidden;
            }
        }
Beispiel #17
0
        /// <summary>
        /// Erzeugt neues Filter-Datenbankobjekt anhand einer formletter_pattern-ID
        /// </summary>
        /// <param name="patternID"></param>
        public FormletterPatternModelDB(int patternID)
        {
            filterSetModels = new List <FilterSetModel>();
            //formletterTableAssignments = new List<FormletterTableAssignment>();
            formletterColumnCsvDocumentAssignments = new List <FormletterColumnCsvDocumentAssignment>();

            // Lese zurück
            IList <FormletterPattern> patterns = FormletterPattern.GetFormletterPatterns(patternID).ToList <FormletterPattern>();

            // Es gibt genau einen formletterPattern
            FormletterPattern pattern = patterns[0];

            // Strings füllen
            this.name                = SafeStringParser.safeParseToStr(pattern.Name);
            this.saluation_m         = SafeStringParser.safeParseToStr(pattern.SaluationM);
            this.saluation_f         = SafeStringParser.safeParseToStr(pattern.SaluationF);
            this.saluation_n         = SafeStringParser.safeParseToStr(pattern.SaluationNT);
            this.formletter_filename = SafeStringParser.safeParseToStr(pattern.FileName);
            this.csv_filename        = SafeStringParser.safeParseToStr(pattern.FileName).Replace(".odt", ".csv");
            this.letterText          = SafeStringParser.safeParseToStr(pattern.Text);

            // pattern ID
            pID = pattern.FormletterPatternID;

            // füge diesem formletterPattern alle filterSets hinzu
            IEnumerable <FilterSet> filterSets = FilterSet.GetFilterSets(null, pID);

            foreach (var set in filterSets)
            {
                // Hole die IDs alle Filter dieses FilterSets
                int fsID = set.FilterSetID;
                IEnumerable <Filter> filters = Filter.GetFilters(null, fsID);

                // Name des FilterSets
                FilterSetModel filterSetModel = new FilterSetModel(set.Linking);
                filterSetModel.name = set.Name;

                // füge diesem filterSet alle filter hinzu
                foreach (var filter in filters)
                {
                    FilterModel filterModel = new FilterModel();
                    // konvertiere die strings aus der datenbank in enums
                    filterModel.group     = (FilterModel.Groups)Enum.Parse(typeof(FilterModel.Groups), filter.Table);
                    filterModel.criterion = (FilterModel.Criterions)Enum.Parse(typeof(FilterModel.Criterions), filter.Type);
                    filterModel.operation = (FilterModel.Operations)Enum.Parse(typeof(FilterModel.Operations), filter.Operation);
                    filterModel.value     = SafeStringParser.safeParseToStr(filter.Value);
                    filterSetModel.filterList.Add(filterModel);
                }

                filterSetModels.Add(filterSetModel);
            }

            // Füge alle Spaltenverknüpfungen hinzu
            IEnumerable <ColumnAssignment> assignments = ColumnAssignment.GetColumnAssignments(null, pID);

            foreach (var assignment in assignments)
            {
                string csvCol  = SafeStringParser.safeParseToStr(assignment.CsvColumn);
                string dbTable = SafeStringParser.safeParseToStr(assignment.DatabaseTable);
                string dbCol   = SafeStringParser.safeParseToStr(assignment.DatabaseColumn);

                // parse diese strings in ihre Enum-Äquivalente
                FormletterTableAssignment.Groups eDbTable = (FormletterTableAssignment.Groups)Enum.Parse(typeof(FormletterTableAssignment.Groups), dbTable);
                FormletterTableAssignment.Fields eDbCol   = (FormletterTableAssignment.Fields)Enum.Parse(typeof(FormletterTableAssignment.Fields), dbCol);

                // erstelle eine enum-basierte tabellen-spalten-verknüpfung damit
                FormletterTableAssignment fta = new FormletterTableAssignment(eDbTable, eDbCol);

                // jetzt haben wir ein komplettes csv-datenbank-spaltenverknüpfungs-objekt
                FormletterColumnCsvDocumentAssignment colAssignment = new FormletterColumnCsvDocumentAssignment(csvCol, fta);

                this.formletterColumnCsvDocumentAssignments.Add(colAssignment);
            }
        }
Beispiel #18
0
        /// <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\">&lt;Nachname&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(person.LastName));

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Vorname&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(person.FirstName));

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Ausweisnummer&gt;</text:placeholder>");
                if (person.TableNo.HasValue)
                {
                    replaceSt.Add(SafeStringParser.safeParseToStr(person.TableNo));
                }
                else
                {
                    return;
                }

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Datum&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(DateTime.Now));
            }
            else
            {
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Nachname&gt;</text:placeholder>");
                replaceSt.Add("");

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Vorname&gt;</text:placeholder>");
                replaceSt.Add("");

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Ausweisnummer&gt;</text:placeholder>");
                replaceSt.Add("");

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Datum&gt;</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);
            }
        }
 /// <summary>
 /// Setzt in der GUI den Gewinn dieses und des letzten Jahres.
 /// </summary>
 private void SetProfit()
 {
     lProfitThisYear.Content = SafeStringParser.safeParseToMoney((revenuesThisYear - expensesThisYear), true);
     lProfitLastYear.Content = SafeStringParser.safeParseToMoney((revenuesLastYear - expensesLastYear), true);
 }
Beispiel #20
0
        /// <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\">&lt;Vorname&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.FirstName));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Nachname&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.LastName));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Strasse&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.Street));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;PLZ&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.ZipCode));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Ort&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.City));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Geburtstag&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.DateOfBirth));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Staatsangehoerigkeit&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.Nationality));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Geburtsland&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.CountryOfBirth));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Familienstand&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.FamilyState.Name));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Vorname_Partner&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalFirstName));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Nachname_Partner&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalLastName));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Geburtstag_Partner&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalBirthday));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Staatsangehoerigkeit_Partner&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalNationality));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Datum&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(DateTime.Now));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Gueltigkeitsende&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.ValidityEnd));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;KNR&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.TableNo));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Erfasser&gt;</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\">&lt;Kind_Index_" + childIndex + "&gt;</text:placeholder>");
                replaceSt.Add("#" + childIndex);
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Vorname_" + childIndex + "&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(child.FirstName));
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Nachname_" + childIndex + "&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(child.LastName));
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Geburtstag_" + childIndex + "&gt;</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\">&lt;Kind_Index_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Vorname_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Nachname_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Geburtstag_" + i + "&gt;</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\">&lt;Einkunft_" + revenueIndex + "&gt;</text:placeholder>");
                replaceSt.Add(revenue.RevenueType.Name + ": " + revenue.Description);
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Bescheid_" + revenueIndex + "&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(revenue.StartDate));
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Bewilligt_" + revenueIndex + "&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(revenue.EndDate));
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Hoehe_" + revenueIndex + "&gt;</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\">&lt;Einkunft_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Bescheid_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Bewilligt_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Hoehe_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
            }

            string tmpFilePath;
            bool   success = LibreOffice.replaceXMLstringInODT(path, toReplace, replaceSt, out tmpFilePath);

            if (success)
            {
                LibreOffice.openWithWriter(tmpFilePath, true, true);
            }
        }
        public void fillRevenuesDataGrid(IEnumerable <Revenue> revenues)
        {
            //Bisheriger Gesamtbetrag
            double amount = 0;

            IEnumerable <DB.RevenueType> revTypes = DB.RevenueType.GetRevenueTypes();

            // Combobox mit den RevenueTypes befüllen!
            var types   = revTypes.ToList();
            var cbItems = types.ToList().Select(n => new CBItem
            {
                Name = n.Name
            });

            List <CBItem> tmpRevTypes = new List <CBItem>();

            tmpRevTypes.Add(null);

            foreach (CBItem cI in cbItems)
            {
                tmpRevTypes.Add(cI);
            }

            DateTime defaultDate = DateTime.Today;

            //DB.RevenueDetail revDetail = new RevenueDetail();
            //revDetail.Amount = 0;
            //revDetail.EndDate = defaultDate;
            //revDetail.StartDate = defaultDate;

            //vorhandene Revenues eintragen


            foreach (Revenue rev in revenues)
            {
                //Combobox individuell füllen Selektiertes zuerst.

                List <CBItem> existingRevType = new List <CBItem>();

                foreach (CBItem cI in cbItems)
                {
                    if (cI.Name == rev.RevenueType.Name)
                    {
                        existingRevType.Add(cI);
                    }
                }

                foreach (CBItem cI in cbItems)
                {
                    if (cI.Name != rev.RevenueType.Name)
                    {
                        existingRevType.Add(cI);
                    }
                }


                RevenueModel existingRev = new RevenueModel();
                existingRev.revType        = existingRevType;
                existingRev.revDescription = rev.Description;
                existingRev.revAmount      = rev.Amount.ToString();
                amount += rev.Amount;
                existingRev.isAdded      = true;
                existingRev.revStartDate = rev.StartDate;
                existingRev.revEndDate   = (DateTime)rev.EndDate;
                existingRev.revenueID    = rev.RevenueID;


                this._Revenues.Add(existingRev);
            }


            //eine Neue Zeile hinzufügen
            RevenueModel newRev = new RevenueModel();

            newRev.revType        = tmpRevTypes;
            newRev.revDescription = "";
            newRev.revStartDate   = defaultDate;
            newRev.revEndDate     = defaultDate;
            newRev.revenueID      = 0;
            newRev.revAmount      = "0";
            newRev.isAdded        = false;

            this._Revenues.Add(newRev);
            dtgRevenue2.Items.Refresh();
            dtgRevenue2.ItemsSource = this._Revenues;
            dtgRevenue2.Items.Refresh();

            //Gesamtbetrag vorbelegen
            lblAmount.Content = SafeStringParser.safeParseToMoney(amount, true);
        }
Beispiel #22
0
        /// <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\">&lt;Kassenabschlussdatum&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(receipt.CashClosure.ClosureDate));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Einnahmen&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToMoney(receipt.CashClosure.Revenue, true));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Ausgaben&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToMoney(receipt.CashClosure.Expense, true));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Saldo&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToMoney(receipt.CashClosure.Sum, true));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;abgerechnet_durch&gt;</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\">&lt;Nachdruck&gt;</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);
            }
        }