Categories: QuickBooks Desktop

How To Add Sales Order In Quickbook Desktop Using C#

Introduction

In this article, we will learn how to add sales orders in Quickbook Desktop using c#.

If you have not seen Quickbook Desktop Installation then I recommend seeing that first. in that article here.

A sales order is used to record a sale. It helps track items.

First of all Install the Interop.QBFC13 package in your project.

Install Package

Right click on your project and select Manage Nuget Packages.

After search Interop.QBFC13 and install it.

The code is as below.

private void CreateSalesOrder(object sender, EventArgs e)
{
    try
    {
        string customerName = "Sagar Rana";
        string itemName = "Computer";
        double itemAmount = 1500;
        QBSessionManager  sessionManager = new QBSessionManager();
        IMsgSetRequest requestSet = sessionManager.CreateMsgSetRequest("US", 13, 0);
        requestSet.Attributes.OnError = ENRqOnError.roeStop;
        sessionManager.OpenConnection(@"Your Company File Path", "Quickbook Desktop Example");
        sessionManager.BeginSession("", ENOpenMode.omDontCare);
        IMsgSetResponse responseSet;
       
        //create customer
        ICustomerAdd newcustomer = requestSet.AppendCustomerAddRq();
        newcustomer.Name.SetValue(customerName);
        responseSet = sessionManager.DoRequests(requestSet);
        requestSet.ClearRequests();
        

        //create item
        IItemNonInventoryAdd newitem = requestSet.AppendItemNonInventoryAddRq();

        newitem.Name.SetValue(itemName);
        newitem.ORSalesPurchase.SalesAndPurchase.Type.Equals("Non-inventory Part");
        newitem.ORSalesPurchase.SalesAndPurchase.PurchaseDesc.SetValue("");
        newitem.ORSalesPurchase.SalesAndPurchase.SalesDesc.SetValue("");
        newitem.ORSalesPurchase.SalesAndPurchase.PurchaseCost.SetValue(itemAmount);
        newitem.ORSalesPurchase.SalesAndPurchase.SalesPrice.SetValue(itemAmount);
        newitem.ORSalesPurchase.SalesAndPurchase.IncomeAccountRef.FullName.SetValue("Payroll Liabilities");
        newitem.ORSalesPurchase.SalesAndPurchase.ExpenseAccountRef.FullName.SetValue("Payroll Liabilities");
        responseSet = sessionManager.DoRequests(requestSet);
        requestSet.ClearRequests();


        //create sales order
        ISalesOrderAdd SalesOrderAdd = requestSet.AppendSalesOrderAddRq();
        SalesOrderAdd.CustomerRef.FullName.SetValue(customerName);
        IORSalesOrderLineAdd SalesOrderLineAdd = SalesOrderAdd.ORSalesOrderLineAddList.Append();
        SalesOrderLineAdd.SalesOrderLineAdd.ItemRef.FullName.SetValue(itemName);
        SalesOrderLineAdd.SalesOrderLineAdd.Amount.SetValue(itemAmount);
        responseSet = sessionManager.DoRequests(requestSet);
        IResponse response = responseSet.ResponseList.GetAt(0);
        MessageBox.Show("Sales Order successfully created.");
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

If you have any questions about this article, please let me know and more information here.

Sagar Rana

Sagar Rana is a Web Developer in Vision Infotech. He has strong skills and knowledge of ASP.NET C#, ASP.NET MVC, .Net Core, Jquery, JavaScript, WEB API, React.js, ADO.Net, Entity Framework, SQL and different integration like Xero, Stripe, Zoho CRM, Square, PayTM, PayKUN, RazorPay, Quickbook Desktop etc.

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

3 years ago