private void Connect(DataGrid grid)
        {
            try
            {
                adoDB = new ADOModel();
                IEnumerable <Category> categories = adoDB.Categories.Include(c => c.WHs).Where(c => c.NameCategory == selectedCategory.NameCategory).ToList();
                IEnumerable <WH>       parts      = categories.SelectMany(p => p.WHs).ToList();

                foreach (var a in parts)
                {
                    List <string> str = a.Categories.Select(c => c.NameCategory).ToList();

                    foreach (string s in str)
                    {
                        AllResullt res = new AllResullt();
                        res.Manufacturer = a.Manufacturer;
                        res.Model        = a.Model;
                        res.Count        = a.Count;
                        res.Price        = a.Price;
                        res.CategoryName = s;
                        grid.Items.Add(res);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(" Error: " + ex.Message);
            }
        }
Esempio n. 2
0
 private void Edit_Button_Click(object sender, RoutedEventArgs e)
 {
     selectItem = MainGrid.SelectedItem as AllResullt;
     if (selectItem != null)
     {
         EditWindow edit = new EditWindow(selectItem);
         edit.Show();
     }
     Connect();
 }
Esempio n. 3
0
        private void Wharehouse_Button_Click(object sender, RoutedEventArgs e)
        {
            MainGrid.Items.Clear();

            adoDB = new ADOModel();
            IEnumerable <WH> allLine = adoDB.WHs;

            foreach (var a in allLine)
            {
                List <string> str = a.Categories.Select(c => c.NameCategory).ToList();
                AllResullt    res = new AllResullt();
                res.Manufacturer = a.Manufacturer;
                res.Model        = a.Model;
                res.Count        = a.Count;
                res.Price        = a.Price;
                foreach (string s in str)
                {
                    res.CategoryName = s;
                }
                MainGrid.Items.Add(res);
            }
        }
Esempio n. 4
0
        protected void Delete()
        {
            try
            {
                selectItem = MainGrid.SelectedItem as AllResullt;

                if (selectItem != null && selectItem.CategoryName != null)
                {
                    WH       delPart = adoDB.WHs.Where(o => o.Model == selectItem.Model).First();
                    Category delcat  = adoDB.Categories.Where(c => c.NameCategory == selectItem.CategoryName).First();
                    delcat.WHs.Remove(delPart);
                    adoDB.Entry(delcat).State = EntityState.Modified;
                    adoDB.WHs.Remove(delPart);
                    adoDB.SaveChanges();
                    Connect();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Esempio n. 5
0
        private void Connect()
        {
            MainGrid.Items.Clear();
            adoDB = new ADOModel();
            IEnumerable <WH> allLine = adoDB.WHs.Include(p => p.Categories);

            foreach (var a in allLine)
            {
                List <string> str = a.Categories.Select(c => c.NameCategory).ToList();

                foreach (string s in str)
                {
                    AllResullt res = new AllResullt();
                    res.IdPart       = a.ID_Pard;
                    res.Manufacturer = a.Manufacturer;
                    res.Model        = a.Model;
                    res.Count        = a.Count;
                    res.Price        = a.Price;
                    res.CategoryName = s;
                    MainGrid.Items.Add(res);
                }
            }
        }
Esempio n. 6
0
 public EditWindow(AllResullt resultIn)
 {
     this.resultIn = resultIn;
     InitializeComponent();
     Connect();
 }