public static string CreatePalletForceInvoice() { System.Web.SessionState.HttpSessionState currentSession = HttpContext.Current.Session; string retVal = string.Empty; string userID = !string.IsNullOrEmpty(currentSession[vs_userID].ToString()) ? currentSession[vs_userID].ToString() : string.Empty; int invoiceID = -1; int? preInvoiceID = (int?)currentSession[vs_preInvoiceID]; eInvoiceType?invoiceType = (eInvoiceType?)currentSession[vs_preInvoiceType]; if (preInvoiceID.HasValue && preInvoiceID.Value > 0 && invoiceType != null && userID != string.Empty) { Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice(); List <int> preInvoiceIDs = new List <int>(); preInvoiceIDs.Add(preInvoiceID.Value); List <Entities.PreInvoice> preInvoices = facPreInvoice.GetPreInvoices(preInvoiceIDs); if (preInvoices != null && preInvoices.Count > 0) { try { Entities.PreInvoice currentPreInvoice = preInvoices[0]; invoiceID = facPreInvoice.CreateInvoice(currentPreInvoice, userID); if (invoiceID > 0) { facPreInvoice.DeletePreInvoice(currentPreInvoice.PreInvoiceID); } } catch (Exception ex) { retVal = RetrieveErrorMessages(ex); } } } else { retVal = string.Format("{0}|{1}", 1, "There was an error retrieving the preinvoice details. Please reload the page and try again."); } return(retVal); }