コード例 #1
0
ファイル: Booking.cs プロジェクト: mariusnorheim/app2000v
        // Button 'Edit' in the room section
        // Open specialized edit form, identical to DataGridViewRoom double click
        private void buttonEditBookingRoom_Click(object sender, EventArgs e)
        {
            Boolean checkedin = false;

            if (dataGridViewRoom.SelectedRows.Count > 0 && dataGridViewRoom.CurrentRow != null)
            {
                int reservationid = Convert.ToInt32(dataGridViewRoom.CurrentRow.Cells[0].Value);

                if (DBGetData.GetRoomCheckedin(reservationid) > 0)
                {
                    checkedin = true;
                }
                if (checkedin)
                {
                    new StatusMessage("Room reservation has already checked in and cant be changed.");
                }
                else
                {
                    // Set database record ID for reference
                    DBGetData.QueryID = reservationid;
                    Form editForm = new EditBookingRoom();
                    editForm.ShowDialog();
                }
            }
        }
コード例 #2
0
ファイル: Booking.cs プロジェクト: mariusnorheim/app2000v
        // Button 'Delete' in the room section
        // Remove isactive flag on selected record
        private void buttonDeleteBookingRoom_Click(object sender, EventArgs e)
        {
            Boolean checkedin = false;

            if (dataGridViewRoom.SelectedRows.Count > 0 && dataGridViewRoom.CurrentRow != null)
            {
                int reservationid = Convert.ToInt32(dataGridViewRoom.CurrentRow.Cells[0].Value);
                int roomid        = Convert.ToInt32(dataGridViewRoom.CurrentRow.Cells[3].Value);

                // Confirm delete
                DialogResult confirmDelete = MessageBox.Show("Deleting room reservation for room " + roomid +
                                                             "\nAre you sure you want to continue?", "Warning!", MessageBoxButtons.YesNo);

                if (confirmDelete == DialogResult.Yes)
                {
                    if (DBGetData.GetRoomCheckedin(reservationid) > 0)
                    {
                        checkedin = true;
                    }
                    if (checkedin)
                    {
                        new StatusMessage("Room reservation has already checked in and cant be deleted.");
                    }
                    else
                    {
                        // Save entry to database
                        DBSetData.RoomreservationDelete(reservationid);
                        DisplayDefaultRoom();
                        this.Refresh();
                        new StatusMessage("Room reservation removed from active list.");
                    }
                }
            }
        }
コード例 #3
0
ファイル: Booking.cs プロジェクト: mariusnorheim/app2000v
        // Button 'Check out' in the room section
        // Validation: Room is marked as checked in > Date for checkout is today -> Guest has active messages
        // Checkout procedure: Potential reimbursement -> Payment process ->
        // Mark folio with paid or due date -> Mark room for housekeeping -> Mark room reservation as checked out and inactive
        private void buttonCheckoutRoom_Click(object sender, EventArgs e)
        {
            // Make sure datagridview has selection
            if (dataGridViewRoom.SelectedRows.Count > 0 && dataGridViewRoom.CurrentRow != null)
            {
                // Validation variables
                Boolean checkedout   = false;
                Boolean checkoutdate = true;
                Boolean message      = false;
                // Reference variables
                int roomid        = Convert.ToInt32(dataGridViewRoom.CurrentRow.Cells[3].Value);
                int reservationid = Convert.ToInt32(dataGridViewRoom.CurrentRow.Cells[0].Value);

                // Confirm checkout
                DialogResult confirmCheckout = MessageBox.Show("Checking out roomnumber " + roomid +
                                                               "\nAre you sure you want to continue?", "Check out", MessageBoxButtons.YesNo);
                if (confirmCheckout == DialogResult.Yes)
                {
                    // Check that reservation checkout date is today
                    MySqlDataReader getRoomCheckoutDate = DBGetData.GetRoomCheckoutDate(reservationid);
                    if (getRoomCheckoutDate.Read())
                    {
                        DateTime date = Convert.ToDateTime(getRoomCheckoutDate[0]);
                        if (date != DateTime.Today)
                        {
                            checkoutdate = false;
                        }
                        if (!checkoutdate)
                        {
                            new StatusMessage("Room reservation not marked for checkout today.");
                        }
                    }
                    getRoomCheckoutDate.Dispose();

                    // Yes/no continue dialogue if checkout is early
                    if (!checkoutdate)
                    {
                        DialogResult continueCheckout = MessageBox.Show(
                            "Room is not flagged for checkout today" +
                            "\nAre you sure you want to continue?", "Warning!", MessageBoxButtons.YesNo);
                        if (continueCheckout == DialogResult.Yes)
                        {
                            checkoutdate = true;
                        }
                    }

                    // Check that reservation is checked in
                    if (DBGetData.GetRoomCheckedin(reservationid) < 1)
                    {
                        checkedout = true;
                    }
                    if (checkedout)
                    {
                        new StatusMessage("Room reservation has not checked in or already checked out.");
                    }

                    if (!checkedout && checkoutdate)
                    {
                        // Check if guest has undelivered messages
                        MySqlDataReader getRoomMessages = DBGetData.GetRoomMessages(reservationid);
                        while (getRoomMessages.Read())
                        {
                            message = true;
                            MessageBox.Show("Date recieved: " + getRoomMessages.GetDateTime(0) +
                                            "\nFrom: " + getRoomMessages.GetString(1) +
                                            "\n\n" + getRoomMessages.GetString(2),
                                            "Message to guest");
                        }

                        getRoomMessages.Dispose();

                        // Mark messages as inactive if any
                        if (message)
                        {
                            DBSetData.RoomreservationUpdateMessages(reservationid);
                        }

                        // Check if guest has more than one room reservation checked in
                        int roomcount = DBGetData.GetRoomCount(reservationid);

                        // Do checkout process
                        DBSetData.RoomreservationCheckout(reservationid);
                        DisplayDefaultRoom();
                        this.Refresh();
                        new StatusMessage("Room reservation for room " + roomid + " has been flagged for housekeeping and checked out.");

                        // Print customer folio total for the last room checkout
                        if (roomcount == 1)
                        {
                            MySqlDataReader getFolioTotal = DBGetData.GetRoomCheckoutTotal(reservationid);
                            if (getFolioTotal.Read())
                            {
                                Decimal foliototal = getFolioTotal.GetDecimal(0);

                                // Payment options
                                // Yes -> Cash/card, No -> Invoice bill
                                DialogResult paymentCheckout = MessageBox.Show("Payment total: " + foliototal +
                                                                               "\n\n'Yes' for immidiate payment with cash or creditcard," +
                                                                               "\n'No' for invoice with due date 3 weeks from today.",
                                                                               "Payment options", MessageBoxButtons.YesNo);

                                // Mark folio as paid
                                if (paymentCheckout == DialogResult.Yes)
                                {
                                    DBSetData.RoomreservationFolioPaid(reservationid);
                                }
                                // Mark folio with duedate
                                else if (paymentCheckout == DialogResult.No)
                                {
                                    DBSetData.RoomreservationFolioDue(reservationid);
                                }
                            }

                            getFolioTotal.Dispose();
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: Booking.cs プロジェクト: mariusnorheim/app2000v
        // Button 'Check in' in the room section
        // Validation: Room is not marked as checked in already -> Date for checkin is today -> Room is clean
        // Checkin procedure: Create new folio or append existing -> Add folio items for room charge -> Mark room as checked in
        private void buttonCheckinRoom_Click(object sender, EventArgs e)
        {
            // Make sure datagridview has selection
            if (dataGridViewRoom.SelectedRows.Count > 0 && dataGridViewRoom.CurrentRow != null)
            {
                // Validation variables
                Boolean checkedin   = false;
                Boolean checkindate = true;
                Boolean roomcleared = true;
                // Roomstatus values: 0 = deny checkin, 1 = warning, 2 = no flag
                int roomstatus = 2;
                // Reference variables
                string adminid       = UserInfo.AdminID;
                int    reservationid = Convert.ToInt32(dataGridViewRoom.CurrentRow.Cells[0].Value);
                int    roomid        = Convert.ToInt32(dataGridViewRoom.CurrentRow.Cells[3].Value);

                // Confirm checkin
                DialogResult confirmCheckin = MessageBox.Show("Checking in roomnumber " + roomid +
                                                              "\nAre you sure you want to continue?", "Check in", MessageBoxButtons.YesNo);
                if (confirmCheckin == DialogResult.Yes)
                {
                    // Check that reservation checkin date is today
                    MySqlDataReader getRoomCheckinDate = DBGetData.GetRoomCheckinDate(reservationid);
                    if (getRoomCheckinDate.Read())
                    {
                        DateTime date = Convert.ToDateTime(getRoomCheckinDate[0]);
                        if (date != DateTime.Today)
                        {
                            checkindate = false;
                        }
                        if (!checkindate)
                        {
                            new StatusMessage("Room reservation not marked for checkin today.");
                        }
                    }
                    getRoomCheckinDate.Dispose();

                    // Check that reservation is not already checked in
                    if (DBGetData.GetRoomCheckedin(reservationid) > 0)
                    {
                        checkedin = true;
                    }
                    if (checkedin)
                    {
                        new StatusMessage("Room reservation has already checked in.");
                    }

                    // Check if room is clean
                    MySqlDataReader getHousekeepingCode = DBGetData.GetRoomHousekeeping(roomid);
                    if (getHousekeepingCode.Read())
                    {
                        int code = Convert.ToInt32(getHousekeepingCode[0]);
                        switch (code)
                        {
                        case 0:
                            roomstatus = 0;
                            new StatusMessage("Room unavailable due to maintainance, " +
                                              "please change reservation or upgrade guest.");
                            break;

                        case 1:
                            roomstatus = 1;
                            new StatusMessage("Room needs inspection, " +
                                              "please change reservation or send staff immediately.");
                            break;

                        case 2:
                            roomstatus = 1;
                            new StatusMessage("Room needs cleaning, " +
                                              "please change reservation or send staff immediately.");
                            break;
                        }
                    }
                    getHousekeepingCode.Dispose();

                    // Check if room is cleared for checkin
                    switch (roomstatus)
                    {
                    // Deny checkin of a room that is flagged as inactive
                    case 0:
                        roomcleared = false;
                        break;

                    // Option to continue if room has a warning code and other arrangements cant be made
                    case 1:
                        DialogResult continueCheckin = MessageBox.Show(
                            "Room is flagged for cleaning or inspection" +
                            "\nAre you sure you want to continue?", "Warning!", MessageBoxButtons.YesNo);
                        if (continueCheckin == DialogResult.Yes)
                        {
                            roomcleared = true;
                        }
                        else if (continueCheckin == DialogResult.No)
                        {
                            roomcleared = false;
                        }

                        break;

                    // No code on room
                    case 2:
                        roomcleared = true;
                        break;
                    }

                    // Proceed with checkin
                    if (!checkedin && checkindate && roomcleared)
                    {
                        DBSetData.RoomreservationCheckin(reservationid, adminid);
                        DisplayDefaultRoom();
                        this.Refresh();
                        new StatusMessage("Room reservation for room " + roomid + " has been flagged as checked in and folio was added.");
                    }
                }
            }
        }
コード例 #5
0
        // Button 'Lagre'
        // Validate input and update database record
        private void buttonEditBookingConfirm_Click(object sender, EventArgs e)
        {
            // Validation variables
            Boolean checkedin    = false;
            Boolean guestchanged = false;
            Boolean guestconfirm = true;

            // Display error messages if value is not selected
            if (listBoxGuest.SelectedIndex == -1)
            {
                MessageBox.Show("Select a guest before saving entry");
            }
            if (!roomchecked || roomid == null)
            {
                MessageBox.Show("Select a room before saving entry");
            }

            // Make sure guest and room is selected and reservationid set
            if (listBoxGuest.SelectedIndex > -1 && roomchecked && roomid != null && reservationid > 0)
            {
                //Reference variables
                string datefrom = datePickerArrival.Value.ToString("yyyy-MM-dd");
                string dateto   = datePickerDeparture.Value.ToString("yyyy-MM-dd");
                int    guestid  = Convert.ToInt32(listBoxGuest.SelectedValue);
                string remark;
                if (string.IsNullOrWhiteSpace(textBoxRemark.Text))
                {
                    remark = null;
                }
                else
                {
                    remark = textBoxRemark.Text;
                }

                ValidateInput();
                // Check all relevant fields for input
                if (validinput)
                {
                    // Check if reservation is checked in
                    if (DBGetData.GetRoomCheckedin(reservationid) > 0)
                    {
                        checkedin = true;
                    }
                    if (checkedin)
                    {
                        new StatusMessage("Room reservation has already checked in.");
                    }

                    // Check if guestid has changed
                    MySqlDataReader getReservationGuest = DBGetData.GetRoomreservationGuest(reservationid, guestid);
                    if (getReservationGuest.Read())
                    {
                        guestchanged = true;
                    }
                    getReservationGuest.Dispose();

                    // Give warning if guest has changed and ask for confirmation
                    if (!guestchanged)
                    {
                        DialogResult guestDifferent = MessageBox.Show("You have changed the guest for this reservation" +
                                                                      "\nAre you sure you want to continue?", "Warning!", MessageBoxButtons.YesNo);
                        if (guestDifferent == DialogResult.No)
                        {
                            // Cancel edit and reload data
                            guestconfirm = false;
                            LoadDataBooking();
                            // Clear flowlayoutpanel and set parameter to enable drag and drop
                            flowLayoutPanel1.Controls.Clear();
                            roomchecked = false;
                        }
                    }

                    if (!checkedin && guestconfirm)
                    {
                        DBSetData.RoomreservationEdit(reservationid, guestid, roomid, datefrom, dateto, remark);
                        // Refresh datagridview, close form and display new StatusMessage
                        bookingForm.DisplayDefaultRoom();
                        bookingForm.Refresh();
                        this.Close();
                        new StatusMessage("Reservation for roomnumber " + roomid + " saved in database and previous roomnumber released.");
                    }
                }
            }
        }