Beispiel #1
0
        private void ChangeProject_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                foreach (var pr in lp.Proj)
                {
                    if (AllPrListBox.SelectedItem != null)
                    {
                        if (AllPrListBox.SelectedItem.ToString() == pr.Name)
                        {
                            int k = lp.Proj.IndexOf(pr);
                            lp.Proj.RemoveAt(k);
                            break;
                        }
                    }
                }



                Customer customer = null;
                lc.Cust = new List <Customer>();

                lc = Serialization.Deserialze(lc);
                foreach (var item in lc.Cust)
                {
                    if (CustomerComboBox.SelectedItem.ToString() == item.Name)
                    {
                        customer = item;
                    }
                }


                Project proj = new Project(NameText.Text, Description.Text, ManagerComboBox.Text, customer, int.Parse(People.Text), int.Parse(Money.Text), Date.Text);


                lp.Proj.Add(proj);


                Log.logging("Изменен проект: " + proj.Name + " " + DateTime.Now);
                Serialization.Serialize_proj(lp);


                MessageBox.Show("Сохранено!");

                AllPrListBox.Items.Clear();
                foreach (var item in lp.Proj)
                {
                    AllPrListBox.Items.Add(item.Name);
                }



                NameText.Clear();
                Description.Clear();
                ManagerComboBox.SelectedIndex  = -1;
                CustomerComboBox.SelectedIndex = -1;
                People.Clear();
                Money.Clear();
                Date.Clear();

                AllPrListBox.SelectedItem = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.logging("Ошибка: " + ex);
            }
        }