public void GetPartsInventoryView_ReturnsPartsAndAnyRelatedInventoryLocations()
        {
            Part[] parts =
            {
                new Part {
                    SKU = "sku1", Id = 1
                },
                new Part {
                    SKU = "sku2", Id = 2
                },
            };
            InventoryLocation[] inventoryLocations =
            {
                new InventoryLocation {
                    Part      = parts[0],
                    BinNumber = "Bin1",
                    Quantity  = 1
                },
            };

            var dataContext = new BDataContext <PartsSiteDataContext>();

            dataContext.SetOne("Parts", parts);
            dataContext.SetNext("Inventory Locations", inventoryLocations);

            var target  = new PartManagementRepository(dataContext);
            var results = target.GetPartsInventoryView("sku").OrderBy((p) => p.Sku).ToList();

            Assert.AreEqual(2, results.Count);
            Assert.AreEqual("sku1", results[0].Sku);
            Assert.AreEqual("Bin1", results[0].LocationBin);
            Assert.AreEqual(1, results[0].InventoryQuantity);
            Assert.AreEqual("sku2", results[1].Sku);
        }
        protected void machineGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedMachineID = int.Parse(machineGridView.SelectedRow.Cells[1].Text.ToString());

            var partManagementRepository = new PartManagementRepository();

            partGridView.DataSource = partManagementRepository.GetPartsByMachineId(selectedMachineID);
            partGridView.DataBind();
        }
        public void GetPartsByMachineId_ReturnsRelatedParts()
        {
            Part[] parts =
            {
                new Part {
                    Id = 1, SKU = "sku1"
                },
                new Part {
                    Id = 2, SKU = "sku2"
                },
                new Part {
                    Id = 3, SKU = "sku3"
                },
                new Part {
                    Id = 4, SKU = "sku4"
                },
            };
            Machine[] machines =
            {
                new Machine {
                    Id = 1111, ModelNumber = "mn1"
                },
                new Machine {
                    Id = 2222, ModelNumber = "mn2"
                },
            };
            MachinePart[] machineParts =
            {
                new MachinePart {
                    Machine = machines[0], Part = parts[0]
                },
                new MachinePart {
                    Machine = machines[0], Part = parts[1]
                },
                new MachinePart {
                    Machine = machines[1], Part = parts[2]
                },
                new MachinePart {
                    Machine = machines[1], Part = parts[3]
                },
            };

            var dataContext = new BDataContext <PartsSiteDataContext>();

            dataContext.SetOne("Parts", parts);
            dataContext.SetNext("Machines", machines);
            dataContext.SetNext("Machine Parts", machineParts);
            dataContext.SetNext("Inventory Locations", new InventoryLocation[] {});

            var target  = new PartManagementRepository(dataContext);
            var results = target.GetPartsByMachineId(1111).OrderBy((p) => p.Sku).ToList();

            Assert.AreEqual(2, results.Count);
            Assert.AreEqual("sku1", results[0].Sku);
            Assert.AreEqual("sku2", results[1].Sku);
        }
Esempio n. 4
0
        protected void MachineResultsGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var selectedMachineDepartmentId = int.Parse(MachineResultsGridView.DataKeys[e.RowIndex].Value.ToString());

            using (var partManagementRepository = new PartManagementRepository())
            {
                partManagementRepository.DeleteMachineDepartment(selectedMachineDepartmentId);
            }
            Update();
        }
Esempio n. 5
0
        protected void SupplierResultsGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int partSupplierId = int.Parse(SupplierResultsGridView.DataKeys[e.RowIndex].Value.ToString());

            using (var partManagementRepository = new PartManagementRepository())
            {
                partManagementRepository.DeletePartSupplier(partSupplierId);
                Update();
            }
        }
        protected void CategoryResultsGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedCategoryId = int.Parse(CategoryResultsGridView.DataKeys[CategoryResultsGridView.SelectedRow.RowIndex].Value.ToString());

            using (var partManagementRepository = new PartManagementRepository())
            {
                RelatedMachinesFound(new GenericEventArgs <IEnumerable <Machine> >
                {
                    PayLoad = partManagementRepository.GetMachinesByCategory(selectedCategoryId)
                });
            }
        }
        protected void MachineResultsGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selectedMachineId =
                int.Parse(MachineResultsGridView.DataKeys[MachineResultsGridView.SelectedIndex].Value.ToString());

            using (var partManagementRepository = new PartManagementRepository())
            {
                MachineSelected(new GenericEventArgs <Machine>
                {
                    PayLoad = partManagementRepository.GetMachine(selectedMachineId)
                });
            }
        }
 private void GoButton_Click(object sender, EventArgs eventArgs)
 {
     using (var partManagementRepository = new PartManagementRepository())
     {
         if (OnSuppliersFound != null)
         {
             SuppliersFound(new GenericEventArgs <IEnumerable <Supplier> >
             {
                 PayLoad = partManagementRepository.GetSuppliersByPartialName(SupplierSearchTextBox.Text)
             });
         }
     }
 }
Esempio n. 9
0
 private void GoButton_Click(object sender, EventArgs eventArgs)
 {
     using (var partManagementRepository = new PartManagementRepository())
     {
         if (OnMachinesFound != null)
         {
             MachinesFound(new GenericEventArgs <IEnumerable <Machine> >
             {
                 PayLoad =
                     partManagementRepository.GetMachinesByPartialModelNumber(MachineSearchTextBox.Text)
             });
         }
     }
 }
 private void GoButton_Click(object sender, EventArgs eventArgs)
 {
     using (var partManagementRepository = new PartManagementRepository())
     {
         if (OnCategoriesFound != null)
         {
             CategoriesFound(new GenericEventArgs <IEnumerable <Category> >
             {
                 PayLoad =
                     partManagementRepository.GetCategoriesByPartialName(CategorySearchTextBox.Text)
             });
         }
     }
 }
        protected void SupplierResultsGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selectedSupplierId = int.Parse(SupplierResultsGridView.DataKeys[SupplierResultsGridView.SelectedRow.RowIndex].Value.ToString());

            using (var partManagementRepository = new PartManagementRepository())
            {
                if (OnSupplierSelected != null)
                {
                    SupplierSelected(new GenericEventArgs <Supplier>
                    {
                        PayLoad = partManagementRepository.GetSupplier(selectedSupplierId)
                    });
                }
            }
        }
Esempio n. 12
0
        protected void ManufacturerResultsGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selectedManufacturerId = int.Parse(ManufacturerResultsGridView.DataKeys[ManufacturerResultsGridView.SelectedRow.RowIndex].Value.ToString());

            using (var partManagementRepository = new PartManagementRepository())
            {
                if (OnRelatedMachinesFound != null)
                {
                    MachineResultsReturned(new GenericEventArgs <IEnumerable <Machine> >
                    {
                        PayLoad =
                            partManagementRepository.GetMachinesByManufacturer(selectedManufacturerId)
                    });
                }
            }
        }
        void SearchMachineModelButton_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(searchMachineModelTextBox.Text) && searchMachineModelTextBox.Text.Length >= 3)
            {
                validationLabel.Text    = string.Empty;
                validationLabel.Visible = false;

                var partManagementRepository = new PartManagementRepository();
                machineGridView.DataSource = partManagementRepository.GetMachinesByModelNumber(searchMachineModelTextBox.Text);
                machineGridView.DataBind();
            }
            else
            {
                validationLabel.Text    = "Machine Model must contain at least three (3) alpha-numeric characters !";
                validationLabel.Visible = true;
            }
        }
Esempio n. 14
0
        void SearchSupplierNameButton_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(searchSupplierNameTextBox.Text) && searchSupplierNameTextBox.Text.Length >= 3)
            {
                validationLabel.Text    = string.Empty;
                validationLabel.Visible = false;

                var partManagementRepository = new PartManagementRepository();
                SupplierGridView.DataSource = partManagementRepository.GetSuppliersByName(searchSupplierNameTextBox.Text);
                SupplierGridView.DataBind();
            }
            else
            {
                validationLabel.Text    = "Supplier Name must contain at least three (3) alpha-numeric characters !";
                validationLabel.Visible = true;
            }
        }
        public void GetInventoryLocations_ReturnsInventoryLocationsRelatedToPart()
        {
            Part[] parts =
            {
                new Part {
                    SKU = "sku1", Id = 111
                },
                new Part {
                    SKU = "sku2", Id = 222
                },
            };
            InventoryLocation[] inventoryLocations =
            {
                new InventoryLocation {
                    Part      = parts[0],
                    BinNumber = "Bin1",
                    Quantity  = 1
                },
                new InventoryLocation {
                    Part      = parts[0],
                    BinNumber = "Bin2",
                    Quantity  = 2
                },
                new InventoryLocation {
                    Part      = parts[1],
                    BinNumber = "Bin3",
                    Quantity  = 3
                },
            };

            var dataContext = new BDataContext <PartsSiteDataContext>();

            dataContext.SetOne("Parts", parts);
            dataContext.SetNext("Inventory Locations", inventoryLocations);

            var target  = new PartManagementRepository(dataContext);
            var results = target.GetInventoryLocations(parts[0]).OrderBy((il) => il.BinNumber).ToList();

            Assert.AreEqual(2, results.Count);
            Assert.AreEqual("Bin1", results[0].BinNumber);
            Assert.AreEqual("Bin2", results[1].BinNumber);
        }
        private void machineResultsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            var selectedMachineId =
                int.Parse(MachineResultsGridView.DataKeys[int.Parse(e.CommandArgument.ToString())].Value.ToString());

            using (var partManagementRepository = new PartManagementRepository())
            {
                switch (e.CommandName)
                {
                case "ViewParts":
                    if (OnRelatedPartsFound != null)
                    {
                        RelatedPartsFound(new GenericEventArgs <IEnumerable <Part> >
                        {
                            PayLoad = partManagementRepository.GetPartsByMachineId(selectedMachineId)
                        });
                    }

                    break;
                }
            }
        }
Esempio n. 17
0
        public void GetData()
        {
            using (var partManagementRepository = new PartManagementRepository())
            {
                IEnumerable <Part> parts;
                if (CurrentPage > 0)
                {
                    parts = partManagementRepository.GetPartsByPartialSkuPaged(PartSearchTextBox.Text, CurrentPage, Constants.DeafultPageSize);
                }
                else
                {
                    parts = partManagementRepository.GetPartsByPartialSku(PartSearchTextBox.Text);
                }

                var partsEventArgs = new GenericEventArgs <IEnumerable <Part> >();
                partsEventArgs.PayLoad = parts;

                if (OnPartsFound != null)
                {
                    PartsFound(partsEventArgs);
                }
            }
        }
        protected void AreaRadioButton_SelectedIndexChanged(object sender, EventArgs e)
        {
            AreaDisplayTypes displayType = (AreaDisplayTypes)System.Enum.Parse(typeof(AreaDisplayTypes), AreaRadioButton.SelectedValue);

            AreaResultsGridView.Columns[1].HeaderText = "All " + MakePlural(displayType);

            using (var partManagementRepository = new PartManagementRepository())
            {
                switch (displayType)
                {
                case AreaDisplayTypes.Category:
                    IEnumerable <Category> categories = partManagementRepository.GetCategories();
                    AreaResultsGridView.DataSource = GetAreaViewModels(categories);
                    break;

                case AreaDisplayTypes.Manufacturer:
                    IEnumerable <Manufacturer> manufacturers = partManagementRepository.GetManufacturers();
                    AreaResultsGridView.DataSource = GetAreaViewModels(manufacturers);
                    break;

                case AreaDisplayTypes.Department:
                    IEnumerable <Department> departments = partManagementRepository.GetDepartments();
                    AreaResultsGridView.DataSource = GetAreaViewModels(departments);
                    break;

                default:
                    throw new ArgumentOutOfRangeException("Area Display Type Not Found");
                }
            }
            AreaResultsGridView.DataBind();

            //Reset the MAchine Results Grid by clearing out the results and firing the event
            RelatedMachinesFound(new GenericEventArgs <IEnumerable <Machine> >
            {
                PayLoad = new List <Machine>()
            });
        }
        public void GetPartsByPartialSku_ReturnsPartsStartingWithMatchingSku()
        {
            // Arrange
            var dataContext = new BDataContext <PartsSiteDataContext>();

            dataContext.SetEmpty();

            BEntityList <Part> partsList = dataContext.SetOne("Parts",
                                                              new Part {
                SKU = "sku0"
            },
                                                              new Part {
                SKU = "1sku1"
            },
                                                              new Part {
                SKU = "2sku"
            });

            var target = new PartManagementRepository(dataContext);
            var parts  = new List <Part>(target.GetPartsByPartialSku("sku"));

            Assert.AreEqual(1, parts.Count);
            Assert.AreEqual(partsList.Entities[0], parts[0]);
        }