private void sendButton_Click(object sender, EventArgs e) { if (AddPartMaxBoxText < AddPartMinBoxText) { MessageBox.Show("Minimum canot be greater than the Maximum"); return; } if ((AddPartMaxBoxText < AddPartInvBoxText) ^ (AddPartInvBoxText < AddPartMinBoxText)) { MessageBox.Show("Inventory must be between Min and Max"); return; } if (InHouse.Checked) { InHousePart inHouse = new InHousePart((Inventory.Parts.Count + 1), AddPartNameBoxText, AddPartInvBoxText, AddPartPriceBoxText, AddPartMinBoxText, AddPartMaxBoxText, int.Parse(AddPartMachComBoxText)); Inventory.AddPart(inHouse); } else { OutSourcedPart outSourced = new OutSourcedPart((Inventory.Parts.Count + 1), AddPartNameBoxText, AddPartInvBoxText, AddPartPriceBoxText, AddPartMinBoxText, AddPartMaxBoxText, AddPartMachComBoxText); Inventory.AddPart(outSourced); } this.Hide(); MainForm.mainPartsGrid.Refresh(); MainForm.mainProductsGrid.Refresh(); }
public ModifyPartScreen() { InitializeComponent(); ModPartIDBoxText = Inventory.Parts[Inventory.grid1Index].PartID; ModPartNameBoxText = Inventory.Parts[Inventory.grid1Index].PartName; ModPartInvBoxText = Inventory.Parts[Inventory.grid1Index].PartInventory; ModPartPriceBoxText = Inventory.Parts[Inventory.grid1Index].Price; ModPartMaxBoxText = Inventory.Parts[Inventory.grid1Index].Max; ModPartMinBoxText = Inventory.Parts[Inventory.grid1Index].Min; if (Inventory.Parts[Inventory.grid1Index].GetType() == typeof(InHousePart)) { tmpI = (InHousePart)Inventory.Parts[Inventory.grid1Index]; ModPartMachComBoxText = tmpI.MachineID.ToString(); radioModInhouse.Checked = true; } else { tmpO = (OutSourcedPart)Inventory.Parts[Inventory.grid1Index]; ModPartMachComBoxText = tmpO.CompanyName.ToString(); radioModOutsourced.Checked = true; } }
//lookup public Part LookupAssociatedPart(int partID) { foreach (Part part in AssociatedParts) { if (part.PartID == partID) { return(part); } } InHousePart emptyInPart = new InHousePart(); return(emptyInPart); }
public static void PopulateDummyLists() { //create dummy prods Product dummyProd1 = new Product(1, "Product 1", 3, 12.00m, 5, 2); Product dummyProd2 = new Product(2, "Product 2", 3, 8.00m, 5, 2); Product dummyProd3 = new Product(3, "Product 3", 3, 3m, 5, 2); Product dummyProd4 = new Product(4, "Product 4", 3, 7m, 5, 2); Products.Add(dummyProd1); Products.Add(dummyProd2); Products.Add(dummyProd3); Products.Add(dummyProd4); // add mach ids and comp names Part dummyPart1A = new InHousePart(1, "Part 1.A", 5, 15.00m, 3, 10, 9001); Part dummyPart1B = new InHousePart(2, "Part 1.B", 5, 12.00m, 2, 10, 9001); Part dummyPart2A = new InHousePart(3, "Part 2.A", 6, 10.00m, 2, 10, 9002); Part dummyPart2B = new InHousePart(4, "Part 2.B", 7, 5.00m, 2, 10, 9002); Part dummyPart3A = new OutSourcedPart(5, "Part 3.A", 8, 15.00m, 2, 10, "ShopCorp"); Part dummyPart3B = new OutSourcedPart(6, "Part 3.B", 6, 12.00m, 2, 10, "ShopCorp"); Part dummyPart4A = new OutSourcedPart(7, "Part 4.A", 7, 10.00m, 2, 10, "PPI, LLC"); Part dummyPart4B = new OutSourcedPart(8, "Part 4.B", 7, 5.00m, 2, 10, "PPI, LLC"); Parts.Add(dummyPart1A); Parts.Add(dummyPart1B); Parts.Add(dummyPart2A); Parts.Add(dummyPart2B); Parts.Add(dummyPart3A); Parts.Add(dummyPart3B); Parts.Add(dummyPart4A); Parts.Add(dummyPart4B); // Add parts to assicated products dummyProd1.AssociatedParts.Add(dummyPart1A); dummyProd1.AssociatedParts.Add(dummyPart1B); dummyProd2.AssociatedParts.Add(dummyPart2A); dummyProd2.AssociatedParts.Add(dummyPart2B); dummyProd3.AssociatedParts.Add(dummyPart3A); dummyProd3.AssociatedParts.Add(dummyPart3B); dummyProd4.AssociatedParts.Add(dummyPart4A); dummyProd4.AssociatedParts.Add(dummyPart4B); }
//test //public ModifyPartScreen(OutSourcedPart outPart) //{ // InitializeComponent(); // ModPartIDBoxText = outPart.PartID; // ModPartNameBoxText = outPart.PartName; // ModPartInvBoxText = outPart.PartInventory; // ModPartPriceBoxText = outPart.Price; // ModPartMaxBoxText = outPart.Max; // ModPartMinBoxText = outPart.Min; // ModPartMachComBoxText = outPart.CompanyName.ToString(); // radioModOutsourced.Checked = true; //} //save it private void btnModPartSave_Click(object sender, EventArgs e) { if (ModPartMaxBoxText < ModPartMinBoxText) { MessageBox.Show("Minimum cannot be greater than the maximum"); return; } if ((ModPartMaxBoxText < ModPartInvBoxText) || (ModPartInvBoxText < ModPartMinBoxText)) { MessageBox.Show("Inventory must be between Min and Max"); return; } if ((radioModInhouse.Checked) && (!Int32.TryParse(modPartMachComBox.Text, out number))) { MessageBox.Show("MachineID must be an integer"); return; } if (radioModInhouse.Checked == true) { InHousePart inHouse = new InHousePart(ModPartIDBoxText, ModPartNameBoxText, ModPartInvBoxText, ModPartPriceBoxText, ModPartMinBoxText, ModPartMaxBoxText, int.Parse(ModPartMachComBoxText)); Inventory.UpdatePart(ModPartIDBoxText, inHouse); //radioModInhouse.Checked = true; } else { OutSourcedPart outSourced = new OutSourcedPart(ModPartIDBoxText, ModPartNameBoxText, ModPartInvBoxText, ModPartPriceBoxText, ModPartMinBoxText, ModPartMaxBoxText, ModPartMachComBoxText); Inventory.UpdatePart(ModPartIDBoxText, outSourced); //radioModOutsourced.Checked = true; } //else //{ // Part updatedPart; // if (radioModInhouse.Checked) // { // updatedPart = new InHousePart(ModPartIDBoxText, ModPartNameBoxText, ModPartInvBoxText, ModPartPriceBoxText, ModPartMinBoxText, ModPartMaxBoxText, int.Parse(ModPartMachComBoxText)); // radioModInhouse.Checked = true; // } // else // { // updatedPart = new OutSourcedPart(ModPartIDBoxText, ModPartNameBoxText, ModPartInvBoxText, ModPartPriceBoxText, ModPartMinBoxText, ModPartMaxBoxText, ModPartMachComBoxText); // radioModOutsourced.Checked = true; // } //} ////Part partToSave; ////int tmpPartID = ModPartIDBoxText; ////string tmpPartName = ModPartNameBoxText; ////int tmpPartInventory = ModPartInvBoxText; ////decimal tmpPrice = ModPartPriceBoxText; ////int tmpMax = ModPartMaxBoxText; ////int tmpMin = ModPartMinBoxText; ////if (radioModInhouse.Checked == true) ////{ //// int machineID = Int32.Parse(ModPartMachComBoxText); //// partToSave = new InHousePart(); //// Inventory.UpdatePart(ModPartIDBoxText, partToSave); ////} ////else if (radioModOutsourced.Checked == true) ////{ //// string cName = ModPartMachComBoxText; //// partToSave = new OutSourcedPart(); //// Inventory.UpdatePart(ModPartIDBoxText, partToSave); ////} this.Hide(); //MainScreen.home.Show(); //MainForm.MainScreenFormLoad(); //MainForm.mainPartsGrid.Update(); MainForm.mainPartsGrid.Refresh(); MainForm.mainProductsGrid.Refresh(); }