Ejemplo n.º 1
0
 public static void Serialize(ListOfCustomers lc)
 {
     using (FileStream fs = new FileStream(file, FileMode.Create))
     {
         serializer.Serialize(fs, lc);
     };
 }
Ejemplo n.º 2
0
        private void AddProject_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (AllPrListBox.SelectedItem.ToString() != NameText.Text)
                {
                    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);

                    lp = Serialization.Deserialze_proj(lp);

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


                    AllPrListBox.Items.Clear();
                    foreach (var item in lp.Proj)
                    {
                        AllPrListBox.Items.Add(item.Name);
                    }
                }
                else
                {
                    MessageBox.Show("Такой проект уже существует");
                }

                AllPrListBox.SelectedItem = -1;
                NameText.Clear();
                Description.Clear();
                ManagerComboBox.SelectedIndex  = -1;
                CustomerComboBox.SelectedIndex = -1;
                People.Clear();
                Money.Clear();
                Date.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.logging("Ошибка: " + ex);
            }
        }
Ejemplo n.º 3
0
        public Projects_Page1()
        {
            InitializeComponent();

            try
            {
                //десериализация для проектов
                //lp.Proj = new List<Project>();

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

                //чтение из текстового файла и вывод информации в поле "Руководитель"
                using (FileStream fs = new FileStream(@"../../input_managers.txt", FileMode.Open, FileAccess.Read))
                {
                    string[]     data_txt;
                    Manager      mg;
                    StreamReader sr = new StreamReader(fs, Encoding.Default);

                    while (!sr.EndOfStream)
                    {
                        data_txt = sr.ReadLine().Split(' ');
                        mg       = new Manager(data_txt[0], data_txt[1]);
                        managers.Add(mg);
                    }



                    sr.Close();
                    fs.Close();
                }

                foreach (Manager mg in managers)
                {
                    string emp = mg._name + ' ' + mg._lastName;
                    ManagerComboBox.Items.Add(emp);
                }

                //вывод информации в поле "Заказчик"

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

                lc = Serialization.Deserialze(lc);
                foreach (var item in lc.Cust)
                {
                    CustomerComboBox.Items.Add(item.Name);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.logging("Ошибка: " + ex);
            }
        }
Ejemplo n.º 4
0
        public static ListOfCustomers Deserialze(ListOfCustomers lc)
        {
            ListOfCustomers data = null;

            using (FileStream fs = new FileStream(file, FileMode.Open))
            {
                data = (ListOfCustomers)serializer.Deserialize(fs);
            };
            return(data);
        }
Ejemplo n.º 5
0
        public Customer_Page2()
        {
            InitializeComponent();

            //десериализация для заказчиков
            lc.Cust = new List <Customer>();

            lc = Serialization.Deserialze(lc);
            foreach (var item in lc.Cust)
            {
                ClientsListBox.Items.Add(item.Name);
            }
        }
Ejemplo n.º 6
0
        private void AddClient_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ClientsListBox.SelectedItem.ToString() != NameCustomerText.Text)
                {
                    Customer cust = new Customer(NameCustomerText.Text, SiteText.Text, RepresentativeText.Text, PhoneNumberText.Text);

                    lc.Cust.Add(cust);
                    Log.logging("Добавлен клиент: " + cust.Name + " " + DateTime.Now);
                    Serialization.Serialize(lc);

                    ClientsListBox.Items.Clear();


                    lc = Serialization.Deserialze(lc);

                    NameCustomerText.Clear();
                    SiteText.Clear();
                    RepresentativeText.Clear();
                    PhoneNumberText.Clear();


                    foreach (var item in lc.Cust)
                    {
                        ClientsListBox.Items.Add(item.Name);
                    }
                    MessageBox.Show("Сохранено!");
                }
                else
                {
                    MessageBox.Show("Такой заказчик уже существует!");
                    NameCustomerText.Clear();
                    SiteText.Clear();
                    RepresentativeText.Clear();
                    PhoneNumberText.Clear();

                    ClientsListBox.SelectedItem = -1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.logging("Ошибка" + ex);
            }
        }
Ejemplo n.º 7
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);
            }
        }