2014-10-07 59 views
0

我想添加Employee.I需要爲「IsUsingTimeDataToCreatePaychecks」設置值,因爲如果我沒有設置該值並嘗試創建時間跟蹤對於該員工,它給我錯誤「3310未知員工時間狀態未能保存T」。我使用以下代碼來創建員工。添加員工到快速預訂和設置時間狀態值爲false快速預訂使用QBSDK 10.0

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)」 Exception.How我可以解決這個問題?我使用QBSDK 10.0,我的快速書籍版本是2014會計副本。

回答

1

您需要使用

EmployeePayrollInfo.UseTimeDataToCreatePaychecks.SetValue(ENUseTimeDataToCreatePaychecks.utdtcpUseTimeData);

,而不是

EmployeePayrollInfo.IsUsingTimeDataToCreatePaychecks.SetValue(true);

出於某種原因,「IsUsing」選項尚未實現,你會得到錯誤,它的不支持,但「使用」確實有效。這既適用於QBFC也適用於QBXML。