diff --git a/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs b/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs index a3435f3..67a96df 100644 --- a/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs +++ b/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs @@ -320,7 +320,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces public SbmCommodity.Params GetParams() { SbmCommodity.Params prmCommodity = config.CommodityParams ?? new SbmCommodity.Params(); - prmCommodity.IncludedIds.AddRange(config.ItemIds); + prmCommodity.IdsIncluded.AddRange(config.ItemIds); return prmCommodity; } private DbResultSet ExecuteQuery() @@ -715,7 +715,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces AddColumnValue(SbmCommodity.Column.Length, "Cmd_Length", "Length"); //AddColumnValue(SbmCommodity.Column.LengthUomId, "Cmd_LengthUomId", "Length","UOM Id"); AddColumnValue(SbmCommodity.Column.Length_ValueUnits, "Cmd_Length_ValueUnits", "Length", "", "", "value & units"); - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.Commodity_Volume)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_Volume)) { AddColumnValue(SbmCommodity.Column.Volume, "Cmd_Volume", "Volume"); //AddColumnValue(SbmCommodity.Column.VolumeUomId, "Cmd_VolumeUomId", "Volume","UOM Id"); @@ -724,7 +724,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces AddColumnValue(SbmCommodity.Column.Density, "Cmd_Density", "Density"); //AddColumnValue(SbmCommodity.Column.DensityUomId, "Cmd_DensityUomId", "Density","UOM Id"); AddColumnValue(SbmCommodity.Column.Density_ValueUnits, "Cmd_Density_ValueUnits", "Density", "", "", "value & units"); - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.Commodity_BoxQuantity)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity)) { AddColumnValue(SbmCommodity.Column.BoxQuantity, "Cmd_BoxQuantity", "Box qty"); //AddColumnValue(SbmCommodity.Column.BoxUomId, "Cmd_BoxUomId", "Box","UOM Id"); @@ -732,7 +732,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces } AddColumnValue(SbmCommodity.Column.Dimensions, "Cmd_Dimensions", "Dimensions"); AddColumnValue(SbmCommodity.Column.SpecSummary, "Cmd_SpecSummary", "Specification"); - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode)) AddColumnValue(SbmCommodity.Column.ICNTariffCode, "Cmd_ICNTariffCode", "Tariff code"); // Codings: if (CommodityMgr.CodeTypeHasCodes(Sbm.ApplCodeType.CommodityRange)) @@ -800,7 +800,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces AddColumnValue(SbmCommodity.Column.ReorderQty, "Cmd_ReorderQty", "Reorder qty"); AddColumnValue(SbmCommodity.Column.QtyOnOrder, "Cmd_QtyOnOrder", "Qty on order"); // Sales: - if (ConfigConsole.AllowOption(UserContext, Sbm.ConfigOption.CommodityExclusiveToCustomer)) + if (SessionConsole.AllowOption(Sbm.ConfigOption.CommodityExclusiveToCustomer)) AddColumnValue(SbmCommodity.Column.Customer_Name, "Cmd_CustomerName", "Customer name"); AddColumnValue(SbmCommodity.Column.SalesPrice, "Cmd_SalesPrice", "Sales price"); AddColumnValue(SbmCommodity.Column.SalesPrice_Fmt, "Cmd_SalesPrice_Fmt", "Sales price (fmt)"); @@ -824,7 +824,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces AddColumnValue(SbmCommodity.Column.LastOrderDate, "Cmd_LastOrderDate", "Last order date"); AddColumnValue(SbmCommodity.Column.LastOrderQty, "Cmd_LastOrderQty", "Last order qty"); // Customer definition: - if (ConfigConsole.AllowOption(UserContext, Sbm.ConfigOption.CommodityCustomers) && CommodityMgr.TableExists(SbmDbDfn.TableIdx.CommodityCustomer)) + if (SessionConsole.AllowOption(Sbm.ConfigOption.CommodityCustomers) && CommodityMgr.TableExists(SbmDbDfn.TableIdx.CommodityCustomer)) { String commodityCustomerComment = "Only relevant for customer commodity exports"; AddColumnValue(SbmCommodity.Column.Cust_ProductCode, "CmdCust_ProductCode", "Customer product code", "", "", commodityCustomerComment); @@ -902,13 +902,13 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces AddColumnValue(SbmCommodity.Column.Stock_AvailVsReorder, "Cmd_Stock_AvailVsReorder", "Stock - avail vs reorder"); AddColumnValue(SbmCommodity.Column.Stock_ImminentAvailVsReorder, "Cmd_Stock_ImminentAvailVsReorder", "Stock - imminent avail vs reorder"); // Stock bays by location. - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.StockLevel_Bay1)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.StockLevel_Bay1)) AddColumnValue(SbmCommodity.Column.Stock_Bays, "Cmd_Stock_Bays", "Stock bays"); - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.StockLevel_Bay1)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.StockLevel_Bay1)) AddColumnValue(SbmCommodity.Column.Stock_Bay1, "Cmd_Stock_Bay1", "Bay 1", "Stock - ", "", "Selected location"); - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.StockLevel_Bay2)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.StockLevel_Bay2)) AddColumnValue(SbmCommodity.Column.Stock_Bay2, "Cmd_Stock_Bay2", "Bay 2", "Stock - ", "", "Selected location"); - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.StockLevel_Bay3)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.StockLevel_Bay3)) AddColumnValue(SbmCommodity.Column.Stock_Bay3, "Cmd_Stock_Bay3", "Bay 3", "Stock - ", "", "Selected location"); // Stock due: AddColumnValue(SbmCommodity.Column.Stock_NextDue_Commodity_Date, "Cmd_Stock_NextDue_Commodity_Date", "Stock - next date due commodity"); @@ -1003,7 +1003,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces AddColumnValue(SbmCommodity.Column.Stock_EndOfMonth_12, "Cmd_Stock_EndOfMonth_12", "Stock - end of month 12"); // Requirements. AddColumnValue(SbmCommodity.Column.Reqnt_AmountUnit_Earliest_ById, "Cmd_Reqnt_AmountUnit_Earliest_ById", "Earliest item price (regardless of item status)"); - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.Commodity_DrawingIssue)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue)) AddColumnValue(SbmCommodity.Column.Reqnt_AmountUnit_Earliest_ByCode, "Cmd_Reqnt_AmountUnit_Earliest_ByCode", "Earliest item price (regardless of issue or item status"); // Processes: if (ProcessMgr.HasProcesses(Sbm.ProcessCategory.Commodity)) @@ -1031,25 +1031,25 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces bool allowColumn = true; SbmDbDfn.ColumnIdx eDbCol = (SbmDbDfn.ColumnIdx)CommodityMgr.GetCommodityColumnDfn(eCol).DbColumn; // Some columns excluded by console. - if (allowColumn) allowColumn = ((int)eDbCol < 1 || ConfigConsole.DisplayAttribute(UserContext, eDbCol)); + if (allowColumn) allowColumn = ((int)eDbCol < 1 || SessionConsole.DisplayAttribute(eDbCol)); if (allowColumn) { // Some tables require console permission. switch (SbmDbDfn.GetTableForColumn(eDbCol)) { case SbmDbDfn.TableIdx.PortfolioItem: - allowColumn = ConfigConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowPortfolios); + allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.AllowPortfolios); if (allowColumn) allowColumn = CommodityMgr.PortfolioDatabaseIsValid; break; case SbmDbDfn.TableIdx.StockLevel: - allowColumn = ConfigConsole.GetStockControlConfig(UserContext).AllowStockControl(); + allowColumn = SessionConsole.GetStockControlConfig().AllowStockControl(); if (allowColumn) allowColumn = StockMgr.DatabaseIsValid(); break; case SbmDbDfn.TableIdx.Transaction: case SbmDbDfn.TableIdx.Requirement: - allowColumn = ConfigConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowTransactions); + allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.AllowTransactions); break; } @@ -1058,7 +1058,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces { String sDescPrefix = pcDescPrefix; String sDescSuffix = pcDescSuffix; - optionValues_Column.Add(eCol, sCode, (sDescPrefix + " " + ConfigConsole.GetAttributeCaption(UserContext, eDbCol, sDesc) + " " + sDescSuffix).Trim(), pcComment); + optionValues_Column.Add(eCol, sCode, (sDescPrefix + " " + SessionConsole.GetAttributeCaption(eDbCol, sDesc) + " " + sDescSuffix).Trim(), pcComment); bAddValue = true; } return bAddValue; diff --git a/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Base.cs b/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Base.cs index e8e40f1..7346eac 100644 --- a/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Base.cs +++ b/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Base.cs @@ -25,8 +25,8 @@ using Sarand.BusinessMgr.Net.Standard.Base.Consoles; namespace Sarand.BusinessMgr.Net.Core.Procs.Procs { - //======================================================================= - public abstract partial class SbmProcess_Base : SaProcess + //======================================================================= + public abstract partial class SbmProcess_Base : SaProcess { //------------------------------------------------------------------- // Configuration. @@ -126,8 +126,8 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs public static Color ExcelColumnHeadingColor { get; } = Color.LightYellow; // Security. protected ISbmSecurityProfile_Core SecurityProfile { get { return Internals.SecurityProfile; } } - protected bool UserCanUpdateContacts { get { return (SecurityProfile != null && SecurityProfile.UserCanUpdateContacts); } } - protected bool UserCanCreateContacts { get { return (SecurityProfile != null && SecurityProfile.UserCanCreateContacts); } } + protected bool UserCanUpdateContacts { get { return (SecurityProfile != null && SecurityProfile.UserCanUpdateContacts()); } } + protected bool UserCanCreateContacts { get { return (SecurityProfile != null && SecurityProfile.UserCanCreateContacts()); } } protected bool UserCanViewFinancials { get { return (SecurityProfile != null && SecurityProfile.UserCanViewFinancials()); } } protected bool UserCanUpdateFinancials { get { return (SecurityProfile != null && SecurityProfile.UserCanUpdateFinancials()); } } protected bool UserCanManageFinancials { get { return (SecurityProfile != null && SecurityProfile.UserCanUpdateFinancials()); } } @@ -146,7 +146,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs protected SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } } protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } } // Consoles. - protected SbmConfigConsole ConfigConsole { get { return Internals.ConfigConsole; } } + protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } } protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } } protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } } diff --git a/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Commodity_Export.cs b/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Commodity_Export.cs index 41b0fbf..94e49d3 100644 --- a/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Commodity_Export.cs +++ b/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Commodity_Export.cs @@ -182,9 +182,9 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs // Processing options - flags. if (optionContexts_Flag.Count == 0) { - optionContexts_Flag.Add(ProcessOptionFlag.IncludeCol_MaterialCost, "IncludeCol_MaterialCost", "Include column - " + ConfigConsole.GetAttributeCaption(UserContext, SbmDbDfn.ColumnIdx.Commodity_MaterialCost, "Material cost")); - optionContexts_Flag.Add(ProcessOptionFlag.IncludeCol_CostPrice, "IncludeCol_CostPrice", "Include column - " + ConfigConsole.GetAttributeCaption(UserContext, SbmDbDfn.ColumnIdx.Commodity_CostPrice, "Cost price")); - optionContexts_Flag.Add(ProcessOptionFlag.IncludeCol_RetailPrice, "IncludeCol_RetailPrice", "Include column - " + ConfigConsole.GetAttributeCaption(UserContext, SbmDbDfn.ColumnIdx.Commodity_RetailPrice, "Retail price")); + optionContexts_Flag.Add(ProcessOptionFlag.IncludeCol_MaterialCost, "IncludeCol_MaterialCost", "Include column - " + SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_MaterialCost, "Material cost")); + optionContexts_Flag.Add(ProcessOptionFlag.IncludeCol_CostPrice, "IncludeCol_CostPrice", "Include column - " + SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_CostPrice, "Cost price")); + optionContexts_Flag.Add(ProcessOptionFlag.IncludeCol_RetailPrice, "IncludeCol_RetailPrice", "Include column - " + SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_RetailPrice, "Retail price")); optionContexts_Flag.Add(ProcessOptionFlag.IncludeCol_StockCurrent, "IncludeCol_StockCurrent", "Include column - Stock: current"); optionContexts_Flag.Add(ProcessOptionFlag.IncludeCol_StockAvailable, "IncludeCol_StockAvailable", "Include column - Stock: available"); optionContexts_Flag.Add(ProcessOptionFlag.IncludeCol_StockDue_MonthTo03, "IncludeCol_StockDue_MonthTo03", "Include column - Stock: due to 3 months"); @@ -415,18 +415,18 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Weight_ValueUnits)); if (UserContext.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale)) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.PackQtySale)); - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.Commodity_Volume)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_Volume)) { // Aug16 Cadix Was just SbmCommodity.Column.Volume_ValueUnits displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Volume)); //displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Volume_Unit)); } - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.Commodity_BoxQuantity)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity)) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.BoxQuantity_ValueUnits)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Dimensions)); if (CommodityMgr.CodeTypeHasCodes(Sbm.ApplCodeType.CommodityMaterial)) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.MaterialDesc)); if (CommodityMgr.CodeTypeHasCodes(Sbm.ApplCodeType.CommodityFinish)) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.FinishDesc)); - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode)) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.ICNTariffCode)); if (config.ExportType == ExportType.PurchasePlanning) @@ -533,13 +533,13 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs else { // Standard column list. - if (ConfigConsole.DisplayAttribute(UserContext, SbmDbDfn.ColumnIdx.Commodity_DrawingIssue)) + if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue)) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.DrawingIssue)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Status_Current_X)); // Only show 'Type' column if type not selected: if (config.CommodityParams.CommodityType <= 0) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Type_Desc)); - if (ConfigConsole.AllowOption(UserContext, Sbm.ConfigOption.CommodityExclusiveToCustomer)) + if (SessionConsole.AllowOption(Sbm.ConfigOption.CommodityExclusiveToCustomer)) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Customer_Name)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.SalesPrice)); if (CommodityMgr.CodeTypeHasCodes(Sbm.ApplCodeType.CommodityRange)) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.RangeDesc)); diff --git a/SaBusMgrCoreProcs/SaBusMgrCoreProcs.csproj b/SaBusMgrCoreProcs/SaBusMgrCoreProcs.csproj index 75c228f..a765282 100644 --- a/SaBusMgrCoreProcs/SaBusMgrCoreProcs.csproj +++ b/SaBusMgrCoreProcs/SaBusMgrCoreProcs.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/SaBusMgrCoreWeb/SaBusMgrCoreWeb.csproj b/SaBusMgrCoreWeb/SaBusMgrCoreWeb.csproj index 7610589..8cee9bf 100644 --- a/SaBusMgrCoreWeb/SaBusMgrCoreWeb.csproj +++ b/SaBusMgrCoreWeb/SaBusMgrCoreWeb.csproj @@ -7,6 +7,7 @@ + diff --git a/SaBusMgrCoreWeb/Web/App/SbmApplication_Web.cs b/SaBusMgrCoreWeb/Web/App/SbmApplication_Web.cs index 2d2ddbc..0202e16 100644 --- a/SaBusMgrCoreWeb/Web/App/SbmApplication_Web.cs +++ b/SaBusMgrCoreWeb/Web/App/SbmApplication_Web.cs @@ -24,8 +24,8 @@ using System.Text; namespace Sarand.BusinessMgr.Net.Core.Web.App { - //======================================================================= - public abstract class SbmApplication_Web : SbmApplication + //======================================================================= + public abstract class SbmApplication_Web : SbmApplication { //------------------------------------------------------------------- // Data members. @@ -98,9 +98,9 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App //------------------------------------------------------------------- // Create consoles. - public override SbmConfigConsole CreateConfigConsole(SbmSessionContext sessionContext) + public override SbmSessionConsole CreateSessionConsole(ISbmUserContext_Core userContext) { - return SbmConfigConsole.CreateConsole(sessionContext); + return SbmSessionConsole.CreateConsole(userContext); } public override SaDiaryConsole CreateDiaryConsole(ISbmUserContext_Core userContext) { @@ -114,10 +114,6 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App { return new SbmCodeTypeConsole_Web(userContext); } - public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext_Core userContext) - { - return null; - } public override SaItemDataConsole CreateItemDataConsole(ISbmUserContext_Core userContext) { return null; diff --git a/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs new file mode 100644 index 0000000..d1bc856 --- /dev/null +++ b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs @@ -0,0 +1,74 @@ +using DocumentFormat.OpenXml.Drawing.Diagrams; +using Sarand.BusinessMgr.Net.Standard.Base.App; +using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; +using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control; +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Utils; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace Sarand.BusinessMgr.Net.Core.Web.App +{ + //======================================================================= + /// + /// Facade Instance configuration for core databases without Control configuration. + /// + public class SbmInstanceConfig_Core : SbmInstanceConfig + { + //------------------------------------------------------------------- + // Definitions. + + //------------------------------------------------------------------- + // Data members. + + //------------------------------------------------------------------- + // Construction. + public SbmInstanceConfig_Core(SbmSessionContext_Web sessionContext) + { + this.SessionContext = sessionContext; + } + + //------------------------------------------------------------------- + // Properties. + private SbmSessionContext_Web SessionContext { get; } + + //------------------------------------------------------------------- + // Allowed data component types. + //------------------------------------------------------------------- + + // Supported affiliate types. + public override bool AllowAffiliateType(Sbm.AffiliateType affiliateType, bool defaultResponse) + { + return defaultResponse; + } + + // Supported affiliate types. + public override bool AllowAssociationType(Sbm.AssociationType affiliateType, bool defaultResponse) + { + return defaultResponse; + } + + // Supported affiliate types. + public override bool AllowTransactionType(Sbm.TransactionType affiliateType, bool defaultResponse) + { + return defaultResponse; + } + + //------------------------------------------------------------------- + + // Supported application options. + public override bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse) + { + return defaultResponse; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrCoreWeb/Web/App/SbmLocaliser.cs b/SaBusMgrCoreWeb/Web/App/SbmLocaliser.cs index e1b420d..bb3e13f 100644 --- a/SaBusMgrCoreWeb/Web/App/SbmLocaliser.cs +++ b/SaBusMgrCoreWeb/Web/App/SbmLocaliser.cs @@ -28,7 +28,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App // Properties. public abstract IStringLocalizer MainProperties { get; } public virtual List AlternativeProperties { get; } = new List(); - private HashSet MissingKeysLogged { get; } = new HashSet(StringComparer.OrdinalIgnoreCase); + private HashSet MissingKeysLogged { get; } = new HashSet(StringComparer.OrdinalIgnoreCase); //------------------------------------------------------------------- // Generic phrase translation. @@ -36,7 +36,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App /// Retrieve localised text. public LocalizedString GetText(string key, bool logMissingKey = true) { - return GetText(key, new object[] { }, logMissingKey ); + return GetText(key, new object[] { }, logMissingKey); } public LocalizedString GetText(string key, object param) { @@ -49,22 +49,22 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App public LocalizedString GetText(string key, object[] parameters, bool logMissingKey = true) { LocalizedString text = MainProperties.GetString(key, parameters); - if (text.ResourceNotFound) - { - // Look up key in alternative property files. - foreach (IStringLocalizer properties in AlternativeProperties ?? new List()) - { - text = parameters == null || parameters.IsEmpty() ? properties.GetString(key) : properties.GetString(key, parameters); - if (!text.ResourceNotFound) - break; - } - } - if (text.ResourceNotFound && logMissingKey && !MissingKeysLogged.Contains(key)) - { - MissingKeysLogged.Add(key); - SaLogger.Debug($"{SysUtil.Fn} Key not found: {key}"); - } - return text; + if (text.ResourceNotFound) + { + // Look up key in alternative property files. + foreach (IStringLocalizer properties in AlternativeProperties ?? new List()) + { + text = parameters == null || parameters.IsEmpty() ? properties.GetString(key) : properties.GetString(key, parameters); + if (!text.ResourceNotFound) + break; + } + } + if (text.ResourceNotFound && logMissingKey && !MissingKeysLogged.Contains(key)) + { + MissingKeysLogged.Add(key); + SaLogger.Debug($"{SysUtil.Fn} Key not found: {key}"); + } + return text; } // Square bracket indexing. @@ -162,6 +162,15 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App return affiliateTypeCodes.GetDescForType(affiliateType, affiliateTypeCodes.GetCodeForType(affiliateType)); } + // Association Type. + public String GetAssociationTypeCaption(Sbm.AssociationType associationType) + { + if ((int)associationType < 1) return ""; + // ToDo Association Type localisation. + List associationTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AssociationType); + return associationTypeCodes.GetDescForType(associationType, associationTypeCodes.GetCodeForType(associationType)); + } + // Asset Type. public String GetAssetTypeCaption(Sbm.AssetType assetType) { diff --git a/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs b/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs index 07453f4..48ba1b0 100644 --- a/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs +++ b/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs @@ -29,8 +29,8 @@ using System.Threading.Tasks; namespace Sarand.BusinessMgr.Net.Core.Web.Controllers { - //======================================================================= - public abstract class SbmController_Base : SaController + //======================================================================= + public abstract class SbmController_Base : SaController { //------------------------------------------------------------------- // Data members. @@ -64,7 +64,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers // Properties. public SbmLocaliser Localiser { get; } protected SbmApplication_Web App { get { return SbmGlobals_Web.Application; } } - public SbmAppConfig AppConfig { get { return App.AppConfig; } } + public App.SbmAppConfig AppConfig { get { return App.AppConfig; } } public abstract SbmSessionContext SessionContext { get; } public abstract ISbmUserContext_Core UserContext_Core { get; } // Business components. @@ -84,7 +84,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers protected SbmcInstanceMgr ControlInstanceMgr { get { return Internals_Control.ControlInstanceMgr; } } protected SbmcItemMgr ControlItemMgr { get { return Internals_Control.ControlItemMgr; } } // Consoles. - public SbmConfigConsole ConfigConsole { get { return Internals.ConfigConsole; } } + public SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } public SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } } public SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } } public SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } } diff --git a/SaBusMgrCoreWeb/Web/Helpers/SbmAppConfigHelper.cs b/SaBusMgrCoreWeb/Web/Helpers/SbmAppConfigHelper.cs index 76391c8..9d929fd 100644 --- a/SaBusMgrCoreWeb/Web/Helpers/SbmAppConfigHelper.cs +++ b/SaBusMgrCoreWeb/Web/Helpers/SbmAppConfigHelper.cs @@ -12,17 +12,17 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Helpers public static class SbmAppConfigHelper { //------------------------------------------------------------------- - public static Dictionary ExtractAppConfigs(IConfigurationSection appConfigsSection) + public static Dictionary ExtractAppConfigs(IConfigurationSection appConfigsSection) { - // NB The set of configurations will only allow one per context. - // Only the last configuration found for each context will be stored (NB usually only one of each apart from 'Defaults'). - Dictionary appConfigs = new Dictionary(); + // NB The set of configurations will only allow one per context. + // Only the last configuration found for each context will be stored (NB usually only one of each apart from 'Defaults'). + Dictionary appConfigs = new Dictionary(); - // Start the list with a default 'Defaults' configuration - values set to application defaults (defined in Sbm). - // NB This can be overridden in each level of configuration. - // Settings from the 'Defaults' configuration provide values where they are missing from other configurations. - // NB Coverage may not be 100% - just where it's proven needed. - SbmAppConfig defaultsAppConfig = new SbmAppConfig(Sbm.Config.Context_Defaults, null, null); + // Start the list with a default 'Defaults' configuration - values set to application defaults (defined in Sbm). + // NB This can be overridden in each level of configuration. + // Settings from the 'Defaults' configuration provide values where they are missing from other configurations. + // NB Coverage may not be 100% - just where it's proven needed. + App.SbmAppConfig defaultsAppConfig = new App.SbmAppConfig(Sbm.Config.Context_Defaults, null, null); appConfigs.Add(defaultsAppConfig.Context, defaultsAppConfig); // Load session configurations. @@ -30,8 +30,8 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Helpers { if (StringUtil.IsEmpty(appConfigSection.Key)) continue; - // Extract the configuration, supplying current 'Defaults' to supply missing values, and add to the list. - SbmAppConfig appConfig = new SbmAppConfig(appConfigSection.Key, appConfigSection, defaultsAppConfig); + // Extract the configuration, supplying current 'Defaults' to supply missing values, and add to the list. + App.SbmAppConfig appConfig = new App.SbmAppConfig(appConfigSection.Key, appConfigSection, defaultsAppConfig); appConfigs.Remove(appConfigSection.Key); appConfigs.Add(appConfigSection.Key, appConfig); @@ -48,13 +48,13 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Helpers //======================================================================= public static class AppConfigList { - public static SbmAppConfig getConfigForApplication(this List appConfigs) + public static App.SbmAppConfig getConfigForApplication(this List appConfigs) { - SbmAppConfig defaultsAppConfig = new SbmAppConfig("", null, null); + App.SbmAppConfig defaultsAppConfig = new App.SbmAppConfig("", null, null); SbmApplication app = SbmGlobals_Web.Application; if (app != null) { - foreach (SbmAppConfig appConfig in appConfigs) + foreach (App.SbmAppConfig appConfig in appConfigs) { if (appConfig.Environments.ContainsCI(app.EnvironmentName)) return appConfig; diff --git a/SaBusMgrCoreWeb/Web/Helpers/SbmEmailConfigHelper.cs b/SaBusMgrCoreWeb/Web/Helpers/SbmEmailConfigHelper.cs index 758e342..ea366b7 100644 --- a/SaBusMgrCoreWeb/Web/Helpers/SbmEmailConfigHelper.cs +++ b/SaBusMgrCoreWeb/Web/Helpers/SbmEmailConfigHelper.cs @@ -75,7 +75,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Helpers //======================================================================= public static class EmailConfigList { - public static SbmEmailConfig getConfigForSession(this List emailConfigs, SbmAppConfig appConfig) + public static SbmEmailConfig getConfigForSession(this List emailConfigs, App.SbmAppConfig appConfig) { if (appConfig != null && !StringUtil.IsEmpty(appConfig.Email.Context)) { diff --git a/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs b/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs index 4bfcf8a..d2d0c6f 100644 --- a/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs +++ b/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs @@ -58,7 +58,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models //------------------------------------------------------------------- // Application properties. private SbmApplication_Web App { get { return SbmGlobals_Web.Application; } } - protected SbmAppConfig AppConfig { get { return App.AppConfig; } } + protected App.SbmAppConfig AppConfig { get { return App.AppConfig; } } protected SbmSystem_Web System { get { return App.System_Web; } } public String SessionCookieName { get { return App.SessionCookieName; } } public SbmSessionData SessionData { get { return SessionData_Web; } } @@ -94,7 +94,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models protected SbmcInstanceMgr ControlInstanceMgr { get { return Internals_Control.ControlInstanceMgr; } } protected SbmcItemMgr ControlItemMgr { get { return Internals_Control.ControlItemMgr; } } // Consoles. - protected SbmConfigConsole ConfigConsole { get { return Internals.ConfigConsole; } } + protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } protected SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } } protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } } protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } } @@ -251,17 +251,26 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models // NB Use methods rathe rthan accessors for properties that depend on session data // to avoid the model binding logic invoking a getter before it's ready for use. - /// List of Address Types for dropdown. + /// List of Code Types for dropdown. public IEnumerable GetCodeTypesForSelect() { - List codeTypes = new List(); - SaCodeType.Params prmCodeType = new SaCodeType.Params(); - prmCodeType.SortColumns.Add(CodeTypeConsole.GetCodeTypeColumnDfn(SaCodeType.Column.Name)); + List codeTypes = new List(); + SaCodeType.Params prmCodeType = new SaCodeType.Params(); + prmCodeType.SortColumns.Add(CodeTypeConsole.GetCodeTypeColumnDfn(SaCodeType.Column.Name)); foreach (SaCodeType codeType in CodeTypeConsole.GetCodeTypeList(prmCodeType)) - codeTypes.Add(codeType.Code, codeType.Name); + codeTypes.Add(codeType.Code, codeType.Name); return new SelectList(codeTypes, "Code", "Desc"); } + /// List of Code Type Codes for dropdown. + public IEnumerable GetCodeTypeCodesForSelect(Sbm.ApplCodeType codeType, bool activeOnly = true) + { + List codes = new List(); + foreach (SaCode code in CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(codeType), activeOnly)) + codes.Add(code.Code, code.Description); + return new SelectList(codes, "Code", "Desc"); + } + /// List of Address Types for dropdown. public IEnumerable GetAddressTypeCodesForSelect() { @@ -270,12 +279,12 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models /// List of Affiliate Types for dropdown. public IEnumerable GetAffiliateTypeCodesForSelect() - { - return new SelectList(GetCodesOfType(Sbm.SystemCode.AffiliateType), "Code", "Desc"); - } + { + return new SelectList(GetCodesOfType(Sbm.SystemCode.AffiliateType), "Code", "Desc"); + } - /// List of Association Types for dropdown. - public IEnumerable GetAssociationTypeCodesForSelect() + /// List of Association Types for dropdown. + public IEnumerable GetAssociationTypeCodesForSelect() { return new SelectList(GetCodesOfType(Sbm.SystemCode.AssociationType), "Code", "Desc"); } @@ -283,7 +292,6 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models /// List of Commodity Types for dropdown. public IEnumerable GetCommodityTypeCodesForSelect() { - return new SelectList(GetCodesOfType(Sbm.SystemCode.CommodityType), "Code", "Desc"); } diff --git a/SaBusMgrStandardBase/Base/App/Sbm.cs b/SaBusMgrStandardBase/Base/App/Sbm.cs index 66439f1..b4082d3 100644 --- a/SaBusMgrStandardBase/Base/App/Sbm.cs +++ b/SaBusMgrStandardBase/Base/App/Sbm.cs @@ -112,7 +112,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Configuration console. - public enum ConfigConsole + public enum SessionConfig { Generic, Sarand, @@ -127,7 +127,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { Text, Html - }; + } //------------------------------------------------------------------- /// @@ -408,7 +408,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App CommoditySuppliers, CommodityItemDocs, //--------------------------------------------------------------- - }; + } //------------------------------------------------------------------- /// @@ -469,7 +469,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App ItemOption = SaDataItemType.ItemOption, SecurityItem = SaDataItemType.SecurityItem, SecurityLink = SaDataItemType.SecurityLink, - }; + } //------------------------------------------------------------------- /// @@ -538,7 +538,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Asset, VehicleClass, Vehicle, - }; + } //------------------------------------------------------------------- /// Association Tab. @@ -553,7 +553,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Time, Task, Doc, - }; + } //------------------------------------------------------------------- /// @@ -564,7 +564,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Create, Update, Remove, - }; + } //------------------------------------------------------------------- /// @@ -580,7 +580,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App DataTaxRate, DataUnitMeasure, DataUomCategory, // has it own right of UOM Cat - }; + } //------------------------------------------------------------------- /// ItemBatchType link between data items. @@ -589,7 +589,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Any = -1, Unknown = 0, // Do not change existing values - these are tied to the database. SalesOrder = 10, - }; + } //------------------------------------------------------------------- /// @@ -614,7 +614,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App ItemCodeList_JobTrade = 101, ItemCodeList_JobEngineer = 102, ItemCodeList_SeasonalCategory = 103, - }; + } + + public enum AssociatedItemMode + { + Unknown, + Commodity_Parent, // 'From' item is fixed commodity - list associated 'To' items. + Commodity_Child, // 'To' item is fixed commodity - list associated 'From' items. + Requirement_Parent, // etc. + Requirement_Child, + } + //------------------------------------------------------------------- /// @@ -635,7 +645,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Process_LabourCost_Job = 311, Currency = 312, Region = 313, - }; + } //------------------------------------------------------------------- /// @@ -646,7 +656,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Any = 0, Security = 1, // Security parameter. UserParam = 2, // User configuration parameter. - }; + } //------------------------------------------------------------------- /// @@ -702,7 +712,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Contact_Update, Contact_Manage, */ - }; + } //------------------------------------------------------------------- /// @@ -714,7 +724,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Unknown = 0, CommoditySupply = 10, CommoditySales = 20, - }; + } //------------------------------------------------------------------- /// @@ -825,7 +835,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Generic file interface options. FileInterface_RowColValue, FileInterface_Mode, - }; + } //------------------------------------------------------------------- /// @@ -897,7 +907,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Item documents: DocType_Pdf, DocType_Image, - }; + } //------------------------------------------------------------------- /// @@ -908,7 +918,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App EstimateType_QuoteDefault = 1, DocType_Pdf_WebPublish, DocType_Image_WebPublish, - }; + } //------------------------------------------------------------------- /// @@ -917,7 +927,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public enum SystemUserOption { Right = 1000, - }; + } //------------------------------------------------------------------- /// @@ -929,7 +939,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App AllAccounts = 1, Admin, Test, - }; + } //------------------------------------------------------------------- /// @@ -942,7 +952,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Transactions, // Transactions Utilities, // Utilities Appl, // Application specific - }; + } //------------------------------------------------------------------- /// @@ -962,7 +972,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Utilities_Codes, Utilities_Security, Appl, // Application specific - }; + } //------------------------------------------------------------------- /// @@ -1004,7 +1014,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Util_Security_Stats, Util_Security_Manage, Appl, // Application specific - }; + } //------------------------------------------------------------------- /// @@ -1028,7 +1038,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App CommodityFilterInitialStockCat, StatusCaption_Container, SalesLocation, - }; + } //------------------------------------------------------------------- /// @@ -1070,7 +1080,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App File_ColumnWidth, File_ColumnCaption, File_Unit, - }; + } //------------------------------------------------------------------- /// @@ -1088,13 +1098,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App TransTimeChunk2Caption, EmailSubject, EmailBody, - }; + } //------------------------------------------------------------------- public enum OrgOption_Folder { CommodityImage, CommodityBarcodeImage, - }; + } //------------------------------------------------------------------- public enum OrgOption_AllowOption { @@ -1125,7 +1135,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App PurchaseItem_AssociatedSalesItems, Asset_Sale, Asset_Rental, - }; + } //------------------------------------------------------------------- public enum OrgOption_Caption { @@ -1161,7 +1171,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App MenuOpt_PurchaseDeliveries, MenuOpt_ProformaPurchaseInvoices, MenuOpt_PurchaseInvoices, - }; + } //------------------------------------------------------------------- public enum OrgOption_ShowColumn { @@ -1190,7 +1200,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App SalesOrderItem_QtyInvoiced, SalesOrderItem_NextProcess, Vehicle_KeyLocation, - }; + } //------------------------------------------------------------------- /// @@ -1216,7 +1226,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App StockLevel_Bay1 = SbmDbDfn.ColumnIdx.StockLevel_Bay1, StockLevel_Bay2 = SbmDbDfn.ColumnIdx.StockLevel_Bay2, StockLevel_Bay3 = SbmDbDfn.ColumnIdx.StockLevel_Bay3, - }; + } //------------------------------------------------------------------- /// @@ -1254,12 +1264,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App StockLevel_Bay1 = SbmDbDfn.ColumnIdx.StockLevel_Bay1, StockLevel_Bay2 = SbmDbDfn.ColumnIdx.StockLevel_Bay2, StockLevel_Bay3 = SbmDbDfn.ColumnIdx.StockLevel_Bay3, - }; + } public enum OrgOption_TransCreateStatus { ProformaSalesOrder, SalesOrder, - }; + } public enum OrgOption_StatusContainer { Provisional, @@ -1267,24 +1277,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Active, Actioned, Cancelled, - }; + } public enum OrgOption_PeriodDays { TransactionDatesInFuture, UpdateClosedTransaction, UpdateClosedTransaction_DispatchDetails, UpdateStockLevelsInPast, - }; + } public enum OrgOption_Minutes { AutoSaveTransaction, - }; + } public enum OrgOption_PeriodWeeks { ImminentStockDue, Timesheets, UpdateTimeRecords_Control, - }; + } public enum OrgOption_NumericDecimals { OrderQuantity, @@ -1292,23 +1302,23 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App CommodityLength, CommodityVolume, CommodityDensity, - }; + } public enum OrgOption_CommodityType { CommodityCreationDefault, - }; + } public enum OrgOption_StockLocation { SalesOrderDefault, PurchaseOrderDefault, TransactionFilterDefault, - }; + } public enum OrgOption_CmdFilterStockCat { MaintView, SalesSearch, PurchaseSearch, - }; + } //------------------------------------------------------------------- /// @@ -1321,26 +1331,26 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App StockLevels, Accounts, SalesProfile, - }; + } public enum WebUploadMethod { Unknown = 0, None = 10, Ftp, Webstore, - }; + } public enum WebDownloadData { Unknown = 0, Orders = 10, - }; + } public enum WebDownloadMethod { Unknown = 0, None = 10, Ftp, Webstore, - }; + } //------------------------------------------------------------------- /// @@ -1350,7 +1360,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { IncludeImminentStock, AllowZeroOrderItemAmount, - }; + } //------------------------------------------------------------------- /// FileInterface option. @@ -1360,14 +1370,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Row = 10, Col, Value, - }; + } /// File interface mode. public enum FileInterface_Mode { Unknown = 0, Csv = 1, MsExcel, - }; + } //------------------------------------------------------------------- /// @@ -1377,7 +1387,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { Unknown = 0, Customer = 10, - }; + } //------------------------------------------------------------------- /// @@ -1392,7 +1402,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App JobBooking = 30, // Allows period across more than one day. JobActionDue = 31, StaffHoliday = 900, - }; + } //------------------------------------------------------------------- /// @@ -1403,7 +1413,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Unknown = -1, Individual = 0, Organisation = 1, - }; + } //------------------------------------------------------------------- /// @@ -1423,7 +1433,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App PublicSector = 5, // 'PUB' Charity = 6, // 'CHA' ContactGroup = 10, // 'GRP' - }; + } //--------------------------------------------------------------------------- public enum AddressType @@ -1435,7 +1445,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Home = 3, // 'HOM' Delivery = 4, // 'DEL' Billing = 5, // 'BIL' - }; + } //------------------------------------------------------------------- /// @@ -1447,7 +1457,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App None, Full, Partial, - }; + } //------------------------------------------------------------------- /// @@ -1458,7 +1468,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Any = -1, Unknown = 0, Stock = 10, - }; + } //------------------------------------------------------------------- public enum LocationFilter @@ -1468,7 +1478,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App All = -2, // All locations. Any = -1, Unknown = 0, - }; + } //------------------------------------------------------------------- // Containers. @@ -1478,7 +1488,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Unknown = 0, // NB Do not change the positive values, as tied to the database. Stock = 10, - }; + } public enum ContainerType { Any = -1, @@ -1491,7 +1501,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Container = 200, Wagon, Pallet = 300, - }; + } //------------------------------------------------------------------- /// @@ -1502,7 +1512,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Unknown = 0, // NB Do not change the positive values, as tied to the database. Requirement_AssocItem_PurchaseCostProportion = 1, - }; + } //------------------------------------------------------------------- @@ -1516,12 +1526,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Portfolio = 10, Category = 20, Commodity = 30, - }; + } public enum PortfolioItemStatusCat { Current = -2, Any = -1, - }; + } //------------------------------------------------------------------- // Commodity. @@ -1535,7 +1545,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App NonStock = 2, // 'NST' Service = 3, // 'SRV' Asset = 4, // 'AST' - }; + } //------------------------------------------------------------------- // Stock Movement. @@ -1548,7 +1558,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App StockTransfer = 10, SalesAllocation = 20, PurchaseAllocation = 30, - }; + } public enum StockLevelType { Any = -1, @@ -1556,7 +1566,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // NB Do not change the positive values, as tied to the database. CurrentLevel = 10, StockTake = 20, - }; + } public enum StockEventType { Any = -1, @@ -1564,7 +1574,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // NB Do not change the positive values, as tied to the database. Movement = 1, StockLevel, - }; + } public enum StockLevelSource { Any = -1, @@ -1573,7 +1583,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Manual = 10, System = 20, Sage = 30, // NB Needs to be corrected from '21' on Cadix db [Apr2012]. - }; + } //------------------------------------------------------------------- // Pricing. @@ -1583,7 +1593,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Customer = 10, Supplier = 20, Special = 30, - }; + } public enum PriceCalcMethod { Unknown = 0, @@ -1601,39 +1611,39 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App MarkupValue = 15, /// Increase sales price by a percentage MarkupSales = 16, - }; + } public enum PriceRounderMethod { Unknown = 0, - }; + } public enum PriceRounderDirection { Unknown = 0, - }; + } //------------------------------------------------------------------- // Associations. public enum AssociationType { Personal = -2, // Task management only. - Any = -1, - Unknown = 0, + NotInternal = -1, + Any = 0, // NB Do not change the positive values, as tied to the database. - Internal = 1, // 'INT' - Customer = 2, // 'CUS' - Supplier = 3, // 'SUP' - Associate = 4, // 'ASS' - Member = 5, // 'MEM' - Contractor = 6, // 'CON' - Stockist = 7, // 'STK' - FinanceAgency = 8, // 'FIN' - }; + Internal = 1, + Customer = 2, + Supplier = 3, + Associate = 4, + Member = 5, + Contractor = 6, + Stockist = 7, + FinanceAgency = 8, + } public enum AssociationTypeContext { Any, TimeRecording, // Association types that can have time records. Action, // Association types that can have actions. - }; + } //------------------------------------------------------------------- // Transaction. @@ -1658,13 +1668,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App SalesInvoice = 51, // 'SAI' PurchaseInvoice = 52, // 'PUV' ProformaPurchaseInvoice = 53, // 'PPI' - }; + } public enum TransactionTypeContext { Any, TimeRecording, // Transaction types that can have time records. Action, // Transaction types that can have actions. - }; + } //------------------------------------------------------------------- // Requirements. @@ -1673,13 +1683,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Any = 0, Detail = 1, Job = 2, - }; + } public enum TaskCodeType { Any = 0, Project = 1, Job = 2, - }; + } //------------------------------------------------------------------- // Constituents. @@ -1695,7 +1705,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Consumable = 14, Expense = 15, Process = 20, - }; + } //------------------------------------------------------------------- // Cost Estimates. @@ -1705,7 +1715,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // NB Do not change the positive values, as tied to the database. Cost = 1, Labour - }; + } //------------------------------------------------------------------- public enum CostEstimateCategory { @@ -1716,14 +1726,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App CostPerJob = 2, LabourPerUnit = 3, LabourPerJob = 4, - }; + } //------------------------------------------------------------------- public enum DiscountMarkup { Discount = 10, Markup = 20, - }; + } public enum DiscountType { // Values 0 - 6 are in line with Sage Sales Order definition. @@ -1734,7 +1744,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App QtyDiscountC = 4, // Discount Applied by Banding C QtyDiscountD = 5, // Discount Applied by Banding D QtyDiscountE = 6, // Discount Applied by Banding E - }; + } //------------------------------------------------------------------- public enum ProcessCategory @@ -1744,7 +1754,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // NB Do not change the positive values, as tied to the database. Commodity = 10, Asset = 20, - }; + } public enum ProcessType { Any = -1, @@ -1754,7 +1764,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Production = 11, Finishing = 12, External = 20, - }; + } //------------------------------------------------------------------- public enum PaymentType @@ -1767,7 +1777,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Cheque = 30, DebitCard = 40, CreditCard = 50, - }; + } //------------------------------------------------------------------- // Assets. @@ -1779,7 +1789,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Furniture = 11, Vehicle = 50, ComputerHardware = 60, - }; + } public enum AssetIncomeType { Unknown = 0, @@ -1787,7 +1797,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // NB Do not change the positive values, as tied to the database. Sale = 10, Rental = 20, - }; + } //------------------------------------------------------------------- // Vehicles. @@ -1801,7 +1811,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Van = 12, Truck = 13, Coach = 14, - }; + } public enum VehicleEventType { Any = -1, @@ -1812,7 +1822,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Incident = 12, Repair = 13, Comment = 14, - }; + } public enum VehicleFeatureSource { Any = -1, @@ -1823,7 +1833,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App CAP = 12, DVLA = 13, SMMT = 14, - }; + } public enum VehicleFeatureType { Any = -1, @@ -1847,7 +1857,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Equipment = 101, // Standard equipment. OptionalExtra = 102, // Manufacturer option. SelectedOption = 103, - }; + } public enum VehicleOptionType { Any = -1, @@ -1858,7 +1868,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Wheels, PaintFinish, Packs, - }; + } public enum VehicleTransType { Any = -1, @@ -1866,7 +1876,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // NB Do not change the positive values, as tied to the database. Manual = 10, Automatic = 20, - }; + } public enum VehicleFuelType { Any = -1, @@ -1877,7 +1887,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Lpg = 12, Electric = 13, Hybrid = 20, - }; + } public enum VehicleOdometerUnits { Any = -1, @@ -1885,7 +1895,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // NB Do not change the positive values, as tied to the database. Mile = 10, Kilometre = 11, - }; + } //------------------------------------------------------------------- // Interface types. @@ -1896,14 +1906,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App WebStore = 10, JoomlaVirtueMart = 40, MiMoWeb = 150, // MiMo website. - }; + } public enum InterfaceType_Accounts { Unknown = 0, // NB Do not change the positive values, as tied to the database. SageLine50 = 50, QuickBooks = 60, - }; + } public enum InterfaceType_System { Unknown = 0, @@ -1918,7 +1928,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Anchor_OrderFulfilment = 200, // Order fulfilment for Anchor Storage. Cadix_OrderSpreadsheet_Argos = 220, Cadix_OrderSpreadsheet_Homebase = 221, - }; + } public enum InterfaceType_File { Unknown = 0, @@ -1950,7 +1960,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App TransToWord_PurchaseDelivery = 1500 + TransactionType.PurchaseDelivery, //TransToWord_ProformaPurchaseInvoice = 1500+ProformaPurchaseInvoice, - Use Purchase Invoice interface. TransToWord_PurchaseInvoice = 1500 + TransactionType.PurchaseInvoice, - }; + } //------------------------------------------------------------------- // Interface Data Types. @@ -1998,7 +2008,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App ConstituentTime, // Utility data: Pricing, - }; + } //------------------------------------------------------------------- // Action to be performed for each Stock Type on import. @@ -2006,7 +2016,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { Import, Ignore - }; + } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardBase/Base/App/SbmAppConsole.cs b/SaBusMgrStandardBase/Base/App/SbmAppConfig.cs similarity index 61% rename from SaBusMgrStandardBase/Base/App/SbmAppConsole.cs rename to SaBusMgrStandardBase/Base/App/SbmAppConfig.cs index 224bf87..75cc212 100644 --- a/SaBusMgrStandardBase/Base/App/SbmAppConsole.cs +++ b/SaBusMgrStandardBase/Base/App/SbmAppConfig.cs @@ -8,19 +8,22 @@ using System; namespace Sarand.BusinessMgr.Net.Standard.Base.App { - //======================================================================= - public static class SbmAppConsole + //======================================================================= + /// + /// Application configuration: + /// - Availability of UI components - menu options, views etc. + /// + public static class SbmAppConfig { - private static readonly String ClassName = "SbmAppConsole"; + private const String ClassName = nameof(SbmAppConfig); //------------------------------------------------------------------- // A p p l i c a t i o n V i e w s //------------------------------------------------------------------- - // Jul-2021 ConfigConsole parameter added to avoid local creation. To be reviewed/replaced. - public static bool IsViewApplicable(ISbmUserContext_Core userContext, SbmConfigConsole configConsole, Sbm.View view) + // Jul-2021 SessionConfig parameter added to avoid local creation. To be reviewed/replaced. + public static bool IsViewApplicable(SbmSessionConsole sessionConfig, Sbm.View view) { - //SbmConfigConsole configConsole = SbmGlobals.GetConfigConsole(userContext.SessionContext); - ISbmSecurityProfile_Core securityProfile = userContext.SecurityProfile_Core; + ISbmSecurityProfile_Core securityProfile = sessionConfig.UserContext.SecurityProfile_Core; switch (view) { //----------------------------------------------------------- @@ -29,210 +32,210 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App case Sbm.View.Main: return true; case Sbm.View.Console: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowConsoleView)) return false; - if (!configConsole.GetConsoleViewDfn().HasContent()) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowConsoleView)) return false; + if (!sessionConfig.GetConsoleViewDfn().HasContent()) return false; return true; case Sbm.View.Diary: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.DiaryView)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.DiaryView)) return false; return true; //----------------------------------------------------------- // Contacts. case Sbm.View.Contacts_Affiliates: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; return true; case Sbm.View.Contacts_ContactGroups: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; return true; case Sbm.View.Contacts_Associations: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AnyAssociationView)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AnyAssociationView)) return false; return true; case Sbm.View.Contacts_Associations_Customer: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Customer)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; return true; case Sbm.View.Contacts_Associations_Supplier: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Supplier)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; return true; case Sbm.View.Contacts_Associations_Associate: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Associate)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Associate)) return false; return true; case Sbm.View.Contacts_Associations_Stockist: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Stockist)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Stockist)) return false; return true; case Sbm.View.Contacts_Associations_FinanceAgency: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.FinanceAgency)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.FinanceAgency)) return false; return true; case Sbm.View.Contacts_Associations_Member: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Member)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Member)) return false; return true; case Sbm.View.Contacts_Associations_Contractor: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Contractor)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Contractor)) return false; return true; //----------------------------------------------------------- // Commodities. case Sbm.View.Commodities: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; return true; case Sbm.View.Commodity_Locations: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; return true; case Sbm.View.Commodity_Containers: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; return true; case Sbm.View.Commodity_Portfolio: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; return true; case Sbm.View.Commodity_SalesBudget: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; return true; case Sbm.View.PriceSets: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) return false; - //if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowPriceSets)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; + //if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowPriceSets)) return false; return true; //----------------------------------------------------------- // Assets. case Sbm.View.AssetCategories: case Sbm.View.Assets: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowAssets)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets)) return false; return true; case Sbm.View.VehicleClasses: case Sbm.View.Vehicles: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowAssets)) return false; - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowVehicles)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowVehicles)) return false; return true; //----------------------------------------------------------- // Transactions. case Sbm.View.Transactions: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AnyTransactionView)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AnyTransactionView)) return false; return true; case Sbm.View.Transactions_Project: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.Project)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.Project)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.Project)) return false; return true; case Sbm.View.Transactions_PurchaseQuote: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Supplier)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseQuote)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseQuote)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseQuote)) return false; return true; case Sbm.View.Transactions_ProformaPurchaseOrder: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Supplier)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaPurchaseOrder)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaPurchaseOrder)) return false; return true; case Sbm.View.Transactions_PurchaseOrder: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Supplier)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseOrder)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseOrder)) return false; return true; case Sbm.View.Transactions_PurchaseSO: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Supplier)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseSO)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseSO)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseSO)) return false; return true; case Sbm.View.Transactions_PurchaseDelivery: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Supplier)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseDelivery)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseDelivery)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseDelivery)) return false; return true; case Sbm.View.Transactions_ProformaPurchaseInvoice: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Supplier)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaPurchaseInvoice)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaPurchaseInvoice)) return false; return true; case Sbm.View.Transactions_PurchaseInvoice: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Supplier)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseInvoice)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseInvoice)) return false; return true; case Sbm.View.Transactions_SalesLead: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Customer)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesLead)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesLead)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesLead)) return false; return true; case Sbm.View.Transactions_SalesQuote: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Customer)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesQuote)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesQuote)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesQuote)) return false; return true; case Sbm.View.Transactions_ProformaSalesOrder: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Customer)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaSalesOrder)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaSalesOrder)) return false; return true; case Sbm.View.Transactions_SalesOrder: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Customer)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesOrder)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesOrder)) return false; return true; case Sbm.View.Transactions_SalesPO: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Customer)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesPO)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesPO)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesPO)) return false; return true; case Sbm.View.Transactions_SalesDispatch: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Customer)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesDispatch)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesDispatch)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesDispatch)) return false; return true; case Sbm.View.Transactions_ProformaSalesInvoice: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Customer)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesInvoice)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesInvoice)) return false; return true; case Sbm.View.Transactions_SalesInvoice: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowAssociationType(userContext, Sbm.AssociationType.Customer)) return false; - if (!configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesInvoice)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesInvoice)) return false; return true; //----------------------------------------------------------- // Planning. case Sbm.View.Transactions_PurchasingPlanning: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowPurchasingPlanning)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowPurchasingPlanning)) return false; return true; case Sbm.View.Transactions_ProductionControl: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowProductionControl)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowProductionControl)) return false; return true; case Sbm.View.Transactions_DeliveryPlanning: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) return false; - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowDeliveryPlanning)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowDeliveryPlanning)) return false; return true; //----------------------------------------------------------- // Other. case Sbm.View.SystemAccounts: case Sbm.View.SystemUsers: - if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; // Interfaces must be available. - using (SaInterfaceConsole interfaceConsole = SbmGlobals.Application.CreateInterfaceConsole(userContext)) + using (SaInterfaceConsole interfaceConsole = SbmGlobals.Application.CreateInterfaceConsole(sessionConfig.UserContext)) { if (interfaceConsole == null || !interfaceConsole.DatabaseIsValid) return false; // System Account & User tables must be available. - ISacsDatabase busMgrDb = SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext); + ISacsDatabase busMgrDb = SbmGlobals.Application.GetBusMgrDatabase(sessionConfig.UserContext.SessionContext); if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemAccount)) return false; if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemUser)) return false; } @@ -265,17 +268,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // A p p l i c a t i o n M e n u //------------------------------------------------------------------- - public static bool IsMenuOptionApplicable(ISbmUserContext_Core userContext, SbmConfigConsole configConsole, Sbm.MenuOption menuOption) + public static bool IsMenuOptionApplicable(SbmSessionConsole sessionConfig, Sbm.MenuOption menuOption) { - if (!userContext.ValidUser) + if (!sessionConfig.UserContext.ValidUser) { // ToDo Only Login menu option available. return false; } - Sbm.View view = GetViewForMenuOption(userContext.SessionContext, menuOption); + Sbm.View view = GetViewForMenuOption(sessionConfig.UserContext.SessionContext, menuOption); if (view != Sbm.View.Unknown) // View options. - return IsViewApplicable(userContext, configConsole, GetViewForMenuOption(userContext.SessionContext, menuOption)); + return IsViewApplicable(sessionConfig, GetViewForMenuOption(sessionConfig.UserContext.SessionContext, menuOption)); // Non-view options. switch (menuOption) @@ -293,7 +296,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //----------------------------------------------------------- // Actions. case Sbm.MenuOption.Timesheet: - return configConsole.AllowOption(userContext, Sbm.ConfigOption.TimeRecording); + return sessionConfig.AllowOption(Sbm.ConfigOption.TimeRecording); //----------------------------------------------------------- } SaLogger.Warn($"{SysUtil.Fn} Unsupport menu option - {menuOption.ToString()}"); diff --git a/SaBusMgrStandardBase/Base/App/SbmApplication.cs b/SaBusMgrStandardBase/Base/App/SbmApplication.cs index 852d454..709769f 100644 --- a/SaBusMgrStandardBase/Base/App/SbmApplication.cs +++ b/SaBusMgrStandardBase/Base/App/SbmApplication.cs @@ -16,8 +16,8 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.App { - //======================================================================= - public abstract class SbmApplication : SacsDisposable + //======================================================================= + public abstract class SbmApplication : SacsDisposable { //------------------------------------------------------------------- // Data members. @@ -58,6 +58,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { return GetBusMgrDatabase(sessionContext).CreateDbInfo(); } + // Instance configuration. + public abstract SbmInstanceConfig GetInstanceConfig(SbmSessionContext sessionContext); // Database utilities. public IDatabaseInfo CreateDbInfo(ISacsDatabase db) { @@ -82,7 +84,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Create consoles. - public abstract SbmConfigConsole CreateConfigConsole(SbmSessionContext sessionContext); + public abstract SbmSessionConsole CreateSessionConsole(ISbmUserContext_Core userContext); public abstract SaDiaryConsole CreateDiaryConsole(ISbmUserContext_Core userContext); public abstract SaSecurityConsole CreateSecurityConsole(ISbmUserContext_Core userContext); public abstract SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserContext_Core userContext); diff --git a/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs b/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs index 1fb8f02..8113836 100644 --- a/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs +++ b/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs @@ -1,4 +1,5 @@ -using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; +using Org.BouncyCastle.Math.EC; +using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; @@ -16,102 +17,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App /// public abstract class SbmInstanceConfig { - //------------------------------------------------------------------- - // Definitions. - protected const String ParamContext_Config = "Config"; - protected const String ParamContext_ConfigPrefix = "Config-"; - protected const String ApplicationOptionValue_Allow = "Allow"; - protected const String ApplicationOptionValue_Disallow = "Disallow"; - protected const String ApplicationOptionValue_Default= "Default"; - - //------------------------------------------------------------------- - // Owner/Instance configuration parameters. - public enum ConfigParamType - { - // Affiliate types. - AllowedAffiliateTypes, - DisallowedAffiliateTypes, - // Association types. - AllowedAssociationTypes, - DisallowedAssociationTypes, - // Transaction types. - AllowedTransactionTypes, - DisallowedTransactionTypes, - // Application options. - ApplicationOption, - } - public class ConfigParamData - { - public ConfigParamType ConfigParam { get; set; } - public String Context { get; set; } - public String Name { get; set; } - public HashSet Values { get; } = new HashSet(); - public bool Password { get; set; } - } - - public bool IsConfigParamOfType(ConfigParamType configParam, SbmcItemParam itemParam) - { - switch (configParam) - { - // Affiliate types. - case ConfigParamType.AllowedAffiliateTypes: - case ConfigParamType.DisallowedAffiliateTypes: - // Association types. - case ConfigParamType.AllowedAssociationTypes: - case ConfigParamType.DisallowedAssociationTypes: - // Transaction types. - case ConfigParamType.AllowedTransactionTypes: - case ConfigParamType.DisallowedTransactionTypes: - return itemParam.Context.EqualsCI(ParamContext_Config) && itemParam.Name.EqualsCI(configParam.ToString()); - // Application options. - case ConfigParamType.ApplicationOption: - return itemParam.Context.EqualsCI($"{ParamContext_ConfigPrefix}{ConfigParamType.ApplicationOption.ToString()}"); - } - return false; - } - - public ConfigParamData GetConfigParamData(ConfigParamType configParam) - { - switch (configParam) - { - // Affiliate types. - case ConfigParamType.AllowedAffiliateTypes: - case ConfigParamType.DisallowedAffiliateTypes: - // Association types. - case ConfigParamType.AllowedAssociationTypes: - case ConfigParamType.DisallowedAssociationTypes: - // Transaction types. - case ConfigParamType.AllowedTransactionTypes: - case ConfigParamType.DisallowedTransactionTypes: - return new ConfigParamData() { ConfigParam = configParam, Context = ParamContext_Config, Name = configParam.ToString() }; - } - return null; - } - - public ConfigParamData GetAllowOptionConfigParamData(Sbm.ConfigOption option) - { - ConfigParamData configParamData = new ConfigParamData() { ConfigParam = ConfigParamType.ApplicationOption, Context = $"{ParamContext_ConfigPrefix}{ConfigParamType.ApplicationOption.ToString()}", Name = option.ToString() }; - configParamData.Values.UnionWith(new List() { ApplicationOptionValue_Allow, ApplicationOptionValue_Disallow, ApplicationOptionValue_Default }); - return configParamData; - } - //------------------------------------------------------------------- // Application options. - //------------------------------------------------------------------- + public abstract bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse); //------------------------------------------------------------------- // Allowed data component types. - //------------------------------------------------------------------- - // Supported affiliate types. - public abstract bool AllowAffiliateType(Sbm.AffiliateType type); - // Supported Association types. - public abstract bool AllowAssociationType(Sbm.AssociationType type); - // Supported Transaction types. - public abstract bool AllowTransactionType(Sbm.TransactionType type); - //------------------------------------------------------------------- - // Allow Option. + // Supported affiliate types. + public abstract bool AllowAffiliateType(Sbm.AffiliateType type, bool defaultResponse); + // Supported Association types. + public abstract bool AllowAssociationType(Sbm.AssociationType type, bool defaultResponse); + // Supported Transaction types. + public abstract bool AllowTransactionType(Sbm.TransactionType type, bool defaultResponse); //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardBase/Base/App/SbmInternals.cs b/SaBusMgrStandardBase/Base/App/SbmInternals.cs index 0fbbb6c..d56f795 100644 --- a/SaBusMgrStandardBase/Base/App/SbmInternals.cs +++ b/SaBusMgrStandardBase/Base/App/SbmInternals.cs @@ -40,7 +40,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App private SbmProcessMgr processMgr; private SbmDataItemMgr dataItemMgr; // Consoles. - private SbmConfigConsole configConsole; + private SbmSessionConsole sessionConsole; private SaDiaryConsole diaryConsole; private SaSecurityConsole securityConsole; private SaCodeTypeConsole codeTypeConsole; @@ -83,7 +83,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App if (taxCodes != null) taxCodes.ClearAndDispose(); if (unitsOfMeasure != null) unitsOfMeasure.ClearAndDispose(); // Consoles. - if (configConsole != null) configConsole.Dispose(); + if (sessionConsole != null) sessionConsole.Dispose(); if (diaryConsole != null) diaryConsole.Dispose(); if (securityConsole != null) securityConsole.Dispose(); if (codeTypeConsole != null) codeTypeConsole.Dispose(); @@ -213,13 +213,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Consoles. - public SbmConfigConsole ConfigConsole + public SbmSessionConsole SessionConsole { get { - if (configConsole == null) - configConsole = Application.CreateConfigConsole(SessionContext); - return configConsole; + if (sessionConsole == null) + sessionConsole = Application.CreateSessionConsole(UserContext); + return sessionConsole; } } public SaDiaryConsole DiaryConsole @@ -324,7 +324,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App get { if (stockControlConfig == null) - stockControlConfig = ConfigConsole.GetStockControlConfig(UserContext); + stockControlConfig = SessionConsole.GetStockControlConfig(); return stockControlConfig; } } @@ -333,7 +333,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App get { if (requirementCostingConfig == null) - requirementCostingConfig = ConfigConsole.GetRequirementCostingConfig(UserContext); + requirementCostingConfig = SessionConsole.GetRequirementCostingConfig(); return requirementCostingConfig; } } @@ -351,7 +351,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public List GetCurrencies() { populateCurrencies(); - return currencies; + return new List(currencies); } public SaCurrency GetCurrencyById(SysId currencyId) { @@ -393,7 +393,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public List GetTaxCodes() { populateTaxCodes(); - return taxCodes; + return new List(taxCodes); } public SaTaxCode GetTaxCodeById(SysId currencyId) { @@ -415,7 +415,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public List GetUnitsOfMeasure() { populateUnitsOfMeasure(); - return unitsOfMeasure; + return new List(unitsOfMeasure); + } + public String GetUnitOfMeasureCaption(SysId currencyId) + { + if (!SysId.IsValid(currencyId)) return null; + populateUnitsOfMeasure(); + SaUnitMeasure uom = unitsOfMeasure.Find(item => item.Id.Equals(currencyId)); + return uom?.Single ?? ""; } public SaUnitMeasure GetUnitOfMeasureById(SysId currencyId) { diff --git a/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs b/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs index 2178753..9b316ef 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs @@ -21,19 +21,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App private bool includeHostSecurityProfile = false; private SaSecurityProfile userSecurityProfile; private SaSecurityProfile hostSecurityProfile; - private readonly List securityRights = new List(); + private readonly List securityRights = new List(); //------------------------------------------------------------------- // Construction. + [JsonConstructor] + private SbmSecurityProfile() { } public SbmSecurityProfile(ISbmUserContext_Core userContext, bool includeHostSecurityProfile) { this.UserContext = userContext; this.includeHostSecurityProfile = includeHostSecurityProfile; - Admin = new AdminProfile(this); - Manage = new ManageProfile(this); - Financial = new FinancialProfile(this); - Contacts = new ContactsProfile(this); - Transaction = new TransactionsProfile(this); + Admin = new AdminProfile(); + Manage = new ManageProfile(); + Financial = new FinancialProfile(); + Contacts = new ContactsProfile(); + Transaction = new TransactionsProfile(); } //------------------------------------------------------------------- @@ -43,7 +45,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Refresh profile. - public void RefreshProfile(SbmConfigConsole configConsole, SaSecurityConsole securityConsole, SysId userId, List securityRights) + public void RefreshProfile(SbmSessionConsole sessionConsole, SaSecurityConsole securityConsole, SysId userId, List securityRights) { ClearErrorState(); @@ -65,33 +67,33 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App } SaLogger.Debug($"{SysUtil.Fn} User: '{UserDisplayName}' [Id: {UserId}]" + (SysId.IsValid(previousUserId) ? ". Previous UserId: " + SysId.ToString(previousUserId) : "")); - RefreshProfileSettings(configConsole); + RefreshProfileSettings(sessionConsole); } - protected void RefreshProfile(SbmConfigConsole configConsole, SaSecurityProfile userSecurityProfile, SaSecurityProfile hostSecurityProfile) + protected void RefreshProfile(SbmSessionConsole sessionConsole, SaSecurityProfile userSecurityProfile, SaSecurityProfile hostSecurityProfile) { this.userSecurityProfile = userSecurityProfile; this.hostSecurityProfile = hostSecurityProfile; - RefreshProfileSettings(configConsole); + RefreshProfileSettings(sessionConsole); } - private void RefreshProfileSettings(SbmConfigConsole configConsole) + private void RefreshProfileSettings(SbmSessionConsole sessionConfig) { - RefreshAdminProfile(configConsole); - RefreshManageProfile(configConsole); - RefreshFinancialProfile(configConsole); - RefreshContactsProfile(configConsole); - RefreshTransactionProfile(configConsole); - RefreshItemTypeProfile(configConsole); + RefreshAdminProfile(sessionConfig); + RefreshManageProfile(sessionConfig); + RefreshFinancialProfile(sessionConfig); + RefreshContactsProfile(sessionConfig); + RefreshTransactionProfile(sessionConfig); + RefreshItemTypeProfile(sessionConfig); // ToDo Commodities. } private void ClearProfile() { // Reset security profiles. - Admin = new AdminProfile(this); - Manage = new ManageProfile(this); - Financial = new FinancialProfile(this); - Contacts = new ContactsProfile(this); - Transaction = new TransactionsProfile(this); + Admin = new AdminProfile(); + Manage = new ManageProfile(); + Financial = new FinancialProfile(); + Contacts = new ContactsProfile(); + Transaction = new TransactionsProfile(); } //------------------------------------------------------------------- @@ -126,18 +128,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Security rights - Admin. public class AdminProfile { - private readonly SbmSecurityProfile securityProfile; - internal AdminProfile(SbmSecurityProfile securityProfile) - { - this.securityProfile = securityProfile; - } + internal AdminProfile() { } public bool CanManageSecurity { get; internal set; } = false; public bool CanManageDatabase { get; internal set; } = false; public bool CanManageReferenceData { get; internal set; } = false; public bool CanManageInterfaces { get; internal set; } = false; } public AdminProfile Admin { get; internal set; } - private void RefreshAdminProfile(SbmConfigConsole configConsole) + private void RefreshAdminProfile(SbmSessionConsole sessionConfig) { Admin.CanManageSecurity = UserHasSecurityRight(Sbm.SecurityRight.Security_Admin); Admin.CanManageDatabase = UserHasSecurityRight(Sbm.SecurityRight.Database_Admin); @@ -149,16 +147,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Security rights - Manage. public class ManageProfile { - private readonly SbmSecurityProfile securityProfile; - internal ManageProfile(SbmSecurityProfile securityProfile) - { - this.securityProfile = securityProfile; - } + internal ManageProfile() { } public bool CanManageTasks { get; internal set; } = false; public bool CanManageTimesheets { get; internal set; } = false; } public ManageProfile Manage { get; internal set; } - private void RefreshManageProfile(SbmConfigConsole configConsole) + private void RefreshManageProfile(SbmSessionConsole sessionConfig) { Manage.CanManageTasks = UserHasSecurityRight(Sbm.SecurityRight.TaskManager); Manage.CanManageTimesheets = UserHasSecurityRight(Sbm.SecurityRight.TimesheetManager); @@ -168,36 +162,32 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Security rights - Financials. public class FinancialProfile { - private readonly SbmSecurityProfile securityProfile; - internal FinancialProfile(SbmSecurityProfile securityProfile) - { - this.securityProfile = securityProfile; - } - public bool CanViewFinancials { get; internal set; } - public bool CanUpdateFinancials { get; internal set; } - public bool CanViewCommoditySupplyFinancials { get; internal set; } - public bool CanUpdateCommoditySupplyFinancials { get; internal set; } - public bool CanViewCommoditySalesFinancials { get; internal set; } - public bool CanUpdateCommoditySalesFinancials { get; internal set; } - public bool ConfigOption_AllowFinancialsAccessControl { get; internal set; } + internal FinancialProfile() { } + public bool ViewFinancials { get; internal set; } + public bool UpdateFinancials { get; internal set; } + public bool ViewCommoditySupplyFinancials { get; internal set; } + public bool UpdateCommoditySupplyFinancials { get; internal set; } + public bool ViewCommoditySalesFinancials { get; internal set; } + public bool UpdateCommoditySalesFinancials { get; internal set; } + public bool FinancialsAccessControl { get; internal set; } } public FinancialProfile Financial { get; internal set; } - private void RefreshFinancialProfile(SbmConfigConsole configConsole) + private void RefreshFinancialProfile(SbmSessionConsole sessionConfig) { - Financial.CanViewFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_View); - Financial.CanUpdateFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_Update); - Financial.CanViewCommoditySupplyFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySupply); - Financial.CanUpdateCommoditySupplyFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySupply); - Financial.CanViewCommoditySalesFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySales); - Financial.CanUpdateCommoditySalesFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySales); + Financial.ViewFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_View); + Financial.UpdateFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_Update); + Financial.ViewCommoditySupplyFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySupply); + Financial.UpdateCommoditySupplyFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySupply); + Financial.ViewCommoditySalesFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySales); + Financial.UpdateCommoditySalesFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySales); // Config options. - Financial.ConfigOption_AllowFinancialsAccessControl = (configConsole != null && !configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowFinancialsAccessControl)); + Financial.FinancialsAccessControl = (sessionConfig != null && !sessionConfig.AllowOption(Sbm.ConfigOption.AllowFinancialsAccessControl)); } public bool UserCanViewFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any) { - if (!Financial.ConfigOption_AllowFinancialsAccessControl) return true; - if (Financial.CanUpdateFinancials || Financial.CanViewFinancials) + if (!Financial.FinancialsAccessControl) return true; + if (Financial.UpdateFinancials || Financial.ViewFinancials) { // If specific type of financial is requested, check that view is not denied. if (financialType > 0 && IsSecurityRightDenied(Sbm.SecurityRight.Financial_ViewByType, new SysId((int)financialType))) @@ -209,8 +199,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public bool UserCanUpdateFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any) { - if (!Financial.ConfigOption_AllowFinancialsAccessControl) return true; - if (Financial.CanUpdateFinancials) + if (!Financial.FinancialsAccessControl) return true; + if (Financial.UpdateFinancials) { // If specific type of financial is requested, check that update is not denied. if (financialType > 0 && IsSecurityRightDenied(Sbm.SecurityRight.Financial_UpdateByType, new SysId((int)financialType))) @@ -242,35 +232,27 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Security rights - Contacts. public class ContactsProfile { - private readonly SbmSecurityProfile securityProfile; - internal ContactsProfile(SbmSecurityProfile securityProfile) - { - this.securityProfile = securityProfile; - } - public bool CanCreate { get; internal set; } = false; - public bool CanUpdate { get; internal set; } = false; + internal ContactsProfile() { } + public bool Create { get; internal set; } = false; + public bool Update { get; internal set; } = false; } public ContactsProfile Contacts { get; internal set; } - public bool UserCanCreateContacts { get { return Contacts.CanCreate; } } - public bool UserCanUpdateContacts { get { return Contacts.CanUpdate; } } - private void RefreshContactsProfile(SbmConfigConsole configConsole) + public bool UserCanCreateContacts() { return Contacts.Create; } + public bool UserCanUpdateContacts() { return Contacts.Update; } + private void RefreshContactsProfile(SbmSessionConsole sessionConfig) { - Contacts.CanUpdate = (UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Update)); - Contacts.CanCreate = (Contacts.CanUpdate || UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Create)); + Contacts.Update = (UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Update)); + Contacts.Create = (Contacts.Update || UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Create)); } //------------------------------------------------------------------- // Security rights - Transactions. public class TransactionsProfile { - private readonly SbmSecurityProfile securityProfile; - internal TransactionsProfile(SbmSecurityProfile securityProfile) - { - this.securityProfile = securityProfile; - } - public bool CanCreate { get; internal set; } = false; - public bool CanUpdate { get; internal set; } = false; - public bool CanUpdateTransactionTypeStatusCat(Sbm.TransactionType transactionType, SbmTransaction.StatusCat transactionStatusCat) + internal TransactionsProfile() { } + public bool Create { get; internal set; } = false; + public bool Update { get; internal set; } = false; + public bool CanUpdateTransactionTypeStatusCat(SbmSecurityProfile securityProfile, Sbm.TransactionType transactionType, SbmTransaction.StatusCat transactionStatusCat) { SysId transactionTypeStatusCatId = SbmTransaction.GetTransactionTypeStatusId(transactionType, transactionStatusCat); @@ -297,10 +279,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App } } public TransactionsProfile Transaction { get; internal set; } - private void RefreshTransactionProfile(SbmConfigConsole configConsole) + private void RefreshTransactionProfile(SbmSessionConsole sessionConfig) { - Transaction.CanUpdate = (UserHasSecurityRight(Sbm.SecurityRight.Transaction_Update)); - Transaction.CanCreate = (Transaction.CanUpdate || UserHasSecurityRight(Sbm.SecurityRight.Transaction_View)); + Transaction.Update = (UserHasSecurityRight(Sbm.SecurityRight.Transaction_Update)); + Transaction.Create = (Transaction.Update || UserHasSecurityRight(Sbm.SecurityRight.Transaction_View)); } public bool UserCanAccessTransactionsOfType(Sbm.TransactionType transactionType) @@ -317,40 +299,40 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public class ItemTypesProfile { internal ItemTypesProfile() { } - public bool CanCreate { get; internal set; } - public bool CanUpdate { get; internal set; } - public bool CanRemove { get; internal set; } + public bool Create { get; internal set; } + public bool Update { get; internal set; } + public bool Remove { get; internal set; } // Config options. - public bool ConfigOption_AllowProcesses { get; internal set; } - public bool ConfigOption_AllowContacts { get; internal set; } - public bool ConfigOption_AllowCommodities { get; internal set; } - public bool ConfigOption_AllowPortfolios { get; internal set; } - public bool ConfigOption_AllowPriceSets { get; internal set; } - public bool ConfigOption_CommodityCustomers { get; internal set; } - public bool ConfigOption_CommoditySuppliers { get; internal set; } - public bool ConfigOption_AllowTransactions { get; internal set; } - public bool ConfigOption_AllowAssets { get; internal set; } - public bool ConfigOption_AllowVehicles { get; internal set; } - public bool ConfigOption_AllowStockLocations { get; internal set; } - public bool ConfigOption_AllowStockContainers { get; internal set; } - public bool ConfigOption_AllowStockControl { get; internal set; } + public bool Processes { get; internal set; } + public bool Contacts { get; internal set; } + public bool Commodities { get; internal set; } + public bool Portfolios { get; internal set; } + public bool PriceSets { get; internal set; } + public bool CommodityCustomers { get; internal set; } + public bool CommoditySuppliers { get; internal set; } + public bool Transactions { get; internal set; } + public bool Assets { get; internal set; } + public bool Vehicles { get; internal set; } + public bool StockLocations { get; internal set; } + public bool StockContainers { get; internal set; } + public bool StockControl { get; internal set; } } public ItemTypesProfile ItemType { get; } = new ItemTypesProfile(); - private void RefreshItemTypeProfile(SbmConfigConsole configConsole) + private void RefreshItemTypeProfile(SbmSessionConsole sessionConfig) { - ItemType.ConfigOption_AllowProcesses = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowProcesses); - ItemType.ConfigOption_AllowContacts = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowContacts); - ItemType.ConfigOption_AllowCommodities = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowCommodities); - ItemType.ConfigOption_AllowPortfolios = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowPortfolios); - ItemType.ConfigOption_AllowPriceSets = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowPriceSets); - ItemType.ConfigOption_CommodityCustomers = configConsole.AllowOption(UserContext, Sbm.ConfigOption.CommodityCustomers); - ItemType.ConfigOption_CommoditySuppliers = configConsole.AllowOption(UserContext, Sbm.ConfigOption.CommoditySuppliers); - ItemType.ConfigOption_AllowTransactions = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowTransactions); - ItemType.ConfigOption_AllowAssets = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowAssets); - ItemType.ConfigOption_AllowVehicles = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowVehicles); - ItemType.ConfigOption_AllowStockLocations = configConsole.GetStockControlConfig(UserContext).AllowStockLocations(); - ItemType.ConfigOption_AllowStockContainers = configConsole.GetStockControlConfig(UserContext).AllowStockContainers(); - ItemType.ConfigOption_AllowStockControl = configConsole.GetStockControlConfig(UserContext).AllowStockControl(); + ItemType.Processes = sessionConfig.AllowOption(Sbm.ConfigOption.AllowProcesses); + ItemType.Contacts = sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts); + ItemType.Commodities = sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities); + ItemType.Portfolios = sessionConfig.AllowOption(Sbm.ConfigOption.AllowPortfolios); + ItemType.PriceSets = sessionConfig.AllowOption(Sbm.ConfigOption.AllowPriceSets); + ItemType.CommodityCustomers = sessionConfig.AllowOption(Sbm.ConfigOption.CommodityCustomers); + ItemType.CommoditySuppliers = sessionConfig.AllowOption(Sbm.ConfigOption.CommoditySuppliers); + ItemType.Transactions = sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions); + ItemType.Assets = sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets); + ItemType.Vehicles = sessionConfig.AllowOption(Sbm.ConfigOption.AllowVehicles); + ItemType.StockLocations = sessionConfig.GetStockControlConfig().AllowStockLocations(); + ItemType.StockContainers = sessionConfig.GetStockControlConfig().AllowStockContainers(); + ItemType.StockControl = sessionConfig.GetStockControlConfig().AllowStockControl(); } public bool ItemTypeIsAllowed(Sbm.ItemType itemType) @@ -363,37 +345,37 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //case Sbm.ItemType.Language: //case Sbm.ItemType.TaxCode: //case Sbm.ItemType.UnitMeasure: - case Sbm.ItemType.Process: return ItemType.ConfigOption_AllowProcesses; + case Sbm.ItemType.Process: return ItemType.Processes; case Sbm.ItemType.Affiliate: - case Sbm.ItemType.Address: return ItemType.ConfigOption_AllowContacts; - case Sbm.ItemType.Commodity: return ItemType.ConfigOption_AllowCommodities; - case Sbm.ItemType.PortfolioItem: return ItemType.ConfigOption_AllowPortfolios; - case Sbm.ItemType.Location: return ItemType.ConfigOption_AllowStockLocations; + case Sbm.ItemType.Address: return ItemType.Contacts; + case Sbm.ItemType.Commodity: return ItemType.Commodities; + case Sbm.ItemType.PortfolioItem: return ItemType.Portfolios; + case Sbm.ItemType.Location: return ItemType.StockLocations; case Sbm.ItemType.Container: - case Sbm.ItemType.ContainerItem: return ItemType.ConfigOption_AllowStockContainers; + case Sbm.ItemType.ContainerItem: return ItemType.StockContainers; case Sbm.ItemType.Movement: - case Sbm.ItemType.StockLevel: return ItemType.ConfigOption_AllowStockControl; + case Sbm.ItemType.StockLevel: return ItemType.StockControl; case Sbm.ItemType.PriceSet: - case Sbm.ItemType.Price: return ItemType.ConfigOption_AllowPriceSets; - case Sbm.ItemType.CommodityCustomer: return ItemType.ConfigOption_CommodityCustomers; - case Sbm.ItemType.CommoditySupplier: return ItemType.ConfigOption_CommoditySuppliers; + case Sbm.ItemType.Price: return ItemType.PriceSets; + case Sbm.ItemType.CommodityCustomer: return ItemType.CommodityCustomers; + case Sbm.ItemType.CommoditySupplier: return ItemType.CommoditySuppliers; //case Sbm.ItemType.Association: case Sbm.ItemType.Transaction: case Sbm.ItemType.Requirement: - case Sbm.ItemType.Constituent: return ItemType.ConfigOption_AllowTransactions; + case Sbm.ItemType.Constituent: return ItemType.Transactions; //case Sbm.ItemType.SystemAccount: //case Sbm.ItemType.SystemUser: //case Sbm.ItemType.SystemAccountUser: case Sbm.ItemType.AssetCategory: case Sbm.ItemType.AssetCategoryProcess: case Sbm.ItemType.Asset: - case Sbm.ItemType.AssetProcess: return ItemType.ConfigOption_AllowAssets; + case Sbm.ItemType.AssetProcess: return ItemType.Assets; case Sbm.ItemType.VehicleClass: case Sbm.ItemType.Vehicle: case Sbm.ItemType.VehicleEvent: - case Sbm.ItemType.VehicleFeature: return ItemType.ConfigOption_AllowVehicles; - case Sbm.ItemType.CommodityProcess: return ItemType.ConfigOption_AllowProcesses; - case Sbm.ItemType.RequirementProcess: return ItemType.ConfigOption_AllowProcesses; + case Sbm.ItemType.VehicleFeature: return ItemType.Vehicles; + case Sbm.ItemType.CommodityProcess: return ItemType.Processes; + case Sbm.ItemType.RequirementProcess: return ItemType.Processes; //case Sbm.ItemType.Interface: } return true; diff --git a/SaBusMgrStandardBase/Base/App/SbmSessionProfile.cs b/SaBusMgrStandardBase/Base/App/SbmSessionProfile.cs deleted file mode 100644 index b1e1454..0000000 --- a/SaBusMgrStandardBase/Base/App/SbmSessionProfile.cs +++ /dev/null @@ -1,172 +0,0 @@ -using Sarand.BusinessMgr.Net.Standard.Base.Bus; -using Sarand.BusinessMgr.Net.Standard.Base.Consoles; -using Sarand.BusinessMgr.Net.Standard.Base.Core; -using Sarand.BusinessMgr.Net.Standard.Base.Mgr; -using Sarand.Net.Standard.Base.App; -using Sarand.Net.Standard.Base.Bus; -using Sarand.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Dbas; -using Sarand.Net.Standard.Base.ItemOptions; -using Sarand.Net.Standard.Base.Security; -using Sarand.Net.Standard.Base.Utils; -using System.Collections.Generic; - -namespace Sarand.BusinessMgr.Net.Standard.Base.App -{ - //======================================================================= - public abstract class SbmSessionProfile - { - //------------------------------------------------------------------- - // Definitions. - internal class SbmUserContext_Internal : SbmUserContext - { - // Construction. - public SbmUserContext_Internal(SbmSessionContext sessionContext) : - base(sessionContext) - { - } - // Refresh context. - public void RefreshUser(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List supervisedOwners) - { - SetUserData(securityItemUser, affiliateUser, supervisedOwners); - } - public void ClearUser() - { - ClearUserData(); - } - public void RefreshSecurityProfile(SbmSecurityProfile securityProfile) - { - SetSecurityProfile(securityProfile); - } - public void RefreshOrganisation(SysId affiliateIdOrganisation) - { - SetOrganisationData(affiliateIdOrganisation); - } - public void ClearOrganisation() - { - ClearOrganisationData(); - } - } - - //------------------------------------------------------------------- - // Data members. - private readonly SbmUserContext_Internal userContext; - - //------------------------------------------------------------------- - // Protected Construction - use derived objects. - protected SbmSessionProfile(SbmSessionContext sessionContext, SysId affiliateIdUser) - { - userContext = new SbmUserContext_Internal(sessionContext); - SysParamCache = new SbmSysParamCache(userContext, affiliateIdUser); - } - - //------------------------------------------------------------------- - // Properties. - public SbmUserContext UserContext { get { return userContext; } } - public SbmSessionContext SessionContext { get { return userContext.SessionContext; } } - public ISbmSecurityProfile_Core SecurityProfile { get { return UserContext.SecurityProfile_Core; } } - protected SaItemOption.Cache OrganisationConfigOptionsCache { get { return UserContext.OrganisationConfigOptionsCache; } } - // User parameters. - protected SbmSysParamCache SysParamCache { get; } - - //------------------------------------------------------------------- - // O w n e r O r g a n i s a t i o n - //------------------------------------------------------------------- - public abstract bool SetSelectedOwner(SysId affiliateId); - protected void RefreshOwnerOrganisation(SysId affiliateIdOrganisation) - { - if (SysId.IsValid(affiliateIdOrganisation)) - userContext.RefreshOrganisation(affiliateIdOrganisation); - else userContext.ClearOrganisation(); - } - - //------------------------------------------------------------------- - // U s e r S e s s i o n - //------------------------------------------------------------------- - public bool StartUserSession(SysId userId, List securityRights) - { - // Clear existing User details. - ClearUserSession(); - - using (SbmConfigConsole configConsole = SbmGlobals.Application.CreateConfigConsole(UserContext.SessionContext)) - using (SaSecurityConsole securityConsole = SbmGlobals.Application.CreateSecurityConsole(UserContext)) - using (SbmAccountMgr accountMgr = CreateAccountMgr()) - { - // Security item. - SaSecurityItem securityItemUser = securityConsole.GetSecurityItemById(SaSecurity.ItemType.User, userId); - - SbmAffiliate affiliateUser = accountMgr.GetAffiliateByUserId(userId); - if (affiliateUser == null) - { - SaLogger.Warn($"{SysUtil.Fn} Unable to retrieve affiliate for UserId: {SysId.ToString(userId)}"); - return false; - } - List userSupervisedOwners = accountMgr.GetAffiliatesSupervisedBy(affiliateUser.Id); - userContext.RefreshUser(securityItemUser, affiliateUser, userSupervisedOwners); - - // Populate security rights. - SecurityProfile.RefreshProfile(configConsole, securityConsole, userId, securityRights); - - // Reinstate previous owner if defined and verify that it is in the supervised list. - SysId affiliateIdOwner = UserContext.Organisation.AffiliateId; - if (!userSupervisedOwners.Exists(item => item.Id.Equals(affiliateIdOwner))) - affiliateIdOwner = new SysId(); - // If not otherwise defined, select first owner in supervised list. - if (!SysId.IsValid(affiliateIdOwner) && userSupervisedOwners.Count > 0) - affiliateIdOwner = userSupervisedOwners[0].Id; - SetSelectedOwner(affiliateIdOwner); - } - - // ToDo StartUserSession Reinstate previous default view. - - return true; - } - public void ClearUserSession() - { - // Save user parameters. - SysParamCache.Store(); - - // Reset user details. - userContext.ClearUser(); - SysParamCache.Clear(); - } - - //------------------------------------------------------------------- - // Save the user's session parameters. - public bool SaveSessionProfile() - { - bool success = false; - - // Update the list of parameters that we know about to the database. - success = SysParamCache.Store(); - - // Clear down the list of parameters for this user. - SysParamCache.Clear(); - - return success; - } - - //------------------------------------------------------------------- - // D a t a b a s e - //------------------------------------------------------------------- - // Database Update - public DbUpdateInfo DbUpdateInfo - { - get - { - return new DbUpdateInfo(SecurityProfile.UserId, SecurityProfile.UserDisplayName, SacsSystem.ComputerName); - } - } - - public SaSecurityConsole SaSecurityConsole { get; private set; } - - // Data managers. - protected SbmAccountMgr CreateAccountMgr() - { - return SbmGlobals.System.CreateAccountMgr(UserContext); - } - - //------------------------------------------------------------------- - } - //======================================================================= -} diff --git a/SaBusMgrStandardBase/Base/App/SbmSystem-CodeTypes.cs b/SaBusMgrStandardBase/Base/App/SbmSystem-CodeTypes.cs index ee9f93d..fd1e5cd 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSystem-CodeTypes.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSystem-CodeTypes.cs @@ -25,17 +25,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // R e g i s t e r C o d e T y p e s //------------------------------------------------------------------- - public static void RegisterCodeTypes(SbmConfigConsole configConsole, SaCodeTypeConsole codeTypeConsole, ISbmUserContext_Core userContext) + public static void RegisterCodeTypes(SbmSessionConsole sessionConfig, SaCodeTypeConsole codeTypeConsole) { //--------------------------------------------------------------- // C o m m o d i t i e s //--------------------------------------------------------------- - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) + if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) { // Commodity category. SaCodeTypeDfn codeTypeCommodityCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.CommodityCategory), 12); codeTypeConsole.RegisterCodeType(codeTypeCommodityCategory); - codeTypeConsole.RegisterCodesOfType(codeTypeCommodityCategory.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityCategory)); + codeTypeConsole.RegisterCodesOfType(codeTypeCommodityCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityCategory)); // Commodity range. SaCodeTypeDfn codeTypeCommodityRange = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityRange), codeTypes.GetDescForType(Sbm.ApplCodeType.CommodityRange), 12); @@ -62,184 +62,184 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //codeTypeConsole.RegisterCodeType(codeTypeCommodityDelivery); // Commodity material. - String commodityMaterialLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material"); + String commodityMaterialLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material"); if (!commodityMaterialLabel.ContainsCI("Commodity")) commodityMaterialLabel = "Commodity " + commodityMaterialLabel; SaCodeTypeDfn codeTypeCommodityMaterial = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityMaterial), commodityMaterialLabel, 12); codeTypeConsole.RegisterCodeType(codeTypeCommodityMaterial); - codeTypeConsole.RegisterCodesOfType(codeTypeCommodityMaterial.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityMaterial)); + codeTypeConsole.RegisterCodesOfType(codeTypeCommodityMaterial.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityMaterial)); // Commodity finish. - String commodityFinishLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish"); + String commodityFinishLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish"); if (!commodityFinishLabel.ContainsCI("Commodity")) commodityFinishLabel = "Commodity " + commodityFinishLabel; SaCodeTypeDfn codeTypeCommodityFinish = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityFinish), commodityFinishLabel, 12); codeTypeConsole.RegisterCodeType(codeTypeCommodityFinish); - codeTypeConsole.RegisterCodesOfType(codeTypeCommodityFinish.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityFinish)); + codeTypeConsole.RegisterCodesOfType(codeTypeCommodityFinish.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityFinish)); // Commodity promotion. - String commodityPromotionLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion"); + String commodityPromotionLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion"); if (!commodityPromotionLabel.ContainsCI("Commodity")) commodityPromotionLabel = "Commodity " + commodityPromotionLabel; SaCodeTypeDfn codeTypeCommodityPromotion = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityPromotion), commodityPromotionLabel, 12); codeTypeConsole.RegisterCodeType(codeTypeCommodityPromotion); - codeTypeConsole.RegisterCodesOfType(codeTypeCommodityPromotion.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityPromotion)); + codeTypeConsole.RegisterCodesOfType(codeTypeCommodityPromotion.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityPromotion)); } //--------------------------------------------------------------- // P r o c e s s e s //--------------------------------------------------------------- - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowProcesses)) + if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowProcesses)) { // Process type. SaCodeTypeDfn codeTypeProcessType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ProcessType), codeTypes.GetDescForType(Sbm.ApplCodeType.ProcessType), 12); codeTypeConsole.RegisterCodeType(codeTypeProcessType); - codeTypeConsole.RegisterCodesOfType(codeTypeProcessType.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.ProcessType)); + codeTypeConsole.RegisterCodesOfType(codeTypeProcessType.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.ProcessType)); } //--------------------------------------------------------------- // R e f e r r a l //--------------------------------------------------------------- - if (configConsole != null) + if (sessionConfig != null) { // Refer type. SaCodeTypeDfn codeTypeReferType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ReferType), codeTypes.GetDescForType(Sbm.ApplCodeType.ReferType), 12); codeTypeReferType.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeReferType); - codeTypeConsole.RegisterCodesOfType(codeTypeReferType.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.ReferType)); + codeTypeConsole.RegisterCodesOfType(codeTypeReferType.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.ReferType)); } //--------------------------------------------------------------- // T a s k s //--------------------------------------------------------------- - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowTasks)) + if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowTasks)) { // Task category. SaCodeTypeDfn codeTypeTaskCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.TaskCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.TaskCategory), 12); codeTypeTaskCategory.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeTaskCategory); - codeTypeConsole.RegisterCodesOfType(codeTypeTaskCategory.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.TaskCategory)); + codeTypeConsole.RegisterCodesOfType(codeTypeTaskCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.TaskCategory)); } //--------------------------------------------------------------- // A s s e t s //--------------------------------------------------------------- - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowAssets)) + if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets)) { // Asset sell category. SaCodeTypeDfn codeTypeAssetSellCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AssetSellCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.AssetSellCategory), 8); codeTypeConsole.RegisterCodeType(codeTypeAssetSellCategory); - codeTypeConsole.RegisterCodesOfType(codeTypeAssetSellCategory.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.AssetSellCategory)); + codeTypeConsole.RegisterCodesOfType(codeTypeAssetSellCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.AssetSellCategory)); } //--------------------------------------------------------------- // V e h i c l e s //--------------------------------------------------------------- - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowVehicles)) + if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowVehicles)) { // Vehicle category. SaCodeTypeDfn codeTypeVehicleCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleCategory), 8); codeTypeConsole.RegisterCodeType(codeTypeVehicleCategory); - codeTypeConsole.RegisterCodesOfType(codeTypeVehicleCategory.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleCategory)); + codeTypeConsole.RegisterCodesOfType(codeTypeVehicleCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleCategory)); // Vehicle make. SaCodeTypeDfn codeTypeVehicleMake = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleMake), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleMake), 8); codeTypeConsole.RegisterCodeType(codeTypeVehicleMake); - codeTypeConsole.RegisterCodesOfType(codeTypeVehicleMake.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleMake)); + codeTypeConsole.RegisterCodesOfType(codeTypeVehicleMake.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleMake)); // Vehicle service history. SaCodeTypeDfn codeTypeVehicleServiceHistory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleServiceHistory), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleServiceHistory), 12); codeTypeConsole.RegisterCodeType(codeTypeVehicleServiceHistory); - codeTypeConsole.RegisterCodesOfType(codeTypeVehicleServiceHistory.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleServiceHistory)); + codeTypeConsole.RegisterCodesOfType(codeTypeVehicleServiceHistory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleServiceHistory)); // Vehicle insurance. SaCodeTypeDfn codeTypeVehicleInsurance = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleInsurance), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleInsurance), 3); codeTypeConsole.RegisterCodeType(codeTypeVehicleInsurance); - codeTypeConsole.RegisterCodesOfType(codeTypeVehicleInsurance.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleInsurance)); + codeTypeConsole.RegisterCodesOfType(codeTypeVehicleInsurance.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleInsurance)); // Vehicle tacho. SaCodeTypeDfn codeTypeVehicleTacho = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleTacho), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleTacho), 8); //codeTypeConsole.RegisterCodeType(codeTypeVehicleTacho); - //codeTypeConsole.RegisterCodesOfType(codeTypeVehicleTacho.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleTacho)); + //codeTypeConsole.RegisterCodesOfType(codeTypeVehicleTacho.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleTacho)); } //--------------------------------------------------------------- // H P I V e h i c l e s //--------------------------------------------------------------- - if (configConsole != null && configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (int)Sbm.InterfaceType_System.Hpi)) + if (sessionConfig != null && sessionConfig.AllowInterface(SaInterfaceCategory.System, (int)Sbm.InterfaceType_System.Hpi)) { // HPI vehicle make. SaCodeTypeDfn codeTypeHpiVehicleMake = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleMake), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleMake), 12); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleMake); - codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleMake.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleMake)); + codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleMake.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleMake)); // HPI vehicle model. SaCodeTypeDfn codeTypeHpiVehicleModel = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleModel), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleModel), 12); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleModel); - codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleModel.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleModel)); + codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleModel.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleModel)); // HPI vehicle colour. SaCodeTypeDfn codeTypeHpiVehicleColour = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleColour), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleColour), 12); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleColour); - codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleColour.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleColour)); + codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleColour.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleColour)); // HPI vehicle fuel. SaCodeTypeDfn codeTypeHpiVehicleFuel = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleFuel), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleFuel), 12); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleFuel); - codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleFuel.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleFuel)); + codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleFuel.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleFuel)); // HPI vehicle transmission. SaCodeTypeDfn codeTypeHpiVehicleTrans = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleTrans), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleTrans), 12); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleTrans); - codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleTrans.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleTrans)); + codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleTrans.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleTrans)); } //--------------------------------------------------------------- // C o n t a c t M a n a g e m e n t //--------------------------------------------------------------- - if (configConsole != null) + if (sessionConfig != null) { // Account manager. - String accountManagerLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Association_AccountManagerCode, "Account manager"); + String accountManagerLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountManagerCode, "Account manager"); SaCodeTypeDfn codeTypeAccountManager = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountManager), accountManagerLabel, 12, "Account management group"); codeTypeConsole.RegisterCodeType(codeTypeAccountManager); // Account handler. - String accountHandlerLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Association_AccountHandlerCode, "Account handler"); + String accountHandlerLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode, "Account handler"); SaCodeTypeDfn codeTypeAccountHandler = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountHandler), accountHandlerLabel, 12, "Account handling group"); codeTypeConsole.RegisterCodeType(codeTypeAccountHandler); // Account type. - String accountTypeLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Association_AccountTypeCode, "Account type"); + String accountTypeLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountTypeCode, "Account type"); SaCodeTypeDfn codeTypeAccountType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountType), accountTypeLabel, 12, "Grouping by nature of business"); codeTypeConsole.RegisterCodeType(codeTypeAccountType); // Account rating. - String accountRatingLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Association_AccountRatingCode, "Account rating"); + String accountRatingLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountRatingCode, "Account rating"); SaCodeTypeDfn codeTypeAccountRating = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountRating), accountRatingLabel, 12); codeTypeConsole.RegisterCodeType(codeTypeAccountRating); // Contact title. - String contactTitleLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Affiliate_Title, "Contact title"); + String contactTitleLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Affiliate_Title, "Contact title"); SaCodeTypeDfn codeTypeContactTitle = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactTitle), contactTitleLabel, 12); codeTypeContactTitle.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeContactTitle); - codeTypeConsole.RegisterCodesOfType(codeTypeContactTitle.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.ContactTitle)); + codeTypeConsole.RegisterCodesOfType(codeTypeContactTitle.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.ContactTitle)); // Contact area. - String contactAreaLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Association_ContactAreaCode, "Contact area"); + String contactAreaLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, "Contact area"); SaCodeTypeDfn codeTypeContactArea = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactArea), contactAreaLabel, 12, "Geographic region"); codeTypeConsole.RegisterCodeType(codeTypeContactArea); // Contact handler. - String contactHandlerLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Association_ContactHandlerCode, "Contact handler"); + String contactHandlerLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode, "Contact handler"); SaCodeTypeDfn codeTypeContactHandler = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactHandler), contactHandlerLabel, 12); codeTypeConsole.RegisterCodeType(codeTypeContactHandler); // Contact method. - String contactMethodLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Association_ContactMethodCode, "Contact method"); + String contactMethodLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactMethodCode, "Contact method"); SaCodeTypeDfn codeTypeContactMethod = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactMethod), contactMethodLabel, 12); codeTypeConsole.RegisterCodeType(codeTypeContactMethod); // Contact call cycle. - String contactCallCycleLabel = configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode, "Contact call cycle"); + String contactCallCycleLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode, "Contact call cycle"); SaCodeTypeDfn codeTypeContactCallCycle = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactCallCycle), contactCallCycleLabel, 12); codeTypeConsole.RegisterCodeType(codeTypeContactCallCycle); @@ -252,7 +252,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // C o s t E s t i m a t e s //--------------------------------------------------------------- FlagDfn estimateDefaultFlag = new FlagDfn((Byte)Sbm.ApplCodeFlag.EstimateType_QuoteDefault, "Default to quote", "Default"); - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.EstimateSalesQuotesByCosts)) + if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.EstimateSalesQuotesByCosts)) { // Cost per unit. SaCodeTypeDfn codeTypeCostPerUnit = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CostPerUnit), codeTypes.GetDescForType(Sbm.ApplCodeType.CostPerUnit), 12); @@ -264,85 +264,85 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App codeTypeCostPerUnit.FlagDefinitions.Add(new FlagDfn(4, "Flag 4", "#4")); #endif codeTypeConsole.RegisterCodeType(codeTypeCostPerUnit); - codeTypeConsole.RegisterCodesOfType(codeTypeCostPerUnit.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerUnit)); + codeTypeConsole.RegisterCodesOfType(codeTypeCostPerUnit.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerUnit)); // Cost per job. SaCodeTypeDfn codeTypeCostPerJob = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CostPerJob), codeTypes.GetDescForType(Sbm.ApplCodeType.CostPerJob), 12); codeTypeCostPerJob.AllowSequence = true; codeTypeCostPerJob.FlagDefinitions.Add(estimateDefaultFlag); codeTypeConsole.RegisterCodeType(codeTypeCostPerJob); - codeTypeConsole.RegisterCodesOfType(codeTypeCostPerJob.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerJob)); + codeTypeConsole.RegisterCodesOfType(codeTypeCostPerJob.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerJob)); } - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.EstimateLabourByMinutes)) + if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.EstimateLabourByMinutes)) { // Labour cost per unit. SaCodeTypeDfn codeTypeLabourPerUnit = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.LabourPerUnit), codeTypes.GetDescForType(Sbm.ApplCodeType.LabourPerUnit), 12); codeTypeLabourPerUnit.AllowSequence = true; codeTypeLabourPerUnit.FlagDefinitions.Add(estimateDefaultFlag); codeTypeConsole.RegisterCodeType(codeTypeLabourPerUnit); - codeTypeConsole.RegisterCodesOfType(codeTypeLabourPerUnit.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.LabourPerUnit)); + codeTypeConsole.RegisterCodesOfType(codeTypeLabourPerUnit.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.LabourPerUnit)); // Labour cost per job. SaCodeTypeDfn codeTypeLabourPerJob = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.LabourPerJob), codeTypes.GetDescForType(Sbm.ApplCodeType.LabourPerJob), 12); codeTypeLabourPerJob.AllowSequence = true; codeTypeLabourPerJob.FlagDefinitions.Add(estimateDefaultFlag); codeTypeConsole.RegisterCodeType(codeTypeLabourPerJob); - codeTypeConsole.RegisterCodesOfType(codeTypeLabourPerJob.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.LabourPerJob)); + codeTypeConsole.RegisterCodesOfType(codeTypeLabourPerJob.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.LabourPerJob)); } //--------------------------------------------------------------- // D e l i v e r y //--------------------------------------------------------------- - if (configConsole != null && userContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails)) + if (sessionConfig != null && sessionConfig.UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails)) { // Delivery status. SaCodeTypeDfn codeTypeDeliveryStatus = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryStatus), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryStatus), 3); codeTypeDeliveryStatus.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeDeliveryStatus); - codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryStatus.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryStatus)); + codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryStatus.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryStatus)); // Delivery type. SaCodeTypeDfn codeTypeDeliveryType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryType), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryType), 12); codeTypeDeliveryType.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeDeliveryType); - codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryType.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryType)); + codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryType.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryType)); // Delivery method. SaCodeTypeDfn codeTypeDeliveryMethod = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryMethod), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryMethod), 12); codeTypeDeliveryMethod.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeDeliveryMethod); - codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryMethod.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryMethod)); + codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryMethod.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryMethod)); // Delivery courier. SaCodeTypeDfn codeTypeDeliveryCourier = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryCourier), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryCourier), 12); codeTypeDeliveryCourier.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeDeliveryCourier); - codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryCourier.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryCourier)); + codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryCourier.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryCourier)); // Delivery book-in. SaCodeTypeDfn codeTypeDeliveryBookIn = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryBookIn), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryBookIn), 12); codeTypeDeliveryBookIn.AllowSequence = true; //codeTypeConsole.RegisterCodeType(codeTypeDeliveryBookIn); - //codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryBookIn.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryBookIn)); + //codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryBookIn.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryBookIn)); // Order lead time. SaCodeTypeDfn codeTypeOrderLeadTime = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.OrderLeadTime), codeTypes.GetDescForType(Sbm.ApplCodeType.OrderLeadTime), 12); codeTypeOrderLeadTime.AllowSequence = true; //codeTypeConsole.RegisterCodeType(codeTypeOrderLeadTime); - //codeTypeConsole.RegisterCodesOfType(codeTypeOrderLeadTime.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.OrderLeadTime)); + //codeTypeConsole.RegisterCodesOfType(codeTypeOrderLeadTime.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.OrderLeadTime)); // Delivery picker. SaCodeTypeDfn codeTypeStockPicker = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.StockPicker), codeTypes.GetDescForType(Sbm.ApplCodeType.StockPicker), 12); codeTypeStockPicker.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeStockPicker); - codeTypeConsole.RegisterCodesOfType(codeTypeStockPicker.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.StockPicker)); + codeTypeConsole.RegisterCodesOfType(codeTypeStockPicker.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.StockPicker)); } //--------------------------------------------------------------- // I t e m D o c u m e n t s //--------------------------------------------------------------- - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowItemDocuments)) + if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowItemDocuments)) { // PDF document types. SaCodeTypeDfn codeTypeDocType_Pdf = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DocType_Pdf), codeTypes.GetDescForType(Sbm.ApplCodeType.DocType_Pdf), 12); @@ -350,7 +350,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App codeTypeDocType_Pdf.AllowMixedCode = true; codeTypeDocType_Pdf.FlagDefinitions.Add(new FlagDfn((Byte)Sbm.ApplCodeFlag.DocType_Pdf_WebPublish, "WebPublish", "Publish to Web")); codeTypeConsole.RegisterCodeType(codeTypeDocType_Pdf); - codeTypeConsole.RegisterCodesOfType(codeTypeDocType_Pdf.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DocType_Pdf)); + codeTypeConsole.RegisterCodesOfType(codeTypeDocType_Pdf.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DocType_Pdf)); // Image document types. SaCodeTypeDfn codeTypeDocType_Image = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DocType_Image), codeTypes.GetDescForType(Sbm.ApplCodeType.DocType_Image), 12); @@ -358,7 +358,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App codeTypeDocType_Image.AllowMixedCode = true; codeTypeDocType_Image.FlagDefinitions.Add(new FlagDfn((Byte)Sbm.ApplCodeFlag.DocType_Image_WebPublish, "WebPublish", "Publish to Web")); codeTypeConsole.RegisterCodeType(codeTypeDocType_Image); - codeTypeConsole.RegisterCodesOfType(codeTypeDocType_Image.Code, configConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DocType_Image)); + codeTypeConsole.RegisterCodesOfType(codeTypeDocType_Image.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DocType_Image)); } //--------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/App/SbmSystem.cs b/SaBusMgrStandardBase/Base/App/SbmSystem.cs index aff7ffb..803a121 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSystem.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSystem.cs @@ -42,17 +42,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Application definitions. - public static Sbm.ConfigConsole GetConfigConsoleType(String consoleProperty) + public static Sbm.SessionConfig GetSessionConfigType(String consoleProperty) { if (consoleProperty.ContainsCI("Sarand")) - return Sbm.ConfigConsole.Sarand; + return Sbm.SessionConfig.Sarand; if (consoleProperty.ContainsCI("MPE")) - return Sbm.ConfigConsole.MPE; + return Sbm.SessionConfig.MPE; if (consoleProperty.ContainsCI("BPE")) - return Sbm.ConfigConsole.BPE; + return Sbm.SessionConfig.BPE; if (consoleProperty.ContainsCI("Cadix") || consoleProperty.ContainsCI("CUL")) - return Sbm.ConfigConsole.Cadix; - return Sbm.ConfigConsole.Generic; + return Sbm.SessionConfig.Cadix; + return Sbm.SessionConfig.Generic; } public static String GetCopyrightNotice(bool html = false) { @@ -86,18 +86,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App } public static List GetCodesOfType(ISbmUserContext_Core userContext, Sbm.SystemCode systemCode) { - SbmConfigConsole configConsole = null; // SbmGlobals.GetConfigConsole(userContext.SessionContext); - switch (systemCode) + using (SbmInternals internals = new SbmInternals(userContext)) { - case Sbm.SystemCode.ItemType: - return new List(itemTypes); - case Sbm.SystemCode.AffiliateType: - return new List(affiliateTypes); - case Sbm.SystemCode.AssociationType: - return new List(associationTypes); - case Sbm.SystemCode.TransactionType: - // Transaction types. - return new List() + SbmSessionConsole sessionConsole = internals.SessionConsole; + switch (systemCode) + { + case Sbm.SystemCode.ItemType: + return new List(itemTypes); + case Sbm.SystemCode.AffiliateType: + return new List(affiliateTypes); + case Sbm.SystemCode.AssociationType: + return new List(associationTypes); + case Sbm.SystemCode.TransactionType: + // Transaction types. + return new List() { new TypeCodeDesc((int) Sbm.TransactionType.Project, "PRO", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_Project, "Project")), new TypeCodeDesc((int)Sbm.TransactionType.SalesLead, "SLD", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_SalesLead, "Sales Lead")), @@ -116,366 +118,367 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App new TypeCodeDesc((int)Sbm.TransactionType.ProformaPurchaseInvoice, "PPI", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_ProformaPurchaseInvoice, "Proforma Purchase Invoice")), new TypeCodeDesc((int)Sbm.TransactionType.PurchaseInvoice, "PUI", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_PurchaseInvoice, "Purchase Invoice")), }; - case Sbm.SystemCode.TransactionStatusCat: - return new List(transactionStatusCats); - case Sbm.SystemCode.RequirementType: - return new List(requirementTypes); - case Sbm.SystemCode.TaskCodeType: - return new List(taskCodeTypes); - case Sbm.SystemCode.RequirementStatusCat: - return new List(requirementStatusCats); - case Sbm.SystemCode.ConstituentType: - return new List(constituentTypes); - case Sbm.SystemCode.ConstituentStatusCat: - return new List(constituentStatusCats); - case Sbm.SystemCode.ItemLinkData: - return new List(itemLinkDatas); - case Sbm.SystemCode.PortfolioItemType: - return new List(portfolioItemTypes); - case Sbm.SystemCode.LocationCategory: - return new List(locationCategories); - case Sbm.SystemCode.LocationFilter: - return new List(locationFilters); - case Sbm.SystemCode.ContainerCategory: - return new List(containerCategories); - case Sbm.SystemCode.ContainerType: - return new List(containerTypes); - case Sbm.SystemCode.CommodityType: - { - // CommodityType. - List CommodityType = new List(); - CommodityType.Add(Sbm.CommodityType.Stock, "STK", "Stock"); - CommodityType.Add(Sbm.CommodityType.NonStock, "NST", "Non-stock"); - CommodityType.Add(Sbm.CommodityType.Service, "SRV", "Service"); - if (assetCommodityTypeAllowed < 0) + case Sbm.SystemCode.TransactionStatusCat: + return new List(transactionStatusCats); + case Sbm.SystemCode.RequirementType: + return new List(requirementTypes); + case Sbm.SystemCode.TaskCodeType: + return new List(taskCodeTypes); + case Sbm.SystemCode.RequirementStatusCat: + return new List(requirementStatusCats); + case Sbm.SystemCode.ConstituentType: + return new List(constituentTypes); + case Sbm.SystemCode.ConstituentStatusCat: + return new List(constituentStatusCats); + case Sbm.SystemCode.ItemLinkData: + return new List(itemLinkDatas); + case Sbm.SystemCode.PortfolioItemType: + return new List(portfolioItemTypes); + case Sbm.SystemCode.LocationCategory: + return new List(locationCategories); + case Sbm.SystemCode.LocationFilter: + return new List(locationFilters); + case Sbm.SystemCode.ContainerCategory: + return new List(containerCategories); + case Sbm.SystemCode.ContainerType: + return new List(containerTypes); + case Sbm.SystemCode.CommodityType: { - // ToDo SbmSystem assetCommodityTypeAllowed - - using (SbmAssetMgr assetMgr = SbmGlobals.System.CreateAssetMgr(userContext)) + // CommodityType. + List CommodityType = new List(); + CommodityType.Add(Sbm.CommodityType.Stock, "STK", "Stock"); + CommodityType.Add(Sbm.CommodityType.NonStock, "NST", "Non-stock"); + CommodityType.Add(Sbm.CommodityType.Service, "SRV", "Service"); + if (assetCommodityTypeAllowed < 0) { - //assetCommodityTypeAllowed = assetMgr != null && assetMgr.DatabaseIsValid(); - } - } - if (assetCommodityTypeAllowed > 0) - CommodityType.Add(Sbm.CommodityType.Asset, "AST", "Asset"); - return CommodityType; - } - case Sbm.SystemCode.CommodityStatusCat: - return new List(commodityStatusCats); - case Sbm.SystemCode.MovementType: - return new List(movementTypes); - case Sbm.SystemCode.StockLevelType: - return new List(stockLevelTypes); - case Sbm.SystemCode.StockLevelSource: - return new List(stockLevelSources); - case Sbm.SystemCode.AddressType: - return new List(addressTypes); - case Sbm.SystemCode.SysParamCategory: - return new List(sysParamCategories); - case Sbm.SystemCode.ProcessCategory: - { - List ProcessCategory = new List(); - if (configConsole != null) - { - if (configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) - ProcessCategory.Add(Sbm.ProcessCategory.Commodity, "CMD", "Commodity"); - if (configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowAssets)) - ProcessCategory.Add(Sbm.ProcessCategory.Asset, "ASSET", "Asset"); - } - return ProcessCategory; - } - case Sbm.SystemCode.ProcessType: - return new List(processTypes); - case Sbm.SystemCode.PaymentType: - return new List(paymentTypes); - case Sbm.SystemCode.AssetIncomeType: - return new List(assetIncomeTypes); - case Sbm.SystemCode.AssetType: - return new List(assetTypes); - case Sbm.SystemCode.VehicleType: - return new List(vehicleTypes); - case Sbm.SystemCode.VehicleEventType: - return new List(vehicleEventTypes); - case Sbm.SystemCode.VehicleFeatureSource: - return new List(vVehicleFeatureSources); - case Sbm.SystemCode.VehicleFeatureType: - return new List(vehicleFeatureTypes); - case Sbm.SystemCode.VehicleOptionType: - return new List(vehicleOptionTypes); - case Sbm.SystemCode.VehicleTransType: - return new List(vehicleTransTypes); - case Sbm.SystemCode.FuelType: - return new List(fuelTypes); - case Sbm.SystemCode.OdometerUnits: - return new List(odometerUnits); - case Sbm.SystemCode.DiscountType: - return new List(discountTypes); - case Sbm.SystemCode.DiscountMarkup: - return new List(discountMarkups); - case Sbm.SystemCode.RegionType: - return new List(regionTypes); - case Sbm.SystemCode.UnitMeasureCategory: - return new List(unitMeasureCategories); - case Sbm.SystemCode.UnitMeasureType: - return new List(unitMeasureTypes); - case Sbm.SystemCode.FinancialType: - { - List FinancialType = new List(); - if (configConsole != null) - { - if (configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) - FinancialType.Add(Sbm.FinancialType.CommoditySupply, "CmdSup", "Commodity supply"); - } - FinancialType.Add(Sbm.FinancialType.CommoditySales, "CmdSal", "Commodity sales"); - return FinancialType; - } - case Sbm.SystemCode.PriceType: - return new List(priceTypes); - case Sbm.SystemCode.PriceCalcMethod: - return new List(priceCalcMethods); - case Sbm.SystemCode.PriceRounderMethod: - return new List(priceRounderMethods); - case Sbm.SystemCode.PriceRounderDirection: - return new List(priceRounderDirections); - case Sbm.SystemCode.SystemAccountType: - return new List(systemAccountTypes); - case Sbm.SystemCode.ItemStatus: - return new List(itemStatuses); - case Sbm.SystemCode.EventStatus: - return new List(eventStatuses); - case Sbm.SystemCode.AssociationTab: - return new List(associationTabs); - case Sbm.SystemCode.InterfaceType_Website: - { - // Interface types - Website. - // Duplicate static list and remove unsupported options. - List codes = new List(interfaceTypes_Website); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.Website, (short)(Sbm.InterfaceType_Website.WebStore))) - interfaceTypes_Website.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_Website.WebStore); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.Website, (short)(Sbm.InterfaceType_Website.JoomlaVirtueMart))) - interfaceTypes_Website.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_Website.JoomlaVirtueMart); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.Website, (short)(Sbm.InterfaceType_Website.MiMoWeb))) - interfaceTypes_Website.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_Website.MiMoWeb); - return new List(codes); - } - case Sbm.SystemCode.InterfaceType_Accounts: - { - // Interface Type - Accounts. - // Duplicate static list and remove unsupported options. - List codes = new List(interfaceTypes_Accounts); - return new List(codes); - } - case Sbm.SystemCode.InterfaceType_System: - { - // Interface Type - System. - // Duplicate static list and remove unsupported options. - List codes = new List(interfaceTypes_System); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.MSOutlook)) - interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.MSOutlook); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.PostcodeAnywhere)) - interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.PostcodeAnywhere); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Bac)) - interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Bac); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Pvh)) - interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Pvh); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Cap)) - interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Cap); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Hpi)) - interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Hpi); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Anchor_OrderFulfilment)) - interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Anchor_OrderFulfilment); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Argos)) - interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Argos); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase)) - interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase); - return new List(codes); - } - case Sbm.SystemCode.InterfaceType_File: - { - // Interface Type - File. - // Duplicate static list and remove unsupported options. - List codes = new List(interfaceTypes_File); - if (configConsole == null || !configConsole.AllowInterface(userContext, SaInterfaceCategory.System, (short)Sbm.InterfaceType_File.LeasewayInvoice)) - codes.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_File.LeasewayInvoice); - return new List(codes); - } - case Sbm.SystemCode.InterfaceDataType: - return new List(interfaceDataTypes); - case Sbm.SystemCode.ItemDataType: - return new List(itemDataTypes); - case Sbm.SystemCode.OrgOption_Value: - return new List(orgOption_Values); - case Sbm.SystemCode.OrgOption_Folder: - return new List(orgOption_Folders); - case Sbm.SystemCode.OrgOption_Minutes: - return new List(OrgOption_Minutes); - case Sbm.SystemCode.OrgOption_PeriodDays: - { - List OrgOption_PeriodDays = new List(); + // ToDo SbmSystem assetCommodityTypeAllowed - OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.TransactionDatesInFuture, "TransDatesInFut", "Days in future that transaction dates can be set", ""); - OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.UpdateClosedTransaction, "UpdClosedTrans", "Grace period (days) for updating closed transactions", "Period after transaction closure during which updates are allowed (0-30 days)"); - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowDeliveryPlanning)) - OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.UpdateClosedTransaction_DispatchDetails, "UpdDisDetCloTrans", "Grace period (days) for updating dispatch details on closed order", "Period after transaction closure during which dispatch updates are allowed (0-30 days)"); - if (configConsole != null && configConsole.GetStockControlConfig(userContext).AllowStockControl()) - OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.UpdateStockLevelsInPast, "UpdStkLvlInPast", "Update stock levels in past"); - return OrgOption_PeriodDays; - } - case Sbm.SystemCode.OrgOption_PeriodWeeks: - { - List OrgOption_PeriodWeeks = new List(); - if (configConsole != null && configConsole.AllowOption(userContext, Sbm.ConfigOption.TimeRecording)) - { - OrgOption_PeriodWeeks.Add(Sbm.OrgOption_PeriodWeeks.Timesheets, "Timesheets", "Weeks of timesheets to list (default 8)"); - OrgOption_PeriodWeeks.Add(Sbm.OrgOption_PeriodWeeks.UpdateTimeRecords_Control, "UpdTimeRecsCtrl", "Weeks in past for admin user to update time records (default 2)"); + using (SbmAssetMgr assetMgr = SbmGlobals.System.CreateAssetMgr(userContext)) + { + //assetCommodityTypeAllowed = assetMgr != null && assetMgr.DatabaseIsValid(); + } + } + if (assetCommodityTypeAllowed > 0) + CommodityType.Add(Sbm.CommodityType.Asset, "AST", "Asset"); + return CommodityType; } - OrgOption_PeriodWeeks.Add(Sbm.OrgOption_PeriodWeeks.ImminentStockDue, "ImminStkDue", "Weeks of due stock to treat as imminent", "Weeks for which stock due is treated as imminent (0-12 weeks, default: 0)"); - return OrgOption_PeriodWeeks; - } - case Sbm.SystemCode.OrgOption_AllowOption: - return new List(orgOption_AllowOptions); - case Sbm.SystemCode.OrgOption_Caption: - { - List OrgOption_Caption = new List(); - if (configConsole != null) + case Sbm.SystemCode.CommodityStatusCat: + return new List(commodityStatusCats); + case Sbm.SystemCode.MovementType: + return new List(movementTypes); + case Sbm.SystemCode.StockLevelType: + return new List(stockLevelTypes); + case Sbm.SystemCode.StockLevelSource: + return new List(stockLevelSources); + case Sbm.SystemCode.AddressType: + return new List(addressTypes); + case Sbm.SystemCode.SysParamCategory: + return new List(sysParamCategories); + case Sbm.SystemCode.ProcessCategory: { - // Transaction type captions. - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.Project)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_Project, "Project", "Transaction type - Project"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesLead)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesLead, "SalLead", "Transaction type - Sales Lead"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesQuote)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesQuote, "SalQuote", "Transaction type - Sales quote"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesPO)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesPO, "SalPO", "Transaction type - Sales PO"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaSalesOrder)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaSalesOrder, "SalPfOrder", "Transaction type - sales proforma order"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesOrder)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesOrder, "SalOrder", "Transaction type - sales order"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesDispatch)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesDispatch, "SalDispatch", "Transaction type - Sales dispatch"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaSalesInvoice)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaSalesInvoice, "SalPfInvoice", "Transaction type - Proforma sales invoice"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesInvoice)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesInvoice, "SalInvoice", "Transaction type - Sales invoice"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseQuote)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseQuote, "PurQuote", "Transaction type - Purchase quote"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseSO)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseSO, "PurSO", "Transaction type - Purchase SO"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaPurchaseOrder)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaPurchaseOrder, "PurPfOrder", "Transaction type - Purchase proforma order"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseOrder)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseOrder, "PurOrder", "Transaction type - Purchase order"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseDelivery)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseDelivery, "PurDelivery", "Transaction type - Purchase Delivery"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaPurchaseInvoice)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaPurchaseInvoice, "PurPfInvoice", "Transaction type - Proforma Purchase invoice"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseInvoice)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseInvoice, "PurInvoice", "Transaction type - Purchase invoice"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.Project)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_Projects, "MnuOptProject", "Caption - Projects menu option"); - // Menu option captions: - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesLead)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesLeads, "MnuOptSalLead", "Caption - Sales leads menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesPO)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesPOs, "MnuOptSalPO", "Caption - Sales POs menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesQuote)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesQuotes, "MnuOptSalQuote", "Caption - Sales quotes menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaSalesOrder)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaSalesOrders, "MnuOptSalPfOrder", "Caption - Proforma sales orders menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesOrder)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesOrders, "MnuOptSalOrder", "Caption - Sales orders menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesDispatch)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesDispatches, "MnuOptSalDispatch", "Caption - Sales dispatches menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaSalesInvoice)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaSalesInvoices, "MnuOptSalPfInvoice", "Caption - Proforma sales invoices menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.SalesInvoice)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesInvoices, "MnuOptSalInvoice", "Caption - Sales invoices menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseQuote)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseQuotes, "MnuOptPurQuote", "Caption - Purchase quotes menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseSO)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseSOs, "MnuOptPurSO", "Caption - Purchase SOs menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaPurchaseOrder)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseOrders, "MnuOptPurPfOrder", "Caption - Proforma purchase orders menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseOrder)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseOrders, "MnuOptPurOrder", "Caption - Purchase orders menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseDelivery)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseDeliveries, "MnuOptPurDelivery", "Caption - Purchase Deliveries menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.ProformaPurchaseInvoice)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseInvoices, "MnuOptPurPfInvoice", "Caption - Proforma purchase invoices menu option"); - if (configConsole.AllowTransactionType(userContext, Sbm.TransactionType.PurchaseInvoice)) - OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseInvoices, "MnuOptPurInvoice", "Caption - Purchase invoices menu option"); + List ProcessCategory = new List(); + if (sessionConsole != null) + { + if (sessionConsole.AllowOption(Sbm.ConfigOption.AllowCommodities)) + ProcessCategory.Add(Sbm.ProcessCategory.Commodity, "CMD", "Commodity"); + if (sessionConsole.AllowOption(Sbm.ConfigOption.AllowAssets)) + ProcessCategory.Add(Sbm.ProcessCategory.Asset, "ASSET", "Asset"); + } + return ProcessCategory; } - return OrgOption_Caption; - } - case Sbm.SystemCode.OrgOption_ShowColumn: - { - List OrgOption_ShowColumn = new List(); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget, "Association:AnnualSalesTarget", "Association: Annual sales target"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised, "Association:Trans:LastSaleRaised", "Association: Last SO raised"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open, "Association:Trans:SalesValue:Open", "Association: SO value: Open"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd, "Association:Trans:SalesValue:Cytd", "Association: SO value: YTD"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy, "Association:Trans:SalesValue:Lcy", "Association: SO value: LCY"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Group, "Association:Group", "Association: Group"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef, "Commodity:CatalogRef", "Commodity: Catalog reference"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_Weight, "Commodity:Weight", "Commodity: Weight"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale, "Commodity:PackQtySale", "Commodity: Pack qty - sale"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_StockAllocated, "Commodity:StockAllocated", "Commodity: Allocated stock"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_StockLevelSales, "Commodity:StockLevelSales", "Commodity: Stock level (Sales)"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_StockAvailable, "Commodity:StockAvailable", "Commodity: Available stock"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Order_AllocationInd, "Order:AllocationInd", "Order: Allocation indicator"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrder_DeliveryCourier, "SalesOrder:DeliveryCourier", "Order: Delivery courier"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice, "SalesOrder:HasInvoice", "Order: Has invoice flag"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Transaction_ContactArea, "Transaction:ContactArea", "Transaction: " + configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Association_ContactAreaCode, "Contact area")); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef, "Accounts:InvoiceRef", "Accounts: Invoice reference"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_AllocationInd, "OrderItem:AllocationInd", "Order item: Allocation indicator"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Current, "OrderItem:StockCurrent", "Order item: Stock current"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Available, "OrderItem:StockAvailable", "Order item: Stock available"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_Stock_BySalesLocation, "OrderItem:StockBySalesLocation", "Order item: Stock by sales location"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyDispatched, "SalesOrderItem:QuantityDispatched", "Sales order item: qty dispatched"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyInvoiced, "SalesOrderItem:QuantityInvoiced", "Sales order item: qty invoiced"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrderItem_NextProcess, "SalesOrderItem:NextProcess", "Sales order item: Next process"); - OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation, "Vehicle:KeyLocation", "Vehicle: Key location"); - return OrgOption_ShowColumn; - } - case Sbm.SystemCode.OrgOption_ShowField: - return new List(orgOption_ShowFields); - case Sbm.SystemCode.OrgOption_FieldLabel: - return new List(orgOption_FieldLabels); - case Sbm.SystemCode.OrgOption_TransactionCreationStatus: - return new List(orgOption_TransactionCreationStatuses); - case Sbm.SystemCode.OrgOption_ContainerStatusCaption: - return new List(orgOption_ContainerStatusCaptions); - case Sbm.SystemCode.OrgOption_NumericDecimals: - return new List(orgOption_NumericDecimals); - case Sbm.SystemCode.OrgOption_CommodityType: - return new List(orgOption_CommodityTypes); - case Sbm.SystemCode.OrgOption_StockLocation: - return new List(orgOption_StockLocations); - case Sbm.SystemCode.OrgOption_TaxCodeColumn: - return new List(orgOption_TaxCodeColumns); - case Sbm.SystemCode.OrgOption_SystemUserRight: - return new List(orgOption_SystemUserRights); - case Sbm.SystemCode.SystemUserOption: - return new List(systemUserOptions); - case Sbm.SystemCode.AssociationOption: - return new List(associationOptions); - case Sbm.SystemCode.InterfaceOption: - return new List(interfaceOptions); - case Sbm.SystemCode.InterfaceOption_WebFlag: - return new List(interfaceOption_WebFlags); - case Sbm.SystemCode.InterfaceOption_WebUploadData: - return new List(interfaceOption_WebUploadDatas); - case Sbm.SystemCode.InterfaceOption_WebUploadMethod: - return new List(interfaceOption_WebUploadMethods); - case Sbm.SystemCode.InterfaceOption_WebDownloadData: - return new List(interfaceOption_WebDownloadDatas); - case Sbm.SystemCode.InterfaceOption_WebDownloadMethod: - return new List(interfaceOption_WebDownloadMethods); - case Sbm.SystemCode.FileInterface_RowColValue: - return new List(fileInterface_RowColValues); - case Sbm.SystemCode.FileInterface_Mode: - return new List(fileInterface_Modes); + case Sbm.SystemCode.ProcessType: + return new List(processTypes); + case Sbm.SystemCode.PaymentType: + return new List(paymentTypes); + case Sbm.SystemCode.AssetIncomeType: + return new List(assetIncomeTypes); + case Sbm.SystemCode.AssetType: + return new List(assetTypes); + case Sbm.SystemCode.VehicleType: + return new List(vehicleTypes); + case Sbm.SystemCode.VehicleEventType: + return new List(vehicleEventTypes); + case Sbm.SystemCode.VehicleFeatureSource: + return new List(vVehicleFeatureSources); + case Sbm.SystemCode.VehicleFeatureType: + return new List(vehicleFeatureTypes); + case Sbm.SystemCode.VehicleOptionType: + return new List(vehicleOptionTypes); + case Sbm.SystemCode.VehicleTransType: + return new List(vehicleTransTypes); + case Sbm.SystemCode.FuelType: + return new List(fuelTypes); + case Sbm.SystemCode.OdometerUnits: + return new List(odometerUnits); + case Sbm.SystemCode.DiscountType: + return new List(discountTypes); + case Sbm.SystemCode.DiscountMarkup: + return new List(discountMarkups); + case Sbm.SystemCode.RegionType: + return new List(regionTypes); + case Sbm.SystemCode.UnitMeasureCategory: + return new List(unitMeasureCategories); + case Sbm.SystemCode.UnitMeasureType: + return new List(unitMeasureTypes); + case Sbm.SystemCode.FinancialType: + { + List FinancialType = new List(); + if (sessionConsole != null) + { + if (sessionConsole.AllowOption(Sbm.ConfigOption.AllowCommodities)) + FinancialType.Add(Sbm.FinancialType.CommoditySupply, "CmdSup", "Commodity supply"); + } + FinancialType.Add(Sbm.FinancialType.CommoditySales, "CmdSal", "Commodity sales"); + return FinancialType; + } + case Sbm.SystemCode.PriceType: + return new List(priceTypes); + case Sbm.SystemCode.PriceCalcMethod: + return new List(priceCalcMethods); + case Sbm.SystemCode.PriceRounderMethod: + return new List(priceRounderMethods); + case Sbm.SystemCode.PriceRounderDirection: + return new List(priceRounderDirections); + case Sbm.SystemCode.SystemAccountType: + return new List(systemAccountTypes); + case Sbm.SystemCode.ItemStatus: + return new List(itemStatuses); + case Sbm.SystemCode.EventStatus: + return new List(eventStatuses); + case Sbm.SystemCode.AssociationTab: + return new List(associationTabs); + case Sbm.SystemCode.InterfaceType_Website: + { + // Interface types - Website. + // Duplicate static list and remove unsupported options. + List codes = new List(interfaceTypes_Website); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.Website, (short)(Sbm.InterfaceType_Website.WebStore))) + interfaceTypes_Website.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_Website.WebStore); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.Website, (short)(Sbm.InterfaceType_Website.JoomlaVirtueMart))) + interfaceTypes_Website.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_Website.JoomlaVirtueMart); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.Website, (short)(Sbm.InterfaceType_Website.MiMoWeb))) + interfaceTypes_Website.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_Website.MiMoWeb); + return new List(codes); + } + case Sbm.SystemCode.InterfaceType_Accounts: + { + // Interface Type - Accounts. + // Duplicate static list and remove unsupported options. + List codes = new List(interfaceTypes_Accounts); + return new List(codes); + } + case Sbm.SystemCode.InterfaceType_System: + { + // Interface Type - System. + // Duplicate static list and remove unsupported options. + List codes = new List(interfaceTypes_System); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.MSOutlook)) + interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.MSOutlook); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.PostcodeAnywhere)) + interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.PostcodeAnywhere); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Bac)) + interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Bac); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Pvh)) + interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Pvh); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Cap)) + interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Cap); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Hpi)) + interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Hpi); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Anchor_OrderFulfilment)) + interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Anchor_OrderFulfilment); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Argos)) + interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Argos); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase)) + interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase); + return new List(codes); + } + case Sbm.SystemCode.InterfaceType_File: + { + // Interface Type - File. + // Duplicate static list and remove unsupported options. + List codes = new List(interfaceTypes_File); + if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_File.LeasewayInvoice)) + codes.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_File.LeasewayInvoice); + return new List(codes); + } + case Sbm.SystemCode.InterfaceDataType: + return new List(interfaceDataTypes); + case Sbm.SystemCode.ItemDataType: + return new List(itemDataTypes); + case Sbm.SystemCode.OrgOption_Value: + return new List(orgOption_Values); + case Sbm.SystemCode.OrgOption_Folder: + return new List(orgOption_Folders); + case Sbm.SystemCode.OrgOption_Minutes: + return new List(OrgOption_Minutes); + case Sbm.SystemCode.OrgOption_PeriodDays: + { + List OrgOption_PeriodDays = new List(); + + OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.TransactionDatesInFuture, "TransDatesInFut", "Days in future that transaction dates can be set", ""); + OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.UpdateClosedTransaction, "UpdClosedTrans", "Grace period (days) for updating closed transactions", "Period after transaction closure during which updates are allowed (0-30 days)"); + if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.AllowDeliveryPlanning)) + OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.UpdateClosedTransaction_DispatchDetails, "UpdDisDetCloTrans", "Grace period (days) for updating dispatch details on closed order", "Period after transaction closure during which dispatch updates are allowed (0-30 days)"); + if (sessionConsole != null && sessionConsole.GetStockControlConfig().AllowStockControl()) + OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.UpdateStockLevelsInPast, "UpdStkLvlInPast", "Update stock levels in past"); + return OrgOption_PeriodDays; + } + case Sbm.SystemCode.OrgOption_PeriodWeeks: + { + List OrgOption_PeriodWeeks = new List(); + if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.TimeRecording)) + { + OrgOption_PeriodWeeks.Add(Sbm.OrgOption_PeriodWeeks.Timesheets, "Timesheets", "Weeks of timesheets to list (default 8)"); + OrgOption_PeriodWeeks.Add(Sbm.OrgOption_PeriodWeeks.UpdateTimeRecords_Control, "UpdTimeRecsCtrl", "Weeks in past for admin user to update time records (default 2)"); + } + OrgOption_PeriodWeeks.Add(Sbm.OrgOption_PeriodWeeks.ImminentStockDue, "ImminStkDue", "Weeks of due stock to treat as imminent", "Weeks for which stock due is treated as imminent (0-12 weeks, default: 0)"); + return OrgOption_PeriodWeeks; + } + case Sbm.SystemCode.OrgOption_AllowOption: + return new List(orgOption_AllowOptions); + case Sbm.SystemCode.OrgOption_Caption: + { + List OrgOption_Caption = new List(); + if (sessionConsole != null) + { + // Transaction type captions. + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.Project)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_Project, "Project", "Transaction type - Project"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesLead)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesLead, "SalLead", "Transaction type - Sales Lead"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesQuote)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesQuote, "SalQuote", "Transaction type - Sales quote"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesPO)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesPO, "SalPO", "Transaction type - Sales PO"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaSalesOrder, "SalPfOrder", "Transaction type - sales proforma order"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesOrder)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesOrder, "SalOrder", "Transaction type - sales order"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesDispatch)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesDispatch, "SalDispatch", "Transaction type - Sales dispatch"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaSalesInvoice, "SalPfInvoice", "Transaction type - Proforma sales invoice"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesInvoice, "SalInvoice", "Transaction type - Sales invoice"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseQuote)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseQuote, "PurQuote", "Transaction type - Purchase quote"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseSO)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseSO, "PurSO", "Transaction type - Purchase SO"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaPurchaseOrder, "PurPfOrder", "Transaction type - Purchase proforma order"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseOrder)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseOrder, "PurOrder", "Transaction type - Purchase order"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseDelivery)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseDelivery, "PurDelivery", "Transaction type - Purchase Delivery"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaPurchaseInvoice, "PurPfInvoice", "Transaction type - Proforma Purchase invoice"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseInvoice)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseInvoice, "PurInvoice", "Transaction type - Purchase invoice"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.Project)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_Projects, "MnuOptProject", "Caption - Projects menu option"); + // Menu option captions: + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesLead)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesLeads, "MnuOptSalLead", "Caption - Sales leads menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesPO)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesPOs, "MnuOptSalPO", "Caption - Sales POs menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesQuote)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesQuotes, "MnuOptSalQuote", "Caption - Sales quotes menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaSalesOrders, "MnuOptSalPfOrder", "Caption - Proforma sales orders menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesOrder)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesOrders, "MnuOptSalOrder", "Caption - Sales orders menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesDispatch)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesDispatches, "MnuOptSalDispatch", "Caption - Sales dispatches menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaSalesInvoices, "MnuOptSalPfInvoice", "Caption - Proforma sales invoices menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesInvoices, "MnuOptSalInvoice", "Caption - Sales invoices menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseQuote)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseQuotes, "MnuOptPurQuote", "Caption - Purchase quotes menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseSO)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseSOs, "MnuOptPurSO", "Caption - Purchase SOs menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseOrders, "MnuOptPurPfOrder", "Caption - Proforma purchase orders menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseOrder)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseOrders, "MnuOptPurOrder", "Caption - Purchase orders menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseDelivery)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseDeliveries, "MnuOptPurDelivery", "Caption - Purchase Deliveries menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseInvoices, "MnuOptPurPfInvoice", "Caption - Proforma purchase invoices menu option"); + if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseInvoice)) + OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseInvoices, "MnuOptPurInvoice", "Caption - Purchase invoices menu option"); + } + return OrgOption_Caption; + } + case Sbm.SystemCode.OrgOption_ShowColumn: + { + List OrgOption_ShowColumn = new List(); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget, "Association:AnnualSalesTarget", "Association: Annual sales target"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised, "Association:Trans:LastSaleRaised", "Association: Last SO raised"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open, "Association:Trans:SalesValue:Open", "Association: SO value: Open"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd, "Association:Trans:SalesValue:Cytd", "Association: SO value: YTD"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy, "Association:Trans:SalesValue:Lcy", "Association: SO value: LCY"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Group, "Association:Group", "Association: Group"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef, "Commodity:CatalogRef", "Commodity: Catalog reference"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_Weight, "Commodity:Weight", "Commodity: Weight"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale, "Commodity:PackQtySale", "Commodity: Pack qty - sale"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_StockAllocated, "Commodity:StockAllocated", "Commodity: Allocated stock"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_StockLevelSales, "Commodity:StockLevelSales", "Commodity: Stock level (Sales)"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_StockAvailable, "Commodity:StockAvailable", "Commodity: Available stock"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Order_AllocationInd, "Order:AllocationInd", "Order: Allocation indicator"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrder_DeliveryCourier, "SalesOrder:DeliveryCourier", "Order: Delivery courier"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice, "SalesOrder:HasInvoice", "Order: Has invoice flag"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Transaction_ContactArea, "Transaction:ContactArea", "Transaction: " + sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, "Contact area")); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef, "Accounts:InvoiceRef", "Accounts: Invoice reference"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_AllocationInd, "OrderItem:AllocationInd", "Order item: Allocation indicator"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Current, "OrderItem:StockCurrent", "Order item: Stock current"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Available, "OrderItem:StockAvailable", "Order item: Stock available"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_Stock_BySalesLocation, "OrderItem:StockBySalesLocation", "Order item: Stock by sales location"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyDispatched, "SalesOrderItem:QuantityDispatched", "Sales order item: qty dispatched"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyInvoiced, "SalesOrderItem:QuantityInvoiced", "Sales order item: qty invoiced"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrderItem_NextProcess, "SalesOrderItem:NextProcess", "Sales order item: Next process"); + OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation, "Vehicle:KeyLocation", "Vehicle: Key location"); + return OrgOption_ShowColumn; + } + case Sbm.SystemCode.OrgOption_ShowField: + return new List(orgOption_ShowFields); + case Sbm.SystemCode.OrgOption_FieldLabel: + return new List(orgOption_FieldLabels); + case Sbm.SystemCode.OrgOption_TransactionCreationStatus: + return new List(orgOption_TransactionCreationStatuses); + case Sbm.SystemCode.OrgOption_ContainerStatusCaption: + return new List(orgOption_ContainerStatusCaptions); + case Sbm.SystemCode.OrgOption_NumericDecimals: + return new List(orgOption_NumericDecimals); + case Sbm.SystemCode.OrgOption_CommodityType: + return new List(orgOption_CommodityTypes); + case Sbm.SystemCode.OrgOption_StockLocation: + return new List(orgOption_StockLocations); + case Sbm.SystemCode.OrgOption_TaxCodeColumn: + return new List(orgOption_TaxCodeColumns); + case Sbm.SystemCode.OrgOption_SystemUserRight: + return new List(orgOption_SystemUserRights); + case Sbm.SystemCode.SystemUserOption: + return new List(systemUserOptions); + case Sbm.SystemCode.AssociationOption: + return new List(associationOptions); + case Sbm.SystemCode.InterfaceOption: + return new List(interfaceOptions); + case Sbm.SystemCode.InterfaceOption_WebFlag: + return new List(interfaceOption_WebFlags); + case Sbm.SystemCode.InterfaceOption_WebUploadData: + return new List(interfaceOption_WebUploadDatas); + case Sbm.SystemCode.InterfaceOption_WebUploadMethod: + return new List(interfaceOption_WebUploadMethods); + case Sbm.SystemCode.InterfaceOption_WebDownloadData: + return new List(interfaceOption_WebDownloadDatas); + case Sbm.SystemCode.InterfaceOption_WebDownloadMethod: + return new List(interfaceOption_WebDownloadMethods); + case Sbm.SystemCode.FileInterface_RowColValue: + return new List(fileInterface_RowColValues); + case Sbm.SystemCode.FileInterface_Mode: + return new List(fileInterface_Modes); + } } return null; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs index aa2f339..6f87c0b 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs @@ -12,6 +12,7 @@ using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; using System.IO; +using static Sarand.Net.Standard.Base.Bus.ItemId; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -206,12 +207,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // I t e m I m p o r t e d F r o m A c c o u n t s //------------------------------------------------------------------- - public void PopulateItemCache(Sbm.ItemType itemType, SysId idItem, bool force = false) + public void PopulateItemCache(ItemId itemId, bool force = false) { - if (force || itemCache.itemType != itemType || itemCache.idItem != idItem) + if (!ItemId.IsValid(itemId)) return; + if (force || (short)itemCache.itemType != itemId.Type || itemCache.idItem != itemId.Id) { - itemCache.itemType = itemType; - itemCache.idItem = idItem; + itemCache.itemType = (Sbm.ItemType)itemId.Type; + itemCache.idItem = itemId.Id; itemCache.importedFromSage = false; itemCache.importedFromQBooks = false; itemCache.exportedFromSage = false; @@ -222,7 +224,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus if (SysId.IsValid(sageParams.InterfaceId) && sageParams.dfnInt_Sage.Active) { // Retrieve interface data item for this item. - List plIntItm = InterfaceConsole.GetInterfaceDataItemsByItem(sageParams.InterfaceId, SaInterfaceProcessDirection.Unknown, new ItemId((short)itemType, idItem)); + List plIntItm = InterfaceConsole.GetInterfaceDataItemsByItem(sageParams.InterfaceId, SaInterfaceProcessDirection.Unknown, itemId); foreach (SaInterfaceDataItem pIntItm in plIntItm) { if (pIntItm.Direction == SaInterfaceProcessDirection.Inbound || pIntItm.Direction == SaInterfaceProcessDirection.Both) itemCache.importedFromSage = true; @@ -233,7 +235,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus if (SysId.IsValid(qbkParams.InterfaceId) && qbkParams.dfnInt_QBooks.Active) { // Retrieve interface data item for this item. - List plIntItm = InterfaceConsole.GetInterfaceDataItemsByItem(qbkParams.InterfaceId, SaInterfaceProcessDirection.Unknown, new ItemId((short)itemType, idItem)); + List plIntItm = InterfaceConsole.GetInterfaceDataItemsByItem(qbkParams.InterfaceId, SaInterfaceProcessDirection.Unknown, itemId); foreach (SaInterfaceDataItem pIntItm in plIntItm) { if (pIntItm.Direction == SaInterfaceProcessDirection.Inbound || pIntItm.Direction == SaInterfaceProcessDirection.Both) itemCache.importedFromQBooks = true; @@ -244,12 +246,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } return; } - public bool ItemIsImportedFromAccounts(Sbm.ItemType itemType, SysId idItem, Sbm.InterfaceType_Accounts accounts = Sbm.InterfaceType_Accounts.Unknown) + public bool ItemIsImportedFromAccounts(ItemId itemId, Sbm.InterfaceType_Accounts accounts = Sbm.InterfaceType_Accounts.Unknown) { - if (itemType == Sbm.ItemType.Unknown || !SysId.IsValid(idItem)) return false; + if (!ItemId.IsValid(itemId)) return false; - PopulateItemCache(itemType, idItem); - if (itemCache.itemType == itemType && itemCache.idItem == idItem) + PopulateItemCache(itemId); + if ((short)itemCache.itemType == itemId.Type && itemCache.idItem == itemId.Id) { switch (accounts) { @@ -264,21 +266,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus return false; } - public bool ItemIsImportedFromSage(Sbm.ItemType itemType, SysId idItem) + public bool ItemIsImportedFromSage(ItemId itemId) { - return ItemIsImportedFromAccounts(itemType, idItem, Sbm.InterfaceType_Accounts.SageLine50); + return ItemIsImportedFromAccounts(itemId, Sbm.InterfaceType_Accounts.SageLine50); } - public bool ItemIsImportedFromQBooks(Sbm.ItemType itemType, SysId idItem) + public bool ItemIsImportedFromQBooks(ItemId itemId) { - return ItemIsImportedFromAccounts(itemType, idItem, Sbm.InterfaceType_Accounts.QuickBooks); + return ItemIsImportedFromAccounts(itemId, Sbm.InterfaceType_Accounts.QuickBooks); } - public bool IsItemExportedToAccounts(Sbm.ItemType itemType, SysId idItem, Sbm.InterfaceType_Accounts accounts = Sbm.InterfaceType_Accounts.Unknown) + public bool IsItemExportedToAccounts(ItemId itemId, Sbm.InterfaceType_Accounts accounts = Sbm.InterfaceType_Accounts.Unknown) { - if (itemType == Sbm.ItemType.Unknown || !SysId.IsValid(idItem)) return false; - PopulateItemCache(itemType, idItem); - if (itemCache.itemType == itemType && itemCache.idItem == idItem) + if (!ItemId.IsValid(itemId)) return false; + PopulateItemCache(itemId); + if ((short)itemCache.itemType == itemId.Type && itemCache.idItem == itemId.Id) { switch (accounts) { @@ -342,7 +344,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public bool IsAssociationTypeManagedByAccounts(Sbm.AssociationType associationType) { - if (associationType == Sbm.AssociationType.Unknown) return false; // Sage Line 50: if (IsUsingSageInterface()) { @@ -358,7 +359,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus #if DEBUG SaLogger.Warn("IsAssociationTypeManagedByAccounts Unsupported Sage association type: " + associationType.ToString()); #endif - break; + return false; } } @@ -377,7 +378,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus #if DEBUG SaLogger.Warn("IsAssociationTypeManagedByAccounts Unsupported QBooks association type: " + associationType.ToString()); #endif - break; + return false; } } return false; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs b/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs index 466738d..c5b6285 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using static Sarand.Net.Standard.Base.Core.StringPair; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -432,6 +433,30 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Utilities. + + // Address display. + public String GetDisplay() + { + return GetDisplay(Line1, Line2, Line3, City, Province, Postcode, Country); + } + public static String GetDisplay(String line1, String line2, String line3, String city, String province, String postcode, String country) + { + List lines = new List() { line1, line2, line3, city, province }; + return StringUtil.TrimWhitespace(lines.Concat(", ", null, null, true, true).ToString() + " " + postcode + " " + country); + } + + // Address summary. + public String GetSummary() + { + return GetSummary(Line1, City, Province, Postcode, Country); + } + public static String GetSummary(String line1, String city, String province, String postcode, String country) + { + List lines = new List() { line1, city, province }; + return StringUtil.TrimWhitespace(lines.Concat(", ", null, null, true, true).ToString() + " " + postcode + " " + country); + } + + // Visit on. public bool IsVisitOn(DateTime visitDate) { if (DateUtil.IsValid(LastVisitOn) && LastVisitOn.CompareTo(visitDate) > 0) return false; @@ -674,8 +699,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Address. public Sbm.AddressType AddressType { get; set; } public ItemId ItemId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs b/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs index 77e62d0..0e61427 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs @@ -51,7 +51,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus Address_Postcode, Address_Country, ProspectGroup, + // Associated data. GroupMembers, + Association_Count, // Common properties. Notes, Flag, @@ -377,7 +379,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } //------------------------------------------------------------------- - // Utilities - affiliate category. + // Utilities. + public ItemId GetItemId() + { + return new ItemId((short)Sbm.ItemType.Affiliate, Id); + } + + // Affiliate category. public static Sbm.AffiliateCategory GetCategory(Sbm.AffiliateType AffiliateType) { if (IsIndividual(AffiliateType)) @@ -388,7 +396,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { return GetCategory(AffiliateType); } - // Utilities - affiliate type. + + // Affiliate type. public bool TypeIsValid() { if (IsIndividual()) return true; @@ -400,19 +409,23 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus if (IsContactGroup()) return true; return false; } - // Utilities - affiliate types' accessor - public static bool IsIndividual(Sbm.AffiliateType AffiliateType) + public static bool IsIndividual(Sbm.AffiliateType affiliateType) { - return AffiliateType == Sbm.AffiliateType.Individual; + return affiliateType == Sbm.AffiliateType.Individual; } public bool IsIndividual() { return IsIndividual(AffiliateType); } + public static bool IsOrganisation(Sbm.AffiliateType affiliateType) + { + return !IsIndividual(affiliateType) & !IsContactGroup(affiliateType); + } public bool IsOrganisation() { - return AffiliateType != Sbm.AffiliateType.Individual & AffiliateType != Sbm.AffiliateType.ContactGroup; + return IsOrganisation(AffiliateType); } + // Specific affiliate types. public bool IsCommercial() { return AffiliateType == Sbm.AffiliateType.Commercial; @@ -433,11 +446,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { return AffiliateType == Sbm.AffiliateType.Charity; } + public static bool IsContactGroup(Sbm.AffiliateType affiliateType) + { + return affiliateType == Sbm.AffiliateType.ContactGroup; + } public bool IsContactGroup() { - return AffiliateType == Sbm.AffiliateType.ContactGroup; + return IsContactGroup(AffiliateType); } - // Utilities - email validation. + + // Email validation. public static bool IsValidEmail(String email) { int count = 0; @@ -748,8 +766,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Affiliate. public Sbm.AffiliateType AffiliateType { get; set; } = Sbm.AffiliateType.Any; public SysId AffiliateIdParent { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs b/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs index 92f3c5f..36d416b 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs @@ -626,8 +626,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Asset. public SysId AssetCatId { get; set; } public String Search { get; set; } @@ -646,8 +646,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { List value = new List(); - if (IncludedIds.Count > 0) value.Add("Assets included", IncludedIds.ToString()); - if (ExcludedIds.Count > 0) value.Add("Assets excluded", ExcludedIds.ToString()); + if (IdsIncluded.Count > 0) value.Add("Assets included", IdsIncluded.ToString()); + if (IdsExcluded.Count > 0) value.Add("Assets excluded", IdsExcluded.ToString()); if (SysId.IsValid(AssetCatId)) value.Add("Asset category Id", AssetCatId.ToString()); if (ItemType > 0) value.Add("Item type", ItemType.ToString()); if (ItemId.IsValid(ItemId)) value.Add("Item Id", ItemId.ToString()); diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs b/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs index 04eb687..caebb33 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs @@ -225,8 +225,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // AssetProcess. public SysId AssetId { get; set; } public SysId ProcessId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs b/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs index 60fd3ee..40790df 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs @@ -103,7 +103,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus Target_DeliveryAddress_Postcode, Target_DeliveryAddress_AccountManagerCode, Target_DeliveryAddress_ContactAreaCode, - // Associated members. [17-NOV-10] + // Associated members. [17-Nov-10] Member_Type, Member_TypeDesc, Member_Code, @@ -142,7 +142,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { public SysId AffiliateIdOwner { get; set; } = new SysId(); public SysId AffiliateIdTarget { get; set; } = new SysId(); - public Sbm.AssociationType AssociationType { get; set; } = Sbm.AssociationType.Unknown; + public Sbm.AssociationType AssociationType { get; set; } public String Code { get; set; } = ""; public String RefExt { get; set; } = ""; public String Location { get; set; } = ""; @@ -543,7 +543,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } //------------------------------------------------------------------- - // Utilities - association type. + // Utilities. + public ItemId GetItemId() + { + return new ItemId((short)Sbm.ItemType.Association, Id); + } + + // Association type. public bool TypeIsValid() { if (AssociationType > 0) return true; @@ -867,10 +873,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Association. - public Sbm.AssociationType AssociationType { get; set; } = Sbm.AssociationType.Any; + public Sbm.AssociationType AssociationType { get; set; } = Sbm.AssociationType.NotInternal; public SysId AffiliateIdOwner { get; set; } public SysId AffiliateIdTarget { get; set; } public SysId AffiliateIdContactGroup { get; set; } @@ -901,12 +907,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public List DeliveryMethodCodes { get; } = new List(); public List DeliveryCourierCodes { get; } = new List(); public List DeliveryBookInCodes { get; } = new List(); - /// Association must have a transaction active at some time between the specified dates (one date can be specified for open ended period). - public SbmTransaction.StatusCat TransactionStatusCat { get; set; } = SbmTransaction.StatusCat.NotDeleted; + // Association must have a transaction of the specified type (optional) active at some time between the specified dates (one date can be specified for open ended period). + /// Transaction status - Value other than 'Any' triggers transaction filter. + public SbmTransaction.StatusCat TransactionStatusCat { get; set; } = SbmTransaction.StatusCat.Any; + /// Has transactions of type. + public Sbm.TransactionType TransactionType { get; set; } = Sbm.TransactionType.Unknown; /// Has transactions active from. - public DateTime TransActiveFrom { get; set; } = DateTime.MinValue; + public DateTime TransactionActiveFrom { get; set; } = DateTime.MinValue; /// Has transactions active up to (inclusive). - public DateTime TransActiveTo { get; set; } = DateTime.MinValue; + public DateTime TransactionActiveTo { get; set; } = DateTime.MinValue; /// Excluded associations that are already a System Account for the specified Interface. public SysId InterfaceIdExcludeSystemAccounts { get; set; } /// Associated codes (via ItemLink) - Seasonal Category. diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs b/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs index c3ba7cb..98c2670 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs @@ -1126,6 +1126,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Utilities. + public ItemId GetItemId() + { + return new ItemId((short)Sbm.ItemType.Commodity, Id); + } + //------------------------------------------------------------------- // Properties. public Data GetData() { return data.Clone(); } @@ -1764,31 +1769,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } //------------------------------------------------------------------- - // A s s o c i a t e d D a t a E l e m e n t s - //------------------------------------------------------------------- - public abstract bool HasProcesses(); - public abstract bool HasRequirements(); - public abstract bool IsSalesBudgetTemplate(); - public abstract bool HasComponents(); - public abstract bool HasPortfolioItems(); - public abstract bool HasContainers(); - public abstract bool HasCustomerDetails(); - public abstract bool HasSupplierDetails(); - public abstract bool HasMovements(); - public abstract bool HasStockLevels(); - // Dependent data should only be cleared when removing a commodity. - // Data owned by this item is deleted (eg. interface data items & document references). - public abstract bool ClearDependentData(); - //--------------------------------------------------------------- - // Commodity cost estimates. - public abstract List GetCostEstimates(); - public abstract bool SetCostEstimates(List costEstimatesNew); - public abstract bool CommitCostEstimates(); - //--------------------------------------------------------------- - // Commodity processes. - public abstract List GetProcesses(bool bActiveOnly = false); - public abstract bool SetProcesses(List itemProcessesNew); - public abstract bool CommitProcesses(); + // Associated data. + public List CostEstimates { get; set; } + public List ItemProcesses { get; set; } //------------------------------------------------------------------- // P a r a m s @@ -1804,8 +1787,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // Commodity Ids. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Commodity. public Sbm.CommodityType CommodityType { get; set; } public bool StockItemsOnly { get; set; } = false; @@ -1879,11 +1862,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { SbmAccountMgr accountMgr = null; List lValue = new List(); - using (SbmConfigConsole configConsole = SbmGlobals.Application.CreateConfigConsole(userContext.SessionContext)) + using (SbmSessionConsole sessionConsole = SbmGlobals.Application.CreateSessionConsole(userContext)) { // Commodities to exclude. - if (IncludedIds.Count > 0) lValue.Add("Included commodities", IncludedIds.Count.ToString()); - if (ExcludedIds.Count > 0) lValue.Add("Excluded commodities", ExcludedIds.Count.ToString()); + if (IdsIncluded.Count > 0) lValue.Add("Included commodities", IdsIncluded.Count.ToString()); + if (IdsExcluded.Count > 0) lValue.Add("Excluded commodities", IdsExcluded.Count.ToString()); // Commodity type. if (CommodityType > 0) lValue.Add("Type", SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.CommodityType).GetDescForType(CommodityType, CommodityType.ToString())); else if (CommodityType == Sbm.CommodityType.AnyProduct) lValue.Add("Type", "Any product"); @@ -1910,9 +1893,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus if (!StringUtil.IsEmpty(SupplyMethodCode)) lValue.Add("SupplyMethod code", SupplyMethodCode); if (!StringUtil.IsEmpty(HandlingCode)) lValue.Add("Handling code", HandlingCode); if (!StringUtil.IsEmpty(DeliveryCode)) lValue.Add("Delivery code", DeliveryCode); - if (!StringUtil.IsEmpty(MaterialCode)) lValue.Add(configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material") + " code", MaterialCode); - if (!StringUtil.IsEmpty(FinishCode)) lValue.Add(configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish") + " code", FinishCode); - if (!StringUtil.IsEmpty(PromotionCode)) lValue.Add(configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion") + " code", PromotionCode); + if (!StringUtil.IsEmpty(MaterialCode)) lValue.Add(sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material") + " code", MaterialCode); + if (!StringUtil.IsEmpty(FinishCode)) lValue.Add(sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish") + " code", FinishCode); + if (!StringUtil.IsEmpty(PromotionCode)) lValue.Add(sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion") + " code", PromotionCode); // Price sets. if (PriceSetIdsIncluded.Count > 0) lValue.Add("Included in price sets", PriceSetIdsIncluded.Count.ToString()); if (PriceSetIdsExcluded.Count > 0) lValue.Add("Excluded from price sets", PriceSetIdsExcluded.Count.ToString()); diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs b/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs index 4009468..214445e 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs @@ -230,8 +230,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // CommodityCustomer. public SysId CommodityId { get; set; } public SysId AssocIdCustomer { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs b/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs index de480d3..ed70b12 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs @@ -220,8 +220,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // CommoditySupplier. public SysId CommodityId { get; set; } public SysId AssocIdSupplier { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs b/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs index 1054e09..0814d6b 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs @@ -660,8 +660,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Constituent. public Sbm.ConstituentType ConstituentType { get; set; } = Sbm.ConstituentType.Any; public SysId AffIdTarget { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs b/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs index ce41f83..ccde9bb 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs @@ -287,8 +287,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public Params() { } public Params(SbmContainerItem.Params prmContainerItem) { - IncludedIds = prmContainerItem.IncludedIds; - ExcludedIds = prmContainerItem.ExcludedIds; + IdsIncluded = prmContainerItem.IdsIncluded; + IdsExcluded = prmContainerItem.IdsExcluded; ContainerCategory = prmContainerItem.ContainerCategory; ContainerType = prmContainerItem.ContainerType; Reference = prmContainerItem.ContainerReference; @@ -302,8 +302,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus HasItems = prmContainerItem.ContainerHasItems; } // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Container. //public SysId AffiliateIdOwner { get; set; } public Sbm.ContainerCategory ContainerCategory { get; set; } = Sbm.ContainerCategory.Any; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs b/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs index 27792cf..05ad8d4 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs @@ -273,8 +273,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // Item Ids. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Item properties. public SysId ContainerId { get; set; } public short ItemSeq { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs b/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs index 896761a..9b09881 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs @@ -442,10 +442,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } //------------------------------------------------------------------- - public static void SetCommodityCosts(this List values, ISbmUserContext_Core userContext, SbmCommodity commodity, decimal quantity) + public static void SetCommodityCosts(this List values, ISbmUserContext_Core userContext, SbmInternals internals, SbmCommodity commodity, decimal quantity) { // Retrieve costs from commodity and remove unwanted costs (for other quantities). - List costEstimatesCommodity = commodity.GetCostEstimates(); + List costEstimatesCommodity = internals.CommodityMgr.GetCommodityCostEstimates(commodity); costEstimatesCommodity.ConsolidateByQuantity(quantity); // If there are cost estimates remaining, replace the contents of this list. diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs index 742832e..06a15d0 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs @@ -222,8 +222,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // ItemBatch. public Sbm.ItemBatchType ItemBatchType { get; set; } public String Ref { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs index 5731383..efc6d48 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs @@ -366,8 +366,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // ItemLink. public Sbm.ItemLinkType ItemLinkType { get; set; } public Sbm.ItemType ItemTypeFrom { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs index ef85501..04b3a52 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs @@ -349,8 +349,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // ItemProcess. public Sbm.ItemType ItemType { get; set; } public SysId ItemId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs b/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs index e06cbeb..466d068 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs @@ -221,8 +221,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Location. public SysId AffiliateIdOwner { get; set; } public Sbm.LocationCategory LocationCategory { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs b/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs index 03c1d63..d3cd1bb 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs @@ -305,8 +305,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Movement. public Sbm.ItemType ItemType { get; set; } public Sbm.ItemType ItemTypeSource { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs b/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs index c87a54e..2540f31 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs @@ -329,8 +329,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Hierarchy. public SysId ParentItemId { get; set; } public SysId AncestorItemId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs b/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs index 0bbafc2..6ee401a 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs @@ -231,8 +231,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // Item Ids. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Item properties. public Sbm.PriceType PriceType { get; set; } public String Reference { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs b/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs index 516d37f..e90cc03 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs @@ -284,8 +284,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Process. public Sbm.ProcessCategory ProcessCategory { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs b/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs index f8241f6..30a574d 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs @@ -1221,55 +1221,52 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus /// public new class Params : SacsHierarchyItem.Params { - /* List filtering. ~ due to have their own Trans&Reqnt List - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List();*/ // Data members - requirements always restricted to current owner. /* General details*/ public SysId AssociationId { get; set; } public SysId CommodityId { get; set; } public SysId AssetId { get; set; } // Requirement. - public List ReqntIncludedIds { get; } = new List(); - public List ReqntExcludedIds { get; } = new List(); - public List ReqntIdsSource { get; } = new List(); - public String ReqntProductCodeFull { get; set; } - public String ReqntProductCodePartial { get; set; } + public List RequirementIdsIncluded { get; } = new List(); + public List RequirementIdsExcluded { get; } = new List(); + public List RequirementIdsSource { get; } = new List(); + public String RequirementProductCodeFull { get; set; } + public String RequirementProductCodePartial { get; set; } // Stored as product code for 'Project' transactions (populating this value will force the transaction type). - public String ReqntProjectTaskCodeFull { get; set; } - public String ReqntProjectTaskCodePartial { get; set; } - public String ReqntJobNumberFull { get; set; } - public String ReqntJobNumberPartial { get; set; } - public String ReqntAssetSerialFull { get; set; } - public String ReqntAssetSerialPartial { get; set; } - public String ReqntDescBrief { get; set; } - public String ReqntPromotionCode { get; set; } + public String RequirementProjectTaskCodeFull { get; set; } + public String RequirementProjectTaskCodePartial { get; set; } + public String RequirementJobNumberFull { get; set; } + public String RequirementJobNumberPartial { get; set; } + public String RequirementAssetSerialFull { get; set; } + public String RequirementAssetSerialPartial { get; set; } + public String RequirementDescBrief { get; set; } + public String RequirementPromotionCode { get; set; } // Transaction. public String AliasTransaction { get; set; } - public List TransIncludedIds { get; } = new List(); - public List TransExcludedIds { get; } = new List(); - public SysId TransReqntSourceId { get; set; } // Identifies the transaction to which the source requirement belongs. + public List TransactionIdsIncluded { get; } = new List(); + public List TransactionIdsExcluded { get; } = new List(); + public SysId TransactionRequirementSourceId { get; set; } // Identifies the transaction to which the source requirement belongs. public Sbm.TransactionType TransactionType { get; set; } = Sbm.TransactionType.Any; - public SysId TransLocationIdStock { get; set; } + public SysId TransactionLocationIdStock { get; set; } public SbmTransaction.StatusCat TransactionStatusCat { get; set; } = SbmTransaction.StatusCat.NotDeleted; - public String TransRefPartial { get; set; } - public String TransRefExtPartial { get; set; } - public String TransDescBriefPartial { get; set; } - public String AssocPartial { get; set; } + public String TransactionRefPartial { get; set; } + public String TransactionRefExtPartial { get; set; } + public String TransactionDescBriefPartial { get; set; } + public String AssociationPartial { get; set; } public String AccountManagerCode { get; set; } public String AccountHandlerCode { get; set; } - public DateTime TransRaisedFrom { get; set; } - public DateTime TransRaisedTo { get; set; } - public DateTime TransRequiredFrom { get; set; } - public DateTime TransRequiredTo { get; set; } - public decimal TransAmountNetLt { get; set; } = Decimal.MinValue; - public decimal TransAmountNetGt { get; set; } = Decimal.MinValue; + public DateTime TransactionRaisedFrom { get; set; } + public DateTime TransactionRaisedTo { get; set; } + public DateTime TransactionRequiredFrom { get; set; } + public DateTime TransactionRequiredTo { get; set; } + public decimal TransactionAmountNetLt { get; set; } = Decimal.MinValue; + public decimal TransactionAmountNetGt { get; set; } = Decimal.MinValue; // Active period. // Active on specific date. [Date period below ignored if this date is valid] - public DateTime TransActiveOn { get; set; } + public DateTime TransactionActiveOn { get; set; } // Active during the period, or at any time from or to the specified date if only one is valid. - public DateTime TransActiveFrom { get; set; } - public DateTime TransActiveTo { get; set; } + public DateTime TransactionActiveFrom { get; set; } + public DateTime TransactionActiveTo { get; set; } // True (default) = Active at any time during period, False = Active throughout period. [Used when complete date range specified] public DateTime ActiveAnyDayDuringPeriod { get; set; } // Commodity against associated items. @@ -1280,8 +1277,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public SysId SalesLocationIdStock02 { get; set; } public SysId SalesLocationIdStock03; // Required date. - public DateTime ReqntRequiredFrom { get; set; } - public DateTime ReqntRequiredTo { get; set; } + public DateTime RequirementRequiredFrom { get; set; } + public DateTime RequirementRequiredTo { get; set; } public String CmdMaterialCode { get; set; } public String CmdFinishCode { get; set; } // Common properties. diff --git a/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs b/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs index eaa5734..8edaf92 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs @@ -279,8 +279,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // StockLevel. public SysId CommodityId { get; set; } public SysId LocationId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs b/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs index 9340d21..0347293 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs @@ -229,8 +229,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // SysParam. public Sbm.SysParamCategory Category { get; set; } = Sbm.SysParamCategory.Any; public String Name { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs index 6cccef7..18f673a 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs @@ -245,8 +245,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // SystemAccount. public Sbm.SystemAccountType Type { get; set; } = Sbm.SystemAccountType.Customer; public SysId InterfaceId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs index f8eed2a..80425db 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs @@ -173,8 +173,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // SystemAccountUser. public SysId InterfaceId { get; set; } public SysId AccountId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs b/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs index 1b20af2..526b835 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs @@ -219,8 +219,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // User. public SysId AffIdOwner { get; set; } public SysId InterfaceId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs b/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs index 548c8cd..ea1dafd 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs @@ -9,8 +9,8 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { - //======================================================================= - public abstract class SbmTransaction : SbmHierarchyItem + //======================================================================= + public abstract class SbmTransaction : SbmHierarchyItem { //------------------------------------------------------------------- // Columns. @@ -859,9 +859,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus // Nov-08 Current thinking is that the only differences is whether the 'In Progress' date has been specified and whether that should be used in preference to the 'Raised' date. if (DateUtil.IsValid(inProgress) && (transactionStatusCat == SbmTransaction.StatusCat.Open || transactionStatusCat == SbmTransaction.StatusCat.Closed)) { - using (SbmConfigConsole configConsole = SbmGlobals.Application.CreateConfigConsole(userContext.SessionContext)) + using (SbmSessionConsole sessionConsole = SbmGlobals.Application.CreateSessionConsole(userContext)) { - if (configConsole != null && configConsole.UseInProgressTaxDateAsTaxPoint(userContext, transactionType)) + if (sessionConsole != null && sessionConsole.UseInProgressTaxDateAsTaxPoint(transactionType)) return inProgress; } } @@ -1646,8 +1646,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; set; } = new List(); - public List ExcludedIds { get; set; } = new List(); + public List IdsIncluded { get; set; } = new List(); + public List IdsExcluded { get; set; } = new List(); // Transaction. public SysId AssocId { get; set; } public SysId TransIdSource { get; set; } @@ -1721,7 +1721,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus // Test each 'significant' element of the filter and return 'false' if any of the values are set. // NB Elements without a test in the list below are not regarded as 'significant'. if (ForceFullResults) return false; - if (IncludedIds.Count > 0) return false; + if (IdsIncluded.Count > 0) return false; if (SysId.IsValid(TransIdSource)) return false; if (StatusCat == StatusCat.Pending || StatusCat == StatusCat.Open) return false; if (!StringUtil.IsEmpty(AssocPartial)) return false; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs index 5a638df..987e65f 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs @@ -567,8 +567,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // Vehicle. public SysId VehicleClassId { get; set; } public SysId AssetCatIdInclude { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs index fb6b49e..beb95dc 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs @@ -317,8 +317,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // VehicleEvent. public SysId VehicleId { get; set; } public Sbm.VehicleEventType VehicleEventType { get; set; } = Sbm.VehicleEventType.Any; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs index e6af2ae..16a6ed0 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs @@ -300,8 +300,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IncludedIds { get; } = new List(); - public List ExcludedIds { get; } = new List(); + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); // VehicleFeature. public SysId VehicleId { get; set; } public Sbm.VehicleFeatureSource VehicleFeatureSource { get; set; } = Sbm.VehicleFeatureSource.Any; diff --git a/SaBusMgrStandardBase/Base/Consoles/SbmConfigConsole.cs b/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs similarity index 75% rename from SaBusMgrStandardBase/Base/Consoles/SbmConfigConsole.cs rename to SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs index 60019d5..7e3f931 100644 --- a/SaBusMgrStandardBase/Base/Consoles/SbmConfigConsole.cs +++ b/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs @@ -16,7 +16,10 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles { //======================================================================= - public class SbmConfigConsole : SacsDisposable + /// + /// Application configuration associated with a specific session. + /// + public class SbmSessionConsole : SacsDisposable { //------------------------------------------------------------------- // Interface definition. @@ -26,11 +29,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles { } public SysId InterfaceId { get; } = new SysId(); - public String Context { get; } = ""; + public string Context { get; } = ""; public SaInterfaceCategory InterfaceCategory { get; } = SaInterfaceCategory.Unknown; public short InterfaceType { get; } - public String Code { get; } = ""; - public String Caption { get; } = ""; + public string Code { get; } = ""; + public string Caption { get; } = ""; public bool Active { get; } } // Sage/Quickbooks interface definition. @@ -68,6 +71,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Data members. private List transactionTypes_Full = new List(); + private SbmInstanceConfig instanceConfig; private SbmAccountsDfn accountsDfn; private AccountsInterfaceDfn dfnSageInt = new AccountsInterfaceDfn(); private AccountsInterfaceDfn dfnQBooksInt = new AccountsInterfaceDfn(); @@ -76,12 +80,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Construction. - protected SbmConfigConsole(Sbm.ConfigConsole configConsole, SbmVersion consoleVersion, SbmSessionContext sessionContext) + protected SbmSessionConsole(Sbm.SessionConfig sessionConfig, SbmVersion consoleVersion, ISbmUserContext_Core userContext) { - ConfigConsole = configConsole; - AppVersion = new SbmVersion("BusinessMgr", Sbm.Version.GetFullVersion(), SbmSystem.AssemblyBuildAt); - ConsoleVersion = consoleVersion; - SessionContext = sessionContext; + this.SessionConfig = sessionConfig; + this.AppVersion = new SbmVersion("BusinessMgr", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt); + this.ConsoleVersion = consoleVersion; + this.UserContext = userContext; } protected override void Dispose(bool disposing) { @@ -92,20 +96,22 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Properties. - public Sbm.ConfigConsole ConfigConsole { get; } - public SbmSessionContext SessionContext { get; } + public Sbm.SessionConfig SessionConfig { get; } + public ISbmUserContext_Core UserContext { get; } + public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } public SbmVersion AppVersion { get; } public SbmVersion ConsoleVersion { get; } + public SbmInstanceConfig InstanceConfig { get { if (instanceConfig == null) instanceConfig = SbmGlobals.Application.GetInstanceConfig(SessionContext); return instanceConfig; } } //------------------------------------------------------------------- // C r e a t e C o n s o l e //------------------------------------------------------------------- - public static SbmConfigConsole CreateConsole(SbmSessionContext sessionContext) + public static SbmSessionConsole CreateConsole(ISbmUserContext_Core userContext) { SaLogger.Warn($"{SysUtil.Fn} Creating default configuration console."); // Default console. - SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version.GetFullVersion(), SbmSystem.AssemblyBuildAt); - return new SbmConfigConsole(Sbm.ConfigConsole.Generic, consoleVersion, sessionContext); + SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt); + return new SbmSessionConsole(Sbm.SessionConfig.Generic, consoleVersion, userContext); } //------------------------------------------------------------------- @@ -115,7 +121,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // A p p l i c a t i o n //------------------------------------------------------------------- // Application Customisation. - public virtual String GetApplicationCaption(Sbm.CaptionType captionType) + public virtual string GetApplicationCaption(Sbm.CaptionType captionType) { return "BusinessMgr"; } @@ -127,7 +133,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles return new List(); } - public virtual bool DoAdditionalMenuOption(Sbm.MenuSection menuSection, String str) + public virtual bool DoAdditionalMenuOption(Sbm.MenuSection menuSection, string str) { return false; } @@ -145,13 +151,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Application Configuration. - AllowOption. - public virtual bool AllowOption(ISbmUserContext_Core userContext, Sbm.ConfigOption option) + public virtual bool AllowOption(Sbm.ConfigOption option) { switch (option) { // Application. case Sbm.ConfigOption.SystemMenu: - return SacsSystem.DebugMode; + return InstanceConfig.AllowApplicationOption(option, SacsSystem.DebugMode); case Sbm.ConfigOption.AllowConsoleView: case Sbm.ConfigOption.AllowOrganisationUpdate: case Sbm.ConfigOption.AllowContacts: @@ -160,26 +166,31 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles case Sbm.ConfigOption.AllowTransactions: case Sbm.ConfigOption.DiaryView: case Sbm.ConfigOption.AllowRequirementUpdateInline: - return true; + return InstanceConfig.AllowApplicationOption(option, true); // Commodities. case Sbm.ConfigOption.CommodityPartialCodeFilter: - //return true; - return userContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter); + if (InstanceConfig.AllowApplicationOption(option, false)) + return true; + return UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter); // Order Pricing. case Sbm.ConfigOption.CustomerPriceSet: case Sbm.ConfigOption.CustomerDiscount: { - if (accountsDfn == null) accountsDfn = new SbmAccountsDfn(userContext); + if (InstanceConfig.AllowApplicationOption(option, false)) + return true; + if (accountsDfn == null) accountsDfn = new SbmAccountsDfn(UserContext); return accountsDfn.IsUsingSageInterface() && accountsDfn.IsAssociationTypeManagedByAccounts(Sbm.AssociationType.Customer) && !accountsDfn.UseLocalCustomerPricing(); } case Sbm.ConfigOption.SupplierPriceSet: case Sbm.ConfigOption.SupplierDiscount: { + if (InstanceConfig.AllowApplicationOption(option, false)) + return true; SbmAccountsDfn account = null; return account.IsUsingSageInterface() && account.IsAssociationTypeManagedByAccounts(Sbm.AssociationType.Supplier) && !account.UseLocalSupplierPricing(); } } - return false; + return InstanceConfig.AllowApplicationOption(option, false); } //------------------------------------------------------------------- @@ -357,17 +368,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Supported Data Item Types. // Supported affiliate types (all allowed by default). - public virtual bool AllowAffiliateType(ISbmUserContext_Core userContext, Sbm.AffiliateType type) + public virtual bool AllowAffiliateType(Sbm.AffiliateType type) { - return true; + return InstanceConfig.AllowAffiliateType(type, true); } // Supported Association types (all allowed by default). - public virtual bool AllowAssociationType(ISbmUserContext_Core userContext, Sbm.AssociationType type) + public virtual bool AllowAssociationType(Sbm.AssociationType type) { - return true; + return InstanceConfig.AllowAssociationType(type, true); } // Supported Transaction types. - public virtual bool AllowTransactionType(ISbmUserContext_Core userContext, Sbm.TransactionType type) + public virtual bool AllowTransactionType(Sbm.TransactionType type) { switch (type) { @@ -375,15 +386,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles case Sbm.TransactionType.SalesQuote: case Sbm.TransactionType.SalesOrder: //case Sbm.TransactionType.PurchaseOrder: - return true; + return InstanceConfig.AllowTransactionType(type, true); // Proforma types are only allowed if ther counterparts cannot be created. case Sbm.TransactionType.ProformaPurchaseOrder: - return (AllowTransactionType(userContext, Sbm.TransactionType.PurchaseOrder) && !CanCreateTransactionLocally(userContext, Sbm.TransactionType.PurchaseOrder)); + return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.PurchaseOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.PurchaseOrder)); case Sbm.TransactionType.ProformaSalesOrder: - return (AllowTransactionType(userContext, Sbm.TransactionType.SalesOrder) && !CanCreateTransactionLocally(userContext, Sbm.TransactionType.SalesOrder)); + return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesOrder)); case Sbm.TransactionType.ProformaSalesInvoice: - return (AllowTransactionType(userContext, Sbm.TransactionType.SalesInvoice) && !CanCreateTransactionLocally(userContext, Sbm.TransactionType.SalesInvoice)); + return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesInvoice) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesInvoice)); } return false; } @@ -392,27 +403,27 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // D a t a O p t i o n s //------------------------------------------------------------------- // Application Configuration. - Display and caption for data attributes. - public virtual bool DisplayAttribute(ISbmUserContext_Core userContext, SbmDbDfn.ColumnIdx column) + public virtual bool DisplayAttribute(SbmDbDfn.ColumnIdx column) { switch (column) { // Fields that are tied to other columns for the purposes of controlling their display. case SbmDbDfn.ColumnIdx.Commodity_UomIdWeight: - return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Weight); + return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Weight); case SbmDbDfn.ColumnIdx.Commodity_UomIdLength: - return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Length); + return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Length); case SbmDbDfn.ColumnIdx.Commodity_UomIdVolume: - return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Volume); + return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Volume); case SbmDbDfn.ColumnIdx.Commodity_UomIdDensity: - return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Density); + return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Density); case SbmDbDfn.ColumnIdx.Commodity_UomIdBox: - return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity); + return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity); case SbmDbDfn.ColumnIdx.Commodity_UomIdTimeProd: - return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_TimeProd); + return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_TimeProd); case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial: - return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_MaterialCost); + return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_MaterialCost); case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks: - return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost); + return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost); case SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonthlyProp: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01: @@ -427,23 +438,23 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth10: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12: - return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual); + return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual); default: // Sep-08: Session profile should be able to handle all fields now (rather than just those that are controlled) - return userContext.GetOwnerOption_ShowField(column); + return UserContext.GetOwnerOption_ShowField(column); } //return true; } //------------------------------------------------------------------- // Alternative data value captions. - public virtual String GetAttributeCaption(ISbmUserContext_Core userContext, SbmDbDfn.ColumnIdx column, string Default) + public virtual string GetAttributeCaption(SbmDbDfn.ColumnIdx column, string Default) { - String Caption = ""; + string Caption = ""; if (column != SbmDbDfn.ColumnIdx.Unknown) { - Caption = userContext.GetOwnerOption_FieldLabel(column, Default); + Caption = UserContext.GetOwnerOption_FieldLabel(column, Default); } - if (StringUtil.IsEmpty(Caption)) Caption = Default; + if (Caption.IsEmpty()) Caption = Default; return Caption; } @@ -451,7 +462,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // T r a n s a c t i o n O p t i o n s //------------------------------------------------------------------- // Job Tracking Options. - public virtual String GetDefaultQuoteDescIntro(ISbmUserContext_Core userContext) + public virtual string GetDefaultQuoteDescIntro() { return ""; } @@ -471,19 +482,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Create Transaction. - public virtual bool CanCreateTransactionLocally(ISbmUserContext_Core userContext, Sbm.TransactionType type) + public virtual bool CanCreateTransactionLocally(Sbm.TransactionType type) { - if (!AllowTransactionType(userContext, type)) return false; + if (!AllowTransactionType(type)) return false; // Refresh options. - if (dfnSageInt.AffiliateId_Owner != userContext.OrganisationAffiliateId || dfnQBooksInt.AffiliateId_Owner != userContext.OrganisationAffiliateId) + if (dfnSageInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId || dfnQBooksInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId) { // Reset the accounts interface configurations. dfnSageInt.ClearConfig(); - dfnSageInt.AffiliateId_Owner = userContext.OrganisationAffiliateId; + dfnSageInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId; dfnQBooksInt.ClearConfig(); - dfnQBooksInt.AffiliateId_Owner = userContext.OrganisationAffiliateId; + dfnQBooksInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId; // Identify the interfaces. - SbmAccountsDfn accountsDfn = new SbmAccountsDfn(userContext); + SbmAccountsDfn accountsDfn = new SbmAccountsDfn(UserContext); dfnSageInt.InterfaceId = accountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.SageLine50); dfnQBooksInt.InterfaceId = accountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.QuickBooks); @@ -523,12 +534,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles createTransaction_SalesQuote = true; createTransaction_SalesOrder = true; createTrans_SalesInvoice = true; - if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = (!dfnSageInt.importPurchaseOrder && !dfnSageInt.exportPurchaseOrder); - if (createTransaction_SalesOrder) createTransaction_SalesOrder = (!dfnSageInt.importSalesOrder && !dfnSageInt.exportSalesOrder); - if (createTrans_SalesInvoice) createTrans_SalesInvoice = (!dfnSageInt.importProductInvoice && !dfnSageInt.exportProductInvoice && !dfnSageInt.importServiceInvoice && !dfnSageInt.exportServiceInvoice && !dfnSageInt.importSalesOrderInvoice && !dfnSageInt.bexport_SalesOrderInvoice); - if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = (!dfnQBooksInt.importPurchaseOrder && !dfnQBooksInt.exportPurchaseOrder); - if (createTransaction_SalesOrder) createTransaction_SalesOrder = (!dfnQBooksInt.importSalesOrder && !dfnQBooksInt.exportSalesOrder); - if (createTrans_SalesInvoice) createTrans_SalesInvoice = (!dfnQBooksInt.importProductInvoice && !dfnQBooksInt.exportProductInvoice && !dfnQBooksInt.importServiceInvoice && !dfnQBooksInt.exportServiceInvoice && !dfnQBooksInt.importSalesOrderInvoice && !dfnQBooksInt.bexport_SalesOrderInvoice); + if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = !dfnSageInt.importPurchaseOrder && !dfnSageInt.exportPurchaseOrder; + if (createTransaction_SalesOrder) createTransaction_SalesOrder = !dfnSageInt.importSalesOrder && !dfnSageInt.exportSalesOrder; + if (createTrans_SalesInvoice) createTrans_SalesInvoice = !dfnSageInt.importProductInvoice && !dfnSageInt.exportProductInvoice && !dfnSageInt.importServiceInvoice && !dfnSageInt.exportServiceInvoice && !dfnSageInt.importSalesOrderInvoice && !dfnSageInt.bexport_SalesOrderInvoice; + if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = !dfnQBooksInt.importPurchaseOrder && !dfnQBooksInt.exportPurchaseOrder; + if (createTransaction_SalesOrder) createTransaction_SalesOrder = !dfnQBooksInt.importSalesOrder && !dfnQBooksInt.exportSalesOrder; + if (createTrans_SalesInvoice) createTrans_SalesInvoice = !dfnQBooksInt.importProductInvoice && !dfnQBooksInt.exportProductInvoice && !dfnQBooksInt.importServiceInvoice && !dfnQBooksInt.exportServiceInvoice && !dfnQBooksInt.importSalesOrderInvoice && !dfnQBooksInt.bexport_SalesOrderInvoice; // Sales quotes are also imported from Sage Sales Orders. createTransaction_SalesQuote = createTransaction_SalesOrder; @@ -553,7 +564,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles { System, Manual, Option } - public virtual AssignTransRefMethod TransactionAssignRefMethod(ISbmUserContext_Core userContext, Sbm.TransactionType transTypes) + public virtual AssignTransRefMethod TransactionAssignRefMethod(Sbm.TransactionType transTypes) { return AssignTransRefMethod.System; } @@ -561,28 +572,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles { ByOwnerType, ByType } - public virtual AssignTransRefSource TransactionAssignRefSource(ISbmUserContext_Core userContext, Sbm.TransactionType transTypes) + public virtual AssignTransRefSource TransactionAssignRefSource(Sbm.TransactionType transTypes) { return AssignTransRefSource.ByOwnerType; } // By default all types of transaction have their own Id sequence. // Override this method to allow different types of transaction to share Id sequence. - public virtual Sbm.TransactionType GetTransactionTypeForNextId(ISbmUserContext_Core userContext, Sbm.TransactionType transTypes) + public virtual Sbm.TransactionType GetTransactionTypeForNextId(Sbm.TransactionType transTypes) { return transTypes; } // NextId key value. - public virtual String GetTransactionNextIdKey(ISbmUserContext_Core userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType eType) + public virtual string GetTransactionNextIdKey(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType eType) { idAssoc = new SysId(); - Sbm.TransactionType transTypes = GetTransactionTypeForNextId(userContext, eType); - switch (TransactionAssignRefSource(userContext, eType)) + Sbm.TransactionType transTypes = GetTransactionTypeForNextId(eType); + switch (TransactionAssignRefSource(eType)) { case AssignTransRefSource.ByOwnerType: // Next Id depends on both the transaction type and owner. - return (String)"TransRef:" + transTypes.ToString() + ":" + AffiliateId_Owner.ToString(); + return "TransRef:" + transTypes.ToString() + ":" + AffiliateId_Owner.ToString(); default: // Next Id only depends on the transaction type. return "TransRef:" + transTypes.ToString(); @@ -590,12 +601,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles } // Set the minimum Id for transactions of the specified type. - public virtual bool SetMinTransactionId(ISbmUserContext_Core userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long iId) + public virtual bool SetMinTransactionId(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long iId) { bool set = false; if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null) { - String nextIdKey = GetTransactionNextIdKey(userContext, AffiliateId_Owner, idAssoc, transTypes); + string nextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes); // ToDo set = SbmGlobals.Database.SetMinNextId(nextIdKey, iId, false); } return set; @@ -603,61 +614,61 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // The implementation in this class will generate simple numeric values for the owner // and global options that can be formatted (eg. to fixed length) by overwridden versions. - public virtual String GetTransactionCreateRef - (ISbmUserContext_Core userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes) + public virtual string GetTransactionCreateRef + (SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes) { - String Ref = ""; + string Ref = ""; if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null) { - String NextIdKey = GetTransactionNextIdKey(userContext, AffiliateId_Owner, idAssoc, transTypes); + string NextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes); // ToDo long iRefNext = SbmGlobals.Database.GetNextId(NextIdKey, false); // Ref = FormatTransactionCreateRef(AffiliateId_Owner, idAssoc, transTypes, iRefNext); } return Ref; } - public virtual String FormatTransactionCreateRef - (ISbmUserContext_Core userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long RefInt) + public virtual string FormatTransactionCreateRef + (SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long RefInt) { - String Ref = ""; + string Ref = ""; if (RefInt > 0) { // Retrieve and validate the sequence padding length. - int SeqLen = Math.Max(1, Math.Min(8, GetTransactionRefSeqLength(userContext, AffiliateId_Owner, idAssoc, transTypes))); + int SeqLen = Math.Max(1, Math.Min(8, GetTransactionRefSeqLength(AffiliateId_Owner, idAssoc, transTypes))); // Pad the sequence number. //Ref = String(RefInt, SeqLen); // Add the reference prefix (max 5 chars) - String prefix = GetTransactionRefPrefix(AffiliateId_Owner, idAssoc, transTypes); + string prefix = GetTransactionRefPrefix(AffiliateId_Owner, idAssoc, transTypes); Ref = prefix.Left(5) + Ref; } return Ref; } - public virtual int GetTransactionRefSeqLength(ISbmUserContext_Core userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes) + public virtual int GetTransactionRefSeqLength(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes) { return 5; } //------------------------------------------------------------------- /// Transaction reference prefix by type - public virtual String GetTransactionRefPrefix(SysId id, SysId idAssoc, Sbm.TransactionType transactionType) + public virtual string GetTransactionRefPrefix(SysId id, SysId idAssoc, Sbm.TransactionType transactionType) { return ""; } //------------------------------------------------------------------- // Raise Transaction. - public virtual bool CanRaiseTransaction(ISbmUserContext_Core userContext, Sbm.TransactionType typeFrom, Sbm.TransactionType typeTo) + public virtual bool CanRaiseTransaction(Sbm.TransactionType typeFrom, Sbm.TransactionType typeTo) { - if (!AllowTransactionType(userContext, typeFrom) || !AllowTransactionType(userContext, typeTo)) return false; - if (!CanCreateTransactionLocally(userContext, typeTo)) return false; + if (!AllowTransactionType(typeFrom) || !AllowTransactionType(typeTo)) return false; + if (!CanCreateTransactionLocally(typeTo)) return false; if (typeFrom == Sbm.TransactionType.Project) { // Can raise another project from a project. switch (typeTo) { case Sbm.TransactionType.Project: - return CanCreateTransactionLocally(userContext, typeTo); + return CanCreateTransactionLocally(typeTo); } } else if (typeFrom == Sbm.TransactionType.SalesLead) @@ -668,7 +679,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles case Sbm.TransactionType.SalesQuote: case Sbm.TransactionType.ProformaSalesOrder: case Sbm.TransactionType.SalesOrder: - return CanCreateTransactionLocally(userContext, typeTo); + return CanCreateTransactionLocally(typeTo); } } else if (typeFrom == Sbm.TransactionType.SalesQuote) @@ -682,7 +693,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles case Sbm.TransactionType.SalesOrder: case Sbm.TransactionType.ProformaSalesInvoice: case Sbm.TransactionType.SalesInvoice: - return CanCreateTransactionLocally(userContext, typeTo); + return CanCreateTransactionLocally(typeTo); } } else if (typeFrom == Sbm.TransactionType.SalesOrder || typeFrom == Sbm.TransactionType.ProformaSalesOrder) @@ -701,7 +712,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles case Sbm.TransactionType.PurchaseQuote: case Sbm.TransactionType.ProformaPurchaseOrder: case Sbm.TransactionType.PurchaseOrder: - return CanCreateTransactionLocally(userContext, typeTo); + return CanCreateTransactionLocally(typeTo); } } else if (typeFrom == Sbm.TransactionType.SalesDispatch) @@ -711,7 +722,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles { case Sbm.TransactionType.ProformaSalesInvoice: case Sbm.TransactionType.SalesInvoice: - return CanCreateTransactionLocally(userContext, typeTo); + return CanCreateTransactionLocally(typeTo); } } else if (typeFrom == Sbm.TransactionType.PurchaseQuote) @@ -722,7 +733,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles case Sbm.TransactionType.PurchaseQuote: case Sbm.TransactionType.ProformaPurchaseOrder: case Sbm.TransactionType.PurchaseOrder: - return CanCreateTransactionLocally(userContext, typeTo); + return CanCreateTransactionLocally(typeTo); } } else if (typeFrom == Sbm.TransactionType.PurchaseOrder || typeFrom == Sbm.TransactionType.ProformaPurchaseOrder) @@ -736,39 +747,39 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles case Sbm.TransactionType.PurchaseQuote: case Sbm.TransactionType.ProformaPurchaseOrder: case Sbm.TransactionType.PurchaseOrder: - return CanCreateTransactionLocally(userContext, typeTo); + return CanCreateTransactionLocally(typeTo); } } return false; } //------------------------------------------------------------------- - public virtual List GetTransactionTypesForRaiseFrom(ISbmUserContext_Core userContext, Sbm.TransactionType typeFrom) + public virtual List GetTransactionTypesForRaiseFrom(Sbm.TransactionType typeFrom) { // Build the list of transaction types that are allowed to be raised from the specified type. List transTypes = new List(); - if (transactionTypes_Full.Count == 0) transactionTypes_Full = SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.TransactionType); + if (transactionTypes_Full.Count == 0) transactionTypes_Full = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType); foreach (TypeCodeDesc transTypeTo in transactionTypes_Full) { //if ((Sbm.TransactionType)typeTo.iType == typeFrom) continue; - if (CanRaiseTransaction(userContext, typeFrom, (Sbm.TransactionType)transTypeTo.Type)) + if (CanRaiseTransaction(typeFrom, (Sbm.TransactionType)transTypeTo.Type)) transTypes.Add(transTypeTo); } return transTypes; } //------------------------------------------------------------------- - public virtual List GetTransactionTypesForRaiseTo(ISbmUserContext_Core userContext, Sbm.TransactionType typeTo) + public virtual List GetTransactionTypesForRaiseTo(Sbm.TransactionType typeTo) { // Build the list of transaction types that are allowed to be raised to the specified type. List transTypes = new List(); - if (transactionTypes_Full.Count == 0) transactionTypes_Full = SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.TransactionType); + if (transactionTypes_Full.Count == 0) transactionTypes_Full = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType); //transTypes_Full.GotoStart(); foreach (TypeCodeDesc transTypeTo in transactionTypes_Full) { //TypeCodeDesc & typeTo = transTypes_Full.Index(); if ((Sbm.TransactionType)transTypeTo.Type == typeTo) continue; - if (CanRaiseTransaction(userContext, (Sbm.TransactionType)transTypeTo.Type, typeTo)) + if (CanRaiseTransaction((Sbm.TransactionType)transTypeTo.Type, typeTo)) transTypes.Add(transTypeTo); } return transTypes; @@ -776,7 +787,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Prepare Requirements Transaction. - Prepare copied list of requirements, eg. when raising from another transaction. - public virtual bool PrepareCopiedRequirements(ISbmUserContext_Core userContext, SbmTransaction transSource, List requireList, Sbm.TransactionType type) + public virtual bool PrepareCopiedRequirements(SbmTransaction transSource, List requireList, Sbm.TransactionType type) { type = new Sbm.TransactionType(); //transSource; requireList; type; @@ -785,15 +796,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Remove Transaction.- By default, not allowed if transaction has requirements. - public virtual bool CanRemoveTransactionWithRequirements(ISbmUserContext_Core userContext, SbmTransaction transaction, int requirementCount) + public virtual bool CanRemoveTransactionWithRequirements(SbmTransaction transaction, int requirementCount) { if (transaction == null || !SysId.IsValid(transaction.Id)) return false; - return (requirementCount < 1); + return requirementCount < 1; } //------------------------------------------------------------------- // Tax Effective Date. - TransTypes that should use the 'In Progress' date as tax point as opposed to the 'Raised' date. - public virtual bool UseInProgressTaxDateAsTaxPoint(ISbmUserContext_Core userContext, Sbm.TransactionType transactionType) + public virtual bool UseInProgressTaxDateAsTaxPoint(Sbm.TransactionType transactionType) { switch (transactionType) { @@ -811,14 +822,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // R e q u i r e m e n t O p t i o n s //------------------------------------------------------------------- // Requirement Actions. - public virtual bool SearchCommodityOnCreateRequirement(ISbmUserContext_Core userContext, Sbm.TransactionType transactionType) + public virtual bool SearchCommodityOnCreateRequirement(Sbm.TransactionType transactionType) { return false; } //------------------------------------------------------------------- // Requirement Costing. - public virtual SbmRequirementCostingConfig GetRequirementCostingConfig(ISbmUserContext_Core userContext) + public virtual SbmRequirementCostingConfig GetRequirementCostingConfig() { SbmRequirementCostingConfig cfgRequirementCosting = new SbmRequirementCostingConfig(); return cfgRequirementCosting; @@ -828,21 +839,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // C o m m o d i t y O p t i o n s //------------------------------------------------------------------- // Commodity Management. - public virtual Sbm.CommodityType GetCommodityTypeDefault(ISbmUserContext_Core userContext, Sbm.OrgOption_CommodityType commodityType) + public virtual Sbm.CommodityType GetCommodityTypeDefault(Sbm.OrgOption_CommodityType commodityType) { // Default = 'Stock'. return Sbm.CommodityType.Stock; } // Clean-up imported data (default no action). - public virtual bool CleanupImportedCommodity(ISbmUserContext_Core userContext, SbmCommodity commodity) + public virtual bool CleanupImportedCommodity(SbmCommodity commodity) { return true; } //------------------------------------------------------------------- // Stock Control - public virtual SbmStockControlConfig GetStockControlConfig(ISbmUserContext_Core userContext) + public virtual SbmStockControlConfig GetStockControlConfig() { SbmStockControlConfig cfgStockControl = new SbmStockControlConfig(); return cfgStockControl; @@ -852,11 +863,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // R e p o r t i n g //------------------------------------------------------------------- // Available reports (over and above standard). - public virtual List GetReports(ISbmUserContext_Core userContext, Sbm.View view) + public virtual List GetReports(Sbm.View view) { return new List(); } - public virtual bool ItemHasDiaryReports(ISbmUserContext_Core userContext/*SaItemId &*/) + public virtual bool ItemHasDiaryReports(ItemId itemId) { return false; } @@ -882,7 +893,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles /// Sales Invoice report horizontal lines [Bool] RptSalesInvoiceHorizontalLines = 111, } - public virtual DataValue GetDefaultProcessParam(ISbmUserContext_Core userContext, ProcessParam prm) + public virtual DataValue GetDefaultProcessParam(ProcessParam prm) { switch (prm) { @@ -895,18 +906,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Automated processes. - public virtual bool PerformProcess(ISbmUserContext_Core userContext, Sbm.ProcessType type) + public virtual bool PerformProcess(Sbm.ProcessType type) { return false; } // Available data import/export processes (over and above standard). - public virtual List GetImportProcesses(ISbmUserContext_Core userContext, Sbm.InterfaceDataType dataType, List itemIds) + public virtual List GetImportProcesses(Sbm.InterfaceDataType dataType, List itemIds) { return new List(); } - public virtual List GetExportProcesses(ISbmUserContext_Core userContext, Sbm.InterfaceDataType dataType, List itemIds) + public virtual List GetExportProcesses(Sbm.InterfaceDataType dataType, List itemIds) { return new List(); } @@ -915,17 +926,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // Data export Enhancements. eg. for export to accounts. public class DataExportItemDetails { - internal DataExportItemDetails(String itemCode, String itemDesc, String itemText) + internal DataExportItemDetails(string itemCode, string itemDesc, string itemText) { ItemCode = itemCode; ItemDesc = itemDesc; ItemText = itemText; } - public String ItemCode { get; } - public String ItemDesc { get; } - public String ItemText { get; } + public string ItemCode { get; } + public string ItemDesc { get; } + public string ItemText { get; } }; - public virtual DataExportItemDetails GetDataExportInvoiceItemDetails(ISbmUserContext_Core userContext, SbmRequirement requirement) + public virtual DataExportItemDetails GetDataExportInvoiceItemDetails(SbmRequirement requirement) { return null; } @@ -933,16 +944,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // I n t e r f a c e O p t i o n s //------------------------------------------------------------------- - public virtual bool AllowInterfaces(ISbmUserContext_Core userContext) + public virtual bool AllowInterfaces() { - if (AllowInterfaceCategory(userContext, SaInterfaceCategory.Website)) return true; - if (AllowInterfaceCategory(userContext, SaInterfaceCategory.Accounts)) return true; - if (AllowInterfaceCategory(userContext, SaInterfaceCategory.System)) return true; - if (AllowInterfaceCategory(userContext, SaInterfaceCategory.File)) return true; + if (AllowInterfaceCategory(SaInterfaceCategory.Website)) return true; + if (AllowInterfaceCategory(SaInterfaceCategory.Accounts)) return true; + if (AllowInterfaceCategory(SaInterfaceCategory.System)) return true; + if (AllowInterfaceCategory(SaInterfaceCategory.File)) return true; return false; } - public virtual bool AllowInterfaceCategory(ISbmUserContext_Core userContext, SaInterfaceCategory interfaceCategory) + public virtual bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory) { // By default, only website and file interfaces are allowed. switch (interfaceCategory) @@ -954,9 +965,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles return false; } - public virtual bool AllowInterface(ISbmUserContext_Core userContext, SaInterfaceCategory interfaceCategory, short interfaceType) + public virtual bool AllowInterface(SaInterfaceCategory interfaceCategory, short interfaceType) { - if (!AllowInterfaceCategory(userContext, interfaceCategory)) return false; + if (!AllowInterfaceCategory(interfaceCategory)) return false; switch (interfaceCategory) { case SaInterfaceCategory.Website: @@ -987,29 +998,29 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // Sbm.InterfaceType_System.Hpi - Only allowed by derived console. break; case SaInterfaceCategory.File: - if (AllowOption(userContext, Sbm.ConfigOption.AllowTransactions)) + if (AllowOption(Sbm.ConfigOption.AllowTransactions)) { if (interfaceType == (short)Sbm.InterfaceType_File.TransactionImport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.TransactionExport) return true; - if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesQuote) return AllowTransactionType(userContext, Sbm.TransactionType.SalesQuote); - if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesOrder) return (AllowTransactionType(userContext, Sbm.TransactionType.ProformaSalesOrder) || AllowTransactionType(userContext, Sbm.TransactionType.SalesOrder)); - if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesDispatch) return AllowTransactionType(userContext, Sbm.TransactionType.SalesDispatch); - if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesInvoice) return (AllowTransactionType(userContext, Sbm.TransactionType.ProformaSalesInvoice) || AllowTransactionType(userContext, Sbm.TransactionType.SalesInvoice)); - if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_PurchaseOrder) return (AllowTransactionType(userContext, Sbm.TransactionType.ProformaPurchaseOrder) || AllowTransactionType(userContext, Sbm.TransactionType.PurchaseOrder)); + if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesQuote) return AllowTransactionType(Sbm.TransactionType.SalesQuote); + if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesOrder) return AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder) || AllowTransactionType(Sbm.TransactionType.SalesOrder); + if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesDispatch) return AllowTransactionType(Sbm.TransactionType.SalesDispatch); + if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesInvoice) return AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice) || AllowTransactionType(Sbm.TransactionType.SalesInvoice); + if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_PurchaseOrder) return AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder) || AllowTransactionType(Sbm.TransactionType.PurchaseOrder); } - if (AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) + if (AllowOption(Sbm.ConfigOption.AllowContacts)) { if (interfaceType == (short)Sbm.InterfaceType_File.AffiliateImport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.AffiliateExport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.AssociationImport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.AssociationExport) return true; } - if (AllowOption(userContext, Sbm.ConfigOption.AllowCommodities)) + if (AllowOption(Sbm.ConfigOption.AllowCommodities)) { if (interfaceType == (short)Sbm.InterfaceType_File.CommodityImport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.CommodityExport) return true; } - if (interfaceType == (short)Sbm.InterfaceType_File.VehicleImport) return AllowOption(userContext, Sbm.ConfigOption.AllowVehicles); + if (interfaceType == (short)Sbm.InterfaceType_File.VehicleImport) return AllowOption(Sbm.ConfigOption.AllowVehicles); if (interfaceType == (short)Sbm.InterfaceType_File.LeasewayInvoice) //return SbmGlobals.Application.GetPropertyValue("Interface", "LeasewayInvoice").EqualsCI("Allow"); return false; diff --git a/SaBusMgrStandardBase/Base/Core/ISbmSecurityProfile_Core.cs b/SaBusMgrStandardBase/Base/Core/ISbmSecurityProfile_Core.cs index 7a440ee..81c651c 100644 --- a/SaBusMgrStandardBase/Base/Core/ISbmSecurityProfile_Core.cs +++ b/SaBusMgrStandardBase/Base/Core/ISbmSecurityProfile_Core.cs @@ -21,8 +21,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Core //------------------------------------------------------------------- // Security - Contacts. - bool UserCanCreateContacts { get; } - bool UserCanUpdateContacts { get; } + bool UserCanCreateContacts(); + bool UserCanUpdateContacts(); // Security - Financials. bool UserCanViewFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any); @@ -41,7 +41,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Core //------------------------------------------------------------------- /// Refresh profile. - void RefreshProfile(SbmConfigConsole configConsole, SaSecurityConsole securityConsole, SysId userId, List securityRights); + void RefreshProfile(SbmSessionConsole sessionConsole, SaSecurityConsole securityConsole, SysId userId, List securityRights); //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcAccountMgr_UserAccount.cs b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcAccountMgr_UserAccount.cs index 67b9d49..1921810 100644 --- a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcAccountMgr_UserAccount.cs +++ b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcAccountMgr_UserAccount.cs @@ -191,6 +191,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control DataValue value = new DataValue(); switch ((SbmcUserAccount.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmcUserAccount.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -209,7 +210,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr_Owner.cs b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr_Owner.cs index 11ca934..c073f47 100644 --- a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr_Owner.cs +++ b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr_Owner.cs @@ -141,8 +141,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control DataValue value = new DataValue(); switch ((SbmcOwner.Column)column.Id) { - // Notes. - case SbmcOwner.Column.Notes: + //----------------------------------------------------------- + // Notes. + case SbmcOwner.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); break; @@ -159,9 +160,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control } break; - //----------------------------------------------------------- - } - return value; + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + + } + return value; } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr_Repository.cs b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr_Repository.cs index 8acbfc3..4610d8f 100644 --- a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr_Repository.cs +++ b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr_Repository.cs @@ -169,8 +169,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control DataValue value = new DataValue(); switch ((SbmcRepository.Column)column.Id) { - // Notes. - case SbmcRepository.Column.Notes: + //----------------------------------------------------------- + // Notes. + case SbmcRepository.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); break; @@ -187,9 +188,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control } break; - //----------------------------------------------------------- - } - return value; + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + + } + return value; } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcItemMgr_ItemParam.cs b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcItemMgr_ItemParam.cs index 2ef3d2c..79c2496 100644 --- a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcItemMgr_ItemParam.cs +++ b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcItemMgr_ItemParam.cs @@ -147,6 +147,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control DataValue value = new DataValue(); switch ((SbmcItemParam.Column)column.Id) { + //----------------------------------------------------------- // Item Type caption. case SbmcItemParam.Column.ItemType_Caption: { @@ -156,6 +157,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control } break; + //----------------------------------------------------------- // Item caption. case SbmcItemParam.Column.Item_Caption: { @@ -169,6 +171,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control } break; + //----------------------------------------------------------- // Value. case SbmcItemParam.Column.Value: String paramContext = values.GetValue(GetItemParamColumnDfn(SbmcItemParam.Column.Context).DataName).AsString(); @@ -179,6 +182,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control else value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); break; + //----------------------------------------------------------- // Notes. case SbmcItemParam.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -197,11 +201,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control } break; + //----------------------------------------------------------- default: - value = new DataValue(column.FormatValue(values)); + value = values.GetValue(column.DataName); break; - //----------------------------------------------------------- } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Address.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Address.cs index a0bc534..2b57e4d 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Address.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Address.cs @@ -29,7 +29,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(addressId)) return false; SbmAddress.Params prmAddress = new SbmAddress.Params(); - prmAddress.IncludedIds.Add(addressId); + prmAddress.IdsIncluded.Add(addressId); prmAddress.StatusCat = SbmAddress.StatusCat.Any; return GetAddressCount(prmAddress) == 1; } @@ -42,7 +42,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(addressId)) return null; SbmAddress.Params prmAddress = new SbmAddress.Params(); - prmAddress.IncludedIds.Add(addressId); + prmAddress.IdsIncluded.Add(addressId); prmAddress.StatusCat = SbmAddress.StatusCat.Any; return GetAddress(prmAddress); } @@ -348,6 +348,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmAddress.Column)column.Id) { + //----------------------------------------------------------- // Address type description. case SbmAddress.Column.Type_Desc: { @@ -356,19 +357,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; + //----------------------------------------------------------- // Address summary. case SbmAddress.Column.Summary: { - List addresses = new List(); - addresses.Add(values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Line1).DataName).AsString()); - addresses.Add(values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Line2).DataName).AsString()); - addresses.Add(values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Line3).DataName).AsString()); - addresses.Add(values.GetValue(GetAddressColumnDfn(SbmAddress.Column.City).DataName).AsString()); - addresses.Add(values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Province).DataName).AsString()); - value = new DataValue(addresses.Concat(", ", null, null, true, true).ToString() + " " + values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Postcode).DataName).AsString()); + String line1 = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Line1).DataName).AsString(); + String city = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.City).DataName).AsString(); + String province = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Province).DataName).AsString(); + String postcode = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Postcode).DataName).AsString(); + String country = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Country).DataName).AsString(); + value = new DataValue(SbmAddress.GetSummary(line1, city, province, postcode, country)); } break; + //----------------------------------------------------------- // Notes. case SbmAddress.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -386,6 +388,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmAddress.GetStatusTriState(status)); } break; + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Affiliate.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Affiliate.cs index 522b02c..b7c4203 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Affiliate.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Affiliate.cs @@ -36,7 +36,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(affiliateId)) return false; SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); - prmAffiliate.IncludedIds.Add(affiliateId); + prmAffiliate.IdsIncluded.Add(affiliateId); prmAffiliate.StatusCat = SbmAffiliate.StatusCat.Any; return GetAffiliateCount(prmAffiliate) == 1; } @@ -45,7 +45,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(affiliateIdOwner)) return false; SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); - prmAffiliate.IncludedIds.Add(affiliateIdOwner); + prmAffiliate.IdsIncluded.Add(affiliateIdOwner); prmAffiliate.StatusCat = SbmAffiliate.StatusCat.Any; return GetAffiliateCount(prmAffiliate) == 1; } @@ -55,7 +55,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr if (!StringUtil.IsEmpty(organisationName) || !SysId.IsValid(affiliateIdExclude)) return false; SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); prmAffiliate.Name = organisationName; - prmAffiliate.ExcludedIds.Add(affiliateIdExclude); + prmAffiliate.IdsExcluded.Add(affiliateIdExclude); prmAffiliate.StatusCat = SbmAffiliate.StatusCat.Any; return GetAffiliateCount(prmAffiliate) == 1; } @@ -66,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); prmAffiliate.Name = firstName; prmAffiliate.Name = lastName; - prmAffiliate.ExcludedIds.Add(affiliateIdExclude); + prmAffiliate.IdsExcluded.Add(affiliateIdExclude); prmAffiliate.StatusCat = SbmAffiliate.StatusCat.Any; return GetAffiliateCount(prmAffiliate) == 1; } @@ -80,7 +80,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(affiliateId)) return null; SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); - prmAffiliate.IncludedIds.Add(affiliateId); + prmAffiliate.IdsIncluded.Add(affiliateId); prmAffiliate.StatusCat = SbmAffiliate.StatusCat.Any; return GetAffiliate(prmAffiliate); } @@ -126,7 +126,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(associationId)) return null; SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); - prmAffiliate.IncludedIds.Add(associationId); + prmAffiliate.IdsIncluded.Add(associationId); prmAffiliate.StatusCat = SbmAffiliate.StatusCat.Any; return GetAffiliate(prmAffiliate); } @@ -386,6 +386,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmAffiliate.Column)column.Id) { + //----------------------------------------------------------- // Affiliate type description. case SbmAffiliate.Column.Type_Code: case SbmAffiliate.Column.Type_Desc: @@ -397,27 +398,25 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; + //----------------------------------------------------------- // Address summary. case SbmAffiliate.Column.Address_Summary: { - List addresses = new List() - { - values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_Line1).DataName).AsString(), - values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_Line2).DataName).AsString(), - values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_City).DataName).AsString(), - values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_Province).DataName).AsString(), - values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_Postcode).DataName).AsString(), - values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_Country).DataName).AsString(), - }; - - value = new DataValue(addresses.Concat(", ", null, null, true, true).Replace(" ,", ",").Trim(',').Trim()); + String line1 = values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_Line1).DataName).AsString(); + String city = values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_City).DataName).AsString(); + String province = values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_Province).DataName).AsString(); + String postcode = values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_Postcode).DataName).AsString(); + String country = values.GetValue(GetAffiliateColumnDfn(SbmAffiliate.Column.Address_Country).DataName).AsString(); + value = new DataValue(SbmAddress.GetSummary(line1, city, province, postcode, country)); break; } + //----------------------------------------------------------- // Prospect Group. case SbmAffiliate.Column.ProspectGroup: break; + //----------------------------------------------------------- // Notes. case SbmAffiliate.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -436,7 +435,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Association.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Association.cs index 3730062..8dbff4e 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Association.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Association.cs @@ -4,6 +4,7 @@ using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.ReferenceData; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; @@ -34,7 +35,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr public bool AllowColumnImport(SbmAssociation.Column column) { SbmDbDfn.ColumnIdx columnDb = GetDbCol(column); - if (column.Equals(SbmDbDfn.ColumnIdx.Unknown) && ConfigConsole.DisplayAttribute(UserContext, columnDb)) + if (column.Equals(SbmDbDfn.ColumnIdx.Unknown) && SessionConsole.DisplayAttribute(columnDb)) { switch (column) { @@ -494,7 +495,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return false; SbmAssociation.Params prmAssociation = new SbmAssociation.Params(); - prmAssociation.IncludedIds.Add(id); + prmAssociation.IdsIncluded.Add(id); prmAssociation.StatusCat = SbmAssociation.StatusCat.Any; return GetAssociationCount(prmAssociation) == 1; } @@ -533,7 +534,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(associationId)) return null; SbmAssociation.Params prmAssociation = new SbmAssociation.Params(); - prmAssociation.IncludedIds.Add(associationId); + prmAssociation.IdsIncluded.Add(associationId); + prmAssociation.AssociationType = Sbm.AssociationType.Any; prmAssociation.StatusCat = SbmAssociation.StatusCat.Any; return GetAssociation(prmAssociation); } @@ -557,7 +559,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr AssociationType = associationType, Code = associationCode, StatusCat = SbmAssociation.StatusCat.NotDeleted - }; + }; return GetAssociation(prmAssociation); } @@ -784,7 +786,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr if (errField.AffiliateIdOwner != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.AffiliateIdOwner)) { SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); - prmAffiliate.IncludedIds.Add(data.AffiliateIdOwner); + prmAffiliate.IdsIncluded.Add(data.AffiliateIdOwner); prmAffiliate.StatusCat = SbmAffiliate.StatusCat.Any; if (GetAffiliateCount(prmAffiliate) < 1) { @@ -795,7 +797,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr if (errField.AffiliateIdTarget != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.AffiliateIdTarget)) { SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); - prmAffiliate.IncludedIds.Add(data.AffiliateIdTarget); + prmAffiliate.IdsIncluded.Add(data.AffiliateIdTarget); prmAffiliate.StatusCat = SbmAffiliate.StatusCat.Any; if (GetAffiliateCount(prmAffiliate) < 1) { @@ -805,23 +807,27 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } if (errField.PriceSetId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.PriceSetId)) { - /* ToDo Validate Association PriceSet + // Association PriceSet. SbmPriceSet.Params prmPriceSet = new SbmPriceSet.Params(); - prmPriceSet.IncludedIds.Add(data.PriceSetId); + prmPriceSet.IdsIncluded.Add(data.PriceSetId); prmPriceSet.StatusCat = SbmPriceSet.StatusCat.Any; - if (GetPriceSetCount(prmPriceSet) < 1) + if (PriceMgr.GetPriceSetCount(prmPriceSet) < 1) { errField.PriceSetId = SacsHierarchyItem.ValidValue.Invalid; return SetErrorState("Price Set not found"); } - */ } if (errField.TaxCodeId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.TaxCodeId)) { - /* ToDo Validate Association TaxCode - errField.TaxCodeId = SacsHierarchyItem.ValidValue.Invalid; - return SetErrorState("Tax Code's Id not found"); - */ + // Association TaxCode. + using (SaTaxCode taxCode = Internals.GetTaxCodeById(data.TaxCodeId)) + { + if (taxCode == null) + { + errField.TaxCodeId = SacsHierarchyItem.ValidValue.Invalid; + return SetErrorState("Tax Code not found"); + } + } } return true; } @@ -858,7 +864,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmAssociation.Column)column.Id) { - //--------------------------------------------------------------- + //----------------------------------------------------------- // Association TypeDesc. case SbmAssociation.Column.Type_Desc: { @@ -867,7 +873,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Discount TypeDesc. case SbmAssociation.Column.DiscountType_Desc: { @@ -876,7 +882,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Association Coding. case SbmAssociation.Column.AccountManagerDesc: { @@ -926,6 +932,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(GetCodeTypeCodeDesc(Sbm.ApplCodeType.ContactCallCycle, contactCallCycle)); break; } + + //----------------------------------------------------------- // Association Seasonal Category. case SbmAssociation.Column.SeasonalCategoryCode1: case SbmAssociation.Column.SeasonalCategoryDesc1: @@ -977,6 +985,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; } + + //----------------------------------------------------------- case SbmAssociation.Column.OrderLeadTimeDesc: { String orderLeadTime = values.GetValue(column.DataName).ToString(); @@ -1002,7 +1012,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Notes. case SbmAssociation.Column.Notes: { @@ -1035,7 +1045,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SacsHierarchyItem.GetFlag(flags, SbmAssociation.Flag_Technician)); break; } - //--------------------------------------------------------------- + + //----------------------------------------------------------- // Affiliate Type Desc. case SbmAssociation.Column.Target_TypeDesc: { @@ -1050,7 +1061,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Address Type. case SbmAssociation.Column.Target_Address_TypeDesc: { @@ -1061,17 +1072,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr // Address Summary. case SbmAssociation.Column.Target_Address_Summary: { - List addresses = new List() - { - values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_Line1).DataName).ToString(), - values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_Line2).DataName).ToString(), - values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_City).DataName).ToString(), - values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_Province).DataName).ToString(), - values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_Postcode).DataName).ToString(), - values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_Country).DataName).ToString(), - }; - - value = new DataValue(addresses.Concat(", ", null, null, true, true).Replace(" ,", ",").Trim(',').Trim()); + String line1 = values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_Line1).DataName).ToString(); + String city = values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_City).DataName).ToString(); + String province = values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_Province).DataName).ToString(); + String postcode = values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_Postcode).DataName).ToString(); + String country = values.GetValue(GetAssociationColumnDfn(SbmAssociation.Column.Target_Address_Country).DataName).ToString(); + value = new DataValue(SbmAddress.GetSummary(line1, city, province, postcode, country)); break; } // Address Coding. @@ -1100,7 +1106,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs index 02cb622..a03bf93 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs @@ -9,8 +9,8 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { - //======================================================================= - public partial class SbmAccountMgr + //======================================================================= + public partial class SbmAccountMgr { //******************************************************************* // O r g a n i s a t i o n @@ -178,7 +178,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } // Additonal organisation options - to support non-standard configuration options: - itemOptionDfns.AddRange(ConfigConsole.GetAdditionalOrganisationOptions()); + itemOptionDfns.AddRange(SessionConsole.GetAdditionalOrganisationOptions()); return itemOptionDfns; } @@ -218,7 +218,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr private OrganisationOptionData InitOrganisationOptionData() { OrganisationOptionData orgOptData = new OrganisationOptionData(); - using (SbmConfigConsole console = SbmGlobals.Application.CreateConfigConsole(UserContext.SessionContext)) + using (SbmSessionConsole sessionConsole = SbmGlobals.Application.CreateSessionConsole(UserContext)) using (SbmAccountsDfn accounts = new SbmAccountsDfn(UserContext)) { // Option types. @@ -241,8 +241,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr bool bAllowSalesDispatches = (AllowTransactionType(Sbm.TransactionType.SalesDispatch)); bool bAllowSalesInvoices = ((AllowTransactionType(Sbm.TransactionType.SalesInvoice) || AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice))); bool bAllowPurchaseOrders = ((AllowTransactionType(Sbm.TransactionType.PurchaseOrder) || AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder))); - bool bAllowInterfaces = (console.AllowInterfaces(UserContext)); - bool bAllowInterfaces_File = (bAllowInterfaces && console.AllowInterfaceCategory(UserContext, SaInterfaceCategory.File)); + bool bAllowInterfaces = (sessionConsole.AllowInterfaces()); + bool bAllowInterfaces_File = (bAllowInterfaces && sessionConsole.AllowInterfaceCategory(SaInterfaceCategory.File)); // Values: List orgOptionValues = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Value); @@ -251,7 +251,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter)); if (CodeTypeHasCodes(Sbm.ApplCodeType.CommodityPromotion)) orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.AlternativePromotionText)); - if (console.GetRequirementCostingConfig(UserContext).AllowRequirementCosting(Sbm.TransactionType.SalesOrder)) + if (sessionConsole.GetRequirementCostingConfig().AllowRequirementCosting(Sbm.TransactionType.SalesOrder)) orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CostLabourRateDefault)); orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CommoditiesAllowedNegativePrice)); if (AllowConfigOption(Sbm.ConfigOption.TransactionSplitTimes)) diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SysParam.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SysParam.cs index 359f29d..228e898 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SysParam.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SysParam.cs @@ -28,7 +28,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return false; SbmSysParam.Params prmSysParam = new SbmSysParam.Params(); - prmSysParam.IncludedIds.Add(id); + prmSysParam.IdsIncluded.Add(id); prmSysParam.StatusCat = SbmSysParam.StatusCat.Any; return GetSysParamCount(prmSysParam) == 1; } @@ -42,7 +42,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(paramId)) return null; SbmSysParam.Params prmSysParam = new SbmSysParam.Params(); - prmSysParam.IncludedIds.Add(paramId); + prmSysParam.IdsIncluded.Add(paramId); prmSysParam.StatusCat = SbmSysParam.StatusCat.Any; return GetSysParam(prmSysParam); } @@ -153,6 +153,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmSysParam.Column)column.Id) { + //----------------------------------------------------------- // SysParam Cat_Desc? //----------------------------------------------------------- @@ -161,7 +162,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); break; - //----------------------------------------------------------- // Status. case SbmSysParam.Column.Status_Desc: case SbmSysParam.Column.Status_Ind: @@ -175,7 +175,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemAccount.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemAccount.cs index 39d1d2d..5b4b95c 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemAccount.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemAccount.cs @@ -30,7 +30,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(systemAccountId)) return false; SbmSystemAccount.Params prmSystemAccount = new SbmSystemAccount.Params(); - prmSystemAccount.IncludedIds.Add(systemAccountId); + prmSystemAccount.IdsIncluded.Add(systemAccountId); prmSystemAccount.StatusCat = SbmSystemAccount.StatusCat.Any; return GetSystemAccountCount(prmSystemAccount) == 1; } @@ -65,7 +65,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(systemAccountId)) return null; SbmSystemAccount.Params prmSystemAccount = new SbmSystemAccount.Params(); - prmSystemAccount.IncludedIds.Add(systemAccountId); + prmSystemAccount.IdsIncluded.Add(systemAccountId); prmSystemAccount.StatusCat = SbmSystemAccount.StatusCat.Any; return GetSystemAccount(prmSystemAccount); } @@ -183,6 +183,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmSystemAccount.Column)column.Id) { + //----------------------------------------------------------- // SystemAccount TypeDesc. case SbmSystemAccount.Column.Type_Desc: { @@ -191,6 +192,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } + //----------------------------------------------------------- // Notes. case SbmSystemAccount.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -222,7 +224,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemAccountUser.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemAccountUser.cs index bbf1450..c13e484 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemAccountUser.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemAccountUser.cs @@ -124,6 +124,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmSystemAccountUser.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmSystemAccountUser.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -142,7 +143,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemUser.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemUser.cs index ffa3f7c..b11d8c6 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemUser.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_SystemUser.cs @@ -30,7 +30,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(systemUserId)) return false; SbmSystemUser.Params prmSystemUser = new SbmSystemUser.Params(); - prmSystemUser.IncludedIds.Add(systemUserId); + prmSystemUser.IdsIncluded.Add(systemUserId); prmSystemUser.StatusCat = SbmSystemUser.StatusCat.Any; return GetSystemUserCount(prmSystemUser) == 1; } @@ -65,7 +65,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(systemUserId)) return null; SbmSystemUser.Params prmSystemUser = new SbmSystemUser.Params(); - prmSystemUser.IncludedIds.Add(systemUserId); + prmSystemUser.IdsIncluded.Add(systemUserId); prmSystemUser.StatusCat = SbmSystemUser.StatusCat.Any; return GetSystemUser(prmSystemUser); } @@ -174,6 +174,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmSystemUser.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmSystemUser.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -191,7 +192,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmSystemUser.GetStatusTriState(status)); } break; - //----------------------------------------------------------- + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_Asset.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_Asset.cs index b897052..c2f052a 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_Asset.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_Asset.cs @@ -27,7 +27,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(assetId)) return false; SbmAsset.Params prmAsset = new SbmAsset.Params(); - prmAsset.IncludedIds.Add(assetId); + prmAsset.IdsIncluded.Add(assetId); prmAsset.StatusCat = SbmAsset.StatusCat.Any; return GetAssetCount(prmAsset) == 1; } @@ -54,7 +54,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(assetId)) return null; SbmAsset.Params prmAsset = new SbmAsset.Params(); - prmAsset.IncludedIds.Add(assetId); + prmAsset.IdsIncluded.Add(assetId); prmAsset.StatusCat = SbmAsset.StatusCat.Any; return GetAsset(prmAsset); } @@ -271,6 +271,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmAsset.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmAsset.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -289,7 +290,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_AssetCategory.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_AssetCategory.cs index 35d4764..7ea2264 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_AssetCategory.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_AssetCategory.cs @@ -187,6 +187,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmAssetCategory.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmAssetCategory.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -205,7 +206,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_AssetProcess.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_AssetProcess.cs index d69cf83..26c088c 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_AssetProcess.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_AssetProcess.cs @@ -28,7 +28,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(assetProcessId)) return false; SbmAssetProcess.Params prmAssetProcess = new SbmAssetProcess.Params(); - prmAssetProcess.IncludedIds.Add(assetProcessId); + prmAssetProcess.IdsIncluded.Add(assetProcessId); prmAssetProcess.StatusCat = SbmAssetProcess.StatusCat.Any; return GetAssetProcessCount(prmAssetProcess) == 1; } @@ -42,7 +42,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(assetProcessId)) return null; SbmAssetProcess.Params prmAssetProcess = new SbmAssetProcess.Params(); - prmAssetProcess.IncludedIds.Add(assetProcessId); + prmAssetProcess.IdsIncluded.Add(assetProcessId); prmAssetProcess.StatusCat = SbmAssetProcess.StatusCat.Any; return GetAssetProcess(prmAssetProcess); } @@ -147,6 +147,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmAssetProcess.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmAssetProcess.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -165,7 +166,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_Vehicle.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_Vehicle.cs index 8b3ef1e..00a23c8 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_Vehicle.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_Vehicle.cs @@ -28,7 +28,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return false; SbmVehicle.Params prm = new SbmVehicle.Params(); - prm.IncludedIds.Add(id); + prm.IdsIncluded.Add(id); prm.StatusCat = SbmVehicle.StatusCat.Any; return GetVehicleCount(prm) == 1; } @@ -53,7 +53,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return null; SbmVehicle.Params prm = new SbmVehicle.Params(); - prm.IncludedIds.Add(id); + prm.IdsIncluded.Add(id); prm.StatusCat = SbmVehicle.StatusCat.Any; return GetVehicle(prm); } @@ -173,6 +173,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmVehicle.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmVehicle.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -191,7 +192,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleClass.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleClass.cs index 61f624e..4997144 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleClass.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleClass.cs @@ -182,6 +182,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmVehicleClass.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmVehicleClass.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -200,7 +201,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleEvent.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleEvent.cs index 1e9c4ac..9b332c7 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleEvent.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleEvent.cs @@ -29,7 +29,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return false; SbmVehicleEvent.Params prm = new SbmVehicleEvent.Params(); - prm.IncludedIds.Add(id); + prm.IdsIncluded.Add(id); prm.StatusCat = SbmVehicleEvent.StatusCat.Any; return GetVehicleEventCount(prm) == 1; } @@ -39,7 +39,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(vehicleId) || (int)vehicleEventType < 1 || DateUtil.IsValid(eventOn)) return false; SbmVehicleEvent.Params prm = new SbmVehicleEvent.Params(); - prm.IncludedIds.Add(vehicleId); + prm.IdsIncluded.Add(vehicleId); prm.VehicleEventType = vehicleEventType; prm.EventOn = eventOn; prm.StatusCat = SbmVehicleEvent.StatusCat.Any; @@ -55,7 +55,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return null; SbmVehicleEvent.Params prm = new SbmVehicleEvent.Params(); - prm.IncludedIds.Add(id); + prm.IdsIncluded.Add(id); prm.StatusCat = SbmVehicleEvent.StatusCat.Any; return GetVehicleEvent(prm); } @@ -63,7 +63,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { if (!SysId.IsValid(vehicleId) || (int)vehicleEventType < 1 || !DateUtil.IsValid(eventOn)) return null; SbmVehicleEvent.Params prm = new SbmVehicleEvent.Params(); - prm.IncludedIds.Add(vehicleId); + prm.IdsIncluded.Add(vehicleId); prm.VehicleEventType = vehicleEventType; prm.EventOn = eventOn; prm.StatusCat = SbmVehicleEvent.StatusCat.Any; @@ -149,6 +149,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmVehicleEvent.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmVehicleEvent.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -167,7 +168,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleFeature.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleFeature.cs index 1f467cf..29f8b48 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleFeature.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr_VehicleFeature.cs @@ -29,7 +29,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return false; SbmVehicleFeature.Params prm = new SbmVehicleFeature.Params(); - prm.IncludedIds.Add(id); + prm.IdsIncluded.Add(id); prm.StatusCat = SbmVehicleFeature.StatusCat.Any; return GetVehicleFeatureCount(prm) == 1; } @@ -143,6 +143,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmVehicleFeature.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmVehicleFeature.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -161,7 +162,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr.cs index 053d42e..43d3ca0 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr.cs @@ -6,11 +6,14 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Commodity Manager. //======================================================================= public abstract partial class SbmCommodityMgr : SbmCoreMgr { //------------------------------------------------------------------- // Data members. + // Code types. private List supportedCodeTypes = new List() { diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity-Utils.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity-Utils.cs new file mode 100644 index 0000000..7221d12 --- /dev/null +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity-Utils.cs @@ -0,0 +1,329 @@ +using Sarand.BusinessMgr.Net.Standard.Base.App; +using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.ReferenceData; +using Sarand.Net.Standard.Base.Utils; +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; + +namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr +{ + //======================================================================= + // Commodity Manager - Commodity - Utils. + //======================================================================= + partial class SbmCommodityMgr + { + + //------------------------------------------------------------------- + // Commodity Associated data. + public abstract bool CommodityHasProcesses(SysId commodityId); + public abstract bool CommodityHasRequirements(SysId commodityId); + public abstract bool CommodityIsSalesBudgetTemplate(SysId commodityId); + public abstract bool CommodityHasComponents(SysId commodityId); + public abstract bool CommodityHasPortfolioItems(SysId commodityId); + public abstract bool CommodityHasContainers(SysId commodityId); + public abstract bool CommodityHasCustomerDetails(SysId commodityId); + public abstract bool CommodityHasSupplierDetails(SysId commodityId); + public abstract bool CommodityHasMovements(SysId commodityId); + public abstract bool CommodityHasStockLevels(SysId commodityId); + // Dependent data should only be cleared when removing a commodity. + // Data owned by this item is deleted (eg. interface data items & document references). + public abstract bool ClearCommodityDependentData(SysId commodityId); + + //------------------------------------------------------------------- + // Commodity requirements. + + /// + /// Update requirements for this commodity with the correct code. + /// + public abstract bool UpdateCommodityRequirements(SbmCommodity commodity); + + //------------------------------------------------------------------- + // Commodity cost estimates. + public abstract List GetCommodityCostEstimates(SbmCommodity commodity); + public abstract bool SetCommodityCostEstimates(SbmCommodity commodity, List costEstimatesNew); + public abstract bool CommitCommodityCostEstimates(SbmCommodity commodity); + + //------------------------------------------------------------------- + // Commodity processes. + public abstract List GetCommodityProcesses(SbmCommodity commodity, bool bActiveOnly = false); + public abstract bool SetCommodityProcesses(SbmCommodity commodity, List itemProcessesNew); + public abstract bool CommitCommodityProcesses(SbmCommodity commodity); + + //------------------------------------------------------------------- + // Interfaces. + + // Commodity interface rules. + public bool AllowColumnImport(SbmDbDfn.ColumnIdx column) + { + switch (column) + { + //case SbmDbDfn.ColumnIdx.Commodity_Id: + //case SbmDbDfn.ColumnIdx.Commodity_AffIdOwner: + //case SbmDbDfn.ColumnIdx.Commodity_Type: + case SbmDbDfn.ColumnIdx.Commodity_Code: + case SbmDbDfn.ColumnIdx.Commodity_DescBrief: + case SbmDbDfn.ColumnIdx.Commodity_DescOrder: + case SbmDbDfn.ColumnIdx.Commodity_DescDetail: + case SbmDbDfn.ColumnIdx.Commodity_DrawingNo: + case SbmDbDfn.ColumnIdx.Commodity_DrawingIssue: + case SbmDbDfn.ColumnIdx.Commodity_ImagePath: + case SbmDbDfn.ColumnIdx.Commodity_Category: + case SbmDbDfn.ColumnIdx.Commodity_Category2: + case SbmDbDfn.ColumnIdx.Commodity_Category3: + case SbmDbDfn.ColumnIdx.Commodity_Location: + case SbmDbDfn.ColumnIdx.Commodity_Department: + case SbmDbDfn.ColumnIdx.Commodity_CatalogRef: + case SbmDbDfn.ColumnIdx.Commodity_Weight: + case SbmDbDfn.ColumnIdx.Commodity_UomIdWeight: + case SbmDbDfn.ColumnIdx.Commodity_Length: + case SbmDbDfn.ColumnIdx.Commodity_UomIdLength: + case SbmDbDfn.ColumnIdx.Commodity_Volume: + case SbmDbDfn.ColumnIdx.Commodity_UomIdVolume: + case SbmDbDfn.ColumnIdx.Commodity_Density: + case SbmDbDfn.ColumnIdx.Commodity_UomIdDensity: + case SbmDbDfn.ColumnIdx.Commodity_BoxQuantity: + case SbmDbDfn.ColumnIdx.Commodity_UomIdBox: + case SbmDbDfn.ColumnIdx.Commodity_Dimensions: + case SbmDbDfn.ColumnIdx.Commodity_SpecSummary: + case SbmDbDfn.ColumnIdx.Commodity_NominalCode: + case SbmDbDfn.ColumnIdx.Commodity_NominalCodePurchase: + case SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode: + //case SbmDbDfn.ColumnIdx.Commodity_TimeProd: + //case SbmDbDfn.ColumnIdx.Commodity_UomIdTimeProd: + //case SbmDbDfn.ColumnIdx.Commodity_RangeCode: + //case SbmDbDfn.ColumnIdx.Commodity_ColourCode: + //case SbmDbDfn.ColumnIdx.Commodity_SourceCode: + //case SbmDbDfn.ColumnIdx.Commodity_SupplyMethodCode: + //case SbmDbDfn.ColumnIdx.Commodity_HandlingCode: + //case SbmDbDfn.ColumnIdx.Commodity_DeliveryCode: + case SbmDbDfn.ColumnIdx.Commodity_MaterialCode: + case SbmDbDfn.ColumnIdx.Commodity_FinishCode: + case SbmDbDfn.ColumnIdx.Commodity_PromotionCode: + case SbmDbDfn.ColumnIdx.Commodity_AssIdSupplier: + case SbmDbDfn.ColumnIdx.Commodity_SupplierRef: + case SbmDbDfn.ColumnIdx.Commodity_CostPrice: + case SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin: + case SbmDbDfn.ColumnIdx.Commodity_MaterialCost: + case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial: + case SbmDbDfn.ColumnIdx.Commodity_ExWorksCost: + case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks: + case SbmDbDfn.ColumnIdx.Commodity_ReorderLevel: + case SbmDbDfn.ColumnIdx.Commodity_ReorderQty: + //case SbmDbDfn.ColumnIdx.Commodity_QtyOnOrder: + case SbmDbDfn.ColumnIdx.Commodity_AssIdCustomer: + case SbmDbDfn.ColumnIdx.Commodity_SalesPrice: + case SbmDbDfn.ColumnIdx.Commodity_RetailPrice: + case SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned: + case SbmDbDfn.ColumnIdx.Commodity_UomIdSale: + case SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative: + //case SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative_Fmt: + case SbmDbDfn.ColumnIdx.Commodity_MinOrderQty: + case SbmDbDfn.ColumnIdx.Commodity_PackQty: + case SbmDbDfn.ColumnIdx.Commodity_TaxCodeId: + //case SbmDbDfn.ColumnIdx.Commodity_LastOrderDate: + //case SbmDbDfn.ColumnIdx.Commodity_LastOrderQty: + //case SbmDbDfn.ColumnIdx.Commodity_QtyInStock: + //case SbmDbDfn.ColumnIdx.Commodity_QtyAllocated: + //case SbmDbDfn.ColumnIdx.Commodity_FreeStock: + //case SbmDbDfn.ColumnIdx.Commodity_StockTakeDate: + //case SbmDbDfn.ColumnIdx.Commodity_StockTakeQty: + //case SbmDbDfn.ColumnIdx.Commodity_OrderQtyDecimals: + case SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj: + //case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonthlyProp: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth02: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth03: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth04: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth05: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth06: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth07: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth08: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth09: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth10: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11: + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12: + case SbmDbDfn.ColumnIdx.Commodity_Notes: + //case SbmDbDfn.ColumnIdx.Commodity_Flags: + //case SbmDbDfn.ColumnIdx.Commodity_Status: + //case SbmDbDfn.ColumnIdx.Commodity_CreateOn: + //case SbmDbDfn.ColumnIdx.Commodity_CreateBy: + //case SbmDbDfn.ColumnIdx.Commodity_CreateHost: + //case SbmDbDfn.ColumnIdx.Commodity_UpdateOn: + //case SbmDbDfn.ColumnIdx.Commodity_UpdateBy: + //case SbmDbDfn.ColumnIdx.Commodity_UpdateHost: + return SessionConsole.DisplayAttribute(column); + } + return false; + } + public String GetColumnCaption(SbmDbDfn.ColumnIdx column) + { + switch (column) + { + case SbmDbDfn.ColumnIdx.Commodity_Type: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Type, "Type"); + case SbmDbDfn.ColumnIdx.Commodity_Code: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Code, "Code"); + case SbmDbDfn.ColumnIdx.Commodity_DescBrief: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DescBrief, "Brief description"); + case SbmDbDfn.ColumnIdx.Commodity_DescOrder: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DescOrder, "Order description"); + case SbmDbDfn.ColumnIdx.Commodity_DescDetail: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DescDetail, "Detail description"); + case SbmDbDfn.ColumnIdx.Commodity_DrawingNo: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DrawingNo, "Drawing no"); + case SbmDbDfn.ColumnIdx.Commodity_DrawingIssue: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue, "Drawing issue"); + case SbmDbDfn.ColumnIdx.Commodity_ImagePath: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ImagePath, "Image path"); + case SbmDbDfn.ColumnIdx.Commodity_Category: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Category, "Category"); + case SbmDbDfn.ColumnIdx.Commodity_Location: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Location, "Location"); + case SbmDbDfn.ColumnIdx.Commodity_Department: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Department, "Department"); + case SbmDbDfn.ColumnIdx.Commodity_CatalogRef: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_CatalogRef, "Catalog ref"); + case SbmDbDfn.ColumnIdx.Commodity_Weight: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Weight, "Weight"); + case SbmDbDfn.ColumnIdx.Commodity_UomIdWeight: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdWeight, "Weight unit"); + case SbmDbDfn.ColumnIdx.Commodity_Length: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Length, "Length"); + case SbmDbDfn.ColumnIdx.Commodity_UomIdLength: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdLength, "Length unit"); + case SbmDbDfn.ColumnIdx.Commodity_Volume: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Volume, "Volume"); + case SbmDbDfn.ColumnIdx.Commodity_UomIdVolume: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdVolume, "Volume unit"); + case SbmDbDfn.ColumnIdx.Commodity_Density: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Density, "Density"); + case SbmDbDfn.ColumnIdx.Commodity_UomIdDensity: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdDensity, "Density unit"); + case SbmDbDfn.ColumnIdx.Commodity_BoxQuantity: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity, "Box quantity"); + case SbmDbDfn.ColumnIdx.Commodity_UomIdBox: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdBox, "Box unit"); + case SbmDbDfn.ColumnIdx.Commodity_Dimensions: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Dimensions, "Dimensions"); + case SbmDbDfn.ColumnIdx.Commodity_SpecSummary: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SpecSummary, "Specification"); + case SbmDbDfn.ColumnIdx.Commodity_NominalCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_NominalCode, "Nominal code - sales"); + case SbmDbDfn.ColumnIdx.Commodity_NominalCodePurchase: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_NominalCodePurchase, "Nominal code - purchase"); + case SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode, "ICN Tariff code"); + case SbmDbDfn.ColumnIdx.Commodity_MaterialCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material"); + case SbmDbDfn.ColumnIdx.Commodity_FinishCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish"); + case SbmDbDfn.ColumnIdx.Commodity_PromotionCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion"); + case SbmDbDfn.ColumnIdx.Commodity_AssIdSupplier: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_AssIdSupplier, "Supplier"); + case SbmDbDfn.ColumnIdx.Commodity_SupplierRef: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SupplierRef, "Supplier ref"); + case SbmDbDfn.ColumnIdx.Commodity_CostPrice: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_CostPrice, "Cost price"); + case SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin, "Place of origin"); + case SbmDbDfn.ColumnIdx.Commodity_MaterialCost: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_MaterialCost, "Material cost"); + case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial, "Material currency"); + case SbmDbDfn.ColumnIdx.Commodity_ExWorksCost: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost, "Ex-works cost"); + case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks, "Ex-works currency"); + case SbmDbDfn.ColumnIdx.Commodity_ReorderLevel: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ReorderLevel, "Reorder level"); + case SbmDbDfn.ColumnIdx.Commodity_ReorderQty: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ReorderQty, "Reorder qty"); + case SbmDbDfn.ColumnIdx.Commodity_AssIdCustomer: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_AssIdCustomer, "Customer"); + case SbmDbDfn.ColumnIdx.Commodity_SalesPrice: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesPrice, "Sales price"); + case SbmDbDfn.ColumnIdx.Commodity_RetailPrice: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_RetailPrice, "Retail price"); + case SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned, "Retail price planned"); + case SbmDbDfn.ColumnIdx.Commodity_UomIdSale: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdSale, "Sale unit"); + case SbmDbDfn.ColumnIdx.Commodity_PackQty: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PackQty, "Pack qty - sale"); + case SbmDbDfn.ColumnIdx.Commodity_TaxCodeId: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_TaxCodeId, "Tax code"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual, "Projected annual sales"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01, "Projected sales - Jan"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth02: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth02, "Projected sales - Feb"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth03: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth03, "Projected sales - Mar"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth04: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth04, "Projected sales - Apr"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth05: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth05, "Projected sales - May"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth06: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth06, "Projected sales - Jun"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth07: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth07, "Projected sales - Jul"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth08: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth08, "Projected sales - Aug"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth09: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth09, "Projected sales - Sep"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth10: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth10, "Projected sales - Oct"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11, "Projected sales - Nov"); + case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12, "Projected sales - Dec"); + } + return ""; + } + + //------------------------------------------------------------------- + // Image Paths. + public String GetImagePathPrefix() + { + String prefix = ""; + if (AccountsDfn.IsItemTypeManagedByAccounts(Sbm.ItemType.Commodity)) + { + if (AccountsDfn.IsUsingSageInterface()) + prefix = "%SAGE%\\"; + } + return prefix; + } + public String GetActualImagePath(String imagePath) + { + //SATRACE("SapCommodityMgr::GetActualImagePath '"+imagePath+"'\n"); + if (StringUtil.IsEmpty(imagePath)) return imagePath; + String imagePathPrefix = GetImagePathPrefix(); + String cmdImagePath = imagePath; + if (cmdImagePath.Left(imagePathPrefix.Length) == imagePathPrefix) + { + String imageFolder = ""; + if (AccountsDfn.IsItemTypeManagedByAccounts(Sbm.ItemType.Commodity)) + { + if (AccountsDfn.IsUsingSageInterface()) + imageFolder = AccountsDfn.GetImageFolder(Sbm.InterfaceType_Accounts.SageLine50); + } + //ToDo SaSystem::GETPATHDELIM in SbmCmdMgr need to be created inorder to work + cmdImagePath = imageFolder + /*SaSystem::GetPathDelim(imageFolder) +*/ cmdImagePath.Right(cmdImagePath.Length - imagePathPrefix.Length); + } +#if _DEBUG_XXX + if (!sCmdImagePath.IsEmpty()) + { + SATRACE("GetActualImagePath Path = '" + cmdImagePath + "'\n"); + } +#endif + return cmdImagePath; + } + + public String GetStandardImagePath(String commodityCode) + { + // Using organisation configuration image folder. + if (StringUtil.IsEmpty(commodityCode)) return commodityCode; + String path = ""; + if (!StringUtil.IsEmpty(commodityCode)) + { + String folder = UserContext.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityImage); + path = GetImagePath(folder, commodityCode); + } + return path; + } + public String GetBarcodeImagePath(String commodityCode) + { + // Using organisation configuration barcode image folder. + if (StringUtil.IsEmpty(commodityCode)) return commodityCode; + String path = ""; + if (!StringUtil.IsEmpty(commodityCode)) + { + String folder = UserContext.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityBarcodeImage); + path = GetImagePath(folder, commodityCode); + } + return path; + } + + public String GetImagePath(String folder, String filenamePrefix) + { + String path = ""; + //SATRACE("SapCommodityMgr::GetImagePath Locating image file '"+sFilenamePrefix+"' in folder '"+sFolder+"'\n"); + if (!folder.IsEmpty() && Directory.Exists(folder) && !filenamePrefix.IsEmpty()) + { + List imageExtensions = StringListUtil.Split("jpg,jpeg,gif,png,tif,eps", ","); + foreach (String imageExtension in imageExtensions) + { + //ToDo SaSystem::GETPATHDELIM in SbmCmdMgr need to be created inorder to work + path = folder + /*SaSystem::GetPathDelim(folder) +*/ filenamePrefix + "." + imageExtension; +#if _DEBUG + if (Sys_Fn::FileExists(path)) + { + SATRACE("GetImagePath Found image file: " + path + "\n"); + } +#endif + if (!Directory.Exists(path)) path.IsEmpty(); + } + } + return path; + } + + //------------------------------------------------------------------- + public abstract List GetCommodityTypesInUse(); + public abstract Sbm.CommodityType GetTypeForCommodityId(SysId commodityId); + public abstract double GetCostPriceForCommodityId(SysId commodityId); + public abstract List GetSalesTemplateCommmodities(); + public abstract bool UpdateReferencesToSalesTemplate(SbmCommodity commodity); + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity.cs index c070aff..c715e95 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity.cs @@ -13,293 +13,20 @@ using System.Threading.Tasks; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Commodity Manager - Commodity. //======================================================================= partial class SbmCommodityMgr { - public object StringList { get; private set; } - - //******************************************************************* - // C o m m o d i t i e s - //******************************************************************* + //------------------------------------------------------------------- // Utilities. public bool IsValidCode(String code) { - if (StringUtil.IsEmpty(code)) return false; + if (StringUtil.IsBlank(code)) return false; if (code != code.Trim(' ')) return false; return true; } - // Commodity interface rules. - public bool AllowColumnImport(SbmCommodity.Column column) - { - switch (column) - { - //case SbmCommodity.Column.Id: - //case SbmCommodity.Column.AffIdOwner: - //case SbmCommodity.Column.Type: - case SbmCommodity.Column.Code: - case SbmCommodity.Column.DescBrief: - case SbmCommodity.Column.DescOrder: - case SbmCommodity.Column.DescDetail: - case SbmCommodity.Column.DrawingNo: - case SbmCommodity.Column.DrawingIssue: - case SbmCommodity.Column.ImagePath: - case SbmCommodity.Column.Category1Code: - case SbmCommodity.Column.Category2Code: - case SbmCommodity.Column.Category3Code: - case SbmCommodity.Column.Location: - case SbmCommodity.Column.Department: - case SbmCommodity.Column.CatalogRef: - case SbmCommodity.Column.Weight: - case SbmCommodity.Column.Weight_UomId: - case SbmCommodity.Column.Length: - case SbmCommodity.Column.Length_UomId: - case SbmCommodity.Column.Volume: - case SbmCommodity.Column.Volume_UomId: - case SbmCommodity.Column.Density: - case SbmCommodity.Column.Density_UomId: - case SbmCommodity.Column.BoxQuantity: - case SbmCommodity.Column.BoxQuantity_UomId: - case SbmCommodity.Column.Dimensions: - case SbmCommodity.Column.SpecSummary: - case SbmCommodity.Column.NominalCode: - case SbmCommodity.Column.NominalCodePurchase: - case SbmCommodity.Column.ICNTariffCode: - //case SbmCommodity.Column.TimeProd: - //case SbmCommodity.Column.UomIdTimeProd: - //case SbmCommodity.Column.RangeCode: - //case SbmCommodity.Column.ColourCode: - //case SbmCommodity.Column.SourceCode: - //case SbmCommodity.Column.SupplyMethodCode: - //case SbmCommodity.Column.HandlingCode: - //case SbmCommodity.Column.DeliveryCode: - case SbmCommodity.Column.MaterialCode: - case SbmCommodity.Column.FinishCode: - case SbmCommodity.Column.PromotionCode: - case SbmCommodity.Column.AssociationIdSupplier: - case SbmCommodity.Column.Supplier_Ref: - case SbmCommodity.Column.CostPrice: - case SbmCommodity.Column.PlaceOfOrigin: - case SbmCommodity.Column.MaterialCost: - case SbmCommodity.Column.MaterialCurrencyId: - case SbmCommodity.Column.ExWorksCost: - case SbmCommodity.Column.ExWorksCurrencyId: - case SbmCommodity.Column.ReorderLevel: - case SbmCommodity.Column.ReorderQty: - //case SbmCommodity.Column.QtyOnOrder: - case SbmCommodity.Column.AssociationIdCustomer: - case SbmCommodity.Column.SalesPrice: - case SbmCommodity.Column.RetailPrice: - case SbmCommodity.Column.RetailPricePlanned: - case SbmCommodity.Column.UomIdSale: - case SbmCommodity.Column.CarriageCostIndicative: - //case SbmCommodity.Column.CarriageCostIndicative_Fmt: - case SbmCommodity.Column.MinOrderQty: - case SbmCommodity.Column.PackQty: - case SbmCommodity.Column.TaxCodeId: - //case SbmCommodity.Column.LastOrderDate: - //case SbmCommodity.Column.LastOrderQty: - //case SbmCommodity.Column.QtyInStock: - //case SbmCommodity.Column.QtyAllocated: - //case SbmCommodity.Column.FreeStock: - //case SbmCommodity.Column.StockTakeDate: - //case SbmCommodity.Column.StockTakeQty: - //case SbmCommodity.Column.OrderQtyDecimals: - case SbmCommodity.Column.CommodityIdSalesProj: - //case SbmCommodity.Column.SalesProjMonthlyProp: - case SbmCommodity.Column.SalesProj_Annual: - case SbmCommodity.Column.SalesProjMonth01: - case SbmCommodity.Column.SalesProjMonth02: - case SbmCommodity.Column.SalesProjMonth03: - case SbmCommodity.Column.SalesProjMonth04: - case SbmCommodity.Column.SalesProjMonth05: - case SbmCommodity.Column.SalesProjMonth06: - case SbmCommodity.Column.SalesProjMonth07: - case SbmCommodity.Column.SalesProjMonth08: - case SbmCommodity.Column.SalesProjMonth09: - case SbmCommodity.Column.SalesProjMonth10: - case SbmCommodity.Column.SalesProjMonth11: - case SbmCommodity.Column.SalesProjMonth12: - case SbmCommodity.Column.Notes: - //case SbmCommodity.Column.Flags: - //case SbmCommodity.Column.Status: - //case SbmCommodity.Column.CreateOn: - //case SbmCommodity.Column.CreateBy: - //case SbmCommodity.Column.CreateHost: - //case SbmCommodity.Column.UpdateOn: - //case SbmCommodity.Column.UpdateBy: - //case SbmCommodity.Column.UpdateHost: - return true;//return ConfigConsole.DisplayAttribute(column); - } - return false; - } - public String GetColumnCode(SbmCommodity.Column column) - { - switch (column) - { - case SbmCommodity.Column.Type: - case SbmCommodity.Column.Type_Code: - case SbmCommodity.Column.Type_Desc: - return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Type, "Type"); - case SbmCommodity.Column.Code: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Code, "Code"); - case SbmCommodity.Column.DescBrief: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DescBrief, "Brief description"); - case SbmCommodity.Column.DescOrder: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DescOrder, "Order description"); - case SbmCommodity.Column.DescDetail: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DescDetail, "Detail description"); - case SbmCommodity.Column.DrawingNo: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DrawingNo, "Drawing no"); - case SbmCommodity.Column.DrawingIssue: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue, "Drawing issue"); - case SbmCommodity.Column.ImagePath: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ImagePath, "Image path"); - case SbmCommodity.Column.Category1Code: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Category, "Category"); - case SbmCommodity.Column.Location: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Location, "Location"); - case SbmCommodity.Column.Department: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Department, "Department"); - case SbmCommodity.Column.CatalogRef: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_CatalogRef, "Catalog ref"); - case SbmCommodity.Column.Weight: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Weight, "Weight"); - case SbmCommodity.Column.Weight_UomId: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdWeight, "Weight unit"); - case SbmCommodity.Column.Length: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Length, "Length"); - case SbmCommodity.Column.Length_UomId: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdLength, "Length unit"); - case SbmCommodity.Column.Volume: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Volume, "Volume"); - case SbmCommodity.Column.Volume_UomId: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdVolume, "Volume unit"); - case SbmCommodity.Column.Density: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Density, "Density"); - case SbmCommodity.Column.Density_UomId: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdDensity, "Density unit"); - case SbmCommodity.Column.BoxQuantity: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity, "Box quantity"); - case SbmCommodity.Column.BoxQuantity_UomId: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdBox, "Box unit"); - case SbmCommodity.Column.Dimensions: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_Dimensions, "Dimensions"); - case SbmCommodity.Column.SpecSummary: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SpecSummary, "Specification"); - case SbmCommodity.Column.NominalCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_NominalCode, "Nominal code - sales"); - case SbmCommodity.Column.NominalCodePurchase: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_NominalCodePurchase, "Nominal code - purchase"); - case SbmCommodity.Column.ICNTariffCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode, "ICN Tariff code"); - case SbmCommodity.Column.MaterialCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material"); - case SbmCommodity.Column.FinishCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish"); - case SbmCommodity.Column.PromotionCode: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion"); - case SbmCommodity.Column.AssociationIdSupplier: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_AssIdSupplier, "Supplier"); - case SbmCommodity.Column.Supplier_Ref: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SupplierRef, "Supplier ref"); - case SbmCommodity.Column.CostPrice: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_CostPrice, "Cost price"); - case SbmCommodity.Column.PlaceOfOrigin: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin, "Place of origin"); - case SbmCommodity.Column.MaterialCost: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_MaterialCost, "Material cost"); - case SbmCommodity.Column.MaterialCurrencyId: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial, "Material currency"); - case SbmCommodity.Column.ExWorksCost: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost, "Ex-works cost"); - case SbmCommodity.Column.ExWorksCurrencyId: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks, "Ex-works currency"); - case SbmCommodity.Column.ReorderLevel: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ReorderLevel, "Reorder level"); - case SbmCommodity.Column.ReorderQty: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_ReorderQty, "Reorder qty"); - case SbmCommodity.Column.AssociationIdCustomer: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_AssIdCustomer, "Customer"); - case SbmCommodity.Column.SalesPrice: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesPrice, "Sales price"); - case SbmCommodity.Column.RetailPrice: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_RetailPrice, "Retail price"); - case SbmCommodity.Column.RetailPricePlanned: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned, "Retail price planned"); - case SbmCommodity.Column.UomIdSale: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_UomIdSale, "Sale unit"); - case SbmCommodity.Column.PackQty: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PackQty, "Pack qty - sale"); - case SbmCommodity.Column.TaxCodeId: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_TaxCodeId, "Tax code"); - case SbmCommodity.Column.SalesProj_Annual: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual, "Projected annual sales"); - case SbmCommodity.Column.SalesProjMonth01: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01, "Projected sales - Jan"); - case SbmCommodity.Column.SalesProjMonth02: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth02, "Projected sales - Feb"); - case SbmCommodity.Column.SalesProjMonth03: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth03, "Projected sales - Mar"); - case SbmCommodity.Column.SalesProjMonth04: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth04, "Projected sales - Apr"); - case SbmCommodity.Column.SalesProjMonth05: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth05, "Projected sales - May"); - case SbmCommodity.Column.SalesProjMonth06: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth06, "Projected sales - Jun"); - case SbmCommodity.Column.SalesProjMonth07: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth07, "Projected sales - Jul"); - case SbmCommodity.Column.SalesProjMonth08: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth08, "Projected sales - Aug"); - case SbmCommodity.Column.SalesProjMonth09: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth09, "Projected sales - Sep"); - case SbmCommodity.Column.SalesProjMonth10: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth10, "Projected sales - Oct"); - case SbmCommodity.Column.SalesProjMonth11: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11, "Projected sales - Nov"); - case SbmCommodity.Column.SalesProjMonth12: return GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12, "Projected sales - Dec"); - } - return ""; - } - // Image Paths. - public String GetImagePathPrefix() - { - String prefix = ""; - if (AccountsDfn.IsItemTypeManagedByAccounts(Sbm.ItemType.Commodity)) - { - if (AccountsDfn.IsUsingSageInterface()) - prefix = "%SAGE%\\"; - } - return prefix; - } - public String GetActualImagePath(String imagePath) - { - //SATRACE("SapCommodityMgr::GetActualImagePath '"+imagePath+"'\n"); - if (StringUtil.IsEmpty(imagePath)) return imagePath; - String imagePathPrefix = GetImagePathPrefix(); - String cmdImagePath = imagePath; - if (cmdImagePath.Left(imagePathPrefix.Length) == imagePathPrefix) - { - String imageFolder = ""; - if (AccountsDfn.IsItemTypeManagedByAccounts(Sbm.ItemType.Commodity)) - { - if (AccountsDfn.IsUsingSageInterface()) - imageFolder = AccountsDfn.GetImageFolder(Sbm.InterfaceType_Accounts.SageLine50); - } - //ToDo SaSystem::GETPATHDELIM in SbmCmdMgr need to be created inorder to work - cmdImagePath = imageFolder + /*SaSystem::GetPathDelim(imageFolder) +*/ cmdImagePath.Right(cmdImagePath.Length - imagePathPrefix.Length); - } -#if _DEBUG_XXX - if (!sCmdImagePath.IsEmpty()) - { - SATRACE("GetActualImagePath Path = '" + cmdImagePath + "'\n"); - } -#endif - return cmdImagePath; - } - - public String GetStandardImagePath(String commodityCode) - { - // Using organisation configuration image folder. - if (StringUtil.IsEmpty(commodityCode)) return commodityCode; - String path = ""; - if (!StringUtil.IsEmpty(commodityCode)) - { - String folder = UserContext.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityImage); - path = GetImagePath(folder, commodityCode); - } - return path; - } - public String GetBarcodeImagePath(String commodityCode) - { - // Using organisation configuration barcode image folder. - if (StringUtil.IsEmpty(commodityCode)) return commodityCode; - String path = ""; - if (!StringUtil.IsEmpty(commodityCode)) - { - String folder = UserContext.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityBarcodeImage); - path = GetImagePath(folder, commodityCode); - } - return path; - } - - public String GetImagePath(String folder, String filenamePrefix) - { - String path = ""; - //SATRACE("SapCommodityMgr::GetImagePath Locating image file '"+sFilenamePrefix+"' in folder '"+sFolder+"'\n"); - if (!folder.IsEmpty() && Directory.Exists(folder) && !filenamePrefix.IsEmpty()) - { - List imageExtensions = StringListUtil.Split("jpg,jpeg,gif,png,tif,eps", ","); - foreach (String imageExtension in imageExtensions) - { - //ToDo SaSystem::GETPATHDELIM in SbmCmdMgr need to be created inorder to work - path = folder + /*SaSystem::GetPathDelim(folder) +*/ filenamePrefix + "." + imageExtension; -#if _DEBUG - if (Sys_Fn::FileExists(path)) - { - SATRACE("GetImagePath Found image file: " + path + "\n"); - } -#endif - if (!Directory.Exists(path)) path.IsEmpty(); - } - } - return path; - } - - public abstract List GetCommodityTypesInUse(); - public abstract Sbm.CommodityType GetTypeForCommodityId(SysId commodityId); - public abstract double GetCostPriceForCommodityId(SysId commodityId); - public abstract List GetSalesTemplateCommmodities(); - public abstract bool UpdateReferencesToSalesTemplate(SbmCommodity commodity); - - public abstract String BuildSalesQuantityQuery(DateTime earliest, DateTime latest, bool completeOrders, String tableAliasCommodity);// Sales Quantity Query. - public abstract String BuildAllocatedStockQuery(List locIds);// Allocated Stock Query. - public abstract String BuildCurrentStockQuery(List locIds);// Currency Stock Query. - public abstract String BuildPlannedStockMovementsQuery(DateTime earliest, DateTime latest, SbmCommodity.Params prmCmd, bool intoStock, bool provisional, String tableAliasCommodity);// Stock Movements Query. - public abstract void PopulateLocationIdLists();// Populate LocationId Lists. - //------------------------------------------------------------------- // Retrieve individual commodities. //------------------------------------------------------------------- @@ -309,7 +36,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(commodityId)) return false; SbmCommodity.Params prmCommodity = new SbmCommodity.Params(); - prmCommodity.IncludedIds.Add(commodityId); + prmCommodity.IdsIncluded.Add(commodityId); prmCommodity.StatusCat = SbmCommodity.StatusCat.Any; return GetCommodityCount(prmCommodity) == 1; } @@ -343,7 +70,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(commodityId)) return null; SbmCommodity.Params prmCommodity = new SbmCommodity.Params(); - prmCommodity.IncludedIds.Add(commodityId); + prmCommodity.IdsIncluded.Add(commodityId); prmCommodity.StatusCat = SbmCommodity.StatusCat.Any; return GetCommodity(prmCommodity); } @@ -567,7 +294,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmCommodity.Column)column.Id) { - //--------------------------------------------------------------- + //----------------------------------------------------------- // Commodity TypeDesc. case SbmCommodity.Column.Type_Code: case SbmCommodity.Column.Type_Desc: @@ -590,7 +317,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Weight units. case SbmCommodity.Column.Weight_Unit: { @@ -739,7 +466,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Commodity Codings Description. case SbmCommodity.Column.RangeDesc: { @@ -796,7 +523,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Commodity Formatted Currency Values. case SbmCommodity.Column.CostPrice_Fmt: { @@ -905,7 +632,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Customer Definition. /*case SbmCommodity.Column.Cust_ProductCode: case SbmCommodity.Column.Cust_AmountRetail:*/ @@ -942,7 +669,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr case SbmCommodity.Column.Cust_PromotionDesc: break;*/ - //--------------------------------------------------------------- + //----------------------------------------------------------- // Stock Bays. case SbmCommodity.Column.Stock_Bays: { @@ -1014,7 +741,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- + // Barcode Images. + case SbmCommodity.Column.BarcodeImagePath: + { + String commodityCode = values.GetValue(GetCommodityColumnDfn(SbmCommodity.Column.Code).DataName).ToString(); + value = new DataValue(GetBarcodeImagePath(commodityCode)); + break; + } + + //----------------------------------------------------------- // Commodity Notes. case SbmCommodity.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -1045,14 +781,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - // Barcode Images. - case SbmCommodity.Column.BarcodeImagePath: - { - String commodityCode = values.GetValue(GetCommodityColumnDfn(SbmCommodity.Column.Code).DataName).ToString(); - value = new DataValue(GetBarcodeImagePath(commodityCode)); - break; - } - //--------------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_CommodityCustomer.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_CommodityCustomer.cs index 2bbe364..aec0213 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_CommodityCustomer.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_CommodityCustomer.cs @@ -11,12 +11,11 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Commodity Manager - Commodity Customer. //======================================================================= partial class SbmCommodityMgr { - //******************************************************************* - // C o m m o d i t y C u s t o m e r s - //******************************************************************* //------------------------------------------------------------------- // Utilities. public abstract bool CanManageCommodityCustomers(); @@ -30,7 +29,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(commodityCustomerId)) return false; SbmCommodityCustomer.Params prmCommodityCustomer = new SbmCommodityCustomer.Params(); - prmCommodityCustomer.IncludedIds.Add(commodityCustomerId); + prmCommodityCustomer.IdsIncluded.Add(commodityCustomerId); prmCommodityCustomer.StatusCat = SbmCommodityCustomer.StatusCat.Any; return GetCommodityCustomerCount(prmCommodityCustomer) == 1; } @@ -165,7 +164,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmCommodityCustomer.Column)column.Id) { - //--------------------------------------------------------------- + //----------------------------------------------------------- // Commodity Category. case SbmCommodityCustomer.Column.Commodity_CategoryDesc: { @@ -193,7 +192,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmCommodityCustomer.GetStatusTriState(status)); } break; - //--------------------------------------------------------------- + + //----------------------------------------------------------- // CmdCustomer Formatted currency values. case SbmCommodityCustomer.Column.AmountRetail_Fmt: { @@ -226,8 +226,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; }*/ - - //--------------------------------------------------------------- + //----------------------------------------------------------- // Promotion Description. case SbmCommodityCustomer.Column.PromotionDesc: { @@ -236,7 +235,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Notes. case SbmCommodityCustomer.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -254,7 +253,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmCommodityCustomer.GetStatusTriState(status)); break; } - //--------------------------------------------------------------- + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_CommoditySupplier.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_CommoditySupplier.cs index 346576e..1475641 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_CommoditySupplier.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_CommoditySupplier.cs @@ -9,12 +9,11 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Commodity Manager - Commodity Supplier. //======================================================================= partial class SbmCommodityMgr { - //******************************************************************* - // C o m m o d i t y S u p p l i e r s - //******************************************************************* //------------------------------------------------------------------- // Utilities. public abstract bool CanManageCommoditySuppliers(); @@ -28,7 +27,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(commoditySupplierId)) return false; SbmCommoditySupplier.Params prmCommoditySupplier = new SbmCommoditySupplier.Params(); - prmCommoditySupplier.IncludedIds.Add(commoditySupplierId); + prmCommoditySupplier.IdsIncluded.Add(commoditySupplierId); prmCommoditySupplier.StatusCat = SbmCommoditySupplier.StatusCat.Any; return GetCommoditySupplierCount(prmCommoditySupplier) == 1; } @@ -42,7 +41,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(commoditySupplierId)) return null; SbmCommoditySupplier.Params prmCommoditySupplier = new SbmCommoditySupplier.Params(); - prmCommoditySupplier.IncludedIds.Add(commoditySupplierId); + prmCommoditySupplier.IdsIncluded.Add(commoditySupplierId); prmCommoditySupplier.StatusCat = SbmCommoditySupplier.StatusCat.Any; return GetCommoditySupplier(prmCommoditySupplier); } @@ -142,7 +141,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmCommoditySupplier.Column)column.Id) { - //--------------------------------------------------------------- + //----------------------------------------------------------- // Commodity Category. case SbmCommoditySupplier.Column.Commodity_CategoryDesc: { @@ -170,11 +169,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmCommoditySupplier.GetStatusTriState(status)); } break; - //--------------------------------------------------------------- + + //----------------------------------------------------------- // CmdCustomer Formatted currency values. - - //--------------------------------------------------------------- + //----------------------------------------------------------- // Notes. case SbmCommoditySupplier.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -192,7 +191,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmCommoditySupplier.GetStatusTriState(status)); break; } - //--------------------------------------------------------------- + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Container.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Container.cs index 6dac002..20b8ced 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Container.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Container.cs @@ -10,12 +10,11 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Commodity Manager - Container. //======================================================================= partial class SbmCommodityMgr { - //******************************************************************* - // C o n t a i n e r s - //******************************************************************* //------------------------------------------------------------------- // Utilities. @@ -28,7 +27,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(containerId)) return false; SbmContainer.Params prmContainer = new SbmContainer.Params(); - prmContainer.IncludedIds.Add(containerId); + prmContainer.IdsIncluded.Add(containerId); return GetContainerCount(prmContainer) == 1; } @@ -53,7 +52,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(containerId)) return null; SbmContainer.Params prmContainer = new SbmContainer.Params(); - prmContainer.IncludedIds.Add(containerId); + prmContainer.IdsIncluded.Add(containerId); return GetContainer(prmContainer); } @@ -196,7 +195,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Notes. case SbmContainer.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -214,7 +213,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmContainer.GetStatusTriState(status)); break; } - //----------------------------------------------------------- + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_ContainerItem.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_ContainerItem.cs index 9f79658..298d5ac 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_ContainerItem.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_ContainerItem.cs @@ -9,12 +9,11 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Commodity Manager - Container Item. //======================================================================= partial class SbmCommodityMgr { - //******************************************************************* - // C o n t a i n e r s - //******************************************************************* //------------------------------------------------------------------- // Utilities. public abstract String GetItemSource(Sbm.ItemType itemType, SysId itemId, bool brief = false); @@ -29,7 +28,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(containerItemId)) return false; SbmContainerItem.Params prmContainerItem = new SbmContainerItem.Params(); - prmContainerItem.IncludedIds.Add(containerItemId); + prmContainerItem.IdsIncluded.Add(containerItemId); return GetContainerItemCount(prmContainerItem) == 1; } @@ -42,7 +41,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(containerItemId)) return null; SbmContainerItem.Params prmContainerItem = new SbmContainerItem.Params(); - prmContainerItem.IncludedIds.Add(containerItemId); + prmContainerItem.IdsIncluded.Add(containerItemId); return GetContainerItem(prmContainerItem); } @@ -163,7 +162,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmContainerItem.Column)column.Id) { - //--------------------------------------------------------------- + //----------------------------------------------------------- // Notes. case SbmContainerItem.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -181,7 +180,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmContainerItem.GetStatusTriState(status)); break; } - //----------------------------------------------------------- + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_PortfolioItem.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_PortfolioItem.cs index 22a0cc0..0481bba 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_PortfolioItem.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_PortfolioItem.cs @@ -12,12 +12,12 @@ using static Sarand.Net.Standard.Base.Interfaces.SaInterfaceConsole; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Commodity Manager - Portfolio Item. //======================================================================= partial class SbmCommodityMgr { - //******************************************************************* - // P o r t f o l i o I t e m - //******************************************************************* + //------------------------------------------------------------------- // Utilities. //------------------------------------------------------------------- @@ -91,7 +91,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(portfolioItemId)) return false; SbmPortfolioItem.Params prmPortfolioItem = new SbmPortfolioItem.Params(); - prmPortfolioItem.IncludedIds.Add(portfolioItemId); + prmPortfolioItem.IdsIncluded.Add(portfolioItemId); prmPortfolioItem.StatusCat = SbmPortfolioItem.StatusCat.Any; return GetPortfolioItemCount(prmPortfolioItem) == 1; } @@ -116,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(portfolioItemId)) return null; SbmPortfolioItem.Params prmPortfolioItem = new SbmPortfolioItem.Params(); - prmPortfolioItem.IncludedIds.Add(portfolioItemId); + prmPortfolioItem.IdsIncluded.Add(portfolioItemId); prmPortfolioItem.StatusCat = SbmPortfolioItem.StatusCat.Any; return GetPortfolioItem(prmPortfolioItem); } @@ -293,7 +293,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs index 2918912..ca3eb70 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs @@ -20,8 +20,8 @@ using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { - //======================================================================= - public abstract class SbmCoreMgr : SbmItemMgr + //======================================================================= + public abstract class SbmCoreMgr : SbmItemMgr { //------------------------------------------------------------------- // System code cache. @@ -180,7 +180,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr protected SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } } protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } } // Consoles. - protected SbmConfigConsole ConfigConsole { get { return Internals.ConfigConsole; } } + protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } } protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } } protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } } @@ -243,23 +243,23 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr // Configuration console utilities. public bool AllowConfigOption(Sbm.ConfigOption configOption) { - return ConfigConsole.AllowOption(UserContext, configOption); + return SessionConsole.AllowOption(configOption); } public bool AllowAffiliateType(Sbm.AffiliateType affiliateType) { - return ConfigConsole.AllowAffiliateType(UserContext, affiliateType); + return SessionConsole.AllowAffiliateType(affiliateType); } public bool AllowAssociationType(Sbm.AssociationType associationType) { - return ConfigConsole.AllowAssociationType(UserContext, associationType); + return SessionConsole.AllowAssociationType(associationType); } public bool AllowTransactionType(Sbm.TransactionType transactionType) { - return ConfigConsole.AllowTransactionType(UserContext, transactionType); + return SessionConsole.AllowTransactionType(transactionType); } public String GetAttributeCaption(SbmDbDfn.ColumnIdx columnIdx, String defaultValue) { - return ConfigConsole.GetAttributeCaption(UserContext, columnIdx, defaultValue); + return SessionConsole.GetAttributeCaption(columnIdx, defaultValue); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr.cs index 075b827..41872e4 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr.cs @@ -3,6 +3,8 @@ using Sarand.BusinessMgr.Net.Standard.Base.Core; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Data Item Manager. //======================================================================= public abstract partial class SbmDataItemMgr : SbmCoreMgr { diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemBatch.cs b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemBatch.cs index 3cf3f0a..6bd5369 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemBatch.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemBatch.cs @@ -10,12 +10,11 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Data Item Manager - Item Batches. //======================================================================= partial class SbmDataItemMgr { - //******************************************************************* - // I t e m B a t c h e s - //******************************************************************* //------------------------------------------------------------------- // Utilities. @@ -28,7 +27,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(itemBatchId)) return false; SbmItemBatch.Params prmItemBatch = new SbmItemBatch.Params(); - prmItemBatch.IncludedIds.Add(itemBatchId); + prmItemBatch.IdsIncluded.Add(itemBatchId); prmItemBatch.StatusCat = SbmItemBatch.StatusCat.Any; return GetItemBatchCount(prmItemBatch) == 1; } @@ -51,7 +50,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(itemBatchId)) return null; SbmItemBatch.Params prmItemBatch = new SbmItemBatch.Params(); - prmItemBatch.IncludedIds.Add(itemBatchId); + prmItemBatch.IdsIncluded.Add(itemBatchId); prmItemBatch.StatusCat = SbmItemBatch.StatusCat.Any; return GetItemBatch(prmItemBatch); } @@ -165,6 +164,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmItemBatch.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmItemBatch.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -183,7 +183,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemLink-Utils.cs b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemLink-Utils.cs new file mode 100644 index 0000000..7666673 --- /dev/null +++ b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemLink-Utils.cs @@ -0,0 +1,79 @@ +using Sarand.BusinessMgr.Net.Standard.Base.App; +using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Utils; +using System; +using System.Collections.Generic; + +namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr +{ + //======================================================================= + // Data Item Manager - Item Links - Utils. + //======================================================================= + partial class SbmDataItemMgr + { + //------------------------------------------------------------------- + // Utilities. + public static Sbm.ItemLinkType GetLinkType(Sbm.ApplCodeType applCodeType) + { + switch (applCodeType) + { + case Sbm.ApplCodeType.SeasonalCategory: return Sbm.ItemLinkType.ItemCodeList_SeasonalCategory; + case Sbm.ApplCodeType.PostcodeArea: return Sbm.ItemLinkType.ItemCodeList_PostcodeArea; + case Sbm.ApplCodeType.JobTrade: return Sbm.ItemLinkType.ItemCodeList_JobTrade; + case Sbm.ApplCodeType.JobEngineer: return Sbm.ItemLinkType.ItemCodeList_JobEngineer; + } + return Sbm.ItemLinkType.Unknown; + } + + //------------------------------------------------------------------- + // Clean up data issues/inconsistencies. + public abstract bool DoDbCleanup(); + + // Clear all associated data for item - attributes and links. + public abstract bool ClearDataItem(Sbm.ItemType itemType, SysId itemId); + + //------------------------------------------------------------------- + // Linked Items. + + public static bool ItemLinkParentIsFixed(Sbm.AssociatedItemMode itemMode) + { + switch (itemMode) + { + case Sbm.AssociatedItemMode.Commodity_Parent: + case Sbm.AssociatedItemMode.Requirement_Parent: + return true; + } + return false; + } + + public static bool ItemLinkChildIsFixed(Sbm.AssociatedItemMode itemMode) + { + switch (itemMode) + { + case Sbm.AssociatedItemMode.Commodity_Child: + case Sbm.AssociatedItemMode.Requirement_Child: + return true; + } + return false; + } + + public static bool ItemLinkConfigIsValid(Sbm.AssociatedItemMode itemMode, Sbm.ItemLinkType itemLinkType) + { + switch (itemMode) + { + case Sbm.AssociatedItemMode.Commodity_Child: + case Sbm.AssociatedItemMode.Requirement_Child: + return true; + } + return false; + } + public abstract bool UpdateLinkedItems(Sbm.AssociatedItemMode itemMode, Sbm.ItemLinkType itemLinkType, ref ItemId itemIdParent, ref ItemId itemIdChild, ItemId itemId, List itemLinks); + + //------------------------------------------------------------------- + } + //======================================================================= +} \ No newline at end of file diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemLink.cs b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemLink.cs index 5f9c5a4..0d4de39 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemLink.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr_ItemLink.cs @@ -10,48 +10,27 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { + //======================================================================= + // Data Item Manager - Item Links. //======================================================================= partial class SbmDataItemMgr { - //******************************************************************* - // I t e m L i n k s - //******************************************************************* - - //------------------------------------------------------------------- - // Utilities. - public static Sbm.ItemLinkType GetLinkType(Sbm.ApplCodeType applCodeType) - { - switch (applCodeType) - { - case Sbm.ApplCodeType.SeasonalCategory: return Sbm.ItemLinkType.ItemCodeList_SeasonalCategory; - case Sbm.ApplCodeType.PostcodeArea: return Sbm.ItemLinkType.ItemCodeList_PostcodeArea; - case Sbm.ApplCodeType.JobTrade: return Sbm.ItemLinkType.ItemCodeList_JobTrade; - case Sbm.ApplCodeType.JobEngineer: return Sbm.ItemLinkType.ItemCodeList_JobEngineer; - } - return Sbm.ItemLinkType.Unknown; - } - - // Clean up data issues/inconsistencies. - public abstract bool DoDbCleanup(); - // Clear all associated data for item - attributes and links. - public abstract bool ClearDataItem(Sbm.ItemType itemType, SysId itemId); - //------------------------------------------------------------------- // Retrieve individual itemLinks. //------------------------------------------------------------------- - // ItemLink exists. + // Item exists. public bool ItemLinkExistsById(SysId itemLinkId) { ClearErrorState(); if (!SysId.IsValid(itemLinkId)) return false; SbmItemLink.Params prmItemLink = new SbmItemLink.Params(); - prmItemLink.IncludedIds.Add(itemLinkId); + prmItemLink.IdsIncluded.Add(itemLinkId); prmItemLink.StatusCat = SbmItemLink.StatusCat.Any; return GetItemLinkCount(prmItemLink) == 1; } //------------------------------------------------------------------- - // Get itemLinks. + // Get items. public abstract SbmItemLink GetItemLink(SbmItemLink.Params prm); public SbmItemLink GetItemLinkById(SysId itemLinkId) @@ -59,21 +38,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(itemLinkId)) return null; SbmItemLink.Params prmItemLink = new SbmItemLink.Params(); - prmItemLink.IncludedIds.Add(itemLinkId); + prmItemLink.IdsIncluded.Add(itemLinkId); prmItemLink.StatusCat = SbmItemLink.StatusCat.Any; return GetItemLink(prmItemLink); } //------------------------------------------------------------------- - // Create itemLinks. + // Create items. public abstract SbmItemLink CreateItemLink(Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo); //------------------------------------------------------------------- - // Has itemLinks. + // Has items. public abstract bool HasItemLinks(Sbm.ItemType itemType, SysId itemId); //------------------------------------------------------------------- - // Validate Item Link data. + // Validate item data. public bool IsValidItemLink(SbmItemLink itemLink) { ClearErrorState(); @@ -83,7 +62,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr public virtual bool IsValidItemLinkData(SbmItemLink.Data data, SbmItemLink.ErrField errField) { ClearErrorState(); - // ItemLink properties. + // Item properties. if (errField.ItemLinkType != SacsHierarchyItem.ValidValue.Ignore) { if ((int)data.ItemLinkType < 1) @@ -157,11 +136,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } //------------------------------------------------------------------- - // ItemLink database interface. + // Item database interface. public abstract bool InsertItemLink(SbmItemLink itemLink, DbUpdateInfo dbUpdateInfo); public abstract bool UpdateItemLink(SbmItemLink itemLink, DbUpdateInfo dbUpdateInfo); - public abstract bool StoreFromItemLinks(Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, List itemLinks, DbUpdateInfo dbUpdateInfo); - public abstract bool StoreToItemLinks(Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeTo, SysId itemIdTo, List itemLinks, DbUpdateInfo dbUpdateInfo); + public abstract bool StoreFromItemLinks(Sbm.ItemLinkType itemLinkType, ItemId itemIdFrom, List itemLinks, DbUpdateInfo dbUpdateInfo); + public abstract bool StoreToItemLinks(Sbm.ItemLinkType itemLinkType, ItemId itemIdTo, List itemLinks, DbUpdateInfo dbUpdateInfo); public virtual bool ItemLinkCanBeDeleted(SbmItemLink itemLink) { @@ -172,7 +151,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr public abstract bool DeleteItemLink(SbmItemLink itemLink, DbUpdateInfo dbUpdateInfo); //------------------------------------------------------------------- - // ItemLink list. + // Item list. public abstract ColumnDfn GetItemLinkColumnDfn(SbmItemLink.Column columnId, String caption = "", int width = 0); public abstract List GetItemLinkQueryFilter(SbmItemLink.Params prm); public abstract long GetItemLinkCount(SbmItemLink.Params prm); @@ -191,6 +170,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmItemLink.Column)column.Id) { + //----------------------------------------------------------- // Notes. case SbmItemLink.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -209,7 +189,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr-Price.cs b/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr-Price.cs index fe5a7c5..8895989 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr-Price.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr-Price.cs @@ -140,6 +140,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmPrice.Column)column.Id) { + //----------------------------------------------------------- // Price type. case SbmPrice.Column.PriceType_Desc: { @@ -147,6 +148,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(PriceTypes.GetDescForType(priceType, priceType > 0 ? priceType.ToString() : "")); break; } + + //----------------------------------------------------------- // Calculation method. case SbmPrice.Column.CalculationMethod_Desc: { @@ -154,6 +157,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(PriceCalculationMethods.GetDescForType(calculationMethod, calculationMethod > 0 ? calculationMethod.ToString() : "")); break; } + + //----------------------------------------------------------- // Rounder method. case SbmPrice.Column.RounderMethod_Desc: { @@ -161,6 +166,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(PriceRounderMethods.GetDescForType(rounderMethod, rounderMethod > 0 ? rounderMethod.ToString() : "")); break; } + // Rounder direction. case SbmPrice.Column.RounderDirection_Desc: { @@ -168,6 +174,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(PriceRounderDirections.GetDescForType(rounderDirection, rounderDirection > 0 ? rounderDirection.ToString() : "")); break; } + + //----------------------------------------------------------- // Sales dicount. case SbmPrice.Column.SalesDiscountPercent: { @@ -196,12 +204,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(salesDiscountPercent); break; } + + //----------------------------------------------------------- // Notes. case SbmPrice.Column.Notes: { value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); break; } + // Status. case SbmPrice.Column.Status_Desc: case SbmPrice.Column.Status_Ind: @@ -214,6 +225,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmPrice.GetStatusTriState(status)); break; } + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr-PriceSet.cs b/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr-PriceSet.cs index 62f2b6e..463389a 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr-PriceSet.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr-PriceSet.cs @@ -29,7 +29,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(priceSetId)) return false; SbmPriceSet.Params prmPriceSet = new SbmPriceSet.Params(); - prmPriceSet.IncludedIds.Add(priceSetId); + prmPriceSet.IdsIncluded.Add(priceSetId); prmPriceSet.StatusCat = SbmPriceSet.StatusCat.Any; return GetPriceSetCount(prmPriceSet) == 1; } @@ -51,7 +51,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(priceSetId)) return null; SbmPriceSet.Params prmPriceSet = new SbmPriceSet.Params(); - prmPriceSet.IncludedIds.Add(priceSetId); + prmPriceSet.IdsIncluded.Add(priceSetId); prmPriceSet.StatusCat = SbmPriceSet.StatusCat.Any; return GetPriceSet(prmPriceSet); } @@ -152,6 +152,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmPriceSet.Column)column.Id) { + //----------------------------------------------------------- // Price type. case SbmPriceSet.Column.PriceType_Desc: { @@ -159,6 +160,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(PriceTypes.GetDescForType(priceType, priceType > 0 ? priceType.ToString() : "")); break; } + + //----------------------------------------------------------- // Has Static Prices. case SbmPriceSet.Column.HasStaticPrices_Tick: case SbmPriceSet.Column.HasStaticPrices_Y: @@ -170,12 +173,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr else value = new DataValue(hasStaticPrices); break; } + + //----------------------------------------------------------- // Notes. case SbmPriceSet.Column.Notes: { value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); break; } + // Status. case SbmPriceSet.Column.Status_Desc: case SbmPriceSet.Column.Status_Ind: @@ -188,6 +194,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmPriceSet.GetStatusTriState(status)); break; } + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr.cs index 85119fc..5ef7f70 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr.cs @@ -8,8 +8,8 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { - //======================================================================= - public abstract partial class SbmPriceMgr : SbmCoreMgr + //======================================================================= + public abstract partial class SbmPriceMgr : SbmCoreMgr { //------------------------------------------------------------------- // Data members. @@ -101,11 +101,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { // Price set is available but no valid price found. // Discount can be used if allowed in conjunction with no price set price found. - SbmConfigConsole configConsole = ConfigConsole; + SbmSessionConsole sessionConsole = SessionConsole; if (prmCalc.IsSales) - bUseDiscount = configConsole != null && configConsole.AllowOption(UserContext, Sbm.ConfigOption.CustomerDiscountWhenNoPriceInSet); + bUseDiscount = sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.CustomerDiscountWhenNoPriceInSet); else - bUseDiscount = configConsole != null && configConsole.AllowOption(UserContext, Sbm.ConfigOption.SupplierDiscountWhenNoPriceInSet); + bUseDiscount = sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.SupplierDiscountWhenNoPriceInSet); } if (bUseDiscount) { diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmProcessMgr_Process.cs b/SaBusMgrStandardBase/Base/Mgr/SbmProcessMgr_Process.cs index 9ab78dd..b08ff70 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmProcessMgr_Process.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmProcessMgr_Process.cs @@ -31,7 +31,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(processId)) return false; SbmProcess.Params prmProcess = new SbmProcess.Params(); - prmProcess.IncludedIds.Add(processId); + prmProcess.IdsIncluded.Add(processId); prmProcess.StatusCat = SbmProcess.StatusCat.Any; return GetProcessCount(prmProcess) == 1; } @@ -45,7 +45,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(processId)) return null; SbmProcess.Params prmProcess = new SbmProcess.Params(); - prmProcess.IncludedIds.Add(processId); + prmProcess.IdsIncluded.Add(processId); prmProcess.StatusCat = SbmProcess.StatusCat.Any; return GetProcess(prmProcess); } @@ -145,7 +145,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmProcess.Column)column.Id) { - //--------------------------------------------------------------- - + //----------------------------------------------------------- // Process TypeDesc. case SbmProcess.Column.Type_Desc: { @@ -153,6 +153,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(ProcessTypes.GetDescForType(processType, ((int)processType).ToString())); break; } + // Process CategoryDesc. case SbmProcess.Column.Category_Desc: { @@ -161,7 +162,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- - + //----------------------------------------------------------- // Notes. case SbmProcess.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -180,7 +181,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Location.cs b/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Location.cs index 5efd6cd..7a26889 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Location.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Location.cs @@ -78,7 +78,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(locationId)) return false; SbmLocation.Params prmLocation = new SbmLocation.Params(); - prmLocation.IncludedIds.Add(locationId); + prmLocation.IdsIncluded.Add(locationId); prmLocation.StatusCat = SbmLocation.StatusCat.Any; return GetLocationCount(prmLocation) == 1; } @@ -103,7 +103,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(locationId)) return null; SbmLocation.Params prmLocation = new SbmLocation.Params(); - prmLocation.IncludedIds.Add(locationId); + prmLocation.IdsIncluded.Add(locationId); prmLocation.StatusCat = SbmLocation.StatusCat.Any; return GetLocation(prmLocation); } @@ -237,6 +237,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmLocation.GetStatusTriState(status)); break; } + + //----------------------------------------------------------- // Flags. case SbmLocation.Column.SalesStock_Y: case SbmLocation.Column.SalesStock_Tick: @@ -259,7 +261,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //----------------------------------------------------------- + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Movement.cs b/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Movement.cs index 6a05edd..211bbfd 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Movement.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Movement.cs @@ -33,7 +33,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(movementId)) return false; SbmMovement.Params prmMovement = new SbmMovement.Params(); - prmMovement.IncludedIds.Add(movementId); + prmMovement.IdsIncluded.Add(movementId); return GetMovementCount(prmMovement) == 1; } @@ -46,7 +46,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(movementId)) return null; SbmMovement.Params prmMovement = new SbmMovement.Params(); - prmMovement.IncludedIds.Add(movementId); + prmMovement.IdsIncluded.Add(movementId); return GetMovement(prmMovement); } @@ -142,7 +142,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //----------------------------------------------------------- // Movement TypeDesc. - //--------------------------------------------------------------- + //----------------------------------------------------------- // Notes. case SbmMovement.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -160,7 +160,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmMovement.GetStatusTriState(status)); break; } - //----------------------------------------------------------- + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Constituent.cs b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Constituent.cs index 35bdac2..605f364 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Constituent.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Constituent.cs @@ -50,7 +50,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return false; SbmConstituent.Params prmituent = new SbmConstituent.Params(); - prmituent.IncludedIds.Add(id); + prmituent.IdsIncluded.Add(id); prmituent.StatusCat = SbmConstituent.StatusCat.Any; return GetConstituentCount(prmituent) == 1; } @@ -64,7 +64,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return null; SbmConstituent.Params prmituent = new SbmConstituent.Params(); - prmituent.IncludedIds.Add(id); + prmituent.IdsIncluded.Add(id); prmituent.StatusCat = SbmConstituent.StatusCat.Any; return GetConstituent(prmituent); } @@ -192,7 +192,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmConstituent.Column)column.Id) { - //------------------------------------------------------------------- + //----------------------------------------------------------- // Constituent TypeDesc. case SbmConstituent.Column.Type_Desc: { @@ -219,7 +219,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //------------------------------------------------------------------- + //----------------------------------------------------------- // Started Date&Time. case SbmConstituent.Column.Started_DateFmt: { @@ -273,6 +273,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr else value = new DataValue(DateUtil.Format(required, "d-MMM-yyyy")); break; } + // Completed Date&Time. case SbmConstituent.Column.Completed_DateFmt: { @@ -281,7 +282,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //------------------------------------------------------------------- + //----------------------------------------------------------- // Due Indicator. case SbmConstituent.Column.DueInd: { @@ -301,7 +302,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //------------------------------------------------------------------- + //----------------------------------------------------------- // Notes. case SbmConstituent.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -318,7 +319,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(SbmConstituent.GetStatusTriState(status)); break; } - //------------------------------------------------------------------- + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Requirement.cs b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Requirement.cs index 7639bc3..9069fd0 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Requirement.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Requirement.cs @@ -51,7 +51,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return false; SbmRequirement.Params prmRequirement = new SbmRequirement.Params(); - prmRequirement.ReqntIncludedIds.Add(id); + prmRequirement.RequirementIdsIncluded.Add(id); prmRequirement.StatusCat = SbmRequirement.StatusCat.Any; return GetRequirementCount(prmRequirement) == 1; } @@ -67,7 +67,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return null; SbmRequirement.Params prmRequirement = new SbmRequirement.Params(); - prmRequirement.ReqntIncludedIds.Add(id); + prmRequirement.RequirementIdsIncluded.Add(id); prmRequirement.StatusCat = SbmRequirement.StatusCat.Any; return GetRequirement(prmRequirement); } @@ -258,7 +258,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmRequirement.Column)column.Id) { - //--------------------------------------------------------------- -(Requirement Details) + //----------------------------------------------------------- // Requirement Promotion. /// Precedence: & Hence: /// P1 ~ Requirement promotion - If not 'Commodity' requirement promotion requested. @@ -319,7 +319,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; } - //------------------------------------------------------------------ + + //----------------------------------------------------------- // Association Coding. case SbmRequirement.Column.Assoc_AccountManagerDesc: { @@ -334,7 +335,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //------------------------------------------------------------------ + //----------------------------------------------------------- // Transaction Coding. case SbmRequirement.Column.Trans_ContactArea: { @@ -412,7 +413,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //------------------------------------------------------------------ + //----------------------------------------------------------- // Reqnt-Trans Delivery TaxCode. case SbmRequirement.Column.Trans_DeliveryTaxCode_Code: case SbmRequirement.Column.Trans_DeliveryTaxCode_Rate: @@ -466,7 +467,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(valAmount); break; } - //------------------------------------------------------------------ + + //----------------------------------------------------------- // Transaction Cost & Margin. case SbmRequirement.Column.Trans_CostTotal_Fmt: case SbmRequirement.Column.Trans_AmountMargin: @@ -521,7 +523,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; } - //------------------------------------------------------------------ + + //----------------------------------------------------------- // Transaction Flags (Allocation & Replacement). case SbmRequirement.Column.Trans_AllocationInd: case SbmRequirement.Column.Trans_AllocationInd_YP: @@ -560,7 +563,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr else if (column.Id == (int)SbmRequirement.Column.Trans_ReplacementOrder_Y) value = new DataValue(replacementOrder ? "Y" : ""); break; } - //------------------------------------------------------------------ + + //----------------------------------------------------------- // Transaction Status. case SbmRequirement.Column.Trans_StatusDesc: case SbmRequirement.Column.Trans_StatusInd: @@ -583,7 +587,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr else if (column.Id == (int)SbmRequirement.Column.Trans_Status_OnHold_Y) value = new DataValue(onHold ? "Y" : ""); break; } - //------------------------------------------------------------------ + + //----------------------------------------------------------- // Required Date. case SbmRequirement.Column.Required_Fmt: { @@ -606,7 +611,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(started.DayOfWeek.ToString()); break; } - //------------------------------------------------------------------ + + //----------------------------------------------------------- // Allocation Indicators. case SbmRequirement.Column.Allocation_Ind: case SbmRequirement.Column.AllocationInd_YP: @@ -630,7 +636,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; } - //------------------------------------------------------------------ + + //----------------------------------------------------------- // Amount fields. case SbmRequirement.Column.AmountUnitNet: { @@ -663,7 +670,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; } - //------------------------------------------------------------------ + + //----------------------------------------------------------- // Display Estimated Time. case SbmRequirement.Column.TimeEst: case SbmRequirement.Column.TimeEstMins: @@ -730,7 +738,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //------------------------------------------------------------------ + //----------------------------------------------------------- // Job costing. case SbmRequirement.Column.CostTotal_Fmt: case SbmRequirement.Column.AmountMargin: @@ -792,6 +800,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } + //----------------------------------------------------------- // Requirement Notes. case SbmRequirement.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -809,7 +818,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } break; - //------------------------------------------------------------------ + //----------------------------------------------------------- // Order or source order info. case SbmRequirement.Column.OrderItem_JobNumber: { @@ -820,7 +829,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //------------------------------------------------------------------ + //----------------------------------------------------------- // Commodity Codings. case SbmRequirement.Column.Cmd_MaterialDesc: { @@ -835,7 +844,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------- + //----------------------------------------------------------- // Requirement Formatted Currency Value. case SbmRequirement.Column.Cmd_CostPrice_Fmt: { @@ -929,7 +938,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(stockAvailable); break; } - //------------------------------------------------------------------ + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Transaction.cs b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Transaction.cs index 80a5100..17078f9 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Transaction.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Transaction.cs @@ -12,8 +12,8 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { - //======================================================================= - partial class SbmTransactionMgr + //======================================================================= + partial class SbmTransactionMgr { //******************************************************************* // T r a n s a c t i o n s @@ -46,7 +46,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return false; SbmTransaction.Params prmTransaction = new SbmTransaction.Params(); - prmTransaction.IncludedIds.Add(id); + prmTransaction.IdsIncluded.Add(id); prmTransaction.StatusCat = SbmTransaction.StatusCat.Any; return GetTransactionCount(prmTransaction) == 1; } @@ -55,7 +55,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { if (!SysId.IsValid(affIdOwner) || (int)transactionType < 1 || StringUtil.IsEmpty(transactionRef)) return false; SbmTransaction.Params prmTransaction = new SbmTransaction.Params(); - prmTransaction.IncludedIds.Add(affIdOwner); + prmTransaction.IdsIncluded.Add(affIdOwner); prmTransaction.TransactionType = transactionType; prmTransaction.TransRefFull = transactionRef; prmTransaction.StatusCat = SbmTransaction.StatusCat.Any; @@ -71,7 +71,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (!SysId.IsValid(id)) return null; SbmTransaction.Params prmTransaction = new SbmTransaction.Params(); - prmTransaction.IncludedIds.Add(id); + prmTransaction.IdsIncluded.Add(id); prmTransaction.StatusCat = SbmTransaction.StatusCat.Any; return GetTransaction(prmTransaction); } @@ -83,7 +83,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr SbmTransaction transaction = null; if (!SysId.IsValid(affIdOwner) || transactionType > 0 || StringUtil.IsEmpty(transRef)) return transaction; SbmTransaction.Params prmTransaction = new SbmTransaction.Params(); - prmTransaction.IncludedIds.Add(affIdOwner); + prmTransaction.IdsIncluded.Add(affIdOwner); prmTransaction.TransactionType = Sbm.TransactionType.Any; prmTransaction.TransRefFull = transRef; prmTransaction.StatusCat = SbmTransaction.StatusCat.Any; @@ -301,10 +301,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } // Populate reference if not already done. - if (StringUtil.IsEmpty(data.Ref) && ConfigConsole.TransactionAssignRefMethod(UserContext, data.TransactionType) != SbmConfigConsole.AssignTransRefMethod.Manual) + if (StringUtil.IsEmpty(data.Ref) && SessionConsole.TransactionAssignRefMethod(data.TransactionType) != SbmSessionConsole.AssignTransRefMethod.Manual) { // Retrieve the next available transaction reference. - String sRef = ConfigConsole.GetTransactionCreateRef(UserContext, data.AffiliateIdOwner, data.AssociationId, data.TransactionType); ; ; + String sRef = SessionConsole.GetTransactionCreateRef(data.AffiliateIdOwner, data.AssociationId, data.TransactionType); // Check that another transaction doesn't already exist with this reference. SbmTransaction transRef = GetTransactionByOwnerTypeRef(data.AffiliateIdOwner, data.TransactionType, sRef); if (transRef == null) @@ -356,7 +356,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr DataValue value = new DataValue(); switch ((SbmTransaction.Column)column.Id) { - //--------------------------------------------------------------------- - + //----------------------------------------------------------- // Transaction TypeDesc. case SbmTransaction.Column.Type_Desc: { @@ -374,7 +374,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------------- - + //----------------------------------------------------------- // Association Codings. case SbmTransaction.Column.Assoc_AccountManagerDesc: { @@ -433,7 +433,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------------- - + //----------------------------------------------------------- // Transaction DeliveryAmount & Amount. case SbmTransaction.Column.DeliveryAmountNet_Fmt: case SbmTransaction.Column.DeliveryAmountTax_Fmt: @@ -470,7 +470,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------------- + //----------------------------------------------------------- // Transaction cost and margin. case SbmTransaction.Column.CostTotal_Fmt: case SbmTransaction.Column.AmountMargin: @@ -523,7 +523,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------------- + //----------------------------------------------------------- // Transaction Notes. case SbmTransaction.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); @@ -593,7 +593,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr break; } - //--------------------------------------------------------------------- + //----------------------------------------------------------- // Target Address. case SbmTransaction.Column.AssocTarget_Address: { @@ -627,7 +627,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr value = new DataValue(addresses.Concat(", ", null, null, true, true).Replace(" ,", ",").Trim(',').Trim()); break; } - //--------------------------------------------------------------------- + + //----------------------------------------------------------- + default: + value = values.GetValue(column.DataName); + break; + } return value; } diff --git a/SaBusMgrStandardBase/Base/Procs/SbmReport_Base.cs b/SaBusMgrStandardBase/Base/Procs/SbmReport_Base.cs index 1ea3c78..57d4966 100644 --- a/SaBusMgrStandardBase/Base/Procs/SbmReport_Base.cs +++ b/SaBusMgrStandardBase/Base/Procs/SbmReport_Base.cs @@ -19,8 +19,8 @@ using Sarand.BusinessMgr.Net.Standard.Base.Consoles; namespace Sarand.BusinessMgr.Net.Standard.Base.Procs { - //======================================================================= - public abstract class SbmReport_Base : SaReport_Base + //======================================================================= + public abstract class SbmReport_Base : SaReport_Base { //------------------------------------------------------------------- // Configuration. @@ -66,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Procs protected SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } } protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } } // Consoles. - protected SbmConfigConsole ConfigConsole { get { return Internals.ConfigConsole; } } + protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } } protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } } protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } } diff --git a/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs b/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs index 3ce2fec..c86a0b1 100644 --- a/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs +++ b/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs @@ -8,8 +8,8 @@ using System; namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog { - //======================================================================= - public class SbmUpdateLogItemMonitor : SaUpdateLogItemMonitor + //======================================================================= + public class SbmUpdateLogItemMonitor : SaUpdateLogItemMonitor { //------------------------------------------------------------------- // Configuration. @@ -26,7 +26,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog //------------------------------------------------------------------- // Data members. private readonly Config config; - private SbmConfigConsole configConsole = null; + private SbmSessionConsole sessionConsole { get { return config.Internals.SessionConsole; } } //------------------------------------------------------------------- // Construction. @@ -44,9 +44,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog protected virtual bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx columnIdx) { if (!config.UpdateLogConsole.CanUpdateDatabase) return false; - if (configConsole == null) - configConsole = config.Internals.ConfigConsole; - if (!configConsole.IsColumnChangeLogged(UserContext, columnIdx)) return false; + if (!sessionConsole.IsColumnChangeLogged(UserContext, columnIdx)) return false; return true; } protected bool RecordAttrValue(SbmDbDfn.ColumnIdx columnIdx, String value, bool newValue) diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmAddress_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmAddress_Dbas.cs index 4d38798..356e5c0 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmAddress_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmAddress_Dbas.cs @@ -60,7 +60,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (interfaceConsole != null) { if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.Association, Id), internals.DbUpdateInfo)) - SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorState); + SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorStateMessage); } else SetErrorState("failed to initialise interface console"); interfaceConsole = null; // Do not delete this global object. @@ -72,7 +72,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (dataItemMgr != null) { if (!dataItemMgr.ClearDataItem(Sbm.ItemType.Address, Id)) - SetErrorState(dataItemMgr.ErrorState.ToString()); + SetErrorState(dataItemMgr.ErrorStateMessage); } else SetErrorState("Data item manager is not available"); } diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmAffiliate_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmAffiliate_Dbas.cs index 51a9ee6..17fe948 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmAffiliate_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmAffiliate_Dbas.cs @@ -111,7 +111,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (interfaceConsole != null) { if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.Association, Id), internals.DbUpdateInfo)) - SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorState); + SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorStateMessage); } else SetErrorState("failed to initialise interface console"); interfaceConsole = null; // Do not delete this global object. @@ -123,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (dataItemMgr != null) { if (!dataItemMgr.ClearDataItem(Sbm.ItemType.Affiliate, Id)) - SetErrorState(dataItemMgr.ErrorState.ToString()); + SetErrorState(dataItemMgr.ErrorStateMessage); } else SetErrorState("Data item manager is not available"); } diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmAssetCategory_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmAssetCategory_Dbas.cs index a4df22e..ab78286 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmAssetCategory_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmAssetCategory_Dbas.cs @@ -104,7 +104,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (interfaceConsole != null) { if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.AssetCategory, Id), internals.DbUpdateInfo)) - SetErrorState(interfaceConsole.ErrorState.ToString()); + SetErrorState(interfaceConsole.ErrorStateMessage); } else SetErrorState("Failed to retrieve interface console"); interfaceConsole = null; // Do not delete this global object. @@ -149,7 +149,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus { ClearErrorState(); /*if (!processMgr.UpdateProcessesForItem(Sbm.ItemType.AssetCategory, Id, itemProcesses)) - SetErrorState(processMgr.ErrorState.ToString());*/ + SetErrorState(processMgr.ErrorStateMessage.ToString());*/ return !HasErrorState(); } } diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmAsset_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmAsset_Dbas.cs index 729e969..514ac0d 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmAsset_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmAsset_Dbas.cs @@ -120,7 +120,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (internals.DataItemMgr != null) { if (!internals.DataItemMgr.ClearDataItem(Sbm.ItemType.Asset, Id)) - SetErrorState(internals.DataItemMgr.ErrorState.ToString()); + SetErrorState(internals.DataItemMgr.ErrorStateMessage); } else SetErrorState("Failed to retrieve Data Item manager"); } @@ -130,7 +130,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (internals.InterfaceConsole != null) { if (!internals.InterfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.AssetCategory, Id), internals.DbUpdateInfo)) - SetErrorState(internals.InterfaceConsole.ErrorState.ToString()); + SetErrorState(internals.InterfaceConsole.ErrorStateMessage); } else SetErrorState("Failed to retrieve interface console"); } @@ -184,10 +184,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus { ProcessIdNext = itemProcessIdNext; if (!internals.AssetMgr.UpdateAsset(asset, internals.DbUpdateInfo)) - SetErrorState("Failed to update next process id - " + internals.AssetMgr.ErrorState); + SetErrorState("Failed to update next process id - " + internals.AssetMgr.ErrorStateMessage); } } - SetErrorState(internals.ProcessMgr.ErrorState.ToString()); + SetErrorState(internals.ProcessMgr.ErrorStateMessage); return !HasErrorState(); } public override bool PopulateDefaultProcesses() @@ -290,12 +290,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus } } // Store these details. - if (internals.DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.ItemPrice, Sbm.ItemType.Asset, Id, itemLinks, internals.DbUpdateInfo)) + if (internals.DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.ItemPrice, new ItemId((short)Sbm.ItemType.Asset, Id), itemLinks, internals.DbUpdateInfo)) { } else { - SetErrorState("Failed to save asset price item links - " + internals.DataItemMgr.ErrorState); + SetErrorState("Failed to save asset price item links - " + internals.DataItemMgr.ErrorStateMessage); } if (itemLinks != null) itemLinks.Clear(); diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmAssociation_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmAssociation_Dbas.cs index f6380d1..5beb76b 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmAssociation_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmAssociation_Dbas.cs @@ -100,7 +100,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (interfaceConsole != null) { if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.Association, Id), internals.DbUpdateInfo)) - SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorState); + SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorStateMessage); } else SetErrorState("failed to initialise interface console"); interfaceConsole = null; // Do not delete this global object. @@ -112,7 +112,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (itemDocConsole != null) { if (!itemDocConsole.ClearItemDocs(Sbm.ItemType.Association, Id)) - SetErrorState(itemDocConsole.ErrorState); + SetErrorState(itemDocConsole.ErrorStateMessage); } else SetErrorState("Failed to retrieve item document console"); itemDocConsole = null; // Do not delete this global object. @@ -121,7 +121,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (!HasErrorState()) { if (!internals.DataItemMgr.ClearDataItem(Sbm.ItemType.Association, Id)) - SetErrorState(internals.DataItemMgr.ErrorState.ToString()); + SetErrorState(internals.DataItemMgr.ErrorStateMessage); } return !HasErrorState(); } diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmCommodity_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmCommodity_Dbas.cs index 0891e08..47efd3c 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmCommodity_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmCommodity_Dbas.cs @@ -19,8 +19,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus //------------------------------------------------------------------- // Data members. private readonly SbmInternals internals; - private List costEstimates = new List(); - private List itemProcesses = new List(); //------------------------------------------------------------------- // Construction. @@ -40,352 +38,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus } //------------------------------------------------------------------- - // Properties. - - //------------------------------------------------------------------- - // Associated data. - //------------------------------------------------------------------- - public override bool HasProcesses() - { - ClearErrorState(); - if (!SysId.IsValid(Id)) return SetErrorState("invalid item"); - return internals.ProcessMgr.HasItemProcesses(Sbm.ItemType.Commodity, Id); - } - public override bool HasRequirements() - { - ClearErrorState(); - if (!SysId.IsValid(Id)) return false; - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null) - { - String tableRequirement = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement); - String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_CommodityId) + "=" + Id.ToString(); - return db.GetRowCount(tableRequirement, /*SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_Id),*/ filter) > 0; - } - return false; - } - public override bool IsSalesBudgetTemplate() - { - ClearErrorState(); - if (!SysId.IsValid(Id)) return false; - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null) - { - String tableCommodity = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity); - String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj) + "=" + Id.ToString(); - return db.GetRowCount(tableCommodity, /*SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Commodity_Id),*/ filter) > 0; - } - return false; - } - public override bool HasComponents() - { - ClearErrorState(); - return false; - } - public override bool HasPortfolioItems() - { - ClearErrorState(); - if (!SysId.IsValid(Id)) return false; - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null) - { - String tablePortfolioItem = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem); - if (db.TableExists(tablePortfolioItem)) - { - String colPortfolioItem_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.PortfolioItem_Id); - List filters = new List(); - filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.PortfolioItem_CommodityId) + "=" + Id.ToString()); - return db.GetRowCount(tablePortfolioItem, /*colPortfolioItem_Id,*/ filters.Concat(" AND ", "(", ")")) > 0; - } - } - return false; - } - public override bool HasContainers() - { - ClearErrorState(); - if (!SysId.IsValid(Id)) return false; - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null) - { - String tableContainer = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container); - if (db.TableExists(tableContainer)) - { - String colContainerItem_ContainerId = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ContainerId); - List filters = new List(); - filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ItemType) + "=" + Sbm.ItemType.Commodity.ToString()); - filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ItemId) + "=" + Id.ToString()); - return db.GetRowCount(tableContainer, /*colContainerItem_ContainerId,*/ filters.Concat(" AND ", "(", ")")) > 0; - } - } - return false; - } - public override bool HasCustomerDetails() - { - ClearErrorState(); - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null) - { - String tableCommodityCustomer = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer); - if (db.TableExists(tableCommodityCustomer)) - { - List filters = new List(); - filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId) + "=" + Id.ToString()); - return db.GetRowCount(tableCommodityCustomer, /*"1",*/ filters.Concat(" AND ", "(", ")")) > 0; - } - } - return false; - } - public override bool HasSupplierDetails() - { - ClearErrorState(); - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null) - { - String tableCommoditySupplier = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier); - if (db.TableExists(tableCommoditySupplier)) - { - List filters = new List(); - filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommoditySupplier_CommodityId) + "=" + Id.ToString()); - return db.GetRowCount(tableCommoditySupplier, /*"1",*/ filters.Concat(" AND ", "(", ")")) > 0; - } - } - return false; - } - public override bool HasMovements() - { - ClearErrorState(); - if (!SysId.IsValid(Id)) return false; - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null) - { - String tableMovement = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement); - if (db.TableExists(tableMovement)) - { - String colMovement_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_Id); - List filters = new List(); - filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemType)); - filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemId) + "=" + Id.ToString()); - return db.GetRowCount(tableMovement, /*colMovement_Id,*/ filters.Concat(" AND ", "(", ")")) > 0; - } - } - return false; - } - public override bool HasStockLevels() - { - ClearErrorState(); - if (!SysId.IsValid(Id)) return false; - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null) - { - String tableStockLevel = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel); - if (db.TableExists(tableStockLevel)) - { - String colStockLevel_CommodityId = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.StockLevel_CommodityId); - String filter = colStockLevel_CommodityId + "=" + Id.ToString(); - return db.GetRowCount(tableStockLevel, filter) > 0; - } - } - return false; - } - public override bool ClearDependentData() - { - ClearErrorState(); - if (!SysId.IsValid(Id)) return false; - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null && !HasErrorState()) - { - if (!HasErrorState()) - { - // Remove data item references. - if (!internals.DataItemMgr.ClearDataItem(Sbm.ItemType.Commodity, Id)) - SetErrorState(internals.DataItemMgr.ErrorState.ToString()); - } - if (!HasErrorState()) - { - // ToDo SaItemDocConsole for Remove document references. - SaItemDocConsole itemDocConsole = internals.ItemDocConsole; - if (itemDocConsole != null) - { - if (!itemDocConsole.ClearItemDocs(new ItemId((short)Sbm.ItemType.Commodity, Id), SaItemDocConsole.Category.Document, internals.DbUpdateInfo)) - SetErrorState(itemDocConsole.ErrorState.ToString()); - } - else SetErrorState("Failed to retrieve item document console"); - itemDocConsole = null; - } - if (!HasErrorState()) - { - // Remove interface references. - SaInterfaceConsole interfaceConsole = internals.InterfaceConsole; - if (interfaceConsole != null) - { - if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.Commodity, Id), internals.DbUpdateInfo)) - SetErrorState(interfaceConsole.ErrorState.ToString()); - } - else SetErrorState("Failed to retrieve interface console"); - interfaceConsole = null; - } - if (!HasErrorState()) - { - // Remove customer commodity details. - List columnNameValues = new List(); - String tableCommodityCustomer = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer); - String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId) + "=" + Id.ToString(); - if (db != null && db.TableExists(tableCommodityCustomer) && db.ExecuteDelete(tableCommodityCustomer, filter) > 0) - SetErrorState("Failed to clear customer commodity details"); - } - if (!HasErrorState()) - { - // Remove Supplier commodity details. - String tableCommoditySupplier = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier); - String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommoditySupplier_CommodityId) + "=" + Id.ToString(); - if (db != null && db.TableExists(tableCommoditySupplier) && db.ExecuteDelete(tableCommoditySupplier, filter) > 0) - SetErrorState("Failed to clear Supplier commodity details"); - } - } - return false; - } - //--------------------------------------------------------------- - // Commodity Cost Estimates. - public override List GetCostEstimates() - { - //ClearErrorState(); - List costEstimatesCopy = null; - if (costEstimates == null && SysId.IsValid(Id)) - { - //*************************************************************** - // 15-Dec MPE Fix - Commodity cost estimates were stored as requirement cost estimates. Here we convert the data for this commodity. - ISacsDatabase db = internals.BusMgrDatabase; - if (db != null /*&& SbmGlobals.GetConsole().GetVersion().GetName() == "MPE" && Id.ToInt() < 6000*/) - { - String colItemLink_Type = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_Type); - String colItemLink_ItemTypeFrom = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom); - String colItemLink_ItemIdFrom = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemIdFrom); - String colItemLink_CreateOn = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_CreateOn); - String colItemLink_UpdateOn = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_UpdateOn); - List filters = new List(); - // Identify cost estimates for requirements with the same Id as this commodity which were created since the 1-Jan-2006 - // (to avoid updating cost estimates that are more likely to belong to requirements - cost estimates were introduced against commodities during 2006). - filters.Add("(" + colItemLink_Type + "=" + Sbm.ItemLinkType.ItemCostEstimate.ToString() + " OR " + colItemLink_Type + "=" + Sbm.ItemLinkType.Requirement_CostEstimate.ToString() + ")"); - filters.Add(colItemLink_ItemTypeFrom + "=" + Sbm.ItemType.Requirement.ToString()); - filters.Add(colItemLink_ItemIdFrom + "=" + Id.ToString()); - filters.Add(colItemLink_CreateOn + ">=" + DbQuery.FormatForCondition(new DateTime(1, 1, 2006/*2006,1,1*/).ToString())); - if (db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), /*colItemLink_Type, rowCount,*/ filters.Concat(" AND ", "(", ")")) > 0) - { - // The link type and 'From' item type are changed to reflect the commodity relationship. - List values = new List(); - SacsDatabase.AddValuePair(values, colItemLink_Type, ((int)Sbm.ItemLinkType.ItemCostEstimate).ToString(), false); - SacsDatabase.AddValuePair(values, colItemLink_ItemTypeFrom, ((int)Sbm.ItemType.Commodity).ToString(), false); - SacsDatabase.AddValuePair(values, colItemLink_UpdateOn, DbQuery.FormatForCondition(new DateTime().ToString()), false); - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), values, filters.Concat(" AND ", "(", ")")); - } - } - //*************************************************************** - SbmItemLink.Params prmItemLink = new SbmItemLink.Params(); - prmItemLink.ItemLinkType = Sbm.ItemLinkType.ItemCostEstimate; - prmItemLink.ItemTypeFrom = Sbm.ItemType.Commodity; - prmItemLink.ItemIdFrom = Id; - List itemLinks = internals.DataItemMgr.GetItemLinkList(prmItemLink); - if (itemLinks != null) - { - foreach (SbmItemLink itemLink in itemLinks) - { - SbmCostEstimate costEstimate = new SbmCostEstimate(UserContext, itemLink.DataContent); - costEstimate.Notes = itemLink.Notes; - costEstimate.Changed = false; - if (costEstimates == null) costEstimates = new List(); - costEstimates.Add(costEstimate); - } - // Clean-up. - itemLinks.Clear(); - } - } - // Clone the list. - costEstimatesCopy = costEstimates.Clone(); - return costEstimatesCopy; - } - public override bool SetCostEstimates(List costEstimatesNew) - { - ClearErrorState(); - // Clear the existing list. - if (costEstimates != null) costEstimates.Clear(); - // Copy all items from the specified list. - costEstimates = costEstimatesNew.Clone(); - return true; - } - public override bool CommitCostEstimates() - { - ClearErrorState();// Do not attempt any updates unless the list has been populated. - if (costEstimates != null && SysId.IsValid(Id)) - { - // Build an item link list corresponding to the list of cost estimates. - List itemLinks = new List(); - foreach (SbmCostEstimate costEstimate in costEstimates) - { - if (costEstimate == null) continue; - SbmItemLink itemLink = internals.DataItemMgr.CreateItemLink(Sbm.ItemLinkType.ItemCostEstimate, Sbm.ItemType.Commodity, Id, Sbm.ItemType.Unknown, new SysId()); - if (itemLink != null) - { - itemLink.Seq = (short)costEstimate.CodeSeq; - itemLink.DataContent = costEstimate.ToString(); - itemLink.Notes = costEstimate.Notes; - itemLinks.Add(itemLink); - itemLink = null; // Now owned by the list. - } - } - // Store these details. - if (internals.DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.ItemCostEstimate, Sbm.ItemType.Commodity, Id, itemLinks, internals.DbUpdateInfo)) - { - } - else - { - SetErrorState("Failed to save cost estimate item links - " + internals.DataItemMgr.ErrorState); - } - if (itemLinks != null) - itemLinks.Clear(); - } - return !HasErrorState(); - } - //--------------------------------------------------------------- - // Commodity processes. - public override List GetProcesses(bool activeOnly) - { - //ToDo need to creat SbmProcessMgr_Dbas-ItemProcess inorder to do processMgr.??? - ClearErrorState(); - List itemProcesesCopy = null; - if (activeOnly) - { - // Retrieve the list of 'active' processes for this item. - internals.ProcessMgr.GetProcessesForItem(Sbm.ItemType.Commodity, Id, true); - } - else - { - // Full list required - check whether the internal list has been populated yet. - if (itemProcesses == null && SysId.IsValid(Id)) - { - // Get the list of processes. - internals.ProcessMgr.GetProcessesForItem(Sbm.ItemType.Commodity, Id, false); - } - // Clone the list. - itemProcesesCopy = itemProcesses.Clone(); - } - if (itemProcesesCopy != null) itemProcesesCopy.Sort(); - return itemProcesesCopy; - } - public override bool SetProcesses(List itemProcessesNew) - { - ClearErrorState(); - if (itemProcesses != null) itemProcesses.Clear(); - // Copy all items from the specified list. - itemProcesses = itemProcessesNew.Clone(); - return !HasErrorState(); - } - public override bool CommitProcesses() - { - ClearErrorState(); - if (!internals.ProcessMgr.StoreItemProcesses(Sbm.ItemType.Commodity, Id, itemProcesses, internals.DbUpdateInfo)) - SetErrorState(internals.ProcessMgr.ErrorState.ToString()); - return !HasErrorState(); - } } //======================================================================= } diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmRequirement_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmRequirement_Dbas.cs index 619396c..9c78ad6 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmRequirement_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmRequirement_Dbas.cs @@ -220,7 +220,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus } } // Store these details. - if (!DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.Requirement_CostEstimate, Sbm.ItemType.Requirement, Id, itemLinks, internals.DbUpdateInfo)) + if (!DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.Requirement_CostEstimate, new ItemId((short)Sbm.ItemType.Requirement, Id), itemLinks, internals.DbUpdateInfo)) SetErrorState("Failed to save cost estimate item links - " + DataItemMgr.ErrorState); if (itemLinks != null) itemLinks.Clear(); diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmTransaction_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmTransaction_Dbas.cs index 13c844b..d51d881 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmTransaction_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmTransaction_Dbas.cs @@ -14,8 +14,8 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus { - //======================================================================= - class SbmTransaction_Dbas : SbmTransaction + //======================================================================= + class SbmTransaction_Dbas : SbmTransaction { //------------------------------------------------------------------- // Data members. @@ -160,7 +160,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus // Retrieve the current set of requirements for this transaction. SbmRequirement.Params prmRequirement = new SbmRequirement.Params(); //prmRequirement.RequirementStatusCat = requirementStatusCat; - prmRequirement.TransIncludedIds.Add(Id); + prmRequirement.TransactionIdsIncluded.Add(Id); return internals.TransactionMgr.GetRequirementList(prmRequirement); } return new List(); @@ -168,9 +168,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus public override bool ItemsRequireJobNumber() { // Check whether Job Number should be allocated. - SbmConfigConsole configConsole = internals.ConfigConsole; + SbmSessionConsole sessionConsole = internals.SessionConsole; ISacsDatabase db = internals.BusMgrDatabase; - if (configConsole != null && configConsole.AllowOption(UserContext, Sbm.ConfigOption.SalesOrderItemJobNumber) && SbmGlobals.Application.DbColumnExists(db, SbmDbDfn.ColumnIdx.Requirement_JobNumber)) + if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.SalesOrderItemJobNumber) && SbmGlobals.Application.DbColumnExists(db, SbmDbDfn.ColumnIdx.Requirement_JobNumber)) return TransactionType == Sbm.TransactionType.SalesOrder; return false; } @@ -237,7 +237,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus List columnsQuery = new List(); String colRequirement_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_Id); SbmRequirement.Params prmRequirement = new SbmRequirement.Params(); - prmRequirement.TransIncludedIds.Add(Id); + prmRequirement.TransactionIdsIncluded.Add(Id); using (DbResultSet dbResultSet = internals.TransactionMgr.ExecuteRequirementQuery(columnsQuery, prmRequirement)) { while (!HasErrorState() && dbResultSet != null && dbResultSet.NextRecord()) @@ -252,9 +252,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (internals.TransactionMgr.UpdateRequirement(requirement, internals.DbUpdateInfo)) { if (!requirement.CommitAssociatedData()) - SetErrorState("Failed to update requirement's data: " + requirement.ErrorState); + SetErrorState("Failed to update requirement's data: " + requirement.ErrorStateMessage); } - else SetErrorState("Failed to update requirement: " + internals.TransactionMgr.ErrorState); + else SetErrorState("Failed to update requirement: " + internals.TransactionMgr.ErrorStateMessage); requirementsNotUpdated.Remove(requirement); } else @@ -264,9 +264,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (requirement != null) { if (!internals.TransactionMgr.DeleteRequirement(requirement, TransactionType, internals.DbUpdateInfo)) - SetErrorState("Failed to remove requirement: " + internals.TransactionMgr.ErrorState); + SetErrorState("Failed to remove requirement: " + internals.TransactionMgr.ErrorStateMessage); } - else SetErrorState("Failed to retrieve requirement for deletion: " + internals.TransactionMgr.ErrorState); + else SetErrorState("Failed to retrieve requirement for deletion: " + internals.TransactionMgr.ErrorStateMessage); } } } @@ -283,9 +283,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (internals.TransactionMgr.InsertRequirement(requirementNotUpdate, internals.DbUpdateInfo)) { if (!requirementNotUpdate.CommitAssociatedData()) - SetErrorState("Failed to update requirement's data: " + requirementNotUpdate.ErrorState); + SetErrorState("Failed to update requirement's data: " + requirementNotUpdate.ErrorStateMessage); } - else SetErrorState("Failed to create requirement: " + internals.TransactionMgr.ErrorState); + else SetErrorState("Failed to create requirement: " + internals.TransactionMgr.ErrorStateMessage); } } else SetErrorState("null item in list"); @@ -316,7 +316,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (interfaceConsole != null) { if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.Transaction, Id), internals.DbUpdateInfo)) - SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorState); + SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorStateMessage); } else SetErrorState("Failed to retrieve interface console"); interfaceConsole = null; // Do not delete this global object. @@ -328,7 +328,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (itemDocConsole != null) { if (!itemDocConsole.ClearItemDocs(Sbm.ItemType.Transaction, Id)) - SetErrorState(itemDocConsole.ErrorState()); + SetErrorState(itemDocConsole.ErrorStateMessage); } else SetErrorState("Failed to retrieve item document console"); itemDocConsole = null; // Do not delete this global object.*/ @@ -355,7 +355,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus foreach (SbmRequirement requirement in requirements) { if (!internals.TransactionMgr.DeleteRequirement(requirement, TransactionType, internals.DbUpdateInfo)) - SetErrorState(internals.TransactionMgr.ErrorState.ToString()); + SetErrorState(internals.TransactionMgr.ErrorStateMessage); requirements = null; } } @@ -365,7 +365,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (!HasErrorState()) { if (!internals.AccountMgr.ClearAddressesFor(Sbm.ItemType.Transaction, new ItemId())) - SetErrorState("failed to clear addresses - " + internals.AccountMgr.ErrorState); + SetErrorState("failed to clear addresses - " + internals.AccountMgr.ErrorStateMessage); } // Clear any references to this transaction from other transactions: if (!HasErrorState()) @@ -374,7 +374,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus List values = new List(); SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_TransIdSource), "0", false); db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), values, filter); - SetErrorState("failed to clear Transaction references"); + if (db.HasErrorState()) + SetErrorState($"{db.ErrorStateMessage}"); } } else SetErrorState("database is unavailable"); @@ -458,12 +459,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus } } // Store these details: - if (internals.DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.Transaction_Payment, Sbm.ItemType.Transaction, Id, itemLinks, internals.DbUpdateInfo)) + if (internals.DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.Transaction_Payment, new ItemId((short)Sbm.ItemType.Transaction, Id), itemLinks, internals.DbUpdateInfo)) { } else { - SetErrorState("Failed to save transaction payment item links - " + internals.DataItemMgr.ErrorState); + SetErrorState("Failed to save transaction payment item links - " + internals.DataItemMgr.ErrorStateMessage); } if (itemLinks != null) itemLinks.Clear(); diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmVehicleClass_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmVehicleClass_Dbas.cs index 81806b1..e6e6782 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmVehicleClass_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmVehicleClass_Dbas.cs @@ -125,7 +125,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (interfaceConsole != null) { if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.AssetCategory, Id), internals.DbUpdateInfo)) - SetErrorState(interfaceConsole.ErrorState.ToString()); + SetErrorState(interfaceConsole.ErrorStateMessage); } else SetErrorState("Failed to retrieve interface console"); interfaceConsole = null; // Do not delete this global object. diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmVehicle_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmVehicle_Dbas.cs index 3817003..5563f4e 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmVehicle_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmVehicle_Dbas.cs @@ -73,7 +73,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus { } #if _DEBUG - else TRACE("SapVehicle::SetOdometerReading: Failed to update vehicle event - %s\n", assetMgr.ErrorState.Message.ToString()); + else TRACE("SapVehicle::SetOdometerReading: Failed to update vehicle event - %s\n", assetMgr.ErrorStateMessage); #endif } else @@ -89,11 +89,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus { } #if _DEBUG - else TRACE("SapVehicle::SetOdometerReading: Failed to add vehicle event - %s\n", assetMgr.ErrorState.Message.ToString()); + else TRACE("SapVehicle::SetOdometerReading: Failed to add vehicle event - %s\n", assetMgr.ErrorStateMessage); #endif } #if _DEBUG - else TRACE("SapVehicle::SetOdometerReading: Failed to create vehicle event - %s\n", assetMgr.ErrorState.Message.ToString()); + else TRACE("SapVehicle::SetOdometerReading: Failed to create vehicle event - %s\n", assetMgr.ErrorStateMessage); #endif } // Update this vehicle itself. @@ -255,7 +255,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (interfaceConsole != null) { if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.AssetCategory, Id), internals.DbUpdateInfo)) - SetErrorState(interfaceConsole.ErrorState.ToString()); + SetErrorState(interfaceConsole.ErrorStateMessage); } else SetErrorState("Failed to retrieve interface console"); interfaceConsole = null; // Do not delete this global object. diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmInterfaceConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmInterfaceConsole_Dbas.cs index 1350380..5d4ff8c 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmInterfaceConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmInterfaceConsole_Dbas.cs @@ -19,9 +19,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { //------------------------------------------------------------------- // Data members. - private SbmConfigConsole configConsole; - private SaItemOptionConsole itemOptionConsole; - private SaUpdateLogConsole updateLogConsole; + private SbmInternals internals; private readonly List dataItemTypes; private readonly List interfaceDataTypes; @@ -37,9 +35,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { if (disposing) { - if (configConsole != null) configConsole.Dispose(); configConsole = null; - if (itemOptionConsole != null) itemOptionConsole.Dispose(); itemOptionConsole = null; - if (updateLogConsole != null) updateLogConsole.Dispose(); updateLogConsole = null; + if (internals != null) internals.Dispose(); internals = null; } base.Dispose(disposing); } @@ -48,35 +44,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles // Properties. public ISbmUserContext_Core UserContext { get; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } + private SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } } public override short InterfaceDataType { get { return (short)Sbm.ItemType.Interface; } } // Consoles. - private SbmConfigConsole ConfigConsole - { - get - { - if (configConsole == null) - configConsole = SbmGlobals.Application.CreateConfigConsole(UserContext.SessionContext); - return configConsole; - } - } - public override SaItemOptionConsole ItemOptionConsole - { - get - { - if (itemOptionConsole == null) - itemOptionConsole = SbmGlobals.Application.CreateItemOptionConsole(UserContext); - return itemOptionConsole; - } - } - public override SaUpdateLogConsole UpdateLogConsole - { - get - { - if (updateLogConsole == null) - updateLogConsole = SbmGlobals.Application.CreateUpdateLogConsole(UserContext); - return updateLogConsole; - } - } + private SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } + public override SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } } + public override SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } } //--------------------------------------------------------------- // Utilities. @@ -129,7 +102,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles } public bool InterfaceTypeValidForContextCategory(SaInterfaceCategory interfaceCategory, short interfaceType) { - return ConfigConsole.AllowInterface(UserContext, interfaceCategory, interfaceType); + return SessionConsole.AllowInterface(interfaceCategory, interfaceType); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmSecurityConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmSecurityConsole_Dbas.cs index f30a5eb..ba9378a 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmSecurityConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmSecurityConsole_Dbas.cs @@ -19,8 +19,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { //------------------------------------------------------------------- // Data members. - private SbmConfigConsole configConsole; - private SaUpdateLogConsole updateLogConsole; + private SbmInternals internals; private List securityRights; //------------------------------------------------------------------- @@ -34,8 +33,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { if (disposing) { - if (configConsole != null) configConsole.Dispose(); configConsole = null; - if (updateLogConsole != null) updateLogConsole.Dispose(); updateLogConsole = null; + if (internals != null) internals.Dispose(); internals = null; } base.Dispose(disposing); } @@ -44,27 +42,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles // Properties. public ISbmUserContext_Core UserContext { get; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } + private SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } } public override short SecurityItemDataType { get { return (short)Sbm.ItemType.SecurityItem; } } public override short SecurityLinkDataType { get { return (short)Sbm.ItemType.SecurityLink; } } // Consoles. - private SbmConfigConsole ConfigConsole - { - get - { - if (configConsole == null) - configConsole = SbmGlobals.Application.CreateConfigConsole(UserContext.SessionContext); - return configConsole; - } - } - public override SaUpdateLogConsole UpdateLogConsole - { - get - { - if (updateLogConsole == null) - updateLogConsole = SbmGlobals.Application.CreateUpdateLogConsole(UserContext); - return updateLogConsole; - } - } + private SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } + public override SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } } //------------------------------------------------------------------- // Utilities. @@ -77,28 +60,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles if (securityRights == null) { securityRights = new List(); - if (configConsole != null && configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowContacts)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowContacts)) { securityRights.Add(Sbm.SecurityRight.Affiliate_Create, "AffIns", "Affiliates - Create"); securityRights.Add(Sbm.SecurityRight.Affiliate_Update, "AffUpd", "Affiliates - Update"); securityRights.Add(Sbm.SecurityRight.Association_Create, "AssIns", "Associations - Create"); securityRights.Add(Sbm.SecurityRight.Association_Update, "AssUpd", "Associations - Update"); } - if (configConsole != null && configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowCommodities)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowCommodities)) { securityRights.Add(Sbm.SecurityRight.Commodity_Create, "CmdIns", "Commodities - Create"); securityRights.Add(Sbm.SecurityRight.Commodity_Update, "CmdUpd", "Commodities - Update"); - if (configConsole.GetStockControlConfig(UserContext).AllowStockControl()) + if (SessionConsole.GetStockControlConfig().AllowStockControl()) { securityRights.Add(Sbm.SecurityRight.StockTake, "CmdStkTak", "Commodities - Stock Take"); } } - if (configConsole != null && configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowAssets)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowAssets)) { securityRights.Add(Sbm.SecurityRight.Asset_Create, "AssetIns", "Assets - Create"); securityRights.Add(Sbm.SecurityRight.Asset_Update, "AssetUpd", "Assets - Update"); } - if (configConsole != null && configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowTransactions)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowTransactions)) { securityRights.Add(Sbm.SecurityRight.Transaction_Create, "TraIns", "Transactions - Create"); securityRights.Add(Sbm.SecurityRight.Transaction_Update, "TraUpd", "Transactions - Update"); @@ -109,7 +92,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles securityRights.Add(Sbm.SecurityRight.Security_Admin, "SecAdm", "Admin - Security"); securityRights.Add(Sbm.SecurityRight.Database_Admin, "DbAdm", "Admin - Database"); securityRights.Add(Sbm.SecurityRight.ReferenceData_Admin, "RefAdm", "Admin - Reference data"); - if (configConsole != null && configConsole.AllowInterfaces(UserContext)) + if (SessionConsole != null && SessionConsole.AllowInterfaces()) { securityRights.Add(Sbm.SecurityRight.InterfaceConfig, "IntCfg", "Interfaces - Configuration"); securityRights.Add(Sbm.SecurityRight.InterfaceByCategory, "IntCategory", "Interfaces - Allow by category"); @@ -118,11 +101,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles securityRights.Add(Sbm.SecurityRight.Financial_View, "FinLst", "Financials - View"); securityRights.Add(Sbm.SecurityRight.Financial_ViewByType, "FinType", "Financials - View by type"); securityRights.Add(Sbm.SecurityRight.Financial_UpdateByType, "FinTypeUpd", "Financials - Update by type"); - if (configConsole != null && configConsole.AllowOption(UserContext, Sbm.ConfigOption.TimeRecording)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.TimeRecording)) { securityRights.Add(Sbm.SecurityRight.TimesheetManager, "TimMgr", "Manage - Timesheets"); } - if (configConsole != null && configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowTasks)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowTasks)) { securityRights.Add(Sbm.SecurityRight.TaskManager, "TskMgr", "Manage - Tasks"); } @@ -144,7 +127,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles bool bValidTransType = false; if (!bValidTransType) bValidTransType = (transType == Sbm.TransactionType.SalesQuote); if (!bValidTransType) bValidTransType = (transType == Sbm.TransactionType.SalesOrder); - if (fullList || bValidTransType && configConsole.AllowTransactionType(UserContext, transType)) + if (fullList || bValidTransType && SessionConsole.AllowTransactionType(transType)) { // Retrieve status categories for transaction type: foreach (TypeCodeDesc transactionStatus in GetTransactionStatusCats(transType)) @@ -152,7 +135,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles SbmTransaction.StatusCat transStatusCat = (SbmTransaction.StatusCat)transactionStatus.Type; String sDesc = transactionType.Desc + " - " + transactionType.Desc; SysId transactionTypeIdStatus = GetTransactionTypeStatusId(transType, transStatusCat); - if (fullList || configConsole.AllowTransactionType(UserContext, transType)) + if (fullList || SessionConsole.AllowTransactionType(transType)) transactionTypesStatus.Add(transactionTypeIdStatus, transactionStatus.Desc); } } @@ -219,36 +202,36 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles switch (secRight.Type) { case (int)Sbm.SecurityRight.Transaction_ByType: - RegisterSecurityRight(secRight.Code, secRight.Desc, (short)Sbm.ItemType.TransactionType); + RegisterSecurityRight(secRight.Type, secRight.Code, secRight.Desc, (short)Sbm.ItemType.TransactionType); break; case (int)Sbm.SecurityRight.Transaction_UpdateByTypeStatus: - RegisterSecurityRight(secRight.Code, secRight.Desc, (short)Sbm.ItemType.TransactionTypeStatus); + RegisterSecurityRight(secRight.Type, secRight.Code, secRight.Desc, (short)Sbm.ItemType.TransactionTypeStatus); break; case (int)Sbm.SecurityRight.InterfaceByCategory: - RegisterSecurityRight(secRight.Code, secRight.Desc, (short)Sbm.ItemType.InterfaceCategory); + RegisterSecurityRight(secRight.Type, secRight.Code, secRight.Desc, (short)Sbm.ItemType.InterfaceCategory); break; case (int)Sbm.SecurityRight.Financial_ViewByType: - RegisterSecurityRight(secRight.Code, secRight.Desc, (short)Sbm.ItemType.FinancialType); + RegisterSecurityRight(secRight.Type, secRight.Code, secRight.Desc, (short)Sbm.ItemType.FinancialType); break; case (int)Sbm.SecurityRight.Financial_UpdateByType: - RegisterSecurityRight(secRight.Code, secRight.Desc, (short)Sbm.ItemType.FinancialType); + RegisterSecurityRight(secRight.Type, secRight.Code, secRight.Desc, (short)Sbm.ItemType.FinancialType); break; default: - RegisterSecurityRight(secRight.Code, secRight.Desc); + RegisterSecurityRight(secRight.Type, secRight.Code, secRight.Desc); break; } } //--------------------------------------------------------------- // Register the security data item types. - if (configConsole != null) + if (SessionConsole != null) { // Transaction types: List transactionTypesDesc = new List(); List transactionTypesDescAllowed = new List(); foreach (TypeCodeDesc transactionType in SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType)) { - if (configConsole.AllowTransactionType(UserContext, (Sbm.TransactionType)transactionType.Type)) + if (SessionConsole.AllowTransactionType((Sbm.TransactionType)transactionType.Type)) transactionTypesDescAllowed.Add(new SysId(transactionType.Type), transactionType.Desc); transactionTypesDesc.Add(new SysId(transactionType.Type), transactionType.Desc); } @@ -264,7 +247,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles List interfaceCategoriesDescAllowed = new List(); foreach (TypeCodeDesc interfaceCategory in SacsSystem.GetCodesOfType(SaSysCodeType.InterfaceCategory)) { - if (configConsole.AllowInterfaceCategory(UserContext, (SaInterfaceCategory)interfaceCategory.Type)) + if (SessionConsole.AllowInterfaceCategory((SaInterfaceCategory)interfaceCategory.Type)) interfaceCategoriesDescAllowed.Add(new SysId(interfaceCategory.Type), interfaceCategory.Desc); interfaceCategoriesDesc.Add(new SysId(interfaceCategory.Type), interfaceCategory.Desc); } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Address.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Address.cs index 140bb76..62012a7 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Address.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Address.cs @@ -468,12 +468,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // Address Id. - String includedIds = prm.IncludedIds.Concat(","); - if (!includedIds.IsEmpty()) - filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasAddress) + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); - if (!excludedIds.IsEmpty()) - filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasAddress) + " NOT IN (" + excludedIds + ")"); + String colId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasAddress); + if (prm.IdsIncluded.HasValidIds()) + filter.Add($"{colId} IN ({prm.IdsIncluded.Concat(",")})"); + if (prm.IdsExcluded.HasValidIds()) + filter.Add($"{colId} NOT IN ({prm.IdsExcluded.Concat(",")})"); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Address Type. @@ -777,7 +776,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetAddressQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetAddressSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs index d571a34..f81214f 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs @@ -91,7 +91,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!SysId.IsValid(affiliateId)) return ""; // Filter to target specified contact. SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); - prmAffiliate.IncludedIds.Add(affiliateId); + prmAffiliate.IdsIncluded.Add(affiliateId); prmAffiliate.StatusCat = SbmAffiliate.StatusCat.Any; if (GetAffiliateCount(prmAffiliate) != 1) return ""; // Columns to query. @@ -115,7 +115,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!SysId.IsValid(associationIdOwner)) return ""; // Filter to target specified association. SbmAssociation.Params prmAssociation = new SbmAssociation.Params(); - prmAssociation.IncludedIds.Add(associationIdOwner); + prmAssociation.IdsIncluded.Add(associationIdOwner); prmAssociation.StatusCat = SbmAssociation.StatusCat.Any; if (GetAssociationCount(prmAssociation) != 1) return ""; // Columns to query. @@ -139,7 +139,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!SysId.IsValid(associationIdTarget)) return ""; // Filter to target specified association. SbmAssociation.Params prmAssociation = new SbmAssociation.Params(); - prmAssociation.IncludedIds.Add(associationIdTarget); + prmAssociation.IdsIncluded.Add(associationIdTarget); prmAssociation.StatusCat = SbmAssociation.StatusCat.Any; if (GetAssociationCount(prmAssociation) != 1) return ""; // Columns to query. @@ -369,6 +369,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private static readonly String aliasAffiliate_AddPrim = "Aff_AddPrim"; private static readonly String prefixAffiliate_AddPrim = aliasAffiliate_AddPrim + "_"; private static readonly String colNameAffiliate_GroupMembers = "GroupMembers"; + private static readonly String colNameAffiliate_AssociationCount = "AssocCount"; // Column definition population. private void SetAffiliateColDfn @@ -501,6 +502,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr SetAffiliateColDfn(columnDfn, "Members", 90, SbmDbDfn.ColumnIdx.Unknown, ColumnAlignment.Right); columnDfn.DataName = colNameAffiliate_GroupMembers; break; + case SbmAffiliate.Column.Association_Count: + SetAffiliateColDfn(columnDfn, "Associations", 90, SbmDbDfn.ColumnIdx.Unknown, ColumnAlignment.Right); + columnDfn.DataName = colNameAffiliate_AssociationCount; + break; //----------------------------------------------------------------- // Common properties. @@ -539,31 +544,29 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { List filter = new List(); - // Affiliate Id. + // Item Id. String colAffiliate_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Id, aliasAffiliate); - String includedIds = prm.IncludedIds.Concat(","); - if (!includedIds.IsEmpty()) - filter.Add(colAffiliate_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); - if (!excludedIds.IsEmpty()) - filter.Add(colAffiliate_Id + " NOT IN (" + excludedIds + ")"); + if (prm.IdsIncluded.HasValidIds()) + filter.Add($"{colAffiliate_Id} IN ({prm.IdsIncluded.Concat(",")})"); + if (prm.IdsExcluded.HasValidIds() ) + filter.Add($"{colAffiliate_Id} NOT IN ({prm.IdsExcluded.Concat(",")})"); // Type. String colAffiliate_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Type, aliasAffiliate); // Affiliate type - Individual. if (prm.AffiliateType == Sbm.AffiliateType.AnyOrganisation) - filter.Add(colAffiliate_Type + "<>" + ((int)Sbm.AffiliateType.Individual).ToString()); + filter.Add($"{colAffiliate_Type}<>{(int)Sbm.AffiliateType.Individual}"); // Affiliate type - ContactGroup. else if (prm.AffiliateType == Sbm.AffiliateType.AnyContact) - filter.Add(colAffiliate_Type + "<>" + ((int)Sbm.AffiliateType.ContactGroup).ToString()); + filter.Add($"{colAffiliate_Type}<>{(int)Sbm.AffiliateType.ContactGroup}"); // Affiliate type. else if (prm.AffiliateType != Sbm.AffiliateType.Any && prm.AffiliateType != Sbm.AffiliateType.Unknown) - filter.Add(colAffiliate_Type + "=" + ((int)prm.AffiliateType).ToString()); + filter.Add($"{colAffiliate_Type}={(int)prm.AffiliateType}"); - // Parent Id? + // Parent Id. String colAffiliate_AffIdParent = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_AffIdParent, aliasAffiliate); if (SysId.IsValid(prm.AffiliateIdParent)) - filter.Add(colAffiliate_AffIdParent + "=" + SysId.ToString(prm.AffiliateIdParent)); + filter.Add($"{colAffiliate_AffIdParent}={SysId.ToString(prm.AffiliateIdParent)}"); //--------------------------------------------------------------- // Common columns. @@ -912,67 +915,67 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), aliasAffiliate); // Affiliate Properties - add columns as defined in query list. - if (columns.HasId((int)SbmAffiliate.Column.Id)) + if (columns.HasId(SbmAffiliate.Column.Id)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Id, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Type) || columns.HasId((int)SbmAffiliate.Column.Type_Code) || columns.HasId((int)SbmAffiliate.Column.Type_Desc)) + if (columns.HasId(SbmAffiliate.Column.Type) || columns.HasId(SbmAffiliate.Column.Type_Code) || columns.HasId(SbmAffiliate.Column.Type_Desc)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Type, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Name)) + if (columns.HasId(SbmAffiliate.Column.Name)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Name, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Abbrev)) + if (columns.HasId(SbmAffiliate.Column.Abbrev)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Abbrev, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Title)) + if (columns.HasId(SbmAffiliate.Column.Title)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Title, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Initials)) + if (columns.HasId(SbmAffiliate.Column.Initials)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Initials, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.LastName)) + if (columns.HasId(SbmAffiliate.Column.LastName)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_LastName, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.FirstName)) + if (columns.HasId(SbmAffiliate.Column.FirstName)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_FirstName, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Salutation)) + if (columns.HasId(SbmAffiliate.Column.Salutation)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Salutation, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Nature)) + if (columns.HasId(SbmAffiliate.Column.Nature)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Nature, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.CompanyNo)) + if (columns.HasId(SbmAffiliate.Column.CompanyNo)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_CompanyNo, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.VatReg)) + if (columns.HasId(SbmAffiliate.Column.VatReg)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_VatReg, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Contact)) + if (columns.HasId(SbmAffiliate.Column.Contact)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Contact, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.PhoneMain)) + if (columns.HasId(SbmAffiliate.Column.PhoneMain)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_PhoneMain, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.PhoneAlt)) + if (columns.HasId(SbmAffiliate.Column.PhoneAlt)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_PhoneAlt, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.PhoneDirect)) + if (columns.HasId(SbmAffiliate.Column.PhoneDirect)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_PhoneDirect, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.PhoneFax)) + if (columns.HasId(SbmAffiliate.Column.PhoneFax)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_PhoneFax, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.PhoneMobile)) + if (columns.HasId(SbmAffiliate.Column.PhoneMobile)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_PhoneMobile, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Email)) + if (columns.HasId(SbmAffiliate.Column.Email)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Email, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Website)) + if (columns.HasId(SbmAffiliate.Column.Website)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Website, aliasAffiliate)); // Common Properties - if (columns.HasId((int)SbmAffiliate.Column.Notes)) + if (columns.HasId(SbmAffiliate.Column.Notes)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Notes, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.Status) || columns.HasId((int)SbmAffiliate.Column.Status_Desc) || columns.HasId((int)SbmAffiliate.Column.Status_Ind)) + if (columns.HasId(SbmAffiliate.Column.Status) || columns.HasId(SbmAffiliate.Column.Status_Desc) || columns.HasId(SbmAffiliate.Column.Status_Ind)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Status, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.CreateOn_Date)) + if (columns.HasId(SbmAffiliate.Column.CreateOn_Date)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_CreateOn, aliasAffiliate)); - if (columns.HasId((int)SbmAffiliate.Column.UpdateOn_Date)) + if (columns.HasId(SbmAffiliate.Column.UpdateOn_Date)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_UpdateOn, aliasAffiliate)); //--------------------------------------------------------------- // Primary address. bool hasColsAddPrim = false; - if (!hasColsAddPrim) hasColsAddPrim = columns.HasId((int)SbmAffiliate.Column.Address_Summary); - if (!hasColsAddPrim) hasColsAddPrim = columns.HasId((int)SbmAffiliate.Column.Address_Line1); - if (!hasColsAddPrim) hasColsAddPrim = columns.HasId((int)SbmAffiliate.Column.Address_Line2); - if (!hasColsAddPrim) hasColsAddPrim = columns.HasId((int)SbmAffiliate.Column.Address_Line3); - if (!hasColsAddPrim) hasColsAddPrim = columns.HasId((int)SbmAffiliate.Column.Address_City); - if (!hasColsAddPrim) hasColsAddPrim = columns.HasId((int)SbmAffiliate.Column.Address_Province); - if (!hasColsAddPrim) hasColsAddPrim = columns.HasId((int)SbmAffiliate.Column.Address_Postcode); - if (!hasColsAddPrim) hasColsAddPrim = columns.HasId((int)SbmAffiliate.Column.Address_Country); + if (!hasColsAddPrim) hasColsAddPrim = columns.HasId(SbmAffiliate.Column.Address_Summary); + if (!hasColsAddPrim) hasColsAddPrim = columns.HasId(SbmAffiliate.Column.Address_Line1); + if (!hasColsAddPrim) hasColsAddPrim = columns.HasId(SbmAffiliate.Column.Address_Line2); + if (!hasColsAddPrim) hasColsAddPrim = columns.HasId(SbmAffiliate.Column.Address_Line3); + if (!hasColsAddPrim) hasColsAddPrim = columns.HasId(SbmAffiliate.Column.Address_City); + if (!hasColsAddPrim) hasColsAddPrim = columns.HasId(SbmAffiliate.Column.Address_Province); + if (!hasColsAddPrim) hasColsAddPrim = columns.HasId(SbmAffiliate.Column.Address_Postcode); + if (!hasColsAddPrim) hasColsAddPrim = columns.HasId(SbmAffiliate.Column.Address_Country); if (hasColsAddPrim) { // Sub-query to identify primary address with lowest Id for each affiliate. @@ -1020,9 +1023,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- - bool hasColsGrpMembers = false; - if (!hasColsGrpMembers) hasColsGrpMembers = columns.HasId((int)SbmAffiliate.Column.GroupMembers); - if (hasColsGrpMembers) + if (columns.HasId(SbmAffiliate.Column.GroupMembers)) { // Count group members. String aliasAffiliate_GroupMembers = "AffGrpMembers"; @@ -1035,11 +1036,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr query.Columns.Add("(" + qryGrpMembers.BuildQuery() + ")", colNameAffiliate_GroupMembers); } + //--------------------------------------------------------------- + if (columns.HasId(SbmAffiliate.Column.Association_Count)) + { + // Count active associations. + String aliasAffiliate_Associations = "AffAssocs"; + DbQuery qryAssocs = new DbQuery(db.DbmsType); + qryAssocs.Tables.Add((SbmDbDfn.TableIdx.Association).ToString(), aliasAffiliate_Associations); + qryAssocs.Columns.Add("Count(*)"); + qryAssocs.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner, aliasAffiliate_Associations)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Id, aliasAffiliate)}"); + qryAssocs.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Status, aliasAffiliate_Associations)}='{StatusCurrent}'"); + query.Columns.Add("(" + qryAssocs.BuildQuery() + ")", colNameAffiliate_AssociationCount); + } + //--------------------------------------------------------------- // Populate filter. query.Filters.AddRange(GetAffiliateQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetAffiliateSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs index 34d3864..336a3a4 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs @@ -14,6 +14,7 @@ using System; using System.Collections.Generic; using System.Data.Common; using System.Linq; +using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { @@ -279,7 +280,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!SysId.IsValid(associationId)) return null; // Filter to target specified association. SbmAssociation.Params prmAssociation = new SbmAssociation.Params(); - prmAssociation.IncludedIds.Add(associationId); + prmAssociation.IdsIncluded.Add(associationId); prmAssociation.StatusCat = SbmAssociation.StatusCat.Any; if (GetAssociationCount(prmAssociation) != 1) return null; // Columns to query. @@ -303,7 +304,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!SysId.IsValid(associationId)) return ""; // Filter to target specified association. SbmAssociation.Params prmAssociation = new SbmAssociation.Params(); - prmAssociation.IncludedIds.Add(associationId); + prmAssociation.IdsIncluded.Add(associationId); prmAssociation.StatusCat = SbmAssociation.StatusCat.Any; if (GetAssociationCount(prmAssociation) != 1) return ""; // Columns to query. @@ -1320,10 +1321,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Association Id. String colAssociation_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, aliasAssociation); - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); if (!includedIds.IsEmpty()) filter.Add(colAssociation_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colAssociation_Id + " NOT IN (" + excludedIds + ")"); @@ -1331,6 +1332,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colAssociation_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type, aliasAssociation); if (prm.AssociationType > 0) filter.Add(colAssociation_Type + "=" + ((int)prm.AssociationType).ToString()); + else if (prm.AssociationType == AssociationType.NotInternal) + filter.Add(colAssociation_Type + "!=" + ((int)Sbm.AssociationType.Internal).ToString()); //--------------------------------------------------------------- // Owner affiliate. @@ -1383,7 +1386,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!prm.NameTargetFull.IsEmpty() || !prm.NameTargetPartial.IsEmpty()) { // Target affiliate alias. - String aliasAffiliateTarget = StringUtil.OnEmpty(prm.Alias_Affiliate_Target, aliasAssociation_Affiliate_Target); + String aliasAffiliateTarget = StringUtil.OnBlank(prm.Alias_Affiliate_Target, aliasAssociation_Affiliate_Target); // Target affiliate columns. String colAffiliate_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Id, aliasAffiliateTarget); @@ -1427,7 +1430,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!StringUtil.IsEmpty(prm.AddressPartial) || !StringUtil.IsEmpty(prm.PostcodePartial)) { // Target Address alias. - String aliasAddTarget = StringUtil.OnEmpty(prm.Alias_Address_Target, "aAddTarget"); + String aliasAddTarget = StringUtil.OnBlank(prm.Alias_Address_Target, "aAddTarget"); // Target address columns. String colAddress_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasAddTarget); @@ -1494,7 +1497,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr searchValueFilter.Add(colAssociation_Group + " LIKE '%" + searchValue + "%'"); // Target affiliate. - String aliasAffiliateTarget = StringUtil.OnEmpty(prm.Alias_Affiliate_Target, aliasAssociation_Affiliate_Target); + String aliasAffiliateTarget = StringUtil.OnBlank(prm.Alias_Affiliate_Target, aliasAssociation_Affiliate_Target); String colAffiliate_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Id, aliasAffiliateTarget); String colAffiliate_Name = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Name, aliasAffiliateTarget); List affiliateFilter = new List(); @@ -1518,7 +1521,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } // Target address. - String aliasAddTarget = StringUtil.OnEmpty(prm.Alias_Address_Target, "aAddTarget"); + String aliasAddTarget = StringUtil.OnBlank(prm.Alias_Address_Target, "aAddTarget"); String colAddress_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasAddTarget); String colAddress_ItemType = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ItemType, aliasAddTarget); String colAddress_ItemId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ItemId, aliasAddTarget); @@ -1744,9 +1747,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Transactions. - if (prm.TransactionStatusCat != SbmTransaction.StatusCat.Any || prm.TransActiveFrom.IsValid() || prm.TransActiveTo.IsValid()) + if (prm.TransactionStatusCat != SbmTransaction.StatusCat.Any || prm.TransactionType > 0 || prm.TransactionActiveFrom.IsValid() || prm.TransactionActiveTo.IsValid()) { - List filterTransStatus = new List(); + List filterTrans = new List(); DateTime dateTime = new DateTime(1970, 1, 1); // Constructed to set DBMS (in case required to format query elements). DbQuery qryTrans = new DbQuery(db.DbmsType); @@ -1755,26 +1758,33 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colTransaction_Status = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Status); String colTransaction_StatusCat = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_StatusCat); + // Transaction type. + if (prm.TransactionType > 0) + { + String colTransaction_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Type); + filterTrans.Add($"{colTransaction_Type}={(int)prm.TransactionType}"); + } + // Transaction dates. - if (prm.TransActiveFrom.IsValid() || prm.TransActiveTo.IsValid()) + if (prm.TransactionActiveFrom.IsValid() || prm.TransactionActiveTo.IsValid()) { // Transaction must have an 'In Progress' date. - filterTransStatus.Add(colTransaction_InProgress + " IS NOT NULL"); - filterTransStatus.Add(colTransaction_InProgress + ">" + DbQuery.FormatDateForCondition(dateTime)); + filterTrans.Add($"{colTransaction_InProgress} IS NOT NULL"); + filterTrans.Add($"{colTransaction_InProgress}>{DbQuery.FormatDateForCondition(dateTime)}"); // Transaction must not be cancelled. - filterTransStatus.Add(colTransaction_Status + "<>'" + StatusCancelled + "'"); - if (prm.TransActiveFrom.IsValid()) + filterTrans.Add($"{colTransaction_Status}<>'{StatusCancelled}'"); + if (prm.TransactionActiveFrom.IsValid()) { // Transaction's 'Closed' date must not be earlier than the 'From' date. - filterTransStatus.Add( + filterTrans.Add( colTransaction_Closed + " IS NULL OR " + colTransaction_Closed + "=" + DbQuery.FormatForCondition(dateTime.ToString()) + " OR " + colTransaction_Closed + ">=" + - DbQuery.FormatForCondition(prm.TransActiveFrom.ToString())); + DbQuery.FormatForCondition(prm.TransactionActiveFrom.ToString())); } - if (prm.TransActiveTo.IsValid()) + if (prm.TransactionActiveTo.IsValid()) { // Transaction's 'In Progress' date must not be later than the 'To' date. - filterTransStatus.Add(colTransaction_InProgress + "<" + DbQuery.FormatDateForCondition(DateUtil.IncrementDate(prm.TransActiveTo, 1))); + filterTrans.Add(colTransaction_InProgress + "<" + DbQuery.FormatDateForCondition(DateUtil.IncrementDate(prm.TransactionActiveTo, 1))); } } // Check whether a Transaction status has been specified: @@ -1782,22 +1792,22 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String transtatuscatOpen = TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Open); String transtatuscatClosed = TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Closed); if (prm.TransactionStatusCat == SbmTransaction.StatusCat.NotDeleted) - filterTransStatus.Add(colTransaction_Status + "<>'" + StatusDeleted + "'"); + filterTrans.Add(colTransaction_Status + "<>'" + StatusDeleted + "'"); else if (prm.TransactionStatusCat == SbmTransaction.StatusCat.Completed) - filterTransStatus.Add(colTransaction_Status + "='" + TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Completed) + "'"); + filterTrans.Add(colTransaction_Status + "='" + TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Completed) + "'"); else if (prm.TransactionStatusCat == SbmTransaction.StatusCat.NotClosed) - filterTransStatus.Add(colTransaction_StatusCat + "<>'" + TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Closed) + "'"); + filterTrans.Add(colTransaction_StatusCat + "<>'" + TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Closed) + "'"); else if (prm.TransactionStatusCat == SbmTransaction.StatusCat.NotCancelled) - filterTransStatus.Add(colTransaction_Status + "<>'" + StatusCancelled + "'"); + filterTrans.Add(colTransaction_Status + "<>'" + StatusCancelled + "'"); else if (!StringUtil.IsEmpty(TransactionStatusCats.GetCodeForType(prm.TransactionStatusCat))) - filterTransStatus.Add(colTransaction_StatusCat + "='" + TransactionStatusCats.GetCodeForType(prm.TransactionStatusCat) + "'"); - filterTransStatus.RemoveDuplicatesCI(); - if (!filterTransStatus.IsEmpty()) + filterTrans.Add(colTransaction_StatusCat + "='" + TransactionStatusCats.GetCodeForType(prm.TransactionStatusCat) + "'"); + filterTrans.RemoveDuplicatesCI(); + if (!filterTrans.IsEmpty()) { qryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction)); qryTrans.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Id)); qryTrans.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_AssocId) + "=" + colAssociation_Id); - qryTrans.Filters.AddRange(filterTransStatus); + qryTrans.Filters.AddRange(filterTrans); filter.Add("EXISTS (" + qryTrans.BuildQuery() + ")"); } } @@ -1980,7 +1990,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_PhoneMain, aliasAssociation)); if (columns.HasId((int)SbmAssociation.Column.Email)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Email, aliasAssociation)); - if (columns.HasId((int)SbmAssociation.Column.Group)) + if (columns.HasId((int)SbmAssociation.Column.Group) && ColumnExists(SbmDbDfn.ColumnIdx.Association_Group)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Group, aliasAssociation, true)); if (columns.HasId((int)SbmAssociation.Column.DescDetail)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_DescDetail, aliasAssociation)); @@ -2483,7 +2493,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetAssociationQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetAssociationSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs index ee70b5d..32618cb 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs @@ -329,11 +329,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // Param Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colSysParam_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SysParam_Id, aliasSysParam); if (!includedIds.IsEmpty()) filter.Add(colSysParam_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colSysParam_Id + " NOT IN (" + excludedIds + ")"); @@ -504,7 +504,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetSysParamQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetSysParamSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccount.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccount.cs index 40d605e..2660da0 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccount.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccount.cs @@ -355,11 +355,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // SystemAccount Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colSystemAccount_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccount_Id, aliasSystemAccount); if (!includedIds.IsEmpty()) filter.Add(colSystemAccount_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colSystemAccount_Id + " NOT IN (" + excludedIds + ")"); @@ -583,7 +583,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetSystemAccountQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetSystemAccountSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccountUser.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccountUser.cs index 110a79c..95d4914 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccountUser.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccountUser.cs @@ -340,11 +340,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // SystemAccountUser Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colSystemAccountUser_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccountUser_AccountId, aliasSystemAccountUser); if (!includedIds.IsEmpty()) filter.Add(colSystemAccountUser_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colSystemAccountUser_Id + " NOT IN (" + excludedIds + ")"); @@ -581,7 +581,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetSystemAccountUserQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetSystemAccountUserSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemUser.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemUser.cs index 5902609..d3605b8 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemUser.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemUser.cs @@ -348,11 +348,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // SystemUser Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colSystemUser_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemUser_Id, aliasSystemUser); if (!includedIds.IsEmpty()) filter.Add(colSystemUser_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colSystemUser_Id + " NOT IN (" + excludedIds + ")"); @@ -562,7 +562,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetSystemUserQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetSystemUserSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Asset.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Asset.cs index 82852f7..8d25c7b 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Asset.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Asset.cs @@ -473,11 +473,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // Asset Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colAsset_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_Id, aliasAsset); if (!includedIds.IsEmpty()) filter.Add($"{colAsset_Id} IN ({includedIds})"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add($"{colAsset_Id} NOT IN ({excludedIds})"); @@ -792,7 +792,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetAssetQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetAssetSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs index 2c091d8..3996127 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs @@ -56,7 +56,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String filter = GetAssetCategoryQueryFilter(prm).Concat(" AND ", "(", ")"); db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), /*SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAssetCategory_Id), 0,*/ filter); } - else SetErrorState(db.ErrorState.ToString()); + else SetErrorState(db.ErrorStateMessage); } return false; } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetProcess.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetProcess.cs index 2f1e0e2..3fcba04 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetProcess.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetProcess.cs @@ -337,11 +337,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // AssetProcess Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colAssetProcess_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetProcess_Id, aliasAssetProcess); if (!includedIds.IsEmpty()) filter.Add($"{colAssetProcess_Id} IN ({includedIds})"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add($"{colAssetProcess_Id} NOT IN ({excludedIds})"); @@ -475,7 +475,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetAssetProcessQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetAssetProcessSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Vehicle.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Vehicle.cs index 5301ea6..fdfc91c 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Vehicle.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Vehicle.cs @@ -493,11 +493,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // Vehicle Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colVehicle_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle); if (!StringUtil.IsEmpty(includedIds)) filter.Add($"{colVehicle_Id} IN ({includedIds})"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!StringUtil.IsEmpty(excludedIds)) filter.Add($"{colVehicle_Id} NOT IN ({excludedIds})"); //--------------------------------------------------------------- @@ -780,7 +780,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetVehicleQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetVehicleSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs index 1ebe9a1..8414ca9 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs @@ -395,11 +395,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // VehicleEvent Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colVehicleEvent_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleEvent_Id, aliasVehicleEvent); if (!includedIds.IsEmpty()) filter.Add(colVehicleEvent_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colVehicleEvent_Id + " NOT IN (" + excludedIds + ")"); // Vehicle: @@ -582,7 +582,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetVehicleEventQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetVehicleEventSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs index 3859081..68b6709 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs @@ -61,7 +61,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (UpdateVehicleFeature(vehicleFeature, dbUpdateInfo)) { vehicleFeature.AcceptChanges(); - // Unable to process vehicle feature events - features do not have a system Id: pCon > configConsole? + // Unable to process vehicle feature events - features do not have a system Id: pCon > sessionConsole? //if (pCon) pCon->OnItemEvent(eSapItemEvent_Update,eSapItemTypeVehicleFeature,vehicleFeature.Id()); return true; } @@ -84,7 +84,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (InsertVehicleFeature(vehicleFeature, dbUpdateInfo)) { vehicleFeature.AcceptChanges(); - // Unable to process vehicle feature events - features do not have a system Id: pCon > configConsole? + // Unable to process vehicle feature events - features do not have a system Id: pCon > sessionConsole? //if (pCon) pCon->OnItemEvent(eSapItemEvent_Create,eSapItemTypeVehicleFeature,vehicleFeature.Id()); return true; } @@ -449,11 +449,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colVehicleFeature_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleFeature_VehicleId, aliasVehicleFeature); if (!StringUtil.IsEmpty(includedIds)) filter.Add(colVehicleFeature_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!StringUtil.IsEmpty(excludedIds)) filter.Add(colVehicleFeature_Id + " NOT IN (" + excludedIds + ")"); // Vehicle. @@ -619,7 +619,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetVehicleFeatureQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetVehicleFeatureSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity-Utils.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity-Utils.cs new file mode 100644 index 0000000..1d27878 --- /dev/null +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity-Utils.cs @@ -0,0 +1,332 @@ +using Sarand.BusinessMgr.Net.Standard.Base.App; +using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.BusinessMgr.Net.Standard.Dbas.Internal; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Interfaces; +using Sarand.Net.Standard.Base.ItemDocs; +using Sarand.Net.Standard.Base.Utils; +using Sarand.Net.Standard.Dbas.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr +{ + //======================================================================= + // Commodity Manager - Commodity - Utils. + //======================================================================= + partial class SbmCommodityMgr_Dbas + { + //------------------------------------------------------------------- + // Commodity Associated data. + public override bool CommodityHasProcesses(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return SetErrorState("invalid item"); + return ProcessMgr.HasItemProcesses(Sbm.ItemType.Commodity, commodityId); + } + public override bool CommodityHasRequirements(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return false; + String tableRequirement = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement); + String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_CommodityId)}={commodityId.ToString()}"; + return Database.GetRowCount(tableRequirement, filter) > 0; + } + public override bool CommodityIsSalesBudgetTemplate(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return false; + String tableCommodity = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity); + String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj)}={commodityId.ToString()}"; + return Database.GetRowCount(tableCommodity, filter) > 0; + } + public override bool CommodityHasComponents(SysId commodityId) + { + ClearErrorState(); + return false; + } + public override bool CommodityHasPortfolioItems(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return false; + String tablePortfolioItem = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem); + if (Database.TableExists(tablePortfolioItem)) + { + String colPortfolioItem_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.PortfolioItem_Id); + List filters = new List(); + filters.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.PortfolioItem_CommodityId)}={commodityId.ToString()}"); + return Database.GetRowCount(tablePortfolioItem, filters.Concat(" AND ", "(", ")")) > 0; + } + return false; + } + public override bool CommodityHasContainers(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return false; + String tableContainer = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container); + if (Database.TableExists(tableContainer)) + { + String colContainerItem_ContainerId = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ContainerId); + List filters = new List(); + filters.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ItemType)}={Sbm.ItemType.Commodity.ToString()}"); + filters.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ItemId)}={commodityId.ToString()}"); + return Database.GetRowCount(tableContainer, filters.Concat(" AND ", "(", ")")) > 0; + } + return false; + } + public override bool CommodityHasCustomerDetails(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return false; + String tableCommodityCustomer = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer); + if (Database.TableExists(tableCommodityCustomer)) + { + List filters = new List(); + filters.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId)}={commodityId.ToString()}"); + return Database.GetRowCount(tableCommodityCustomer, filters.Concat(" AND ", "(", ")")) > 0; + } + return false; + } + public override bool CommodityHasSupplierDetails(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return false; + String tableCommoditySupplier = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier); + if (Database.TableExists(tableCommoditySupplier)) + { + List filters = new List(); + filters.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommoditySupplier_CommodityId)}={commodityId.ToString()}"); + return Database.GetRowCount(tableCommoditySupplier, filters.Concat(" AND ", "(", ")")) > 0; + } + return false; + } + public override bool CommodityHasMovements(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return false; + String tableMovement = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement); + if (Database.TableExists(tableMovement)) + { + String colMovement_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_Id); + List filters = new List(); + filters.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemType)}={Sbm.ItemType.Commodity.ToString()}"); + filters.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemId)}={commodityId.ToString()}"); + return Database.GetRowCount(tableMovement, filters.Concat(" AND ", "(", ")")) > 0; + } + return false; + } + public override bool CommodityHasStockLevels(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return false; + String tableStockLevel = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel); + if (Database.TableExists(tableStockLevel)) + { + String colStockLevel_CommodityId = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.StockLevel_CommodityId); + String filter = $"{colStockLevel_CommodityId}={commodityId.ToString()}"; + return Database.GetRowCount(tableStockLevel, filter) > 0; + } + return false; + } + public override bool ClearCommodityDependentData(SysId commodityId) + { + ClearErrorState(); + if (!SysId.IsValid(commodityId)) return false; + if (!HasErrorState()) + { + // Remove data item references. + if (!DataItemMgr.ClearDataItem(Sbm.ItemType.Commodity, commodityId)) + SetErrorState(DataItemMgr.ErrorStateMessage); + } + if (!HasErrorState()) + { + if (ItemDocConsole != null) + { + if (!ItemDocConsole.ClearItemDocs(new ItemId((short)Sbm.ItemType.Commodity, commodityId), SaItemDocConsole.Category.Document, DbUpdateInfo)) + SetErrorState(ItemDocConsole.ErrorStateMessage); + } + else SetErrorState("Failed to retrieve item document console"); + } + if (!HasErrorState()) + { + // Remove interface references. + if (InterfaceConsole != null) + { + if (!InterfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.Commodity, commodityId), DbUpdateInfo)) + SetErrorState(InterfaceConsole.ErrorStateMessage); + } + else SetErrorState("Failed to retrieve interface console"); + } + if (!HasErrorState()) + { + // Remove customer commodity details. + List columnNameValues = new List(); + String tableCommodityCustomer = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer); + String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId) + "=" + commodityId.ToString(); + if (db != null && Database.TableExists(tableCommodityCustomer) && Database.ExecuteDelete(tableCommodityCustomer, filter) > 0) + SetErrorState("Failed to clear customer commodity details"); + } + if (!HasErrorState()) + { + // Remove Supplier commodity details. + String tableCommoditySupplier = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier); + String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommoditySupplier_CommodityId) + "=" + commodityId.ToString(); + if (db != null && Database.TableExists(tableCommoditySupplier) && Database.ExecuteDelete(tableCommoditySupplier, filter) > 0) + SetErrorState("Failed to clear Supplier commodity details"); + } + return false; + } + + //------------------------------------------------------------------- + // Commodity requirements. + + /// + /// Update requirements for this commodity with the correct code. + /// + public override bool UpdateCommodityRequirements(SbmCommodity commodity) + { + ClearErrorState(); + if (!SysId.IsValid(commodity.Id)) return true; + List filter = new List(); + filter.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_CommodityId)}={commodity.Id}"); + filter.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_ProductCode)}!='{DbQuery.FormatForCondition(commodity.Code)}'"); + List values = new List(); + SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_ProductCode), commodity.Code, true); + db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filter.Concat(" And ", "(", ")")); + if (db.HasErrorState()) + SetErrorState($"{db.ErrorStateMessage}."); + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Commodity cost estimates. + + public override List GetCommodityCostEstimates(SbmCommodity commodity) + { + //ClearErrorState(); + List costEstimatesCopy = null; + if (commodity.CostEstimates == null && SysId.IsValid(commodity.Id)) + { + using (DisposableCollection disposables = new DisposableCollection()) + { + SbmItemLink.Params prmItemLink = new SbmItemLink.Params(); + prmItemLink.ItemLinkType = Sbm.ItemLinkType.ItemCostEstimate; + prmItemLink.ItemTypeFrom = Sbm.ItemType.Commodity; + prmItemLink.ItemIdFrom = commodity.Id; + List itemLinks = DataItemMgr.GetItemLinkList(prmItemLink); + if (itemLinks != null) + { + disposables.AddRange(itemLinks); + foreach (SbmItemLink itemLink in itemLinks) + { + SbmCostEstimate costEstimate = new SbmCostEstimate(UserContext, itemLink.DataContent); + costEstimate.Notes = itemLink.Notes; + costEstimate.Changed = false; + if (commodity.CostEstimates == null) commodity.CostEstimates = new List(); + commodity.CostEstimates.Add(costEstimate); + } + // Clean-up. + itemLinks.Clear(); + } + } + } + // Clone the list. + costEstimatesCopy = commodity.CostEstimates.Clone(); + return costEstimatesCopy; + } + public override bool SetCommodityCostEstimates(SbmCommodity commodity, List costEstimatesNew) + { + ClearErrorState(); + // Clear the existing list. + if (commodity.CostEstimates != null) commodity.CostEstimates.Clear(); + // Copy all items from the specified list. + commodity.CostEstimates = costEstimatesNew.Clone(); + return true; + } + public override bool CommitCommodityCostEstimates(SbmCommodity commodity) + { + ClearErrorState();// Do not attempt any updates unless the list has been populated. + if (commodity.CostEstimates == null) return true; + if (commodity.CostEstimates != null && SysId.IsValid(commodity.Id)) + { + // Build an item link list corresponding to the list of cost estimates. + List itemLinks = new List(); + foreach (SbmCostEstimate costEstimate in commodity.CostEstimates) + { + if (costEstimate == null) continue; + SbmItemLink itemLink = DataItemMgr.CreateItemLink(Sbm.ItemLinkType.ItemCostEstimate, Sbm.ItemType.Commodity, commodity.Id, Sbm.ItemType.Unknown, new SysId()); + if (itemLink != null) + { + itemLink.Seq = (short)costEstimate.CodeSeq; + itemLink.DataContent = costEstimate.ToString(); + itemLink.Notes = costEstimate.Notes; + itemLinks.Add(itemLink); + } + } + // Store these details. + if (DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.ItemCostEstimate, new ItemId((short)Sbm.ItemType.Commodity, commodity.Id), itemLinks, DbUpdateInfo)) + { + } + else + { + SetErrorState("Failed to save cost estimate item links - " + DataItemMgr.ErrorStateMessage); + } + if (itemLinks != null) + itemLinks.Clear(); + } + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Commodity processes. + + public override List GetCommodityProcesses(SbmCommodity commodity, bool activeOnly) + { + //ToDo need to creat SbmProcessMgr_Dbas-ItemProcess inorder to do processMgr.??? + ClearErrorState(); + List itemProcesesCopy = null; + if (activeOnly) + { + // Retrieve the list of 'active' processes for this item. + ProcessMgr.GetProcessesForItem(Sbm.ItemType.Commodity, commodity.Id, true); + } + else + { + // Full list required - check whether the internal list has been populated yet. + if (commodity.ItemProcesses == null && SysId.IsValid(commodity.Id)) + { + // Get the list of processes. + ProcessMgr.GetProcessesForItem(Sbm.ItemType.Commodity, commodity.Id, false); + } + // Clone the list. + itemProcesesCopy = commodity.ItemProcesses.Clone(); + } + if (itemProcesesCopy != null) itemProcesesCopy.Sort(); + return itemProcesesCopy; + } + public override bool SetCommodityProcesses(SbmCommodity commodity, List itemProcessesNew) + { + ClearErrorState(); + if (commodity.ItemProcesses != null) commodity.ItemProcesses.Clear(); + // Copy all items from the specified list. + commodity.ItemProcesses = itemProcessesNew.Clone(); + return !HasErrorState(); + } + public override bool CommitCommodityProcesses(SbmCommodity commodity) + { + ClearErrorState(); + if (commodity.ItemProcesses == null) return true; + if (!ProcessMgr.StoreItemProcesses(Sbm.ItemType.Commodity, commodity.Id, commodity.ItemProcesses, DbUpdateInfo)) + SetErrorState(ProcessMgr.ErrorStateMessage); + return !HasErrorState(); + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs index 89aaee2..86287d4 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs @@ -20,43 +20,17 @@ using System.Threading.Tasks; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { //======================================================================= - internal partial class SbmCommodityMgr_Dbas : SbmCommodityMgr + // Commodity Manager - Commodity. + //======================================================================= + partial class SbmCommodityMgr_Dbas { - //******************************************************************* - // C o m m o d i t i e s - //******************************************************************* - public class PlannedStockMovements_Params - { - public PlannedStockMovements_Params() - { - earliest = DateTime.MinValue; - latest = DateTime.MinValue; - moveCol = PlanStockMoveCol.ItemQuanity; - intoStock = true; - provisionalContainersOnly = false; - excludeAwaitingContainers = false; - tableAliasCommodity = aliasCommodity; - } - - public DateTime earliest; - public DateTime latest; - public SbmCommodity.Params prmCmd; - public enum PlanStockMoveCol { ItemQuanity, MovementDate, }; - public PlanStockMoveCol moveCol; - public bool intoStock; - public bool provisionalContainersOnly; - public bool excludeAwaitingContainers; - public String tableAliasCommodity; - public String commodityIdCol; - } - //------------------------------------------------------------------- // Data members. private bool locationIdListPopulated = false; - private List locationIds_All = new List(); - private List locationIds_Calc = new List(); - private List locationIds_Sales = new List(); - private List locationIds_NonSales = new List(); + private readonly List locationIds_All = new List(); + private readonly List locationIds_Calc = new List(); + private readonly List locationIds_Sales = new List(); + private readonly List locationIds_NonSales = new List(); //------------------------------------------------------------------- // Utilities. @@ -70,6 +44,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr new StringPair("Status",commodity.StatusCode) }; } + + //------------------------------------------------------------------- public override List GetCommodityTypesInUse() { List types = new List(); @@ -210,6 +186,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Perform the update: db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), value, filters.Concat(" AND ", "(", ")")); + if (db.HasErrorState()) + SetErrorState($"{db.ErrorStateMessage}"); return !HasErrorState(); } @@ -219,7 +197,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Sales Quantity Query. - public override String BuildSalesQuantityQuery(DateTime earliest, DateTime latest, bool completeOrders, String tableAliasCommodity) + public String BuildSalesQuantityQuery(DateTime earliest, DateTime latest, bool completeOrders, String tableAliasCommodity) { tableAliasCommodity = StringUtil.OnEmpty(tableAliasCommodity, aliasCommodity); // Calculate the quantity against sales orders for this commodity. @@ -269,7 +247,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Allocated Stock Query. - public override String BuildAllocatedStockQuery(List locIds) + public String BuildAllocatedStockQuery(List locIds) { // Calculate the pending movements sourced to sales order requirements. String tableAliasMov = "StkAllMov"; @@ -286,7 +264,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Currency Stock Query. - public override String BuildCurrentStockQuery(List locIds) + public String BuildCurrentStockQuery(List locIds) { // Calculate the current stock level. String aliasStockLevel = "aCmdStkLvl"; @@ -301,8 +279,34 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- + // Planned stock movements. + public class PlannedStockMovements_Params + { + public PlannedStockMovements_Params() + { + earliest = DateTime.MinValue; + latest = DateTime.MinValue; + moveCol = PlanStockMoveCol.ItemQuanity; + intoStock = true; + provisionalContainersOnly = false; + excludeAwaitingContainers = false; + tableAliasCommodity = aliasCommodity; + } + + public DateTime earliest; + public DateTime latest; + public SbmCommodity.Params prmCmd; + public enum PlanStockMoveCol { ItemQuanity, MovementDate, }; + public PlanStockMoveCol moveCol; + public bool intoStock; + public bool provisionalContainersOnly; + public bool excludeAwaitingContainers; + public String tableAliasCommodity; + public String commodityIdCol; + } + // Stock Movements Query. - public override String BuildPlannedStockMovementsQuery(DateTime earliest, DateTime latest, SbmCommodity.Params prmCmd, bool intoStock, bool provisional, String tableAliasCommodity) + public String BuildPlannedStockMovementsQuery(DateTime earliest, DateTime latest, SbmCommodity.Params prmCmd, bool intoStock, bool provisional, String tableAliasCommodity) { PlannedStockMovements_Params prm = new PlannedStockMovements_Params(); prm.earliest = earliest; @@ -508,7 +512,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //------------------------------------------------------------------- // Populate LocationId Lists. - public override void PopulateLocationIdLists() + public void PopulateLocationIdLists() { // Verify that the location table exists. String tableLocation = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location); @@ -550,7 +554,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (locationIds_Sales.Count > 0) { // Assume that all locations are for sales. - locationIds_Sales = new List(locationIds_NonSales); + locationIds_Sales.Clear(); + locationIds_Sales.AddIds(locationIds_NonSales); locationIds_NonSales.Clear(); } } @@ -1096,12 +1101,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr break; case SbmCommodity.Column.Code: SetCommodityColDfn(columnDfn, "Code", 120, SbmDbDfn.ColumnIdx.Commodity_Code); - if (ConfigConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityDoubleColumnWidth)) + if (SessionConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityDoubleColumnWidth)) columnDfn.Width = columnDfn.Width * (int)1.25; break; case SbmCommodity.Column.DescBrief: SetCommodityColDfn(columnDfn, "Desc", 120, SbmDbDfn.ColumnIdx.Commodity_DescBrief); - if (ConfigConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityDoubleColumnWidth)) + if (SessionConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityDoubleColumnWidth)) columnDfn.Width = columnDfn.Width * (int)1.25; break; case SbmCommodity.Column.DescOrder: @@ -1487,6 +1492,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr columnDfn.ShowZeroValues = false; } break; + // Sales UOM. + case SbmCommodity.Column.UomIdSale: + SetCommodityColDfn(columnDfn, "Sales UOM Id", 80, SbmDbDfn.ColumnIdx.Commodity_UomIdSale, ColumnAlignment.Center, DataValue.DataType.Long); + columnDfn.ShowZeroValues = false; + break; case SbmCommodity.Column.UnitOfSale: SetCommodityColDfn(columnDfn, "Unit of Sale", 100, SbmDbDfn.ColumnIdx.UnitMeasure_Single, ColumnAlignment.Center); break; @@ -2288,15 +2298,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Commodity Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); if (!includedIds.IsEmpty()) filter.Add(colCommodity_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colCommodity_Id + " NOT IN (" + excludedIds + ")"); //--------------------------------------------------------------- // Organisation. // Must filter by organisation if insufficient alternative filetrs. - if (!prm.IncludedIds.HasValidIds() && !prm.PriceSetIdsIncluded.HasValidIds() && !SysId.IsValid(prm.AssociationIdCustomer) && !SysId.IsValid(prm.AssociationIdCommodityCustomer)) + if (!prm.IdsIncluded.HasValidIds() && !prm.PriceSetIdsIncluded.HasValidIds() && !SysId.IsValid(prm.AssociationIdCustomer) && !SysId.IsValid(prm.AssociationIdCommodityCustomer)) { if (!SysId.IsValid(AffiliateId_Owner)) throw new NotSupportedException("Commodity query filter - Organisation Id must be specified"); filter.Add(colCommodity_AffIdOwner + "=" + SysId.ToLong(AffiliateId_Owner)); @@ -2317,7 +2327,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filter.Add(colCommodity_Code + "='" + DbQuery.FormatForCondition(prm.CodeFull) + "'"); else if (!StringUtil.IsEmpty(prm.CodePartial)) { - if (ConfigConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityPartialCodeFilter)) + if (SessionConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityPartialCodeFilter)) filter.Add(colCommodity_Code + " LIKE '%" + DbQuery.FormatForLike(prm.CodePartial) + "%'"); else filter.Add(DbQuery.FormatFn_Left(colCommodity_Code, prm.CodePartial.Length) + "='" + DbQuery.FormatForCondition(prm.CodePartial) + "'"); } @@ -2816,6 +2826,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (columns.HasId(SbmCommodity.Column.CarriageCostIndicative) || columns.HasId(SbmCommodity.Column.CarriageCostIndicative_Fmt)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative, aliasCommodity)); if (columns.HasId(SbmCommodity.Column.MinOrderQty)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_MinOrderQty, aliasCommodity)); + if (columns.HasId(SbmCommodity.Column.UomIdSale)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_UomIdSale, aliasCommodity)); if (columns.HasId(SbmCommodity.Column.PackQtySale)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_PackQty, aliasCommodity)); if (columns.HasId(SbmCommodity.Column.LastOrderDate)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_LastOrderDate, aliasCommodity)); if (columns.HasId(SbmCommodity.Column.LastOrderQty)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_LastOrderQty, aliasCommodity)); @@ -3866,7 +3877,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetCommodityQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetCommoditySortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs index 7e44aab..1b79908 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs @@ -16,12 +16,11 @@ using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { + //======================================================================= + // Commodity Manager - Commodity Customer. //======================================================================= partial class SbmCommodityMgr_Dbas { - //******************************************************************* - // C o m m o d i t i e s C u s t o m e r - //******************************************************************* //------------------------------------------------------------------- // Data members. private String msg_UnableToManageCommodityCustomers = "Unable to manage commodity customers"; @@ -39,7 +38,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool CanManageCommodityCustomers() { - if (ConfigConsole == null || !AllowConfigOption(Sbm.ConfigOption.CommodityCustomers)) return false; + if (!AllowConfigOption(Sbm.ConfigOption.CommodityCustomers)) return false; return db != null && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer)); } public override bool StoreCommodityCustomers(List commodityCustomers) @@ -487,10 +486,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); //CommodityCustomer Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); if (!includedIds.IsEmpty()) filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId, aliasCommodityCustomer) + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId, aliasCommodityCustomer) + " NOT IN (" + excludedIds + ")"); @@ -713,7 +712,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetCommodityCustomerQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetCommodityCustomerSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs index c14d585..4de6a87 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs @@ -15,12 +15,11 @@ using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { + //======================================================================= + // Commodity Manager - Commodity Supplier. //======================================================================= partial class SbmCommodityMgr_Dbas { - //******************************************************************* - // C o m m o d i t i e s S u p p l i e r - //******************************************************************* //------------------------------------------------------------------- // Data members. @@ -36,7 +35,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool CanManageCommoditySuppliers() { - if (ConfigConsole == null || !AllowConfigOption(Sbm.ConfigOption.CommoditySuppliers)) return false; + if (SessionConsole == null || !AllowConfigOption(Sbm.ConfigOption.CommoditySuppliers)) return false; return db != null && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier)); } @@ -393,10 +392,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // CommoditySupplier Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); if (!includedIds.IsEmpty()) filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.CommoditySupplier_CommodityId, aliasCommoditySupplier) + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.CommoditySupplier_CommodityId, aliasCommoditySupplier) + " NOT IN (" + excludedIds + ")"); @@ -608,7 +607,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetCommoditySupplierQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetCommoditySupplierSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs index 45230cd..a0cc1f6 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs @@ -16,12 +16,12 @@ using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { + //======================================================================= + // Commodity Manager - Container. //======================================================================= partial class SbmCommodityMgr_Dbas { - //******************************************************************* - // C o n t a i n e r s - //******************************************************************* + //------------------------------------------------------------------- // Data members. //------------------------------------------------------------------- @@ -372,10 +372,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //Container Id. String colContainer_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Container_Id, tableAlias); - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); if (!includedIds.IsEmpty()) filter.Add(colContainer_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colContainer_Id + " NOT IN (" + excludedIds + ")"); @@ -709,7 +709,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetContainerQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetContainerSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs index c216164..1325b9e 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs @@ -16,12 +16,12 @@ using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { + //======================================================================= + // Commodity Manager - Container Item. //======================================================================= partial class SbmCommodityMgr_Dbas { - //******************************************************************* - // C o n t a i n e r I t e m s - //******************************************************************* + //------------------------------------------------------------------- // Utilities. private List GetLogProperties(SbmContainerItem containerItem) { @@ -561,10 +561,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Item Ids. String colContainerItem_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ContainerItem_ContainerId, tableAliasContainerItem); - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); if (!includedIds.IsEmpty()) filters.Add(colContainerItem_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filters.Add(colContainerItem_Id + " NOT IN (" + excludedIds + ")"); @@ -944,7 +944,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Populate filter. query.Filters.AddRange(GetContainerItemQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetContainerItemSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs index 37aa81c..885383e 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs @@ -17,12 +17,12 @@ using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { + //======================================================================= + // Commodity Manager - Portfolio Item. //======================================================================= partial class SbmCommodityMgr_Dbas { - //******************************************************************* - // P o r t f o l i o I t e m - //******************************************************************* + //------------------------------------------------------------------- // Utilities. private List GetLogProperties(SbmPortfolioItem portfolioItem) { @@ -729,10 +729,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Portfolio Item Id. String colPortfolioItem_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.PortfolioItem_Id, aliasPortfolioItem); - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); if (!StringUtil.IsEmpty(includedIds)) filter.Add(colPortfolioItem_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!StringUtil.IsEmpty(excludedIds)) filter.Add(colPortfolioItem_Id + " NOT IN (" + excludedIds + ")"); @@ -1014,7 +1014,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetPortfolioItemQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetPortfolioItemSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs index 507d86a..4262113 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs @@ -75,7 +75,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------- // Create ItemBatch. - //public SbmItemBatch_Dbas(SbmSessionProfile sessionProfile, SysId id, SysId affIdOwner, Sbm.ItemBatchType type, String refs, ushort flags) public override SbmItemBatch CreateItemBatch(Sbm.ItemBatchType itemBatchType, String refs) { ClearErrorState(); @@ -337,11 +336,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // ItemBatch Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colItemBatch_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemBatch_Id, aliasItemBatch); if (!includedIds.IsEmpty()) filter.Add(colItemBatch_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colItemBatch_Id + " NOT IN (" + excludedIds + ")"); @@ -511,7 +510,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetItemBatchQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetItemBatchSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink-Utils.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink-Utils.cs new file mode 100644 index 0000000..7620512 --- /dev/null +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink-Utils.cs @@ -0,0 +1,154 @@ +using Sarand.BusinessMgr.Net.Standard.Base.App; +using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.BusinessMgr.Net.Standard.Dbas.Bus; +using Sarand.BusinessMgr.Net.Standard.Dbas.Internal; +using Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog; +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Utils; +using Sarand.Net.Standard.Dbas.Data; +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Linq; + +namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr +{ + //======================================================================= + // Data Item Manager - Item Links - Utils. + //======================================================================= + partial class SbmDataItemMgr_Dbas + { + //------------------------------------------------------------------- + // Utilities. + + private List GetLogProperties(SbmItemLink itemLink) + { + return new List() + { + new StringPair("Id",SysId.ToString(itemLink.Id)), + new StringPair("DataContent",itemLink.DataContent), + new StringPair("Status",itemLink.StatusCode) + }; + } + + //------------------------------------------------------------------- + + public override bool DoDbCleanup() + { + ClearErrorState(); + /*RS_ItemLink* prsLink = (pSys ? pSys.ItemLinkRecordSet() : NULL); + if (!prsLink) return SetException("failed to create ItemLink recordset"); + if (!HasException()) + { + //--------------------------------------------------------------- + // Jan10: Item Links with Seq=0. + // These are prohibiting the primary key that includes this column. + // Should be able to set the value in sequence for the parent ('From') item. + //--------------------------------------------------------------- + // Keep track of previous values: + eSapItemLinkType eLinkTypePrev = eSapItemLink_Unknown; + eSapItemType eTypeFromPrev = eSapItemTypeUnknown; + SaSysId itemIdFromPrev; + int iNextSeq = 1; + int iRowsModified = 0, iParentItemsFound = 0; + + // Restrict to Seq=0 and sort by parent item: + prsLink->AddToSort(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_Type, false)); + prsLink->AddToSort(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom, false)); + prsLink->AddToSort(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemIdFrom, false)); + prsLink->AddToFilter(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_Seq) + "=0"); + prsLink->Open(); + while (!HasException() && prsLink->IsOpen() && !prsLink->IsEOF()) + { + // Reset the sequence if the parent item has changed: + if (eLinkTypePrev != (eSapItemLinkType)prsLink->iType || eTypeFromPrev != (eSapItemType)prsLink->iItemTypeTo || itemIdFromPrev != prsLink->iItemIdTo) + { + iNextSeq = 1; + eLinkTypePrev = (eSapItemLinkType)prsLink->iType; + eTypeFromPrev = (eSapItemType)prsLink->iItemTypeTo; + itemIdFromPrev = prsLink->iItemIdTo; + iParentItemsFound++; + } + prsLink->Edit(); + prsLink->iSeq = iNextSeq++; + if (!prsLink->Update()) + SetException("failed to update link (" + prsLink->Exception() + ")"); + iRowsModified++; + // Move to the next record in the result set: + prsLink->MoveNext(); + } + SATRACE("\nSapDataItemMgr_Odbc::DoDbCleanup\n\tParent items found: " + String(iParentItemsFound) + "\n\tRows modified: " + String(iRowsModified) + "\n\n"); + //--------------------------------------------------------------- + }*/ + return !HasErrorState(); + } + + //------------------------------------------------------------------- + + public override bool ClearDataItem(Sbm.ItemType itemType, SysId itemId) + { + ClearErrorState(); + if ((int)itemType < 1 || !SysId.IsValid(itemId)) return false; + List filters = new List(); + String colItemTypeFrom = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom); + String colItemIdFrom = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemIdFrom); + String colItemTypeTo = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeTo); + String colItemIdTo = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemIdTo); + filters.Add(colItemTypeFrom + "=" + ((int)itemType).ToString() + " AND " + colItemIdFrom + "=" + itemId.ToString()); + filters.Add(colItemTypeTo + "=" + ((int)itemType).ToString() + " AND " + colItemIdTo + "=" + itemId.ToString()); + String filter = filters.Concat(" OR ", "(", ")"); + //return db.ExecuteDelete("DELETE FROM" + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink) + " WHERE " + filter); + db.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), filter); + return false; + } + + //------------------------------------------------------------------- + // Associated items. + public override bool UpdateLinkedItems(Sbm.AssociatedItemMode itemMode, Sbm.ItemLinkType itemLinkType, ref ItemId itemIdParent, ref ItemId itemIdChild, ItemId itemId, List itemLinks) + { + ClearErrorState(); + // If the fixed item hasn't previously been specified, store the value now. + if (ItemLinkParentIsFixed(itemMode) && itemIdParent.Type == itemId.Type && !SysId.IsValid(itemIdParent.Id)) + itemIdParent = itemId; + else if (ItemLinkChildIsFixed(itemMode) && itemIdChild.Type == itemId.Type && !SysId.IsValid(itemIdChild.Id)) + itemIdChild = itemId; + // Validate the configuration. + if (ItemLinkConfigIsValid(itemMode, itemLinkType)) + return SetErrorState("Invalid configuration for associated items"); + + // Validate fixed item: + if (ItemLinkParentIsFixed(itemMode)) + { + if (itemIdParent != itemId) + return SetErrorState("Inconsistent parent item specified"); + } + else if (ItemLinkChildIsFixed(itemMode)) + { + if (itemIdChild != itemId) + return SetErrorState("Inconsistent child item specified"); + } + + if (ItemLinkParentIsFixed(itemMode)) + { + // Parent item is fixed - update its child items as specified in the list: + if (itemLinks != null) itemLinks.SetSequences(); + if (!DataItemMgr.StoreFromItemLinks(itemLinkType, itemId, itemLinks, DbUpdateInfo)) + return SetErrorState($"Failed to store associated items - {DataItemMgr.ErrorStateMessage}"); + } + else if (ItemLinkChildIsFixed(itemMode)) + { + // Child item is fixed - update its parent items as specified in the list: + if (!DataItemMgr.StoreToItemLinks(itemLinkType, itemId, itemLinks, DbUpdateInfo)) + return SetErrorState($"Failed to store associated items - {DataItemMgr.ErrorStateMessage}"); + } + + return !HasErrorState(); + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs index 7d606df..94477f1 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs @@ -16,94 +16,16 @@ using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { + //======================================================================= + // Data Item Manager - Item Links. //======================================================================= partial class SbmDataItemMgr_Dbas { - //******************************************************************* - // I t e m L i n k s - //******************************************************************* //------------------------------------------------------------------- // Data members. //------------------------------------------------------------------- - // Utilities. - private List GetLogProperties(SbmItemLink itemLink) - { - return new List() - { - new StringPair("Id",SysId.ToString(itemLink.Id)), - new StringPair("DataContent",itemLink.DataContent), - new StringPair("Status",itemLink.StatusCode) - }; - } - public override bool DoDbCleanup() - { - ClearErrorState(); - /*RS_ItemLink* prsLink = (pSys ? pSys.ItemLinkRecordSet() : NULL); - if (!prsLink) return SetException("failed to create ItemLink recordset"); - if (!HasException()) - { - //--------------------------------------------------------------- - // Jan10: Item Links with Seq=0. - // These are prohibiting the primary key that includes this column. - // Should be able to set the value in sequence for the parent ('From') item. - //--------------------------------------------------------------- - // Keep track of previous values: - eSapItemLinkType eLinkTypePrev = eSapItemLink_Unknown; - eSapItemType eTypeFromPrev = eSapItemTypeUnknown; - SaSysId itemIdFromPrev; - int iNextSeq = 1; - int iRowsModified = 0, iParentItemsFound = 0; - - // Restrict to Seq=0 and sort by parent item: - prsLink->AddToSort(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_Type, false)); - prsLink->AddToSort(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom, false)); - prsLink->AddToSort(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemIdFrom, false)); - prsLink->AddToFilter(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_Seq) + "=0"); - prsLink->Open(); - while (!HasException() && prsLink->IsOpen() && !prsLink->IsEOF()) - { - // Reset the sequence if the parent item has changed: - if (eLinkTypePrev != (eSapItemLinkType)prsLink->iType || eTypeFromPrev != (eSapItemType)prsLink->iItemTypeTo || itemIdFromPrev != prsLink->iItemIdTo) - { - iNextSeq = 1; - eLinkTypePrev = (eSapItemLinkType)prsLink->iType; - eTypeFromPrev = (eSapItemType)prsLink->iItemTypeTo; - itemIdFromPrev = prsLink->iItemIdTo; - iParentItemsFound++; - } - prsLink->Edit(); - prsLink->iSeq = iNextSeq++; - if (!prsLink->Update()) - SetException("failed to update link (" + prsLink->Exception() + ")"); - iRowsModified++; - // Move to the next record in the result set: - prsLink->MoveNext(); - } - SATRACE("\nSapDataItemMgr_Odbc::DoDbCleanup\n\tParent items found: " + String(iParentItemsFound) + "\n\tRows modified: " + String(iRowsModified) + "\n\n"); - //--------------------------------------------------------------- - }*/ - return !HasErrorState(); - } - public override bool ClearDataItem(Sbm.ItemType itemType, SysId itemId) - { - ClearErrorState(); - if ((int)itemType < 1 || !SysId.IsValid(itemId)) return false; - List filters = new List(); - String colItemTypeFrom = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom); - String colItemIdFrom = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemIdFrom); - String colItemTypeTo = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeTo); - String colItemIdTo = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_ItemIdTo); - filters.Add(colItemTypeFrom + "=" + ((int)itemType).ToString() + " AND " + colItemIdFrom + "=" + itemId.ToString()); - filters.Add(colItemTypeTo + "=" + ((int)itemType).ToString() + " AND " + colItemIdTo + "=" + itemId.ToString()); - String filter = filters.Concat(" OR ", "(", ")"); - //return db.ExecuteDelete("DELETE FROM" + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink) + " WHERE " + filter); - db.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), filter); - return false; - } - - //------------------------------------------------------------------- - // Get ItemLink. + // Get Item. public override SbmItemLink GetItemLink(SbmItemLink.Params prm) { return GetItemLink(GetItemLinkQueryFilter(prm).Concat(" AND ", "(", ")")); @@ -140,7 +62,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //------------------------------------------------------------------- - // Create ItemLink. + // Create Item. public override SbmItemLink CreateItemLink(Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo) { ClearErrorState(); @@ -158,7 +80,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr return itemLink; } //------------------------------------------------------------------- - // Has ItemLink. + // Has Item. public override bool HasItemLinks(Sbm.ItemType itemType, SysId itemId) { ClearErrorState(); @@ -175,7 +97,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //------------------------------------------------------------------- - // Validate ItemLink. + // Validate Item. public override bool IsValidItemLinkData(SbmItemLink.Data data, SbmItemLink.ErrField errField) { ClearErrorState(); @@ -184,7 +106,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //------------------------------------------------------------------- - // Insert ItemLink. + // Insert Item. public override bool InsertItemLink(SbmItemLink itemLink, DbUpdateInfo dbUpdateInfo) { String fn = GetType().Name + ".InsertItemLink"; @@ -215,7 +137,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //------------------------------------------------------------------- - // Update ItemLink. + // Update Item. public override bool UpdateItemLink(SbmItemLink itemLink, DbUpdateInfo dbUpdateInfo) { String fn = GetType().Name + ".UpdateItemLink"; @@ -232,7 +154,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { try { - // Retrieve ItemLink. + // Retrieve Item. dbConnection.Open(); ItemLink_Db dbItemLink = new ItemLink_Db(DbInfo); dbItemLink.PopulateFrom(dbCommand, aliasItemLink, "Id=" + SysId.ToString(itemLink.Id)); @@ -262,7 +184,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // LinkType = 20 [eSapItemLink_Requirement_CostEstimate]; Item Type From = 52: 1080 key values, last updated recently. // Problem stems from sequence not being set for cost estimates. //------------------------------------------------------------------- - public override bool StoreFromItemLinks(Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, List itemLinks, DbUpdateInfo dbUpdateInfo) + public override bool StoreFromItemLinks(Sbm.ItemLinkType itemLinkType, ItemId itemIdFrom, List itemLinks, DbUpdateInfo dbUpdateInfo) { ClearErrorState(); if ((int)itemLinkType < 1) return SetErrorState("invalid link type"); @@ -272,8 +194,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { if (itemLink == null) continue; if (itemLink.ItemLinkType != itemLinkType) return SetErrorState("inconsistent link type found in item list"); - if (itemLink.ItemTypeFrom != itemTypeFrom) return SetErrorState("inconsistent 'from' item type found in item list"); - if (itemLink.ItemIdFrom != itemIdFrom) return SetErrorState("inconsistent 'from' item id found in item list"); + if ((int)itemLink.ItemTypeFrom != itemIdFrom.Type) return SetErrorState("inconsistent 'from' item type found in item list"); + if (itemLink.ItemIdFrom != itemIdFrom.Id) return SetErrorState("inconsistent 'from' item id found in item list"); if (itemLink.Seq < 1) return SetErrorState("invalid sequence (" + itemLink.Seq.ToString() + ") found in item list"); } @@ -281,12 +203,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List itemLinksLocal = new List(itemLinks); SbmItemLink.Params prm = new SbmItemLink.Params(); prm.ItemLinkType = itemLinkType; - prm.ItemTypeFrom = itemTypeFrom; - prm.ItemIdFrom = itemIdFrom; + prm.ItemTypeFrom = (Sbm.ItemType)itemIdFrom.Type; + prm.ItemIdFrom = itemIdFrom.Id; foreach (SbmItemLink itemLink in DataItemMgr.GetItemLinkList(prm)) { // Does this link still exist in the list. - if (itemLinksLocal.FindByLink(itemLinkType, itemTypeFrom, itemIdFrom, prm.ItemTypeTo, prm.ItemIdTo)) + if (itemLinksLocal.FindByLink(itemLinkType, (Sbm.ItemType)itemIdFrom.Type, itemIdFrom.Id, prm.ItemTypeTo, prm.ItemIdTo)) { if (UpdateItemLink(itemLink, dbUpdateInfo)) { @@ -294,7 +216,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } else SetErrorState("failed to update link"); // Remove the lisk from the local list (without deleting it). - itemLinksLocal.RemoveByLink(itemLinkType, itemTypeFrom, itemIdFrom, prm.ItemTypeTo, prm.ItemIdTo); + itemLinksLocal.RemoveByLink(itemLinkType, (Sbm.ItemType)itemIdFrom.Type, itemIdFrom.Id, prm.ItemTypeTo, prm.ItemIdTo); } else { @@ -314,7 +236,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr return !HasErrorState(); } - public override bool StoreToItemLinks(Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeTo, SysId itemIdTo, List itemLinks, DbUpdateInfo dbUpdateInfo) + public override bool StoreToItemLinks(Sbm.ItemLinkType itemLinkType, ItemId itemIdTo, List itemLinks, DbUpdateInfo dbUpdateInfo) { ClearErrorState(); if ((int)itemLinkType < 1) return SetErrorState("invalid link type"); @@ -324,8 +246,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { if (itemLink == null) continue; if (itemLink.ItemLinkType != itemLinkType) return SetErrorState("inconsistent link type found in item list"); - if (itemLink.ItemTypeFrom != itemTypeTo) return SetErrorState("inconsistent 'from' item type found in item list"); - if (itemLink.ItemIdFrom != itemIdTo) return SetErrorState("inconsistent 'from' item id found in item list"); + if ((short)itemLink.ItemTypeFrom != itemIdTo.Type) return SetErrorState("inconsistent 'from' item type found in item list"); + if (itemLink.ItemIdFrom != itemIdTo.Id) return SetErrorState("inconsistent 'from' item id found in item list"); if (itemLink.Seq < 1) return SetErrorState("invalid sequence (" + itemLink.Seq.ToString() + ") found in item list"); } @@ -333,12 +255,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List itemLinksLocal = new List(itemLinks); SbmItemLink.Params prm = new SbmItemLink.Params(); prm.ItemLinkType = itemLinkType; - prm.ItemTypeFrom = itemTypeTo; - prm.ItemIdFrom = itemIdTo; + prm.ItemTypeFrom = (Sbm.ItemType)itemIdTo.Type; + prm.ItemIdFrom = itemIdTo.Id; foreach (SbmItemLink itemLink in DataItemMgr.GetItemLinkList(prm)) { // Does this link still exist in the list. - if (itemLinksLocal.FindByLink(itemLinkType, prm.ItemTypeFrom, prm.ItemIdFrom, itemTypeTo, itemIdTo)) + if (itemLinksLocal.FindByLink(itemLinkType, prm.ItemTypeFrom, prm.ItemIdFrom, (Sbm.ItemType)itemIdTo.Type, itemIdTo.Id)) { if (UpdateItemLink(itemLink, dbUpdateInfo)) { @@ -346,7 +268,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } else SetErrorState("failed to update link"); // Remove the lisk from the local list (without deleting it). - itemLinksLocal.RemoveByLink(itemLinkType, prm.ItemTypeFrom, prm.ItemIdFrom, itemTypeTo, itemIdTo); + itemLinksLocal.RemoveByLink(itemLinkType, prm.ItemTypeFrom, prm.ItemIdFrom, (Sbm.ItemType)itemIdTo.Type, itemIdTo.Id); } else { @@ -550,11 +472,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // ItemLink Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colItemLink_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Unknown, aliasItemLink); if (!includedIds.IsEmpty()) filter.Add(colItemLink_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colItemLink_Id + " NOT IN (" + excludedIds + ")"); @@ -708,7 +630,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetItemLinkQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetItemLinkSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs index 39c9ed8..4782bdd 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs @@ -349,11 +349,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // PriceSet Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colPriceSet_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPriceSet_Id, aliasPriceSet); if (!includedIds.IsEmpty()) filter.Add(colPriceSet_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colPriceSet_Id + " NOT IN (" + excludedIds + ")"); @@ -541,7 +541,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetPriceSetQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetPriceSetSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs index a124277..3a1d11f 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs @@ -390,11 +390,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- - // Process Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colProcess_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Process_Id, aliasProcess); if (!includedIds.IsEmpty()) filter.Add(colProcess_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colProcess_Id + " NOT IN (" + excludedIds + ")"); @@ -555,7 +555,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetProcessQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetProcessSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs index cf92d2a..ec02df5 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs @@ -340,10 +340,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Location Id. String colLocation_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Location_Id, aliasLocation); - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); if (!includedIds.IsEmpty()) filter.Add(colLocation_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colLocation_Id + " NOT IN (" + excludedIds + ")"); @@ -519,7 +519,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetLocationQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetLocationSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs index c720c0d..d5c1449 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs @@ -103,6 +103,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List values = new List(); SacsDatabase.AddValuePair(values, colMovement_Status, StatusCancelled, true); db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), values, lFilterSourceItem.Concat(" AND ", "(", ")")); + if (db.HasErrorState()) + SetErrorState($"{db.ErrorStateMessage}"); // ToDo CalculateStockLevels(commodityIds); > in Stock-MgrDbas return !HasErrorState(); @@ -597,10 +599,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //Movement Id. String colMovement_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_Id, aliasMovement); - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); if (!includedIds.IsEmpty()) filters.Add(colMovement_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filters.Add(colMovement_Id + " NOT IN (" + excludedIds + ")"); @@ -733,7 +735,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Performance of querying requirements for transaction(s) within movement query is very poor - eg. ItemIdSource in (Select Id From Requirement Where TransactionId in (1,2,3)). // Get list of requirement Ids first and then explicitly query against these in the movement query. SbmTransaction.Params prmTrans = new SbmTransaction.Params(); - prmTrans.IncludedIds = prm.ItemIdSource; + prmTrans.IdsIncluded = prm.ItemIdSource; List requirementId = TransactionMgr.GetRequirementByIds(prmTrans); // Movements can be matched: either directly to one of the transactions or to any of their associated requirements. @@ -1036,7 +1038,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetMovementQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetMovementSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs index 090defc..35b38c2 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs @@ -796,11 +796,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // Constituent Id. - String includedIds = prm.IncludedIds.Concat(","); + String includedIds = prm.IdsIncluded.Concat(","); String colConstituent_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Constituent_Id, aliasConstituent); if (!includedIds.IsEmpty()) filter.Add(colConstituent_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ExcludedIds.Concat(","); + String excludedIds = prm.IdsExcluded.Concat(","); if (!excludedIds.IsEmpty()) filter.Add(colConstituent_Id + " NOT IN (" + excludedIds + ")"); @@ -1198,7 +1198,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetConstituentQueryFilter(prm)); - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetConstituentSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs index 0d88195..4e57c0e 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs @@ -132,7 +132,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SysId.IsValid(requirementId)) return SetErrorState("Invalid item specified"); - String fn = this.GetFn("ClearRequirementDependentData"); // Clear any references to this requirement from other requirements. if (!HasErrorState()) ClearRequirementAssociatedRequirements(requirementId); @@ -144,7 +143,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (db.HasErrorState()) { String msg = "Failed to clear requirement constituents"; - SaLogger.Warn(fn + " " + msg + ": " + db.ErrorStateMessage + ". RequirentId: " + SysId.ToString(requirementId)); + SaLogger.Warn($"{SysUtil.Fn} {msg}: {db.ErrorStateMessage}. RequirentId: {SysId.ToString(requirementId)}."); SetErrorState(msg); } } @@ -163,7 +162,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DataItemMgr.ClearDataItem(Sbm.ItemType.Requirement, requirementId)) { String msg = "failed to clear requirement item links"; - SaLogger.Warn(fn + " " + msg + ": " + DataItemMgr.ErrorStateMessage + ". RequirentId: " + SysId.ToString(requirementId)); + SaLogger.Warn($"{SysUtil.Fn} {msg}: {DataItemMgr.ErrorStateMessage}. RequirentId: {requirementId}."); SetErrorState(msg); } } @@ -178,9 +177,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List values = new List(); SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_ReqntIdSource), "0", false); db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filter); - { + if (db.HasErrorState()) SetErrorState("Failed to clear requirement references"); - } return !HasErrorState(); } @@ -804,12 +802,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr break; case SbmRequirement.Column.ProductCode: SetRequirementColDfn(columnDfn, "Code", 120, SbmDbDfn.ColumnIdx.Requirement_ProductCode); - if (ConfigConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityDoubleColumnWidth)) + if (SessionConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityDoubleColumnWidth)) columnDfn.Width = columnDfn.Width * 2; break; case SbmRequirement.Column.DescBrief: SetRequirementColDfn(columnDfn, "Description", 140, SbmDbDfn.ColumnIdx.Requirement_DescBrief); - if (ConfigConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityDoubleColumnWidth)) + if (SessionConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityDoubleColumnWidth)) columnDfn.Width = columnDfn.Width * 2; break; case SbmRequirement.Column.DescOutline: @@ -1785,13 +1783,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Validate the parameters. #if DEBUG - if (!SysId.IsValid(AffiliateId_Owner) && !SysId.IsValid(prm.AssociationId) && !SysId.IsValid(prm.CommodityId) && !SysId.IsValid(prm.TransReqntSourceId) && !prm.TransIncludedIds.HasValidIds() && !prm.ReqntIncludedIds.HasValidIds() && !prm.ReqntIdsSource.HasValidIds()) + if (!SysId.IsValid(AffiliateId_Owner) && !SysId.IsValid(prm.AssociationId) && !SysId.IsValid(prm.CommodityId) && !SysId.IsValid(prm.TransactionRequirementSourceId) && !prm.TransactionIdsIncluded.HasValidIds() && !prm.RequirementIdsIncluded.HasValidIds() && !prm.RequirementIdsSource.HasValidIds()) SaLogger.Trace("\t### " + GetType().Name + ".GetRequirementQueryFilter - Owner/association/transaction not specified."); #endif //--------------------------------------------------------------- // Affiliate Owner - only need to be filtered if no significant Ids specified. - bool filterByOwner = !SysId.IsValid(prm.AssociationId) && !SysId.IsValid(prm.CommodityId) && !SysId.IsValid(prm.TransReqntSourceId) && !prm.TransIncludedIds.HasValidIds() && !prm.ReqntIncludedIds.HasValidIds() && !prm.ReqntIdsSource.HasValidIds(); + bool filterByOwner = !SysId.IsValid(prm.AssociationId) && !SysId.IsValid(prm.CommodityId) && !SysId.IsValid(prm.TransactionRequirementSourceId) && !prm.TransactionIdsIncluded.HasValidIds() && !prm.RequirementIdsIncluded.HasValidIds() && !prm.RequirementIdsSource.HasValidIds(); if (filterByOwner) filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_AffIdOwner, tableAlias, false) + "=" + SysId.ToString(AffiliateId_Owner)); @@ -1803,7 +1801,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filter.Add(colRequirement_AssocId + "=" + prm.AssociationId.ToString()); // Association coding. - String assocFilter = DbQuery.FormatForCondition(prm.AssocPartial); + String assocFilter = DbQuery.FormatForCondition(prm.AssociationPartial); String accountManagerCode = DbQuery.FormatForCondition(prm.AccountManagerCode); String accountHandlerCode = DbQuery.FormatForCondition(prm.AccountHandlerCode); if (!StringUtil.IsEmpty(assocFilter) || !StringUtil.IsEmpty(accountManagerCode) || !StringUtil.IsEmpty(accountHandlerCode)) @@ -1832,8 +1830,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colAssociation_Code = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Code, tableAlias_Assoc, false); String colAffiliate_Name = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Name, tableAlias_AssocTarget, false); List filterAssoc = new List(); - filterAssoc.Add(DbQuery.FormatFn_Left(colAssociation_Code, prm.AssocPartial.Length) + "='" + assocFilter + "'"); - filterAssoc.Add(DbQuery.FormatFn_Left(colAffiliate_Name, prm.AssocPartial.Length) + "='" + assocFilter + "'"); + filterAssoc.Add(DbQuery.FormatFn_Left(colAssociation_Code, prm.AssociationPartial.Length) + "='" + assocFilter + "'"); + filterAssoc.Add(DbQuery.FormatFn_Left(colAffiliate_Name, prm.AssociationPartial.Length) + "='" + assocFilter + "'"); qryAssoc.Filters.Add(filterAssoc.Concat(" OR ", "(", ")")); } // Account Manager. @@ -1855,30 +1853,30 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Transaction filter. String colRequirement_TransId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, tableAlias, false); - if (prm.TransIncludedIds.HasValidIds()) - filter.Add(colRequirement_TransId + " IN(" + prm.TransIncludedIds.Concat(",") + ")"); - if (prm.TransExcludedIds.HasValidIds()) - filter.Add(colRequirement_TransId + " NOT IN(" + prm.TransExcludedIds.Concat(",") + ")"); + if (prm.TransactionIdsIncluded.HasValidIds()) + filter.Add(colRequirement_TransId + " IN(" + prm.TransactionIdsIncluded.Concat(",") + ")"); + if (prm.TransactionIdsExcluded.HasValidIds()) + filter.Add(colRequirement_TransId + " NOT IN(" + prm.TransactionIdsExcluded.Concat(",") + ")"); // Transaction parameters. SbmTransaction.Params prmTrans = new SbmTransaction.Params(); prmTrans.TableAlias = StringUtil.OnEmpty(prm.AliasTransaction, "ReqTra"); prmTrans.IncludeDefaultFilter = false; prmTrans.TransactionType = prm.TransactionType; - prmTrans.LocationIdStock = prm.TransLocationIdStock; + prmTrans.LocationIdStock = prm.TransactionLocationIdStock; prmTrans.StatusCat = prm.TransactionStatusCat; - prmTrans.TransRefPartial = prm.TransRefPartial; - prmTrans.TransRefExtPartial = prm.TransRefExtPartial; - prmTrans.TransDescBriefPartial = prm.TransDescBriefPartial; - prmTrans.RaisedFrom = prm.TransRaisedFrom; - prmTrans.RaisedTo = prm.TransRaisedTo; - prmTrans.RequiredFrom = prm.TransRequiredFrom; - prmTrans.RequiredTo = prm.TransRequiredTo; - prmTrans.AmountNetLt = prm.TransAmountNetLt; - prmTrans.AmountNetGt = prm.TransAmountNetGt; - prmTrans.ActiveOn = prm.TransActiveOn; - prmTrans.ActiveFrom = prm.TransActiveFrom; - prmTrans.ActiveTo = prm.TransActiveTo; + prmTrans.TransRefPartial = prm.TransactionRefPartial; + prmTrans.TransRefExtPartial = prm.TransactionRefExtPartial; + prmTrans.TransDescBriefPartial = prm.TransactionDescBriefPartial; + prmTrans.RaisedFrom = prm.TransactionRaisedFrom; + prmTrans.RaisedTo = prm.TransactionRaisedTo; + prmTrans.RequiredFrom = prm.TransactionRequiredFrom; + prmTrans.RequiredTo = prm.TransactionRequiredTo; + prmTrans.AmountNetLt = prm.TransactionAmountNetLt; + prmTrans.AmountNetGt = prm.TransactionAmountNetGt; + prmTrans.ActiveOn = prm.TransactionActiveOn; + prmTrans.ActiveFrom = prm.TransactionActiveFrom; + prmTrans.ActiveTo = prm.TransactionActiveTo; prmTrans.ForceFullResults = true; List transactionFilters = TransactionMgr.GetTransactionQueryFilter(prmTrans); if (transactionFilters.Count > 0) @@ -1901,21 +1899,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Requirement Details: // IncludeIds & ExcludeIds. - String includedIds = prm.ReqntIncludedIds.Concat(","); + String includedIds = prm.RequirementIdsIncluded.Concat(","); String colRequirement_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, tableAlias); if (!StringUtil.IsEmpty(includedIds)) filter.Add(colRequirement_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.ReqntExcludedIds.Concat(","); + String excludedIds = prm.RequirementIdsExcluded.Concat(","); if (!StringUtil.IsEmpty(excludedIds)) filter.Add(colRequirement_Id + " NOT IN (" + excludedIds + ")"); // Source Requirement. String colRequirement_ReqntIdSource = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_ReqntIdSource, tableAlias, false); - if (prm.ReqntIdsSource.HasValidIds()) - filter.Add(colRequirement_ReqntIdSource + " IN (" + prm.ReqntIdsSource.Concat(",") + ")"); + if (prm.RequirementIdsSource.HasValidIds()) + filter.Add(colRequirement_ReqntIdSource + " IN (" + prm.RequirementIdsSource.Concat(",") + ")"); // Source Requirment Transaction. - if (SysId.IsValid(prm.TransReqntSourceId)) + if (SysId.IsValid(prm.TransactionRequirementSourceId)) { String tableAlias_ReqntSource = "ReqSrcFlt"; String colRequirementId_ReqntSource = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, tableAlias_ReqntSource, false); @@ -1923,21 +1921,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), tableAlias_ReqntSource); qryTrans.Columns.Add(colRequirementId_ReqntSource); qryTrans.Filters.Add(colRequirementId_ReqntSource + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_ReqntIdSource, tableAlias, false)); - if (SysId.IsValid(prm.TransReqntSourceId)) - qryTrans.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, tableAlias_ReqntSource, false) + "=" + prm.TransReqntSourceId.ToString()); + if (SysId.IsValid(prm.TransactionRequirementSourceId)) + qryTrans.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, tableAlias_ReqntSource, false) + "=" + prm.TransactionRequirementSourceId.ToString()); // Add this transaction sub-query to the filter. filter.Add("EXISTS(" + qryTrans.BuildQuery() + ")"); } // Requirement DescBrief. - String reqntDescBrief = DbQuery.FormatForCondition(prm.ReqntDescBrief); + String reqntDescBrief = DbQuery.FormatForCondition(prm.RequirementDescBrief); String Requirement_DescBrief = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_DescBrief, tableAlias, false); if (!reqntDescBrief.IsEmpty()) filter.Add(DbQuery.FormatFn_Left(Requirement_DescBrief, reqntDescBrief.Length) + "='" + reqntDescBrief + "'"); // Promotion Code. - if (!StringUtil.IsEmpty(prm.ReqntPromotionCode)) - filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_PromotionCode, tableAlias, false) + "='" + DbQuery.FormatForCondition(prm.ReqntPromotionCode) + "'"); + if (!StringUtil.IsEmpty(prm.RequirementPromotionCode)) + filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_PromotionCode, tableAlias, false) + "='" + DbQuery.FormatForCondition(prm.RequirementPromotionCode) + "'"); //--------------------------------------------------------------- @@ -1947,10 +1945,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_CommodityId, tableAlias, false) + "=" + prm.CommodityId.ToString()); // Product Code. - if (!prm.ReqntProductCodeFull.IsEmpty() || !prm.ReqntProductCodePartial.IsEmpty()) + if (!prm.RequirementProductCodeFull.IsEmpty() || !prm.RequirementProductCodePartial.IsEmpty()) { - String reqntProductCodeFull = DbQuery.FormatForCondition(prm.ReqntProductCodeFull); - String reqntProductCodePartial = DbQuery.FormatForCondition(prm.ReqntProductCodePartial); + String reqntProductCodeFull = DbQuery.FormatForCondition(prm.RequirementProductCodeFull); + String reqntProductCodePartial = DbQuery.FormatForCondition(prm.RequirementProductCodePartial); String colRequirement_ProductCode = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_ProductCode, tableAlias); if (!reqntProductCodeFull.IsEmpty()) { @@ -1958,9 +1956,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } else if (!reqntProductCodePartial.IsEmpty()) { - if (ConfigConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityPartialCodeFilter)) + if (SessionConsole != null && AllowConfigOption(Sbm.ConfigOption.CommodityPartialCodeFilter)) filter.Add(colRequirement_ProductCode + " LIKE '%" + DbQuery.FormatForLike(reqntProductCodePartial) + "%'"); - else filter.Add(DbQuery.FormatFn_Left(colRequirement_ProductCode, prm.ReqntProductCodePartial.Length) + "='" + reqntProductCodePartial + "'"); + else filter.Add(DbQuery.FormatFn_Left(colRequirement_ProductCode, prm.RequirementProductCodePartial.Length) + "='" + reqntProductCodePartial + "'"); } } @@ -1994,15 +1992,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------ // Project Task Code. - if (!StringUtil.IsEmpty(prm.ReqntProjectTaskCodeFull) || !StringUtil.IsEmpty(prm.ReqntProjectTaskCodePartial)) + if (!StringUtil.IsEmpty(prm.RequirementProjectTaskCodeFull) || !StringUtil.IsEmpty(prm.RequirementProjectTaskCodePartial)) { String colRequirement_ProductCode = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_ProductCode, tableAlias, false); - if (!StringUtil.IsEmpty(prm.ReqntProjectTaskCodeFull)) - filter.Add(colRequirement_ProductCode + "='" + DbQuery.FormatForCondition(prm.ReqntProjectTaskCodeFull) + "'"); - else if (!StringUtil.IsEmpty(prm.ReqntProjectTaskCodePartial)) + if (!StringUtil.IsEmpty(prm.RequirementProjectTaskCodeFull)) + filter.Add(colRequirement_ProductCode + "='" + DbQuery.FormatForCondition(prm.RequirementProjectTaskCodeFull) + "'"); + else if (!StringUtil.IsEmpty(prm.RequirementProjectTaskCodePartial)) { - String reqntProjectTaskCodePartial = DbQuery.FormatForCondition(prm.ReqntProjectTaskCodePartial); - filter.Add(DbQuery.FormatFn_Left(colRequirement_ProductCode, prm.ReqntProjectTaskCodePartial.Length) + "='" + reqntProjectTaskCodePartial + "'"); + String reqntProjectTaskCodePartial = DbQuery.FormatForCondition(prm.RequirementProjectTaskCodePartial); + filter.Add(DbQuery.FormatFn_Left(colRequirement_ProductCode, prm.RequirementProjectTaskCodePartial.Length) + "='" + reqntProjectTaskCodePartial + "'"); } // Force the transaction type of 'Project'. if (prm.TransactionType != Sbm.TransactionType.Project) @@ -2021,13 +2019,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Job Number. - if (!StringUtil.IsEmpty(prm.ReqntJobNumberFull) || !StringUtil.IsEmpty(prm.ReqntJobNumberPartial)) + if (!StringUtil.IsEmpty(prm.RequirementJobNumberFull) || !StringUtil.IsEmpty(prm.RequirementJobNumberPartial)) { String colRequirement_JobNumber = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_JobNumber, tableAlias, false); - if (!StringUtil.IsEmpty(prm.ReqntJobNumberFull)) - filter.Add(colRequirement_JobNumber + "='" + DbQuery.FormatForCondition(prm.ReqntJobNumberFull) + "'"); - else if (!StringUtil.IsEmpty(prm.ReqntJobNumberPartial)) - filter.Add(DbQuery.FormatFn_Left(colRequirement_JobNumber, prm.ReqntJobNumberPartial.Length) + "='" + DbQuery.FormatForCondition(prm.ReqntJobNumberPartial) + "'"); + if (!StringUtil.IsEmpty(prm.RequirementJobNumberFull)) + filter.Add(colRequirement_JobNumber + "='" + DbQuery.FormatForCondition(prm.RequirementJobNumberFull) + "'"); + else if (!StringUtil.IsEmpty(prm.RequirementJobNumberPartial)) + filter.Add(DbQuery.FormatFn_Left(colRequirement_JobNumber, prm.RequirementJobNumberPartial.Length) + "='" + DbQuery.FormatForCondition(prm.RequirementJobNumberPartial) + "'"); } @@ -2042,13 +2040,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Required date. - if (DateUtil.IsValid(prm.ReqntRequiredFrom)) + if (DateUtil.IsValid(prm.RequirementRequiredFrom)) { - filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Required, tableAlias, false) + ">=" + DbQuery.FormatForCondition(prm.ReqntRequiredFrom.ToString())); + filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Required, tableAlias, false) + ">=" + DbQuery.FormatForCondition(prm.RequirementRequiredFrom.ToString())); } - if (DateUtil.IsValid(prm.ReqntRequiredTo)) + if (DateUtil.IsValid(prm.RequirementRequiredTo)) { - filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Required, tableAlias, false) + "<" + DbQuery.FormatForCondition(prm.ReqntRequiredTo.ToLongDateString() + 1)); + filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Required, tableAlias, false) + "<" + DbQuery.FormatForCondition(prm.RequirementRequiredTo.ToLongDateString() + 1)); } //--------------------------------------------------------------- @@ -2182,7 +2180,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override List GetRequirementsForTransaction(SysId transactionId) { SbmRequirement.Params prmRequirement = new SbmRequirement.Params(); - prmRequirement.TransIncludedIds.Add(transactionId); + prmRequirement.TransactionIdsIncluded.Add(transactionId); prmRequirement.StatusCat = SbmRequirement.StatusCat.Any; return GetRequirementList(prmRequirement); } @@ -3186,7 +3184,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate filter. query.Filters.AddRange(GetRequirementQueryFilter(prm)); - if (prm.ReqntIncludedIds.Count != 1) + if (prm.RequirementIdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetRequirementSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs index 7d1d4a0..f3c197e 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs @@ -113,7 +113,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_AssocId), assocId.ToString(), false); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_TransId) + "=" + transaction.Id.ToString()); - if (db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), values, filters.Concat(" AND ", "(", ")")) > 0) + db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), values, filters.Concat(" AND ", "(", ")")); + if (db.HasErrorState()) { SetErrorState(errorStatePrefix + "transaction updates failed"); ChangeTransactionsAssociation(transaction, transaction.AssociationId); // To reset changes. @@ -123,7 +124,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_AssocId), assocId.ToString(), false); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_TransId) + "=" + transaction.Id.ToString()); - if (db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filters.Concat(" AND ", "(", ")")) > 0) + db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filters.Concat(" AND ", "(", ")")); + if (db.HasErrorState()) { SetErrorState(errorStatePrefix + "requirement updates failed"); ChangeTransactionsAssociation(transaction, transaction.AssociationId); // To reset changes. @@ -134,7 +136,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filters.Clear(); values.Clear(); SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_AssocId), assocId.ToString(), false); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_Id) + "=" + transaction.Id.ToString()); - if (db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), values, filters.Concat(" AND ", "(", ")")) > 0) + db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), values, filters.Concat(" AND ", "(", ")")); + if (db.HasErrorState()) { SetErrorState(errorStatePrefix + "transaction update failed"); ChangeTransactionsAssociation(transaction, transaction.AssociationId); // To reset changes. @@ -154,7 +157,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { /* ToDo create RefreshAllocations in StockMgr for Stock Allocations. if (!InitStockMgr()) SetErrorState("Failed to create Stock Manager"); - if (!HasErrorState() && !StockMgr.RefreshAllocations(transaction, requirements, false)) SetErrorState(StockMgr.ErrorState.ToString()); + if (!HasErrorState() && !StockMgr.RefreshAllocations(transaction, requirements, false)) SetErrorState(StockMgr.ErrorStateMessage); // NB 'RefreshAllocations' updates transaction stock allocation status if necessary.*/ } @@ -168,7 +171,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Refresh totals. if (transaction.RefreshTotals(requirements)) UpdateTransaction(transaction, UserContext.DbUpdateInfo); - else SetErrorState(transaction.ErrorState.ToString()); + else SetErrorState(transaction.ErrorStateMessage); } if (requirementListCreatedLocally) @@ -569,7 +572,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Requirements. int requirementCount = (int)transaction.GetRequirementCount(); - if (requirementCount > 0 && (ConfigConsole == null || !ConfigConsole.CanRemoveTransactionWithRequirements(UserContext, transaction, requirementCount))) + if (requirementCount > 0 && (SessionConsole == null || !SessionConsole.CanRemoveTransactionWithRequirements(transaction, requirementCount))) { if (requirementCount == 1) return SetErrorState("item has a requirement"); else return SetErrorState("item has multiple requirements"); @@ -1275,10 +1278,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Transaction Id. - if (prm.IncludedIds.HasValidIds()) - filter.Add(colTransaction_Id + " IN (" + prm.IncludedIds.Concat(",") + ")"); - if (prm.ExcludedIds.HasValidIds()) - filter.Add(colTransaction_Id + " NOT IN (" + prm.ExcludedIds.Concat(",") + ")"); + if (prm.IdsIncluded.HasValidIds()) + filter.Add(colTransaction_Id + " IN (" + prm.IdsIncluded.Concat(",") + ")"); + if (prm.IdsExcluded.HasValidIds()) + filter.Add(colTransaction_Id + " NOT IN (" + prm.IdsExcluded.Concat(",") + ")"); //--------------------------------------------------------------- // Transaction Source. @@ -1290,7 +1293,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filtersSource.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_TransIdSource, tableAlias) + "=" + prm.TransIdSource.ToString()); // Check for combinations that allow secondary refs: bool checkForSecondaryRefs = false; - if (ConfigConsole != null && AllowTransactionType(Sbm.TransactionType.SalesDispatch) && + if (SessionConsole != null && AllowTransactionType(Sbm.TransactionType.SalesDispatch) && (AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice) || AllowTransactionType(Sbm.TransactionType.SalesInvoice))) checkForSecondaryRefs = true; if (checkForSecondaryRefs) @@ -1420,7 +1423,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SysId.IsValid(AffiliateId_Owner)) { // Only need to filter on owner if no association specified, no transaction Ids and no source transaction id. - if (!SysId.IsValid(prm.AssocId) && !prm.IncludedIds.HasValidIds() && !SysId.IsValid(prm.TransIdSource)) + if (!SysId.IsValid(prm.AssocId) && !prm.IdsIncluded.HasValidIds() && !SysId.IsValid(prm.TransIdSource)) filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_AffIdOwner, tableAlias) + "=" + SysId.ToString(AffiliateId_Owner)); } @@ -2076,9 +2079,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (checkForInvoices) { // Check which types of transaction are allowed. - bool invoicesAllowed = ConfigConsole != null && (AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice) || AllowTransactionType(Sbm.TransactionType.SalesInvoice) || + bool invoicesAllowed = SessionConsole != null && (AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice) || AllowTransactionType(Sbm.TransactionType.SalesInvoice) || AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice) || AllowTransactionType(Sbm.TransactionType.PurchaseInvoice)); - bool dispatchesAllowed = ConfigConsole != null && AllowTransactionType(Sbm.TransactionType.SalesDispatch); + bool dispatchesAllowed = SessionConsole != null && AllowTransactionType(Sbm.TransactionType.SalesDispatch); if (invoicesAllowed) { // Aliases & Columns. @@ -2154,7 +2157,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } } - if (prm.IncludedIds.Count != 1) + if (prm.IdsIncluded.Count != 1) { // Configure sort sequence. foreach (String sortColumn in GetTransactionSortColumns(prm)) diff --git a/SaBusMgrStandardDbas/SaBusMgrStandardDbas.csproj b/SaBusMgrStandardDbas/SaBusMgrStandardDbas.csproj index b8b544d..7213c7e 100644 --- a/SaBusMgrStandardDbas/SaBusMgrStandardDbas.csproj +++ b/SaBusMgrStandardDbas/SaBusMgrStandardDbas.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/SaBusMgrTest_Control/SaBusMgrTest_Control.csproj b/SaBusMgrTest_Control/SaBusMgrTest_Control.csproj index 53d9a06..88e22e1 100644 --- a/SaBusMgrTest_Control/SaBusMgrTest_Control.csproj +++ b/SaBusMgrTest_Control/SaBusMgrTest_Control.csproj @@ -11,11 +11,16 @@ - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - + + + diff --git a/SaBusMgrTest_Portal/SaBusMgrTest_Portal.csproj b/SaBusMgrTest_Portal/SaBusMgrTest_Portal.csproj index d66175c..de20bc4 100644 --- a/SaBusMgrTest_Portal/SaBusMgrTest_Portal.csproj +++ b/SaBusMgrTest_Portal/SaBusMgrTest_Portal.csproj @@ -14,14 +14,16 @@ Sarand.BusinessMgr.Test - + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/SaBusMgrTest_Portal/Web/Portal/App/SbmPortalApp_Tester_Base.cs b/SaBusMgrTest_Portal/Web/Portal/App/SbmPortalApp_Tester_Base.cs index 754d791..5b093d0 100644 --- a/SaBusMgrTest_Portal/Web/Portal/App/SbmPortalApp_Tester_Base.cs +++ b/SaBusMgrTest_Portal/Web/Portal/App/SbmPortalApp_Tester_Base.cs @@ -9,60 +9,60 @@ using Sarand.Net.Standard.Base.Dbas; namespace Sarand.BusinessMgr.Test.Web.Portal.App { - //======================================================================= - public class SbmPortalApp_Tester_Base - { - //------------------------------------------------------------------- - // Application. - private class SbmApplication_Portal_Test : SbmApplication_Portal - { - public SbmApplication_Portal_Test(IConfiguration configuration, IWebHostEnvironment env) : - base(configuration) - { - InitEnvironment(env); - } - } + //======================================================================= + public class SbmPortalApp_Tester_Base + { + //------------------------------------------------------------------- + // Application. + private class SbmApplication_Portal_Test : SbmApplication_Portal + { + public SbmApplication_Portal_Test(IConfiguration configuration, IWebHostEnvironment env) : + base(configuration) + { + InitEnvironment(env); + } + } - //------------------------------------------------------------------- - // Data members. + //------------------------------------------------------------------- + // Data members. - //------------------------------------------------------------------- - // Construction. - protected SbmPortalApp_Tester_Base() - { - // Application. - Mock mockConfiguration = new Mock(); - Mock mockEnvironment = new Mock(); - mockEnvironment.Setup(m => m.EnvironmentName).Returns(Environments.Development); - mockEnvironment.Setup(m => m.ContentRootPath).Returns(@"D:\Sarand\Projects\Users\AHoward\VS2022\BusinessMgr\Workspace\SaBusinessMgrCoreWebPortal"); - App = new SbmApplication_Portal_Test(mockConfiguration.Object, mockEnvironment.Object); + //------------------------------------------------------------------- + // Construction. + protected SbmPortalApp_Tester_Base() + { + // Application. + Mock mockConfiguration = new Mock(); + Mock mockEnvironment = new Mock(); + mockEnvironment.Setup(m => m.EnvironmentName).Returns(Environments.Development); + mockEnvironment.Setup(m => m.ContentRootPath).Returns(@"D:\Sarand\Projects\Users\AHoward\VS2022\BusinessMgr\Workspace\SaBusinessMgrCoreWebPortal"); + App = new SbmApplication_Portal_Test(mockConfiguration.Object, mockEnvironment.Object); - // Session configuration. - SessionContextIdx = App.GetSessionContextIdxs()[0]; - SessionContext = App.GetSessionContext(SessionContextIdx); - Internals = new SbmInternals(GetUserContext(SessionContext)); - UserContext = GetUserContext(SessionContext); - } + // Session configuration. + SessionContextIdx = App.GetSessionContextIdxs()[0]; + SessionContext = App.GetSessionContext(SessionContextIdx); + Internals = new SbmInternals(GetUserContext(SessionContext)); + UserContext = GetUserContext(SessionContext); + } - //------------------------------------------------------------------- - // Properties. - protected ushort SessionContextIdx { get; } - protected SbmApplication_Portal App { get; } - protected SbmSessionContext SessionContext { get; } - protected ISacsDatabase BusMgrDatabase { get { return App.GetBusMgrDatabase(SessionContext); } } - protected SbmInternals Internals { get; } - protected SbmUserContext UserContext { get; } + //------------------------------------------------------------------- + // Properties. + protected ushort SessionContextIdx { get; } + protected SbmApplication_Portal App { get; } + protected SbmSessionContext SessionContext { get; } + protected ISacsDatabase BusMgrDatabase { get { return App.GetBusMgrDatabase(SessionContext); } } + protected SbmInternals Internals { get; } + protected SbmUserContext UserContext { get; } - //------------------------------------------------------------------- - // User Context. - public static SbmUserContext GetUserContext(SbmSessionContext sessionContext) - { - SbmUserContext userContext = new SbmUserContext_Web(sessionContext); + //------------------------------------------------------------------- + // User Context. + public static SbmUserContext GetUserContext(SbmSessionContext sessionContext) + { + SbmUserContext userContext = new SbmUserContext_Web(sessionContext); - return userContext; - } + return userContext; + } - //------------------------------------------------------------------- - } - //======================================================================= + //------------------------------------------------------------------- + } + //======================================================================= } diff --git a/SaBusMgrTest_Portal/Web/Portal/App/SbmSessionData_Portal_Test.cs b/SaBusMgrTest_Portal/Web/Portal/App/SbmSessionData_Portal_Test.cs index 62b890e..111258c 100644 --- a/SaBusMgrTest_Portal/Web/Portal/App/SbmSessionData_Portal_Test.cs +++ b/SaBusMgrTest_Portal/Web/Portal/App/SbmSessionData_Portal_Test.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Sarand.BusinessMgr.Net.Core.Web.Controllers; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.BusinessMgr.Net.Standard.Base.Consoles; using Sarand.BusinessMgr.Net.Standard.Base.Mgr; using Sarand.BusinessMgr.Web.Portal.App; using Sarand.Net.Standard.Base.Bus; @@ -35,9 +36,13 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App // Internals. SaSecurityConsole securityConsole = App.CreateSecurityConsole(UserContext); Assert.IsNotNull(securityConsole); + securityConsole.RegisterSecurityRights(); SbmAccountMgr accountMgr = Internals.AccountMgr; Assert.IsNotNull(accountMgr); + // Session Console. + SbmSessionConsole sessionConsole = SbmSessionConsole.CreateConsole(UserContext); + // Database context. string dbIdentifier = "SBMDB4321"; @@ -45,6 +50,8 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App SaSecurityItem securityItemUser = securityConsole.GetUserByEmail("andy@sarand.com"); Assert.IsNotNull(securityItemUser); + // Security profile. + // User account. SbmAffiliate affiliateUser = accountMgr.GetAffiliateByUserId(securityItemUser.Id); Assert.IsNotNull(affiliateUser); @@ -71,6 +78,11 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App Assert.AreEqual(securityItemUser.Id, sessionData.User.SecurityItemId); Assert.AreEqual(securityItemUser.EmailAddress, sessionData.User.EmailAddress); + // Security profile. + sessionData.SecurityProfile_Core.RefreshProfile(sessionConsole, securityConsole, securityItemUser.Id, securityConsole.GetRegisteredRights()); + Assert.IsTrue(sessionData.SecurityProfile_Core.UserCanCreateContacts()); + Assert.IsTrue(sessionData.SecurityProfile_Core.UserCanViewFinancials()); + // User details. Assert.AreEqual(affiliateUser.Id, sessionData.User.AffiliateId); Assert.AreEqual(affiliateUser.FirstName, sessionData.User.FirstName); @@ -92,6 +104,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App // Deserialise data. SbmSessionData_Portal sessionDataDeserialized = JsonConvert.DeserializeObject(sessionDataJson, SbmController_Web.SbmSessionDataJsonSerializerSettings); Assert.IsNotNull(sessionDataDeserialized); + string sessionDataJsonDeserialized = JsonConvert.SerializeObject(sessionDataDeserialized); // Validate deserialised data. Assert.IsTrue(!StringUtil.IsBlank(sessionData.Base64IV_PortalApp)); @@ -108,6 +121,14 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App Assert.AreEqual(securityItemUser.Id, sessionDataDeserialized.User.SecurityItemId); Assert.AreEqual(securityItemUser.EmailAddress, sessionDataDeserialized.User.EmailAddress); + // Security profile. + sessionData.SecurityProfile_Core.RefreshProfile(sessionConsole, securityConsole, securityItemUser.Id, securityConsole.GetRegisteredRights()); + Assert.IsNotNull(sessionDataDeserialized.SecurityProfile_Core); + Assert.AreEqual(sessionData.SecurityProfile_Core.UserCanCreateContacts(), sessionDataDeserialized.SecurityProfile_Core.UserCanCreateContacts()); + Assert.IsTrue(sessionDataDeserialized.SecurityProfile_Core.UserCanCreateContacts()); + Assert.AreEqual(sessionData.SecurityProfile_Core.UserCanViewFinancials(), sessionDataDeserialized.SecurityProfile_Core.UserCanViewFinancials()); + Assert.IsTrue(sessionDataDeserialized.SecurityProfile_Core.UserCanViewFinancials()); + // User details. Assert.AreEqual(affiliateUser.Id, sessionDataDeserialized.User.AffiliateId); Assert.AreEqual(affiliateUser.FirstName, sessionDataDeserialized.User.FirstName); diff --git a/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs b/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs index bdd055c..bc56a35 100644 --- a/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Sarand.Net.Standard.Base.ReferenceData; namespace Sarand.BusinessMgr.Web.Control.App { @@ -30,7 +31,7 @@ namespace Sarand.BusinessMgr.Web.Control.App private bool generateDatabaseDefinitions_Control = false; private bool generateDatabaseDefinitions_BusMgr = false; private PropertySet propertySet; - private Dictionary appConfigs = new Dictionary(); + private Dictionary appConfigs = new Dictionary(); private Dictionary emailConfigs = new Dictionary(); ushort sessionContextIdx_Control = 0; // Singular databases. @@ -71,7 +72,7 @@ namespace Sarand.BusinessMgr.Web.Control.App //------------------------------------------------------------------- // Properties. // Application Configuration. - public override SbmAppConfig AppConfig { get { return appConfigs.Values.ToList().getConfigForApplication(); } } + public override Net.Core.Web.App.SbmAppConfig AppConfig { get { return appConfigs.Values.ToList().getConfigForApplication(); } } // Session Configuration. public override String SessionCookieName { get { return Sbm.Config.Control.Session.Cookie.Name; } } public override List GetSessionContextIdxs() @@ -82,6 +83,7 @@ namespace Sarand.BusinessMgr.Web.Control.App { return sessionContexts.GetValue(index, null)?.SessionContext ?? null; } + // Databases. public override ISacsDatabase GetControlDatabase() { return controlDatabase; @@ -98,10 +100,20 @@ namespace Sarand.BusinessMgr.Web.Control.App { return sessionContexts.GetValue(sessionContext.Index, null)?.BusMgrDatabase; } + // Instance configuration. + public override SbmInstanceConfig GetInstanceConfig(SbmSessionContext sessionContext) + { + throw new NotSupportedException("InstanceConfig not supported in Control application."); + } + // Email configuration. public override SbmEmailConfig EmailConfig { get { return emailConfigs.Values.ToList().getConfigForSession(AppConfig); } } //------------------------------------------------------------------- // Create Consoles. + public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext_Core userContext) + { + return null; + } public override SbmEmailConsole CreateEmailConsole(ISbmUserContext_Core userContext) { return new SbmEmailConsole_Control(EmailConfig); @@ -177,24 +189,24 @@ namespace Sarand.BusinessMgr.Web.Control.App } // BusinessMgr database connections. - foreach (SbmAppConfig.DatabaseConfig dbConfig in AppConfig.BusMgrDatabases) + foreach (Net.Core.Web.App.SbmAppConfig.DatabaseConfig dbConfig in AppConfig.BusMgrDatabases) { odbcConfig = new SacsDatabaseConsole.OdbcConfig(); odbcConfig.location = dbConfig.Location; odbcConfig.user = dbConfig.User; odbcConfig.pword = dbConfig.Password; - SacsDatabase busMgrDatabase = SacsDatabaseConsole.OpenOdbcDatabase(odbcConfig); + SacsDatabase busMgrDatabase = SacsDatabaseConsole.OpenOdbcDatabase(odbcConfig); if (busMgrDatabase.HasErrorState()) - SaLogger.Warn($"{SysUtil.Fn} BusMgr Database: " + busMgrDatabase.DatabaseName + ". Initialisation error: " + busMgrDatabase.ErrorStateMessage); + SaLogger.Warn($"{SysUtil.Fn} BusMgr Database: " + busMgrDatabase.DatabaseName + ". Initialisation error: " + busMgrDatabase.ErrorStateMessage); // Session context. ushort sessionContextIdx = sessionContextIdx_Next++; if (sessionContextIdx_Control < 1) - sessionContextIdx_Control = sessionContextIdx; - SessionContextData sessionContextData = new SessionContextData(new SbmSessionContext_Web(sessionContextIdx, Sbm.Application.WebControl)); + sessionContextIdx_Control = sessionContextIdx; + SessionContextData sessionContextData = new SessionContextData(new SbmSessionContext_Web(sessionContextIdx, Sbm.Application.WebControl)); sessionContextData.DbIdentifiers.UnionWith(dbConfig.Identifiers); sessionContextData.BusMgrDatabase = busMgrDatabase; - sessionContexts.Add(sessionContextData.SessionContext.Index, sessionContextData); + sessionContexts.Add(sessionContextData.SessionContext.Index, sessionContextData); } } catch (Exception exc) diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs index d9be213..e2e1953 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs @@ -18,7 +18,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance { //------------------------------------------------------------------- // Definitions. - private static String PasswordDummyValue = "********"; // Repository data. private class RepositoryListData : AjaxResponse_Data.ItemData_Base @@ -33,7 +32,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance { public String OwnerId { get; set; } public String UserName { get; set; } - public String PasswordDummy { get; } = PasswordDummyValue; } private void PopulateRepositoryResponseListData(SbmModel_Control model, RepositoryListData data, SbmcOwner owner, SbmcRepository repository) { @@ -277,7 +275,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance repository.DatabaseName = model.Repository.DatabaseName; if (model.Repository.UserName != null) repository.UserName = model.Repository.UserName; - if (model.Repository.Password != null && !model.Repository.Password.Equals(PasswordDummyValue)) + if (model.Repository.Password != null && StringUtil.ToBool(model.Repository.PasswordChanged)) repository.Password = model.Repository.Password; if (model.Repository.StatusCode != null) repository.Status = model.Repository.GetStatus(); diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs index 7e58040..497a830 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs @@ -182,7 +182,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers if (StringUtil.IsEmpty(GetRequestCookie(KeepLoggedIn.CookieName))) return; // Clear cookie by setting expiry date in the past. SetResponseCookie(KeepLoggedIn.CookieName, "", DateTime.Today.AddDays(-7), true); - SaLogger.Info($"{SysUtil.Fn} 'Keep Logged In' cookie cleared."); + SaLogger.Debug($"{SysUtil.Fn} 'Keep Logged In' cookie cleared."); } //------------------------------------------------------------------- diff --git a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Repository.cs b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Repository.cs index 0977b7c..38052a1 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Repository.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Repository.cs @@ -48,6 +48,7 @@ namespace Sarand.BusinessMgr.Web.Control.Models.Instance public String DatabaseName { get; set; } public String UserName { get; set; } public String Password { get; set; } + public String PasswordChanged { get; set; } public String StatusCode { get; set; } public SaStatus GetStatus() { return SacsSystem.GetStatusForCode(StatusCode); } } diff --git a/SaBusinessMgrCoreWebControl/SaBusinessMgrCoreWebControl.csproj b/SaBusinessMgrCoreWebControl/SaBusinessMgrCoreWebControl.csproj index a2a6944..089c100 100644 --- a/SaBusinessMgrCoreWebControl/SaBusinessMgrCoreWebControl.csproj +++ b/SaBusinessMgrCoreWebControl/SaBusinessMgrCoreWebControl.csproj @@ -8,8 +8,10 @@ - + + + diff --git a/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Index.cshtml b/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Index.cshtml index bd64b3c..3710d99 100644 --- a/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Index.cshtml +++ b/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Index.cshtml @@ -114,8 +114,8 @@
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmRepository", @class = "sbc-form", @onSubmit = "return false;" })) { - @Html.HiddenFor(model => model.Repository.Exists, new { @id = "", @class = "RepositoryExists" }) - @Html.HiddenFor(model => model.Repository.Id, new { @id = "", @class = "RepositoryId" }) + @Html.HiddenFor(model => model.Repository.Exists, new { @id = "", @class = "RepositoryExists sbc-input" }) + @Html.HiddenFor(model => model.Repository.Id, new { @id = "", @class = "RepositoryId sbc-input" }) @* Repository Owner *@
@@ -128,7 +128,7 @@
- @Html.HiddenFor(model => model.Repository.OwnerId, new { @id = "", @class = "RepositoryOwnerId" }) + @Html.HiddenFor(model => model.Repository.OwnerId, new { @id = "", @class = "RepositoryOwnerId sbc-input" })
@@ -235,6 +235,7 @@
+ @Html.HiddenFor(model => model.Repository.PasswordChanged, new { @id = "", @class = "RepositoryPasswordChanged sbc-input" }) @Html.PasswordFor(model => model.Repository.Password, new { @id = "ifRepositoryPassword", @class = "RepositoryPassword sbc-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn_Control.ColumnIdx.Repository_Password) })
diff --git a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-data.css b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-data.css index a852b66..9918bfd 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-data.css +++ b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-data.css @@ -463,22 +463,27 @@ table.sbc-item-list tbody td /* Item statuses */ -.sbc-status-awa +.sbc-status-awa, .sbc-status-req, .sbc-status-rai, .sbc-status-clo { color: darkorange; } -.sbc-status-atv, .sbc-status-cur +.sbc-status-atv, .sbc-status-ena, .sbc-status-cur, .sbc-status-rei, .sbc-status-ope, .sbc-status-con, .sbc-status-com, .sbc-status-acc, .sbc-status-gra { color: green; } -.sbc-status-ina +.sbc-status-ina, .sbc-status-dis, .sbc-status-dsc, .sbc-status-red, .sbc-status-can, .sbc-status-fai, .sbc-status-rej, .sbc-status-den { color: darkred; } -.sbc-status-hld +.sbc-status-inp, .sbc-status-exp, .sbc-status-inv, .sbc-status-suc, .sbc-status-act, .sbc-status-que, .sbc-status-log +{ + color: darkcyan; +} + +.sbc-status-pre, .sbc-status-pro, .sbc-status-inp, .sbc-status-hld, .sbc-status-ups, .sbc-status-sup, .sbc-status-aut, .sbc-status-sub { color: dodgerblue; } diff --git a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-own.js b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-own.js index 7ce2b0d..b00539c 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-own.js +++ b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-own.js @@ -57,7 +57,7 @@ $('.OwnerContactName', $item).text(item.contactName); $('.OwnerContactEmailAddress', $item).text(item.contactEmailAddress); $('.OwnerContactPhone', $item).text(item.contactPhone); - $('.OwnerStatusDesc', $item).text(item.statusDesc).removeClass(function (idx, name) { return (name.match(/(^|\s)sbc-status-\S+/g) || []).join(' '); }).addClass('sbc-status-' + item.statusCode.toLowerCase()); + $('.OwnerStatusDesc', $item).text(item.statusDesc).removeStatusClasses().addClass('sbc-status-' + item.statusCode.toLowerCase()); // Actions. let fnUpd = function () { io.updateItem($item, item) }; var $bgr = $('.sbc-burger', $item).hide(); @@ -111,17 +111,16 @@ $dlg.item.dialog('option', 'title', sbc.dlg.title.createItem); io.openOwnerDlg(); } + io.clearItem = function () + { + $('.sbc-input,.sbc-textarea,.sbc-select', $frm.item).val(''); + sbc.populateSelectCodeDesc('#cbOwnerStatus', sbc.data.statuses); + sbc.clearControlErrors(); + } io.openOwnerDlg = function () { sbc.openDialog($dlg.item, 600, 600); } - io.clearItem = function () - { - let frm = $frm.item; - $('.OwnerExists,.OwnerId,input[type="text"],textarea,select', frm).val(''); - sbc.populateSelectCodeDesc('#cbOwnerStatus', sbc.data.statuses); - sbc.clearControlErrors(); - } //-------------------------------------------------------------- io.updateItem = function ($item, item) @@ -166,7 +165,7 @@ $dlg.item.dialog('close'); var item = response.owner; - var $item = $('#' + io.getItemId(item)); + var $item = $('#' + io.getItemId(item), $pnl.table); if (!$item.length) { $item = io.getItemRowTemplate(); diff --git a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep.js b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep.js index a10c663..92df62a 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep.js +++ b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep.js @@ -58,7 +58,7 @@ $('.RepositoryServerName', $item).text(item.serverName); $('.RepositoryInstanceName', $item).text(item.instanceName); $('.RepositoryDatabaseName', $item).text(item.databaseName); - $('.RepositoryStatusDesc', $item).text(item.statusDesc).removeClass(function (idx, name) { return (name.match(/(^|\s)sbc-status-\S+/g) || []).join(' '); }).addClass('sbc-status-' + item.statusCode.toLowerCase()); + $('.RepositoryStatusDesc', $item).text(item.statusDesc).removeStatusClasses().addClass('sbc-status-' + item.statusCode.toLowerCase()); // Actions. let fnUpd = function () { ir.updateItem($item, item) }; var $bgr = $('.sbc-burger', $item).hide(); @@ -118,11 +118,14 @@ } ir.clearItem = function () { - let frm = $frm.item; - $('.RepositoryExists,.RepositoryId,input[type="text"],textarea,select', frm).val(''); + $('.RepositoryExists,.RepositoryId,input[type="text"],textarea,select', $frm.item).val(''); sbc.populateSelectCodeDesc('#cbRepositoryStatus', sbc.data.statuses); sbc.clearControlErrors(); } + ir.onInputPassword = function () + { + $('.RepositoryPasswordChanged', $frm.item).val(1); + } //-------------------------------------------------------------- ir.updateItem = function ($item, item) @@ -136,22 +139,22 @@ ir.onUpdateItem = function (response) { //sbc.debug('onUpdateItem', response); - let frm = $frm.item; + let $ctrls = $('.sbc-input,.sbc-textarea,.sbc-select', $frm.item); ir.clearItem(); if (!response.success) return; let item = response.repository; - $('.RepositoryExists', frm).val(1); - $('.RepositoryId', frm).val(item.id); - $('.RepositoryOwnerId', frm).val(item.ownerId); - $('.RepositoryOwner', frm).val(item.ownerName); - $('.RepositoryContext', frm).val(item.context); - $('.RepositoryServerName', frm).val(item.serverName); - $('.RepositoryInstanceName', frm).val(item.instanceName); - $('.RepositoryDatabaseName', frm).val(item.databaseName); - $('.RepositoryUserName', frm).val(item.userName); - $('.RepositoryPassword', frm).val(item.password); - $('.RepositoryNotes', frm).val(item.notes); - $('.RepositoryStatus', frm).val(item.statusCode).prop('readonly', true); + $ctrls.filter('.RepositoryExists').val(1); + $ctrls.filter('.RepositoryId').val(item.id); + $ctrls.filter('.RepositoryOwnerId').val(item.ownerId); + $ctrls.filter('.RepositoryOwner').val(item.ownerName); + $ctrls.filter('.RepositoryContext').val(item.context); + $ctrls.filter('.RepositoryServerName').val(item.serverName); + $ctrls.filter('.RepositoryInstanceName').val(item.instanceName); + $ctrls.filter('.RepositoryDatabaseName').val(item.databaseName); + $ctrls.filter('.RepositoryUserName').val(item.userName); + $ctrls.filter('.RepositoryPassword').val('######'); + $ctrls.filter('.RepositoryNotes').val(item.notes); + $ctrls.filter('.RepositoryStatus').val(item.statusCode).prop('readonly', true); sbc.clearControlErrors(); $dlg.item.dialog('option', 'title', sbc.dlg.title.updateItem); ir.openRepositoryDlg(); @@ -192,11 +195,11 @@ $dlg.item.dialog('close'); var item = response.repository; - var $item = $('#' + ir.getItemId(item)); + var $item = $('#' + ir.getItemId(item), $pnl.table); if (!$item.length) { $item = ir.getItemRowTemplate(); - $('table', $pnl.table).prepend($item).show(); + $('table tbody', $pnl.table).prepend($item).show(); } ir.populateItem($item, item); } @@ -223,6 +226,7 @@ $frm.item = $('#frmRepository'); $($frm.item).on('input', '.sbc-input, .sbc-textarea', function () { sbc.clearControlError(this); }).on('change', '.sbc-select', function () { sbc.clearControlError(this); }); $($frm.item).on('dblclick', '.sbc-input.RepositoryOwner', ir.selectOwner).on('click', '.sbc-action.RepositoryOwnerSearch', ir.selectOwner); + $($frm.item).on('input', '.RepositoryPassword', ir.onInputPassword); setTimeout(ir.refreshResults, 250); }); diff --git a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-main.js b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-main.js index 927d1be..dc63ff2 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-main.js +++ b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-main.js @@ -97,6 +97,12 @@ return index % 2 == 1 ? "other" : ""; }); } + sbc.selectOrAdd = function ($sel, code, desc) + { + if ($sel.val(code) == code) return; + $sel.append($('