Friday, October 2, 2009

Update / Set CRM Invoice Status/ state

internal bool updateInvioceState(Guid InvioceId, string statusCode, string stateCode)
{
try
{
CrmService Crm4_service = connect();
SetStateInvoiceRequest state = new SetStateInvoiceRequest();

if (stateCode == "Active")
{
state.InvoiceState = InvoiceState.Active;
}
else if (stateCode == "Canceled")
{
state.InvoiceState = InvoiceState.Canceled;
}
else if (stateCode == "Closed")
{
state.InvoiceState = InvoiceState.Closed;
}
else if (stateCode == "Paid")
{
state.InvoiceState = InvoiceState.Paid;
}

state.InvoiceStatus = Convert.ToInt32(statusCode);
state.EntityId = InvioceId;
SetStateInvoiceResponse stateSet = (SetStateInvoiceResponse)Crm4_service.Execute(state);

}
catch (System.Web.Services.Protocols.SoapException ex)
{
return false;
}
return true;
}

No comments: