protected void lnkLinkQuote_Click(object sender, EventArgs e) { var page = Page as EntityPage; if (page != null && page.EntityContext != null) { if (page.EntityContext.EntityType == typeof(IQuote)) { IQuote quote = EntityFactory.GetRepository <IQuote>().Get(page.EntityContext.EntityID); if (quote != null) { IAccount account = quote.Account; // First validation is if the associated Account is Synced if (account == null || account.ErpExtId == null) { // If associated Account is not in Sync throw error throw new ValidationException(GetLocalResourceObject("Error_Account_NotPromoted").ToString()); } // Second Validation is if the Quote had line items var quoteItems = quote.QuoteItems; if (quoteItems == null || quoteItems.Count() <= 0) { throw new ValidationException(GetLocalResourceObject("Error_Quote_NoLineItems").ToString()); } IBackOffice backOffice = Utilities.GetBackOfficeByLogicalID(quote.ErpLogicalId); if (backOffice == null) { backOffice = Utilities.GetBackOfficeByLogicalID(account.ErpLogicalId); } //Get the BOD Mapping from SalesOrder entity. IBODMapping bodMapping = Utilities.GetBODMappingByEntityBackoffice(GetLocalResourceObject("Quote_EntityName").ToString(), backOffice); if (bodMapping != null && bodMapping.IsActive == true && bodMapping.OutboundOnCreate == false) { throw new ValidationException(String.Format(GetLocalResourceObject("OutBoundCreate.Caption").ToString())); } string caption = GetLocalResourceObject("lblLinkQuote.Caption").ToString(); DialogService.SetSpecs(200, 200, 250, 600, "QuoteSalesOrderPromotion", caption, true); string id = GetSelectedRecord(); if (!String.IsNullOrEmpty(id)) { DialogService.DialogParameters.Remove("LinkAccountSelectedId"); DialogService.DialogParameters.Add("LinkAccountSelectedId", id); DialogService.ShowDialog(); if (quote.SyncStatus == GetLocalResourceObject("lblLinkQuote.Caption").ToString()) { lblLinkQuote.Visible = false; imgLinkQuote.Visible = false; } } } else { throw new ValidationException(GetLocalResourceObject("Error_QuoteNotFound").ToString()); } } } }
private void LoadQuoteTasks(EntityPage page) { if (page.IsDetailMode) { divEntityQuoteList.Style.Add("display", "none"); divEntityQuoteDetails.Style.Add("display", "block"); IQuote quote = EntityFactory.GetRepository <IQuote>().Get(page.EntityContext.EntityID); if (quote == null) { HideIntegration(); return; } else { IBackOffice backOffice = Utilities.GetBackOfficeByLogicalID(quote.ErpLogicalId); if (backOffice == null) { backOffice = Utilities.GetBackOfficeByLogicalID(account.ErpLogicalId); } IAccount account = quote.Account; // First validation is if the associated Account is Synced if (account == null || account.ErpExtId == null) { // If associated Account is not in Sync throw error throw new ValidationException(GetLocalResourceObject("Error_Account_NotPromoted").ToString()); } // Second Validation is if the Quote had line items var quoteItems = quote.QuoteItems; if (quoteItems == null || quoteItems.Count() <= 0) { throw new ValidationException(GetLocalResourceObject("Error_Quote_NoLineItems").ToString()); } //Get the BOD Mapping from Quote entity. IBODMapping bodMapping = Utilities.GetBODMappingByEntityBackoffice("SalesOrder", backOffice); if (bodMapping != null && bodMapping.IsActive == true) { if (quote.SyncStatus != null && quote.SyncStatus.Equals(GetLocalResourceObject("LinkQuote.Caption").ToString()) || quote.ErpExtId != null) { lblLinkQuote.Visible = false; imgLinkQuote.Visible = false; } else { lblLinkQuote.Visible = true; imgLinkQuote.Visible = true; } } else { HideQuotePromotion(); } lblLastUpdate.Text = String.Format(GetLocalResourceObject("lblLastUpdate.Caption").ToString(), TimeZone.UTCDateTimeToLocalTime((DateTime)quote.ModifyDate)); } if (page.IsNewEntity) { updateQuotePanel.Update(); } } }