Пример #1
0
        private void CreateObjectButton_Click(object sender, EventArgs e)
        {
            ObjectDataListBox.Items.Clear();

            CellPhone myPhone = new CellPhone();

            GetPhone(myPhone);
            phoneList.Add(GetPhone(myPhone));

            PhoneBrandOut.Text = myPhone.GetBrand();
            PhoneModelOut.Text = myPhone.GetModel();
            PhonePriceOut.Text = myPhone.GetPrice().ToString("c");
            LoadPhoneList(phoneList);
        }
Пример #2
0
        private void CreateObjectButton_Click(object sender, EventArgs e)
        {
            ObjectDataListBox.Items.Clear();     // Clear the list for next use

            CellPhone myPhone = new CellPhone(); // Create an instance of cell phone class

            GetPhone(myPhone);
            phoneList.Add(GetPhone(myPhone));                      // Add phone in the phone list

            PhoneBrandOut.Text = myPhone.GetBrand();               // Get phone brand
            PhoneModelOut.Text = myPhone.GetModel();               // Get phone model
            PhonePriceOut.Text = myPhone.GetPrice().ToString("c"); //Get Phone price

            LoadPhoneList(phoneList);                              //Display phones into list
        }
Пример #3
0
        private CellPhone GetPhone(CellPhone myPhone)
        {
            decimal phonePrice = 0m;

            decimal.TryParse(PhonePriceTextBox.Text, out phonePrice);
            myPhone.SetBrand(PhoneBrandTextBox.Text);
            myPhone.SetModel(PhoneModelTextBox.Text);
            myPhone.SetPrice(phonePrice);

            myPhone.GetBrand();
            myPhone.GetModel();
            myPhone.GetPrice();

            return(myPhone);
        }
Пример #4
0
        private CellPhone GetPhone(CellPhone myPhone)         //Get phone method which is pretented to get all the infomation of the phone
        {
            decimal phonePrice = 0m;

            if (decimal.TryParse(PhonePriceTextBox.Text, out phonePrice))
            {
                myPhone.SetBrand(PhoneBrandTextBox.Text);
                myPhone.SetModel(PhoneModelTextBox.Text);
                myPhone.SetPrice(phonePrice);
            }
            else
            {
                MessageBox.Show("The phone price in invaild - Please try agian");
                PhonePriceTextBox.SelectAll();
            }

            myPhone.GetBrand();
            myPhone.GetModel();
            myPhone.GetPrice();

            return(myPhone);
        }