Exemplo n.º 1
0
        public static int correct(Booking booking)
        {
            if (booking.IsCorrection)
            {
                return(-1);
            }

            if (booking.Date > BookingsHelper.getDateOfLastCashClosure())
            {
                return(-2);
            }

            int    newSourceAccountID = booking.TargetAccount.AccountID;
            int    newTargetAccountID = booking.SourceAccount.AccountID;
            double amount             = booking.Amount;
            string description        = "#" + booking.BookingID + " " + IniParser.GetSetting("ACCOUNTING", "negativeBooking") +
                                        booking.SourceAccount.Number + " -> " +
                                        booking.TargetAccount.Number + ": " + amount + IniParser.GetSetting("APPSETTINGS", "currency");

            int bookingID = Booking.Add(newSourceAccountID, newTargetAccountID, amount, null, UserSession.userAccountID, description, true);

            if (bookingID < 0)
            {
                return(-3);
            }

            return(0);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Definiert das DateRangePanel
        /// </summary>
        /// <param name="dateFromProcessingFunction">Funktion, die vom Start-DatePicker bei Änderung aufgerufen wird</param>
        /// <param name="dateToProcessingFunction">Funktion, die vom Ende-DatePicker bei Änderung aufgerufen wird</param>
        /// <param name="datePickerFrom">Referenz zum darzustellenden DatePicker für Start</param>
        /// <param name="datePickerTo">Referenz zum darzustellenden DatePicker für Ende</param>
        public DateRangePanel(Action <DateTime> dateFromProcessingFunction, Action <DateTime> dateToProcessingFunction, ref DatePicker datePickerFrom, ref DatePicker datePickerTo)
        {
            this.dateFromProcessingFunction = dateFromProcessingFunction;
            this.dateToProcessingFunction   = dateToProcessingFunction;

            this.datePickerFrom = datePickerFrom;
            this.datePickerTo   = datePickerTo;

            Label lbFrom = new Label();
            Label lbTo   = new Label();

            lbFrom.Content = IniParser.GetSetting("APPSETTINGS", "dateRangeFrom");
            lbTo.Content   = IniParser.GetSetting("APPSETTINGS", "dateRangeTo");
            lbTo.Margin    = new Thickness(10, 0, 0, 0);

            this.datePickerFrom.Width = 95;
            this.datePickerTo.Width   = 95;

            this.datePickerFrom.SelectedDate = BookingsHelper.getDateOfLastCashClosure();
            this.datePickerTo.SelectedDate   = DateTime.Today;

            this.datePickerFrom.SelectedDateChanged += processDateFrom;
            this.datePickerTo.SelectedDateChanged   += processDateTo;

            panel = new WrapPanel();
            panel.HorizontalAlignment = HorizontalAlignment.Right;
            panel.VerticalAlignment   = VerticalAlignment.Top;
            panel.Margin = new Thickness(30, 10, 20, 0);     // links nur 30px wegen Platzmangel in Toolbar von Modul pSums

            panel.Children.Add(lbFrom);
            panel.Children.Add(this.datePickerFrom);
            panel.Children.Add(lbTo);
            panel.Children.Add(this.datePickerTo);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Datum zurücksetzen
 /// </summary>
 public void resetDateRange()
 {
     // Zeige standardmäßig alle Buchungen des jeweiligen Kontos vom letzten Kassenschluss bis jetzt an
     this.dateFrom = BookingsHelper.getDateOfLastCashClosure();
     this.dateTo   = BookingsHelper.makeDateGreat(DateTime.Today);
     this.datePickerFrom.SelectedDate = this.dateFrom;
     this.datePickerTo.SelectedDate   = this.dateTo;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Liste mit ungefilterten Daten generieren
        /// </summary>
        private void generateDataGridDataUnfiltered()
        {
            this.bookingModelsUnchanged.Clear();
            IEnumerable <Booking> bookings = Booking.GetBookings();
            DateTime lastCashClosure       = BookingsHelper.getDateOfLastCashClosure();

            foreach (var booking in bookings)
            {
                bookingModelsUnchanged.Add(new BookingDataGridModel(booking, lastCashClosure));
            }
        }
Exemplo n.º 5
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"));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Öffnet das Formular zum Bearbeiten einer Buchung
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Edit_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(IniParser.GetSetting("ERRORMSG", "loadBooking"));
                }

                if (currentBooking.IsCorrection)
                {
                    throw new Exception(IniParser.GetSetting("ERRORMSG", "correctionEdit"));
                }

                if (Booking.GetBookings().Where(b => b.IsCorrection).Where(b => b.Description.Contains("#" + currentBooking.BookingID.ToString())).ToList().Count > 0)
                {
                    throw new Exception(IniParser.GetSetting("ERRORMSG", "correctionExists"));
                }

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

                MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
                Type       pageType   = typeof(pEditBooking);
                mainWindow.switchPage(IniParser.GetSetting("ACCOUNTING", "editBooking"), pageType, currentBooking);
            }
            catch (Exception ex)
            {
                MessageBoxEnhanced.Error(ex.Message);
            }
        }