示例#1
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);
            }
        }
示例#2
0
        public string approveOrder()
        {
            SalesOrder updatedOrder = new SalesOrder();
            updatedOrder.salesOrder = new com.netsuite.webservices.SalesOrder();
            updatedOrder.salesOrder.internalId = this.salesOrder.internalId;
            updatedOrder.salesOrder.itemList = new SalesOrderItemList();
            updatedOrder.salesOrder.orderStatus = SalesOrderOrderStatus._pendingFulfillment;
            updatedOrder.salesOrder.orderStatusSpecified = true;

            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("Approved Sales Order success");
            }
            if (writeResponse.status.isSuccess == false)
            {
                Console.WriteLine(writeResponse.status.statusDetail[0].message);
            }

            return this.salesOrder.tranId;
        }