private void btnSave_Click(object sender, EventArgs e) { var partTypeText = cbType.SelectedItem.ToString(); Part part = null; if (partTypeText == "Weight") { double weight = 0.0f; System.Double.TryParse(txtWeightCount.Text, out weight); part = new PartWithWeight(txtName.Text, txtDescription.Text, (float)weight); } if (partTypeText == "Count") { int count = 0; System.Int32.TryParse(txtWeightCount.Text, out count); part = new PartWithCount(txtName.Text, txtDescription.Text, count); } if (part != null && _main != null) { _main.MLPart.Add(part); this.Close(); } }
public void CreateMasterListOfParts(PartList partList) { Part itemTemp = new PartWithWeight("Fasto Cap", "Fasto's pen cap", 0.010f); partList.Add(itemTemp); itemTemp = new PartWithWeight("Fasto Barrel", "Fasto's pen Barrel", 0.050f); partList.Add(itemTemp); itemTemp = new PartWithCount("Fasto Refill", "Fasto's pen Refill", 1); partList.Add(itemTemp); }
public void PrintPartList(PartList partList) { foreach (var itemTemp in partList.Parts) { //if (itemTemp.Type == PartTypeEnum.ptWeight) if (itemTemp is PartWithWeight) { PartWithWeight item = (PartWithWeight)itemTemp; System.Console.WriteLine(" By Weight Part -> Name: '{0}', Description: '{1}', Weight: {2}", item.Name, item.Description, item.Weight); } if (itemTemp is PartWithCount) { PartWithCount item = (PartWithCount)itemTemp; System.Console.WriteLine(" By Count Part -> Name: '{0}', Description: '{1}', Count: {2}", item.Name, item.Description, item.Count); } } }
public void AddStockInInventory(Inventory stock) { PartWithWeight partWithWeight; PartWithCount partWithCount; InStock inStock = new InStock(); partWithWeight = new PartWithWeight("Fasto Cap", "", 10.0f); inStock.Add(partWithWeight); partWithWeight = new PartWithWeight("Fasto Barrel", "", 15.0f); inStock.Add(partWithWeight); partWithWeight = new PartWithWeight("Gripper Cap", "", 5.0f); inStock.Add(partWithWeight); partWithCount = new PartWithCount("Fasto Refill", "", 1000); inStock.Add(partWithCount); Console.WriteLine(""); StoreInventory.AddToInventory(inStock); }