예제 #1
0
        // Button 'Search' in the room section
        // Searches result in relevant tables from textinput
        private void buttonSearchBookingRoom_Click(object sender, EventArgs e)
        {
            string searchinput = @textBoxSearch.Text.Trim();

            // Fetch dataset
            DataSet roomreservationDS = DBGetData.GetRoomBookingDGVSearch(searchinput);

            if (roomreservationDS != null)
            {
                // No tables fetched
                if (roomreservationDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (roomreservationDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found for search.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewRoom.DataSource = roomreservationDS;
                dataGridViewRoom.DataMember = "Get_RR_Search";
                LoadDataGridViewRoom();
            }
        }
예제 #2
0
        private void buttonDisplayDue_Click(object sender, EventArgs e)
        {
            // Fetch dataset
            DataSet folioDS = DBGetData.GetFolioDGVDue();

            if (folioDS != null)
            {
                // No tables fetched
                if (folioDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (folioDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found in folio marked with due date.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewFolio.DataSource = folioDS;
                dataGridViewFolio.DataMember = "Get_Folio_Due";
                LoadDataGridViewFolio();
            }
        }
예제 #3
0
        // Button 'Edit'
        private void buttonEditFolio_Click(object sender, EventArgs e)
        {
            if (dataGridViewFolio.SelectedRows.Count > 0 && dataGridViewFolio.CurrentRow != null)
            {
                // Set database record ID for reference
                int folioid = Convert.ToInt32(this.dataGridViewFolio.CurrentRow.Cells[0].Value);
                DBGetData.QueryID = folioid;
                Boolean duedate = false;

                MySqlDataReader getFolioDueStatus = DBGetData.GetFolioDueDate(folioid);
                if (getFolioDueStatus.Read())
                {
                    duedate = true;
                }
                getFolioDueStatus.Dispose();
                if (duedate)
                {
                    new StatusMessage("Folio has existing due date, cant make changes.");
                }
                else
                {
                    Form editForm = new EditFolio();
                    editForm.ShowDialog();
                }
            }
        }
예제 #4
0
        // Load dataset to datagridview
        public void LoadDataRoom()
        {
            // Fetch dataset
            DataSet roomDS = DBGetData.GetFloorplanDGVRoom();

            if (roomDS != null)
            {
                // No tables fetched
                if (roomDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (roomDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found in room.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewFloorplanRoom.DataSource = roomDS;
                dataGridViewFloorplanRoom.DataMember = "Get_Floorplan_Room";
                LoadDataGridViewRoom();
            }
        }
예제 #5
0
        // 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.");
                    }
                }
            }
        }
예제 #6
0
        // Load dataset
        public void LoadDataGuest()
        {
            // Fetch dataset
            DataSet guestDS = DBGetData.GetGuestDGVAll();

            if (guestDS != null)
            {
                // No tables fetched
                if (guestDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (guestDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found for this month.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewGuest.DataSource = guestDS;
                dataGridViewGuest.DataMember = "Get_Guest_All";
                LoadDataGridViewGuest();
            }
        }
예제 #7
0
        // Load dataset to datagridview
        public void LoadDataPaymentItem()
        {
            // Fetch dataset
            DataSet paymentitemDS = DBGetData.GetPaymentItemDGVAll();

            if (paymentitemDS != null)
            {
                // No tables fetched
                if (paymentitemDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (paymentitemDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found in billing_item.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewPaymentItem.DataSource = paymentitemDS;
                dataGridViewPaymentItem.DataMember = "Get_PaymentItem_All";
                LoadDataGridViewPaymentItem();
            }
        }
예제 #8
0
        // Button 'All' in the hall section
        // Display all hall reservations
        private void buttonDisplayHallAll_Click(object sender, EventArgs e)
        {
            // Fetch dataset
            DataSet hallreservationDS = DBGetData.GetHallBookingsAll(1);

            if (hallreservationDS != null)
            {
                // No tables fetched
                if (hallreservationDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (hallreservationDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found in table.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewHall.DataSource = hallreservationDS;
                dataGridViewHall.DataMember = "Get_HR_All";
                LoadDataGridViewHall();
            }
        }
예제 #9
0
        // Button 'Save'
        // Validate input and insert into database
        private void buttonNewUserConfirm_Click(object sender, EventArgs e)
        {
            Boolean existingid = false;
            string  adminid    = textBoxUsername.Text;
            string  firstname  = textBoxFirstname.Text;
            string  lastname   = textBoxLastname.Text;
            string  password   = textBoxPassword.Text;
            int     superuser  = 0;

            if (checkBoxSuperuser.Checked)
            {
                superuser = 1;
            }

            // Check for null or empty input
            if (string.IsNullOrWhiteSpace(adminid))
            {
                MessageBox.Show("Username field is not filled in");
            }
            if (string.IsNullOrWhiteSpace(firstname))
            {
                MessageBox.Show("Firstname field is not filled in");
            }
            if (string.IsNullOrWhiteSpace(lastname))
            {
                MessageBox.Show("Lastname field is not filled in");
            }
            if (string.IsNullOrWhiteSpace(password))
            {
                MessageBox.Show("Password field is not filled in");
            }

            // Check if username is already taken
            if (DBGetData.GetLoginUsername(adminid) > 0)
            {
                existingid = true;
            }
            if (existingid)
            {
                MessageBox.Show("Username already exists, please choose a different one.");
            }

            // Execute save
            if (!existingid && !string.IsNullOrWhiteSpace(adminid) && !string.IsNullOrWhiteSpace(firstname) && !string.IsNullOrWhiteSpace(lastname) && !string.IsNullOrWhiteSpace(password))
            {
                // Generate new salt and hash password
                PasswordHasher pwHasher       = new PasswordHasher();
                HashResult     hashedPassword = pwHasher.HashNewSalt(password, 20, SHA512.Create());
                string         salt           = hashedPassword.Salt;
                string         passwordHash   = hashedPassword.Digest;

                DBSetData.UserAdd(adminid, firstname, lastname, passwordHash, salt, superuser);

                // Close form
                this.Close();
                userForm.LoadDataUser();
                userForm.Refresh();
                new StatusMessage("User with login " + adminid + " is added to the database.");
            }
        }
예제 #10
0
        // Load dataset to datagridview
        public void LoadDataTodo()
        {
            // Fetch dataset
            DataSet todoDS = DBGetData.GetTodoDGVActive();

            if (todoDS != null)
            {
                // No tables fetched
                if (todoDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (todoDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found in todo.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewTodo.DataSource = todoDS;
                dataGridViewTodo.DataMember = "Get_Todo_Active";
                LoadDataGridViewTodo();
            }
        }
예제 #11
0
        // Button 'Today' in the room section
        // Display room reservations for today
        private void buttonDisplayRoomDay_Click(object sender, EventArgs e)
        {
            // Find date for today
            DateTime today = DateTime.Today;

            // Fetch dataset
            DataSet roomreservationDS = DBGetData.GetRoomBookingDGVSpesificDate(today);

            if (roomreservationDS != null)
            {
                // No tables fetched
                if (roomreservationDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (roomreservationDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found for today.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewRoom.DataSource = roomreservationDS;
                dataGridViewRoom.DataMember = "Get_RR_SpesificDate";
                LoadDataGridViewRoom();
            }
        }
예제 #12
0
        // Button 'Week' in the room section
        // Display room reservation for this week
        private void buttonDisplayRoomWeek_Click(object sender, EventArgs e)
        {
            // Find this weeks start date and convert to readable format for MySQL
            DateTime datefrom = CalculateDate.GetFirstDayOfWeek(DateTime.Today);
            DateTime dateto   = datefrom.AddDays(7);

            // Fetch dataset
            DataSet roomreservationDS = DBGetData.GetRoomBookingDGVBetweenDates(datefrom, dateto);

            if (roomreservationDS != null)
            {
                // No tables fetched
                if (roomreservationDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (roomreservationDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found for this week.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewRoom.DataSource = roomreservationDS;
                dataGridViewRoom.DataMember = "Get_RR_BetweenDates";
                LoadDataGridViewRoom();
            }
        }
예제 #13
0
        // Button 'Search'
        // Search guest archive
        private void buttonSearchGuest_Click(object sender, EventArgs e)
        {
            string searchinput = @textBoxSearch.Text.Trim();

            // Fetch dataset
            DataSet guestListDS = DBGetData.GetGuestListSearch(searchinput);

            if (guestListDS != null)
            {
                // No tables fetched
                if (guestListDS.Tables.Count == 0)
                {
                    MessageBox.Show("No guest datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (guestListDS.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("No search result found in guest table.");
                    return;
                }

                // Set the dataset as source for listbox
                listBoxGuest.ValueMember   = "guestid";
                listBoxGuest.DisplayMember = "guest_name";
                listBoxGuest.DataSource    = guestListDS.Tables[0];
            }
        }
예제 #14
0
        private void buttonSearchHall_Click(object sender, EventArgs e)
        {
            string searchinput = @textBoxSearch.Text.Trim();

            // Fetch dataset
            DataSet hallDS = DBGetData.GetFloorplanDGVHallSearch(searchinput);

            if (hallDS != null)
            {
                // No tables fetched
                if (hallDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (hallDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found matching search.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewFloorplanHall.DataSource = hallDS;
                dataGridViewFloorplanHall.DataMember = "Get_Floorplan_HallSearch";
                LoadDataGridViewHall();
            }
        }
예제 #15
0
        // 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();
                }
            }
        }
예제 #16
0
        //
        // Room section
        //

        // Default room display (monthly)
        public void DisplayDefaultRoom()
        {
            // Find this weeks start date and convert to readable format for MySQL
            DateTime today    = DateTime.Today;
            DateTime datefrom = new DateTime(today.Year, today.Month, 1);
            DateTime dateto   = datefrom.AddMonths(1).AddDays(-1);
            // Fetch dataset
            DataSet roomreservationDS = DBGetData.GetRoomBookingDGVBetweenDates(datefrom, dateto);

            if (roomreservationDS != null)
            {
                // No tables fetched
                if (roomreservationDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (roomreservationDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found for this month.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewRoom.DataSource = roomreservationDS;
                dataGridViewRoom.DataMember = "Get_RR_BetweenDates";
                LoadDataGridViewRoom();
            }
        }
예제 #17
0
        // Button 'Save'
        private void buttonNewGuestConfirm_Click(object sender, EventArgs e)
        {
            Boolean roomexists = false;
            Boolean roomvalid  = false;
            int     roomid;
            int     roomtypeid = Convert.ToInt32(comboBoxRoomType.SelectedValue);

            // Check if the point entered is numeric
            if (Int32.TryParse(textBoxRoomid.Text, out roomid))
            {
                roomvalid = true;

                if (DBGetData.GetFloorplanRoomExists(roomid) > 0)
                {
                    roomexists = true;
                    MessageBox.Show("Room number already exists, select a different number.");
                }
            }
            else
            {
                MessageBox.Show("Only numbers (0-9) are allowed in the room number.");
            }

            // Execute save
            if (!roomexists && roomvalid)
            {
                DBSetData.FloorplanRoomAdd(roomid, roomtypeid);
                // Close form
                this.Close();
                floorplanForm.LoadDataRoom();
                floorplanForm.Refresh();
                new StatusMessage("Room with number " + roomid + " is added to the database.");
            }
        }
예제 #18
0
        // Loading data from database into comboBoxRoomType
        private void LoadDataFloorplanRoom()
        {
            // Fetch dataset
            DataSet roomtypeListDS = DBGetData.GetRoomtypeList();

            if (roomtypeListDS != null)
            {
                // No tables fetched
                if (roomtypeListDS.Tables.Count == 0)
                {
                    MessageBox.Show("No roomtype datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (roomtypeListDS.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("No datarows found in roomtype table.");
                    return;
                }

                // Set the dataset as source for combobox
                comboBoxRoomType.ValueMember   = "room_typeid";
                comboBoxRoomType.DisplayMember = "name";
                comboBoxRoomType.DataSource    = roomtypeListDS.Tables[0];
            }
        }
예제 #19
0
        // Fetches a valid users stored salt and makes a hash with the salt and password input
        // Checks database for username/password combination match
        private void CheckLogin()
        {
            string uid = textBoxUsername.Text;
            string upw = textBoxPassword.Text;

            // Check for input
            if (!string.IsNullOrWhiteSpace(uid) && !string.IsNullOrWhiteSpace(upw))
            {
                Boolean validLogin = false;
                string  salt;
                int     su;

                // Fetch salt and superuser status for user
                MySqlDataReader getValues = DBGetData.GetLoginData(uid);
                if (getValues.Read())
                {
                    salt = getValues.GetString(0);
                    su   = getValues.GetInt32(1);

                    // Hash password with salt
                    PasswordHasher pwHasher       = new PasswordHasher();
                    HashResult     hashedPassword = pwHasher.HashStoredSalt(upw, salt, SHA512.Create());

                    if (DBGetData.GetLoginMatch(uid, hashedPassword.Digest) == 1)
                    {
                        validLogin = true;
                    }

                    // Check for login match
                    if (validLogin)
                    {
                        // Save user information in static variables through the UserInfo class
                        UserInfo.AdminID   = uid;
                        UserInfo.SuperUser = su;

                        // Open main program and hide login screen
                        UserInterface UIForm = new UserInterface();
                        UIForm.Show();
                        this.Hide();
                    }
                }

                // No login match
                else
                {
                    this.labelStatus.Text = "Username or password incorrect, try again.";
                }

                getValues.Dispose();
            }
            // No textfield input
            else
            {
                this.labelStatus.Text = "Username or password field empty, try again.";
            }
        }
예제 #20
0
        // Load data from guest and billing_item tables into listboxes
        private void LoadDataFolio()
        {
            // Fetch dataset for guestlist
            DataSet guestListDS = DBGetData.GetGuestList();

            if (guestListDS != null)
            {
                // No tables fetched
                if (guestListDS.Tables.Count == 0)
                {
                    MessageBox.Show("No guest datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (guestListDS.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("No datarows found in guest table.");
                    return;
                }

                // Set the dataset as source for listbox
                listBoxGuest.ValueMember   = "guestid";
                listBoxGuest.DisplayMember = "guest_name";
                listBoxGuest.DataSource    = guestListDS.Tables[0];
            }

            // Fetch dataset for billingitems
            DataSet billingitemListDS = DBGetData.GetBillingItemList();

            if (billingitemListDS != null)
            {
                // No tables fetched
                if (billingitemListDS.Tables.Count == 0)
                {
                    MessageBox.Show("No billing_item datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (billingitemListDS.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("No datarows found in billing_item table.");
                    return;
                }

                // Set the dataset as source for listbox
                listBoxBillingItem.ValueMember   = "billing_itemid";
                listBoxBillingItem.DisplayMember = "billing_itemname";
                listBoxBillingItem.DataSource    = billingitemListDS.Tables[0];
            }

            // Set value and display member for listBoxFolioItem
            listBoxFolioItem.ValueMember   = "billing_itemid";
            listBoxFolioItem.DisplayMember = "billing_itemname";
        }
예제 #21
0
        // Button 'Save'
        // Validate input and insert into database
        private void buttonNewFolioConfirm_Click(object sender, EventArgs e)
        {
            Boolean folioexists = false;

            // Validate that guest is selcted and folio has items
            if (listBoxGuest.SelectedIndex > -1 && listBoxFolioItem.Items.Count > 0)
            {
                // Reference variables
                int    guestid = Convert.ToInt32(listBoxGuest.SelectedValue);
                string adminid = UserInfo.AdminID;

                // Check -> Folio does not exist
                if (DBGetData.GetFolioExists(guestid) > 0)
                {
                    folioexists = true;
                }
                if (folioexists)
                {
                    MessageBox.Show("Guest already has an active folio, add any changes to existing.");
                }

                if (!folioexists)
                {
                    // Create new folio
                    DBSetData.FolioAdd(guestid, adminid);
                    // Fetch newly created folioid
                    MySqlDataReader getFolioid = DBGetData.GetFolioid(guestid);
                    if (getFolioid.Read())
                    {
                        // Add folio items to folio
                        int folioid = getFolioid.GetInt32(0);

                        foreach (DataRowView drv in listBoxFolioItem.Items)
                        {
                            int billingitemid = int.Parse(drv.Row[listBoxFolioItem.ValueMember].ToString());
                            DBSetData.FolioItemAdd(folioid, billingitemid, adminid);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Could not fetch newly created folioid, try again or contact administrator.");
                    }
                    getFolioid.Dispose();

                    // Refresh datagridview, close form and display new StatusMessage
                    folioForm.LoadDataFolio();
                    folioForm.Refresh();
                    this.Close();
                    new StatusMessage("Folio with " + listBoxFolioItem.Items.Count + " items added.");
                }
            }
        }
예제 #22
0
        // Button 'Save'
        // Validate input and insert into database
        private void buttonEditFolioConfirm_Click(object sender, EventArgs e)
        {
            // Validate that guest is selcted and folio has items
            if (listBoxGuest.SelectedIndex > -1 && listBoxFolioItem.Items.Count > 0)
            {
                // Reference variables
                Boolean guestchanged = false;
                Boolean guestconfirm = true;
                int     guestid      = Convert.ToInt32(listBoxGuest.SelectedValue);
                string  adminid      = UserInfo.AdminID;

                // Check if guestid has changed
                MySqlDataReader getFolioGuest = DBGetData.GetFolioGuest(folioid, guestid);
                if (getFolioGuest.Read())
                {
                    guestchanged = true;
                }
                getFolioGuest.Dispose();

                // Give warning if guest has changed and ask for confirmation
                if (!guestchanged)
                {
                    DialogResult guestDifferent = MessageBox.Show("You have changed the guest for this folio" +
                                                                  "\nAre you sure you want to continue?", "Warning!", MessageBoxButtons.YesNo);
                    if (guestDifferent == DialogResult.No)
                    {
                        // Cancel edit and reload data
                        guestconfirm = false;
                        LoadDataFolio();
                    }
                }

                if (guestconfirm)
                {
                    // Add new folio items to folio
                    foreach (DataRowView drv in listBoxFolioItem.Items)
                    {
                        int billingitemid = int.Parse(drv.Row[listBoxFolioItem.ValueMember].ToString());
                        DBSetData.FolioItemAdd(folioid, billingitemid, adminid);
                    }

                    // Refresh datagridview, close form and display new StatusMessage
                    folioForm.LoadDataFolio();
                    folioForm.Refresh();
                    this.Close();
                    new StatusMessage("Folio populated with " + listBoxFolioItem.Items.Count + " additional items.");
                }
            }
        }
예제 #23
0
        // Button 'Find room'
        // Display available rooms for selected date
        private void buttonSearchRoomBookingAvailable_Click(object sender, EventArgs e)
        {
            if (listBoxGuest.SelectedIndex > -1 && comboBoxRoomType.SelectedIndex > -1)
            {
                int    roomtypeid = Convert.ToInt32(comboBoxRoomType.SelectedValue);
                string datefrom   = datePickerArrival.Value.ToString("yyyy-MM-dd");
                string dateto     = datePickerDeparture.Value.ToString("yyyy-MM-dd");

                // Clear flowlayoutpanel and set parameter to enable drag and drop
                flowLayoutPanel1.Controls.Clear();
                roomchecked = false;
                roomid      = null;

                ValidateInput();
                // Check all relevant fields for input
                if (validinput)
                {
                    // Check available rooms
                    MySqlDataReader getAvailableRooms = DBGetData.GetAvailableRooms(roomtypeid, datefrom, dateto);

                    while (getAvailableRooms.Read())
                    {
                        // Generate panels to indicate available rooms
                        // Create event handlers for click and drag and drop with values from listBoxGuest
                        Panel p = new Panel();
                        p.Name      = getAvailableRooms["roomid"].ToString();
                        p.Size      = new Size(79, 35);
                        p.BackColor = Color.Yellow;
                        p.AllowDrop = true;
                        // Setup event handlers for DragOver, DragDrop and Click
                        p.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelRoom_DragDrop);
                        p.DragOver += new System.Windows.Forms.DragEventHandler(this.panelRoom_DragOver);
                        p.Click    += new EventHandler(this.panelRoom_Click);
                        this.flowLayoutPanel1.Controls.Add(p);
                        // Draw room number on panel
                        Font drawFont = new Font("Tahoma", 12);
                        p.Paint += (ss, ee) =>
                        {
                            ee.Graphics.DrawString(p.Name, drawFont, Brushes.Black, 20, 8);
                        };
                    }

                    getAvailableRooms.Dispose();
                }
            }
        }
예제 #24
0
        private void LoadDataGuest()
        {
            // Insert existing values
            MySqlDataReader getValues = DBGetData.GetGuestData(guestid);

            if (getValues.Read())
            {
                textBoxFirstname.Text = Convert.ToString(getValues[0]);
                textBoxLastname.Text  = Convert.ToString(getValues[1]);
                textBoxAddress.Text   = Convert.ToString(getValues[2]);
                textBoxCity.Text      = Convert.ToString(getValues[3]);
                textBoxPostcode.Text  = Convert.ToString(getValues[4]);
                textBoxTelephone.Text = Convert.ToString(getValues[5]);
            }

            getValues.Dispose();
        }
예제 #25
0
        // Loading data from database into comboBoxRoomType
        private void LoadDataRoom()
        {
            // Fetch dataset
            DataSet roomtypeListDS = DBGetData.GetRoomtypeList();

            if (roomtypeListDS != null)
            {
                // No tables fetched
                if (roomtypeListDS.Tables.Count == 0)
                {
                    MessageBox.Show("No roomtype datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (roomtypeListDS.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("No datarows found in roomtype table.");
                    return;
                }

                // Set the dataset as source for combobox
                comboBoxRoomType.ValueMember   = "room_typeid";
                comboBoxRoomType.DisplayMember = "name";
                comboBoxRoomType.DataSource    = roomtypeListDS.Tables[0];
            }

            // Highlight existing values
            textBoxRoomid.Text = roomid.ToString();

            MySqlDataReader getValues = DBGetData.GetFloorplanRoomData(roomid);

            if (getValues.Read())
            {
                comboBoxRoomType.SelectedValue = getValues.GetInt32(0);
            }

            getValues.Dispose();
        }
예제 #26
0
        // Button 'Save'
        private void buttonNewHallConfirm_Click(object sender, EventArgs e)
        {
            Boolean hallexists = false;
            string  hallname   = textBoxHallname.Text;

            if (DBGetData.GetFloorplanHallExists(hallname) > 0)
            {
                hallexists = true;
                MessageBox.Show("Hall name already exists, select a different name.");
            }

            // Execute save
            if (!hallexists && !string.IsNullOrWhiteSpace(hallname) && comboBoxHallType.SelectedIndex > -1)
            {
                int halltypeid = Convert.ToInt32(comboBoxHallType.SelectedValue);
                DBSetData.FloorplanHallAdd(hallname, halltypeid);
                // Close form
                this.Close();
                floorplanForm.LoadDataHall();
                floorplanForm.Refresh();
                new StatusMessage("Hall with name " + hallname + " is added to the database.");
            }
        }
예제 #27
0
        // Loading data from database into comboBoxRoomType
        private void LoadDataHall()
        {
            // Fetch dataset
            DataSet halltypeListDS = DBGetData.GetHalltypeList();

            if (halltypeListDS != null)
            {
                // No tables fetched
                if (halltypeListDS.Tables.Count == 0)
                {
                    MessageBox.Show("No halltype datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (halltypeListDS.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("No datarows found in halltype table.");
                    return;
                }

                // Set the dataset as source for combobox
                comboBoxHallType.ValueMember   = "hall_typeid";
                comboBoxHallType.DisplayMember = "name";
                comboBoxHallType.DataSource    = halltypeListDS.Tables[0];
            }

            // Highlight existing values
            MySqlDataReader getValues = DBGetData.GetFloorplanHallData(hallid);

            if (getValues.Read())
            {
                textBoxHallname.Text           = getValues.GetString(0);
                comboBoxHallType.SelectedValue = getValues.GetInt32(1);
            }

            getValues.Dispose();
        }
예제 #28
0
        private void LoadDataUser()
        {
            // Insert existing values
            MySqlDataReader getValues = DBGetData.GetUserData(adminid);

            if (getValues.Read())
            {
                textBoxUsername.Text  = Convert.ToString(getValues[0]);
                textBoxFirstname.Text = Convert.ToString(getValues[1]);
                textBoxLastname.Text  = Convert.ToString(getValues[2]);
                int superuser = Convert.ToInt32(getValues[3]);
                int active    = Convert.ToInt32(getValues[4]);
                if (superuser == 1)
                {
                    checkBoxSuperuser.Checked = true;
                }
                if (active == 1)
                {
                    checkBoxActive.Checked = true;
                }
            }

            getValues.Dispose();
        }
예제 #29
0
        // 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();
                        }
                    }
                }
            }
        }
예제 #30
0
        // 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.");
                    }
                }
            }
        }