diff --git a/SaBusMgrCoreWeb/Web/Components/SbmController_Web.cs b/SaBusMgrCoreWeb/Web/Components/SbmController_Web.cs index 497fbfa..6928643 100644 --- a/SaBusMgrCoreWeb/Web/Components/SbmController_Web.cs +++ b/SaBusMgrCoreWeb/Web/Components/SbmController_Web.cs @@ -118,7 +118,6 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Components Response.Headers.Add(HeaderNames.Expires, "0"); } - base.OnActionExecuted(filterContext); } diff --git a/SaBusMgrStandardBase/Base/App/Sbm-Version.cs b/SaBusMgrStandardBase/Base/App/Sbm-Version.cs index e75622b..b8fde09 100644 --- a/SaBusMgrStandardBase/Base/App/Sbm-Version.cs +++ b/SaBusMgrStandardBase/Base/App/Sbm-Version.cs @@ -15,7 +15,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- public static class Version { - private static String version { get; } = "3.0.0.3"; + private static String version { get; } = "3.0.0.4"; // Retrieve version. public static String GetFullVersion() { return version; } public static String GetAppVersion() @@ -42,6 +42,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // 3.0.0.1 08-Feb-25 Demo repository registration. // 3.0.0.2 08-Feb-25 Production SMTP config. // 3.0.0.3 10-Feb-25 Osie feedback #1. Control Repository Schema, Logs. + // 3.0.0.4 11-Feb-25 Portal Commodity Sales properties. Control Index population. //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/App/Sbm.cs b/SaBusMgrStandardBase/Base/App/Sbm.cs index 814380c..ea53b29 100644 --- a/SaBusMgrStandardBase/Base/App/Sbm.cs +++ b/SaBusMgrStandardBase/Base/App/Sbm.cs @@ -61,6 +61,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public static int MaxLength { get; } = 16; } } + public class Logging + { + public class Folder + { + public static String WebControl { get; } = "WebControl"; + public static String WebPortal { get; } = "WebPortal"; + public static String WebApi { get; } = "Api"; + } + } public class Portal { public static class Session diff --git a/SaBusMgrStandardBase/Base/App/SbmDbDfn.cs b/SaBusMgrStandardBase/Base/App/SbmDbDfn.cs index 40f44d6..1129bdb 100644 --- a/SaBusMgrStandardBase/Base/App/SbmDbDfn.cs +++ b/SaBusMgrStandardBase/Base/App/SbmDbDfn.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Base.App { diff --git a/SaBusMgrStandardBase/Base/App/SbmInternals.cs b/SaBusMgrStandardBase/Base/App/SbmInternals.cs index c8f5454..ccc7a74 100644 --- a/SaBusMgrStandardBase/Base/App/SbmInternals.cs +++ b/SaBusMgrStandardBase/Base/App/SbmInternals.cs @@ -551,6 +551,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // T a x C o d e s //------------------------------------------------------------------- + public String GetDefaultTaxCode() + { + return StringUtil.OnBlank(SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.TaxCodeType).GetCodeForType(SaTaxCodeType.Std), $"{SaTaxCodeType.Std}"); + } private void populateTaxCodes() { if (taxCodes != null) return; @@ -563,6 +567,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App populateTaxCodes(); return new List(taxCodes.Values); } + public List GetTaxCodesEffectiveOn(DateTime effectiveOn) + { + populateTaxCodes(); + return new List(taxCodes.Values.Where(tax => tax.IsEffectiveOn(effectiveOn))); + } public SaTaxCode GetTaxCodeById(SysId taxCodeId) { if (!SysId.IsValid(taxCodeId)) return null; @@ -573,6 +582,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // U n i t s O f M e a s u r e //------------------------------------------------------------------- + public SaUomType GetDefaultUomType() + { + return SaUomType.Pack_Each; + } private void populateUnitsOfMeasure() { if (unitsOfMeasure != null) return; @@ -591,9 +604,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App populateUnitsOfMeasure(); return unitsOfMeasure.GetValueOrDefault(unitMeasureId); } + public SaUomType GetUnitOfMeasureType(SysId unitMeasureId) + { + return GetUnitOfMeasureById(unitMeasureId)?.UnitType ?? SaUomType.Unknown; + } + public String GetUnitOfMeasureCode(SysId unitMeasureId) + { + return GetUnitOfMeasureById(unitMeasureId)?.Code ?? ""; + } public String GetUnitOfMeasureCaption(SysId unitMeasureId) { - return GetUnitOfMeasureById(unitMeasureId)?.Single ?? ""; + return GetUnitOfMeasureById(unitMeasureId)?.GetCaption() ?? ""; } public List GetUnitsOfMeasureByCategory(SaUomCategory uomCategory) { diff --git a/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs b/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs index 1f99a01..9c4b87e 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs @@ -514,59 +514,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Reference. // Region Type. - systemCodes[Sbm.SystemCode.RegionType] = new List() - { - new TypeCodeDesc((int)SaRegionType.Continent, "CON", "Continent"), - new TypeCodeDesc((int)SaRegionType.Country, "COU", "Country"), - new TypeCodeDesc((int)SaRegionType.Province, "PRO", "Province"), - new TypeCodeDesc((int)SaRegionType.Town, "TWN", "Town") - }; + systemCodes[Sbm.SystemCode.RegionType] = new List(SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.RegionType)); // Unit Measure Category. - systemCodes[Sbm.SystemCode.UnitMeasureCategory] = new List() - { - new TypeCodeDesc((int)SaUomCategory.Time, "TIM", "Time"), - new TypeCodeDesc((int)SaUomCategory.Pack, "PCK", "Pack"), - new TypeCodeDesc((int)SaUomCategory.Weight, "WEI", "Weight"), - new TypeCodeDesc((int)SaUomCategory.Length, "LEN", "Length"), - new TypeCodeDesc((int)SaUomCategory.Area, "ARE", "Area"), - new TypeCodeDesc((int)SaUomCategory.Volume, "VOL", "Volume"), - new TypeCodeDesc((int)SaUomCategory.Density, "DEN", "Density"), - new TypeCodeDesc((int)SaUomCategory.Box, "BOX", "Box (container)") - }; + systemCodes[Sbm.SystemCode.UnitMeasureCategory] = new List(SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.UnitMeasureCategory)); // Unit Measure Type. - systemCodes[Sbm.SystemCode.UnitMeasureType] = new List() - { - new TypeCodeDesc((int)SaUomType.Time_Second, "SEC", "Second"), - new TypeCodeDesc((int)SaUomType.Time_Minute, "MIN", "Minute"), - new TypeCodeDesc((int)SaUomType.Time_Hour, "HR", "Hour"), - new TypeCodeDesc((int)SaUomType.Time_Day, "DAY", "Day"), - new TypeCodeDesc((int)SaUomType.Time_WorkingDay, "WDAY", "Working day"), - new TypeCodeDesc((int)SaUomType.Time_Week, "WK", "Week"), - new TypeCodeDesc((int)SaUomType.Time_WorkingWeek, "WWK", "Working week"), - new TypeCodeDesc((int)SaUomType.Time_Fortnight, "FNT", "Fortnight"), - new TypeCodeDesc((int)SaUomType.Time_Month, "MTH", "Month"), - new TypeCodeDesc((int)SaUomType.Time_Quarter, "QTR", "Quarter"), - new TypeCodeDesc((int)SaUomType.Time_Year, "YR", "Year"), - new TypeCodeDesc((int)SaUomType.Pack_Each, "EACH", "Each"), - new TypeCodeDesc((int)SaUomType.Pack_Set, "SET", "Set"), - new TypeCodeDesc((int)SaUomType.Weight_Gram, "GRM", "Gram"), - new TypeCodeDesc((int)SaUomType.Weight_Kilogram, "KG", "Kilogram"), - new TypeCodeDesc((int)SaUomType.Weight_Tonne, "TON", "Tonne"), - new TypeCodeDesc((int)SaUomType.Length_Metre, "METRE", "Metre"), - new TypeCodeDesc((int)SaUomType.Length_Kilometre, "KMET", "Kilometre"), - new TypeCodeDesc((int)SaUomType.Length_SquareMetre, "SQMET", "Square metre"), - new TypeCodeDesc((int)SaUomType.Length_Hectare, "HECT", "Hectare"), - new TypeCodeDesc((int)SaUomType.Length_Acre, "ACRE", "Acre"), - new TypeCodeDesc((int)SaUomType.Volume_Litre, "LITRE", "Litre"), - new TypeCodeDesc((int)SaUomType.Volume_CubicMetre, "CUBMET", "Cubic metre"), - new TypeCodeDesc((int)SaUomType.Density_KilogramsPerCubicMetre, "KPCMET", "Kg/m3"), - new TypeCodeDesc((int)SaUomType.Density_GramsPerCubicCentimeter, "GPCCMET", "g/cm3"), - new TypeCodeDesc((int)SaUomType.Box_Box, "BOX", "Box"), - new TypeCodeDesc((int)SaUomType.Box_Carton, "CARTON", "Carton"), - new TypeCodeDesc((int)SaUomType.Box_Pallet, "PALLET", "Pallet") - }; + systemCodes[Sbm.SystemCode.UnitMeasureType] = new List(SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.UnitMeasureType)); // Financial Type. systemCodes[Sbm.SystemCode.FinancialType] = new List() diff --git a/SaBusMgrStandardBase/Base/Data/SbmRepositoryPopulationData.cs b/SaBusMgrStandardBase/Base/Data/SbmRepositoryPopulationData.cs index eb86462..4916a11 100644 --- a/SaBusMgrStandardBase/Base/Data/SbmRepositoryPopulationData.cs +++ b/SaBusMgrStandardBase/Base/Data/SbmRepositoryPopulationData.cs @@ -1,5 +1,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.ReferenceData; using System; using System.Collections.Generic; using System.Linq; @@ -166,6 +167,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Data public String Code { get; set; } public String Caption { get; set; } public decimal SalePrice { get; set; } + public SaUomType SaleUnitType { get; set; } = SaUomType.Pack_Each; } public class StockCommodityData : CommodityData { @@ -177,7 +179,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Data } public class ServiceCommodityData : CommodityData { - public ServiceCommodityData() : base(Sbm.CommodityType.Service) { } + public ServiceCommodityData() : base(Sbm.CommodityType.Service) + { + SaleUnitType = SaUomType.Time_Hour; + } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmDatabaseConsole.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmDatabaseConsole.cs index 7c57014..0d4e3d3 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmDatabaseConsole.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmDatabaseConsole.cs @@ -36,6 +36,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles // Properties. private SbmSessionContext SessionContext { get { return mbr.SessionContext; } } private ISacsDatabase Database { get { if (mbr.Database == null) { mbr.Database = SbmGlobals.Application.GetBusMgrDatabase(SessionContext); } return mbr.Database; } } + private new IndexStats IndexStats { get; set; } //------------------------------------------------------------------- // Database Indices. @@ -43,6 +44,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles public bool InstallDbIndices(IndexStats indexStats) { ClearErrorState(); + IndexStats = indexStats; if (Database == null || Database.DbmsType != DbmsType.MsSql) return SetErrorState(""); // Turn off database exceptions. @@ -433,130 +435,25 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //--------------------------------------------------------------- // Clean-up. + IndexStats = null; Database.DisplayErrors = displayDbExceptionsPrev; return OK; } + //------------------------------------------------------------------- private bool CreatePrimaryDbIndex(String tableName, String columns, bool dropIndicesIfNotExist = false) { - if (HasErrorState()) return false; - if (!Database.TableExists(tableName)) return true; - List columnNames = new List(Regex.Split(columns, "[\\s,;\\-+]+")); - DbDfnTable dfnTbl = Database.GetTableDfn(tableName); - String indexName = "PK_" + tableName; - if (!dfnTbl.HasIndexByName(indexName)) - { - // Primary index does not exist on table. - if (dropIndicesIfNotExist) - { - // All existing indices are dropped - foreach (DbDfnIndex index in dfnTbl.Indices) - DropDbIndex(tableName, index.Name); - } - if (!HasErrorState()) - { - // Examples: - // MS Access: ALTER TABLE ADD PRIMARY KEY () - // 1. ALTER TABLE Customer ADD PRIMARY KEY (SID); - // 2. ALTER TABLE [Sales].[Individual] - // ADD CONSTRAINT [PK_Individual_CustomerID] - // PRIMARY KEY CLUSTERED - // ([CustomerID] ASC) - String query = "ALTER TABLE [" + tableName + "] ADD CONSTRAINT [" + indexName + "] PRIMARY KEY (" + columnNames.Concat(",", "[", "]") + ")"; - if (Database.DbmsType == DbmsType.MsSql) - query = "ALTER TABLE [" + tableName + "] ADD CONSTRAINT [" + indexName + "] PRIMARY KEY CLUSTERED (" + columnNames.Concat(",", "[", "]") + ")"; - SaLogger.Info($"{SysUtil.Fn} Query:\n\t" + query); - if (!query.IsEmpty()) Database.ExecuteNonQuery(query); - if (Database.HasErrorState()) - { -#if DEBUG - SaLogger.Debug($"{SysUtil.Fn} Table: {tableName}. Index: {indexName}. Exception: {Database.ErrorStateMessage.TrimEnd('.')}."); -#endif - SetErrorState($"Failed to create primary index {indexName} on {tableName} - {Database.ErrorStateMessage}"); - SaLogger.Error(ErrorStateMessage); - } - } - } - return OK; + return CreatePrimaryDbIndex(Database, IndexStats, tableName, columns, dropIndicesIfNotExist); } private bool CreateDbIndex(String tableName, String indexName, String columns, String includeColumns = "", bool unique = false) { - if (HasErrorState()) return false; - if (!Database.TableExists(tableName)) return true; - List columnNames = new List(Regex.Split(columns, "[\\s,;\\-+]+")); - List includeColumnNames = new List(Regex.Split(includeColumns, "[\\s,;\\-+]+")); - DbDfnTable dfnTbl = Database.GetTableDfn(tableName); - if (!dfnTbl.HasIndexByName(indexName)) // ToDo Should also check the columns and their sequence in the index. - { - String query = "CREATE " + (unique ? "UNIQUE " : "") + "INDEX "; - query += "[" + indexName + "] ON [" + tableName + "] (" + columnNames.Concat(",", "[", "]") + ")"; - if (!includeColumnNames.IsEmpty()) - query += " INCLUDE (" + includeColumnNames.Concat(",", "[", "]") + ")"; -#if DEBUG - SaLogger.Debug($"{SysUtil.Fn} Table: {tableName}. Index: {indexName}."); - SaLogger.Debug("\tQuery: {query}"); -#endif - SaLogger.Info($"{SysUtil.Fn} Query:\n\t" + query); - if (!query.IsEmpty()) Database.ExecuteNonQuery(query); - if (Database.HasErrorState()) - { -#if DEBUG - SaLogger.Debug($"\tException: {Database.ErrorStateMessage}"); -#endif - SetErrorState($"Failed to create index {indexName} on {tableName} - {Database.ErrorStateMessage}"); - SaLogger.Error(ErrorStateMessage); - } - } - return OK; + return CreateDbIndex(Database, IndexStats, tableName, indexName, columns, includeColumns, unique); } private bool DropDbIndex(String tableName, String indexName) { - if (HasErrorState()) return false; - if (!Database.TableExists(tableName)) return true; - DbDfnTable dfnTbl = Database.GetTableDfn(tableName); - if (!dfnTbl.HasIndexByName(indexName)) // ToDo Should also check the columns and their sequence in the index. - { - // Drop index: - // MS Access: DROP INDEX index_name ON table_name - // MS SQL Server: DROP INDEX table_name.index_name - // DB2/Oracle: DROP INDEX index_name - // MySQL: ALTER TABLE table_name DROP INDEX index_name - String query = "DROP INDEX [" + indexName + "] ON [" + tableName + "]"; - SaLogger.Info("SapphireDbConsole_Odbc::DropDbIndex"); - SaLogger.Info("Query: " + query); - if (Database.DbmsType == DbmsType.MsSql) - query = "DROP INDEX [" + tableName + "].[" + indexName + "]"; - if (!query.IsEmpty()) Database.ExecuteNonQuery(query); - if (Database.HasErrorState()) - { -#if DEBUG - SaLogger.Debug($"{SysUtil.Fn} Table: {tableName}. Index: {indexName}. Exception: {Database.ErrorStateMessage}"); -#endif - SetErrorState($"Failed to drop index {indexName} on {tableName} - {Database.ErrorStateMessage}"); - SaLogger.Error(ErrorStateMessage); - } - } - else - { - // Assume this is the Primary Key: - String query = "ALTER TABLE [" + tableName + "] DROP CONSTRAINT [" + indexName + "]"; - SaLogger.Info($"{SysUtil.Fn}"); - SaLogger.Info("Query: " + query); - //if (Database.DbmsType == eSaDbmsMsSql) - // sQry = (String)"DROP INDEX ["+sTable+"].["+sIndex+"]"; - if (!query.IsEmpty()) Database.ExecuteNonQuery(query); - if (Database.HasErrorState()) - { -#if DEBUG - SaLogger.Debug($"{SysUtil.Fn} Table: {tableName}. Index: {indexName}. Exception: {Database.ErrorStateMessage}"); -#endif - SetErrorState($"Failed to drop primary key {indexName} on {tableName} - {Database.ErrorStateMessage}"); - SaLogger.Error(ErrorStateMessage); - } - } - return OK; + return DropDbIndex(Database, IndexStats, tableName, indexName); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Address_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Address_Db.cs index 23fa8b6..84c1ef1 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Address_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Address_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Affiliate_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Affiliate_Db.cs index 708b710..e19bc13 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Affiliate_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Affiliate_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Association_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Association_Db.cs index d3eddfb..0ef8d62 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Association_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Association_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/CommodityCustomer_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/CommodityCustomer_Db.cs index 1363bee..f1772a3 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/CommodityCustomer_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/CommodityCustomer_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/CommoditySupplier_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/CommoditySupplier_Db.cs index 26bcfd3..f2e390a 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/CommoditySupplier_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/CommoditySupplier_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Commodity_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Commodity_Db.cs index e78b14e..5aca6df 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Commodity_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Commodity_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Constituent_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Constituent_Db.cs index a0fa136..303a895 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Constituent_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Constituent_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/ContainerItem_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/ContainerItem_Db.cs index 5717201..3d7fefa 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/ContainerItem_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/ContainerItem_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Container_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Container_Db.cs index 929df4c..e87cef6 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Container_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Container_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/ItemBatch_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/ItemBatch_Db.cs index bf50c8e..afe794a 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/ItemBatch_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/ItemBatch_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/ItemLink_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/ItemLink_Db.cs index 48213d9..d68633b 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/ItemLink_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/ItemLink_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Location_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Location_Db.cs index 9bde2c0..aba37e3 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Location_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Location_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Movement_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Movement_Db.cs index 093760c..54877dc 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Movement_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Movement_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/PortfolioItem_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/PortfolioItem_Db.cs index dfac30d..29dc07c 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/PortfolioItem_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/PortfolioItem_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Process_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Process_Db.cs index 9d854c4..05fd04a 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Process_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Process_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Requirement_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Requirement_Db.cs index bf9fadb..9f65561 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Requirement_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Requirement_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaAssetCategory_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaAssetCategory_Db.cs index 378a945..eb2a5b7 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaAssetCategory_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaAssetCategory_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaAssetProcess_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaAssetProcess_Db.cs index ed0a5ec..3cc2e62 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaAssetProcess_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaAssetProcess_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaAsset_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaAsset_Db.cs index 5fbdb4e..cb984c9 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaAsset_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaAsset_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaDiaryEntry_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaDiaryEntry_Db.cs index 6892838..b11b1cd 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaDiaryEntry_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaDiaryEntry_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaDiaryLink_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaDiaryLink_Db.cs index 834698e..3b6973e 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaDiaryLink_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaDiaryLink_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaPriceSet_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaPriceSet_Db.cs index 61b354d..4d6f55b 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaPriceSet_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaPriceSet_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaPrice_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaPrice_Db.cs index eed8ff6..b00f143 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaPrice_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaPrice_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleClass_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleClass_Db.cs index d1d453b..72dd704 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleClass_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleClass_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleEvent_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleEvent_Db.cs index 4eba0bc..6e48896 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleEvent_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleEvent_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleFeature_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleFeature_Db.cs index e42b616..e0b9963 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleFeature_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaVehicleFeature_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { @@ -65,6 +65,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal protected static List fieldsPrimary { get; } = new List() { "VehicleId", + "Source", + "Type", + "CategoryCode", + "FeatureCode", }; protected static List fieldsNullable { get; } = new List() { @@ -217,22 +221,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal if (dbCommand is SqlCommand) { query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " "; - query += "WHERE VehicleId=@VehicleId;"; + query += "WHERE VehicleId=@VehicleId AND Source=@Source AND Type=@Type AND CategoryCode=@CategoryCode AND FeatureCode=@FeatureCode;"; } else { query += columnNames.Concat(", ", "", "=?") + " "; - query += "WHERE VehicleId=?;"; + query += "WHERE VehicleId=? AND Source=? AND Type=? AND CategoryCode=? AND FeatureCode=?;"; } dbCommand.CommandText = query; Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText); // Populate parameters. dbCommand.Parameters.Clear(); - if (columnNames.ContainsCI("Source")) AddCommandParameter(dbCommand, "@Source", _Source); - if (columnNames.ContainsCI("Type")) AddCommandParameter(dbCommand, "@Type", _Type); - if (columnNames.ContainsCI("CategoryCode")) AddCommandParameter(dbCommand, "@CategoryCode", _CategoryCode); if (columnNames.ContainsCI("CategoryDesc")) AddCommandParameter(dbCommand, "@CategoryDesc", _CategoryDesc); - if (columnNames.ContainsCI("FeatureCode")) AddCommandParameter(dbCommand, "@FeatureCode", _FeatureCode); if (columnNames.ContainsCI("FeatureDesc")) AddCommandParameter(dbCommand, "@FeatureDesc", _FeatureDesc); if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes); if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags); @@ -241,6 +241,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy); if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost); AddCommandParameter(dbCommand, "@VehicleId", _VehicleId); + AddCommandParameter(dbCommand, "@Source", _Source); + AddCommandParameter(dbCommand, "@Type", _Type); + AddCommandParameter(dbCommand, "@CategoryCode", _CategoryCode); + AddCommandParameter(dbCommand, "@FeatureCode", _FeatureCode); int executeNonQueryResult = dbCommand.ExecuteNonQuery(); return (executeNonQueryResult == 1); } diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SaVehicle_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SaVehicle_Db.cs index b0e994a..f9707e8 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SaVehicle_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SaVehicle_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/StockLevel_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/StockLevel_Db.cs index e70adff..fcb8cd0 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/StockLevel_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/StockLevel_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SysParam_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SysParam_Db.cs index 63cf843..bbd6b68 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SysParam_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SysParam_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SystemAccountUser_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SystemAccountUser_Db.cs index e3c4885..c6f148f 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SystemAccountUser_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SystemAccountUser_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SystemAccount_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SystemAccount_Db.cs index 9c07b63..b0bf7d6 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SystemAccount_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SystemAccount_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/SystemUser_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/SystemUser_Db.cs index fa10095..43fa5ef 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/SystemUser_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/SystemUser_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Internal/Transaction_Db.cs b/SaBusMgrStandardDbas/Dbas/Internal/Transaction_Db.cs index 77ca3a1..7baa391 100644 --- a/SaBusMgrStandardDbas/Dbas/Internal/Transaction_Db.cs +++ b/SaBusMgrStandardDbas/Dbas/Internal/Transaction_Db.cs @@ -10,7 +10,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20 +// Code generated by Sarand Database Utilities Tue 11-Feb-2025 12:43:45 //--------------------------------------------------------------------------- namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal { diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs index 53c1286..2f4cc1a 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs @@ -1176,7 +1176,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr columnDfn.NumDecimals = (byte)LengthDecimals; break; case SbmCommodity.Column.Length_UomId: - SetCommodityColDfn(columnDfn, "Length UOM #", 70, SbmDbDfn.ColumnIdx.Commodity_UomIdWeight, ColumnAlignment.Right, DataValue.DataType.Long); + SetCommodityColDfn(columnDfn, "Length UOM #", 70, SbmDbDfn.ColumnIdx.Commodity_UomIdLength, ColumnAlignment.Right, DataValue.DataType.Long); break; case SbmCommodity.Column.Length_Unit: SetCommodityColDfn(columnDfn, "Length unit", 80, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Center); @@ -1185,42 +1185,42 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr SetCommodityColDfn(columnDfn, "Length valueunit", 80, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Right); break; case SbmCommodity.Column.Volume: - SetCommodityColDfn(columnDfn, "Volume", 70, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Right, DataValue.DataType.Double); + SetCommodityColDfn(columnDfn, "Volume", 70, SbmDbDfn.ColumnIdx.Commodity_Volume, ColumnAlignment.Right, DataValue.DataType.Double); columnDfn.NumDecimals = (byte)VolumeDecimals; break; case SbmCommodity.Column.Volume_UomId: - SetCommodityColDfn(columnDfn, "Volume uomId", 70, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Center); + SetCommodityColDfn(columnDfn, "Volume uomId", 70, SbmDbDfn.ColumnIdx.Commodity_UomIdVolume, ColumnAlignment.Center); break; case SbmCommodity.Column.Volume_Unit: - SetCommodityColDfn(columnDfn, "Volume unit", 80, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Center); + SetCommodityColDfn(columnDfn, "Volume unit", 80, SbmDbDfn.ColumnIdx.Commodity_Volume, ColumnAlignment.Center); break; case SbmCommodity.Column.Volume_ValueUnits: - SetCommodityColDfn(columnDfn, "Volume valueunit", 80, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Right); + SetCommodityColDfn(columnDfn, "Volume valueunit", 80, SbmDbDfn.ColumnIdx.Commodity_Volume, ColumnAlignment.Right); break; case SbmCommodity.Column.Density: - SetCommodityColDfn(columnDfn, "Density", 70, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Right, DataValue.DataType.Double); + SetCommodityColDfn(columnDfn, "Density", 70, SbmDbDfn.ColumnIdx.Commodity_Density, ColumnAlignment.Right, DataValue.DataType.Double); columnDfn.NumDecimals = (byte)DensityDecimals; break; case SbmCommodity.Column.Density_UomId: - SetCommodityColDfn(columnDfn, "Length uomId", 70, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Center); + SetCommodityColDfn(columnDfn, "Length uomId", 70, SbmDbDfn.ColumnIdx.Commodity_UomIdDensity, ColumnAlignment.Center); break; case SbmCommodity.Column.Density_Unit: - SetCommodityColDfn(columnDfn, "Length unit", 80, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Center); + SetCommodityColDfn(columnDfn, "Length unit", 80, SbmDbDfn.ColumnIdx.Commodity_Density, ColumnAlignment.Center); break; case SbmCommodity.Column.Density_ValueUnits: - SetCommodityColDfn(columnDfn, "Density valueunit", 80, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Right); + SetCommodityColDfn(columnDfn, "Density valueunit", 80, SbmDbDfn.ColumnIdx.Commodity_Density, ColumnAlignment.Right); break; case SbmCommodity.Column.BoxQuantity: - SetCommodityColDfn(columnDfn, "Box qty", 70, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Right, DataValue.DataType.Double); + SetCommodityColDfn(columnDfn, "Box qty", 70, SbmDbDfn.ColumnIdx.Commodity_BoxQuantity, ColumnAlignment.Right, DataValue.DataType.Double); break; case SbmCommodity.Column.BoxQuantity_UomId: - SetCommodityColDfn(columnDfn, "Box qty uomId", 70, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Center); + SetCommodityColDfn(columnDfn, "Box qty uomId", 70, SbmDbDfn.ColumnIdx.Commodity_UomIdBox, ColumnAlignment.Center); break; case SbmCommodity.Column.BoxQuantity_Unit: - SetCommodityColDfn(columnDfn, "Box qty unit", 80, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Center); + SetCommodityColDfn(columnDfn, "Box qty unit", 80, SbmDbDfn.ColumnIdx.Commodity_BoxQuantity, ColumnAlignment.Center); break; case SbmCommodity.Column.BoxQuantity_ValueUnits: - SetCommodityColDfn(columnDfn, "Box qty valueunit", 80, SbmDbDfn.ColumnIdx.Commodity_Length, ColumnAlignment.Right); + SetCommodityColDfn(columnDfn, "Box qty valueunit", 80, SbmDbDfn.ColumnIdx.Commodity_BoxQuantity, ColumnAlignment.Right); break; case SbmCommodity.Column.Dimensions: { @@ -1497,7 +1497,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr columnDfn.ShowZeroValues = false; break; case SbmCommodity.Column.UnitOfSale: - SetCommodityColDfn(columnDfn, "Unit of Sale", 100, SbmDbDfn.ColumnIdx.UnitMeasure_Single, ColumnAlignment.Center); + SetCommodityColDfn(columnDfn, "Unit of Sale", 100, SbmDbDfn.ColumnIdx.UnitMeasure_Single, ColumnAlignment.Center, DataValue.DataType.String, aliasCommodity_UomSale, prefixCommodity_UomSale); break; case SbmCommodity.Column.CarriageCostIndicative: if (canViewSalesFinancials) @@ -2490,7 +2490,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr DbQuery qryPriceSet = new DbQuery(Database.DbmsType); qryPriceSet.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice), aliasPrice); qryPriceSet.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPrice_CommodityId, aliasPrice)); - qryPriceSet.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPrice_PriceSetId, aliasPrice) + " Not In (" + prm.PriceSetIdsIncluded.Concat(",") + ")"); + qryPriceSet.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPrice_PriceSetId, aliasPrice) + " Not In (" + prm.PriceSetIdsExcluded.Concat(",") + ")"); filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Id, aliasCommodity) + " Not In (" + qryPriceSet.BuildQuery() + ")"); } diff --git a/SaBusMgrStandardDbas/Resources/Database/SbmDbDfn.xml b/SaBusMgrStandardDbas/Resources/Database/SbmDbDfn.xml index 69d7772..4e35672 100644 --- a/SaBusMgrStandardDbas/Resources/Database/SbmDbDfn.xml +++ b/SaBusMgrStandardDbas/Resources/Database/SbmDbDfn.xml @@ -15401,6 +15401,106 @@ + + dbo +
SaAsset
+ IDX_SaAsset_CategorySerial + 3 + true + false + false + false + 0 + 0 + false + + + 1 + AssetCategoryId + true + + + 2 + SerialFmt + true + + + + + dbo + SaAsset
+ IDX_SaAsset_Customer + 3 + true + false + false + false + 0 + 0 + false + + + 1 + AssocIdCustomer + true + + + 2 + Id + true + + +
+ + dbo + SaAsset
+ IDX_SaAsset_Supplier + 3 + true + false + false + false + 0 + 0 + false + + + 1 + AssocIdSupplier + true + + + 2 + Id + true + + +
+ + dbo + SaAsset
+ IDX_SaAsset_Item + 3 + false + false + false + false + 0 + 0 + false + + + 1 + ItemType + true + + + 2 + ItemId + true + + +
@@ -15872,6 +15972,86 @@ + + dbo + SaAssetCategory
+ IDX_SaAssetCategory_Customer + 3 + true + false + false + false + 0 + 0 + false + + + 1 + AssocIdCustomer + true + + + 2 + Id + true + + +
+ + dbo + SaAssetCategory
+ IDX_SaAssetCategory_OwnerType + 3 + true + false + false + false + 0 + 0 + false + + + 1 + AffIdOwner + true + + + 2 + AssetType + true + + + 3 + Code + true + + +
+ + dbo + SaAssetCategory
+ IDX_SaAssetCategory_Supplier + 3 + true + false + false + false + 0 + 0 + false + + + 1 + AssocIdSupplier + true + + + 2 + Id + true + + +
@@ -18071,6 +18251,86 @@ + + dbo + SaItemData
+ IDX_SaItemData_DataTypeItem + 3 + false + false + false + false + 0 + 0 + false + + + 1 + DataType + true + + + 2 + ItemType + true + + + 3 + ItemId + true + + +
+ + dbo + SaItemData
+ IDX_SaItemData_Item + 3 + false + false + false + false + 0 + 0 + false + + + 1 + ItemType + true + + + 2 + ItemId + true + + +
+ + dbo + SaItemData
+ IDX_SaItemData_ItemTypeDataType + 3 + false + false + false + false + 0 + 0 + false + + + 1 + ItemType + true + + + 2 + DataType + true + + +
@@ -21068,6 +21328,101 @@ + + dbo + SaVehicle
+ IDX_SaVehicle_CapCode + 3 + true + false + false + false + 0 + 0 + false + + + 1 + CapCode + true + + + 2 + Id + true + + +
+ + dbo + SaVehicle
+ IDX_SaVehicle_KeyLocation + 3 + true + false + false + false + 0 + 0 + false + + + 1 + KeyLocation + true + + + 2 + Id + true + + +
+ + dbo + SaVehicle
+ IDX_SaVehicle_RegNumber + 3 + true + false + false + false + 0 + 0 + false + + + 1 + RegNumber + true + + +
+ + dbo + SaVehicle
+ IDX_SaVehicle_VehicleClass + 3 + true + false + false + false + 0 + 0 + false + + + 1 + VehicleClassId + true + + + 2 + Id + true + + +
@@ -21573,6 +21928,51 @@ + + dbo + SaVehicleClass
+ IDX_SaVehicleClass_Make + 3 + true + false + false + false + 0 + 0 + false + + + 1 + MakeCode + true + + + 2 + Id + true + + +
+ + dbo + SaVehicleClass
+ IDX_SaVehicleClass_Category + 3 + false + false + false + false + 0 + 0 + false + + + 1 + VehicleCategoryCode + true + + +
@@ -21976,6 +22376,51 @@ + + dbo + SaVehicleEvent
+ IDX_SaVehicleEvent_VehicleStart + 3 + true + false + false + false + 0 + 0 + false + + + 1 + VehicleId + true + + + 2 + StartOn + true + + +
+ + dbo + SaVehicleEvent
+ IDX_SaVehicleEvent_TaxCode + 3 + false + false + false + false + 0 + 0 + false + + + 1 + TaxCodeId + true + + +
@@ -22275,6 +22720,26 @@ VehicleId true + + 2 + Source + true + + + 3 + Type + true + + + 4 + CategoryCode + true + + + 5 + FeatureCode + true + @@ -24575,6 +25040,66 @@ + + dbo + TaxCode
+ IDX_TaxCode_IdX_TaxCode_Code + 3 + false + false + false + false + 0 + 0 + false + + + 1 + Code + true + + +
+ + dbo + TaxCode
+ IDX_TaxCode_IdX_TaxCode_CodeAlt1 + 3 + false + false + false + false + 0 + 0 + false + + + 1 + CodeAlt1 + true + + +
+ + dbo + TaxCode
+ IDX_TaxCode_IdX_TaxCode_CodeAlt2 + 3 + false + false + false + false + 0 + 0 + false + + + 1 + CodeAlt2 + true + + +
diff --git a/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs b/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs index 75357b8..c5614b9 100644 --- a/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs @@ -24,6 +24,7 @@ using Sarand.Net.Standard.Dbas.ItemOptions; using Sarand.Net.Standard.Dbas.Security; using System; using System.Collections.Generic; +using System.IO; using System.Linq; namespace Sarand.BusinessMgr.Web.Control.App @@ -242,13 +243,16 @@ namespace Sarand.BusinessMgr.Web.Control.App else if (AppConfig.Instance.EqualsCI("PreProd")) instanceType = Sbm.InstanceType.UAT; // Initialise hard-coded logging path. - if (StringUtil.IsEmpty(LoggingRootFolder)) + if (StringUtil.IsBlank(LoggingRootFolder)) { if (SbmSystem.ComputerName.EqualsCI("WIN-BPCLM1QUOMT")) LoggingRootFolder = @"D:\Sbmonite\Logs\" + (Development ? "Dev" : "Test"); } if (DirectoryUtil.DirectoryExists(LoggingRootFolder)) - SaLogger.LogFolder = LoggingRootFolder; + { + SaLogger.LogFolder = Path.Combine(LoggingRootFolder, Sbm.Config.Logging.Folder.WebControl); + FileUtil.ValidateDirectory(SaLogger.LogFolder, true); + } LogApplicationStart($"{SysUtil.Fn}"); // Control database connection. diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryDatabaseController-Ajax.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryDatabaseController-Ajax.cs index e71d62e..0547e12 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryDatabaseController-Ajax.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryDatabaseController-Ajax.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using NPOI.SS.Formula.Functions; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; +using Sarand.BusinessMgr.Net.Standard.Dbas.Consoles; using Sarand.BusinessMgr.Web.Control.Components; using Sarand.BusinessMgr.Web.Control.Consoles; using Sarand.BusinessMgr.Web.Control.Models.Instance; @@ -10,6 +11,7 @@ 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.Base; using System; using System.Collections.Generic; using System.Linq; @@ -61,17 +63,17 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance { // Validate Repository. - SessionData_Control.Profile.Filter.InstanceContext = model.Filter.Context; - if (StringUtil.IsBlank(model.Filter.Context)) + SessionData_Control.Profile.Filter.InstanceContext = model.DatabaseFilter.Context; + if (StringUtil.IsBlank(model.DatabaseFilter.Context)) { SaLogger.Warn($"{SysUtil.Fn} Instance Context not supplied."); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); } - SbmcRepository repository = ControlInstanceMgr.GetRepositoryByContext(model.Filter.Context); + SbmcRepository repository = ControlInstanceMgr.GetRepositoryByContext(model.DatabaseFilter.Context); disposables.Add(repository); if (repository == null) { - SaLogger.Warn($"{SysUtil.Fn} Repository does not exist. Context: {model.Filter.Context}."); + SaLogger.Warn($"{SysUtil.Fn} Repository does not exist. Context: {model.DatabaseFilter.Context}."); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); } @@ -88,8 +90,8 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance // Table filter. List filter = new List(); - if (!StringUtil.IsBlank(model.Filter.Search)) - filter.Add($"tbl.name Like '%{DbQuery.FormatForLike(model.Filter.Search)}%'"); + if (!StringUtil.IsBlank(model.DatabaseFilter.Search)) + filter.Add($"tbl.name Like '%{DbQuery.FormatForLike(model.DatabaseFilter.Search)}%'"); if (!filter.Any()) filter.Add("1=1"); // Construction query. @@ -133,6 +135,89 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance return Json(responseData); } + //------------------------------------------------------------------- + // Populate Repository Database Indices ajax request. + //------------------------------------------------------------------- + private class AjaxResponse_RepositoryIndexPopulation : AjaxResponse_Data + { + // Construction. + public AjaxResponse_RepositoryIndexPopulation(SbmModel_Control model) : base(model) { } + // Stats. + public class StatsData + { + public int? PrimaryIndicesCreated { get; set; } + public int? IndicesCreated { get; set; } + public int? IndicesDropped { get; set; } + } + public StatsData Stats { get; } = new StatsData(); + } + //------------------------------------------------------------------- + [HttpPost] + [Route("Instance/Repository/Ajax/PopulateIndices")] + public IActionResult Ajax_PopulateRepositoryDatabaseIndices(Model_RepositoryDatabase model) + { + String messageTitle = Localiser["label.database"]; + AjaxResponse_RepositoryIndexPopulation responseData = new AjaxResponse_RepositoryIndexPopulation(model); + + // Validate session and referrer. + if (!ValidReferer) return Forbid(); + if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); + RefreshModel(model); + + // Record disposable items as they are created so all can be disposed when needed. + using (DisposableCollection disposables = new DisposableCollection()) + { + + // Validate Repository. + SessionData_Control.Profile.Filter.InstanceContext = model.DatabaseFilter.Context; + if (StringUtil.IsBlank(model.DatabaseFilter.Context)) + { + SaLogger.Warn($"{SysUtil.Fn} Instance Context not supplied."); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); + } + SbmcRepository repository = ControlInstanceMgr.GetRepositoryByContext(model.DatabaseFilter.Context); + disposables.Add(repository); + if (repository == null) + { + SaLogger.Warn($"{SysUtil.Fn} Repository does not exist. Context: {model.DatabaseFilter.Context}."); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); + } + + // Repository Console. + SbmCoreInstanceConsole_Control instanceConsole = new SbmCoreInstanceConsole_Control(SessionData_Control, repository); + disposables.Add(instanceConsole); + + SbmDatabaseConsole dbConsole = new SbmDatabaseConsole(instanceConsole.Internals.SessionContext); + + // Populate indices. + SaLogger.Info($"{SysUtil.Fn} Populating indices for Repository Context '{model.DatabaseFilter.Context}'.", true); + SacsDatabaseConsole.IndexStats indexStats = new SacsDatabaseConsole.IndexStats(); + dbConsole.InstallDbIndices(indexStats); + if (dbConsole.HasErrorState()) + return Json(responseData.SetMessage(messageTitle, $"Error encountered: {dbConsole.ErrorStateMessage.Trim('.')}.")); + + // Statistics. + if (indexStats.PrimaryIndicesCreated > 0) + responseData.Stats.PrimaryIndicesCreated = indexStats.PrimaryIndicesCreated; + if (indexStats.IndicesCreated > 0) + responseData.Stats.IndicesCreated = indexStats.IndicesCreated; + if (indexStats.IndicesDropped > 0) + responseData.Stats.IndicesDropped = indexStats.IndicesDropped; + List statsOutput = new List(); + if (indexStats.PrimaryIndicesCreated > 0) + statsOutput.Add($"Primary Created: {indexStats.PrimaryIndicesCreated}."); + if (indexStats.IndicesCreated > 0) + statsOutput.Add($"Indices Created: {indexStats.IndicesCreated}."); + if (indexStats.IndicesDropped > 0) + statsOutput.Add($"Indices dropped: {indexStats.IndicesDropped}."); + responseData.SetMessage(messageTitle, $"Indices populated.\n{statsOutput.Concat("", "\n")}"); + } + + // Complete response. + responseData.Success = true; + return Json(responseData); + } + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryDatabaseController.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryDatabaseController.cs index 36b1b9f..7813b9b 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryDatabaseController.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryDatabaseController.cs @@ -36,7 +36,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance // Refresh model. RefreshModel(model); - model.Filter.Context = SessionData_Control.Profile.Filter.InstanceContext; + model.DatabaseFilter.Context = SessionData_Control.Profile.Filter.InstanceContext; // Core Database view. return View("Views/Instance/Repository/Database/Tables.cshtml", model); diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/System/SystemController-Ajax-Database.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/System/SystemController-Ajax-Database.cs index 7466885..3317acb 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/System/SystemController-Ajax-Database.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/System/SystemController-Ajax-Database.cs @@ -68,10 +68,18 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.System // Record disposable items as they are created so all can be disposed when needed. using (DisposableCollection disposableItems = new DisposableCollection()) { - // Database connection. + // Database instance. Sbm.Database databaseInstance = EnumUtil.ParseEnum(StringUtil.EmptyOnNull(model.DatabaseFilter.Instance), Sbm.Database.Unknown); if (databaseInstance <= 0) return Json(responseData.SetMessage(messageTitle, $"Database instance must be specified.")); + + // Context. + if (databaseInstance == Sbm.Database.BusMgr) + { + if (StringUtil.IsBlank(model.DatabaseFilter.Context)) + return Json(responseData.SetMessage(messageTitle, "BusMgr Database context must be specified")); + } + ISacsDatabase db = GetDatabase(databaseInstance, model.DatabaseFilter.Context); if (db == null) return Json(responseData.SetMessage(messageTitle, $"Database unavailable for instance '{databaseInstance}'.")); diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/System/SystemController.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/System/SystemController.cs index e901a76..bc715e9 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/System/SystemController.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/System/SystemController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Sarand.BusinessMgr.Net.Core.Web.App; +using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Web.Control.Components; using Sarand.BusinessMgr.Web.Control.Models.System; using Sarand.Net.Standard.Base.Utils; @@ -53,7 +54,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.System // Refresh model. Model_System model = new Model_System(Localiser); RefreshModel(model); - model.LogsFilter.Folder = StringUtil.OnBlank(SessionData_Control.System.Logs.Filter.Folder, "Control"); + model.LogsFilter.Folder = StringUtil.OnBlank(SessionData_Control.System.Logs.Filter.Folder, Sbm.Config.Logging.Folder.WebControl); model.LogsFilter.Year = StringUtil.OnBlank(SessionData_Control.System.Logs.Filter.Year, DateTime.Today.ToString("yyyy")); model.LogsFilter.Month = StringUtil.OnBlank(SessionData_Control.System.Logs.Filter.Month, DateTime.Today.ToString("yyyyMM")); diff --git a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_RepositoryDatabase.cs b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_RepositoryDatabase.cs index f88ebfa..5be8671 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_RepositoryDatabase.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_RepositoryDatabase.cs @@ -21,7 +21,8 @@ namespace Sarand.BusinessMgr.Web.Control.Models.Instance public String Context { get; set; } public String Search { get; set; } } - public FilterData Filter { get; } = new FilterData(); + // Naming in line with System model so that Database views can use either. + public FilterData DatabaseFilter { get; } = new FilterData(); //------------------------------------------------------------------- } diff --git a/SaBusinessMgrCoreWebControl/Control/Models/System/Model_System.cs b/SaBusinessMgrCoreWebControl/Control/Models/System/Model_System.cs index f3437ab..3fc4605 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/System/Model_System.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/System/Model_System.cs @@ -31,6 +31,7 @@ namespace Sarand.BusinessMgr.Web.Control.Models.System public String Context { get; set; } public String Search { get; set; } } + // Naming in line with Repository Database model so that Database views can use either. public DatabaseFilterData DatabaseFilter { get; } = new DatabaseFilterData(); public class DatabaseTableData { diff --git a/SaBusinessMgrCoreWebControl/Localisation/SbmControlProperties.resx b/SaBusinessMgrCoreWebControl/Localisation/SbmControlProperties.resx index 2eb8586..576a6c7 100644 --- a/SaBusinessMgrCoreWebControl/Localisation/SbmControlProperties.resx +++ b/SaBusinessMgrCoreWebControl/Localisation/SbmControlProperties.resx @@ -435,9 +435,6 @@ Repository database - - Core Database - Schema @@ -537,4 +534,13 @@ Repository schema + + Populate indices + + + Repository Schema + + + Repository Database + \ No newline at end of file diff --git a/SaBusinessMgrCoreWebControl/Views/Home/Index.cshtml b/SaBusinessMgrCoreWebControl/Views/Home/Index.cshtml index 743a8d9..76b6aa4 100644 --- a/SaBusinessMgrCoreWebControl/Views/Home/Index.cshtml +++ b/SaBusinessMgrCoreWebControl/Views/Home/Index.cshtml @@ -41,17 +41,17 @@ @Localiser["label.context"] @Localiser["label.count"] - + Owners - @Model.GetOwnerCount() + @Model.GetOwnerCount() - + Repositories - @Model.GetRepositoryCount() + @Model.GetRepositoryCount() - + Users - @Model.GetUserAccountCount() + @Model.GetUserAccountCount() diff --git a/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Database/Schema.cshtml b/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Database/Schema.cshtml index 92a5831..36956b9 100644 --- a/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Database/Schema.cshtml +++ b/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Database/Schema.cshtml @@ -9,6 +9,7 @@
@@ -23,7 +24,7 @@
@* *@
-
@Localiser["caption.database.core"]
+
@Localiser["caption.repository.schema"]
@* Burger menu *@
diff --git a/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Database/Tables.cshtml b/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Database/Tables.cshtml index 5058a0b..6827877 100644 --- a/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Database/Tables.cshtml +++ b/SaBusinessMgrCoreWebControl/Views/Instance/Repository/Database/Tables.cshtml @@ -22,7 +22,7 @@
@* *@
-
@Localiser["caption.database.core"]
+
@Localiser["caption.repository.database"]
@* Burger menu *@
diff --git a/SaBusinessMgrCoreWebControl/Views/Security/RequestPassword.cshtml b/SaBusinessMgrCoreWebControl/Views/Security/RequestPassword.cshtml index 08ce37c..242b91b 100644 --- a/SaBusinessMgrCoreWebControl/Views/Security/RequestPassword.cshtml +++ b/SaBusinessMgrCoreWebControl/Views/Security/RequestPassword.cshtml @@ -20,7 +20,7 @@
- @Html.TextBoxFor(model => model.EmailAddress, new { @id = "ifEmailAddress", @class = "sbc-input lower", @maxlength = "128" }) + @Html.TextBoxFor(model => model.EmailAddress, new { @type = "email", @id = "ifEmailAddress", @class = "sbc-input lower", @maxlength = "128" })
diff --git a/SaBusinessMgrCoreWebControl/Views/Security/Signin.cshtml b/SaBusinessMgrCoreWebControl/Views/Security/Signin.cshtml index 92e58d6..980972e 100644 --- a/SaBusinessMgrCoreWebControl/Views/Security/Signin.cshtml +++ b/SaBusinessMgrCoreWebControl/Views/Security/Signin.cshtml @@ -21,7 +21,7 @@
- @Html.TextBoxFor(model => model.EmailAddress, new { @id = "ifEmailAddress", @class = "sbc-input lower", @maxlength = @Model.GetControlMaxLength(SbmDbDfn_Control.ColumnIdx.UserAccount_EmailAddress) }) + @Html.TextBoxFor(model => model.EmailAddress, new { @type = "email", @id = "ifEmailAddress", @class = "sbc-input lower", @maxlength = @Model.GetControlMaxLength(SbmDbDfn_Control.ColumnIdx.UserAccount_EmailAddress) })
diff --git a/SaBusinessMgrCoreWebControl/appsettings.Machine.Sarand110.json b/SaBusinessMgrCoreWebControl/appsettings.Machine.Sarand110.json index 71f11c5..79827a5 100644 --- a/SaBusinessMgrCoreWebControl/appsettings.Machine.Sarand110.json +++ b/SaBusinessMgrCoreWebControl/appsettings.Machine.Sarand110.json @@ -23,7 +23,7 @@ "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\BusinessMgr\\Docs" }, "Logging": { - "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\BusinessMgr\\Logs\\WebControl" + "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\BusinessMgr\\Logs" } } } diff --git a/SaBusinessMgrCoreWebControl/appsettings.Machine.Sarand602.json b/SaBusinessMgrCoreWebControl/appsettings.Machine.Sarand602.json index 17a3d75..79676a2 100644 --- a/SaBusinessMgrCoreWebControl/appsettings.Machine.Sarand602.json +++ b/SaBusinessMgrCoreWebControl/appsettings.Machine.Sarand602.json @@ -24,7 +24,7 @@ "RootFolder": "C:\\Sarand\\BusinessMgr\\Docs" }, "Logging": { - "RootFolder": "C:\\Sarand\\BusinessMgr\\Log\\WebControl" + "RootFolder": "C:\\Sarand\\BusinessMgr\\Log" } } } diff --git a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-base.css b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-base.css index 55615bc..5e18438 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-base.css +++ b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-base.css @@ -225,6 +225,11 @@ td.action width: 10%; } +.width15pc +{ + width: 15%; +} + .width20pc { width: 20%; @@ -235,6 +240,16 @@ td.action width: 25%; } +.width30pc +{ + width: 30%; +} + +.width40pc +{ + width: 40%; +} + .halfwidth, .width50pc { width: 50%; diff --git a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep-db.js b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep-db.js index 1638b3f..e80926e 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep-db.js +++ b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep-db.js @@ -37,6 +37,8 @@ env.$pnl.bgr.invisible(); env.$pnl.mnu.empty(); env.$pnl.mnu.append(cd.getFilterMenuOption(env, sbc.lbl.refresh, function () { cd.refreshItems(env); }, 'sbc-refresh')); + env.$pnl.mnu.append(cd.getFilterMenuOption(env, sbc.lbl.popIndices, function () { cd.populateIndices(env); }, 'sbc-config')); + sbc.debug(!!$('.sbc-dropdown-item', env.$pnl.mnu).length); env.$pnl.bgr.toggleVisibility(!!$('.sbc-dropdown-item', env.$pnl.mnu).length); } @@ -97,7 +99,7 @@ env.$pnl.items = $('.sbc-panel.Tables'); env.$pnl.header = env.$pnl.items.find('.sbc-panel-header'); - env.$pnl.bgr = env.$pnl.header.find('.sbc-burger'); + env.$pnl.bgr = env.$pnl.header.find('.sbc-burger').invisible(); env.$pnl.mnu = env.$pnl.bgr.find('ul.sbc-dropdown-menu'); env.$pnl.table = env.$pnl.items.find('.sbc-panel-item-table'); env.$pnl.msgs = env.$pnl.table.find('.sbc-panel-messages'); diff --git a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep-sch.js b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep-sch.js index 617f368..9a33ecb 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep-sch.js +++ b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-ins-rep-sch.js @@ -5,47 +5,48 @@ (function (win, doc, undef) { "use strict"; - let ds = sbc.mdl.repDbSchema = { env: {}, data: {} }; - let $pnl = ds.$pnl = {}, $frm = ds.$frm = {}, $dlg = ds.$dlg = {}; + let rs = sbc.mdl.repoSchema = { env: {} }; //-------------------------------------------------------------- - ds.refreshDbSchema = function (delay) + rs.refreshDbSchema = function (env, delay) { if (sbc.awaitingLogin) return; - if (!$frm.filter.find('.FilterContext').val()) return; - if (!ds.awaitingSchemaResponse) + if (!env.$frm.filter.find('.FilterContext').val()) return; + if (!rs.awaitingSchemaResponse) { - $pnl.msgs.hide().empty().append($('
' + sbc.msg.dataQuerying + '
')).fadeIn(200); + env.$pnl.bgr.invisible(); + rs.clearItems(env); + env.$pnl.msgs.hide().empty().append($('
' + sbc.msg.dataQuerying + '
')).fadeIn(200); } - ds.clearItems(); - sbc.ajax.dbSchema = sbc.ajax.dbSchema || { url: sbc.url.base + 'System/Ajax/ValidateDatabaseSchema', formSel: $frm.filter, callbackFn: ds.handleDbSchemaResponse, noWaitIcon: true }; - sbc.doAjaxRequest(sbc.ajax.dbSchema, delay || 50); - ds.awaitingSchemaResponse = true; + env.ajax.dbSchema = env.ajax.dbSchema || { url: sbc.url.base + 'System/Ajax/ValidateDatabaseSchema', formSel: env.$frm.filter, callbackFn: function (response) { rs.handleDbSchemaResponse(env, response); }, noWaitIcon: true }; + sbc.doAjaxRequest(env.ajax.dbSchema, delay || 50); + rs.awaitingSchemaResponse = true; } - ds.handleDbSchemaResponse = function (response) + rs.handleDbSchemaResponse = function (env, response) { //sbc.debug('handleDbSchemaResponse', response); - delete ds.awaitingSchemaResponse; - $pnl.msgs.hide().empty(); - var $table = $pnl.table.find('table.sbc-item-list'); - ds.clearItems(); + delete rs.awaitingSchemaResponse; + env.$pnl.msgs.hide().empty(); + var $table = env.$pnl.table.find('table.sbc-item-list'); + rs.clearItems(env); if (!response.success) return; + // Menu. + if (env.$pnl.bgr.length) + { + env.$pnl.mnu.empty(); + env.$pnl.mnu.append(rs.getFilterMenuOption(env, sbc.lbl.refresh, function () { rs.refreshDbSchema(env); }, 'sbc-refresh')); + env.$pnl.mnu.append(rs.getFilterMenuOption(env, sbc.lbl.popIndices, function () { rs.populateIndices(env); }, 'sbc-process')); + sbc.debug(env.$pnl.mnu); + env.$pnl.bgr.toggleVisibility(!!env.$pnl.mnu.find('.sbc-dropdown-item').length); + } // Items. var items = response.items; if (!items.length) - return $pnl.msgs.append($('
' + sbc.msg.dbSchemaValid + '
')).fadeIn(500); + return env.$pnl.msgs.append($('
' + sbc.msg.dbSchemaValid + '
')).fadeIn(500); for (const item of items) - $table.append(ds.populateDbSchemaItem(ds.getDbSchemaRowTemplate(), item)); + $table.append(rs.populateDbSchemaItem(env, rs.getItemTemplate(env), item)); } - ds.getDbSchemaTableTemplate = function () - { - return $pnl.tmpl.find('.sbc-panel-item-table.Schema').clone().hide(); - } - ds.getDbSchemaRowTemplate = function () - { - return $pnl.tmpl.find('.sbc-row-item.SchemaItem').clone(); - } - ds.populateDbSchemaItem = function ($item, item) + rs.populateDbSchemaItem = function (env, $item, item) { if (!item) return; $item.prop('id', sbc.itemIdPrefix + item.id); @@ -54,25 +55,72 @@ $('.IndexName', $item).text(item.indexName); $('.ColumnName', $item).text(item.columnName); $('.Comment', $item).text(item.comment); + let $bgr = $item.find('.sbc-burger').invisible(); return $item; } - ds.clearItems = function () + rs.clearItems = function (env) { - $pnl.table.find('table.sbc-item-list').find('tbody tr').remove(); + env.$pnl.table.find('table.sbc-item-list').find('tbody tr').remove(); + } + + //-------------------------------------------------------------- + rs.getFilterDropdownTemplate = function (env) + { + return env.$pnl.tmpl.find('.sbc-dropdown-menu.SchemaFilter li.sbc-dropdown-item').clone(); + } + rs.getItemTemplate = function (env) + { + return env.$pnl.tmpl.find('.sbc-row-item.SchemaItem').clone(); + } + rs.getItemDropdownTemplate = function (env) + { + return env.$pnl.tmpl.find('.sbc-dropdown-menu.SchemaItem li.sbc-dropdown-item').clone(); + } + rs.getFilterMenuOption = function (env, lbl, fn, cls) + { + return rs.getMenuOption(rs.getFilterDropdownTemplate(env), lbl, fn, cls); + } + rs.getItemMenuOption = function (env, lbl, fn, cls) + { + return rs.getMenuOption(rs.getItemDropdownTemplate(env), lbl, fn, cls); + } + rs.getMenuOption = function ($opt, lbl, fn, cls) + { + return $opt.find('div.sbc-label').text(lbl).end().on('click', fn).addClass(cls); + } + + //-------------------------------------------------------------- + rs.populateIndices = function (env, delay) + { + env.ajax.popIndices = env.ajax.popIndices || { url: sbc.url.base + 'Instance/Repository/Ajax/PopulateIndices', formSel: env.$frm.filter, callbackFn: function (response) { rs.onPopulateIndices(env, response); }, noWaitIcon: true }; + sbc.doAjaxRequest(env.ajax.popIndices, delay || 50); + } + rs.onPopulateIndices = function (env, response) + { + //sbc.debug('onPopulateIndices', response); + rs.refreshDbSchema(env); } //-------------------------------------------------------------- $(function () { - $pnl.items = $('.sbc-panel.Schema'); - $frm.filter = $pnl.items.find('#frmSchemaFilter'); - $frm.filter.on('change', '.FilterContext', ds.refreshDbSchema); - $frm.filter.on('input', '.FilterSearch', ds.refreshDbSchema); - $frm.filter.find('.FilterInstance').val('BusMgr'); - $pnl.table = $pnl.items.find('.sbc-panel-item-table'); - $pnl.msgs = $pnl.items.find('.sbc-panel-messages'); - $pnl.tmpl = $pnl.items.find('.sbc-panel-item-template'); - setTimeout(function () { ds.refreshDbSchema(); }, 500); + let env = { data: {}, ajax: {}, $pnl: {}, $frm: {}, $ctrl: {}, $dlg: {} }; + + env.$pnl.items = $('.sbc-panel.Schema'); + env.$pnl.header = env.$pnl.items.find('.sbc-panel-header'); + env.$pnl.bgr = env.$pnl.header.find('.sbc-burger').invisible(); + env.$pnl.mnu = env.$pnl.bgr.find('ul.sbc-dropdown-menu'); + env.$frm.filter = env.$pnl.items.find('#frmSchemaFilter'); + env.$frm.filter.on('change', '.FilterContext', function () { rs.refreshDbSchema(env); }); + env.$frm.filter.on('input', '.FilterSearch', function () { rs.refreshDbSchema(env); }); + env.$frm.filter.find('.FilterInstance').val('BusMgr'); + env.$pnl.table = env.$pnl.items.find('.sbc-panel-item-table'); + env.$pnl.msgs = env.$pnl.items.find('.sbc-panel-messages'); + env.$pnl.tmpl = env.$pnl.items.find('.sbc-panel-item-template'); + + rs.env.schema = env; + if (rs.env.schema.$pnl.table.length) + setTimeout(function () { rs.refreshDbSchema(env); }, 500); }); //-------------------------------------------------------------- diff --git a/SaBusinessMgrCoreWebPortal/Localisation/SbmPortalProperties.resx b/SaBusinessMgrCoreWebPortal/Localisation/SbmPortalProperties.resx index 89c01ac..bf8c6b2 100644 --- a/SaBusinessMgrCoreWebPortal/Localisation/SbmPortalProperties.resx +++ b/SaBusinessMgrCoreWebPortal/Localisation/SbmPortalProperties.resx @@ -513,8 +513,8 @@ Phone - - Sales price + + Sale price Cost price @@ -744,4 +744,13 @@ Strength + + Unit + + + Price + + + Tax + \ No newline at end of file diff --git a/SaBusinessMgrCoreWebPortal/Portal/App/SbmApplication_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/App/SbmApplication_Portal.cs index 9463ed3..96cd46a 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/App/SbmApplication_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/App/SbmApplication_Portal.cs @@ -33,6 +33,7 @@ using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Dbas.Base; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; @@ -217,13 +218,16 @@ namespace Sarand.BusinessMgr.Web.Portal.App else if (AppConfig.Instance.EqualsCI("PreProd")) instanceType = Sbm.InstanceType.UAT; // Initialise hard-coded logging path. - if (StringUtil.IsEmpty(LoggingRootFolder)) + if (StringUtil.IsBlank(LoggingRootFolder)) { if (SbmSystem.ComputerName.EqualsCI("WIN-BPCLM1QUOMT")) LoggingRootFolder = @"D:\Sbmonite\Logs\" + (Development ? "Dev" : "Test"); } if (DirectoryUtil.DirectoryExists(LoggingRootFolder)) - SaLogger.LogFolder = LoggingRootFolder; + { + SaLogger.LogFolder = Path.Combine(LoggingRootFolder, Sbm.Config.Logging.Folder.WebPortal); + FileUtil.ValidateDirectory(SaLogger.LogFolder, true); + } LogApplicationStart($"{SysUtil.Fn}"); // Control database connection. diff --git a/SaBusinessMgrCoreWebPortal/Portal/Consoles/SbmDemoInstanceConsole_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/Consoles/SbmDemoInstanceConsole_Portal.cs index 77393f9..203b9e5 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Consoles/SbmDemoInstanceConsole_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Consoles/SbmDemoInstanceConsole_Portal.cs @@ -9,6 +9,7 @@ using Sarand.BusinessMgr.Web.Portal.Components; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.ReferenceData; using Sarand.Net.Standard.Base.Security; using Sarand.Net.Standard.Base.Utils; using System; @@ -109,7 +110,14 @@ namespace Sarand.BusinessMgr.Web.Portal.Consoles SbmRepositoryPopulationData.CommodityData commodity02 = new SbmRepositoryPopulationData.StockCommodityData() { Code = "MONOPOLY-DEL", Caption = "Monopoly Deluxe", SalePrice = 32.45m }; SbmRepositoryPopulationData.CommodityData commodity03 = new SbmRepositoryPopulationData.StockCommodityData() { Code = "CLUEDO-STD", Caption = "Cluedo", SalePrice = 18.25m }; SbmRepositoryPopulationData.CommodityData commodity04 = new SbmRepositoryPopulationData.StockCommodityData() { Code = "RISK-STD", Caption = "Risk", SalePrice = 21.50m }; - data.Commodities.AddRange(new List() { commodity01, commodity02, commodity03, commodity04 }); + SbmRepositoryPopulationData.CommodityData commodity90 = new SbmRepositoryPopulationData.ServiceCommodityData() { Code = "TUITION-EXP", Caption = "Expert Tuition", SalePrice = 45.00m }; + SbmRepositoryPopulationData.CommodityData commodity91 = new SbmRepositoryPopulationData.ServiceCommodityData() { Code = "TUITION-STD", Caption = "Standard Tuition", SalePrice = 38.75m }; + SbmRepositoryPopulationData.CommodityData commodity92 = new SbmRepositoryPopulationData.ServiceCommodityData() { Code = "TUITION-BAS", Caption = "Basic Tuition", SalePrice = 32.50m }; + data.Commodities.AddRange(new List() + { + commodity01, commodity02, commodity03, commodity04, + commodity90, commodity91, commodity92 + }); return data; } @@ -223,12 +231,14 @@ namespace Sarand.BusinessMgr.Web.Portal.Consoles { if (HasErrorState()) return false; SysId affilliateIdOwner = data.AffiliateIdOrganisation; + Dictionary uomTypes = Internals.GetUnitsOfMeasure().ToDictionary(item => item.UnitType, item => item); foreach (var commodityData in data.Commodities) { SbmCommodity commodity = Internals.CommodityMgr.CreateCommodity(commodityData.Type, commodityData.Code); commodity.DescBrief = commodityData.Caption; commodity.SalesPrice = commodityData.SalePrice; + commodity.UomIdSale = uomTypes.GetValueOrDefault(commodityData.SaleUnitType)?.Id; if (!Internals.CommodityMgr.InsertCommodity(commodity, DbUpdateInfo)) { string msg = "Repository population failed (Commodity)."; diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs index e958196..0566b17 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs @@ -8,10 +8,12 @@ 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.Security; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities { @@ -30,21 +32,22 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities // Field values. public AjaxResponse_Data.FieldValuesData Field { get; } = new AjaxResponse_Data.FieldValuesData(); } - private enum CommodityDataGroup + public enum CommodityDataGroup { - Sales, Purchasing, Specification, Production + Unknown, Sales, Purchasing, Specification, Production } private class CommodityItemData : CommodityListData { // Affiliate properties with specific handling. public String TypeCode { get; set; } public String TypeDesc { get; set; } + public String SalesUnitType { get; set; } } private void PopulateCommodityResponseListData(SbmCommodity commodity, CommodityListData data) { data.Id = SysId.ToString(commodity.Id); } - private void PopulateCommodityResponseItemData(SbmCommodity commodity, CommodityItemData data, HashSet dataGroups = null) + private void PopulateCommodityResponseItemData(SbmCommodity commodity, CommodityItemData data, HashSet dataGroups) { PopulateCommodityResponseListData(commodity, data as CommodityListData); // Prominent properties for selecting and editing. @@ -58,26 +61,33 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities data.Field.Value.Add($"{Model_Commodity.ItemField.Code}", commodity.Code); data.Field.Value.Add($"{Model_Commodity.ItemField.DescBrief}", commodity.DescBrief); data.Field.Value.Add($"{Model_Commodity.ItemField.DrawingIssue}", commodity.DrawingIssue); + // Sales. data.Field.Value.Add($"{Model_Commodity.ItemField.SalesPriceFmt}", StringUtil.NullOnBlank(StringUtil.FormatNumeric(commodity.SalesPrice, SbmInternals.CurrencyDecimalsDefault, 0, ','))); data.Field.Value.Add($"{Model_Commodity.ItemField.SalesUnit}", StringUtil.NullOnBlank(Internals.GetUnitOfMeasureCaption(commodity.UomIdSale))); - data.Field.Value.Add($"{Model_Commodity.ItemField.CostPriceFmt}", StringUtil.NullOnBlank(StringUtil.FormatNumeric(commodity.CostPrice, SbmInternals.CurrencyDecimalsDefault, 0, ','))); - data.Field.Value.Add($"{Model_Commodity.ItemField.AssocIdCustomer}", StringUtil.NullOnBlank(SysId.ToString(commodity.AssociationIdCustomer))); - data.Field.Value.Add($"{Model_Commodity.ItemField.AssocIdSupplier}", StringUtil.NullOnBlank(SysId.ToString(commodity.AssociationIdSupplier))); if (dataGroups != null && dataGroups.Contains(CommodityDataGroup.Sales)) { // Sales. data.Field.Value.Add($"{Model_Commodity.ItemField.SalesPrice}", StringUtil.NullOnBlank(StringUtil.FormatNumeric(commodity.SalesPrice, SbmInternals.CurrencyDecimalsDefault))); - data.Field.Value.Add($"{Model_Commodity.ItemField.UomIdSale}", StringUtil.NullOnBlank(SysId.ToString(commodity.UomIdSale))); + data.Field.Value.Add($"{Model_Commodity.ItemField.SalesTaxCode}", Internals.GetTaxCodeById(commodity.TaxCodeId)?.Code); + data.SalesUnitType = SbmSystem.GetSystemCodes(Sbm.SystemCode.UnitMeasureType).GetCodeForType(Internals.GetUnitOfMeasureType(commodity.UomIdSale)); + if (commodity.PackQtySale > 0) + data.Field.Value.Add($"{Model_Commodity.ItemField.SalesPackQty}", $"{commodity.PackQtySale}"); + data.Field.Value.Add($"{Model_Commodity.ItemField.AssocIdCustomer}", StringUtil.NullOnBlank(SysId.ToString(commodity.AssociationIdCustomer))); } + // Purchasing. if (dataGroups != null && dataGroups.Contains(CommodityDataGroup.Purchasing)) { // Purchasing. data.Field.Value.Add($"{Model_Commodity.ItemField.CostPrice}", StringUtil.NullOnBlank(StringUtil.FormatNumeric(commodity.CostPrice, SbmInternals.CurrencyDecimalsDefault))); + data.Field.Value.Add($"{Model_Commodity.ItemField.CostPriceFmt}", StringUtil.NullOnBlank(StringUtil.FormatNumeric(commodity.CostPrice, SbmInternals.CurrencyDecimalsDefault, 0, ','))); + data.Field.Value.Add($"{Model_Commodity.ItemField.AssocIdSupplier}", StringUtil.NullOnBlank(SysId.ToString(commodity.AssociationIdSupplier))); } + // Specification. if (dataGroups != null && dataGroups.Contains(CommodityDataGroup.Specification)) { // Specification. } + // Production. if (dataGroups != null && dataGroups.Contains(CommodityDataGroup.Production)) { // Production. @@ -104,8 +114,14 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities public Model_Commodity.ListConfigData Config { get; } = new Model_Commodity.ListConfigData(); public Model_Commodity.ItemConfigData ConfigItemNew { get; } = new Model_Commodity.ItemConfigData(); // Reference data. - public List CommodityTypes { get; } = new List(); - public List Statuses { get; } = new List(); + public List CommodityTypes { get; } = new List(); + public List TaxCodes { get; } = new List(); + public String taxCodeDefault { get; set; } + public List UomCats { get; } = new List(); + public List UomTypes { get; } = new List(); + public String uomTypeDefault { get; set; } + public List Uoms { get; set; } = new List(); + public List Statuses { get; } = new List(); public String DefaultStatusCode { get; set; } } // Ajax request. @@ -137,11 +153,33 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities // Reference data - commodity types. foreach (TypeCodeDesc commodityType in GetCodesOfType(Sbm.SystemCode.CommodityType)) - responseData.CommodityTypes.Add(commodityType.Code, commodityType.Desc); + responseData.CommodityTypes.Add(new AjaxResponse_Data.ItemCodeDesc(commodityType.Code, commodityType.Desc)); + + // Tax codes. + DateTime taxEffectiveOn = DateTime.Today; + responseData.TaxCodes.AddRange(Internals.GetTaxCodesEffectiveOn(taxEffectiveOn).Select(tax => new AjaxResponse_Data.TaxCode() { Id = $"{SysId.ToLong(tax.Id)}", Code = tax.Code, Caption = tax.GetCaption(), Rate = tax.TaxRate })); + responseData.taxCodeDefault = Internals.GetDefaultTaxCode(); + + // Units of measure. + List uomCategories = SbmSystem.GetSystemCodes(Sbm.SystemCode.UnitMeasureCategory); + List uomTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.UnitMeasureType); + responseData.UomCats.AddRange(uomCategories.Select(item => new AjaxResponse_Data.ItemCodeDesc(item.Code, item.Desc))); + responseData.UomTypes.AddRange(uomTypes.Select(item => new AjaxResponse_Data.ItemCodeDesc(item.Code, item.Desc))); + foreach (SaUnitMeasure uom in Internals.GetUnitsOfMeasure()) + { + responseData.Uoms.Add(new AjaxResponse_Data.UomData() + { + Id = $"{SysId.ToLong(uom.Id)}", + Category = uomCategories.GetCodeForType(uom.Category), + Type = uomTypes.GetCodeForType(uom.UnitType), + Caption = uom.Multiple, + }); + } + responseData.uomTypeDefault = uomTypes.GetCodeForType(Internals.GetDefaultUomType()); // Reference data - statuses. foreach (SaStatus status in SbmCommodity.ValidStatuses.FindAll(item => item != SaStatus.Deleted)) - responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status)); + responseData.Statuses.Add(new AjaxResponse_Data.ItemCodeDesc(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status))); responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SbmCommodity.DefaultStatus); } @@ -317,7 +355,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities // Construct response. model.PopulateItemConfig(responseData.Config, commodity); - PopulateCommodityResponseItemData(commodity, responseData.commodity); + PopulateCommodityResponseItemData(commodity, responseData.commodity, model.GetDataGroups()); responseData.Success = true; } return Json(responseData); @@ -385,6 +423,15 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities commodity.Code = model.Commodity.Code; if (model.Commodity.DescBrief != null) commodity.DescBrief = model.Commodity.DescBrief; + // Sales. + if (model.Commodity.SalesPrice != null) + commodity.SalesPrice = model.GetCommoditySalesPrice(); + if (model.Commodity.SalesTaxCode != null) + commodity.TaxCodeId = model.GetCommoditySalesTaxCodeId(); + if (model.Commodity.SalesUnitType != null) + commodity.UomIdSale = model.GetCommoditySalesUnitId(); + if (model.Commodity.SalesPackQty != null) + commodity.PackQtySale = model.GetCommoditySalesPackQty(); // Common properties. if (model.Commodity.Notes != null) commodity.Notes = model.Commodity.Notes; @@ -414,7 +461,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities // Construct response. model.PopulateItemConfig(responseData.Config, commodity); - PopulateCommodityResponseItemData(commodity, responseData.commodity); + PopulateCommodityResponseItemData(commodity, responseData.commodity, model.GetDataGroups()); responseData.Success = true; } return Json(responseData); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity-Config.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity-Config.cs index 2a161af..e1070fc 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity-Config.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity-Config.cs @@ -71,15 +71,14 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities SalesPrice, /// Formatted sales price - for list only. SalesPriceFmt, + SalesTaxCode, + /// Unit of sale - caption for list & name of form control. + SalesUnit, + SalesPackQty, + MinOrderQty, RetailPrice, RetailPricePlanned, - TaxCodeId, CarriageCostIndicative, - UomIdSale, - /// Unit of sale caption - for list only. - SalesUnit, - PackQtySale, - MinOrderQty, DescOrder, AssocIdCustomer, Customer, @@ -261,9 +260,9 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities // Pack qty. if (modeIsStockControl || SessionConsole.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale)) - config.Column.Label.Add($"{ItemField.PackQtySale}", Localiser["label.pack.quantity"]); + config.Column.Label.Add($"{ItemField.SalesPackQty}", Localiser["label.pack.quantity"]); else - config.Column.Hide.Add($"{ItemField.PackQtySale}"); + config.Column.Hide.Add($"{ItemField.SalesPackQty}"); // Customer. if (modeIsStockControl || !SessionConsole.AllowOption(Sbm.ConfigOption.CommodityExclusiveToCustomer)) @@ -446,7 +445,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities // Tax code if (managedByAccounts || !UserCanUpdateFinancials()) - config.Field.Readonly.Add($"{ItemField.TaxCodeId}"); + config.Field.Readonly.Add($"{ItemField.SalesTaxCode}"); // Indicative carriage cost. if (UserCanViewCommodityFinancials_Sales() && SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative) || !CommodityMgr.ColumnExists(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative)) @@ -459,7 +458,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities // Sales Unit. if (managedByAccounts || !UserCanUpdateFinancials()) - config.Field.Readonly.Add($"{ItemField.UomIdSale}"); + config.Field.Readonly.Add($"{ItemField.SalesUnit}"); // Sales Pack quantity. diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity.cs index 926836e..11167b0 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity.cs @@ -2,12 +2,16 @@ using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Web.Portal.Components; +using Sarand.BusinessMgr.Web.Portal.Controllers.Commodities; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.ReferenceData; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities { @@ -60,6 +64,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities { public String Exists { get; set; } public String Id { get; set; } + public String DataGroups { get; set; } public String IdSupersede { get; set; } public String Type { get; set; } public String Code { get; set; } @@ -67,16 +72,51 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities public String DescBrief { get; set; } public String AssocIdCustomer { get; set; } public String AssocIdSupplier { get; set; } + // Sales. + public String SalesPrice { get; set; } + public String SalesTaxCode { get; set; } + public String SalesUnitType { get; set; } + public String SalesPackQty { get; set; } // Common properties. public String Notes { get; set; } public String StatusCode { get; set; } public String SupersededStatusConfirmed { get; set; } } public CommodityData Commodity { get; } = new CommodityData(); + public HashSet GetDataGroups() + { + return + Regex.Split(StringUtil.OnBlank(Commodity.DataGroups), "[\\s,;\\-+]+") + .Select(item => EnumUtil.ParseEnum(item, CommodityController.CommodityDataGroup.Unknown)) + .Where(item => item != CommodityController.CommodityDataGroup.Unknown) + .ToHashSet(); + } public Sbm.CommodityType GetCommodityType() { return (Sbm.CommodityType)Internals.CommodityTypeCodes.GetTypeForCode(Commodity.Type); } + // Sales. + public decimal GetCommoditySalesPrice() + { + return StringUtil.ToDecimal(Commodity.SalesPrice); + } + public SysId GetCommoditySalesTaxCodeId() + { + return Internals.GetTaxCodesEffectiveOn(DateTime.Today).FirstOrDefault(tax => tax.Code.EqualsCI(Commodity.SalesTaxCode))?.Id; + } + public SaUomType GetCommoditySalesUnitType() + { + return (SaUomType)Internals.GetSystemCodes(Sbm.SystemCode.UnitMeasureType).GetTypeForCode(Commodity.SalesUnitType); + } + public SysId GetCommoditySalesUnitId() + { + return Internals.GetUnitsOfMeasure().FirstOrDefault(uom => uom.UnitType == GetCommoditySalesUnitType())?.Id; + } + public int GetCommoditySalesPackQty() + { + return StringUtil.ToInt(Commodity.SalesPackQty); + } + // Common properties. public SaStatus GetCommodityStatus() { return SacsSystem.GetStatusForCode(Commodity.StatusCode); @@ -91,7 +131,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities // Commodity Type. if (Commodity.Type != null) { - String controlName = "CommodityType"; + String controlName = GetFieldName(Model_Commodity.ItemField.Type); if (Commodity.Type.IsEmpty() || GetCommodityType() <= 0) responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]); } @@ -99,25 +139,64 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities // Commodity Code. if (Commodity.Code != null) { - String controlName = "CommodityCode"; + String controlName = GetFieldName(Model_Commodity.ItemField.Code); responseData.SetControlValue(controlName, Commodity.Code); if (Commodity.Code.IsEmpty()) responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]); - if (StringUtil.GetLength(Commodity.Code) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_Code)) + else if (StringUtil.GetLength(Commodity.Code) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_Code)) responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_Code)]); } // Commodity Description. if (Commodity.DescBrief != null) { - String controlName = "CommodityDesc"; + String controlName = GetFieldName(Model_Commodity.ItemField.DescBrief); responseData.SetControlValue(controlName, Commodity.DescBrief); if (Commodity.DescBrief.IsEmpty()) responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]); - if (StringUtil.GetLength(Commodity.DescBrief) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_DescBrief)) + else if (StringUtil.GetLength(Commodity.DescBrief) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_DescBrief)) responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_DescBrief)]); } + // Commodity Sales Price. + if (Commodity.SalesPrice != null) + { + String controlName = GetFieldName(Model_Commodity.ItemField.SalesPrice); + responseData.SetControlValue(controlName, Commodity.SalesPrice); + if (Commodity.SalesPrice.IsBlank()) + responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]); + else if (!StringUtil.IsDecimal(Commodity.SalesPrice) || GetCommoditySalesPrice() < 0.0m) + responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]); + } + + // Commodity Tax. + if (Commodity.SalesTaxCode != null) + { + String controlName = GetFieldName(Model_Commodity.ItemField.SalesTaxCode); + if (Commodity.SalesTaxCode.IsBlank()) + responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]); + else if (!SysId.IsValid(GetCommoditySalesTaxCodeId())) + responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]); + } + + // Commodity Sales Unit Type. + if (Commodity.SalesUnitType != null) + { + String controlName = GetFieldName(Model_Commodity.ItemField.SalesUnit); + if (Commodity.SalesUnitType.IsBlank()) + responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]); + else if (GetCommoditySalesUnitType() == SaUomType.Unknown || !SysId.IsValid(GetCommoditySalesUnitId())) + responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]); + } + + // Commodity Sales pack quantity. + if (Commodity.SalesPackQty != null) + { + String controlName = GetFieldName(Model_Commodity.ItemField.SalesPackQty); + if (!StringUtil.IsBlank(Commodity.SalesPackQty) && (!StringUtil.IsNumeric(Commodity.SalesPackQty) || GetCommoditySalesPackQty() < 1)) + responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]); + } + // Commodity Notes. if (Commodity.Notes != null) { @@ -161,10 +240,10 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities SbmCommodity.Params prmCommodity = new SbmCommodity.Params(); // Ignore this commodity if it already exists. if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id))) - prmCommodity.PriceSetIdsExcluded.Add(SysId.ToSysId(Commodity.Id)); + prmCommodity.IdsExcluded.Add(SysId.ToSysId(Commodity.Id)); // Ignore the commodity being superseded, if any. if (SysId.IsValid(SysId.ToSysId(Commodity.IdSupersede))) - prmCommodity.PriceSetIdsExcluded.Add(SysId.ToSysId(Commodity.IdSupersede)); + prmCommodity.IdsExcluded.Add(SysId.ToSysId(Commodity.IdSupersede)); // Same code and issue. prmCommodity.CodeFull = Commodity.Code; prmCommodity.DrawingIssueFull = Commodity.DrawingIssue; @@ -198,7 +277,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities SbmCommodity.Params prmCommodity = new SbmCommodity.Params(); // Ignore this commodity if it already exists. if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id))) - prmCommodity.PriceSetIdsExcluded.Add(SysId.ToSysId(Commodity.Id)); + prmCommodity.IdsExcluded.Add(SysId.ToSysId(Commodity.Id)); // Same code. prmCommodity.CodeFull = Commodity.Code; prmCommodity.StatusCat = SbmCommodity.StatusCat.Current; diff --git a/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityDialog.cshtml b/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityDialog.cshtml index 9dbfcd5..5075d98 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityDialog.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityDialog.cshtml @@ -15,6 +15,7 @@ @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmCommodityId", @class = "sbm-form" })) { @Html.Hidden("Commodity.Id", "", new { @id = "", @class = "CommodityId" }) + @Html.Hidden("Commodity.DataGroups", "", new { @id = "", @class = "CommodityDataGroups" }) }
@@ -24,45 +25,56 @@ @Html.Hidden("Commodity.Id", "", new { @id = "", @class = "CommodityId sbm-input" }) @Html.Hidden("Commodity.Exists", "", new { @id = "", @class = "CommodityExists sbm-input" }) @Html.Hidden("Commodity.SupersededStatusConfirmed", "", new { @id = "", @class = "SupersededStatusConfirmed sbm-input" }) +
- @* Commodity Type *@ -
-
-
-
- +
+
+ + @* Commodity Code *@ +
+
+
+
+ +
+
+
+
+ @Html.TextBox("Commodity.Code", "", new { @id = "ifCommodityCode", @class = "CommodityCode sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_Code) }) +
+
+
-
-
- @Html.DropDownList("Commodity.Type", Model.GetCommodityTypeCodesForDropdown(), Localiser["label.select"], new { @id = "cbCommodityType", @class = "CommodityType sbm-select" }) -
-
-
+
-
+
- @* Commodity Code *@ -
-
-
-
- + @* Commodity Type *@ +
+
+
+
+
+ +
+
+
+
+ @Html.DropDownList("Commodity.Type", Model.GetCommodityTypeCodesForDropdown(), Localiser["label.select"], new { @id = "cbCommodityType", @class = "CommodityType sbm-select" }) +
+
+
-
-
- @Html.TextBox("Commodity.Code", "", new { @id = "ifCommodityCode", @class = "CommodityCode sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_Code) }) -
-
-
+
@* Commodity Description *@
-
+
@@ -76,10 +88,106 @@
+
+
+ + @* Sales Price *@ +
+
+
+
+ +
+
+
+
+ @Html.TextBox("Commodity.SalesPrice", "", new { @id = "ifCommoditySalesPrice", @class = "CommoditySalesPrice sbm-input right sbm-auto-val sbm-format-currency", @maxlength = 12 }) +
+
+
+
+
+ +
+
+ + @* Sales Unit *@ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+ + @* Sales Tax *@ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ +
+
+ + @* Sales Unit *@ +
+ @Html.Hidden("Commodity.SalesUomId") +
+
+
+
+ +
+
+
+
+ @Html.TextBox("Commodity.SalesPackQty", "", new { @id = "ifCommoditySalesPackQty", @class = "CommoditySalesPackQty sbm-input right sbm-auto-val sbm-format-integer", @maxlength = 5 }) +
+
+
+
+
+ +
+
+ @* Commodity status *@
-
+
@@ -96,7 +204,7 @@ @* Commodity Notes *@
-
+
diff --git a/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityList.cshtml b/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityList.cshtml index 2e4e880..2da6894 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityList.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityList.cshtml @@ -16,8 +16,8 @@ @Localiser["label.type"] @if (Model.UserCanViewCommodityFinancials_Sales()) { - @Localiser["label.sales.price"] - @Localiser["label.unit.of.sale"] + @Localiser["label.price"] + @Localiser["label.unit"] } @Localiser["label.notes"] @Localiser["label.status"] diff --git a/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityMaintain.cshtml b/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityMaintain.cshtml index 8b6218e..ce97b11 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityMaintain.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Commodity/Panel-CommodityMaintain.cshtml @@ -63,6 +63,7 @@
-
- + + +
diff --git a/SaBusinessMgrCoreWebPortal/Views/Home/Demo/Register.cshtml b/SaBusinessMgrCoreWebPortal/Views/Home/Demo/Register.cshtml index c03fbfe..b93d5b8 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Home/Demo/Register.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Home/Demo/Register.cshtml @@ -32,7 +32,7 @@
- @Html.TextBoxFor(model => model.EmailAddress, new { @id = "", @class = "AccountEmailAddress sbm-input lower", @readonly = true, @maxlength = @Model.GetControlMaxLength(SaSecurityDbDfn.ColumnIdx.SaSecItem_EmailAddress) }) + @Html.TextBoxFor(model => model.EmailAddress, new { @type = "email", @id = "", @class = "AccountEmailAddress sbm-input lower", @readonly = true, @maxlength = @Model.GetControlMaxLength(SaSecurityDbDfn.ColumnIdx.SaSecItem_EmailAddress) })
diff --git a/SaBusinessMgrCoreWebPortal/Views/Home/Demo/Request.cshtml b/SaBusinessMgrCoreWebPortal/Views/Home/Demo/Request.cshtml index 8b49fe7..59e5b64 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Home/Demo/Request.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Home/Demo/Request.cshtml @@ -24,7 +24,7 @@
- @Html.TextBoxFor(model => model.EmailAddress, new { @id = "ifEmailAddress", @class = "sbm-input lower", @maxlength = @Model.GetControlMaxLength(SaSecurityDbDfn.ColumnIdx.SaSecItem_EmailAddress) }) + @Html.TextBoxFor(model => model.EmailAddress, new { @type = "email", @id = "ifEmailAddress", @class = "sbm-input lower", @maxlength = @Model.GetControlMaxLength(SaSecurityDbDfn.ColumnIdx.SaSecItem_EmailAddress) })
diff --git a/SaBusinessMgrCoreWebPortal/Views/Security/RequestPassword.cshtml b/SaBusinessMgrCoreWebPortal/Views/Security/RequestPassword.cshtml index 9caad4b..6151fe6 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Security/RequestPassword.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Security/RequestPassword.cshtml @@ -31,7 +31,7 @@
- @Html.TextBoxFor(model => model.EmailAddress, new { @id = "ifEmailAddress", @class = "sbm-input lower", @maxlength = "128" }) + @Html.TextBoxFor(model => model.EmailAddress, new { @type = "email", @id = "ifEmailAddress", @class = "sbm-input lower", @maxlength = "128" })
diff --git a/SaBusinessMgrCoreWebPortal/Views/Security/Signin.cshtml b/SaBusinessMgrCoreWebPortal/Views/Security/Signin.cshtml index a2ce593..77f4125 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Security/Signin.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Security/Signin.cshtml @@ -34,7 +34,7 @@
- @Html.TextBoxFor(model => model.EmailAddress, new { @id = "ifEmailAddress", @class = "sbm-input lower", @maxlength = @Model.GetControlMaxLength(SaSecurityDbDfn.ColumnIdx.SaSecItem_EmailAddress) }) + @Html.TextBoxFor(model => model.EmailAddress, new { @type = "email", @id = "ifEmailAddress", @class = "sbm-input lower", @maxlength = @Model.GetControlMaxLength(SaSecurityDbDfn.ColumnIdx.SaSecItem_EmailAddress) })
diff --git a/SaBusinessMgrCoreWebPortal/Views/Shared/_Layout.cshtml b/SaBusinessMgrCoreWebPortal/Views/Shared/_Layout.cshtml index aef76d6..70fcdeb 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Shared/_Layout.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Shared/_Layout.cshtml @@ -87,6 +87,7 @@ sbm.msg.dataNoneFound = '@Localiser.GetJavascriptText("msg.data.noneFound")'; sbm.maxProfileImageSize = 2 * 10 ** 6; sbm.sessionCookieName = '@Model.SessionCookieName'; + sbm.data.decimalsCurrency = 2; sbm.awaitingLogin = @awaitingLogin; sbm.keepLoggedIn = @keepLoggedIn; sbm.keepLoggedInDelay = @(Sbm.Config.Control.Session.Cookie.KeepLoggedInTimeoutMillis); diff --git a/SaBusinessMgrCoreWebPortal/appsettings.Machine.Sarand110.json b/SaBusinessMgrCoreWebPortal/appsettings.Machine.Sarand110.json index 43326e9..cd607f0 100644 --- a/SaBusinessMgrCoreWebPortal/appsettings.Machine.Sarand110.json +++ b/SaBusinessMgrCoreWebPortal/appsettings.Machine.Sarand110.json @@ -18,7 +18,7 @@ "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\BusinessMgr\\Docs" }, "Logging": { - "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\BusinessMgr\\Logs\\WebPortal" + "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\BusinessMgr\\Logs" } } } diff --git a/SaBusinessMgrCoreWebPortal/appsettings.Machine.Sarand602.json b/SaBusinessMgrCoreWebPortal/appsettings.Machine.Sarand602.json index 5549e0a..ccdb1f4 100644 --- a/SaBusinessMgrCoreWebPortal/appsettings.Machine.Sarand602.json +++ b/SaBusinessMgrCoreWebPortal/appsettings.Machine.Sarand602.json @@ -16,10 +16,10 @@ } }, "Documents": { - "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\BusinessMgr\\Docs" + "RootFolder": "C:\\Sarand\\BusinessMgr\\Docs" }, "Logging": { - "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\BusinessMgr\\Logs\\WebPortal" + "RootFolder": "C:\\Sarand\\BusinessMgr\\Logs" } } } diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-form.css b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-form.css index 692e8ba..5f82bad 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-form.css +++ b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-form.css @@ -109,11 +109,10 @@ .sbm-form .sbm-form-control .sbm-label { - margin: 0 0 8px 0; - font-size: 1rem; - line-height: 1.25; + margin: 2px 0 8px 0; } +.sbm-form .sbm-form-control .sbm-label, .sbm-form .sbm-form-control .sbm-label-text { font-size: 1rem; @@ -140,11 +139,10 @@ .sbm-form .sbm-form-control .sbm-label { - margin: 0 0 8px 0; - font-size: 1rem; - line-height: 1.25; + margin: 2px 0 8px 0; } +.sbm-form .sbm-form-control .sbm-label, .sbm-form .sbm-form-control .sbm-label-text { font-size: 1rem; diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-commodity.js b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-commodity.js index 30b2fd1..28a56eb 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-commodity.js +++ b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-commodity.js @@ -22,6 +22,12 @@ env.config = response.config; env.configItemNew = response.configItemNew; env.data.commodityTypes = response.commodityTypes; + env.data.taxCodes = response.taxCodes; + env.data.taxCodeDefault = response.taxCodeDefault; + env.data.uomCats = response.uomCats; + env.data.uomTypes = response.uomTypes; + env.data.uomTypeDefault = response.uomTypeDefault; + env.data.uoms = response.uoms; env.data.statuses = response.statuses; env.data.defaultStatusCode = response.defaultStatusCode; } @@ -140,6 +146,10 @@ { sbm.clearItemForm(env.$frm.item); sbm.populateSelectCodeDesc('#cbCommodityStatus', env.data.statuses); + sbm.populateSelectCodeDesc(env.$ctrl.saleTaxCode, env.data.taxCodes.map(function (tax) { return { code: tax.code, desc: tax.caption }; })); + env.$ctrl.saleTaxCode.val(env.data.taxCodeDefault); + sbm.populateSelectCodeDesc(env.$ctrl.saleUomCat, env.data.uomCats); + co.populateSalesUomType(env, env.data.uomTypeDefault); } co.openItemDlg = function (env, cfg, title) { @@ -154,17 +164,60 @@ sbm.openDialog($dlg, 720, 640); } + //-------------------------------------------------------------- + co.onTaxCodeSelected = function (env, $taxCode) + { + } + co.onSaleTaxCodeSelected = function (env) + { + co.onTaxCodeSelected(env.$ctrl.saleTaxCode); + } + + //-------------------------------------------------------------- + co.onUomCatSelected = function (env, $saleUomCat, $saleUom) + { + let uomCat = $saleUomCat.val(); + let uom = $saleUom.val(); + let uoms = env.data.uoms.filter(function (uom) { return uom.category == uomCat; }).map(function (uom) { return { code: uom.type, desc: uom.caption }; }); + sbm.populateSelectCodeDesc($saleUom, uoms); + $saleUom.val(uom); + } + co.onSaleUomCatSelected = function (env) + { + co.onUomCatSelected(env, env.$ctrl.saleUomCat, env.$ctrl.saleUom); + } + co.populateUomType = function (env, $saleUomCat, $saleUom, type) + { + //sbm.debug('populateUomType', type); + let uom = env.data.uoms.find(function (uom) { return uom.type == type; }); + if (!uom) return; + $saleUomCat.val(uom.category).trigger('change'); + $saleUom.val(uom.type); + } + co.populateSalesUomType = function (env, type) + { + co.populateUomType(env, env.$ctrl.saleUomCat, env.$ctrl.saleUom, type); + } + co.onUomSelected = function (env, $saleUomCat, $saleUom) + { + } + co.onSaleUomSelected = function (env) + { + co.onUomSelected(env, env.$ctrl.saleUomCat, env.$ctrl.saleUom); + } + //-------------------------------------------------------------- co.updateItem = function (env, id) { let $frm = env.$frm.itemId; $('.CommodityId', $frm).val(id); + $('.CommodityDataGroups', $frm).val('Sales'); env.ajax.updateItem = env.ajax.updateItem || { url: sbm.url.base + 'Commodity/Ajax/GetItem', formSel: $frm, callbackFn: function (response) { co.onUpdateItem(env, response); } }; sbm.doAjaxRequest(env.ajax.updateItem, 50); } co.onUpdateItem = function (env, response) { - //sbm.debug('onUpdateItem', env, response); + sbm.debug('onUpdateItem', env, response); if (!response.success) return; let cfg = response.config || {}; co.clearItem(env, cfg); @@ -175,6 +228,7 @@ $ctrls.filter('.CommodityId').val(item.id); $ctrls.filter('.CommodityExists').val(1); sbm.selectOrAdd($ctrls.filter('.CommodityType'), item.typeCode, item.typeDesc); + co.populateSalesUomType(env, item.salesUnitType); sbm.selectOrAdd($ctrls.filter('.CommodityStatus'), item.statusCode, item.field.value.Status); co.openItemDlg(env, cfg, sbm.dlg.title.updateCommodity); } @@ -182,7 +236,7 @@ //-------------------------------------------------------------- co.storeItem = function (env) { - env.ajax.storeItem = env.ajax.storeItem || {url: sbm.url.base + 'Commodity/Ajax/StoreItem', formSel: env.$frm.item, callbackFn: function (response) { co.onStoreItem(env, response); }}; + env.ajax.storeItem = env.ajax.storeItem || { url: sbm.url.base + 'Commodity/Ajax/StoreItem', formSel: env.$frm.item, callbackFn: function (response) { co.onStoreItem(env, response); } }; sbm.doAjaxRequest(env.ajax.storeItem, 50); } co.onStoreItem = function (env, response) @@ -258,27 +312,31 @@ { let env = { data: {}, ajax: {}, $pnl: {}, $frm: {}, $ctrl: {}, $dlg: {} }; - env.$pnl.items = $($pnlItems); - env.$pnl.header = env.$pnl.items.find('.sbm-panel-header'); + let $items = env.$pnl.items = $($pnlItems); + env.$pnl.header = $items.find('.sbm-panel-header'); env.$pnl.bgr = env.$pnl.header.find('.sbm-burger'); env.$pnl.mnu = env.$pnl.bgr.find('ul.sbm-dropdown-menu'); - env.$pnl.table = env.$pnl.items.find('.sbm-panel-item-table'); + env.$pnl.table = $items.find('.sbm-panel-item-table'); env.$pnl.msgs = env.$pnl.table.find('.sbm-panel-messages'); - env.$pnl.tmpls = env.$pnl.items.find('.sbm-panel-item-template'); + env.$pnl.tmpls = $items.find('.sbm-panel-item-template'); - env.$frm.filter = $('#frmCommodityFilter'); + env.$frm.filter = $items.find('#frmCommodityFilter'); env.$frm.filter.on('input', '.FilterSearch', function () { co.refreshResults(env, 250); }).on('change', '.FilterCommodityType,.FilterStatusCat', function () { co.refreshResults(env, 50); }); + env.$frm.itemId = $items.find('#frmCommodityId'); var opt = sbm.dlgOpts(); opt.dialogClass += " sbm-Commodity"; - env.$dlg.item = $('#dlgCommodity').dialog(opt); - env.$frm.itemId = $('#frmCommodityId'); - env.$frm.item = $('#frmCommodity').on('input', '.sbm-input, .sbm-textarea', function () { sbm.clearControlError(this); }).on('change', '.sbm-select', function () { sbm.clearControlError(this); }); + env.$dlg.item = $items.find('#dlgCommodity').dialog(opt); + env.$frm.item = env.$dlg.item.find('#frmCommodity').on('input', '.sbm-input, .sbm-textarea', function () { sbm.clearControlError(this); }).on('change', '.sbm-select', function () { sbm.clearControlError(this); }); + env.$frm.item.on('blur', '.sbm-input.sbm-format-integer', function () { sbm.formatInteger($(this)); }).on('blur', '.sbm-input.sbm-format-currency', function () { sbm.formatCurrency($(this)); }); + env.$ctrl.saleTaxCode = env.$frm.item.find('.sbm-select.CommoditySalesTaxCode').on('change', function () { co.onSaleTaxCodeSelected(env); }); + env.$ctrl.saleUomCat = env.$frm.item.find('.sbm-select.CommoditySalesUnitCategory').on('change', function () { co.onSaleUomCatSelected(env); }) + env.$ctrl.saleUom = env.$frm.item.find('.sbm-select.CommoditySalesUnitType').on('change', function () { co.onSaleUomSelected(env); }); var opt = sbm.dlgOpts(); opt.dialogClass += " sbm-Commodity"; opt.buttons[sbm.lbl.ok] = function () { co.selectItem(env); }; opt.buttons[sbm.lbl.cancel] = function () { delete env.prmSelect; $(this).dialog('close'); }; - env.$dlg.select = $('#dlgCommoditySelect').dialog(opt); + env.$dlg.select = $items.find('#dlgCommoditySelect').dialog(opt); return env; } diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-main.js b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-main.js index fa0ae11..d7dc0c4 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-main.js +++ b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-main.js @@ -188,6 +188,16 @@ let $ctrl = $('.sbm-form-control', $frm); for (var name in val || {}) { $ctrl.filter('.' + cfg.field.prefix + name).find('.sbm-input,.sbm-textarea,.sbm-select').filter('.sbm-auto-val').val(val[name]).end().find('.sbm-checkbox').prop('checked', !!val[name]); }; } + sbm.formatInteger = function ($ctrl) + { + if (sbm.isNumeric($ctrl.val())) + $ctrl.val(parseFloat($ctrl.val()).toFixed(0)); + } + sbm.formatCurrency = function ($ctrl) + { + if (sbm.isNumeric($ctrl.val())) + $ctrl.val(parseFloat($ctrl.val()).toFixed(sbm.data.decimalsCurrency)); + } //-------------------------------------------------------------- // Page navigation.