Beispiel #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);
        }
Beispiel #2
0
        public void ControllerAddBookning(int Treatment, int Doctor, int Animal, int CageID, int CageDay, string Date, int Times, int Owner)
        {
            Booking TempBook;

            TempBook = new Booking(Treatment, Doctor, Animal, CageID, CageDay, Date, Times, Owner);
            TempBook.Add();
        }
Beispiel #3
0
        public static List <BookingModel> SaveBooking(BookingModel bookingData = null)
        {
            var dbBooking = new Booking();

            dbBooking.Id           = bookingData.Id;
            dbBooking.Name         = bookingData.Name;
            dbBooking.CreationDate = DateTime.Now;
            dbBooking.UpdatedDate  = DateTime.Now;
            //dbBooking.BookingParts = new List<BookingPart>();

            bookingData.BookingParts.ForEach(bpt =>
            {
                dbBooking.Add(new BookingPart
                {
                    Id           = bpt.Id,
                    CreationDate = DateTime.Now,
                    CreationTime = DateTime.Now,
                    Status       = 2,
                    Description  = bpt.Description,
                    Title        = bpt.Title,
                    UpdatedDate  = DateTime.Now,
                });
            });

            using (var session = SessionFactoryBuilder.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(dbBooking);
                    transaction.Commit();
                }
            }

            return(GetBookings());
        }
Beispiel #4
0
        /// <summary>
        /// Buchung speichern
        /// </summary>
        /// <param name="button">sendender Button</param>
        private void Speichern_Click(Button button)
        {
            this.validator.clearSB();
            this.checkForm();

            if (!this.isValid)
            {
                MessageBox.Show(this.validator.getErrorMsg().ToString(), IniParser.GetSetting("ERRORMSG", "noTextField"), MessageBoxButton.OK);
                this.validator.clearSB();
            }
            else
            {
                try
                {
                    ComboBox cbSoll       = cbSourceAccount as ComboBox;
                    Account  accSoll      = cbSoll.SelectedItem as Account;
                    int      srcAccountID = accSoll.AccountID;

                    ComboBox cbHaben         = cbTargetAccount as ComboBox;
                    Account  accHaben        = cbHaben.SelectedItem as Account;
                    int      targetAccountID = accHaben.AccountID;

                    double amount;
                    bool   parsed = Double.TryParse(tbAmount.Text.Replace(".", ","), out amount);

                    string description = tbDescription.Text;

                    int bookingId = Booking.Add(srcAccountID, targetAccountID, amount, null, UserSession.userAccountID, description);

                    if (bookingId < 0)
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "newBooking"));
                    this.validator.clearSB();
                    return;
                }

                MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
                Type       pageType   = typeof(pBookings);
                mainWindow.switchPage(IniParser.GetSetting("ACCOUNTING", "bookings"), pageType);
            }
            this.validator.clearSB();
        }
Beispiel #5
0
        public bool IsAvailable(int roomNo, DateTime startDateTime, DateTime endDateTime)
        {
            bool isVal = true;
            List <models.Booking> Booking = new List <models.Booking>();

            if (!RoomBookingList.TryGetValue(roomNo, out Booking))
            {
                Booking = new List <models.Booking>();
            }
            foreach (models.Booking val in Booking)
            {
                if (startDateTime >= val.StartDateTime && startDateTime <= val.EndDateTime)
                {
                    isVal = false;
                }
                else if (startDateTime <= val.StartDateTime)
                {
                    if (endDateTime >= val.StartDateTime || endDateTime >= val.EndDateTime)

                    {
                        isVal = false;
                    }
                }
            }


            if (isVal)
            {
                //set booking
                Booking.Add(new models.Booking
                {
                    StartDateTime = startDateTime,
                    EndDateTime   = endDateTime,
                    Id            = Guid.NewGuid().ToString() //Booking.Count+1
                });

                RoomBookingList[roomNo] = Booking;
            }

            return(isVal);
        }
Beispiel #6
0
        private void btnAddBooking_Click(object sender, EventArgs e)
        {
            if (numMenu1Count.Value + numMenu2Count.Value + numMenu3Count.Value + numMenu4Count.Value > numPeopleUpDown.Value)
            {
                MessageBox.Show("You cannot specify more menus than there are number of people!", "Error:", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                return;
            }
            try
            {
                //take the customer and their details and add to the database
                Customer customer         = Customer.RetrieveById(customerId);
                Booking  inserted_Booking = Booking.Add(new Booking((int)numPeopleUpDown.Value, datePickerPlaced.Value, datePickerEvent.Value,
                                                                    bool.Parse(comboConfirmed.SelectedItem.ToString()),
                                                                    bool.Parse(comboPaid.SelectedItem.ToString()),
                                                                    customerId,
                                                                    ApplicationManagement.ApplicationManager.LoggedInEmployee));

                //add the choosen menus and quantities to the meals table
                if (inserted_Booking != null)
                {
                    try{
                        //the is a max of 4 menus options for each booking

                        if (comboMenu1.Text != "None")
                        {
                            FoodMenu menu1    = (FoodMenu)comboMenu1.SelectedItem;
                            int      quantity = (int)numMenu1Count.Value;

                            Meal.Add(new Meal(inserted_Booking, menu1, quantity));
                        }
                        if (comboMenu2.Text != "None")
                        {
                            FoodMenu menu2    = (FoodMenu)comboMenu2.SelectedItem;
                            int      quantity = (int)numMenu2Count.Value;

                            Meal.Add(new Meal(inserted_Booking, menu2, quantity));
                        }
                        if (comboMenu3.Text != "None")
                        {
                            FoodMenu menu3    = (FoodMenu)comboMenu3.SelectedItem;
                            int      quantity = (int)numMenu3Count.Value;

                            Meal.Add(new Meal(inserted_Booking, menu3, quantity));
                        }
                        if (comboMenu4.Text != "None")
                        {
                            FoodMenu menu4    = (FoodMenu)comboMenu4.SelectedItem;
                            int      quantity = (int)numMenu4Count.Value;

                            Meal.Add(new Meal(inserted_Booking, menu4, quantity));
                        }
                        MessageBox.Show("Booking & Food Menu(s) Successfully Added!");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}", ex.Message);
                MessageBox.Show("Failed to add booking Check Your Input!");
            }
        }
Beispiel #7
0
        /// <summary>
        /// Legt neue Buchung an und aktualisiert Person
        /// </summary>
        /// <param name="person">Instanz von Person</param>
        /// <param name="amount">Betrag</param>
        /// <param name="srcAccountID">Quellkonto</param>
        /// <param name="targetAccountID">Zielkonto</param>
        /// <returns></returns>
        private bool newQuickBooking(Person person, double amount, int srcAccountID, int targetAccountID)
        {
            try
            {
                // aktualisiere lastPurchase des Kunden
                var personID              = person.PersonID;
                var firstName             = person.FirstName;
                var lastName              = person.LastName;
                var zipCode               = person.ZipCode;
                var city                  = person.City;
                var street                = person.Street;
                var nationality           = person.Nationality;
                var tableNo               = person.TableNo;
                var phone                 = person.Phone;
                var mobileNo              = person.MobileNo;
                var comment               = person.Comment;
                var countryOfBirth        = person.CountryOfBirth;
                var dateOfBirth           = person.DateOfBirth;
                var email                 = person.Email;
                var group                 = person.Group;
                var validityStart         = person.ValidityStart;
                var validityEnd           = person.ValidityEnd;
                var maritalBirthday       = person.MaritalBirthday;
                var maritalFirstName      = person.MaritalFirstName;
                var maritalLastName       = person.MaritalLastName;
                var maritalNationality    = person.MaritalNationality;
                var lastPurchase          = DateTime.Now;
                var maritalCountryOfBirth = person.MaritalCountryOfBirth;
                var maritalPhone          = person.MaritalPhone;
                var maritalMobile         = person.MaritalMobile;
                var maritalEmail          = person.MaritalEmail;
                int familyStateID         = person.FamilyState.FamilyStateID;
                int titleID               = person.Title.TitleID;

                int?maritalTitleID;
                if (person.MaritalTitle != null)
                {
                    maritalTitleID = person.MaritalTitle.TitleID;
                }
                else
                {
                    maritalTitleID = null;
                }

                int?userAccountID;      // UserAccount ist manchmal null - wahrscheinlich ein Problem der Datenbank
                if (person.UserAccount != null)
                {
                    userAccountID = person.UserAccount.UserAccountID;
                }
                else
                {
                    userAccountID = UserSession.userAccountID;
                }

                Person.Update(personID, titleID, familyStateID, userAccountID, firstName,
                              lastName, zipCode, city, street, nationality, tableNo, phone,
                              mobileNo, comment, countryOfBirth, dateOfBirth, email, group,
                              validityStart, validityEnd, maritalBirthday, maritalFirstName,
                              maritalLastName, maritalNationality, lastPurchase, maritalCountryOfBirth,
                              maritalPhone, maritalMobile, maritalEmail, maritalTitleID);

                // Trage Buchung ein
                int    userAccountIDbooking = UserSession.userAccountID;
                string description          = IniParser.GetSetting("ACCOUNTING", "quickBookingDescription");

                Booking.Add(srcAccountID, targetAccountID, amount, person.PersonID, userAccountIDbooking, description);

                return(true);
            }
            catch
            {
                // Bei Fehler gebe Kundendetails aus
                string error = IniParser.GetSetting("ERRORMSG", "newQuickBookingError").Replace("{0}", person.FirstName + " " + person.LastName + " (" + person.TableNo + ")");
                MessageBoxEnhanced.Error(error);
                return(false);
            }
        }