private void Change1_Click(object sender, RoutedEventArgs e) { if (lb == 1) { Add_Window wnd = new Add_Window(this); wnd.Show(); try { foreach (var item in lr.Lorries) { if (item.Name == ((Lorry)Table1.SelectedItem).Name) { wnd.Name.Text = item.Name; wnd.Mass.Text = item.FreightMass.ToString(); wnd.Prod_Year.Text = item.ProductionYear.ToString(); wnd.Power.Text = item.Horsepower.ToString(); wnd.Type_eng.Text = item.EngineType; wnd.Capacity.Text = item.EngineСapacity.ToString(); } } lr.Lorries.Remove((Lorry)Table1.SelectedItem); Search_result.Items.Remove(Table1.SelectedItem); Serializing.Serialize_l(lr); Table1.Items.Remove(Table1.SelectedItem); }catch (Exception a) { MessageBox.Show(a.ToString()); } } else { } if (lb == 2) { Add_Window wnd = new Add_Window(this); wnd.Show(); try { foreach (var item in lr.Lorries) { if (item.Name == ((Lorry)Search_result.SelectedItem).Name) { wnd.Name.Text = item.Name; wnd.Mass.Text = item.FreightMass.ToString(); wnd.Prod_Year.Text = item.ProductionYear.ToString(); wnd.Power.Text = item.Horsepower.ToString(); wnd.Type_eng.Text = item.EngineType; wnd.Capacity.Text = item.EngineСapacity.ToString(); } } lr.Lorries.Remove((Lorry)Search_result.SelectedItem); Table1.Items.Remove(Search_result.SelectedItem); Serializing.Serialize_l(lr); Search_result.Items.Remove(Search_result.SelectedItem); } catch (Exception a) { MessageBox.Show(a.ToString()); } } else { } }
private void Add_Lorry_Button_Click(object sender, RoutedEventArgs e) { Add_Window wnd = new Add_Window(this); wnd.Show(); }