Exemple #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            clsMobilePhone phone = phoneLot.GetPhoneCurrentlyDisplayed();

            if (phone is clsAndroidPhone)
            {
                // edit android phone
                frmAdd       editAndroid = new frmAdd((clsAndroidPhone)phone);
                DialogResult dr          = editAndroid.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    phoneLot.EditPhone(editAndroid.AndroidPhoneDetails);
                    DisplayPhone();
                }
            }
            else
            {
                // edit apple phone
                frmAdd       ediApple = new frmAdd((clsApplePhone)phone);
                DialogResult dr       = ediApple.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    phoneLot.EditPhone(ediApple.ApplePhoneDetails);
                    DisplayPhone();
                }
            }
        }
        // Implement IComparable CompareTo method - provide default sort order.
        // this will be used if we need to sort the vehicles
        int IComparable.CompareTo(object obj)
        {
            // iComparable returns   +1, 0 or -1
            clsMobilePhone otherMobilePhone  = (clsMobilePhone)obj;
            decimal        differenceInPrice = this.CalculateApproximateValue() - otherMobilePhone.CalculateApproximateValue();

            // we want to return +1, 0 or -1
            return(Math.Sign(differenceInPrice));
        }
Exemple #3
0
 // we are not using these currently...
 public void EditPhone(clsMobilePhone phone)
 {
     PhoneStock[phoneCurrentlyDisplayed] = phone;
 }
Exemple #4
0
 // we are not using these currently...
 public void AddPhone(clsMobilePhone phone)
 {
     PhoneStock.Add(phone);
     phoneCurrentlyDisplayed = PhoneStock.Count - 1;
 }