private void btn_AddNewPhone_Click(object sender, EventArgs e) { AddPhoneForm form = new AddPhoneForm(); form.Show(); lbx_ListOfPhones.DataSource = PhoneRepository.GetListOfPhones(); }
private void Form1_Load(object sender, EventArgs e) { lbx_ListOfPhones.DisplayMember = "Model"; lbx_ListOfPhones.DataSource = PhoneRepository.GetListOfPhones(); lbx_ListOfPhones.SelectedIndex = -1; chLbx.DataSource = PhoneRepository.GetOptions(); chLbx.DisplayMember = "OptionName"; }
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(); } }