Пример #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //insert data
            string propertyNumber     = txtPropertyNo.Text;
            string propertySuburb     = txtSuburb.Text;
            int    propertyBedroomNum = int.Parse(txtBedroomNum.Text);
            double propertyRent       = double.Parse(txtRent.Text);
            string propertyStatus     = (string)txtStatus.SelectedItem;

            //clear textboxes
            txtBedroomNum.Clear();
            txtPropertyNo.Clear();
            txtRent.Clear();
            txtSearchBy.Clear();
            txtStatus.SelectedIndex = -1;
            txtSuburb.Clear();

            //insert data into constructor
            MyProperty_ myProperty = new MyProperty_(propertyNumber, propertySuburb,
                                                     propertyBedroomNum, propertyRent, propertyStatus);
            //insert data into an array and return a bool apon completion
            bool InsertInto = CanBeInsertedIntoArr(myProperty);

            if (InsertInto == false)
            {
                MessageBox.Show("Array Is Full. Can Not Save Property Details");
                return;
            }
            MessageBox.Show("Property Details inserted");
        }
Пример #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     //lets insert  stored data array apon form load
     for (int i = 0; i < INSERTEDPROPERTIES; i++)
     {
         //point to constructor and insert data
         MyProperty_ myProperty = new MyProperty_(MyProperty_.Numbers[i], MyProperty_.Suburbs[i],
                                                  MyProperty_.BedroomNums[i], MyProperty_.Rents[i], MyProperty_.Statuses[i]);
         //point to the method to store the info into the array
         bool isInserted = CanBeInsertedIntoArr(myProperty);
     }
 }
Пример #3
0
 private bool CanBeInsertedIntoArr(MyProperty_ myProperty)
 {
     for (int i = 0; i < myProperties.Length; i++)
     {
         //enter data where array index is null
         if (myProperties[i] == null)
         {
             myProperties[i] = myProperty;
             return(true);
         }
     }
     return(false);
 }