private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            ManufacturerItem manu = new ManufacturerItem();
            manu.id = mManufacturers.Count == 0 ? 0 : mManufacturers.Max(x => x.id) + 1;
            manu.uidisplayname = "New manufacturer";
            mManufacturers.Add(manu);

            manufacturersUpdates.Enqueue(() =>
                {
                    mParent.AddManufacturer(manu);
                });
        }
Пример #2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            ManufacturerItem manu = new ManufacturerItem();

            manu.id            = mManufacturers.Count == 0 ? 0 : mManufacturers.Max(x => x.id) + 1;
            manu.uidisplayname = "New manufacturer";
            mManufacturers.Add(manu);

            manufacturersUpdates.Enqueue(() =>
            {
                mParent.AddManufacturer(manu);
            });
        }
Пример #3
0
        public void ChangemanufacturerID(int oldID, int newID)
        {
            ManufacturerItem manuf = jsonBase.manufacturers.First(x => x.id == oldID);

            TraverseProducts((product) =>
            {
                if (product.manufacturerid == oldID)
                {
                    product.manufacturerid = newID;
                }
            });

            manuf.id = newID;
        }
Пример #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button           b     = sender as Button;
            ManufacturerItem manuf = b.DataContext as ManufacturerItem;

            int idx = mManufacturers.IndexOf(manuf);

            manufacturersUpdates.Enqueue(() => mParent.RemoveManufacturer(manuf.id));
            if (idx < mManufacturers.Count - 1)
            {
                ManufacturerItem lastManufacturer = mManufacturers.Last();
                manufacturersUpdates.Enqueue(() =>
                {
                    mParent.ChangemanufacturerID(lastManufacturer.id, manuf.id);
                });
                lastManufacturer.id = manuf.id;
            }
            mManufacturers.RemoveAt(idx);
        }
Пример #5
0
        public void RemoveManufacturer(int manufID)
        {
            ManufacturerItem manuf = jsonBase.manufacturers.First(x => x.id == manufID);

            for (int i = 0; i < jsonBase.elements.Count; i++)                           //izby
            {
                for (int j = 0; j < jsonBase.elements[i].child.Count; j++)              //Typ
                {
                    for (int k = 0; k < jsonBase.elements[i].child[j].child.Count; k++) //Typ Typ
                    {
                        for (int l = jsonBase.elements[i].child[j].child[k].products.Count - 1; l >= 0; l--)
                        {
                            if (jsonBase.elements[i].child[j].child[k].products[l].manufacturerid == manufID)
                            {
                                jsonBase.elements[i].child[j].child[k].products.RemoveAt(l);
                            }
                        }
                    }
                }
            }

            jsonBase.manufacturers.Remove(manuf);
        }
Пример #6
0
 public void AddManufacturer(ManufacturerItem manuf)
 {
     jsonBase.manufacturers.Add(manuf);
 }
Пример #7
0
 public void AddManufacturer(ManufacturerItem manuf)
 {
     jsonBase.manufacturers.Add(manuf);
 }