Ejemplo n.º 1
0
        /// <summary>
        /// convert part model to part master for update part master
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IV00101_Part_Master ConvertToUpdateMaster(PartOperationModel model)
        {
            IV00101_Part_Master partMaster = new IV00101_Part_Master();

            var _partStatusRepository = new PartStatusRepository();

            var partStatus = _partStatusRepository.GetPartStatus(model.PartStatusId);

            var active = (partStatus != null && (!partStatus.Description.ToLower().Replace(" ", string.Empty).Equals("inactive") ||
                                                 !partStatus.Description.ToLower().Replace(" ", string.Empty).Equals("archive") ||
                                                 !partStatus.Description.ToLower().Replace(" ", string.Empty).Equals("purge"))) ? true : false;

            partMaster.ITEMNMBR = model.PartNumber;
            partMaster.ITEMDESC = model.PartDescription;
            partMaster.ITEMSHWT = Convert.ToInt32(model.Weight * 100.00m);
            partMaster.STNDCOST = model.Cost;
            partMaster.LOCNCODE = model.SiteId;
            partMaster.INACTIVE = Convert.ToByte(active);
            partMaster.ITMCLSCD = "STANDRRD";

            if (_partStatusRepository != null)
            {
                _partStatusRepository.Dispose();
                _partStatusRepository = null;
            }

            return(partMaster);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// convert part model to domain for update part
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Part ConvertToUpdatePart(PartOperationModel model)
        {
            Part part = new Part();

            var _partStatusRepository = new PartStatusRepository();

            var partStatus = _partStatusRepository.GetPartStatus(model.PartStatusId);

            var active = (partStatus != null && (!partStatus.Description.ToLower().Replace(" ", string.Empty).Equals("inactive") ||
                                                 !partStatus.Description.ToLower().Replace(" ", string.Empty).Equals("archive") ||
                                                 !partStatus.Description.ToLower().Replace(" ", string.Empty).Equals("purge"))) ? true : false;

            part.PartId                  = model.PartId ?? Guid.Empty;
            part.Number                  = model.PartNumber;
            part.AccountCode             = model.AccountCode;
            part.CustomerId              = model.CustomerId;
            part.CustomerAddressId       = model.CustomerAddressId;
            part.FoundryId               = model.FoundryId;
            part.SubFoundryId            = model.SubFoundryId;
            part.HtsNumberId             = model.HtsNumberId;
            part.MaterialId              = model.MaterialId;
            part.MaterialSpecificationId = model.MaterialSpecificationId;
            part.PartStatusId            = model.PartStatusId;
            part.PartTypeId              = model.PartTypeId;
            part.ShipmentTermId          = model.ShipmentTermId;
            part.PaymentTermId           = model.PaymentTermId;
            part.SurchargeId             = model.SurchargeId;
            part.SiteId                  = model.SiteId;
            part.DestinationId           = model.DestinationId;
            part.CoatingTypeId           = model.CoatingTypeId;
            part.PatternMaterialId       = model.PatternMaterialId;
            part.IsRaw              = model.IsRaw;
            part.IsMachined         = model.IsMachined;
            part.PalletQuantity     = model.PalletQuantity;
            part.AdditionalCost     = model.AdditionalCost;
            part.FixtureDate        = model.FixtureDate;
            part.FixtureCost        = model.FixtureCost;
            part.FixturePrice       = model.FixturePrice;
            part.PatternDate        = model.PatternDate;
            part.PatternCost        = model.PatternCost;
            part.PatternPrice       = model.PatternPrice;
            part.IsFamilyPattern    = model.IsFamilyPattern;
            part.Notes              = model.Notes;
            part.MinimumQuantity    = model.MinimumQuantity;
            part.SafetyQuantity     = model.SafetyQuantity;
            part.OrderCycle         = model.OrderCycle;
            part.LeadTime           = model.LeadTime;
            part.AnnualUsage        = model.AnnualUsage;
            part.FoundryOrderId     = model.FoundryOrderId;
            part.ToolingDescription = model.ToolingDescription;
            part.IsActive           = active;

            if (_partStatusRepository != null)
            {
                _partStatusRepository.Dispose();
                _partStatusRepository = null;
            }

            return(part);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// convert part model to part quantity master for update
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IV00102_Part_Quantity_Master ConvertToUpdatePartQuantity(PartOperationModel model)
        {
            IV00102_Part_Quantity_Master partQuantity = new IV00102_Part_Quantity_Master();

            partQuantity.ITEMNMBR = model.PartNumber;
            partQuantity.PRIMVNDR = model.FoundryId;

            return(partQuantity);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// convert part model to part vendor master for update
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IV00103_Part_Vendor_Master ConvertToUpdatePartVendor(PartOperationModel model)
        {
            IV00103_Part_Vendor_Master partVendor = new IV00103_Part_Vendor_Master();

            partVendor.ITEMNMBR = model.PartNumber;
            partVendor.VENDORID = model.FoundryId;
            partVendor.VNDITNUM = model.PartNumber;

            return(partVendor);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// convert part model to part currency for update part currency
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IV00105_Part_Currency ConvertToUpdateCurrency(PartOperationModel model)
        {
            IV00105_Part_Currency partCurrency = new IV00105_Part_Currency();

            partCurrency.ITEMNMBR = model.PartNumber;
            partCurrency.LISTPRCE = model.Price;
            partCurrency.CURNCYID = string.Empty;

            return(partCurrency);
        }
Ejemplo n.º 6
0
        public JsonResult EditPart(PartOperationModel model)
        {
            var operationResult = new OperationResult();

            if (model.IsProjectPart)
            {
                var currentPart = _projectPartRepository.GetProjectPart(model.ProjectPartId);

                if (currentPart != null)
                {
                    currentPart = new ProjectPartConverter().ConvertToDomain(model);

                    operationResult = _projectPartRepository.UpdateProjectPart(currentPart);

                    if (operationResult.Success)
                    {
                        var partToEdit = _priceSheetRepository.GetProductionPriceSheetPartByProjectPart(currentPart.ProjectPartId);

                        if (partToEdit != null)
                        {
                            partToEdit.Cost        = model.Cost;
                            partToEdit.Price       = model.Price;
                            partToEdit.AnnualCost  = model.Cost * partToEdit.AnnualUsage;
                            partToEdit.AnnualPrice = model.Price * partToEdit.AnnualUsage;

                            operationResult = _priceSheetRepository.UpdatePriceSheetPart(partToEdit);

                            var totalAnnualCost  = _priceSheetRepository.GetPriceSheetParts(partToEdit.PriceSheetId).Select(x => x.AnnualCost).Sum();
                            var totalAnnualPrice = _priceSheetRepository.GetPriceSheetParts(partToEdit.PriceSheetId).Select(x => x.AnnualPrice).Sum();

                            var priceSheetToEdit = _priceSheetRepository.GetPriceSheet(partToEdit.PriceSheetId);

                            priceSheetToEdit.AnnualMargin = (totalAnnualPrice - totalAnnualCost) / totalAnnualCost;

                            operationResult = _priceSheetRepository.UpdatePriceSheet(priceSheetToEdit);
                        }
                    }
                }
            }
            else
            {
                var existingPart = _partRepository.GetPart(model.PartId);

                if (existingPart != null)
                {
                    Part part = new PartConverter().ConvertToUpdatePart(model);

                    operationResult = _partRepository.UpdatePart(part);
                }
            }

            return(Json(operationResult, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// convert project part to part model
        /// </summary>
        /// <param name="projectPart"></param>
        /// <returns></returns>
        public PartOperationModel ConvertFromProjectPart(ProjectPart projectPart)
        {
            PartOperationModel operationPart = new PartOperationModel();

            operationPart.ProjectPartId           = projectPart.ProjectPartId;
            operationPart.PartId                  = projectPart.PartId;
            operationPart.PartNumber              = projectPart.Number;
            operationPart.PartDescription         = projectPart.Description;
            operationPart.AccountCode             = projectPart.AccountCode;
            operationPart.RevisionNumber          = projectPart.RevisionNumber;
            operationPart.CustomerId              = projectPart.CustomerId;
            operationPart.FoundryId               = projectPart.FoundryId;
            operationPart.SubFoundryId            = projectPart.SubFoundryId;
            operationPart.PartTypeId              = projectPart.PartTypeId;
            operationPart.HtsNumberId             = projectPart.HtsNumberId;
            operationPart.MaterialId              = projectPart.MaterialId;
            operationPart.ShipmentTermId          = projectPart.ShipmentTermId;
            operationPart.MaterialSpecificationId = projectPart.MaterialSpecificationId;
            operationPart.PaymentTermId           = projectPart.PaymentTermId;
            operationPart.IsMachined              = projectPart.IsMachined;
            operationPart.PartStatusId            = projectPart.PartStatusId;
            operationPart.DestinationId           = projectPart.DestinationId;
            operationPart.Weight                  = projectPart.Weight;
            operationPart.Cost               = projectPart.Cost;
            operationPart.Price              = projectPart.Price;
            operationPart.AdditionalCost     = projectPart.AdditionalCost;
            operationPart.SurchargeId        = projectPart.SurchargeId;
            operationPart.PalletQuantity     = projectPart.PalletQuantity;
            operationPart.CustomerAddressId  = projectPart.CustomerAddressId;
            operationPart.SiteId             = projectPart.SiteId;
            operationPart.CoatingTypeId      = projectPart.CoatingTypeId;
            operationPart.FixtureDate        = projectPart.FixtureDate;
            operationPart.FixtureCost        = projectPart.FixtureCost;
            operationPart.FixturePrice       = projectPart.FixturePrice;
            operationPart.PatternDate        = projectPart.PatternDate;
            operationPart.PatternCost        = projectPart.PatternCost;
            operationPart.PatternPrice       = projectPart.PatternPrice;
            operationPart.IsFamilyPattern    = projectPart.IsFamilyPattern;
            operationPart.PatternMaterialId  = projectPart.PatternMaterialId;
            operationPart.Notes              = projectPart.Notes;
            operationPart.AnnualUsage        = projectPart.AnnualUsage;
            operationPart.IsRaw              = projectPart.IsRaw;
            operationPart.FoundryOrderId     = projectPart.FoundryOrderId;
            operationPart.ToolingDescription = projectPart.ToolingDescription;

            return(operationPart);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// convert part model to project part
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ProjectPart ConvertToDomain(PartOperationModel model)
        {
            ProjectPart projectPart = new ProjectPart();

            projectPart.ProjectPartId           = model.ProjectPartId;
            projectPart.PartId                  = model.PartId;
            projectPart.Number                  = model.PartNumber;
            projectPart.CustomerId              = model.CustomerId;
            projectPart.CustomerAddressId       = model.CustomerAddressId;
            projectPart.FoundryId               = model.FoundryId;
            projectPart.SubFoundryId            = model.SubFoundryId;
            projectPart.HtsNumberId             = model.HtsNumberId;
            projectPart.MaterialId              = model.MaterialId;
            projectPart.MaterialSpecificationId = model.MaterialSpecificationId;
            projectPart.PartStatusId            = model.PartStatusId;
            projectPart.PartTypeId              = model.PartTypeId;
            projectPart.ShipmentTermId          = model.ShipmentTermId;
            projectPart.PaymentTermId           = model.PaymentTermId;
            projectPart.SurchargeId             = model.SurchargeId;
            projectPart.SiteId                  = model.SiteId;
            projectPart.DestinationId           = model.DestinationId;
            projectPart.CoatingTypeId           = model.CoatingTypeId;
            projectPart.PatternMaterialId       = model.PatternMaterialId;
            projectPart.IsRaw              = model.IsRaw;
            projectPart.IsMachined         = model.IsMachined;
            projectPart.Weight             = model.Weight;
            projectPart.Cost               = model.Cost;
            projectPart.Price              = model.Price;
            projectPart.PalletQuantity     = model.PalletQuantity;
            projectPart.AdditionalCost     = model.AdditionalCost;
            projectPart.AnnualUsage        = model.AnnualUsage;
            projectPart.FixtureDate        = model.FixtureDate;
            projectPart.FixtureCost        = model.FixtureCost;
            projectPart.FixturePrice       = model.FixturePrice;
            projectPart.PatternDate        = model.PatternDate;
            projectPart.PatternCost        = model.PatternCost;
            projectPart.PatternPrice       = model.PatternPrice;
            projectPart.IsFamilyPattern    = model.IsFamilyPattern;
            projectPart.Notes              = model.Notes;
            projectPart.FoundryOrderId     = model.FoundryOrderId;
            projectPart.ToolingDescription = model.ToolingDescription;

            return(projectPart);
        }