使用QBSDK 10.0将员工添加到快速簿并将设置时间状态值设置为false

时间:2014-10-07 06:35:35

标签: c# quickbooks

我正在尝试添加Employee.I需要为" IsUsingTimeDataToCreatePaychecks"设置值。因为如果我没有设置该值并尝试为该员工创建时间跟踪,则会给我错误" 3310未知员工时间状态无法保存T"。我已使用以下代码创建员工。

public class Sample
{
    public void DoEmployeeAdd()
    {
        bool sessionBegun = false;
        bool connectionOpen = false;
        QBSessionManager sessionManager = null;

        try
        {
            //Create the session Manager object
            sessionManager = new QBSessionManager();

            //Create the message set request object to hold our request
            IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US",10, 0);
            requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;

            BuildEmployeeAddRq(requestMsgSet);

            //Connect to QuickBooks and begin a session
            sessionManager.OpenConnection("", "SampleTest");
            connectionOpen = true;
            sessionManager.BeginSession("", ENOpenMode.omDontCare);
            sessionBegun = true;

            //Send the request and get the response from QuickBooks
            IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);

            //End the session and close the connection to QuickBooks
            sessionManager.EndSession();
            sessionBegun = false;
            sessionManager.CloseConnection();
            connectionOpen = false;

        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message, "Error");
            if (sessionBegun)
            {
                sessionManager.EndSession();
            }
            if (connectionOpen)
            {
                sessionManager.CloseConnection();
            }
        }
    }


    void BuildEmployeeAddRq(IMsgSetRequest requestMsgSet)
    {
        try
        {
            IEmployeeAdd EmployeeAddRq = requestMsgSet.AppendEmployeeAddRq();

            EmployeeAddRq.IsActive.SetValue(true);

            EmployeeAddRq.Salutation.SetValue("Mr");

            EmployeeAddRq.FirstName.SetValue("Prashant");

            EmployeeAddRq.MiddleName.SetValue("A");

            EmployeeAddRq.LastName.SetValue("Patel");

            EmployeeAddRq.EmployeeAddress.Addr1.SetValue("20,Hari Hari");

            EmployeeAddRq.EmployeeAddress.Addr2.SetValue("ab");

            EmployeeAddRq.EmployeeAddress.City.SetValue("Surat");

            EmployeeAddRq.EmployeeAddress.State.SetValue("CA");

            EmployeeAddRq.EmployeeAddress.PostalCode.SetValue("395004");

            EmployeeAddRq.EmployeeType.SetValue(ENEmployeeType.etOfficer);



            EmployeeAddRq.HiredDate.SetValue(DateTime.Parse("12/15/2014"));

            EmployeeAddRq.ReleasedDate.SetValue(DateTime.Parse("12/15/2014"));

            EmployeeAddRq.BirthDate.SetValue(DateTime.Parse("12/15/2014"));

            EmployeeAddRq.EmployeePayrollInfo.IsUsingTimeDataToCreatePaychecks.SetValue(true);

        }
        catch (Exception ex)
        {
        }
    }

}   

但是这段代码给了我"指定版本的qbXML不支持此功能。在QBFC10Lib.IEmployeePayrollInfo.get_IsUsingTimeDataToCreatePaychecks()在SampleTimeSheet.Sample.BuildEmployeeAddRq(IMsgSetRequest requestMsgSet)"例外。如何解决此问题?我使用的是QBSDK 10.0,我的快速书版本是2014年的会计副本。

1 个答案:

答案 0 :(得分:1)

您需要使用

EmployeePayrollInfo.UseTimeDataToCreatePaychecks.SetValue(ENUseTimeDataToCreatePaychecks.utdtcpUseTimeData);

而不是

EmployeePayrollInfo.IsUsingTimeDataToCreatePaychecks.SetValue(true);

出于某种原因," IsUsing"选项尚未实施,您将收到不支持的错误,但是"使用"确实有效。这既适用于QBFC,也适用于QBXML。