Esempio n. 1
0
        private void BtnEditNbh_Click(object sender, EventArgs e)
        {
            // if neighbourhood is selected
            if (lstNeighbourhoods.SelectedIndex != -1)
            {
                // show the edit form and capture the new data
                frmEditNbh frmEditN = new frmEditNbh();

                // if so display an input form showdialog mode to accept the new name
                frmEditN.ShowDialog();

                // update the data in the array object
                int nbhno = lstNeighbourhoods.SelectedIndex;

                Neighbourhood nbh = Arrays.NbhArray[nbhno];
                nbh.setNbhName(frmEditNbh.SetTextValueNbh);

                // redisplay the neighbourhood dta in the list box
                lstNeighbourhoods.Items.Clear();

                foreach (Neighbourhood newnbh in Arrays.NbhArray)
                {
                    //get the neighbourhood name
                    // put the name in the listbox
                    lstNeighbourhoods.Items.Add(newnbh.getNbhName());
                }
            }
            else
            {
                MessageBox.Show("You must select a neighbourhood to edit.");
            }
        }
Esempio n. 2
0
        public void setNewNbh(string nbhname)
        {
            Neighbourhood TempNBH    = new Neighbourhood("laira");
            int           newnbhSize = Arrays.NbhArray.Length;

            Array.Resize(ref Arrays.NbhArray, newnbhSize + 1);
            Arrays.NbhArray[newnbhSize] = TempNBH;
            distNumNbh = distNumNbh + 1;
        }
Esempio n. 3
0
        private void LstNeighbourhoods_SelectedIndexChanged(object sender, EventArgs e)
        {
            // check a district and neighbourhood is selected
            // check data was loaded in
            if (lstDistricts.SelectedIndex != -1 && lstNeighbourhoods.SelectedIndex != -1 && btnLoadDataWasClicked)
            {
                lstProperties.Items.Clear();
                int distno = lstDistricts.SelectedIndex;

                District dist = Arrays.DistArray[distno];

                // put all the selected  district's nbhs into an array
                Arrays.NbhArray = dist.getDistAllNbh();
                //get the nbh we need
                int           whichnbh = lstNeighbourhoods.SelectedIndex;
                Neighbourhood nbh      = Arrays.NbhArray[whichnbh];

                Arrays.PropArray = nbh.getNbhAllProp();
                if (nbh.getNbhNumProp() != 0)
                {
                    nbh.getNbhAllProp();
                    foreach (Property prop in Arrays.PropArray)
                    {
                        lstProperties.Items.Add(prop.getPropName());
                    }

                    // property maintenance buttons become available
                    btnAddProp.Show();
                    btnEditProp.Show();
                }
            }

            else
            {
                MessageBox.Show("You must select a district and neighbourhood.");
            }
        }
Esempio n. 4
0
        private void BtnEditProp_Click(object sender, EventArgs e)
        {
            // make sure a dist, nbh and prop are selected
            if (lstDistricts.SelectedIndex != -1 && lstNeighbourhoods.SelectedIndex != -1 && lstProperties.SelectedIndex != -1)
            {
                // get district number
                int distno = lstDistricts.SelectedIndex;
                // get neighbourhood number
                int whichnbh = lstNeighbourhoods.SelectedIndex;
                // get property number
                int propno = lstProperties.SelectedIndex;
                // open the property maintenance form
                // get this property object out of the arrays
                District      dist = Arrays.DistArray[distno];
                Neighbourhood nbh  = Arrays.NbhArray[whichnbh];
                Arrays.PropArray = nbh.getNbhAllProp();
                Property prop = Arrays.PropArray[propno];

                // get data ready to carry to new form
                SetTextValuePropID    = prop.getPropID();
                SetTextValuePropName  = prop.getPropName();
                SetTextValueHostID    = prop.getHostID();
                SetTextValueHostName  = prop.getHostName();
                SetTextValueNumProp   = prop.getNumPropH();
                SetTextValueLati      = prop.getLati();
                SetTextValueLongi     = prop.getLongi();
                SetTextValueRoomType  = prop.getRoomType();
                SetTextValuePrice     = prop.getPrice();
                SetTextValueMinNights = prop.getMinNights();
                SetTextValueDays      = prop.getDays();

                frmEditProp frmProp = new frmEditProp();

                frmProp.Show();
            }
        }
Esempio n. 5
0
        private void BtnLoadData_Click(object sender, EventArgs e)
        {
            // hide text and data load button
            btnLoadData.Hide();
            lblClick.Hide();

            // show all buttons and listboxes
            imgTitle.Show();
            imgDistricts.Show();
            imgNeighbourhoods.Show();
            imgProperties.Show();
            lstDistricts.Show();
            lstNeighbourhoods.Show();
            lstProperties.Show();
            btnAddDist.Show();
            btnEditDist.Show();
            btnAddNbh.Show();
            btnEditNbh.Show();
            btnAddProp.Show();
            btnEditProp.Show();
            btnExit.Show();

            btnLoadDataWasClicked = true;

            // select file
            DialogResult result      = openFileDialog1.ShowDialog();
            string       strfilename = openFileDialog1.FileName;

            // read the data in from the text file
            using (StreamReader AirbnbData = new StreamReader(strfilename))
            {
                // create a while loop
                while (!AirbnbData.EndOfStream)
                {
                    // deal with a district
                    string          TempDistName = AirbnbData.ReadLine();
                    string          TempNumNbh   = AirbnbData.ReadLine();
                    int             NumNbh       = Convert.ToInt32(TempNumNbh);
                    Neighbourhood[] nbh_array    = new Neighbourhood[NumNbh];

                    // deal with each of this district's neighbourhoods
                    for (int a = 0; a < NumNbh; a++)
                    {
                        string     TempNbhName = AirbnbData.ReadLine();
                        string     TempNumProp = AirbnbData.ReadLine();
                        int        NumProp     = Convert.ToInt32(TempNumProp);
                        Property[] Prop_Array  = new Property[NumProp];

                        // deal with this neighbourhoods properties
                        if (NumProp != 0)
                        {
                            for (int b = 0; b < NumProp; b++)
                            {
                                string TempPropID    = AirbnbData.ReadLine();
                                string TempPropName  = AirbnbData.ReadLine();
                                string TempHostID    = AirbnbData.ReadLine();
                                string TempHostName  = AirbnbData.ReadLine();
                                string TempNumPropH  = AirbnbData.ReadLine();
                                string TempLati      = AirbnbData.ReadLine();
                                string TempLongi     = AirbnbData.ReadLine();
                                string TempRoomType  = AirbnbData.ReadLine();
                                string TempPrice     = AirbnbData.ReadLine();
                                string TempMinNights = AirbnbData.ReadLine();
                                string TempDays      = AirbnbData.ReadLine();

                                Property TempProp = new Property(TempPropID, TempPropName, TempHostID, TempHostName, Convert.ToInt32(TempNumPropH), TempLati, TempLongi,
                                                                 TempRoomType, Convert.ToInt32(TempPrice), Convert.ToInt32(TempMinNights), Convert.ToInt32(TempDays));

                                int newPropSize = Arrays.PropArray.Length;
                                Array.Resize(ref Arrays.PropArray, newPropSize + 1);
                                Arrays.PropArray[newPropSize] = TempProp;
                            }

                            Neighbourhood TempNbh = new Neighbourhood(TempNbhName, Convert.ToInt32(TempNumProp), Arrays.PropArray);
                            Array.Resize(ref Arrays.PropArray, 0);
                            int newNbhSize = Arrays.NbhArray.Length;
                            Array.Resize(ref Arrays.NbhArray, newNbhSize + 1);
                            Arrays.NbhArray[newNbhSize] = TempNbh;
                        }
                    }

                    District TempDist = new District(TempDistName, Convert.ToInt32(TempNumNbh), Arrays.NbhArray);
                    Array.Resize(ref Arrays.NbhArray, 0);
                    int newDistSize = Arrays.DistArray.Length;
                    Array.Resize(ref Arrays.DistArray, newDistSize + 1);
                    Arrays.DistArray[newDistSize] = TempDist;
                }

                AirbnbData.Close();
            }

            // only show data and buttons if data was loaded in first
            if (btnLoadDataWasClicked)
            {
                // this will show the districts in the list box by looping through the array using the getters
                lstDistricts.Items.Clear();
                foreach (District dist in Arrays.DistArray)
                {
                    // get the district name
                    // put the name in the listbox
                    lstDistricts.Items.Add(dist.getDistName());
                }
                //add/edit dist buttons become available
                btnAddDist.Show();
                btnEditDist.Show();
            }
        }