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();
            }
        }
Example #2
0
        public void AddStockInInventory2(Inventory stock)
        {
            PartWithWeight partWithWeight;

            InStock inStock = new InStock();

            partWithWeight = new PartWithWeight("Fasto Cap", "", 4.5f);
            inStock.Add(partWithWeight);

            StoreInventory.AddToInventory(inStock);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
                }
            }
        }
Example #5
0
        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);
        }