public InventoryItem[] getSupplierInventory(GetSupplierInventoryRequest request)
    {
        DetachedCriteria criteria = DetachedCriteria.For<SupllierLocationView>();


        if (request.supplierCode != null && request.supplierCode != string.Empty)
        {
            criteria.Add(Expression.Like("PartyFrom.Code", request.supplierCode));
        }

        if (request.company != null && request.company != string.Empty)
        {
            criteria.Add(Expression.Like("PartyFrom.Name", request.company));
        }

        IList<SupllierLocationView> supplierLocationList = TheCriteriaMgr.FindAll<SupllierLocationView>(criteria, request.beginRowIndex, request.beginRowIndex + request.rowSize);
        List<InventoryItem> iItemList = new List<InventoryItem>();

        foreach (SupllierLocationView supplierLocation in supplierLocationList)
        {

            //set region					
            com.Sconit.Entity.Svp.Party party = new com.Sconit.Entity.Svp.Party();
            party.code = supplierLocation.PartyTo.Code;
            party.id = supplierLocation.PartyTo.Code;
            party.description = supplierLocation.PartyTo.Name;
            party.type = supplierLocation.PartyTo.Type;

            //set supplier
            com.Sconit.Entity.Svp.Party supplier = new com.Sconit.Entity.Svp.Party();
            supplier.id = supplierLocation.PartyFrom.Code;
            supplier.code = supplierLocation.PartyFrom.Code;
            supplier.description = supplierLocation.PartyFrom.Name;
            supplier.type = supplierLocation.PartyFrom.Type;

            //set unit of messure
            UOM uom = new UOM();
            uom.id = supplierLocation.Item.Code;
            uom.abbreviation = supplierLocation.Item.Code;
            uom.description = supplierLocation.Item.Description;

            //set supplier Item
            string refItemCode = TheItemReferenceMgr.GetItemReferenceByItem(supplierLocation.Item.Code, supplierLocation.PartyFrom.Code, supplierLocation.PartyTo.Code);
            Material suppItem = new Material();
            suppItem.id = refItemCode;
            suppItem.no = refItemCode;
            suppItem.description = refItemCode;
            suppItem.quantityUOM = uom;

            //set Item
            Material material = new Material();
            material.id = supplierLocation.Item.Code;
            material.no = supplierLocation.Item.Code;
            material.name = supplierLocation.Item.Description;
            material.description = supplierLocation.Item.Description;
            suppItem.quantityUOM = uom;

            //set supplier material
            string2MaterialMapEntry[] suppItemMap = new string2MaterialMapEntry[1];
            suppItemMap[0] = new string2MaterialMapEntry();
            suppItemMap[0].key = supplier.code;
            suppItemMap[0].value = suppItem;
            material.supplierMaterials = suppItemMap;

            //set location
            com.Sconit.Entity.Svp.Location location = new com.Sconit.Entity.Svp.Location();
            location.id = supplierLocation.Location.Code;
            location.name = supplierLocation.Location.Name;

            //set inventory
            InventoryItem iItem = new InventoryItem();
            iItem.ownerParty = party;
            iItem.supplier = supplier;
            iItem.material = material;
            iItem.location = location;
            iItem.quantityOnHand = Convert.ToDouble(supplierLocation.Qty);
            iItem.quantityOnHandSpecified = true;
            iItem.unitCount = Convert.ToDouble(supplierLocation.Item.UnitCount);
            iItem.unitCountSpecified = true;

            iItemList.Add(iItem);
        }

        return iItemList.ToArray();

    }
Exemplo n.º 2
0
    public InventoryItem[] getSupplierInventory(GetSupplierInventoryRequest request)
    {
        DetachedCriteria criteria = DetachedCriteria.For <SupllierLocationView>();


        if (request.supplierCode != null && request.supplierCode != string.Empty)
        {
            criteria.Add(Expression.Like("PartyFrom.Code", request.supplierCode));
        }

        if (request.company != null && request.company != string.Empty)
        {
            criteria.Add(Expression.Like("PartyFrom.Name", request.company));
        }

        IList <SupllierLocationView> supplierLocationList = TheCriteriaMgr.FindAll <SupllierLocationView>(criteria, request.beginRowIndex, request.beginRowIndex + request.rowSize);
        List <InventoryItem>         iItemList            = new List <InventoryItem>();

        foreach (SupllierLocationView supplierLocation in supplierLocationList)
        {
            //set region
            com.Sconit.Entity.Svp.Party party = new com.Sconit.Entity.Svp.Party();
            party.code        = supplierLocation.PartyTo.Code;
            party.id          = supplierLocation.PartyTo.Code;
            party.description = supplierLocation.PartyTo.Name;
            party.type        = supplierLocation.PartyTo.Type;

            //set supplier
            com.Sconit.Entity.Svp.Party supplier = new com.Sconit.Entity.Svp.Party();
            supplier.id          = supplierLocation.PartyFrom.Code;
            supplier.code        = supplierLocation.PartyFrom.Code;
            supplier.description = supplierLocation.PartyFrom.Name;
            supplier.type        = supplierLocation.PartyFrom.Type;

            //set unit of messure
            UOM uom = new UOM();
            uom.id           = supplierLocation.Item.Code;
            uom.abbreviation = supplierLocation.Item.Code;
            uom.description  = supplierLocation.Item.Description;

            //set supplier Item
            string   refItemCode = TheItemReferenceMgr.GetItemReferenceByItem(supplierLocation.Item.Code, supplierLocation.PartyFrom.Code, supplierLocation.PartyTo.Code);
            Material suppItem    = new Material();
            suppItem.id          = refItemCode;
            suppItem.no          = refItemCode;
            suppItem.description = refItemCode;
            suppItem.quantityUOM = uom;

            //set Item
            Material material = new Material();
            material.id          = supplierLocation.Item.Code;
            material.no          = supplierLocation.Item.Code;
            material.name        = supplierLocation.Item.Description;
            material.description = supplierLocation.Item.Description;
            suppItem.quantityUOM = uom;

            //set supplier material
            string2MaterialMapEntry[] suppItemMap = new string2MaterialMapEntry[1];
            suppItemMap[0]             = new string2MaterialMapEntry();
            suppItemMap[0].key         = supplier.code;
            suppItemMap[0].value       = suppItem;
            material.supplierMaterials = suppItemMap;

            //set location
            com.Sconit.Entity.Svp.Location location = new com.Sconit.Entity.Svp.Location();
            location.id   = supplierLocation.Location.Code;
            location.name = supplierLocation.Location.Name;

            //set inventory
            InventoryItem iItem = new InventoryItem();
            iItem.ownerParty              = party;
            iItem.supplier                = supplier;
            iItem.material                = material;
            iItem.location                = location;
            iItem.quantityOnHand          = Convert.ToDouble(supplierLocation.Qty);
            iItem.quantityOnHandSpecified = true;
            iItem.unitCount               = Convert.ToDouble(supplierLocation.Item.UnitCount);
            iItem.unitCountSpecified      = true;

            iItemList.Add(iItem);
        }

        return(iItemList.ToArray());
    }