Пример #1
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (comboboxDel.Text != "")
         {
             FotoEquipment f = r.ListFotoEquipment.FirstOrDefault(e1 => (e1.Company + " " + e1.Model) == comboboxDel.Text);
             if (f == null)
             {
                 throw new ArgumentException("The item was not found");
             }
             else
             {
                 r.ListFotoEquipment.Remove(f);
                 MainWindow.story += $"Deleted: {f.ToString()} {f.Company} {f.Model}\r";
             }
         }
         else
         {
             MessageBox.Show("Please, choose an item");
         }
     }
     catch (ArgumentException e2)
     {
         MessageBox.Show(e2.Message);
     }
     this.Close();
 }
Пример #2
0
        public void Create()// формирование нового объекта
        {
            if (type == "Camera")
            {
                f = new Camera(double.Parse(AddPage.arr[1]), int.Parse(AddPage.arr[2]), AddPage.arr[3], AddPage.arr[4], AddPage.arr[5], AddPage.arr[6], double.Parse(AddPage.arr[7]), double.Parse(AddPage.arr[8]), AddPage.arr[9]);
            }
            if (type == "Lens")
            {
                f = new Lens(double.Parse(AddPage.arr[1]), int.Parse(AddPage.arr[2]), AddPage.arr[3], AddPage.arr[4], AddPage.arr[5], AddPage.arr[6], AddPage.arr[7], double.Parse(AddPage.arr[8]));
            }
            if (type == "Flash")
            {
                f = new Flash(double.Parse(AddPage.arr[1]), int.Parse(AddPage.arr[2]), AddPage.arr[3], AddPage.arr[4], AddPage.arr[5], AddPage.arr[6], int.Parse(AddPage.arr[7]), int.Parse(AddPage.arr[8]));
            }

            r.ListFotoEquipment.Add(f);
            MainWindow.story += $"Added: {f.ToString()} {f.Company} {f.Model}\r";
            add.Close();
        }