Ejemplo n.º 1
0
        public void AddNewNeighbourhood(Neighbourhood inputTmpNeighbourhood)
        {
            int currentNeighbourhoodSize = neighbourhoodArray.Length;           //get array size

            Array.Resize(ref neighbourhoodArray, currentNeighbourhoodSize + 1); //make an array space
            neighbourhoodArray[currentNeighbourhoodSize] = inputTmpNeighbourhood;
        }
Ejemplo n.º 2
0
        private void BtnNeighAddSave_Click(object sender, EventArgs e)
        {
            //create a temp neighbourhood
            Neighbourhood tmpNeighbourhood = new Neighbourhood(txtNeighbourhoodName.Text, 0, propertyArray);

            if (txtNeighbourhoodName.Text == "")
            {
                MessageBox.Show("Neighbourhood Name Field must have a value!");
                txtNeighbourhoodName.Focus();
            }
            else
            {
                //increment neighbourhoods in distric number
                int currentNeighbourhoods = districtArray[selectedDistrict].GetNeighbourhoodsInDistrict();
                currentNeighbourhoods += 1;
                districtArray[selectedDistrict].SetNeighbourhoodsInDistrict(currentNeighbourhoods);

                //add to array
                districtArray[selectedDistrict].AddNewNeighbourhood(tmpNeighbourhood);

                //write to data file

                //refresh the list boxes
                DisplayNeighbourhood();
                lstNeighbourhood.SelectedIndex = lstNeighbourhood.Items.Count - 1;

                //clear out property text boxes
                ClearPropertyTextBoxes();
            }

            btnAddNeighbourhood.Enabled = true;
            btnEditNeigh.Enabled        = true;
            btnNeighAddSave.Hide();
            btnEditNeighSave.Hide();
            btnNeighCancel.Hide();

            //Write data back to file
            WriteDataFile();
        }
Ejemplo n.º 3
0
 public void AddNewNhood(Neighbourhood inputTmpNeighbourhood)
 {
     Neighbourhood tmpNeighbourhood = inputTmpNeighbourhood;
 }
Ejemplo n.º 4
0
        } //checks input boxes have a value before submission

        private void LoadDataFileMethod() //reads data file and loads all details to array.
        {
            string tmpDistrictName, tmpNeighbourhoodName, tmpPropID, tmpPropName, tmpHostID,
                   tmpHostName, tmpPropLat, tmpPropLong, tmpRoomType, tmpMinNights, tmpNightsAvailable;
            int    tmpNumNeighbourhood, tmpNumPropInNeighbourhood, tmpHostPropNum;
            double tmpPrice;


            //run streamreader
            StreamReader loadDataIn = new StreamReader(dataFileLocation);

            //get districts
            while (!loadDataIn.EndOfStream)
            {
                //read file for districts
                tmpDistrictName     = loadDataIn.ReadLine();
                tmpNumNeighbourhood = Convert.ToInt32(loadDataIn.ReadLine());

                //get neighbourhoods
                for (int j = 0; j < tmpNumNeighbourhood; j++)
                {
                    //read file for neighbourhoods
                    tmpNeighbourhoodName      = loadDataIn.ReadLine();
                    tmpNumPropInNeighbourhood = Convert.ToInt32(loadDataIn.ReadLine());

                    //get properties
                    for (int k = 0; k < tmpNumPropInNeighbourhood; k++)
                    {
                        tmpPropID          = loadDataIn.ReadLine();
                        tmpPropName        = loadDataIn.ReadLine();
                        tmpHostID          = loadDataIn.ReadLine();
                        tmpHostName        = loadDataIn.ReadLine();
                        tmpHostPropNum     = Convert.ToInt32(loadDataIn.ReadLine());
                        tmpPropLat         = loadDataIn.ReadLine();
                        tmpPropLong        = loadDataIn.ReadLine();
                        tmpRoomType        = loadDataIn.ReadLine();
                        tmpPrice           = Convert.ToInt32(loadDataIn.ReadLine());
                        tmpMinNights       = loadDataIn.ReadLine();
                        tmpNightsAvailable = loadDataIn.ReadLine();

                        //create property
                        Property tmpProperty = new Property(tmpPropID, tmpPropName, tmpHostID,
                                                            tmpHostName, tmpHostPropNum, tmpPropLat, tmpPropLong, tmpRoomType,
                                                            tmpPrice, tmpMinNights, tmpNightsAvailable);

                        //Add to Property array
                        int currentPropertySize = FrmMain.propertyArray.Length + 1;   //get array size
                        Array.Resize(ref FrmMain.propertyArray, currentPropertySize); //make an array space
                        FrmMain.propertyArray[currentPropertySize - 1] = tmpProperty;
                    }

                    //create neighbourhood
                    Neighbourhood tmpNeighbourhood = new Neighbourhood(tmpNeighbourhoodName,
                                                                       tmpNumPropInNeighbourhood, FrmMain.propertyArray);
                    //Add to Neighbourhood array

                    int currentNeighbourhoodSize = FrmMain.neighbourhoodArray.Length + 1;   //get array size
                    Array.Resize(ref FrmMain.neighbourhoodArray, currentNeighbourhoodSize); //make an array space
                    FrmMain.neighbourhoodArray[currentNeighbourhoodSize - 1] = tmpNeighbourhood;

                    //clear prop array
                    FrmMain.propertyArray = new Property[0];
                }

                //create district
                District tempDist = new District(tmpDistrictName, tmpNumNeighbourhood, FrmMain.neighbourhoodArray);

                //add to District array

                int currentDistSize = FrmMain.districtArray.Length + 1;   //get array size
                Array.Resize(ref FrmMain.districtArray, currentDistSize); //make an array space
                FrmMain.districtArray[currentDistSize - 1] = tempDist;

                //clear neighbourhood array
                FrmMain.neighbourhoodArray = new Neighbourhood[0];
            }
            loadDataIn.Close();
            ShowData();
        }