public bool LoadByListID(string lid, ref string err)
        {
            string xml = "" +
                         "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                         "<?qbxml version=\"13.0\"?>" +
                         "<QBXML>" +
                         "<QBXMLMsgsRq onError=\"stopOnError\">" +
                         "<ItemInventoryAssemblyQueryRq>" +
                         "<ListID >" + lid + "</ListID>" +
                         "<OwnerID>0</OwnerID>" +
                         "</ItemInventoryAssemblyQueryRq>" +
                         "</QBXMLMsgsRq>" +
                         "</QBXML>";
            var qbook = new Connector(Quickbook.Config.App_Name, Quickbook.Config.File);

            if (qbook.Connect())
            {
                string response = qbook.sendRequest(xml);

                XmlDocument res = new XmlDocument();
                res.LoadXml(response);

                string code          = "";
                string statusMessage = "";

                code          = res["QBXML"]["QBXMLMsgsRs"]["ItemInventoryAssemblyQueryRs"].Attributes["statusCode"].Value;
                statusMessage = res["QBXML"]["QBXMLMsgsRs"]["ItemInventoryAssemblyQueryRs"].Attributes["statusMessage"].Value;

                if (code == "0")
                {
                    var node = res["QBXML"]["QBXMLMsgsRs"]["ItemInventoryAssemblyQueryRs"]["ItemInventoryAssemblyRet"];

                    ListID       = "" + node["ListID"].InnerText;
                    TimeCreated  = DateTime.Parse("" + node["TimeCreated"].InnerText);
                    TimeModified = DateTime.Parse("" + node["TimeModified"].InnerText);
                    EditSequence = "" + node["EditSequence"].InnerText;
                    Name         = "" + node["Name"].InnerText;
                    FullName     = "" + node["FullName"].InnerText;
                    if (node["BarCodeValue"] != null)
                    {
                        BarCodeValue = "" + node["BarCodeValue"].InnerText;
                    }
                    if (node["IsActive"] != null)
                    {
                        IsActive = ("" + node["IsActive"].InnerText == "true" ? true : false);
                    }

                    if (node["ClassRef"] != null)
                    {
                        ClassRef          = new Class();
                        ClassRef.ListID   = "" + node["ClassRef"]["ListID"].InnerText;
                        ClassRef.FullName = "" + node["ClassRef"]["FullName"].InnerText;
                    }

                    if (node["ParentRef"] != null)
                    {
                        ParentRef          = new ItemInventory();
                        ParentRef.ListID   = "" + node["ParentRef"]["ListID"].InnerText;
                        ParentRef.FullName = "" + node["ParentRef"]["FullName"].InnerText;
                    }

                    Sublevel = Int32.Parse("" + node["Sublevel"].InnerText);
                    if (node["ManufacturerPartNumber"] != null)
                    {
                        ManufacturerPartNumber = "" + node["ManufacturerPartNumber"].InnerText;
                    }

                    if (node["UnitOfMeasureSetRef"] != null)
                    {
                        UnitOfMeasureSetRef          = new UnitOfMeasureSet();
                        UnitOfMeasureSetRef.ListID   = "" + node["UnitOfMeasureSetRef"]["ListID"].InnerText;
                        UnitOfMeasureSetRef.FullName = "" + node["UnitOfMeasureSetRef"]["FullName"].InnerText;
                        UnitOfMeasureSetRef.LoadByListID(UnitOfMeasureSetRef.ListID, ref err);
                    }

                    if (node["SalesTaxCodeRef"] != null)
                    {
                        SalesTaxCodeRef          = new SalesTaxCode();
                        SalesTaxCodeRef.ListID   = "" + node["SalesTaxCodeRef"]["ListID"].InnerText;
                        SalesTaxCodeRef.FullName = "" + node["SalesTaxCodeRef"]["FullName"].InnerText;
                    }

                    if (node["SalesDesc"] != null)
                    {
                        SalesDesc = "" + node["SalesDesc"].InnerText;
                    }
                    if (node["SalesPrice"] != null)
                    {
                        SalesPrice = Functions.ParseFloat("" + node["SalesPrice"].InnerText);
                    }

                    if (node["IncomeAccountRef"] != null)
                    {
                        IncomeAccountRef          = new IncomeAccount();
                        IncomeAccountRef.ListID   = "" + node["IncomeAccountRef"]["ListID"].InnerText;
                        IncomeAccountRef.FullName = "" + node["IncomeAccountRef"]["FullName"].InnerText;
                    }

                    if (node["PurchaseDesc"] != null)
                    {
                        PurchaseDesc = "" + node["PurchaseDesc"].InnerText;
                    }
                    if (node["PurchaseCost"] != null)
                    {
                        PurchaseCost = Functions.ParseFloat("" + node["PurchaseCost"].InnerText);
                    }

                    if (node["COGSAccountRef"] != null)
                    {
                        COGSAccountRef          = new COGSAccount();
                        COGSAccountRef.ListID   = "" + node["COGSAccountRef"]["ListID"].InnerText;
                        COGSAccountRef.FullName = "" + node["COGSAccountRef"]["FullName"].InnerText;
                    }

                    if (node["PrefVendorRef"] != null)
                    {
                        PrefVendorRef          = new PrefVendor();
                        PrefVendorRef.ListID   = "" + node["PrefVendorRef"]["ListID"].InnerText;
                        PrefVendorRef.FullName = "" + node["PrefVendorRef"]["FullName"].InnerText;
                    }

                    if (node["AssetAccountRef"] != null)
                    {
                        AssetAccountRef          = new AssetAccount();
                        AssetAccountRef.ListID   = "" + node["AssetAccountRef"]["ListID"].InnerText;
                        AssetAccountRef.FullName = "" + node["AssetAccountRef"]["FullName"].InnerText;
                    }

                    if (node["BuildPoint"] != null)
                    {
                        BuildPoint = Functions.ParseFloat("" + node["BuildPoint"].InnerText);
                    }

                    if (node["Max"] != null)
                    {
                        Max = Functions.ParseFloat("" + node["Max"].InnerText);
                    }

                    if (node["QuantityOnHand"] != null)
                    {
                        QuantityOnHand = Functions.ParseFloat("" + node["QuantityOnHand"].InnerText);
                    }

                    if (node["AverageCost"] != null)
                    {
                        AverageCost = Functions.ParseFloat("" + node["AverageCost"].InnerText);
                    }

                    if (node["QuantityOnOrder"] != null)
                    {
                        QuantityOnOrder = Functions.ParseFloat("" + node["QuantityOnOrder"].InnerText);
                    }

                    if (node["QuantityOnSalesOrder"] != null)
                    {
                        QuantityOnSalesOrder = Functions.ParseFloat("" + node["QuantityOnSalesOrder"].InnerText);
                    }

                    XmlNodeList __lines = node.SelectNodes("ItemInventoryAssemblyLine");
                    ItemList = new List <ItemInventoryAssemblyLine>();
                    foreach (XmlNode L in __lines)
                    {
                        ItemInventoryAssemblyLine Line = new ItemInventoryAssemblyLine();
                        if (L["ItemInventoryRef"] != null)
                        {
                            Line.ItemIventoryRef          = new ItemInventory();
                            Line.ItemIventoryRef.ListID   = "" + L["ItemInventoryRef"]["ListID"].InnerText;
                            Line.ItemIventoryRef.FullName = "" + L["ItemInventoryRef"]["FullName"].InnerText;
                        }
                        if (L["Quantity"] != null)
                        {
                            Line.Quantity = Functions.ParseFloat("" + L["Quantity"].InnerText);
                        }

                        ItemList.Add(Line);
                    }

                    if (node["ExternalGUID"] != null)
                    {
                        ExternalGUID = "" + node["ExternalGUID"].InnerText;
                    }

                    XmlNodeList __extras = node.SelectNodes("DataExtRet");
                    foreach (XmlNode ex in __extras)
                    {
                        var name  = ex["DataExtName"].InnerText;
                        var value = ex["DataExtValue"].InnerText;
                        AddDataEx(name, value);
                    }
                    return(true);
                }
                else
                {
                    err = statusMessage;
                }
                qbook.Disconnect();
            }
            else
            {
                err = "QuickBook no conecto";
            }

            return(false);
        }
Beispiel #2
0
        public bool LoadByListID(string lid, ref string err)
        {
            string xml = "" +
                         "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                         "<?qbxml version=\"13.0\"?>" +
                         "<QBXML>" +
                         "<QBXMLMsgsRq onError=\"stopOnError\">" +
                         "<ItemGroupQueryRq>" +
                         "<ListID >" + lid + "</ListID>" +
                         "<OwnerID>0</OwnerID>" +
                         "</ItemGroupQueryRq>" +
                         "</QBXMLMsgsRq>" +
                         "</QBXML>";
            var qbook = new Connector(Quickbook.Config.App_Name, Quickbook.Config.File);

            if (qbook.Connect())
            {
                string      response = qbook.sendRequest(xml);
                XmlDocument res      = new XmlDocument();
                res.LoadXml(response);

                string code          = "";
                string statusMessage = "";

                code          = res["QBXML"]["QBXMLMsgsRs"]["ItemGroupQueryRs"].Attributes["statusCode"].Value;
                statusMessage = res["QBXML"]["QBXMLMsgsRs"]["ItemGroupQueryRs"].Attributes["statusMessage"].Value;

                if (code == "0")
                {
                    var node = res["QBXML"]["QBXMLMsgsRs"]["ItemGroupQueryRs"]["ItemGroupRet"];

                    ListID       = "" + node["ListID"].InnerText;
                    TimeCreated  = DateTime.Parse("" + node["TimeCreated"].InnerText);
                    TimeModified = DateTime.Parse("" + node["TimeModified"].InnerText);
                    EditSequence = "" + node["EditSequence"].InnerText;
                    Name         = "" + node["Name"].InnerText;
                    if (node["BarCodeValue"] != null)
                    {
                        BarCodeValue = "" + node["BarCodeValue"].InnerText;
                    }
                    if (node["IsActive"] != null)
                    {
                        IsActive = ("" + node["IsActive"].InnerText == "true" ? true : false);
                    }

                    if (node["UnitOfMeasureSetRef"] != null)
                    {
                        UnitOfMeasureSetRef          = new UnitOfMeasureSet();
                        UnitOfMeasureSetRef.ListID   = "" + node["UnitOfMeasureSetRef"]["ListID"].InnerText;
                        UnitOfMeasureSetRef.FullName = "" + node["UnitOfMeasureSetRef"]["FullName"].InnerText;
                    }

                    XmlNodeList __lines = node.SelectNodes("ItemGroupLine");
                    ItemList = new List <ItemGroupLine>();
                    foreach (XmlNode L in __lines)
                    {
                        ItemGroupLine Line = new ItemGroupLine();
                        if (L["ItemRef"] != null)
                        {
                            Line.ItemRef          = new Item();
                            Line.ItemRef.ListID   = "" + L["ItemRef"]["ListID"].InnerText;
                            Line.ItemRef.FullName = "" + L["ItemRef"]["FullName"].InnerText;
                        }
                        if (L["Quantity"] != null)
                        {
                            Line.Quantity = Functions.ParseFloat("" + L["Quantity"].InnerText);
                        }
                        if (L["UnitOfMeasure"] != null)
                        {
                            Line.UnitOfMeasure = "" + L["UnitOfMeasure"].InnerText;
                        }

                        ItemList.Add(Line);
                    }

                    if (node["ExternalGUID"] != null)
                    {
                        ExternalGUID = "" + node["ExternalGUID"].InnerText;
                    }

                    XmlNodeList __extras = node.SelectNodes("DataExtRet");
                    foreach (XmlNode ex in __extras)
                    {
                        var name  = ex["DataExtName"].InnerText;
                        var value = ex["DataExtValue"].InnerText;
                        AddDataEx(name, value);
                    }
                    return(true);
                }
                else
                {
                    err = statusMessage;
                }
                qbook.Disconnect();
            }
            else
            {
                err = "QuickBook no conecto";
            }


            return(false);
        }
Beispiel #3
0
        public bool LoadByListID(string lid, ref string err)
        {
            string xml = "" +
                         "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                         "<?qbxml version=\"13.0\"?>" +
                         "<QBXML>" +
                         "<QBXMLMsgsRq onError=\"stopOnError\">" +
                         "<ItemServiceQueryRq>" +
                         "<ListID >" + lid + "</ListID>" +
                         "<OwnerID>0</OwnerID>" +
                         "</ItemServiceQueryRq>" +
                         "</QBXMLMsgsRq>" +
                         "</QBXML>";
            var qbook = new Connector(Quickbook.Config.App_Name, Quickbook.Config.File);

            if (qbook.Connect())
            {
                string response = qbook.sendRequest(xml);

                XmlDocument res = new XmlDocument();
                res.LoadXml(response);

                string code          = "";
                string statusMessage = "";

                code          = res["QBXML"]["QBXMLMsgsRs"]["ItemServiceQueryRs"].Attributes["statusCode"].Value;
                statusMessage = res["QBXML"]["QBXMLMsgsRs"]["ItemServiceQueryRs"].Attributes["statusMessage"].Value;

                if (code == "0")
                {
                    var node = res["QBXML"]["QBXMLMsgsRs"]["ItemServiceQueryRs"]["ItemServiceRet"];

                    ListID       = "" + node["ListID"].InnerText;
                    TimeCreated  = DateTime.Parse("" + node["TimeCreated"].InnerText);
                    TimeModified = DateTime.Parse("" + node["TimeModified"].InnerText);
                    EditSequence = "" + node["EditSequence"].InnerText;
                    Name         = "" + node["Name"].InnerText;
                    FullName     = "" + node["FullName"].InnerText;
                    if (node["BarCodeValue"] != null)
                    {
                        BarCodeValue = "" + node["BarCodeValue"].InnerText;
                    }
                    if (node["IsActive"] != null)
                    {
                        IsActive = ("" + node["IsActive"].InnerText == "true" ? true : false);
                    }

                    if (node["ClassRef"] != null)
                    {
                        ClassRef          = new Class();
                        ClassRef.ListID   = "" + node["ClassRef"]["ListID"].InnerText;
                        ClassRef.FullName = "" + node["ClassRef"]["FullName"].InnerText;
                    }

                    if (node["ParentRef"] != null)
                    {
                        ParentRef          = new ItemService();
                        ParentRef.ListID   = "" + node["ParentRef"]["ListID"].InnerText;
                        ParentRef.FullName = "" + node["ParentRef"]["FullName"].InnerText;
                    }

                    Sublevel = Int32.Parse("" + node["Sublevel"].InnerText);

                    if (node["UnitOfMeasureSetRef"] != null)
                    {
                        UnitOfMeasureSetRef          = new UnitOfMeasureSet();
                        UnitOfMeasureSetRef.ListID   = "" + node["UnitOfMeasureSetRef"]["ListID"].InnerText;
                        UnitOfMeasureSetRef.FullName = "" + node["UnitOfMeasureSetRef"]["FullName"].InnerText;
                        UnitOfMeasureSetRef.LoadByListID(UnitOfMeasureSetRef.ListID, ref err);
                    }

                    if (node["SalesTaxCodeRef"] != null)
                    {
                        SalesTaxCodeRef          = new SalesTaxCode();
                        SalesTaxCodeRef.ListID   = "" + node["SalesTaxCodeRef"]["ListID"].InnerText;
                        SalesTaxCodeRef.FullName = "" + node["SalesTaxCodeRef"]["FullName"].InnerText;
                    }

                    if (node["SalesOrPurchase"] != null)
                    {
                        ServiceType = "SalesOrPurchase";
                        if (node["SalesOrPurchase"]["Desc"] != null)
                        {
                            Desc = "" + node["SalesOrPurchase"]["Desc"].InnerText;
                        }

                        if (node["SalesOrPurchase"]["Price"] != null)
                        {
                            Price = Functions.ParseFloat("" + node["SalesOrPurchase"]["Price"].InnerText);
                        }
                        //or
                        if (node["SalesOrPurchase"]["PricePercent"] != null)
                        {
                            PricePercent = Functions.ParseFloat("" + node["SalesOrPurchase"]["PricePercent"].InnerText);
                        }

                        if (node["SalesOrPurchase"]["AccountRef"] != null)
                        {
                            AccountRef          = new Account();
                            AccountRef.ListID   = "" + node["SalesOrPurchase"]["AccountRef"]["ListID"].InnerText;
                            AccountRef.FullName = "" + node["SalesOrPurchase"]["AccountRef"]["FullName"].InnerText;
                        }
                    }

                    if (node["SalesAndPurchase"] != null)
                    {
                        ServiceType = "SalesAndPurchase";
                        if (node["SalesAndPurchase"]["SalesDesc"] != null)
                        {
                            SalesDesc = "" + node["SalesAndPurchase"]["SalesDesc"].InnerText;
                        }
                        if (node["SalesAndPurchase"]["SalesPrice"] != null)
                        {
                            SalesPrice = Functions.ParseFloat("" + node["SalesAndPurchase"]["SalesPrice"].InnerText);
                        }

                        if (node["SalesAndPurchase"]["IncomeAccountRef"] != null)
                        {
                            IncomeAccountRef          = new IncomeAccount();
                            IncomeAccountRef.ListID   = "" + node["SalesAndPurchase"]["IncomeAccountRef"]["ListID"].InnerText;
                            IncomeAccountRef.FullName = "" + node["SalesAndPurchase"]["IncomeAccountRef"]["FullName"].InnerText;
                        }

                        if (node["SalesAndPurchase"]["PurchaseDesc"] != null)
                        {
                            PurchaseDesc = "" + node["SalesAndPurchase"]["PurchaseDesc"].InnerText;
                        }
                        if (node["SalesAndPurchase"]["PurchaseCost"] != null)
                        {
                            PurchaseCost = Functions.ParseFloat("" + node["SalesAndPurchase"]["PurchaseCost"].InnerText);
                        }

                        if (node["SalesAndPurchase"]["ExpenseAccountRef"] != null)
                        {
                            ExpenseAccountRef          = new ExpenseAccount();
                            ExpenseAccountRef.ListID   = "" + node["SalesAndPurchase"]["ExpenseAccountRef"]["ListID"].InnerText;
                            ExpenseAccountRef.FullName = "" + node["SalesAndPurchase"]["ExpenseAccountRef"]["FullName"].InnerText;
                        }

                        if (node["SalesAndPurchase"]["PrefVendorRef"] != null)
                        {
                            PrefVendorRef          = new PrefVendor();
                            PrefVendorRef.ListID   = "" + node["SalesAndPurchase"]["PrefVendorRef"]["ListID"].InnerText;
                            PrefVendorRef.FullName = "" + node["SalesAndPurchase"]["PrefVendorRef"]["FullName"].InnerText;
                        }
                    }

                    if (node["ExternalGUID"] != null)
                    {
                        ExternalGUID = "" + node["ExternalGUID"].InnerText;
                    }

                    XmlNodeList __extras = node.SelectNodes("DataExtRet");
                    foreach (XmlNode ex in __extras)
                    {
                        var name  = ex["DataExtName"].InnerText;
                        var value = ex["DataExtValue"].InnerText;
                        AddDataEx(name, value);
                    }
                    return(true);
                }
                else
                {
                    err = statusMessage;
                }
                qbook.Disconnect();
            }
            else
            {
                err = "QuickBook no conecto";
            }

            return(false);
        }