コード例 #1
0
        /// <summary>
        /// convert containerPart to view model
        /// </summary>
        /// <param name="containerPart"></param>
        /// <returns></returns>
        public ContainerPartViewModel ConvertToView(ContainerPart containerPart)
        {
            ContainerPartViewModel model = new ContainerPartViewModel();

            var _containerRepository    = new ContainerRepository();
            var _partRepository         = new PartRepository();
            var _dynamicsPartRepository = new PartDynamicsRepository();
            var _foundryOrderRepository = new FoundryOrderRepository();

            var container        = _containerRepository.GetContainer(containerPart.ContainerId);
            var foundryOrderPart = _foundryOrderRepository.GetFoundryOrderParts().FirstOrDefault(x => x.FoundryOrderPartId == containerPart.FoundryOrderPartId);
            var part             = _partRepository.GetPart((foundryOrderPart != null) ? foundryOrderPart.PartId : Guid.Empty);
            var dynamicsPart     = _dynamicsPartRepository.GetPartMaster(part != null && !string.IsNullOrEmpty(part.Number) ? part.Number : null);
            var foundryOrder     = _foundryOrderRepository.GetFoundryOrder((foundryOrderPart != null) ? foundryOrderPart.FoundryOrderId : Guid.Empty);

            model.FoundryOrderPartId = containerPart.FoundryOrderPartId;
            model.ContainerPartId    = containerPart.ContainerPartId;
            model.ContainerId        = containerPart.ContainerId;
            model.PartId             = (part != null) ? part.PartId : Guid.Empty;
            model.ContainerNumber    = (container != null) ? container.Number : "N/A";
            model.PartNumber         = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.FoundryOrderId     = (foundryOrder != null) ? foundryOrder.FoundryOrderId : Guid.Empty;
            model.OrderNumber        = (foundryOrder != null && !string.IsNullOrEmpty(foundryOrder.Number)) ? foundryOrder.Number : "N/A";
            model.PalletNumber       = (!string.IsNullOrEmpty(containerPart.PalletNumber)) ? containerPart.PalletNumber : "N/A";
            model.Quantity           = containerPart.Quantity;
            model.Weight             = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.Cost              = foundryOrderPart.Cost;
            model.Price             = foundryOrderPart.Price;
            model.AvailableQuantity = (foundryOrderPart != null) ? foundryOrderPart.Quantity : 0;
            model.ShipCode          = (foundryOrderPart != null && !string.IsNullOrEmpty(foundryOrderPart.ShipCode)) ? foundryOrderPart.ShipCode : "N/A";

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

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

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

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

            return(model);
        }
コード例 #2
0
        /// <summary>
        /// convert part to rfq part view model
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public RfqPartViewModel ConvertToView(Part part)
        {
            RfqPartViewModel model = new RfqPartViewModel();

            var _partRepository         = new PartRepository();
            var _dynamicsPartRepository = new PartDynamicsRepository();
            var _materialRepository     = new MaterialRepository();

            var dynamicsPart = _dynamicsPartRepository.GetPartMaster(part.Number);
            var material     = _materialRepository.GetMaterial(part.MaterialId);
            var partDrawing  = _partRepository.GetPartDrawings(part.PartId).FirstOrDefault(x => x.IsLatest);

            model.PartId              = part.PartId;
            model.PartNumber          = (!string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartDescription     = (dynamicsPart != null && !string.IsNullOrEmpty(dynamicsPart.ITEMDESC)) ? dynamicsPart.ITEMDESC : "N/A";
            model.CustomerId          = part.CustomerId;
            model.FoundryId           = part.FoundryId;
            model.Weight              = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.AnnualUsage         = part.AnnualUsage;
            model.IsMachined          = part.IsMachined;
            model.MaterialId          = part.MaterialId;
            model.MaterialDescription = (material != null && !string.IsNullOrEmpty(material.Description)) ? material.Description : "N/A";
            model.RevisionNumber      = (partDrawing != null && !string.IsNullOrEmpty(partDrawing.RevisionNumber)) ? partDrawing.RevisionNumber : "N/A";
            model.PartDrawingId       = (partDrawing != null) ? partDrawing.PartDrawingId : Guid.Empty;
            model.PartTypeId          = part.PartTypeId;
            model.PartStatusId        = part.PartStatusId;
            model.DestinationId       = part.DestinationId;
            model.SurchargeId         = part.SurchargeId;
            model.SubFoundryId        = part.SubFoundryId;

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

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

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

            return(model);
        }
コード例 #3
0
        /// <summary>
        /// convert container part to packlingList part view model
        /// </summary>
        /// <param name="containerPart"></param>
        /// <returns></returns>
        public PackingListPartViewModel ConvertToView(ContainerPart containerPart)
        {
            PackingListPartViewModel model = new PackingListPartViewModel();

            var _foundryOrderRepository  = new FoundryOrderRepository();
            var _partRepository          = new PartRepository();
            var _dynamicsPartRepository  = new PartDynamicsRepository();
            var _customerOrderRepository = new CustomerOrderRepository();

            var foundryOrderPart  = _foundryOrderRepository.GetFoundryOrderPart(containerPart.FoundryOrderPartId);
            var part              = _partRepository.GetPart(foundryOrderPart.PartId);
            var dynamicsPart      = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : null);
            var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart(foundryOrderPart.CustomerOrderPartId);
            var customerOrder     = _customerOrderRepository.GetCustomerOrder(customerOrderPart.CustomerOrderId);

            model.ShipCode       = foundryOrderPart.ShipCode;
            model.PartNumber     = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartWeight     = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.PartQuantity   = containerPart.Quantity;
            model.PalletNumber   = (!string.IsNullOrEmpty(containerPart.PalletNumber)) ? containerPart.PalletNumber : "N/A";
            model.PONumber       = (customerOrder != null && !string.IsNullOrEmpty(customerOrder.PONumber)) ? customerOrder.PONumber : "N/A";
            model.PalletQuantity = containerPart.Quantity;
            model.InvoiceNumber  = "Will fill in later";

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

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

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

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

            return(model);
        }
コード例 #4
0
        /// <summary>
        /// convert part to quote part view model
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public QuotePartViewModel ConvertToView(Part part)
        {
            QuotePartViewModel model = new QuotePartViewModel();

            var _partRepository         = new PartRepository();
            var _dynamicsPartRepository = new PartDynamicsRepository();
            var _partStatusRepository   = new PartStatusRepository();

            var dynamicsPart         = _dynamicsPartRepository.GetPartMaster(part.Number);
            var dynamicsPartCurrency = _dynamicsPartRepository.GetPartCurrency(part.Number);
            var partStatus           = _partStatusRepository.GetPartStatus(part.PartStatusId);
            var partDrawing          = _partRepository.GetPartDrawings(part.PartId).FirstOrDefault(x => x.IsLatest);

            model.PartId          = part.PartId;
            model.PartNumber      = (!string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartDescription = (dynamicsPart != null && !string.IsNullOrEmpty(dynamicsPart.ITEMDESC)) ? dynamicsPart.ITEMDESC : "N/A";
            model.CustomerId      = part.CustomerId;
            model.FoundryId       = part.FoundryId;
            model.RevisionNumber  = (partDrawing != null && !string.IsNullOrEmpty(partDrawing.RevisionNumber)) ? partDrawing.RevisionNumber : "N/A";
            model.Weight          = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.AnnualUsage     = part.AnnualUsage;
            model.Price           = (dynamicsPartCurrency != null) ? (decimal)dynamicsPartCurrency.LISTPRCE : 0.00m;
            model.PatternPrice    = part.PatternPrice;
            model.FixturePrice    = part.FixturePrice;
            model.Cost            = (dynamicsPart != null) ? (decimal)dynamicsPart.STNDCOST : 0.00m;
            model.PatternCost     = part.PatternCost;
            model.FixtureCost     = part.FixtureCost;
            model.IsRaw           = part.IsRaw;
            model.IsMachined      = part.IsMachined;

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

            return(model);
        }
コード例 #5
0
        /// <summary>
        /// convert price sheet part to view model for production price sheet
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public PriceSheetPartViewModel ConvertToPartView(PriceSheetPart part)
        {
            PriceSheetPartViewModel model = new PriceSheetPartViewModel();

            var _partRepository         = new PartRepository();
            var _dynamicsPartRepository = new PartDynamicsRepository();
            var _priceSheetRepository   = new PriceSheetRepository();
            var _projectPartRepository  = new ProjectPartRepository();

            var priceSheet   = _priceSheetRepository.GetPriceSheet(part.PriceSheetId);
            var projectPart  = _projectPartRepository.GetProjectPart(part.ProjectPartId);
            var tempPart     = _partRepository.GetPart((projectPart != null) ? projectPart.PartId : null);
            var dynamicsPart = _dynamicsPartRepository.GetPartMaster((tempPart != null) ? tempPart.Number : null);

            model.ProjectPartId         = part.ProjectPartId ?? Guid.Empty;
            model.PartId                = (tempPart != null) ? tempPart.PartId : Guid.Empty;
            model.PriceSheetPartId      = part.PriceSheetPartId;
            model.PriceSheetId          = part.PriceSheetId;
            model.PriceSheetNumber      = (priceSheet != null) ? priceSheet.Number : "N/A";
            model.PartNumber            = (tempPart != null) ? tempPart.Number : "N/A";
            model.PartDescription       = (dynamicsPart != null && !string.IsNullOrEmpty(dynamicsPart.ITEMDESC)) ? dynamicsPart.ITEMDESC : "N/A";
            model.AvailableQuantity     = part.AvailableQuantity;
            model.CustomerOrderQuantity = part.AvailableQuantity;
            model.UnitPrice             = part.Price;
            model.UnitCost              = part.Cost;

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

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

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

            return(model);
        }
コード例 #6
0
        /// <summary>
        /// convert part to part inventory list model
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public PartInventoryViewModel ConvertToListView(Part part)
        {
            PartInventoryViewModel model = new PartInventoryViewModel();

            var _partRepository            = new PartRepository();
            var _dynamicsPartRepository    = new PartDynamicsRepository();
            var _foundryOrderRepository    = new FoundryOrderRepository();
            var _dynamicsReceiptRepository = new ReceiptDynamicsRepository();

            var dynamicsPartQty    = _dynamicsPartRepository.GetPartQuantityMaster(part.Number);
            var dynamicsPartStatus = _dynamicsPartRepository.GetItemStatus(part.Number);
            var dynamicsPartSales  = _dynamicsPartRepository.GetItemSales(part.Number);

            model.PartId          = part.PartId;
            model.PartNumber      = part.Number;
            model.CustomerId      = part.CustomerId;
            model.FoundryId       = part.FoundryId;
            model.QuantityOnHand  = (dynamicsPartStatus != null) ? Math.Round(dynamicsPartStatus.Quantity_on_Hand, 2) : 0.00m;
            model.Cost            = (dynamicsPartStatus != null) ? Math.Round(dynamicsPartStatus.Cost, 2) : 0.00m;
            model.OnOrderQuantity = (dynamicsPartQty != null) ? Math.Round(dynamicsPartQty.QTYONORD, 2) : 0.00m;
            model.ReceiptDate     = (dynamicsPartStatus != null && dynamicsPartStatus.Last_Receipt_Date != null) ? dynamicsPartStatus.Last_Receipt_Date : DateTime.MinValue;
            model.ReceiptDateStr  = (dynamicsPartStatus != null && dynamicsPartStatus.Last_Receipt_Date != null) ? dynamicsPartStatus.Last_Receipt_Date.ToShortDateString() : "N/A";
            model.ReceiptQuantity = (dynamicsPartQty != null) ? Math.Round(dynamicsPartQty.LRCPTQTY, 2) : 0.00m;
            model.SalesDate       = (dynamicsPartStatus != null && dynamicsPartStatus.Last_Sale_Date != null) ? dynamicsPartStatus.Last_Sale_Date : DateTime.MinValue;
            model.SalesDateStr    = (dynamicsPartStatus != null && dynamicsPartStatus.Last_Sale_Date != null) ? dynamicsPartStatus.Last_Sale_Date.ToShortDateString() : "N/A";
            model.YearToDateSales = (dynamicsPartSales != null) ? Math.Round(dynamicsPartSales.YTD_SALES, 2) : 0.00m;

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

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

            return(model);
        }
コード例 #7
0
        /// <summary>
        /// convert customer order part to part view model
        /// </summary>
        /// <param name="customerOrderPart"></param>
        /// <returns></returns>
        public CustomerOrderPartViewModel ConvertToPartView(CustomerOrderPart customerOrderPart)
        {
            CustomerOrderPartViewModel model = new CustomerOrderPartViewModel();

            var _priceSheetRepository    = new PriceSheetRepository();
            var _partRepository          = new PartRepository();
            var _dynamicsPartRepository  = new PartDynamicsRepository();
            var _customerOrderRepository = new CustomerOrderRepository();
            var _foundryOrderRepository  = new FoundryOrderRepository();


            var priceSheetPart   = _priceSheetRepository.GetPriceSheetPart(customerOrderPart.PriceSheetPartId);
            var part             = _partRepository.GetPart((customerOrderPart.PartId != null) ? customerOrderPart.PartId : Guid.Empty);
            var dynamicsPart     = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : string.Empty);
            var priceSheet       = _priceSheetRepository.GetPriceSheet((priceSheetPart != null) ? priceSheetPart.PriceSheetId : Guid.Empty);
            var customerOrder    = _customerOrderRepository.GetCustomerOrder(customerOrderPart.CustomerOrderId);
            var receivedQuantity = _foundryOrderRepository.GetFoundryOrderParts().Where(x => x.CustomerOrderPartId == customerOrderPart.CustomerOrderPartId &&
                                                                                        x.HasBeenReceived).Select(y => y.ReceiptQuantity).Sum();

            model.CustomerOrderId     = customerOrderPart.CustomerOrderId;
            model.CustomerOrderPartId = customerOrderPart.CustomerOrderPartId;
            model.PONumber            = (customerOrder != null && !string.IsNullOrEmpty(customerOrder.PONumber)) ? customerOrder.PONumber : "N/A";
            model.PartId                = customerOrderPart.PartId;
            model.PriceSheetPartId      = customerOrderPart.PriceSheetPartId;
            model.PriceSheetId          = (priceSheet != null) ? priceSheet.PriceSheetId : Guid.Empty;
            model.AvailableQuantity     = customerOrderPart.AvailableQuantity;
            model.CustomerOrderQuantity = customerOrderPart.Quantity;
            model.PartNumber            = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartDescription       = (dynamicsPart != null && !string.IsNullOrEmpty(dynamicsPart.ITEMDESC)) ? dynamicsPart.ITEMDESC : "N/A";
            model.PriceSheetNumber      = (priceSheet != null && !string.IsNullOrEmpty(priceSheet.Number)) ? priceSheet.Number : "N/A";
            model.EstArrivalDate        = (customerOrderPart.EstArrivalDate != null) ? customerOrderPart.EstArrivalDate : DateTime.MinValue;
            model.EstArrivalDateStr     = (customerOrderPart.EstArrivalDate != null) ? customerOrderPart.EstArrivalDate.Value.ToShortDateString() : "N/A";
            model.ShipDate              = (customerOrderPart.ShipDate != null) ? customerOrderPart.ShipDate : DateTime.MinValue;;
            model.ShipDateStr           = (customerOrderPart.ShipDate != null) ? customerOrderPart.ShipDate.Value.ToShortDateString() : "N/A";
            model.Cost            = customerOrderPart.Cost;
            model.Price           = customerOrderPart.Price;
            model.ReceiptQuantity = receivedQuantity;

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

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

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

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

            return(model);
        }
コード例 #8
0
        /// <summary>
        /// convert foundry order part to part view model
        /// </summary>
        /// <param name="foundryOrderPart"></param>
        /// <returns></returns>
        public FoundryOrderPartViewModel ConvertToPartView(FoundryOrderPart foundryOrderPart)
        {
            FoundryOrderPartViewModel model = new FoundryOrderPartViewModel();

            var _customerOrderPartRepository = new CustomerOrderRepository();
            var _partRepository          = new PartRepository();
            var _dynamicsPartRepository  = new PartDynamicsRepository();
            var _customerOrderRepository = new CustomerOrderRepository();
            var _foundryOrderRepository  = new FoundryOrderRepository();

            var customerOrderPart = _customerOrderPartRepository.GetCustomerOrderPart(foundryOrderPart.CustomerOrderPartId);
            var part          = _partRepository.GetPart(foundryOrderPart.PartId);
            var dynamicsPart  = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : string.Empty);
            var customerOrder = _customerOrderRepository.GetCustomerOrder((customerOrderPart != null) ? customerOrderPart.CustomerOrderId : Guid.Empty);
            var foundryOrder  = _foundryOrderRepository.GetFoundryOrder(foundryOrderPart.FoundryOrderId);

            model.FoundryOrderPartId  = foundryOrderPart.FoundryOrderPartId;
            model.CustomerOrderPartId = foundryOrderPart.CustomerOrderPartId;
            model.CustomerOrderId     = (customerOrder != null) ? customerOrder.CustomerOrderId : Guid.Empty;
            model.PartId               = foundryOrderPart.PartId;
            model.Weight               = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.FoundryOrderId       = foundryOrderPart.FoundryOrderId;
            model.OrderNumber          = (foundryOrder != null && !string.IsNullOrEmpty(foundryOrder.Number)) ? foundryOrder.Number : "N/A";
            model.AvailableQuantity    = foundryOrderPart.AvailableQuantity;
            model.Quantity             = foundryOrderPart.Quantity;
            model.MaxQuantity          = foundryOrderPart.Quantity;
            model.FoundryOrderQuantity = foundryOrderPart.Quantity;
            model.PartNumber           = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartDescription      = (dynamicsPart != null && !string.IsNullOrEmpty(dynamicsPart.ITEMDESC)) ? dynamicsPart.ITEMDESC : "N/A";
            model.PONumber             = (customerOrder != null && !string.IsNullOrEmpty(customerOrder.PONumber)) ? customerOrder.PONumber : "N/A";
            model.ShipCode             = (!string.IsNullOrEmpty(foundryOrderPart.ShipCode)) ? foundryOrderPart.ShipCode : "N/A";
            model.ShipCodeNotes        = (!string.IsNullOrEmpty(foundryOrderPart.ShipCodeNotes)) ? foundryOrderPart.ShipCodeNotes : "N/A";
            model.EstArrivalDate       = (foundryOrderPart.EstArrivalDate != null) ? foundryOrderPart.EstArrivalDate : DateTime.MinValue;
            model.EstArrivalDateStr    = (foundryOrderPart.EstArrivalDate != null) ? foundryOrderPart.EstArrivalDate.Value.ToShortDateString() : "N/A";
            model.ShipDate             = (foundryOrderPart.ShipDate != null) ? foundryOrderPart.ShipDate : DateTime.MinValue;
            model.ShipDateStr          = (foundryOrderPart.ShipDate != null) ? foundryOrderPart.ShipDate.Value.ToShortDateString() : "N/A";
            model.ReceiptDate          = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate : DateTime.MinValue;
            model.ReceiptDateStr       = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.ToShortDateString() : "N/A";
            model.Cost            = foundryOrderPart.Cost;
            model.Price           = foundryOrderPart.Price;
            model.IsScheduled     = foundryOrderPart.IsScheduled;
            model.HasBeenReceived = foundryOrderPart.HasBeenReceived;
            model.ReceiptDate     = (foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate : DateTime.MinValue;
            model.ReceiptDateStr  = (foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.ToShortDateString() : "N/A";
            model.ReceiptQuantity = foundryOrderPart.ReceiptQuantity;

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

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

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

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

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

            return(model);
        }
コード例 #9
0
        /// <summary>
        /// convert part to project part list model
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public ProjectPartViewModel ConvertToListView(Part part)
        {
            ProjectPartViewModel model = new ProjectPartViewModel();

            var _dynamicsPartRepository     = new PartDynamicsRepository();
            var _customerDynamicsRepository = new CustomerDynamicsRepository();
            var _foundryDynamicsRepository  = new FoundryDynamicsRepository();
            var _htsNumberRepository        = new HtsNumberRepository();
            var _partTypeRepository         = new PartTypeRepository();
            var _partStatusRepository       = new PartStatusRepository();

            var dynamicsPart     = _dynamicsPartRepository.GetPartMaster(part.Number);
            var dynamicsCustomer = _customerDynamicsRepository.GetCustomer(part.CustomerId);
            var dynamicsFoundry  = _foundryDynamicsRepository.GetFoundry(part.FoundryId);
            var htsNumber        = _htsNumberRepository.GetHtsNumber(part.HtsNumberId);
            var partType         = _partTypeRepository.GetPartType(part.PartTypeId);
            var partStatus       = _partStatusRepository.GetPartStatus(part.PartStatusId);

            model.PartId                = part.PartId;
            model.PartNumber            = (!string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartDescription       = (dynamicsPart != null && !string.IsNullOrEmpty(dynamicsPart.ITEMDESC)) ? dynamicsPart.ITEMDESC : "N/A";
            model.CustomerId            = part.CustomerId;
            model.CustomerName          = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A";
            model.FoundryId             = part.FoundryId;
            model.FoundryName           = (dynamicsFoundry != null && !string.IsNullOrEmpty(dynamicsFoundry.VENDSHNM)) ? dynamicsFoundry.VENDSHNM : "N/A";
            model.HtsNumberId           = part.HtsNumberId;
            model.HtsNumber             = (htsNumber != null && !string.IsNullOrEmpty(htsNumber.Description)) ? htsNumber.Description + "(" + (htsNumber.DutyRate * 100).ToString() + "%)" : "N/A";
            model.PartTypeId            = part.PartTypeId;
            model.PartTypeDescription   = (partType != null && !string.IsNullOrEmpty(partType.Description)) ? partType.Description : "N/A";
            model.PartStatusId          = part.PartStatusId;
            model.PartStatusDescription = (partStatus != null && !string.IsNullOrEmpty(partStatus.Description)) ? partStatus.Description : "N/A";
            model.IsProject             = false;

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

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

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

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

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

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

            return(model);
        }
コード例 #10
0
        /// <summary>
        /// convert container part to warehouse inventory list model
        /// </summary>
        /// <param name="containerPart"></param>
        /// <returns></returns>
        public WarehouseInventoryViewModel ConvertToListView(ContainerPart containerPart)
        {
            WarehouseInventoryViewModel model = new WarehouseInventoryViewModel();

            var _foundryOrderRepository  = new FoundryOrderRepository();
            var _customerOrderRepository = new CustomerOrderRepository();
            var _partRepository          = new PartRepository();
            var _dynamicsPartRepository  = new PartDynamicsRepository();
            var _containerRepository     = new ContainerRepository();

            var foundryOrderPart  = _foundryOrderRepository.GetFoundryOrderPart(containerPart.FoundryOrderPartId);
            var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart((foundryOrderPart != null) ? foundryOrderPart.CustomerOrderPartId : Guid.Empty);
            var part         = _partRepository.GetPart((foundryOrderPart != null) ? foundryOrderPart.PartId : Guid.Empty);
            var dynamicsPart = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : string.Empty);
            var container    = _containerRepository.GetContainer(containerPart.ContainerId);

            model.CustomerId       = (part != null) ? part.CustomerId : "N/A";
            model.ShipCode         = (foundryOrderPart != null) ? foundryOrderPart.ShipCode : "N/A";
            model.PartNumber       = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartWeight       = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.PalletNumber     = (!string.IsNullOrEmpty(part.Number)) ? containerPart.PalletNumber : "N/A";
            model.PalletQuantity   = containerPart.Quantity;
            model.TotalQuantity    = containerPart.Quantity;
            model.ContainerNumber  = (!string.IsNullOrEmpty(part.Number)) ? container.Number : "N/A";
            model.PONumber         = (customerOrderPart != null && !string.IsNullOrEmpty(customerOrderPart.CustomerOrder.PONumber)) ? customerOrderPart.CustomerOrder.PONumber : "N/A";
            model.WarehouseDate    = (foundryOrderPart != null) ? foundryOrderPart.ReceiptDate : DateTime.MinValue;
            model.WarehouseDateStr = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.ToShortDateString() : "N/A";
            model.SixtyDaysDate    = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.AddDays(60) : DateTime.MinValue;
            model.SixtyDaysDateStr = (model.SixtyDaysDate != null) ? model.SixtyDaysDate.Value.ToShortDateString() : "N/A";

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

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

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

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

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

            return(model);
        }
コード例 #11
0
        /// <summary>
        /// convert part to view model
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public PartViewModel ConvertToView(Part part)
        {
            PartViewModel model = new PartViewModel();

            var _partRepository             = new PartRepository();
            var _dynamicsPartRepository     = new PartDynamicsRepository();
            var _projectPartRepository      = new ProjectPartRepository();
            var _customerDynamicsRepository = new CustomerDynamicsRepository();
            var _foundryDynamicsRepository  = new FoundryDynamicsRepository();
            var _htsNumberRepository        = new HtsNumberRepository();
            var _partTypeRepository         = new PartTypeRepository();
            var _partStatusRepository       = new PartStatusRepository();
            var _foundryOrderRepository     = new FoundryOrderRepository();

            var dynamicsPart             = _dynamicsPartRepository.GetPartMaster(part.Number);
            var dynamicsPartQty          = _dynamicsPartRepository.GetPartQuantityMaster(part.Number);
            var dynamicsPartCurrency     = _dynamicsPartRepository.GetPartCurrency(part.Number);
            var dynamicsPartRollingSales = _dynamicsPartRepository.GetItemRollingSales(part.Number);
            var foundryOrderPart         = _foundryOrderRepository.GetFoundryOrderPartByPart(part.PartId);

            if (foundryOrderPart != null)
            {
                var toolingOrder = _foundryOrderRepository.GetToolingFoundryOrder(foundryOrderPart.FoundryOrderId);
                model.FoundryOrderId     = (toolingOrder != null) ? foundryOrderPart.FoundryOrderId : Guid.Empty;
                model.ToolingOrderNumber = (toolingOrder != null && !string.IsNullOrEmpty(toolingOrder.Number)) ? toolingOrder.Number : "N/A";
                model.ToolingDescription = (!string.IsNullOrEmpty(part.ToolingDescription)) ? part.ToolingDescription : "N/A";
            }

            var latestDrawing = _partRepository.GetPartDrawings(part.PartId).FirstOrDefault(x => x.IsLatest == true);

            var weight = (dynamicsPart != null) ? Math.Round((dynamicsPart.ITEMSHWT / 100.00m), 2) : 0.00m;

            var yearlySalesTotal = (dynamicsPartRollingSales != null) ? (dynamicsPartRollingSales.Sales_1_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_2_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_3_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_4_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_5_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_6_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_7_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_8_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_9_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_10_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_11_mo_ago +
                                                                         dynamicsPartRollingSales.Sales_12_mo_ago) : 0.00m;

            model.ProjectPartId           = Guid.Empty;
            model.PartId                  = part.PartId;
            model.PartNumber              = (!string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.AccountCode             = (!string.IsNullOrEmpty(part.AccountCode)) ? part.AccountCode : "N/A";
            model.PartDescription         = (dynamicsPart != null && !string.IsNullOrEmpty(dynamicsPart.ITEMDESC)) ? dynamicsPart.ITEMDESC : "N/A";
            model.RevisionNumber          = (latestDrawing != null && !string.IsNullOrEmpty(latestDrawing.RevisionNumber)) ? latestDrawing.RevisionNumber : "N/A";
            model.CustomerId              = part.CustomerId;
            model.CustomerAddressId       = part.CustomerAddressId;
            model.FoundryId               = part.FoundryId;
            model.SubFoundryId            = part.SubFoundryId;
            model.HtsNumberId             = part.HtsNumberId;
            model.MaterialId              = part.MaterialId;
            model.SpecificationMaterialId = part.MaterialSpecificationId;
            model.PartStatusId            = part.PartStatusId;
            model.PartTypeId              = part.PartTypeId;
            model.ShipmentTermId          = part.ShipmentTermId;
            model.PaymentTermId           = part.PaymentTermId;
            model.SurchargeId             = part.SurchargeId;
            model.SiteId                  = part.SiteId;
            model.DestinationId           = part.DestinationId;
            model.CoatingTypeId           = part.CoatingTypeId;
            model.PatternMaterialId       = part.PatternMaterialId;
            model.IsRaw               = part.IsRaw;
            model.IsMachined          = part.IsMachined;
            model.PalletQuantity      = (part.PalletQuantity != 0) ? part.PalletQuantity : 0;
            model.PalletWeight        = (part.PalletQuantity != 0) ? part.PalletQuantity * weight : 0.00m;
            model.Weight              = weight;
            model.Cost                = (dynamicsPart != null && (Math.Round(dynamicsPart.STNDCOST, 2) != 0.00m)) ? Math.Round(dynamicsPart.STNDCOST, 2) : 0.00m;
            model.Price               = (dynamicsPartCurrency != null && (Math.Round(dynamicsPartCurrency.LISTPRCE, 2) != 0.00m)) ? Math.Round(dynamicsPartCurrency.LISTPRCE, 2) : 0.00m;
            model.AdditionalCost      = (part.AdditionalCost != 0.00m) ? part.AdditionalCost : 0.00m;
            model.YearlySalesTotal    = Math.Round(yearlySalesTotal, 2);
            model.SixtyDaysSalesTotal = (yearlySalesTotal != 0.00m) ? Math.Round((yearlySalesTotal / 6), 2) : 0.00m;
            model.MonthlySalesTotal   = (yearlySalesTotal != 0.00m) ? Math.Round((yearlySalesTotal / 12), 2) : 0.00m;
            model.AverageDailySales   = (yearlySalesTotal != 0.00m) ? Math.Round((yearlySalesTotal / 365), 2) : 0.00m;
            model.QuantityOnHand      = (dynamicsPartQty != null && (Math.Round(dynamicsPartQty.QTYONHND, 2) != 0.00m)) ? Math.Round(dynamicsPartQty.QTYONHND, 2) : 0.00m;
            model.FixtureDate         = (part.FixtureDate != null) ? part.FixtureDate : DateTime.MinValue;
            model.FixtureDateStr      = (part.FixtureDate != null) ? part.FixtureDate.Value.ToShortDateString() : "N/A";
            model.FixtureCost         = (Math.Round(part.FixtureCost, 2) != 0.00m) ? Math.Round(part.FixtureCost, 2) : 0.00m;
            model.FixturePrice        = (Math.Round(part.FixturePrice, 2) != 0.00m) ? Math.Round(part.FixturePrice, 2) : 0.00m;
            model.PatternDate         = (part.PatternDate != null) ? part.PatternDate : DateTime.MinValue;
            model.PatternDateStr      = (part.PatternDate != null) ? part.PatternDate.Value.ToShortDateString() : "N/A";
            model.PatternCost         = (Math.Round(part.PatternCost, 2) != 0.00m) ? Math.Round(part.PatternCost, 2) : 0.00m;
            model.PatternPrice        = (Math.Round(part.PatternPrice, 2) != 0.00m) ? Math.Round(part.PatternPrice, 2) : 0.00m;
            model.IsFamilyPattern     = part.IsFamilyPattern;
            model.Notes               = (!string.IsNullOrEmpty(part.Notes)) ? part.Notes : "N/A";
            model.AnnualUsage         = (part.AnnualUsage != 0) ? part.AnnualUsage : 0;
            model.IsActive            = part.IsActive;
            model.IsProjectPart       = false;

            var partDrawings = _partRepository.GetPartDrawings(model.PartId ?? Guid.Empty);

            if (part.PartDrawings != null && part.PartDrawings.Count > 0)
            {
                var drawings = new List <DrawingViewModel>();

                foreach (var partDrawing in partDrawings)
                {
                    DrawingViewModel convertedModel = new PartDrawingConverter().ConvertToView(partDrawing);
                    drawings.Add(convertedModel);
                }

                model.Drawings = drawings;
            }

            var partLayouts = _partRepository.GetPartLayouts(model.PartId ?? Guid.Empty);

            if (part.PartLayouts != null && part.PartLayouts.Count > 0)
            {
                var layouts = new List <LayoutViewModel>();

                foreach (var partLayout in partLayouts)
                {
                    LayoutViewModel convertedModel = new PartLayoutConverter().ConvertToView(partLayout);
                    layouts.Add(convertedModel);
                }

                model.Layouts = layouts;
            }

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

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

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

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

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

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

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

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

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

            return(model);
        }