Exemplo n.º 1
0
        /// <summary>
        /// Add method two which requires every information individually
        /// </summary>
        public bool Add(string[] name, string[] lastname, DateTime checkindate, DateTime Checkoutdate, RoomType roomtype, int money, int capacity)
        {
            bool ok    = true;
            int  index = FindVacantPosition();

            if (index >= 0)
            {
                roomdetail roomdetailobject = new roomdetail(name.Length);
                roomdetailobject.Name         = name;
                roomdetailobject.Lastname     = lastname;
                roomdetailobject.Checkindate  = checkindate;
                roomdetailobject.Checkoutdate = Checkoutdate;
                roomdetailobject.Roomtype     = roomtype;
                roomdetailobject.Money        = money;
                roomdetailobject.Capacity     = capacity;

                roomlist[index] = roomdetailobject;
            }
            else
            {
                ok = false;
            }


            return(ok);
        }
Exemplo n.º 2
0
        /// <summary>
        /// checks if the room is empty or not. if it is empty then deletes it. then in the end currroomdetail will be an empty object to be filled again.
        /// </summary>
        private void deleteroombutton_Click(object sender, EventArgs e)
        {
            if (allroomslistbox.SelectedIndex == -1)
            {
                MessageBox.Show("Error. You shouldnt be able to press this button when there is a choice you made from the listbox below."); return;
            }
            if (allroomslistbox.SelectedIndex != -1)
            {
                if (roomMngr.GetroomdetailAt(allroomslistbox.SelectedIndex).CurrentNumOfCostumers() == 0)
                {
                    roomMngr.DeleteElement(allroomslistbox.SelectedIndex);
                    allroomslistbox.Items.RemoveAt(allroomslistbox.SelectedIndex);
                }
                else
                {
                    MessageBox.Show("You cannot delete a room when there is/are " + roomMngr.GetroomdetailAt(allroomslistbox.SelectedIndex).CurrentNumOfCostumers().ToString() + "costumer(s) inside! Cancel reservation or delete costumers first.");
                }
            }
            else
            {
                MessageBox.Show("You cannot delete a room without selecting it from the list!");
            }

            currRoomdetail = new roomdetail(maxnumberofpeopleinoneroom); //after deleting a recipe i will use this line to delete everything else about that recipe.
            UpdateGUI();                                                 //then update in the end
        }
 roomdetail m_roomdetail;                         //one room object
 public RoomDetailForm(roomdetail roomdetailmain) //form object that comes with one roomobject from the mainform with roomtype information only. so that I will fill the rest here
 {
     InitializeComponent();
     m_roomdetail = roomdetailmain;                                                                   //taking input room to code.
     InitializeGUI();                                                                                 //initialize things
     this.Text = roomdetailmain.Roomtype.ToString().Replace("_", " ") + " Costumer Edit Form";        //putting form title!
     roompicturepicturebox.Size  = new System.Drawing.Size(256, 256);                                 //arranging picturebox to be square
     roompicturepicturebox.Image = imagelistforrooms.Images[roomdetailmain.Picturenumber];            //adding the picture for this roomtype which i use the picturenumber property from roomdetail file
     roomtypelabel.Text          = roomdetailmain.Roomtype.ToString().Replace("_", " ") + " Picture"; //adding roomtype text on the picture
 }
Exemplo n.º 4
0
 /// <summary>
 /// AddRoom button creates a new room object with empty name lastname list and adds it to the manager.
 /// </summary>
 private void addnewroombutton_Click(object sender, EventArgs e)
 {
     if (allroomslistbox.SelectedIndex != -1)
     {
         MessageBox.Show("You choose a room from the list then pressed add a room button. You cannot do that. Please unselect your choice then try again."); return;
     }
     currRoomdetail          = new roomdetail(maxnumberofpeopleinoneroom);
     currRoomdetail.Roomtype = (RoomType)roomtypecombobox.SelectedIndex;
     currRoomdetail.Capacity = currRoomdetail.GetCapacity((RoomType)roomtypecombobox.SelectedIndex);
     roomMngr.Add(currRoomdetail.Name, currRoomdetail.Lastname, currRoomdetail.Checkindate, currRoomdetail.Checkoutdate, currRoomdetail.Roomtype, currRoomdetail.Money, currRoomdetail.Capacity);
     UpdateGUI();
 }
Exemplo n.º 5
0
        /// <summary>
        /// when you choose a room from allroomslistbox it will put its information into form. then tries to find it from list2 is found selects it. if not keeps it empty.
        /// </summary>
        private void allroomslistbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (allroomslistbox.SelectedIndex >= 0)
            {
                if (roomMngr.GetroomdetailAt(allroomslistbox.SelectedIndex) != null)
                {
                    currRoomdetail = roomMngr.GetroomdetailAt(allroomslistbox.SelectedIndex);
                    roomtypecombobox.SelectedIndex = (int)currRoomdetail.Roomtype;
                }


                int test = qualifiedroomslistbox.FindString(allroomslistbox.SelectedItem.ToString(), -1);
                if (test >= 0)
                {
                    qualifiedroomslistbox.SelectedIndex = test;
                }
                else
                {
                    qualifiedroomslistbox.SelectedIndex = -1;
                }
            }


            //this part is for buttons enable disable options. I do not want the user to be able to click addroom when some room is chosen or delete when nothing is chosen.
            if (allroomslistbox.SelectedIndex == -1)
            {
                reserveroombutton.Enabled       = false;
                cancelreservationbutton.Enabled = false;
                if (roomtypecombobox.SelectedIndex != -1)
                {
                    changeroomtypebutton.Enabled = false;
                    deleteroombutton.Enabled     = false;
                }
            }
            else
            {
                changeroomtypebutton.Enabled = true;
                deleteroombutton.Enabled     = true;

                reserveroombutton.Enabled = true;

                if (currRoomdetail.CurrentNumOfCostumers() != 0)
                {
                    reserveroombutton.Text = "Edit Room"; cancelreservationbutton.Enabled = true;
                }
                else
                {
                    reserveroombutton.Text = "Reserve Room"; cancelreservationbutton.Enabled = false;
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Change method which will change index. element to newroomdetail
        /// </summary>
        public bool ChangeElement(int index, roomdetail newroomdetail)
        {
            bool check = true;

            if (CheckIndex(index))
            {
                roomlist[index] = newroomdetail;
            }
            else
            {
                check = false;
            }
            return(check);
        }
Exemplo n.º 7
0
        /// <summary>
        /// if there are people in the selected room. cancels reservation by deleting everyone from that list. and refreshes checkinoutdates. if there are noone gives error.
        /// </summary>
        private void cancelreservationbutton_Click(object sender, EventArgs e)
        {
            if (allroomslistbox.SelectedIndex == -1)
            {
                MessageBox.Show("You did not choose a valid room to cancel.Error"); return;
            }

            currRoomdetail = new roomdetail(currRoomdetail.GetCapacity((RoomType)roomtypecombobox.SelectedIndex));
            currRoomdetail = roomMngr.GetroomdetailAt(allroomslistbox.SelectedIndex);
            currRoomdetail.DefaultValues();
            currRoomdetail.Roomtype = (RoomType)roomtypecombobox.SelectedIndex;
            currRoomdetail.Capacity = currRoomdetail.GetCapacity((RoomType)roomtypecombobox.SelectedIndex);
            UpdateGUI();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Add method one which takes only the roomdetail to add
        /// </summary>
        public bool Add(roomdetail newroomdetail)
        {
            bool ok    = true;
            int  index = FindVacantPosition();

            if (index >= 0)
            {
                roomlist[index] = newroomdetail;
            }
            else
            {
                ok = false;
            }
            return(ok);
        }
Exemplo n.º 9
0
        /// <summary>
        /// You can change a rooms type to a bigger room. but not to a smaller one. because it might cause problems
        /// </summary>
        private void changeroomtypebutton_Click(object sender, EventArgs e)
        {
            if (allroomslistbox.SelectedIndex == -1)
            {
                MessageBox.Show("Error. You cannot do this while an item is selected from listbox."); return;
            }
            currRoomdetail = roomMngr.GetroomdetailAt(allroomslistbox.SelectedIndex);
            if ((int)currRoomdetail.Capacity > currRoomdetail.GetCapacity((RoomType)roomtypecombobox.SelectedIndex))
            {
                MessageBox.Show("New type is smaller than before. This may cause problems with the code so you cannot do this."); return;
            }
            currRoomdetail.Roomtype = (RoomType)roomtypecombobox.SelectedIndex;
            currRoomdetail.Capacity = currRoomdetail.GetCapacity((RoomType)roomtypecombobox.SelectedIndex);

            roomMngr.ChangeElement(allroomslistbox.SelectedIndex, currRoomdetail);
            UpdateGUI();
        }
Exemplo n.º 10
0
        /// <summary>
        /// A perfect method that deletes empty slots in an array, by generating a new array to put everything in then returns to that one. so you can make it equal to a lsit to remove every empty spot inside.
        /// Note to self: integer i and j are used in this loop so be careful when making a change here.
        /// </summary>
        public roomdetail[] FixList(roomdetail[] m_list)
        {
            roomdetail[] newlist = new roomdetail[m_list.Length];
            for (int i = 0; i < roomlist.Length; i++)
            {
                newlist[i] = null;
            }

            int j = 0;

            for (int i = 0; i < roomlist.Length; i++)
            {
                if (roomlist[i] != null)
                {
                    newlist[j] = roomlist[i]; j++;
                }
            }
            return(newlist);
        }
Exemplo n.º 11
0
        /// <summary>
        /// generates the usual parts for object. then opens the other form and sends it to there inside as a parameter to be filled other information there.
        /// </summary>
        private void reserveroombutton_Click(object sender, EventArgs e)
        {
            if (allroomslistbox.SelectedIndex == -1)
            {
                MessageBox.Show("You did not choose a valid room to edit or reserve.Error"); return;
            }
            currRoomdetail = roomMngr.GetroomdetailAt(allroomslistbox.SelectedIndex);
            int index = allroomslistbox.SelectedIndex;

            currRoomdetail.Roomtype = (RoomType)roomtypecombobox.SelectedIndex;
            currRoomdetail.Capacity = currRoomdetail.GetCapacity((RoomType)roomtypecombobox.SelectedIndex);
            RoomDetailForm dlg       = new RoomDetailForm(currRoomdetail);
            DialogResult   dlgResult = dlg.ShowDialog();

            if (dlgResult == DialogResult.OK)
            {
                roomMngr.ChangeElement(index, currRoomdetail);
            }
            UpdateGUI();
        }
Exemplo n.º 12
0
        /// <summary>
        /// 4 rooms that I added for you to test the program with every property that it has.
        /// </summary>
        public void AddReadyRoomsToTest()
        {
            //test room 1
            currRoomdetail          = new roomdetail(maxnumberofpeopleinoneroom);
            currRoomdetail.Roomtype = RoomType.Single_Room;
            currRoomdetail.Capacity = currRoomdetail.GetCapacity(RoomType.Single_Room);
            roomMngr.Add(currRoomdetail);

            //test room 2
            currRoomdetail          = new roomdetail(maxnumberofpeopleinoneroom);
            currRoomdetail.Roomtype = RoomType.Double_Room;
            currRoomdetail.Capacity = currRoomdetail.GetCapacity(RoomType.Double_Room);
            currRoomdetail.AddPerson("Berkay", "KÖKSAL");
            currRoomdetail.AddPerson("Ayberk", "KÖKSAL");
            currRoomdetail.Checkindate  = DateTime.Now;
            currRoomdetail.Checkoutdate = (currRoomdetail.Checkindate.AddDays(4));
            roomMngr.Add(currRoomdetail);

            //test room 3
            currRoomdetail          = new roomdetail(maxnumberofpeopleinoneroom);
            currRoomdetail.Roomtype = RoomType.Family_Room;
            currRoomdetail.Capacity = currRoomdetail.GetCapacity(RoomType.Family_Room);
            roomMngr.Add(currRoomdetail);

            //test room 4
            currRoomdetail          = new roomdetail(maxnumberofpeopleinoneroom);
            currRoomdetail.Roomtype = RoomType.Dormitory_Room;
            currRoomdetail.Capacity = currRoomdetail.GetCapacity(RoomType.Dormitory_Room);
            currRoomdetail.AddPerson("Adrian", "Rekalde");
            currRoomdetail.AddPerson("Elisabeth", "Rouvier");
            currRoomdetail.AddPerson("Michelle", "Thompson");
            currRoomdetail.Checkindate  = DateTime.Now;
            currRoomdetail.Checkoutdate = (currRoomdetail.Checkindate.AddDays(3));
            roomMngr.Add(currRoomdetail);


            currRoomdetail = new roomdetail(maxnumberofpeopleinoneroom);
        }