private void Button_Click(object sender, RoutedEventArgs e)
        {
            supp.CompanyName = companyName.Text.ToString();
            supp.Address     = address.Text.ToString();
            supp.City        = city.Text.ToString();
            supp.Email       = email.Text.ToString();
            supp.PostalCode  = postalCode.Text.ToString();
            supp.Country     = country.Text.ToString();
            supp.Phone       = phone.Text.ToString();
            supp.HomePage    = homePage.Text.ToString();


            if (supp.CompanyName.IsNullOrEmpty())
            {
                System.Windows.MessageBox.Show("Nazwa firmy jest pusta.");
                return;
            }
            if (supp.Address.IsNullOrEmpty())
            {
                System.Windows.MessageBox.Show("Adres jest pusty.");
                return;
            }
            if (supp.City.IsNullOrEmpty())
            {
                System.Windows.MessageBox.Show("Miasto jest puste.");
                return;
            }
            if (!IsValidEmail(supp.Email))
            {
                System.Windows.MessageBox.Show("Mail jest niepoprawny");
                return;
            }
            supp.Add();
            this.Close();
        }
예제 #2
0
        public override void SetModel(dynamic entity)
        {
            Projects data = (Projects)entity;

            BindingFromModel(data, this);
            ProjectContract.Query(data.Id);

            if (data.SupplierTranscationItem.Any())
            {
                foreach (var row in data.SupplierTranscationItem)
                {
                    SuppliersViewModel model = new SuppliersViewModel();
                    model.ProjectId      = row.ProjectId;
                    model.PlaceofReceipt = row.PlaceofReceipt;

                    if (row.ManufacturersBussinessItems != null)
                    {
                        model.ManufacturersName     = row.ManufacturersBussinessItems.Manufacturers.Name;
                        model.TicketPeriod          = row.ManufacturersBussinessItems.TicketPeriod.Name;
                        model.MaterialCategories    = row.ManufacturersBussinessItems.MaterialCategories.Name;
                        model.PaymentTypeName       = row.ManufacturersBussinessItems.PaymentTypes.PaymentTypeName;
                        model.TranscationCategories = row.ManufacturersBussinessItems.TranscationCategories.Name;
                    }

                    model.SetModel(row.ManufacturersBussinessItems);
                    Suppliers.Add(model);
                }
            }
        }
예제 #3
0
        private void UpdateSuppliers()
        {
            var oldSelectedSupplier = _selectedSupplier;

            Suppliers.Clear();
            Suppliers.Add(new SupplierVM {
                Model = new Supplier {
                    ID = -1, Name = "All"
                }
            });

            using (var context = new ERPContext())
            {
                var suppliersFromDatabase = context.Suppliers.Where(supplier => !supplier.Name.Equals("-")).OrderBy(supplier => supplier.Name);
                foreach (
                    var supplier in
                    suppliersFromDatabase.Where(supplier => supplier.IsActive.Equals(_isSupplierActiveChecked)))
                {
                    Suppliers.Add(new SupplierVM {
                        Model = supplier
                    });
                }
            }

            UpdateSelectedSupplier(oldSelectedSupplier);
        }
예제 #4
0
        public void UpdateSuppliers()
        {
            var oldSelectedSupplier = _selectedSupplier;

            Suppliers.Clear();
            var allSupplier = new Supplier {
                ID = -1, Name = "All"
            };

            Suppliers.Add(new SupplierVM {
                Model = allSupplier
            });
            using (var context = new ERPContext())
            {
                var suppliersFromDatabase = context.Suppliers.Where(supplier => !supplier.Name.Equals("-")).OrderBy(supplier => supplier.Name);
                foreach (var supplier in suppliersFromDatabase)
                {
                    Suppliers.Add(new SupplierVM {
                        Model = supplier
                    });
                }
            }

            UpdateSelectedSupplier(oldSelectedSupplier);
        }
예제 #5
0
        public void AddSupplierToCategory(long supplier, Guid category)
        {
            if (Suppliers.ContainsKey(supplier))
            {
                var categoryId = Suppliers[supplier];
                if (CategoriesById.ContainsKey(categoryId))
                {
                    var c = GetCategoryByCategoryId(categoryId);
                    c.Suppliers.Remove(supplier);
                }

                Suppliers[supplier] = category;
            }
            else
            {
                Suppliers.Add(supplier, category);
            }

            if (CategoriesById.ContainsKey(category))
            {
                GetCategoryByCategoryId(category).Suppliers.Add(supplier);
            }

            OnCategoryUpdated(GetCategoryByCategoryId(category), supplier);
        }
예제 #6
0
        async Task ExecuteLoadItemsCommand()
        {
            try
            {
                Stores.Clear();
                var palletMaster = await DataStore.GetPalletMaterDataAsync();

                foreach (var item in palletMaster.Stores)
                {
                    Stores.Add(item);
                }

                Status.Clear();
                foreach (var item in palletMaster.Status)
                {
                    Status.Add(item);
                }

                Categories.Clear();
                foreach (var item in palletMaster.Categories)
                {
                    Categories.Add(item);
                }

                Wrappers.Clear();
                foreach (var item in palletMaster.Wrappers)
                {
                    Wrappers.Add(item);
                }

                Shippers.Clear();
                foreach (var item in palletMaster.Shippers)
                {
                    Shippers.Add(item);
                }

                Suppliers.Clear();
                foreach (var item in palletMaster.Suppliers)
                {
                    Suppliers.Add(item);
                }

                Builders.Clear();
                foreach (var item in palletMaster.Builders)
                {
                    Builders.Add(item);
                }

                PalletTypes.Clear();
                foreach (var item in palletMaster.PalletTypes)
                {
                    PalletTypes.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
예제 #7
0
 void GetSupplier()
 {
     Suppliers.Clear();
     foreach (var item in _ServiceProxy.GetSuppliers())
     {
         Suppliers.Add(item);
     }
 }
예제 #8
0
 protected override void Constructing(Product entity)
 {
     base.Constructing(entity);
     foreach (var item in entity.Suppliers)
     {
         Suppliers.Add(new SupplierDTO(item));
     }
 }
예제 #9
0
        public virtual void UpdateProductsAndSuppliersByIds(ISession dbSession, string productsIds, string suppliersIds)
        {
            var productsListRaw = (productsIds ?? "").Split(',').Select(s => {
                uint itemId = 0;
                uint.TryParse(s, out itemId);
                return(itemId);
            }).Where(s => s != 0).ToList();

            foreach (var item in productsListRaw)
            {
                if (!Products.Select(s => s.Product.Id).Any(s => s == item))
                {
                    var baseItem = dbSession.Query <Product>().First(s => s.Id == item);
                    var newItem  = new PromotionProduct {
                        Promotion = this,
                        Product   = baseItem
                    };
                    dbSession.Save(newItem);
                    Products.Add(newItem);
                }
            }

            var itemsToDelete_Products = Products.Where(s => !productsListRaw.Any(f => f == s.Product.Id)).ToList();

            itemsToDelete_Products.ForEach(s => Products.Remove(s));

            if (SuppliersType == SuppliersType.All)
            {
                Suppliers.Clear();
            }
            else
            {
                var suppliersListRaw = (suppliersIds ?? "").Split(',').Select(s => {
                    uint itemId = 0;
                    uint.TryParse(s, out itemId);
                    return(itemId);
                }).Where(s => s != 0).ToList();

                foreach (var item in suppliersListRaw)
                {
                    if (!Suppliers.Select(s => s.Supplier.Id).Any(s => s == item))
                    {
                        var baseItem = dbSession.Query <Supplier>().First(s => s.Id == item);
                        var newItem  = new PromotionSupplier {
                            Promotion = this,
                            Supplier  = baseItem
                        };
                        dbSession.Save(newItem);
                        Suppliers.Add(newItem);
                    }
                }

                var itemsToDelete_Suppliers = Suppliers.Where(s => !suppliersListRaw.Any(f => f == s.Supplier.Id)).ToList();
                itemsToDelete_Suppliers.ForEach(s => Suppliers.Remove(s));
            }

            dbSession.Save(this);
        }
예제 #10
0
        async Task ExecuteLoadSuppliersCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Geocoder geoCoder = new Geocoder();
                Suppliers.Clear();
                SupplierPins.Clear();
                var suppliers = await SupplierDataStore.GetItemsAsync(true);

                foreach (var supplier in suppliers)
                {
                    if (supplier.Latitude == 0 && supplier.Longitude == 0)
                    {
                        var approximateLocations = await geoCoder.GetPositionsForAddressAsync(supplier.Address);

                        foreach (var position in approximateLocations)
                        {
                            supplier.Latitude  = position.Latitude;
                            supplier.Longitude = position.Longitude;
                            break;
                        }
                    }

                    var distance = Distance(UserPosition.Latitude, UserPosition.Longitude, supplier.Latitude, supplier.Longitude, 'K');

                    if (distance <= MapRadius)
                    {
                        Suppliers.Add(supplier);

                        SupplierPins.Add(new CustomPin
                        {
                            Type     = PinType.Place,
                            Position = new Position(supplier.Latitude, supplier.Longitude),
                            Label    = supplier.Name,
                            Address  = supplier.Address,
                            Color    = Color.Red,
                            Opacity  = 100
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #11
0
        IEnumerable <Supplier> InsertInternal(IDictionary <string, object> newValue)
        {
            var dataItem = new Supplier();

            Update(dataItem, newValue);
            dataItem.SupplierID = Suppliers.Last().SupplierID + 1;
            Suppliers.Add(dataItem);
            return(Suppliers);
        }
예제 #12
0
        public virtual void SaveSupplier(string fixme)
        {
            if (SelectedSupplier.SupplierId <= 0)
            {
                Supplier supplier = new Supplier()
                {
                };

                Suppliers.Add(supplier);
            }
        }
예제 #13
0
 private void UpdateSuppliers()
 {
     using (var context = new ERPContext())
     {
         Suppliers.Clear();
         var suppliersFromDatabase = context.Suppliers.OrderBy(supplier => supplier.Name);
         foreach (var supplier in suppliersFromDatabase)
         {
             Suppliers.Add(new SupplierVM {
                 Model = supplier
             });
         }
     }
 }
예제 #14
0
        private void ShowSuppliers()
        {
            foreach (ListItem supplierListItem in supplierListItems)
            {
                var supplier = new Supplier
                {
                    Name   = supplierListItem["Title"].ToString(),
                    DUNS   = supplierListItem["DUNS"].ToString(),
                    Rating = Convert.ToDouble(supplierListItem["Rating"]),
                };
                Suppliers.Add(supplier);
            }

            NumberOfSuppliersFound = Suppliers.Count.ToString();
            this.Cursor            = Cursors.Arrow;
        }
예제 #15
0
        /// <summary>
        /// Добавляет поставку в список поставок
        /// </summary>
        /// <param name="supply"></param>
        public void AddSupply(Supply supply)
        {
            if (supply is null)
            {
                throw new ArgumentNullException(nameof(supply), "Поставка не может быть null.");
            }

            Products.AddRange(supply.Products);

            if (GetDuplicateSupplier(supply.Supplier) == null)
            {
                Suppliers.Add(supply.Supplier);
            }

            Supplies.Add(supply);
        }
예제 #16
0
        public void UpdateSuppliers()
        {
            var oldSelectedSupplier = _selectedSupplier;

            Suppliers.Clear();
            using (var context = new ERPContext())
            {
                var suppliers = context.Suppliers.Where(e => !e.Name.Equals("-"));
                foreach (var supplier in suppliers)
                {
                    Suppliers.Add(supplier);
                }
            }

            UpdateSelectedSupplier(oldSelectedSupplier);
        }
예제 #17
0
 private void UpdateSuppliers()
 {
     Suppliers.Clear();
     using (var context = new ERPContext())
     {
         var suppliersFromDatabase = context.Suppliers.Where(
             supplier => !supplier.Name.Equals("-") && supplier.IsActive)
                                     .OrderBy(supplier => supplier.Name);
         foreach (var supplier in suppliersFromDatabase)
         {
             Suppliers.Add(new SupplierVM {
                 Model = supplier
             });
         }
     }
 }
예제 #18
0
        void proxy_GetSuppliersListItemsCompleted(object sender, GetListItemsCompletedEventArgs e)
        {
            XNamespace rowsetNamespace = "#RowsetSchema";
            var        query           = from x in e.Result.Descendants()
                                         where x.Name == rowsetNamespace + "row"
                                         select x.Attribute("ows_SupplierLookup").Value;

            foreach (var supplierLookupValue in query)
            {
                Suppliers.Add(supplierLookupValue);
            }

            XElement rsData = e.Result.Descendants().First <XElement>(f => f.Name.LocalName == "data");

            NumberOfSuppliersFound = rsData.Attributes("ItemCount").First().Value;
        }
예제 #19
0
        public void AddSupplier(Supplier supplier)
        {
            if (supplier == null)
            {
                throw new ArgumentNullException(nameof(supplier));
            }

            if (Suppliers == null)
            {
                Suppliers = new List <Supplier>();
            }

            if (SupplierExists(supplier.Name))
            {
                throw new SupplierExistsException();
            }

            Suppliers.Add(supplier);
        }
예제 #20
0
        private void UpdateSuppliers()
        {
            var oldSelectedSupplier = _selectedSupplier;

            Suppliers.Clear();
            Suppliers.Add(new SupplierVM {
                Model = new Supplier {
                    ID = -1, Name = "All"
                }
            });
            using (var context = new ERPContext())
            {
                var suppliers = context.Suppliers.Where(e => !e.Name.Equals("-")).ToList();
                foreach (var supplier in suppliers)
                {
                    Suppliers.Add(new SupplierVM {
                        Model = supplier
                    });
                }
            }

            UpdateSelectedSupplier(oldSelectedSupplier);
        }
예제 #21
0
        private bool Submit()
        {
            bool retValue;

            retValue = true;
            retValue = IsValidSupplier();
            if (!retValue)
            {
                return(false);
            }
            SupplierRepository supplierRepository = new SupplierRepository();

            if (SelectedSupplier != null)
            {
                if (SelectedSupplier.SupplierId == -1)
                {
                    int supplierID = supplierRepository.saveSupplier(SelectedSupplier, "I");
                    SelectedSupplier.SupplierId = supplierID;
                    Suppliers.Add(SelectedSupplier);
                    MessageBox.Show("Supplier added successfully", "OPS", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                else
                {
                    int supplierID = supplierRepository.saveSupplier(SelectedSupplier, "U");
                    MessageBox.Show("Supplier updated successfully", "OPS", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                EnrichControls();
            }

            NotifyPropertyChanged("SelectedSupplier");
            NotifyPropertyChanged("Suppliers");
            Add();

            return(true);
        }
예제 #22
0
        public void Query(Guid ProjectId)
        {
            try
            {
                var QueryResult = _projectcontroller.Query(p => p.Id == ProjectId);

                if (!QueryResult.HasError)
                {
                    var data = QueryResult.Result.SingleOrDefault();
                    BindingFromModel(data, this);

                    if (data.ClientId.HasValue)
                    {
                        Client.QueryModel(data.ClientId.Value);
                    }

                    if (data.SupplierTranscationItem.Any())
                    {
                        Suppliers.Clear();
                        foreach (var row in data.SupplierTranscationItem)
                        {
                            SuppliersViewModel model = new SuppliersViewModel();
                            try
                            {
                                model.ProjectId             = row.ProjectId;
                                model.PlaceofReceipt        = row.PlaceofReceipt;
                                model.ManufacturersName     = row.ManufacturersBussinessItems.Manufacturers.Name;
                                model.TicketPeriod          = row.ManufacturersBussinessItems.TicketPeriod.Name;
                                model.MaterialCategories    = row.ManufacturersBussinessItems.MaterialCategories.Name;
                                model.PaymentTypeName       = row.ManufacturersBussinessItems.PaymentTypes.PaymentTypeName;
                                model.TranscationCategories = row.ManufacturersBussinessItems.TranscationCategories.Name;
                                model.SetModel(row.ManufacturersBussinessItems);
                            }
                            catch (Exception ex)
                            {
                                setErrortoModel(model, ex);
                            }

                            if (!model.HasError)
                            {
                                Suppliers.Add(model);
                            }
                        }
                    }

                    if (data.ProjectContract.Any())
                    {
                        ProjectContract.Clear();
                        foreach (var row in data.ProjectContract)
                        {
                            ProjectContractViewModel model = new ProjectContractViewModel();
                            model.SetModel(row);
                            ProjectContract.Add(model);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                setErrortoModel(this, ex);
            }
        }
예제 #23
0
        static void TestSerialization()
        {
            string testName = "Serialization";
            Begin(testName);
            Suppliers sups = new Suppliers();
            sups.Add(Suppliers.CreateSupplier(21, "MyCompany", "Mark", "CEO", "1234 Here St. PO Box 123", "Dallas", "Texas", "12344", "USA", "555123123",
                    "1231231234", "www.MyCompany.com", SupplierTypes.Supply));
            sups.Add(Suppliers.CreateSupplier(22, "ThisCompany", "Bob", "Lackey", "1234 There", "Washington", "Maryland", "1234", "ASU", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Product));
            sups.Add(Suppliers.CreateSupplier(23, "phifzer", "Bob", "Lackey", "1234 There", "Here", "Markland", "1234", "BBB", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Service));
            sups.Add(Suppliers.CreateSupplier(24, "phisher", "Bob", "Lackey", "1234 There", "There", "Texas", "1234", "UAS", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Service));
            sups.Add(Suppliers.CreateSupplier(25, "phish", "Bob", "Lackey", "1234 There", "Anywhere", "Maryland", "1234", "ASU", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Product));
            sups.Add(Suppliers.CreateSupplier(26, "petunia", "Bob", "Lackey", "1234 There", "Anywher", "Maryland", "1234", "ASU", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Product));
            ShowCollection(sups.GetEnumerator());

            #region Serialize suppliers collection
            Test("Serialize suppliers collection");
            try
            {
                using (FileStream fs = new FileStream("SerializedSuppliers.xml", FileMode.Create,
                    FileAccess.Write, FileShare.None))
                {
                    SoapFormatter sf = new SoapFormatter();
                    sf.Serialize(fs, sups);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("Serialization Complete");
            #endregion

            #region Restore the Suppliers
            Test("Restore the Suppliers");
            sups = null;
            try
            {
                using (FileStream fs = new FileStream("SerializedSuppliers.xml", FileMode.Open,
                    FileAccess.Read, FileShare.None))
                {
                    SoapFormatter sf = new SoapFormatter();
                    sups = (Suppliers)sf.Deserialize(fs);
                    //showCollection(sups.GetEnumerator());
                    //foreach (int i in sups)
                    //{
                    //    Console.WriteLine(i.ToString());
                    //}
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            ShowCollection(sups.GetEnumerator());
            #endregion


            End(testName);
            Wait();
        }
예제 #24
0
        static void TestSuppliers()
        {
            string testName = "Suppliers";
            Begin(testName);

            #region Add Method and IEnumerable
            Test("Add Method and IEnumerable");
            Suppliers sups = new Suppliers();
            sups.Add(Suppliers.CreateSupplier(21, "MyCompany", "Mark", "CEO", "1234 Here St. PO Box 123", "Dallas", "Texas", "12344", "USA", "555123123",
                    "1231231234", "www.MyCompany.com", SupplierTypes.Supply));
            sups.Add(Suppliers.CreateSupplier(22, "ThisCompany", "Bob", "Lackey", "1234 There", "Washington", "Maryland", "1234", "ASU", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Product));
            sups.Add(Suppliers.CreateSupplier(23, "phifzer", "Bob", "Lackey", "1234 There", "Here", "Markland", "1234", "BBB", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Service));
            sups.Add(Suppliers.CreateSupplier(24, "phisher", "Bob", "Lackey", "1234 There", "There", "Texas", "1234", "UAS", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Service));
            sups.Add(Suppliers.CreateSupplier(25, "phish", "Bob", "Lackey", "1234 There", "Anywhere", "Maryland", "1234", "ASU", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Product));
            sups.Add(Suppliers.CreateSupplier(26, "petunia", "Bob", "Lackey", "1234 There", "Anywher", "Maryland", "1234", "ASU", "1231231234",
                "1231231234", "www.thiscompany.com", SupplierTypes.Product));

            //OR Using the Static methods in teh DataAccess.Da class:
            //****if you use this the dupes test wont return and error since i have it looking for a specific object.****
            //sups.Add(new Supplier(DataAccess.DA.GetSupplier(21)));
            //sups.Add(new Supplier(DataAccess.DA.GetSupplier(22)));
            //sups.Add(new Supplier(DataAccess.DA.GetSupplier(23)));
            //sups.Add(new Supplier(DataAccess.DA.GetSupplier(24)));
            //sups.Add(new Supplier(DataAccess.DA.GetSupplier(25)));
            //sups.Add(new Supplier(DataAccess.DA.GetSupplier(26)));
            ShowCollection(sups.GetEnumerator());

            #endregion

            #region Count Method
            Test("Count Method");
            Console.WriteLine(sups.Count.ToString());
            #endregion

            #region Type Checking in Add Method
            Test("Type checking in Add method");
            try
            {
                sups.Add("String Instance");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            #endregion

            #region RemoveAt
            Test("RemoveAt");
            for (int i = 0; i < 3; i++) 
                sups.RemoveAt(0);
            ShowCollection(sups.GetEnumerator());
            #endregion

            #region Insert
            Test("Insert");
            sups.Insert(0, Suppliers.CreateSupplier(50001, "MyCompany", "Mark", "CEO", "1234 Here St. PO Box 123", "Dallas", "Texas", "12344", "USA", "555123123",
                    "1231231234", "www.MyCompany.com", SupplierTypes.Supply));
            ShowCollection(sups.GetEnumerator());
            #endregion

            #region Insert Detects Duplicates
            Test("Insert Detect Duplicates");
            try
            {
                sups.Insert(2, Suppliers.CreateSupplier(26, "petunia", "Bob", "Lackey", "1234 There", "Anywher", "Maryland", "1234", "ASU", "1231231234",
                    "1231231234", "www.thiscompany.com", SupplierTypes.Product));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            #endregion

            #region InvalidIndex
            Test("Invalid Index");
            try
            {
                Console.WriteLine(sups[10].ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            #endregion

            #region Type Checking in Indexer
            Test("Type Checking in Indexer");
            try
            {
                sups[1] = "String Instance";
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            #endregion

            #region Indexer Detects Duplicates
            Test("Indexer Detects Duplicates");
            try
            {
                sups[2] = Suppliers.CreateSupplier(26, "petunia", "Bob", "Lackey", "1234 There", "Anywher", "Maryland", "1234", "ASU", "1231231234",
                    "1231231234", "www.thiscompany.com", SupplierTypes.Product);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            #endregion

            #region CopyTo
            Test("CopyTo");
            int x = sups.Count;
            Supplier[] myArray = new Supplier[x];
            sups.CopyTo(myArray);
            ShowCollection(myArray.GetEnumerator());
            #endregion

            #region GetTypeEnumerator
            Test("GetTypeEnumerator");
            ShowCollection(sups.GetTypeEnumerator(SupplierTypes.Product));           
            #endregion

            #region GetReverseEnumerator
            Test("GetReverseEnumerator");
            ShowCollection(sups.GetReverseEnumerator());
            #endregion

            #region Sort on TypeCompanyName
            Test("Sort on TypeCompanyName");
            sups.Sort(Supplier.GetSortByTypeCompanyName());
            ShowCollection(sups.GetEnumerator());
            #endregion

            #region Sort on CountryRegionCity
            Test("Sort on CountryRegionCity");
            sups.Sort(Supplier.GetSortByCountryRegionCity());
            foreach (Supplier s in sups)
                Console.WriteLine("ID: {0,5}\tCountry: {1}\tRegion: {2,10}\tCity: {3}", s.ID.ToString(), s.Country, s.Region, s.City);
            #endregion

            #region IComparable
            Test("IComparable");
            sups.Sort();
            ShowCollection(sups.GetEnumerator());
            #endregion

            End(testName);
            Wait();
        }
예제 #25
0
 public virtual void AddSupplier(Supplier supplier)
 {
     Suppliers.Add(supplier);
 }
 public void AddSupplier()
 {
     SupplierRepository.Create(Supplier);
     Suppliers.Add(Supplier);
 }
        public void Initialize()
        {
            var createResult = Database.Creator.CreateIfNotExists();

            var suppliersList = new List <Supplier>
            {
                new Supplier()
                {
                    Name = "Bananas-R-Us"
                },
                new Supplier()
                {
                    Name = "Plums-R-Us"
                }
            };

            var productsList = new List <Product>()
            {
                new Product()
                {
                    Name = "Banana", Price = 4.75
                },
                new Product()
                {
                    Name = "Plum", Price = 3.25
                },
            };

            foreach (Supplier s in suppliersList)
            {
                Suppliers.Add(s);
            }

            var count = 0;

            foreach (Product p in productsList)
            {
                p.SupplierId = suppliersList[count++].Id;
                Products.Add(p);
            }

            var productOneId = productsList[0].Id;
            var productTwoId = productsList[1].Id;

            var partList = new List <Part>()
            {
                new Part()
                {
                    Name = "Bolt", Cost = 1.95, ProductKey = productOneId
                },
                new Part()
                {
                    Name = "Wrench", Cost = 5.95, ProductKey = productOneId
                },
                new Part()
                {
                    Name = "Hammer", Cost = 9.99, ProductKey = productOneId
                },

                new Part()
                {
                    Name = "Screw", Cost = 0.95, ProductKey = productTwoId
                },
                new Part()
                {
                    Name = "Drill", Cost = 23.55, ProductKey = productTwoId
                },
                new Part()
                {
                    Name = "Air Compressor", Cost = 99.95, ProductKey = productTwoId
                }
            };

            foreach (var part in partList)
            {
                Parts.Add(part);
            }
        }
예제 #28
0
 static Banana()
 {
     Suppliers.Add("Company B");
 }
예제 #29
0
        private void InitialShopService()
        {
            var supplier1 = new Supplier(1, "Chanel");

            Suppliers.Add(supplier1);

            var shirtCategory = new Category
            {
                CategoryId   = 1,
                CategoryName = "Shirt",
            };

            var tShirtCategory = new Category
            {
                CategoryId       = 2,
                CategoryName     = "TShirt",
                ParentCategoryId = 1,
                ParentCategory   = shirtCategory
            };

            var dressShirtCategory = new Category
            {
                CategoryId       = 3,
                CategoryName     = "Dress shirt",
                ParentCategoryId = 1,
                ParentCategory   = shirtCategory,
            };

            Categories.Add(shirtCategory);
            Categories.Add(tShirtCategory);
            Categories.Add(dressShirtCategory);

            var tShirt = new Product
            {
                ProductId       = 1,
                ProductName     = "TShirt polo special",
                Category        = tShirtCategory,
                Supplier        = supplier1,
                ProductVariants = new List <ProductVariant>
                {
                    new ProductVariant
                    {
                        ProductVariantId  = 1,
                        ProductAttributes = new List <ProductAttribute>
                        {
                            new ProductAttribute
                            {
                                ProductAttributeName  = "Size",
                                ProductAttributeValue = "XL",
                            },
                            new ProductAttribute
                            {
                                ProductAttributeName  = "Color",
                                ProductAttributeValue = "Black"
                            }
                        },
                        BuyPrice     = 6,
                        SellPrice    = 12,
                        UnitsInStock = 10
                    },
                    new ProductVariant
                    {
                        ProductVariantId  = 2,
                        ProductAttributes = new List <ProductAttribute>
                        {
                            new ProductAttribute
                            {
                                ProductAttributeName  = "Size",
                                ProductAttributeValue = "M",
                            },
                            new ProductAttribute
                            {
                                ProductAttributeName  = "Color",
                                ProductAttributeValue = "White"
                            }
                        },
                        BuyPrice     = 6,
                        SellPrice    = 12,
                        UnitsInStock = 20
                    }
                }
            };

            var dress = new Product
            {
                ProductId   = 3,
                ProductName = "Yellow dress shirt with diamond",
                Category    = dressShirtCategory,
                Supplier    = supplier1,

                ProductVariants = new List <ProductVariant>
                {
                    new ProductVariant
                    {
                        ProductVariantId  = 3,
                        ProductAttributes = new List <ProductAttribute>
                        {
                            new ProductAttribute
                            {
                                ProductAttributeName  = "Size",
                                ProductAttributeValue = "S",
                            },
                            new ProductAttribute
                            {
                                ProductAttributeName  = "Color",
                                ProductAttributeValue = "Pink"
                            }
                        },
                        BuyPrice     = 10,
                        SellPrice    = 20,
                        UnitsInStock = 50
                    },
                    new ProductVariant
                    {
                        ProductVariantId  = 4,
                        ProductAttributes = new List <ProductAttribute>
                        {
                            new ProductAttribute
                            {
                                ProductAttributeName  = "Size",
                                ProductAttributeValue = "XS",
                            },
                            new ProductAttribute
                            {
                                ProductAttributeName  = "Color",
                                ProductAttributeValue = "Yellow"
                            }
                        },
                        BuyPrice     = 15,
                        SellPrice    = 30,
                        UnitsInStock = 50
                    }
                }
            };


            Products.Add(tShirt);
            Products.Add(dress);
        }
예제 #30
0
 private void OnSupplierAdded(Supplier obj)
 {
     Suppliers.Add(obj);
     SelectedSupplier = obj;
 }