3.0.0.4 Portal Commodity Sales properties. Control Index population.

This commit is contained in:
Andy Howard
2025-02-11 21:03:34 +00:00
parent a7bec4e806
commit ef4da874b0
80 changed files with 1294 additions and 383 deletions
@@ -118,7 +118,6 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Components
Response.Headers.Add(HeaderNames.Expires, "0");
}
base.OnActionExecuted(filterContext);
}
+2 -1
View File
@@ -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.
//-------------------------------------------------------------------
}
//=======================================================================
+9
View File
@@ -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
+1 -1
View File
@@ -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
{
+22 -1
View File
@@ -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<SaTaxCode>(taxCodes.Values);
}
public List<SaTaxCode> GetTaxCodesEffectiveOn(DateTime effectiveOn)
{
populateTaxCodes();
return new List<SaTaxCode>(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<SaUnitMeasure> GetUnitsOfMeasureByCategory(SaUomCategory uomCategory)
{
@@ -514,59 +514,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
// Reference.
// Region Type.
systemCodes[Sbm.SystemCode.RegionType] = new List<TypeCodeDesc>()
{
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<TypeCodeDesc>(SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.RegionType));
// Unit Measure Category.
systemCodes[Sbm.SystemCode.UnitMeasureCategory] = new List<TypeCodeDesc>()
{
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<TypeCodeDesc>(SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.UnitMeasureCategory));
// Unit Measure Type.
systemCodes[Sbm.SystemCode.UnitMeasureType] = new List<TypeCodeDesc>()
{
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<TypeCodeDesc>(SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.UnitMeasureType));
// Financial Type.
systemCodes[Sbm.SystemCode.FinancialType] = new List<TypeCodeDesc>()
@@ -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;
}
}
//-------------------------------------------------------------------
@@ -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<String> columnNames = new List<String>(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 <table> ADD PRIMARY KEY (<ColumnList>)
// 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<String> columnNames = new List<String>(Regex.Split(columns, "[\\s,;\\-+]+"));
List<String> includeColumnNames = new List<String>(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);
}
//-------------------------------------------------------------------
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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<String> fieldsPrimary { get; } = new List<String>()
{
"VehicleId",
"Source",
"Type",
"CategoryCode",
"FeatureCode",
};
protected static List<String> fieldsNullable { get; } = new List<String>()
{
@@ -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);
}
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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() + ")");
}
@@ -15401,6 +15401,106 @@
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaAsset</Table>
<Name>IDX_SaAsset_CategorySerial</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>AssetCategoryId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>SerialFmt</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaAsset</Table>
<Name>IDX_SaAsset_Customer</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>AssocIdCustomer</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>Id</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaAsset</Table>
<Name>IDX_SaAsset_Supplier</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>AssocIdSupplier</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>Id</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaAsset</Table>
<Name>IDX_SaAsset_Item</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>ItemType</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>ItemId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
</Indices>
</DbDfnTable>
<DbDfnTable>
@@ -15872,6 +15972,86 @@
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaAssetCategory</Table>
<Name>IDX_SaAssetCategory_Customer</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>AssocIdCustomer</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>Id</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaAssetCategory</Table>
<Name>IDX_SaAssetCategory_OwnerType</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>AffIdOwner</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>AssetType</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>3</Seq>
<Name>Code</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaAssetCategory</Table>
<Name>IDX_SaAssetCategory_Supplier</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>AssocIdSupplier</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>Id</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
</Indices>
</DbDfnTable>
<DbDfnTable>
@@ -18071,6 +18251,86 @@
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaItemData</Table>
<Name>IDX_SaItemData_DataTypeItem</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>DataType</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>ItemType</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>3</Seq>
<Name>ItemId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaItemData</Table>
<Name>IDX_SaItemData_Item</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>ItemType</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>ItemId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaItemData</Table>
<Name>IDX_SaItemData_ItemTypeDataType</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>ItemType</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>DataType</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
</Indices>
</DbDfnTable>
<DbDfnTable>
@@ -21068,6 +21328,101 @@
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaVehicle</Table>
<Name>IDX_SaVehicle_CapCode</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>CapCode</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>Id</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaVehicle</Table>
<Name>IDX_SaVehicle_KeyLocation</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>KeyLocation</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>Id</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaVehicle</Table>
<Name>IDX_SaVehicle_RegNumber</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>RegNumber</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaVehicle</Table>
<Name>IDX_SaVehicle_VehicleClass</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>VehicleClassId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>Id</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
</Indices>
</DbDfnTable>
<DbDfnTable>
@@ -21573,6 +21928,51 @@
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaVehicleClass</Table>
<Name>IDX_SaVehicleClass_Make</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>MakeCode</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>Id</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaVehicleClass</Table>
<Name>IDX_SaVehicleClass_Category</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>VehicleCategoryCode</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
</Indices>
</DbDfnTable>
<DbDfnTable>
@@ -21976,6 +22376,51 @@
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaVehicleEvent</Table>
<Name>IDX_SaVehicleEvent_VehicleStart</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>VehicleId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>StartOn</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaVehicleEvent</Table>
<Name>IDX_SaVehicleEvent_TaxCode</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>TaxCodeId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
</Indices>
</DbDfnTable>
<DbDfnTable>
@@ -22275,6 +22720,26 @@
<Name>VehicleId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>Source</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>3</Seq>
<Name>Type</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>4</Seq>
<Name>CategoryCode</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>5</Seq>
<Name>FeatureCode</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
</Indices>
@@ -24575,6 +25040,66 @@
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>TaxCode</Table>
<Name>IDX_TaxCode_IdX_TaxCode_Code</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>Code</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>TaxCode</Table>
<Name>IDX_TaxCode_IdX_TaxCode_CodeAlt1</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>CodeAlt1</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>TaxCode</Table>
<Name>IDX_TaxCode_IdX_TaxCode_CodeAlt2</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>CodeAlt2</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
</Indices>
</DbDfnTable>
<DbDfnTable>
@@ -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.
@@ -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<String> filter = new List<string>();
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<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
{
// 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<String> statsOutput = new List<string>();
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);
}
//-------------------------------------------------------------------
}
//=======================================================================
@@ -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);
@@ -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<SacsDisposable> disposableItems = new DisposableCollection<SacsDisposable>())
{
// 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}'."));
@@ -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"));
@@ -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();
//-------------------------------------------------------------------
}
@@ -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
{
@@ -435,9 +435,6 @@
<data name="label.repository.database" xml:space="preserve">
<value>Repository database</value>
</data>
<data name="caption.database.core" xml:space="preserve">
<value>Core Database</value>
</data>
<data name="label.schema" xml:space="preserve">
<value>Schema</value>
</data>
@@ -537,4 +534,13 @@
<data name="label.repository.schema" xml:space="preserve">
<value>Repository schema</value>
</data>
<data name="label.populate.indices" xml:space="preserve">
<value>Populate indices</value>
</data>
<data name="caption.repository.schema" xml:space="preserve">
<value>Repository Schema</value>
</data>
<data name="caption.repository.database" xml:space="preserve">
<value>Repository Database</value>
</data>
</root>
@@ -41,17 +41,17 @@
<th style="min-width:200px;">@Localiser["label.context"]</th>
<th class="center" style="min-width:80px;">@Localiser["label.count"]</th>
</tr>
<tr>
<tr class="sbc-action-text" onclick="sbc.navigateTo('Instance/Owner')">
<td class="">Owners</td>
<td class="center sbc-action-text" onclick="sbc.navigateTo('Instance/Owner')">@Model.GetOwnerCount()</td>
<td class="center">@Model.GetOwnerCount()</td>
</tr>
<tr>
<tr class="sbc-action-text" onclick="sbc.navigateTo('Instance/Repository')">
<td class="">Repositories</td>
<td class="center sbc-action-text" onclick="sbc.navigateTo('Instance/Repository')">@Model.GetRepositoryCount()</td>
<td class="center">@Model.GetRepositoryCount()</td>
</tr>
<tr>
<tr class="sbc-action-text" onclick="sbc.navigateTo('Account/UserAccount')">
<td class="">Users</td>
<td class="center sbc-action-text" onclick="sbc.navigateTo('Account/UserAccount')">@Model.GetUserAccountCount()</td>
<td class="center">@Model.GetUserAccountCount()</td>
</tr>
</table>
</div>
@@ -9,6 +9,7 @@
<div class="sbc-panel Schema fullheight">
<script type="text/javascript">
sbc.lbl.popIndices = '@Localiser.GetJavascriptText("label.populate.indices")';
sbc.msg.dbSchemaValid = '@Localiser.GetJavascriptText("msg.database.schema.valid")';
</script>
@@ -23,7 +24,7 @@
<div class="fixed">
@* <partial name="~/Views/Common/ResultsPaging.cshtml" /> *@
</div>
<div class="col center"><div class="sbc-panel-caption">@Localiser["caption.database.core"]</div></div>
<div class="col center"><div class="sbc-panel-caption">@Localiser["caption.repository.schema"]</div></div>
<div class="fixed">
@* Burger menu *@
<ul class="nav navbar-nav navbar-dark navbar-right sbc-burger">
@@ -61,11 +62,11 @@
<table class="sbc-item-list">
<thead>
<tr>
<th class="width10pc">@Localiser["label.schema"]</th>
<th class="width20pc">@Localiser["label.table"]</th>
<th class="width20pc">@Localiser["label.column"]</th>
<th class="width20pc">@Localiser["label.index"]</th>
<th class="width25pc">@Localiser["label.comment"]</th>
<th class="width5pc">@Localiser["label.schema"]</th>
<th class="width15pc">@Localiser["label.table"]</th>
<th class="width15pc">@Localiser["label.column"]</th>
<th class="width15pc">@Localiser["label.index"]</th>
<th class="width50pc">@Localiser["label.comment"]</th>
<th class="width5pc"></th>
</tr>
<tr><td colspan="6"><div class="sbc-panel-messages"></div></td></tr>
@@ -102,7 +103,7 @@
</tr>
</table>
@* Item Burger option template - ul is ignored *@
<ul class="sbc-dropdown-menu Schema">
<ul class="sbc-dropdown-menu SchemaItem">
<li class="sbc-dropdown-item sbc-action"><div class="sbc-label">XXX</div></li>
</ul>
</div>
@@ -22,7 +22,7 @@
<div class="fixed">
@* <partial name="~/Views/Common/ResultsPaging.cshtml" /> *@
</div>
<div class="col center"><div class="sbc-panel-caption">@Localiser["caption.database.core"]</div></div>
<div class="col center"><div class="sbc-panel-caption">@Localiser["caption.repository.database"]</div></div>
<div class="fixed">
@* Burger menu *@
<ul class="nav navbar-nav navbar-dark navbar-right sbc-burger">
@@ -41,13 +41,13 @@
<div class="col-sm-4 row pb4">
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.context"]</div>
<div class="col-sm-7">
@Html.DropDownListFor(model => model.Filter.Context, Model.GetInstanceContextsForSelect(), "", new { @id = "", @class = "FilterContext" })
@Html.DropDownListFor(model => model.DatabaseFilter.Context, Model.GetInstanceContextsForSelect(), "", new { @id = "", @class = "FilterContext" })
</div>
</div>
<div class="col-sm-4 row pb4">
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
<div class="col-sm-7">
@Html.TextBoxFor(model => model.Filter.Search, new { @id = "", @class = "FilterSearch", @maxlength = "32" })
@Html.TextBoxFor(model => model.DatabaseFilter.Search, new { @id = "", @class = "FilterSearch", @maxlength = "32" })
</div>
</div>
</div>
@@ -20,7 +20,7 @@
<label for="ifEmailAddress"><span><span class="required">*</span> @Localiser["label.email.address"]</span></label>
</div>
<div class="sbc-control">
@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" })
</div>
<div class="sbc-message"></div>
</div>
@@ -21,7 +21,7 @@
<label for="ifEmailAddress"><span><span class="required">*</span> @Localiser["label.email.address"]</span></label>
</div>
<div class="sbc-control">
@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) })
</div>
<div class="sbc-message"></div>
</div>
@@ -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"
}
}
}
@@ -24,7 +24,7 @@
"RootFolder": "C:\\Sarand\\BusinessMgr\\Docs"
},
"Logging": {
"RootFolder": "C:\\Sarand\\BusinessMgr\\Log\\WebControl"
"RootFolder": "C:\\Sarand\\BusinessMgr\\Log"
}
}
}
@@ -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%;
@@ -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');
@@ -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($('<div class="sbc-message">' + sbc.msg.dataQuerying + '</div>')).fadeIn(200);
env.$pnl.bgr.invisible();
rs.clearItems(env);
env.$pnl.msgs.hide().empty().append($('<div class="sbc-message">' + sbc.msg.dataQuerying + '</div>')).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($('<div class="sbc-message">' + sbc.msg.dbSchemaValid + '</div>')).fadeIn(500);
return env.$pnl.msgs.append($('<div class="sbc-message">' + sbc.msg.dbSchemaValid + '</div>')).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);
});
//--------------------------------------------------------------
@@ -513,8 +513,8 @@
<data name="label.phone" xml:space="preserve">
<value>Phone</value>
</data>
<data name="label.sales.price" xml:space="preserve">
<value>Sales price</value>
<data name="label.sale.price" xml:space="preserve">
<value>Sale price</value>
</data>
<data name="label.cost.price" xml:space="preserve">
<value>Cost price</value>
@@ -744,4 +744,13 @@
<data name="label.strength" xml:space="preserve">
<value>Strength</value>
</data>
<data name="label.unit" xml:space="preserve">
<value>Unit</value>
</data>
<data name="label.price" xml:space="preserve">
<value>Price</value>
</data>
<data name="label.tax" xml:space="preserve">
<value>Tax</value>
</data>
</root>
@@ -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.
@@ -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<SbmRepositoryPopulationData.CommodityData>() { 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<SbmRepositoryPopulationData.CommodityData>()
{
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<SaUomType, SaUnitMeasure> 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).";
@@ -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<CommodityDataGroup> dataGroups = null)
private void PopulateCommodityResponseItemData(SbmCommodity commodity, CommodityItemData data, HashSet<CommodityDataGroup> 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<CodeDesc> CommodityTypes { get; } = new List<CodeDesc>();
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
public List<ItemCodeDesc> CommodityTypes { get; } = new List<ItemCodeDesc>();
public List<TaxCode> TaxCodes { get; } = new List<TaxCode>();
public String taxCodeDefault { get; set; }
public List<ItemCodeDesc> UomCats { get; } = new List<ItemCodeDesc>();
public List<ItemCodeDesc> UomTypes { get; } = new List<ItemCodeDesc>();
public String uomTypeDefault { get; set; }
public List<UomData> Uoms { get; set; } = new List<UomData>();
public List<ItemCodeDesc> Statuses { get; } = new List<ItemCodeDesc>();
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<TypeCodeDesc> uomCategories = SbmSystem.GetSystemCodes(Sbm.SystemCode.UnitMeasureCategory);
List<TypeCodeDesc> 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);
@@ -71,15 +71,14 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities
SalesPrice,
/// <summary>Formatted sales price - for list only.</summary>
SalesPriceFmt,
SalesTaxCode,
/// <summary>Unit of sale - caption for list & name of form control.</summary>
SalesUnit,
SalesPackQty,
MinOrderQty,
RetailPrice,
RetailPricePlanned,
TaxCodeId,
CarriageCostIndicative,
UomIdSale,
/// <summary>Unit of sale caption - for list only.</summary>
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.
@@ -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<CommodityController.CommodityDataGroup> 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;
@@ -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" })
}
<div id="dlgCommodity" class="sbm-dialog" title="">
@@ -24,10 +25,35 @@
@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" })
<div class="spacer2"></div>
<div class="row">
<div class="col-6">
@* Commodity Code *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.Code)">
<div class="row">
<div class="col-sm-4">
<div class="sbm-label">
<label for="ifCommodityCode"><span>@Localiser["label.code"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Commodity.Code", "", new { @id = "ifCommodityCode", @class = "CommodityCode sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_Code) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-6">
@* Commodity Type *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.Type)">
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-3">
<div class="sbm-label">
<label for="cbCommodityType"><span>@Localiser["label.type"]</span><span class="required">&nbsp;*</span></label>
@@ -42,27 +68,13 @@
</div>
</div>
@* Commodity Code *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.Code)">
<div class="row">
<div class="col-sm-3">
<div class="sbm-label">
<label for="ifCommodityCode"><span>@Localiser["label.code"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Commodity.Code", "", new { @id = "ifCommodityCode", @class = "CommodityCode sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Commodity_Code) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
@* Commodity Description *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.DescBrief)">
<div class="row">
<div class="col-sm-3">
<div class="col-sm-2">
<div class="sbm-label">
<label for="ifCommodityDesc"><span>@Localiser["label.description"]</span><span class="required">&nbsp;*</span></label>
</div>
@@ -76,10 +88,106 @@
</div>
</div>
<div class="row">
<div class="col-sm-6">
@* Sales Price *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.SalesPrice)">
<div class="row">
<div class="col-sm-4">
<div class="sbm-label">
<label for="ifCommoditySalesPrice"><span>@Localiser["label.price"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Commodity.SalesPrice", "", new { @id = "ifCommoditySalesPrice", @class = "CommoditySalesPrice sbm-input right sbm-auto-val sbm-format-currency", @maxlength = 12 })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Sales Unit *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.SalesUnit)">
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-3">
<div class="sbm-label">
<label for="ifCommoditySalesUnit"><span>@Localiser["label.unit"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
<div class="row">
<div class="col-5">
<select id="" class="CommoditySalesUnitCategory sbm-select" name=""></select>
</div>
<div class="col-7">
<select id="" class="CommoditySalesUnitType sbm-select" name="Commodity.SalesUnitType"></select>
</div>
</div>
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
@* Sales Tax *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.SalesTaxCode)">
<div class="row">
<div class="col-sm-4">
<div class="sbm-label">
<label for="ifCommoditySalesTax"><span>@Localiser["label.tax"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
<select id="" class="CommoditySalesTaxCode sbm-select sbm-auto-val" name="Commodity.SalesTaxCode"></select>
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Sales Unit *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.SalesPackQty)">
@Html.Hidden("Commodity.SalesUomId")
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-3">
<div class="sbm-label">
<label for="ifCommoditySalesUnit"><span>@Localiser["label.pack.quantity"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Commodity.SalesPackQty", "", new { @id = "ifCommoditySalesPackQty", @class = "CommoditySalesPackQty sbm-input right sbm-auto-val sbm-format-integer", @maxlength = 5 })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
</div>
@* Commodity status *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.Status)">
<div class="row">
<div class="col-sm-3">
<div class="col-sm-2">
<div class="sbm-label">
<label for="cbCommodityStatus"><span>@Localiser["label.status"]</span><span class="required">&nbsp;*</span></label>
</div>
@@ -96,7 +204,7 @@
@* Commodity Notes *@
<div class="sbm-form-control @Model_Commodity.GetFieldName(Model_Commodity.ItemField.Notes)">
<div class="row">
<div class="col-sm-3">
<div class="col-sm-2">
<div class="sbm-label">
<label for="ifCommodityNotes"><span>@Localiser["label.notes"]</span></label>
</div>
@@ -16,8 +16,8 @@
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.Type) width5pc center">@Localiser["label.type"]</th>
@if (Model.UserCanViewCommodityFinancials_Sales())
{
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.SalesPriceFmt) width5pc right">@Localiser["label.sales.price"]</th>
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.SalesUnit) width5pc center">@Localiser["label.unit.of.sale"]</th>
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.SalesPriceFmt) width5pc right">@Localiser["label.price"]</th>
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.SalesUnit) width5pc center">@Localiser["label.unit"]</th>
}
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.Notes) width25pc d-none d-md-table-cell">@Localiser["label.notes"]</th>
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.Status) width5pc center">@Localiser["label.status"]</th>
@@ -63,6 +63,7 @@
<partial name="Panel-CommodityList.cshtml" />
</div>
</div>
<partial name="Panel-CommodityDialog.cshtml" />
<partial name="Panel-CommodityDialog.cshtml" />
</div>
@@ -32,7 +32,7 @@
</div>
<div class="col-sm">
<div class="sbm-control">
@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) })
</div>
<div class="sbm-message"></div>
</div>
@@ -24,7 +24,7 @@
<label for="ifEmailAddress"><span>@Localiser["label.email"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sbm-control">
@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) })
</div>
<div class="sbm-message"></div>
</div>
@@ -31,7 +31,7 @@
<label for="ifEmailAddress"><span>@Localiser["label.email"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sbm-control">
@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" })
</div>
<div class="sbm-message"></div>
</div>
@@ -34,7 +34,7 @@
<label for="ifEmailAddress"><span>@Localiser["label.email"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sbm-control">
@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) })
</div>
<div class="sbm-message"></div>
</div>
@@ -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);
@@ -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"
}
}
}
@@ -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"
}
}
}
@@ -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;
@@ -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;
}
@@ -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.