private void btn_AddNewPhone_Click(object sender, EventArgs e) { AddPhoneForm form = new AddPhoneForm(); form.Show(); lbx_ListOfPhones.DataSource = PhoneRepository.GetListOfPhones(); }
private void btn_SaveInFile_Click(object sender, EventArgs e) { if (lbx_ListOfPhones.Items.Count != 0) { PhoneRepository.SavePhones(); MessageBox.Show("Список телефонов был сохранён", "Сохранено"); } }
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_AddOption_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(tbx_NameOfOption.Text)) { PhoneRepository.AddOption(tbx_NameOfOption.Text); } else { MessageBox.Show("Не введено название добавляемой опции.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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(); } }
private void btn_AddPhone_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(tbx_NewModel.Text) & !String.IsNullOrEmpty(tbx_NewOs.Text) & !String.IsNullOrEmpty(tbx_NewProcessor.Text) & !String.IsNullOrEmpty(tbx_NewPrice.Text)) { if (String.IsNullOrEmpty(tbx_Picture.Text)) { tbx_Picture.Text = "NotFound.jpg"; } PhoneRepository.AddPhone(new PhoneInfo() { Model = tbx_NewModel.Text, OS = tbx_NewOs.Text, Processor = tbx_NewProcessor.Text, Price = Convert.ToDecimal(tbx_NewPrice.Text), Picture = tbx_Picture.Text }); } else { MessageBox.Show("Не все поля заполненны.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Close(); }
private void btn_DelPhone_Click(object sender, EventArgs e) { PhoneInfo phone = lbx_ListOfPhones.SelectedItem as PhoneInfo; PhoneRepository.DeletePhone(phone); }
private void btn_LoadFromFile_Click(object sender, EventArgs e) { lbx_ListOfPhones.DataSource = PhoneRepository.LoadPhones(); lbx_ListOfPhones.DisplayMember = "Model"; }