Exemple #1
0
        /// <summary>
        /// Write Parts
        /// </summary>
        /// <param name="units"></param>
        /// <param name="bworker"></param>
        /// <returns></returns>
        public BusinessObjects.OutputCollection WriteParts(List <FrameWorks.AssemblyBase> units, System.ComponentModel.BackgroundWorker bworker)
        {
            //BusinessObjects.OutputCollection _outParts = Db.OutParts();
            BusinessObjects.OutputCollection _outParts = new BusinessObjects.OutputCollection();
            _outParts.MarkAllAsDeleted();

            int jobid = ProjectData().JobNumber.Value;

            int counter = 0;
            int step    = units.Count / 100;

            foreach (FrameWorks.Unit un in units)
            {
                foreach (FrameWorks.SubAssemblyBase sub in un.SubAssemblies)
                {
                    foreach (FrameWorks.Part prt in sub.Parts)
                    {
                        string ptype = prt.GetType().ToString();

                        switch (ptype)
                        {
                        // Labor Part
                        case "FrameWorks.LPart":
                        {
                            BusinessObjects.Output newPart = _outParts.AddNew();
                            //number the parts starting at 1
                            counter += 1;

                            newPart.PartIdentifier = prt.ContainerAssembly.Parent.UnitID.ToString() + "-" + prt.ContainerAssembly.ID.ToString() + "-" + counter.ToString();
                            newPart.PartType       = prt.PartType;
                            newPart.UnitPrice      = prt.LaborAmount;
                            newPart.PartLabel      = prt.PartLabel;
                            //newPart.Price = prt.CalculatedCost;
                            //newPart.Qnty = prt.Qnty;
                            newPart.Rate        = prt.Rate;
                            newPart.LaborAmount = prt.LaborAmount;
                            //newPart.Markup = prt.MarkUp;
                            newPart.FunctionalName    = prt.FunctionalName;
                            newPart.SubAssemblyGUID   = prt.ContainerAssembly.Name;
                            newPart.SourceDescription = prt.Source.MaterialDescription;
                            newPart.SourceName        = prt.Source.MaterialName;
                            //newPart.Width = prt.PartWidth;
                            //newPart.Length = prt.PartLength;
                            //newPart.Thick = prt.PartThick;
                            newPart.AssemblyID   = prt.ContainerAssembly.Parent.UnitID;
                            newPart.AssemblyName = prt.ContainerAssembly.Parent.UnitName;
                            //newPart.PartID = prt.Source.ItemID;
                            //newPart.Tax = Math.Round((prt.CalculatedCost * 0.0875m), 2);
                            //newPart.Weight = Convert.ToDecimal(prt.Weight.ToString());
                            //newPart.Waste = prt.Waste;
                            //newPart.Area = prt.Area;

                            newPart.AssemblyArea   = prt.ContainerAssembly.Parent.Area;
                            newPart.AssemblyDepth  = prt.ContainerAssembly.Parent.UnitDepth;
                            newPart.AssemblyWidth  = prt.ContainerAssembly.Parent.UnitWidth;
                            newPart.AssemblyHieght = prt.ContainerAssembly.Parent.UnitHeight;

                            newPart.SubAssemblyWidth  = prt.ContainerAssembly.SubAssemblyWidth;
                            newPart.SubAssemblyHieght = prt.ContainerAssembly.SubAssemblyHieght;
                            newPart.SubAssemblyDepth  = prt.ContainerAssembly.SubAssemblyDepth;
                            newPart.SubAssemblyArea   = prt.ContainerAssembly.Area;
                            newPart.JobID             = (short)jobid;
                            break;
                        }

                        // Standard Material Part
                        case "FrameWorks.Part":
                        {
                            BusinessObjects.Output newPart = _outParts.AddNew();
                            //number the parts starting at 1
                            counter += 1;

                            newPart.PartIdentifier    = prt.ContainerAssembly.Parent.UnitID.ToString() + "-" + prt.ContainerAssembly.ID.ToString() + "-" + counter.ToString();
                            newPart.PartType          = prt.PartType;
                            newPart.UnitPrice         = prt.UnitPrice;
                            newPart.PartLabel         = prt.PartLabel;
                            newPart.Price             = prt.CalculatedCost;
                            newPart.Qnty              = prt.Qnty;
                            newPart.Rate              = prt.Rate;
                            newPart.Markup            = prt.MarkUp;
                            newPart.FunctionalName    = prt.FunctionalName;
                            newPart.SubAssemblyGUID   = prt.ContainerAssembly.Name;
                            newPart.SourceDescription = prt.Source.MaterialDescription;
                            newPart.SourceName        = prt.Source.MaterialName;
                            newPart.Width             = prt.PartWidth;
                            newPart.Length            = prt.PartLength;
                            newPart.Thick             = prt.PartThick;
                            newPart.AssemblyID        = prt.ContainerAssembly.Parent.UnitID;
                            newPart.AssemblyName      = prt.ContainerAssembly.Parent.UnitName;
                            newPart.PartID            = prt.Source.ItemID;
                            newPart.Tax    = Math.Round((prt.CalculatedCost * 0.0875m), 2);
                            newPart.Weight = Convert.ToDecimal(prt.Weight.ToString());
                            newPart.Waste  = prt.Waste;
                            newPart.Area   = prt.Area;

                            newPart.AssemblyArea   = prt.ContainerAssembly.Parent.Area;
                            newPart.AssemblyDepth  = prt.ContainerAssembly.Parent.UnitDepth;
                            newPart.AssemblyWidth  = prt.ContainerAssembly.Parent.UnitWidth;
                            newPart.AssemblyHieght = prt.ContainerAssembly.Parent.UnitHeight;

                            newPart.SubAssemblyWidth  = prt.ContainerAssembly.SubAssemblyWidth;
                            newPart.SubAssemblyHieght = prt.ContainerAssembly.SubAssemblyHieght;
                            newPart.SubAssemblyDepth  = prt.ContainerAssembly.SubAssemblyDepth;
                            newPart.SubAssemblyArea   = prt.ContainerAssembly.Area;
                            newPart.Uom   = Convert.ToInt16(prt.UOM.ToString());
                            newPart.JobID = (short)jobid;
                            break;
                        }

                        default:
                            break;
                        }

                        //
                    }
                }
                bworker.ReportProgress(counter += step);
            }

            _outParts.Save();
            return(_outParts);
        }
Exemple #2
0
            protected override void DoTask()
            {
                //BusinessObjects.OutputCollection _outParts = Db.OutParts();
                BusinessObjects.OutputCollection _outParts = new BusinessObjects.OutputCollection();
                _outParts.MarkAllAsDeleted();

                int counter = 0;

                foreach (FrameWorks.Unit un in _units)
                {
                    foreach (FrameWorks.SubAssemblyBase sub in un.SubAssemblies)
                    {
                        foreach (FrameWorks.Part prt in sub.Parts)
                        {
                            string ptype = prt.GetType().ToString();

                            switch (ptype)
                            {
                            // Labor Part
                            case "FrameWorks.LPart":
                            {
                                BusinessObjects.Output newPart = _outParts.AddNew();
                                //number the parts starting at 1
                                counter += 1;

                                newPart.PartIdentifier = prt.ContainerAssembly.Parent.UnitID.ToString() + "-" + prt.ContainerAssembly.ID.ToString() + "-" + counter.ToString();
                                newPart.PartType       = prt.PartType;
                                //newPart.UnitPrice = prt.UnitPrice;
                                newPart.PartLabel = prt.PartLabel;
                                //newPart.Price = prt.CalculatedCost;
                                //newPart.Qnty = prt.Qnty;
                                newPart.Rate        = prt.Rate;
                                newPart.LaborAmount = prt.LaborAmount;
                                //newPart.Markup = prt.MarkUp;
                                newPart.FunctionalName    = prt.FunctionalName;
                                newPart.SubAssemblyGUID   = prt.ContainerAssembly.Name;
                                newPart.SourceDescription = prt.Source.MaterialDescription;
                                newPart.SourceName        = prt.Source.MaterialName;
                                //newPart.Width = prt.PartWidth;
                                //newPart.Length = prt.PartLength;
                                //newPart.Thick = prt.PartThick;
                                newPart.AssemblyID   = prt.ContainerAssembly.Parent.UnitID;
                                newPart.AssemblyName = prt.ContainerAssembly.Parent.UnitName;
                                //newPart.PartID = prt.Source.ItemID;
                                //newPart.Tax = Math.Round((prt.CalculatedCost * 0.0875m), 2);
                                //newPart.Weight = Convert.ToDecimal(prt.Weight.ToString());
                                //newPart.Waste = prt.Waste;
                                //newPart.Area = prt.Area;

                                newPart.AssemblyArea   = prt.ContainerAssembly.Parent.Area;
                                newPart.AssemblyDepth  = prt.ContainerAssembly.Parent.UnitDepth;
                                newPart.AssemblyWidth  = prt.ContainerAssembly.Parent.UnitWidth;
                                newPart.AssemblyHieght = prt.ContainerAssembly.Parent.UnitHeight;

                                newPart.SubAssemblyWidth  = prt.ContainerAssembly.SubAssemblyWidth;
                                newPart.SubAssemblyHieght = prt.ContainerAssembly.SubAssemblyHieght;
                                newPart.SubAssemblyDepth  = prt.ContainerAssembly.SubAssemblyDepth;
                                newPart.SubAssemblyArea   = prt.ContainerAssembly.Area;
                                break;
                            }

                            // Standard Material Part
                            case "FrameWorks.Part":
                            {
                                BusinessObjects.Output newPart = _outParts.AddNew();
                                //number the parts starting at 1
                                counter += 1;

                                newPart.PartIdentifier    = prt.ContainerAssembly.Parent.UnitID.ToString() + "-" + prt.ContainerAssembly.ID.ToString() + "-" + counter.ToString();
                                newPart.PartType          = prt.PartType;
                                newPart.UnitPrice         = prt.UnitPrice;
                                newPart.PartLabel         = prt.PartLabel;
                                newPart.Price             = prt.CalculatedCost;
                                newPart.Qnty              = prt.Qnty;
                                newPart.Rate              = prt.Rate;
                                newPart.Markup            = prt.MarkUp;
                                newPart.FunctionalName    = prt.FunctionalName;
                                newPart.SubAssemblyGUID   = prt.ContainerAssembly.Name;
                                newPart.SourceDescription = prt.Source.MaterialDescription;
                                newPart.SourceName        = prt.Source.MaterialName;
                                newPart.Width             = prt.PartWidth;
                                newPart.Length            = prt.PartLength;
                                newPart.Thick             = prt.PartThick;
                                newPart.AssemblyID        = prt.ContainerAssembly.Parent.UnitID;
                                newPart.AssemblyName      = prt.ContainerAssembly.Parent.UnitName;
                                newPart.PartID            = prt.Source.ItemID;
                                newPart.Tax    = Math.Round((prt.CalculatedCost * 0.0875m), 2);
                                newPart.Weight = Convert.ToDecimal(prt.Weight.ToString());
                                newPart.Waste  = prt.Waste;
                                newPart.Area   = prt.Area;

                                newPart.AssemblyArea   = prt.ContainerAssembly.Parent.Area;
                                newPart.AssemblyDepth  = prt.ContainerAssembly.Parent.UnitDepth;
                                newPart.AssemblyWidth  = prt.ContainerAssembly.Parent.UnitWidth;
                                newPart.AssemblyHieght = prt.ContainerAssembly.Parent.UnitHeight;

                                newPart.SubAssemblyWidth  = prt.ContainerAssembly.SubAssemblyWidth;
                                newPart.SubAssemblyHieght = prt.ContainerAssembly.SubAssemblyHieght;
                                newPart.SubAssemblyDepth  = prt.ContainerAssembly.SubAssemblyDepth;
                                newPart.SubAssemblyArea   = prt.ContainerAssembly.Area;
                                newPart.Uom = Convert.ToInt16(prt.UOM.ToString());
                                break;
                            }

                            default:
                                break;
                            }

                            //
                        }
                    }
                }

                _outParts.Save();
                unitCollection = _outParts;
            }