Example #1
0
        private void ToBlack(object sender, RoutedEventArgs e)
        {                                                                 //загрузить выбранный элемент
            SoftList softList  = GridWhiteList.SelectedItem as SoftList;  //выбор элемента
            SoftList AllocList = GridAllocation.SelectedItem as SoftList; //выбор элемента

            if (softList != null)
            {
                //внести изменения
                softList.List_ID = 1;
                //сохранить изменения
                SoftListDB.SaveChanges();
            }
            else if (AllocList != null)
            {
                //внести изменения
                AllocList.List_ID = 1;
                //сохранить изменения
                SoftListDB.SaveChanges();
            }
            else
            {
                MessageBox.Show("Выберите элемент для переноса в чёрный список", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            //сохранить изменения
            SoftListDB.SaveChanges();
            UploadBlack();
            UploadWhite();
            UploadAllocation();
        }
Example #2
0
        public void Update(object sender, RoutedEventArgs e)
        {
            softLists.Clear();
            GridAllocation.ItemsSource = null;
            GridAllocation.Items.Clear();


            int k = 0;//счётчик совпадений

            foreach (var item2 in Inventory.Software.ToList())
            {
                foreach (var item in SoftListDB.SoftList.ToList())
                {    //выборка по коду ListID
                    if (item.Soft_Name == item2.Name)
                    {
                        k = 1;    //совпадение есть
                    }
                }

                if (k == 0)
                {
                    SoftList softlistss = new SoftList();
                    {
                        softlistss.Soft_Name = item2.Name;
                        softlistss.List_ID   = 0;
                    }
                    SoftListDB.SoftList.Add(softlistss);
                    SoftListDB.SaveChanges();
                }
                k = 0;
            }
            UploadAllocation();
        }