Example #1
0
        public SalesOrderItemList addToExistingItemList(SalesOrderItemList oldList, SalesOrderLine salesOrderLine)
        {
            int oldCount = oldList.item.Length;
            int newCount = oldCount + 1;
            SalesOrderItemList newOrderList = new SalesOrderItemList();
            SalesOrderItem[] newItem = new SalesOrderItem[1];
            SalesOrderItem[] newList = new SalesOrderItem[newCount];
            oldList.item.CopyTo(newList, 0);

            newItem[0] = new SalesOrderItem();
            RecordRef item = new RecordRef();
            item.type = RecordType.inventoryItem;
            item.typeSpecified = true;
            // item.internalId = "1229";
            item.name = salesOrderLine.item.ItemName;
            item.internalId = salesOrderLine.item.itemRecord.internalId;
            newItem[0].item = item;

            RecordRef prLevel = new RecordRef();
            prLevel.type = RecordType.priceLevel;
            prLevel.internalId = "-1";
            prLevel.typeSpecified = true;

            newItem[0].price = prLevel;
            newItem[0].rate = Convert.ToString(salesOrderLine.UnitPrice);
            newItem[0].quantity = salesOrderLine.QuantityRequested;
            newItem[0].quantitySpecified = true;

            newItem.CopyTo(newList, oldCount);
            newOrderList.item = newList;

            return newOrderList;
        }
Example #2
0
        public void editOrder(List<SalesOrderLine> orderLines)
        {
            SalesOrder updatedOrder = new SalesOrder();
            updatedOrder.salesOrder = new com.netsuite.webservices.SalesOrder();
            updatedOrder.salesOrder.internalId = this.salesOrder.internalId;
            updatedOrder.salesOrder.itemList = new SalesOrderItemList();
            bool flag = false;
            bool contains = false;
            bool contains1 = false;

            foreach (var line in orderLines)
            {
                foreach (var itemObject in this.salesOrder.itemList.item)
                {
                    //if (itemObject.item.name.Contains(line.item.ItemName))
                    if (itemObject.item.name.Contains(line.item.ItemName) && (line.delete == true))
                    {
                        this.salesOrder.itemList.item = this.salesOrder.itemList.item.Where(val => !val.item.name.Contains(line.item.ItemName)).ToArray();
                    }
                    if (itemObject.item.name.Contains(line.item.ItemName) && (line.delete == false))
                    {
                        itemObject.quantity = line.QuantityRequested;
                        contains1 = true;
                    }
                    if (!itemObject.item.name.Contains(line.item.ItemName) && (line.delete == false))
                    {
                        contains = false;
                    }
                    if (!itemObject.item.name.Contains(line.item.ItemName) && (line.delete == true))
                    {
                        contains = true;
                    }
                }

                if (!(contains || contains1))
                {
                    SalesOrderLine addLine = new SalesOrderLine(line.item.ItemName, line.QuantityRequested, line.UnitPrice, flag);
                    this.salesOrder.itemList = this.addToExistingItemList(this.salesOrder.itemList, addLine);
                }
                contains = false;
                contains1 = false;
            }

            List<SalesOrderLine> newItemList = new List<SalesOrderLine>();
            newItemList = createNewSalesOrderLines(this.salesOrder.itemList);
            updatedOrder.addItemList(newItemList);

            NetSuiteService service = new NetSuiteService();
            service.CookieContainer = new CookieContainer();
            NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168");
            Passport passport = user.prepare(user);
            Status status = service.login(passport).status;

            WriteResponse writeResponse = service.update(updatedOrder.salesOrder);
            if (writeResponse.status.isSuccess == true)
            {
                Console.WriteLine("Update Sales Order success");
            }
            if (writeResponse.status.isSuccess == false)
            {
                Console.WriteLine(writeResponse.status.statusDetail[0].message);
            }
        }
Example #3
0
        public List<SalesOrderLine> createNewSalesOrderLines(SalesOrderItemList oldItemList)
        {
            List<SalesOrderLine> newItemList = new List<SalesOrderLine>();
            bool flag = false;
            foreach (var line in oldItemList.item)
            {
                SalesOrderLine newLine = new SalesOrderLine(line.item.name, line.quantity, Convert.ToDecimal(line.rate), flag);
                newItemList.Add(newLine);
            }

            return newItemList;
        }