Exemplo n.º 1
0
        private void lbx_ListOfPhones_SelectedIndexChanged(object sender, EventArgs e)
        {
            PhoneInfo phone = lbx_ListOfPhones.SelectedItem as PhoneInfo;

            if (phone != null)
            {
                tbx_Model.Text     = phone.Model;
                tbx_OS.Text        = phone.OS;
                tbx_Processor.Text = phone.Processor;
                tbx_Price.Text     = phone.Price.ToString();
                pictureBox1.Load(phone.Picture);
                ///////////////////////////////////////////
                lbx_Options.DataSource    = phone.GetPhoneOptions();
                lbx_Options.DisplayMember = "OptionName";
                ///////////////////////////////////////////
                tbx_ModelR.Text     = phone.Model;
                tbx_OSR.Text        = phone.OS;
                tbx_ProcessorR.Text = phone.Processor;
                tbx_Picture.Text    = phone.Picture;
                tbx_PriceR.Text     = phone.Price.ToString();
            }
        }
Exemplo n.º 2
0
        private void btn_SaveChanges_Click(object sender, EventArgs e)
        {
            PhoneInfo phone = lbx_ListOfPhones.SelectedItem as PhoneInfo;

            if (phone != null)
            {
                for (int i = 0; i < chLbx.Items.Count; i++)
                {
                    if (chLbx.GetItemChecked(i))
                    {
                        phone.options.Add(chLbx.Items[i] as Option);
                    }
                }

                if (!String.IsNullOrEmpty(tbx_ModelR.Text) & tbx_ModelR.Text != phone.Model)
                {
                    phone.Model = tbx_ModelR.Text;
                }
                if (!String.IsNullOrEmpty(tbx_OSR.Text) & tbx_OSR.Text != phone.OS)
                {
                    phone.OS = tbx_OSR.Text;
                }
                if (!String.IsNullOrEmpty(tbx_ProcessorR.Text) & tbx_ProcessorR.Text != phone.Processor)
                {
                    phone.Processor = tbx_ProcessorR.Text;
                }
                if (!String.IsNullOrEmpty(tbx_PriceR.Text))
                {
                    phone.Price = Convert.ToDecimal(tbx_PriceR.Text);
                }
                if (!String.IsNullOrEmpty(tbx_Picture.Text) & tbx_Picture.Text != phone.Picture)
                {
                    phone.Picture = tbx_Picture.Text;
                }
                PhoneRepository.phones[lbx_ListOfPhones.SelectedIndex] = phone;
                lbx_ListOfPhones.DataSource = PhoneRepository.GetListOfPhones();
            }
        }
Exemplo n.º 3
0
        private void btn_DelPhone_Click(object sender, EventArgs e)
        {
            PhoneInfo phone = lbx_ListOfPhones.SelectedItem as PhoneInfo;

            PhoneRepository.DeletePhone(phone);
        }
Exemplo n.º 4
0
 public static void DeletePhone(PhoneInfo phone)
 {
     phones.Remove(phone);
 }
Exemplo n.º 5
0
 public static void AddPhone(PhoneInfo phone)
 {
     phones.Add(phone);
 }