Ejemplo n.º 1
0
        public bool AddNewCartonBox(string boxNumber)
        {
            var existingCartonBox = (from cartonbox in this.Order.CartonBoxes
                                     where cartonbox.Number == boxNumber
                                     select cartonbox).FirstOrDefault();

            if (existingCartonBox == null)
            {
                CartonBox newCartonBox = new CartonBox();
                newCartonBox.Number = boxNumber;
                newCartonBox.OrderID = Order.OrderID;
                this.Order.CartonBoxes.Add(newCartonBox);

                OrderManagerDBEntities newManager = new OrderManagerDBEntities();
                newManager.CartonBoxes.Add(newCartonBox);
                newManager.SaveChanges();
                newManager.Dispose();

                return true;
            }

            return false;
        }
Ejemplo n.º 2
0
        public Color CreateNewColor(string colorName)
        {
            Color newColor = new Color();
            newColor.Name = colorName;

            OrderManagerDBEntities newManager = new OrderManagerDBEntities();
            newManager.Colors.Add(newColor);
            newManager.SaveChanges();
            newManager.Dispose();

            Colors = new ObservableCollection<Color>(dbContext.Colors.ToList());

            newColor = Colors.Where(a => a.Name == colorName)
                             .Select(a => a).First();

            return newColor;
        }
Ejemplo n.º 3
0
        public SubMaterial CreateNewSubMaterial(string subMaterialName, ProductMaterial material)
        {
            SubMaterial newSubMaterial = AvailableSubMaterials[material.MaterialName.Name].Where(a => a.Name == subMaterialName)
                                                                                            .Select(a => a).FirstOrDefault();

            if (newSubMaterial == null)
            {
                OrderManagerDBEntities newManager = new OrderManagerDBEntities();
                newSubMaterial = new SubMaterial();
                newSubMaterial.Name = subMaterialName;
                newSubMaterial.MaterialNameID = material.MaterialNameID;
                newManager.SubMaterials.Add(newSubMaterial);
                newManager.SaveChanges();
                newManager.Dispose();

                if (AvailableSubMaterials.ContainsKey(material.MaterialName.Name))
                {
                    PopulateAvailableSubMaterials();
                    newSubMaterial = AvailableSubMaterials[material.MaterialName.Name].Where(a => a.Name == subMaterialName)
                                                                                        .Select(a => a).First();
                }
            }

            return newSubMaterial;
        }
Ejemplo n.º 4
0
        public AssetName CreateNewAssetName(string assetName)
        {
            AssetName newAssetName = new AssetName();
            newAssetName.Name = assetName;

            OrderManagerDBEntities newManager = new OrderManagerDBEntities();
            newManager.AssetNames.Add(newAssetName);
            newManager.SaveChanges();
            newManager.Dispose();

            AvailableAssetNames = new ObservableCollection<AssetName>(dbContext.AssetNames.ToList());

            newAssetName = AvailableAssetNames.Where(a => a.Name == assetName)
                                          .Select(a => a).First();

            return newAssetName;
        }
Ejemplo n.º 5
0
        //Create a new product
        public MaterialName CreateNewMaterial(string newMaterialName)
        {
            //Check whether the material is already existing
            MaterialName newMaterial = AvailableMaterials.Where(a => a.Name == newMaterialName)
                       .Select(a => a).FirstOrDefault();

            if (newMaterial == null)
            {
                OrderManagerDBEntities newManager = new OrderManagerDBEntities();
                newMaterial = new MaterialName();
                newMaterial.Name = newMaterialName;
                newManager.MaterialNames.Add(newMaterial);
                newManager.SaveChanges();
                newManager.Dispose();

                AvailableMaterials = new ObservableCollection<MaterialName>(dbContext.MaterialNames.ToList()); //Refresh

                newMaterial = AvailableMaterials.Where(a => a.Name == newMaterialName)
                              .Select(a => a).First();
            }
            return newMaterial;
        }
Ejemplo n.º 6
0
        public ProductExtraCostType CreateNewExtraCostType(string extraCostName)
        {
            ProductExtraCostType newCostType = AvailableExtraCostTypes.Where(a => a.TypeName == extraCostName)
                       .Select(a => a).FirstOrDefault();

            if (newCostType == null)
            {
                OrderManagerDBEntities newManager = new OrderManagerDBEntities();
                newCostType = new ProductExtraCostType();
                newCostType.TypeName = extraCostName;
                newManager.ProductExtraCostTypes.Add(newCostType);
                newManager.SaveChanges();
                newManager.Dispose();
                AvailableExtraCostTypes = new ObservableCollection<ProductExtraCostType>(dbContext.ProductExtraCostTypes.ToList()); //Refresh
                newCostType = AvailableExtraCostTypes.Where(a => a.TypeName == extraCostName)
                              .Select(a => a).First();
            }
            return newCostType;
        }
Ejemplo n.º 7
0
        //Create a new product
        public ProductName CreateNewProduct(string newProductName, string styleID)
        {
            ProductName newProduct = new ProductName();
            newProduct.Name = newProductName;

            newProduct.StyleID = styleID;
            OrderManagerDBEntities newManager = new OrderManagerDBEntities();
            newManager.ProductNames.Add(newProduct);
            newManager.SaveChanges();
            newManager.Dispose();

            AvailableProducts = new ObservableCollection<ProductName>(dbContext.ProductNames.ToList());

            newProduct = AvailableProducts.Where(a => a.Name == newProductName)
                                          .Select(a => a).First();

            return newProduct;
        }
Ejemplo n.º 8
0
        public Company SaveNewCompany(Company company, string type)
        {
            OrderManagerDBEntities localContext = new OrderManagerDBEntities();
            try
            {
                var companyType = localContext.CompanyTypes.Where(c => c.Type == type).Select(c => c).FirstOrDefault();
                company.CompanyTypeID = companyType.CompanyTypeID;
                company.CompanyType = companyType;
                localContext.Companies.Add(company);
                localContext.SaveChanges();
                localContext.Dispose();
            }
            catch { throw; }
            Companies = new ObservableCollection<Company>(dbContext.Companies.ToList());
            Company newCompany = null;
            if (Companies != null)
            {
                newCompany = Companies.Where(c => (c.CompanyType.Type == company.CompanyType.Type && c.Name == company.Name)).Select(c => c).FirstOrDefault();
            }
            else return null;

            switch (company.CompanyType.Type)
            {
                case "Customer":
                    Customers = UpdateCompaniesCollection("Customer");
                    break;
                case "Agent":
                    Agents = UpdateCompaniesCollection("Agent");
                    break;
                case "Supplier":
                    Suppliers = UpdateCompaniesCollection("Supplier");
                    break;
            }
            return newCompany;
        }
Ejemplo n.º 9
0
        public PurchaseOrder CreateNewPurchaseOrder(Order order, Company supplier, string purchseOrderNumber)
        {
            PurchaseOrder newPO = new PurchaseOrder();
            newPO.PurchaseOrderNumber = purchseOrderNumber;
            newPO.SupplierID = supplier.CompanyID;
            newPO.OrderID = order.OrderID;
            newPO.PurchaseOrderStatusID = 1;

            OrderManagerDBEntities newManager = new OrderManagerDBEntities();
            newManager.PurchaseOrders.Add(newPO);
            newManager.SaveChanges();
            newManager.Dispose();

            newPO = GetPurchaseOrder(purchseOrderNumber);

            return newPO;
        }
Ejemplo n.º 10
0
        public ProductSize CreateNewProductSize(string newSize)
        {
            ProductSize newProductSize = new ProductSize();
            newProductSize.Size = newSize;

            OrderManagerDBEntities newManager = new OrderManagerDBEntities();
            newManager.ProductSizes.Add(newProductSize);
            newManager.SaveChanges();
            newManager.Dispose();

            ProductSizes = new ObservableCollection<ProductSize>(dbContext.ProductSizes.ToList());

            newProductSize = ProductSizes.Where(a => a.Size == newSize)
                                          .Select(a => a).First();

            return newProductSize;
        }
Ejemplo n.º 11
0
        public Country CreateNewCountry(string countryName)
        {
            Country country = new Country();
            country.Name = countryName;

            OrderManagerDBEntities newManager = new OrderManagerDBEntities();
            newManager.Countries.Add(country);
            newManager.SaveChanges();
            newManager.Dispose();

            Countries = new ObservableCollection<Country>(dbContext.Countries.ToList());

            country = Countries.Where(a => a.Name == countryName)
                                          .Select(a => a).First();

            return country;
        }