diff --git a/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs b/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs index 559868e..62b2950 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs @@ -217,7 +217,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App itemTypes.Add(Sbm.ItemType.Interface, "Interface", "Interface"); //--------------------------------------------------------------- - // A s s o c i a t i o n s + // Accounts. //--------------------------------------------------------------- // Affiliate Type. affiliateTypes.Add(Sbm.AffiliateType.Individual, "IND", "Individual"); @@ -238,7 +238,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App associationTypes.Add(Sbm.AssociationType.FinanceAgency, "FIN", "Finance agency"); //--------------------------------------------------------------- - // T r a n s a c t i o n s + // Transactions. //--------------------------------------------------------------- // Transaction StatusCat. transactionStatusCats.Add(SbmTransaction.StatusCat.Pending, "PEN", "Pending"); diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs b/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs index 0e61427..88f22dc 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs @@ -455,6 +455,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus return IsContactGroup(AffiliateType); } + /// Most significant phone number. + public String GetPhone() + { + return StringUtil.OnBlank(PhoneMain, PhoneAlt, PhoneMobile, PhoneDirect); + } + // Email validation. public static bool IsValidEmail(String email) { diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs index f81214f..f49bcc1 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs @@ -280,10 +280,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbAffiliate._Website = affiliate.Website; // Ogranisation. dbAffiliate._AffIdParent = affiliate.AffiliateIdParent.ToInt(); - if (!affiliate.IsIndividual()) - dbAffiliate._Name = affiliate.Name; - else - dbAffiliate._Name = affiliate.GetDisplayName(); + if (affiliate.IsIndividual()) + affiliate.Name = affiliate.GetDisplayName(); + dbAffiliate._Name = affiliate.Name; dbAffiliate._Abbrev = affiliate.Abbr; dbAffiliate._Nature = affiliate.Nature; dbAffiliate._Contact = affiliate.Contact; @@ -293,8 +292,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Individual. dbAffiliate._Title = affiliate.Title; dbAffiliate._Initials = affiliate.Initials; - if (affiliate.AffiliateType == Sbm.AffiliateType.Individual) - dbAffiliate._Name = affiliate.GetDisplayName(); dbAffiliate._FirstName = affiliate.FirstName; dbAffiliate._LastName = affiliate.LastName; dbAffiliate._Salutation = affiliate.Salutation; @@ -548,7 +545,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colAffiliate_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Id, aliasAffiliate); if (prm.IdsIncluded.HasValidIds()) filter.Add($"{colAffiliate_Id} IN ({prm.IdsIncluded.Concat(",")})"); - if (prm.IdsExcluded.HasValidIds() ) + if (prm.IdsExcluded.HasValidIds()) filter.Add($"{colAffiliate_Id} NOT IN ({prm.IdsExcluded.Concat(",")})"); // Type. @@ -832,6 +829,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Default sort columns: sortColumnNames.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Type, aliasAffiliate) + " ASC"); + sortColumnNames.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Name, aliasAffiliate) + " ASC"); } return sortColumnNames; } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs index 336a3a4..5c90b0a 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs @@ -1321,30 +1321,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Association Id. String colAssociation_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, aliasAssociation); - String includedIds = prm.IdsIncluded.Concat(","); - if (!includedIds.IsEmpty()) - filter.Add(colAssociation_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.IdsExcluded.Concat(","); - if (!excludedIds.IsEmpty()) - filter.Add(colAssociation_Id + " NOT IN (" + excludedIds + ")"); + if (prm.IdsIncluded.HasValidIds()) + filter.Add($"{colAssociation_Id} IN ({prm.IdsIncluded.Concat(",")})"); + if (prm.IdsExcluded.HasValidIds()) + filter.Add($"{colAssociation_Id} NOT IN ({prm.IdsExcluded.Concat(",")})"); // Association Type. String colAssociation_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type, aliasAssociation); if (prm.AssociationType > 0) - filter.Add(colAssociation_Type + "=" + ((int)prm.AssociationType).ToString()); + filter.Add($"{colAssociation_Type}={(int)prm.AssociationType}"); else if (prm.AssociationType == AssociationType.NotInternal) - filter.Add(colAssociation_Type + "!=" + ((int)Sbm.AssociationType.Internal).ToString()); + filter.Add($"{colAssociation_Type}!={(int)Sbm.AssociationType.Internal}"); //--------------------------------------------------------------- // Owner affiliate. String colAssociation_AffIdOwner = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner, aliasAssociation); if (SysId.IsValid(prm.AffiliateIdOwner)) - filter.Add(colAssociation_AffIdOwner + "=" + prm.AffiliateIdOwner.ToString()); + filter.Add($"{colAssociation_AffIdOwner}={prm.AffiliateIdOwner}"); // Target Affiliate. String colAssociation_AffIdTarget = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget, aliasAssociation); if (SysId.IsValid(prm.AffiliateIdTarget)) - filter.Add(colAssociation_AffIdTarget + "=" + prm.AffiliateIdTarget.ToString()); + filter.Add($"{colAssociation_AffIdTarget}={prm.AffiliateIdTarget}"); //--------------------------------------------------------------- // Contact Group. diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs index 32618cb..369893f 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs @@ -329,40 +329,38 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List(); // Param Id. - String includedIds = prm.IdsIncluded.Concat(","); String colSysParam_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SysParam_Id, aliasSysParam); - if (!includedIds.IsEmpty()) - filter.Add(colSysParam_Id + " IN (" + includedIds + ")"); - String excludedIds = prm.IdsExcluded.Concat(","); - if (!excludedIds.IsEmpty()) - filter.Add(colSysParam_Id + " NOT IN (" + excludedIds + ")"); + if (prm.IdsIncluded.HasValidIds()) + filter.Add($"{colSysParam_Id} IN ({prm.IdsIncluded.Concat(",")})"); + if (prm.IdsExcluded.HasValidIds() ) + filter.Add($"{colSysParam_Id} NOT IN ({prm.IdsExcluded.Concat(",")})"); // Category. String colSysParam_Cat = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SysParam_Cat, aliasSysParam); if (prm.Category > 0) - filter.Add(colSysParam_Cat + " = '" + ((int)prm.Category).ToString() + "'"); + filter.Add($"{colSysParam_Cat}={(int)prm.Category}"); // Name. String colSysParam_Name = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SysParam_Name, aliasSysParam); if (!StringUtil.IsEmpty(prm.Name)) - filter.Add(colSysParam_Name + " = '" + DbQuery.FormatForCondition(prm.Name) + "'"); - if (!StringUtil.IsEmpty(prm.NamePartial)) - filter.Add(colSysParam_Name + " LIKE '%" + DbQuery.FormatForLike(prm.NamePartial) + "%'"); + filter.Add($"{colSysParam_Name}='{DbQuery.FormatForCondition(prm.Name)}'"); + else if (!StringUtil.IsEmpty(prm.NamePartial)) + filter.Add($"{colSysParam_Name} LIKE '%{DbQuery.FormatForLike(prm.NamePartial)}%'"); // Affiliate Owner Id. String colSysParam_AffIdOwner = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SysParam_AffIdOwner, aliasSysParam); if (SysId.IsValid(prm.AffIdOwner)) - filter.Add(colSysParam_AffIdOwner + " = '" + DbQuery.FormatForCondition(SysId.ToString(prm.AffIdOwner)) + "'"); + filter.Add($"{colSysParam_AffIdOwner}={SysId.ToLong(prm.AffIdOwner)}"); // Affiliate Target Id. String colSysParam_AffIdTarget = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SysParam_AffIdTarget, aliasSysParam); if (SysId.IsValid(prm.AssocId)) - filter.Add(colSysParam_AffIdTarget + " = '" + DbQuery.FormatForCondition(SysId.ToString(prm.AssocId)) + "'"); + filter.Add($"{colSysParam_AffIdTarget}={SysId.ToLong(prm.AssocId)}"); // Association Id. String colSysParam_AssocId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SysParam_AssocId, aliasSysParam); if (SysId.IsValid(prm.AssocId)) - filter.Add(colSysParam_AssocId + " = '" + DbQuery.FormatForCondition(SysId.ToString(prm.AssocId)) + "'"); + filter.Add($"{colSysParam_AssocId}={SysId.ToLong(prm.AssocId)}"); // Common Properties /* Notes. diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleClass.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleClass.cs index 183cf3d..60fd514 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleClass.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleClass.cs @@ -196,7 +196,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert VehicleClass. public override bool InsertVehicleClass(SbmVehicleClass vehicleClass, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertVehicleClass"; ClearErrorState(); if (!IsValidVehicleClass(vehicleClass)) return false; if (SysId.IsValid(vehicleClass.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -216,7 +215,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbVehicleClass.ExecuteInsertCommand(dbCommand); vehicleClass.Id = new SysId(dbVehicleClass._Id); vehicleClass.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Insert. " + GetLogProperties(vehicleClass).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Insert. " + GetLogProperties(vehicleClass).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -227,13 +226,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update VehicleClass. public override bool UpdateVehicleClass(SbmVehicleClass vehicleClass, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateVehicleClass"; ClearErrorState(); if (!IsValidVehicleClass(vehicleClass)) return false; if (!SysId.IsValid(vehicleClass.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!vehicleClass.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(vehicleClass).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(vehicleClass).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -251,7 +249,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbVehicleClass, vehicleClass, dbUpdateInfo); dbVehicleClass.ExecuteUpdateCommand(dbCommand); vehicleClass.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(vehicleClass).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(vehicleClass).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(vehicleClass); @@ -272,7 +270,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteVehicleClass(SbmVehicleClass vehicleClass, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteVehicleClass"; ClearErrorState(); if (!VehicleClassCanBeDeleted(vehicleClass)) return false; using (var dbConnection = db.CreateConnection()) @@ -289,7 +286,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass) + " WHERE Id=" + SysId.ToString(vehicleClass.Id) + ";"; dbCommand.ExecuteNonQuery(); vehicleClass.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Delete. " + GetLogProperties(vehicleClass).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Delete. " + GetLogProperties(vehicleClass).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -549,12 +546,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filter.Add($"{colModel} Like '{DbQuery.FormatForLike(prm.ModelPartial)}'"); // Description. - String descBrief = DbQuery.FormatForCondition(prm.DescBrief); - String descBriefPartial = DbQuery.FormatForCondition(prm.DescBriefPartial); - if (!StringUtil.IsBlank(descBrief)) - filter.Add(colDescBrief + "='" + descBrief + "'"); - else if (!StringUtil.IsBlank(descBriefPartial)) - filter.Add(DbQuery.FormatFn_Left(colDescBrief, prm.DescBriefPartial.Length) + "='" + descBriefPartial + "'"); + if (!StringUtil.IsBlank(prm.DescBrief)) + filter.Add($"{colDescBrief}='{DbQuery.FormatForCondition(prm.DescBrief)}'"); + else if (!StringUtil.IsBlank(prm.DescBriefPartial)) + filter.Add($"{colDescBrief} LIKE '%{DbQuery.FormatForLike(prm.DescBriefPartial)}%'"); // Vehicle Category code. String colVehicleClass_VehicleCategoryCode = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_VehicleCategoryCode, aliasVehicleClass); diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs index 8414ca9..542df7f 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs @@ -105,7 +105,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert VehicleEvent. public override bool InsertVehicleEvent(SbmVehicleEvent vehicleEvent, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertVehicleEvent"; ClearErrorState(); if (!IsValidVehicleEvent(vehicleEvent)) return false; if (SysId.IsValid(vehicleEvent.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -125,7 +124,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbVehicleEvent.ExecuteInsertCommand(dbCommand); vehicleEvent.Id = new SysId(dbVehicleEvent._Id); vehicleEvent.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(vehicleEvent).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(vehicleEvent).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -136,13 +135,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update VehicleEvent. public override bool UpdateVehicleEvent(SbmVehicleEvent vehicleEvent, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateVehicleEvent"; ClearErrorState(); if (!IsValidVehicleEvent(vehicleEvent)) return false; if (!SysId.IsValid(vehicleEvent.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!vehicleEvent.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(vehicleEvent).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(vehicleEvent).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -160,7 +158,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbVehicleEvent, vehicleEvent, dbUpdateInfo); dbVehicleEvent.ExecuteUpdateCommand(dbCommand); vehicleEvent.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(vehicleEvent).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(vehicleEvent).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(vehicleEvent); @@ -181,7 +179,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteVehicleEvent(SbmVehicleEvent vehicleEvent, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteVehicleEvent"; ClearErrorState(); if (!VehicleEventCanBeDeleted(vehicleEvent)) return false; using (var dbConnection = db.CreateConnection()) @@ -198,7 +195,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent) + " WHERE Id=" + SysId.ToString(vehicleEvent.Id) + ";"; dbCommand.ExecuteNonQuery(); vehicleEvent.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(vehicleEvent).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(vehicleEvent).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs index 68b6709..12d5e5c 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs @@ -204,7 +204,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert VehicleFeature. public override bool InsertVehicleFeature(SbmVehicleFeature vehicleFeature, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertVehicleFeature"; ClearErrorState(); if (!IsValidVehicleFeature(vehicleFeature)) return false; if (SysId.IsValid(vehicleFeature.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -224,7 +223,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbVehicleFeature.ExecuteInsertCommand(dbCommand); vehicleFeature.Id = new SysId(dbVehicleFeature._VehicleId); vehicleFeature.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(vehicleFeature).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(vehicleFeature).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -235,13 +234,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update VehicleFeature. public override bool UpdateVehicleFeature(SbmVehicleFeature vehicleFeature, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateVehicleFeature"; ClearErrorState(); if (!IsValidVehicleFeature(vehicleFeature)) return false; if (!SysId.IsValid(vehicleFeature.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!vehicleFeature.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(vehicleFeature).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(vehicleFeature).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -259,7 +257,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbVehicleFeature, vehicleFeature, dbUpdateInfo); dbVehicleFeature.ExecuteUpdateCommand(dbCommand); vehicleFeature.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(vehicleFeature).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(vehicleFeature).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(vehicleFeature); @@ -280,7 +278,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteVehicleFeature(SbmVehicleFeature vehicleFeature, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteVehicleFeature"; ClearErrorState(); if (!VehicleFeatureCanBeDeleted(vehicleFeature)) return false; using (var dbConnection = db.CreateConnection()) @@ -297,7 +294,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature) + " WHERE Id=" + SysId.ToString(vehicleFeature.Id) + ";"; dbCommand.ExecuteNonQuery(); vehicleFeature.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(vehicleFeature).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(vehicleFeature).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs index 86287d4..605d2db 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs @@ -624,7 +624,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert Commodity. public override bool InsertCommodity(SbmCommodity commodity, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertCommodity"; ClearErrorState(); if (!IsValidCommodity(commodity)) return false; if (SysId.IsValid(commodity.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -644,7 +643,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommodity.ExecuteInsertCommand(dbCommand); commodity.Id = new SysId(dbCommodity._Id); commodity.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(commodity).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(commodity).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -655,13 +654,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update Commodity. public override bool UpdateCommodity(SbmCommodity commodity, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateCommodity"; ClearErrorState(); if (!IsValidCommodity(commodity)) return false; if (!SysId.IsValid(commodity.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!commodity.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(commodity).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(commodity).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -679,7 +677,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbCommodity, commodity, dbUpdateInfo); dbCommodity.ExecuteUpdateCommand(dbCommand); commodity.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(commodity).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(commodity).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(commodity); @@ -700,7 +698,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteCommodity(SbmCommodity commodity, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteCommodity"; ClearErrorState(); if (!CommodityCanBeDeleted(commodity)) return false; using (var dbConnection = db.CreateConnection()) @@ -717,7 +714,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity) + " WHERE Id=" + SysId.ToString(commodity.Id) + ";"; dbCommand.ExecuteNonQuery(); commodity.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(commodity).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(commodity).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -2281,7 +2278,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Commodity query filter. public override List GetCommodityQueryFilter(SbmCommodity.Params prm) { - String fn = GetType().Name + ".GetCommodityQueryFilter"; List filter = new List(); //--------------------------------------------------------------- @@ -2598,7 +2594,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Id, aliasCommodity) + " IN (" + qryCmdCust.BuildQuery() + ")"); } - else SaLogger.Error(fn + " CmdCust filter specified and CmdCust management not allowed"); + else SaLogger.Error($"{SysUtil.Fn} CmdCust filter specified and CmdCust management not allowed"); } //--------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs index 1b79908..71e7783 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs @@ -210,7 +210,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert CommodityCustomer. public override bool InsertCommodityCustomer(SbmCommodityCustomer commodityCustomer, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertCommodityCustomer"; ClearErrorState(); if (!IsValidCommodityCustomer(commodityCustomer)) return false; if (SysId.IsValid(commodityCustomer.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -230,7 +229,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommodityCustomer.ExecuteInsertCommand(dbCommand); commodityCustomer.Id = new SysId(dbCommodityCustomer._CommodityId); commodityCustomer.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(commodityCustomer).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(commodityCustomer).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -241,13 +240,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update CommodityCustomer. public override bool UpdateCommodityCustomer(SbmCommodityCustomer commodityCustomer, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateCommodityCustomer"; ClearErrorState(); if (!IsValidCommodityCustomer(commodityCustomer)) return false; if (!SysId.IsValid(commodityCustomer.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!commodityCustomer.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(commodityCustomer).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(commodityCustomer).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -265,7 +263,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbCommodityCustomer, commodityCustomer, dbUpdateInfo); dbCommodityCustomer.ExecuteUpdateCommand(dbCommand); commodityCustomer.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(commodityCustomer).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(commodityCustomer).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(commodityCustomer); @@ -286,7 +284,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteCommodityCustomer(SbmCommodityCustomer commodityCustomer, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteCommodityCustomer"; ClearErrorState(); if (!CommodityCustomerCanBeDeleted(commodityCustomer)) return false; using (var dbConnection = db.CreateConnection()) @@ -303,7 +300,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer) + " WHERE Id=" + SysId.ToString(commodityCustomer.Id) + ";"; dbCommand.ExecuteNonQuery(); commodityCustomer.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(commodityCustomer).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(commodityCustomer).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs index 4de6a87..d2439fb 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs @@ -125,7 +125,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert CommoditySupplier. public override bool InsertCommoditySupplier(SbmCommoditySupplier commoditySupplier, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertCommoditySupplier"; ClearErrorState(); if (!IsValidCommoditySupplier(commoditySupplier)) return false; if (SysId.IsValid(commoditySupplier.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -145,7 +144,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommoditySupplier.ExecuteInsertCommand(dbCommand); commoditySupplier.Id = new SysId(dbCommoditySupplier._CommodityId); commoditySupplier.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(commoditySupplier).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(commoditySupplier).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -156,13 +155,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update CommoditySupplier. public override bool UpdateCommoditySupplier(SbmCommoditySupplier commoditySupplier, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateCommoditySupplier"; ClearErrorState(); if (!IsValidCommoditySupplier(commoditySupplier)) return false; if (!SysId.IsValid(commoditySupplier.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!commoditySupplier.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(commoditySupplier).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(commoditySupplier).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -180,7 +178,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbCommoditySupplier, commoditySupplier, dbUpdateInfo); dbCommoditySupplier.ExecuteUpdateCommand(dbCommand); commoditySupplier.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(commoditySupplier).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(commoditySupplier).Concat(": ").Concat("", "\n\t")); /* Record updates. updateLogMonitor.RecordUpdatedValues(commoditySupplier); @@ -201,7 +199,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteCommoditySupplier(SbmCommoditySupplier commoditySupplier, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteCommoditySupplier"; ClearErrorState(); if (!CommoditySupplierCanBeDeleted(commoditySupplier)) return false; using (var dbConnection = db.CreateConnection()) @@ -218,7 +215,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier) + " WHERE Id=" + SysId.ToString(commoditySupplier.Id) + ";"; dbCommand.ExecuteNonQuery(); commoditySupplier.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(commoditySupplier).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(commoditySupplier).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs index a0cc1f6..d65792e 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs @@ -100,7 +100,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert Container. public override bool InsertContainer(SbmContainer container, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertContainer"; ClearErrorState(); if (!IsValidContainer(container)) return false; if (SysId.IsValid(container.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -120,7 +119,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbContainer.ExecuteInsertCommand(dbCommand); container.Id = new SysId(dbContainer._Id); container.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(container).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(container).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -131,13 +130,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update Container. public override bool UpdateContainer(SbmContainer container, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateContainer"; ClearErrorState(); if (!IsValidContainer(container)) return false; if (!SysId.IsValid(container.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!container.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(container).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(container).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -155,7 +153,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbContainer, container, dbUpdateInfo); dbContainer.ExecuteUpdateCommand(dbCommand); container.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(container).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(container).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(container); @@ -176,7 +174,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteContainer(SbmContainer container, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteContainer"; ClearErrorState(); if (!ContainerCanBeDeleted(container)) return false; using (var dbConnection = db.CreateConnection()) @@ -193,7 +190,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container) + " WHERE Id=" + SysId.ToString(container.Id) + ";"; dbCommand.ExecuteNonQuery(); container.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(container).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(container).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs index 1325b9e..d2ba6c8 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs @@ -136,7 +136,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert ContainerItem. public override bool InsertContainerItem(SbmContainerItem containerItem, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertContainerItem"; ClearErrorState(); if (!IsValidContainerItem(containerItem)) return false; if (SysId.IsValid(containerItem.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -156,7 +155,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbContainerItem.ExecuteInsertCommand(dbCommand); containerItem.Id = new SysId(dbContainerItem._ContainerId); containerItem.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(containerItem).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(containerItem).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -167,13 +166,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update ContainerItem. public override bool UpdateContainerItem(SbmContainerItem containerItem, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateContainerItem"; ClearErrorState(); if (!IsValidContainerItem(containerItem)) return false; if (!SysId.IsValid(containerItem.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!containerItem.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(containerItem).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(containerItem).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -191,7 +189,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbContainerItem, containerItem, dbUpdateInfo); dbContainerItem.ExecuteUpdateCommand(dbCommand); containerItem.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(containerItem).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(containerItem).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(containerItem); @@ -212,7 +210,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteContainerItem(SbmContainerItem containerItem, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteContainerItem"; ClearErrorState(); if (!ContainerItemCanBeDeleted(containerItem)) return false; using (var dbConnection = db.CreateConnection()) @@ -229,7 +226,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem) + " WHERE Id=" + SysId.ToString(containerItem.Id) + ";"; dbCommand.ExecuteNonQuery(); containerItem.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(containerItem).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(containerItem).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs index 885383e..c9be84f 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs @@ -295,7 +295,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert PortfolioItem. public override bool InsertPortfolioItem(SbmPortfolioItem portfolioItem, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".AddPortfolioItem"; ClearErrorState(); if (!IsValidPortfolioItem(portfolioItem)) return false; if (SysId.IsValid(portfolioItem.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -315,7 +314,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbPortfolioItem.ExecuteInsertCommand(dbCommand); portfolioItem.Id = new SysId(dbPortfolioItem._Id); portfolioItem.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(portfolioItem).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(portfolioItem).Concat(": ").Concat("", "\n\t")); // Move other items for same parent down sequence. ResequenceSubsequentItems(portfolioItem); @@ -329,13 +328,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update PortfolioItem. public override bool UpdatePortfolioItem(SbmPortfolioItem portfolioItem, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdatePortfolioItem"; ClearErrorState(); if (!IsValidPortfolioItem(portfolioItem)) return false; if (!SysId.IsValid(portfolioItem.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!portfolioItem.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(portfolioItem).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(portfolioItem).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -353,7 +351,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbPortfolioItem, portfolioItem, dbUpdateInfo); dbPortfolioItem.ExecuteUpdateCommand(dbCommand); portfolioItem.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(portfolioItem).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(portfolioItem).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(portfolioItem); @@ -509,7 +507,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeletePortfolioItem(SbmPortfolioItem portfolioItem, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeletePortfolioItem"; ClearErrorState(); if (!PortfolioItemCanBeDeleted(portfolioItem)) return false; using (var dbConnection = db.CreateConnection()) @@ -526,7 +523,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem) + " WHERE Id=" + SysId.ToString(portfolioItem.Id) + ";"; dbCommand.ExecuteNonQuery(); portfolioItem.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(portfolioItem).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(portfolioItem).Concat(": ").Concat("", "\n\t")); // Move other items for same parent down sequence. ResequenceSubsequentItems(portfolioItem); diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs index 4262113..2377b2e 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs @@ -105,7 +105,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert ItemBatch. public override bool InsertItemBatch(SbmItemBatch itemBatch, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertItemBatch"; ClearErrorState(); if (!IsValidItemBatch(itemBatch)) return false; if (SysId.IsValid(itemBatch.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -125,7 +124,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbItemBatch.ExecuteInsertCommand(dbCommand); itemBatch.Id = new SysId(dbItemBatch._Id); itemBatch.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(itemBatch).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(itemBatch).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -136,13 +135,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update ItemBatch. public override bool UpdateItemBatch(SbmItemBatch itemBatch, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateItemBatch"; ClearErrorState(); if (!IsValidItemBatch(itemBatch)) return false; if (!SysId.IsValid(itemBatch.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!itemBatch.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(itemBatch).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(itemBatch).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -160,7 +158,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbItemBatch, itemBatch, dbUpdateInfo); dbItemBatch.ExecuteUpdateCommand(dbCommand); itemBatch.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(itemBatch).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(itemBatch).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(itemBatch); @@ -181,7 +179,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteItemBatch(SbmItemBatch itemBatch, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteXXX"; ClearErrorState(); if (!ItemBatchCanBeDeleted(itemBatch)) return false; using (var dbConnection = db.CreateConnection()) @@ -198,7 +195,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemBatch) + " WHERE Id=" + SysId.ToString(itemBatch.Id) + ";"; dbCommand.ExecuteNonQuery(); itemBatch.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(itemBatch).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(itemBatch).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs index 94477f1..b747b14 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs @@ -109,7 +109,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert Item. public override bool InsertItemLink(SbmItemLink itemLink, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertItemLink"; ClearErrorState(); if (!IsValidItemLink(itemLink)) return false; if (SysId.IsValid(itemLink.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -129,7 +128,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbItemLink.ExecuteInsertCommand(dbCommand); itemLink.Id = new SysId(0); itemLink.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(itemLink).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(itemLink).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -140,13 +139,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update Item. public override bool UpdateItemLink(SbmItemLink itemLink, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateItemLink"; ClearErrorState(); if (!IsValidItemLink(itemLink)) return false; if (!SysId.IsValid(itemLink.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!itemLink.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(itemLink).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(itemLink).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -164,7 +162,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbItemLink, itemLink, dbUpdateInfo); dbItemLink.ExecuteUpdateCommand(dbCommand); itemLink.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(itemLink).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(itemLink).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(itemLink); @@ -298,7 +296,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteItemLink(SbmItemLink itemLink, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteItemLink"; ClearErrorState(); if (!ItemLinkCanBeDeleted(itemLink)) return false; using (var dbConnection = db.CreateConnection()) @@ -315,7 +312,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink) + " WHERE Id=" + SysId.ToString(itemLink.Id) + ";"; dbCommand.ExecuteNonQuery(); itemLink.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(itemLink).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(itemLink).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-Price.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-Price.cs index be7c479..530ee7d 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-Price.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-Price.cs @@ -98,7 +98,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert item. public override bool InsertPrice(SbmPrice price, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertPrice"; ClearErrorState(); if (!IsValidPrice(price)) return false; if (SysId.IsValid(price.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -113,7 +112,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // NB Prices don't have their own Ids. dbPrice.ExecuteInsertCommand(dbCommand); price.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted." + GetLogProperties(price).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted." + GetLogProperties(price).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -124,14 +123,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update item. public override bool UpdatePrice(SbmPrice price, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdatePrice"; ClearErrorState(); if (!IsValidPrice(price)) return false; if (!SysId.IsValid(price.PriceSetId)) return SetErrorState(ErrorMessage.InvalidItemId); if (!SysId.IsValid(price.CommodityId)) return SetErrorState(ErrorMessage.InvalidItemId); if (!price.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed." + GetLogProperties(price).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed." + GetLogProperties(price).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -149,7 +147,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbPrice, price, dbUpdateInfo); dbPrice.ExecuteUpdateCommand(dbCommand); price.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated." + GetLogProperties(price).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated." + GetLogProperties(price).Concat(": ").Concat("", "\n\t")); // Record updates. //updateLogMonitor.RecordUpdatedValues(price); @@ -170,7 +168,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeletePrice(SbmPrice price, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeletePrice"; ClearErrorState(); if (!PriceCanBeDeleted(price)) return false; using (var dbConnection = db.CreateConnection()) @@ -187,7 +184,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice) + " WHERE PriceSetId = " + SysId.ToString(price.PriceSetId) + " And CommodityId=" + SysId.ToString(price.CommodityId) + ";"; dbCommand.ExecuteNonQuery(); price.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted." + GetLogProperties(price).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted." + GetLogProperties(price).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs index 4782bdd..4481ec6 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs @@ -99,7 +99,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert item. public override bool InsertPriceSet(SbmPriceSet priceSet, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertPriceSet"; ClearErrorState(); if (!IsValidPriceSet(priceSet)) return false; if (SysId.IsValid(priceSet.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -119,7 +118,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbPriceSet.ExecuteInsertCommand(dbCommand); priceSet.Id = new SysId(dbPriceSet._Id); priceSet.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted." + GetLogProperties(priceSet).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted." + GetLogProperties(priceSet).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -130,13 +129,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update item. public override bool UpdatePriceSet(SbmPriceSet priceSet, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdatePriceSet"; ClearErrorState(); if (!IsValidPriceSet(priceSet)) return false; if (!SysId.IsValid(priceSet.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!priceSet.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed." + GetLogProperties(priceSet).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed." + GetLogProperties(priceSet).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -154,7 +152,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbPriceSet, priceSet, dbUpdateInfo); dbPriceSet.ExecuteUpdateCommand(dbCommand); priceSet.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated." + GetLogProperties(priceSet).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated." + GetLogProperties(priceSet).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(priceSet); @@ -175,7 +173,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeletePriceSet(SbmPriceSet priceSet, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeletePriceSet"; ClearErrorState(); if (!PriceSetCanBeDeleted(priceSet)) return false; using (var dbConnection = db.CreateConnection()) @@ -192,7 +189,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet) + " WHERE Id=" + SysId.ToString(priceSet.Id) + ";"; dbCommand.ExecuteNonQuery(); priceSet.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted." + GetLogProperties(priceSet).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted." + GetLogProperties(priceSet).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs index 3a1d11f..ae0baae 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs @@ -151,7 +151,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert Process. public override bool InsertProcess(SbmProcess process, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertProcess"; ClearErrorState(); if (!IsValidProcess(process)) return false; if (SysId.IsValid(process.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -171,7 +170,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbProcess.ExecuteInsertCommand(dbCommand); process.Id = new SysId(dbProcess._Id); process.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(process).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(process).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -182,13 +181,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update Process. public override bool UpdateProcess(SbmProcess process, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateProcess"; ClearErrorState(); if (!IsValidProcess(process)) return false; if (!SysId.IsValid(process.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!process.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(process).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(process).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -206,7 +204,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbProcess, process, dbUpdateInfo); dbProcess.ExecuteUpdateCommand(dbCommand); process.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(process).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(process).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(process); @@ -227,7 +225,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteProcess(SbmProcess process, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteProcess"; ClearErrorState(); if (!ProcessCanBeDeleted(process)) return false; using (var dbConnection = db.CreateConnection()) @@ -244,7 +241,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process) + " WHERE Id=" + SysId.ToString(process.Id) + ";"; dbCommand.ExecuteNonQuery(); process.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(process).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(process).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs index ec02df5..4737556 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs @@ -100,7 +100,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert Location. public override bool InsertLocation(SbmLocation location, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertLocation"; ClearErrorState(); if (!IsValidLocation(location)) return false; if (SysId.IsValid(location.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -120,7 +119,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbLocation.ExecuteInsertCommand(dbCommand); location.Id = new SysId(dbLocation._Id); location.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(location).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(location).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -131,13 +130,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update Location. public override bool UpdateLocation(SbmLocation location, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateLocation"; ClearErrorState(); if (!IsValidLocation(location)) return false; if (!SysId.IsValid(location.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!location.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(location).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(location).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -155,7 +153,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbLocation, location, dbUpdateInfo); dbLocation.ExecuteUpdateCommand(dbCommand); location.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(location).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(location).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(location); @@ -176,7 +174,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteLocation(SbmLocation location, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteLocation"; ClearErrorState(); if (!LocationCanBeDeleted(location)) return false; using (var dbConnection = db.CreateConnection()) @@ -193,7 +190,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location) + " WHERE Id=" + SysId.ToString(location.Id) + ";"; dbCommand.ExecuteNonQuery(); location.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(location).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(location).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs index d5c1449..a3fe06c 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs @@ -221,7 +221,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert Movement. public override bool InsertMovement(SbmMovement movement, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertMovement"; ClearErrorState(); if (!IsValidMovement(movement)) return false; if (SysId.IsValid(movement.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -241,7 +240,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbMovement.ExecuteInsertCommand(dbCommand); movement.Id = new SysId(dbMovement._Id); movement.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(movement).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(movement).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -252,13 +251,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update Movement. public override bool UpdateMovement(SbmMovement movement, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateMovement"; ClearErrorState(); if (!IsValidMovement(movement)) return false; if (!SysId.IsValid(movement.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!movement.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(movement).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(movement).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -276,7 +274,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbMovement, movement, dbUpdateInfo); dbMovement.ExecuteUpdateCommand(dbCommand); movement.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(movement).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(movement).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(movement); @@ -297,7 +295,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteMovement(SbmMovement movement, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteMovement"; ClearErrorState(); if (!MovementCanBeDeleted(movement)) return false; using (var dbConnection = db.CreateConnection()) @@ -314,7 +311,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement) + " WHERE Id=" + SysId.ToString(movement.Id) + ";"; dbCommand.ExecuteNonQuery(); movement.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(movement).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(movement).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs index 35b38c2..9ec6e18 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs @@ -153,7 +153,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr /// Get the list of time records recorded for the specified parameters. public override List GetPeriodTimeBooked(SysId affiliateIdEmployee, DateTime periodStart, DateTime periodEnd, SaUomType uomPeriod) { - String fn = GetType().Name + ".GetPeriodTimeBooked"; ClearErrorState(); List dataItems = new List(); if (!SysId.IsValid(affiliateIdEmployee)) @@ -181,7 +180,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr break; default: #if DEBUG - SaLogger.Warn(fn + " Period unit defaulted to working week."); + SaLogger.Warn($"{SysUtil.Fn} Period unit defaulted to working week."); #endif uomPeriod = SaUomType.Time_WorkingWeek; break; @@ -369,7 +368,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert Constituent. public override bool InsertConstituent(SbmConstituent constituent, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertConstituent"; ClearErrorState(); if (!IsValidConstituent(constituent)) return false; if (SysId.IsValid(constituent.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -389,7 +387,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbConstituent.ExecuteInsertCommand(dbCommand); constituent.Id = new SysId(dbConstituent._Id); constituent.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(constituent).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(constituent).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -400,13 +398,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update Constituent. public override bool UpdateConstituent(SbmConstituent constituent, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateConstituent"; ClearErrorState(); if (!IsValidConstituent(constituent)) return false; if (!SysId.IsValid(constituent.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!constituent.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(constituent).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(constituent).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -424,7 +421,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbConstituent, constituent, dbUpdateInfo); dbConstituent.ExecuteUpdateCommand(dbCommand); constituent.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(constituent).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(constituent).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(constituent); @@ -445,7 +442,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteConstituent(SbmConstituent constituent, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteConstituent"; ClearErrorState(); if (!ConstituentCanBeDeleted(constituent)) return false; using (var dbConnection = db.CreateConnection()) @@ -462,7 +458,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent) + " WHERE Id=" + SysId.ToString(constituent.Id) + ";"; dbCommand.ExecuteNonQuery(); constituent.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(constituent).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(constituent).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs index 4e57c0e..27e8f53 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs @@ -432,7 +432,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert Requirement. public override bool InsertRequirement(SbmRequirement requirement, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertRequirement"; ClearErrorState(); if (!IsValidRequirement(requirement)) return false; if (SysId.IsValid(requirement.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -452,7 +451,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbRequirement.ExecuteInsertCommand(dbCommand); requirement.Id = new SysId(dbRequirement._Id); requirement.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(requirement).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(requirement).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -463,13 +462,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update Requirement. public override bool UpdateRequirement(SbmRequirement requirement, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateRequirement"; ClearErrorState(); if (!IsValidRequirement(requirement)) return false; if (!SysId.IsValid(requirement.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!requirement.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(requirement).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(requirement).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -487,7 +485,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbRequirement, requirement, dbUpdateInfo); dbRequirement.ExecuteUpdateCommand(dbCommand); requirement.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(requirement).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(requirement).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(requirement); @@ -507,7 +505,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteRequirement(SbmRequirement requirement, Sbm.TransactionType transactionType, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteRequirement"; ClearErrorState(); if (!RequirementCanBeDeleted(requirement, transactionType)) return false; using (var dbConnection = db.CreateConnection()) @@ -524,7 +521,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement) + " WHERE Id=" + SysId.ToString(requirement.Id) + ";"; dbCommand.ExecuteNonQuery(); requirement.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(requirement).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(requirement).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs index f3c197e..d460008 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs @@ -492,7 +492,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Insert Transaction. public override bool InsertTransaction(SbmTransaction transaction, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".InsertTransaction"; ClearErrorState(); if (!IsValidTransaction(transaction)) return false; if (SysId.IsValid(transaction.Id)) return SetErrorState(ErrorMessage.ValiditemId); @@ -512,7 +511,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbTransaction.ExecuteInsertCommand(dbCommand); transaction.Id = new SysId(dbTransaction._Id); transaction.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(transaction).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. " + GetLogProperties(transaction).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } @@ -523,13 +522,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update Transaction. public override bool UpdateTransaction(SbmTransaction transaction, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".UpdateTransaction"; ClearErrorState(); if (!IsValidTransaction(transaction)) return false; if (!SysId.IsValid(transaction.Id)) return SetErrorState(ErrorMessage.InvalidItemId); if (!transaction.Changed) { - if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(transaction).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(transaction).Concat(": ").Concat("", "\n\t")); return true; } using (var dbConnection = db.CreateConnection()) @@ -547,7 +545,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr PopulateTo(dbTransaction, transaction, dbUpdateInfo); dbTransaction.ExecuteUpdateCommand(dbCommand); transaction.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(transaction).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. " + GetLogProperties(transaction).Concat(": ").Concat("", "\n\t")); // Record updates. updateLogMonitor.RecordUpdatedValues(transaction); @@ -596,7 +594,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override bool DeleteTransaction(SbmTransaction transaction, DbUpdateInfo dbUpdateInfo) { - String fn = GetType().Name + ".DeleteTransaction"; ClearErrorState(); if (!TransactionCanBeDeleted(transaction)) return false; using (var dbConnection = db.CreateConnection()) @@ -613,7 +610,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction) + " WHERE Id=" + SysId.ToString(transaction.Id) + ";"; dbCommand.ExecuteNonQuery(); transaction.Changed = false; - if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(transaction).Concat(": ").Concat("", "\n\t")); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. " + GetLogProperties(transaction).Concat(": ").Concat("", "\n\t")); } catch (Exception exc) { SetErrorState(exc.Message); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs index 505a3ec..6719b9a 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs @@ -55,7 +55,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Retrieve the list of transactions types that reference the specified commodity code. public override List GetTransactionTypesForCommodity(SysId commodityId, SbmTransaction.StatusCat statusCat = SbmTransaction.StatusCat.NotCancelled) { - String fn = GetType().Name + ".GetTransactionTypesForCommodity"; List transactionTypes = new List(); if (!SysId.IsValid(commodityId)) return transactionTypes; @@ -85,14 +84,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr joinReqnt.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_CommodityId, aliasReqnt) + "=" + SysId.ToString(commodityId)); qry.Joins.Add(joinReqnt); // Execute the query. - if (DebugMode) SaLogger.Debug(fn + " Query: " + qry.BuildQuery()); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Query: " + qry.BuildQuery()); using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) { while (!HasErrorState() && dbResultSet != null && dbResultSet.NextRecord()) { NamedValue.Map values = dbResultSet.GetRecordValues(); Sbm.TransactionType transactionType = (Sbm.TransactionType)StringUtil.ToShort(values.GetValue(colTransactionType)); - if (DebugMode) SaLogger.Debug(fn + " Transaction type: " + transactionType.ToString()); + if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Transaction type: " + transactionType.ToString()); // Add this transaction type to the list. if (!transactionTypes.Contains(transactionType)) transactionTypes.Add(transactionType); diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Account/UserAccountController-Ajax.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Account/UserAccountController-Ajax.cs index 29d686e..59586f6 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Account/UserAccountController-Ajax.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Account/UserAccountController-Ajax.cs @@ -83,7 +83,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account [Route("Account/UserAccount/Ajax/GetUserList")] public IActionResult Ajax_GetUserList(Model_UserAccount model) { - String fn = GetType().Name + ".Ajax_GetUserList"; String messageTitle = Localiser["label.users"]; AjaxResponse_UserList responseData = new AjaxResponse_UserList(model); @@ -173,7 +172,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account [Route("Account/UserAccount/Ajax/GetUser")] public IActionResult Ajax_GetUser(Model_UserAccount model) { - String fn = GetType().Name + ".Ajax_GetUser"; String messageTitle = Localiser["label.user"]; AjaxResponse_User responseData = new AjaxResponse_User(model); @@ -214,7 +212,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account [Route("Account/UserAccount/Ajax/GetUserByEmail")] public IActionResult Ajax_GetUserByEmail(Model_UserAccount model) { - String fn = GetType().Name + ".Ajax_GetUserByEmail"; String messageTitle = Localiser["label.user"]; AjaxResponse_User responseData = new AjaxResponse_User(model); StoreSessionData = false; @@ -259,7 +256,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account [Route("Account/UserAccount/Ajax/StoreUser")] public IActionResult Ajax_StoreUser(Model_UserAccount model) { - String fn = GetType().Name + ".Ajax_StoreUser"; String messageTitle = Localiser["label.user"]; AjaxResponse_User responseData = new AjaxResponse_User(model); @@ -357,7 +353,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account [Route("Account/UserAccount/Ajax/SendEmails")] public IActionResult Ajax_SendEmails(Model_UserAccount model) { - String fn = GetType().Name + ".Ajax_SendEmails"; String messageTitle = Localiser["label.emails"]; AjaxResponse_User responseData = new AjaxResponse_User(model); diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/OwnerController-Ajax.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/OwnerController-Ajax.cs index 075f122..4386eb0 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/OwnerController-Ajax.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/OwnerController-Ajax.cs @@ -70,7 +70,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance [Route("Instance/Owner/Ajax/GetOwnerList")] public IActionResult Ajax_GetOwnerList(Model_Owner model) { - String fn = GetType().Name + ".Ajax_GetOwnerList"; String messageTitle = Localiser["label.owners"]; AjaxResponse_OwnerList responseData = new AjaxResponse_OwnerList(model); @@ -157,7 +156,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance [Route("Instance/Owner/Ajax/GetOwner")] public IActionResult Ajax_GetOwner(Model_Owner model) { - String fn = GetType().Name + ".Ajax_GetOwner"; String messageTitle = Localiser["label.owner"]; AjaxResponse_Owner responseData = new AjaxResponse_Owner(model); @@ -199,7 +197,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance [Route("Instance/Owner/Ajax/StoreOwner")] public IActionResult Ajax_StoreOwner(Model_Owner model) { - String fn = GetType().Name + ".Ajax_StoreOwner"; String messageTitle = Localiser["label.owner"]; AjaxResponse_Owner responseData = new AjaxResponse_Owner(model); diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs index e2e1953..b2bb0b0 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs @@ -72,7 +72,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance [Route("Instance/Repository/Ajax/GetRepositoryList")] public IActionResult Ajax_GetRepositoryList(Model_Repository model) { - String fn = GetType().Name + ".Ajax_GetRepositoryList"; String messageTitle = Localiser["label.repositories"]; AjaxResponse_RepositoryList responseData = new AjaxResponse_RepositoryList(model); @@ -156,7 +155,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance [Route("Instance/Repository/Ajax/GetRepository")] public IActionResult Ajax_GetRepository(Model_Repository model) { - String fn = GetType().Name + ".Ajax_GetRepository"; String messageTitle = Localiser["label.repository"]; AjaxResponse_Repository responseData = new AjaxResponse_Repository(model); @@ -207,7 +205,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance [Route("Instance/Repository/Ajax/StoreRepository")] public IActionResult Ajax_StoreRepository(Model_Repository model) { - String fn = GetType().Name + ".Ajax_StoreRepository"; String messageTitle = Localiser["label.repository"]; AjaxResponse_Repository responseData = new AjaxResponse_Repository(model); diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Security/SecurityController.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Security/SecurityController.cs index 316e107..37922f6 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Security/SecurityController.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Security/SecurityController.cs @@ -56,7 +56,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers [HttpGet, HttpPost] public IActionResult ChangePassword(Model_Security model) { - String fn = GetType().Name + ".ChangePassword"; bool validSessionRequired = true; if (Request.Method.EqualsCI(HttpMethods.Get)) @@ -79,19 +78,19 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers model.rpe = encryptedParams; validSessionRequired = false; } - else SaLogger.Warn(fn + " 'Request Password' parameters supplied but invalid. " + logSuffix); + else SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but invalid. {logSuffix}"); } - else SaLogger.Warn(fn + " 'Request Password' parameters supplied but account is not active. " + logSuffix); + else SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but account is not active. {logSuffix}"); } else { // User Account not found - redirect to Portal application. String redirectParamName = ParamName_RequestPasswordEncrypted + "2"; - SaLogger.Warn(fn + " 'Request Password' parameters supplied but account is not 'Admin'. " + logSuffix); + SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but account is not 'Admin'. {logSuffix}"); if (!Request.Query.Keys.Contains(redirectParamName) && !StringUtil.IsEmpty(AppConfig.URL.Portal.Root)) { UriBuilder uri = new UriBuilder(Regex.Replace(AppConfig.URL.Portal.Root, "/$", "") + "/Security/ChangePassword"); - uri.Query = ParamName_RequestPasswordEncrypted + "=" + Uri.EscapeDataString(encryptedParams) + "&" + redirectParamName; + uri.Query = $"{ParamName_RequestPasswordEncrypted}={Uri.EscapeDataString(encryptedParams)}&{redirectParamName}"; return Redirect(uri.Uri.OriginalString); } } diff --git a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-base.css b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-base.css index 44f362a..114f106 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-base.css +++ b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-base.css @@ -109,12 +109,12 @@ table.sbmc-striped table.sbmc-striped tr.sbmc-odd { - background-color:#fff; + background-color: #fff; } table.sbmc-striped tr.sbmc-even { - background-color:#f8f8f8; + background-color: #f8f8f8; } th, td @@ -215,7 +215,32 @@ td.action text-align: center; } -.fullwidth +.width5pc +{ + width: 5%; +} + +.width10pc +{ + width: 10%; +} + +.width20pc +{ + width: 20%; +} + +.width25pc +{ + width: 25%; +} + +.width50pc +{ + width: 50%; +} + +.fullwidth, .width100pc { width: 100%; } @@ -409,9 +434,9 @@ td.action z-index: 99; } -.hidden +.hidden, .sbm-hidden { - display: none; + display: none !important; } .shadow diff --git a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-main.css b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-main.css index 94799ef..1c8daa1 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-main.css +++ b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-main.css @@ -13,10 +13,6 @@ --color-primary: #4b0082; --color-light: #9b71b9; --color-pale: #ebe2f1; - /* Tetrad/Square colors */ - --color-alt1: #820a00; - --color-alt2: #378200; - --color-alt3: #007882; /* Data panels */ --color-panel-data: var(--color-Purple); --color-panel-data-background: var(--color-Purple); @@ -391,7 +387,7 @@ a:focus .ui-dialog.no-close .ui-dialog-titlebar-close { - /*display: none;*/ + display: none; } .ui-dialog .ui-dialog-buttonpane diff --git a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-main.js b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-main.js index dc63ff2..cd60677 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-main.js +++ b/SaBusinessMgrCoreWebControl/wwwroot/js/sbc-main.js @@ -219,7 +219,7 @@ sbc.$dlg.alert = $('
').dialog(opt); } $('#dlgAlertMsg', sbc.$dlg.alert).html(msg.replace(/\\n/g, '
')); - let btns = []; + let btns = {}; btns[sbc.lbl.ok] = function () { $(this).dialog('close'); if (onOk) onOk(); }; sbc.$dlg.alert.dialog('option', { title: title || sbc.dlg.title.alert, buttons: btns }); sbc.openDialog(sbc.$dlg.alert); @@ -236,7 +236,7 @@ var opt = sbc.dlgOpts(); sbc.$dlg.confirm = $('
').dialog(opt); } - var btns = []; + let btns = {}; btns[sbc.lbl.yes] = function () { $(this).dialog('close'); if (onOk) onOk(); }; btns[sbc.lbl.no] = function () { $(this).dialog('close'); if (onCancel) onCancel(); }; sbc.$dlg.confirm.dialog('option', { title: title || sbc.dlg.title.confirm, buttons: btns }); diff --git a/SaBusinessMgrCoreWebPortal/Localisation/SbmPortalProperties.resx b/SaBusinessMgrCoreWebPortal/Localisation/SbmPortalProperties.resx index 032afc2..127955d 100644 --- a/SaBusinessMgrCoreWebPortal/Localisation/SbmPortalProperties.resx +++ b/SaBusinessMgrCoreWebPortal/Localisation/SbmPortalProperties.resx @@ -591,4 +591,22 @@ Email domain + + Create Customer + + + Create Supplier + + + Update Supplier + + + Update Customer + + + Organisation + + + Ext. reference + \ No newline at end of file diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetCategoryController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetCategoryController-Ajax.cs index ab2dc7e..e55b7b5 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetCategoryController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetCategoryController-Ajax.cs @@ -69,7 +69,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets [Route("Assets/AssetCategory/Ajax/GetAssetCategoryList")] public IActionResult Ajax_GetAssetCategoryList(Model_AssetCategory model) { - String fn = GetType().Name + ".Ajax_GetAssetCategoryList"; String messageTitle = Localiser["caption.asset.categories"]; AjaxResponse_AssetCategoryList responseData = new AjaxResponse_AssetCategoryList(model); @@ -154,7 +153,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets [Route("Assets/AssetCategory/Ajax/GetAssetCategory")] public IActionResult Ajax_GetAssetCategory(Model_AssetCategory model) { - String fn = GetType().Name + ".Ajax_GetAssetCategory"; String messageTitle = Localiser["caption.asset.category"]; AjaxResponse_AssetCategory responseData = new AjaxResponse_AssetCategory(model); @@ -196,7 +194,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets [Route("Assets/AssetCategory/Ajax/StoreAssetCategory")] public IActionResult Ajax_StoreAssetCategory(Model_AssetCategory model) { - String fn = GetType().Name + ".Ajax_StoreAssetCategory"; String messageTitle = Localiser["caption.asset.category"]; AjaxResponse_AssetCategory responseData = new AjaxResponse_AssetCategory(model); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetController-Ajax.cs index 05d5688..a7c78bc 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetController-Ajax.cs @@ -80,7 +80,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets [Route("Assets/Asset/Ajax/GetAssetList")] public IActionResult Ajax_GetAssetList(Model_Asset model) { - String fn = GetType().Name + ".Ajax_GetAssetList"; String messageTitle = Localiser["label.assets"]; AjaxResponse_AssetList responseData = new AjaxResponse_AssetList(model); @@ -160,7 +159,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets [Route("Assets/Asset/Ajax/GetAsset")] public IActionResult Ajax_GetAsset(Model_Asset model) { - String fn = GetType().Name + ".Ajax_GetAsset"; String messageTitle = Localiser["label.asset"]; AjaxResponse_Asset responseData = new AjaxResponse_Asset(model); @@ -211,7 +209,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets [Route("Assets/Asset/Ajax/StoreAsset")] public IActionResult Ajax_StoreAsset(Model_Asset model) { - String fn = GetType().Name + ".Ajax_StoreAsset"; String messageTitle = Localiser["label.asset"]; AjaxResponse_Asset responseData = new AjaxResponse_Asset(model); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/VehicleClassController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/VehicleClassController-Ajax.cs index 2bc8dda..3694ef9 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/VehicleClassController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/VehicleClassController-Ajax.cs @@ -76,7 +76,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets [Route("Assets/VehicleClass/Ajax/GetVehicleClassList")] public IActionResult Ajax_GetVehicleClassList(Model_VehicleClass model) { - String fn = GetType().Name + ".Ajax_GetVehicleClassList"; String messageTitle = Localiser["caption.vehicle.classes"]; AjaxResponse_VehicleClassList responseData = new AjaxResponse_VehicleClassList(model); @@ -162,7 +161,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets [Route("Assets/VehicleClass/Ajax/GetVehicleClass")] public IActionResult Ajax_GetVehicleClass(Model_VehicleClass model) { - String fn = GetType().Name + ".Ajax_GetVehicleClass"; String messageTitle = Localiser["caption.vehicle.class"]; AjaxResponse_VehicleClass responseData = new AjaxResponse_VehicleClass(model); @@ -204,7 +202,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets [Route("Assets/VehicleClass/Ajax/StoreVehicleClass")] public IActionResult Ajax_StoreVehicleClass(Model_VehicleClass model) { - String fn = GetType().Name + ".Ajax_StoreVehicleClass"; String messageTitle = Localiser["caption.vehicle.class"]; AjaxResponse_VehicleClass responseData = new AjaxResponse_VehicleClass(model); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Codes/CodeController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Codes/CodeController-Ajax.cs index 59a08ea..3319255 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Codes/CodeController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Codes/CodeController-Ajax.cs @@ -77,7 +77,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes [Route("Codes/Code/Ajax/GetCodeList")] public IActionResult Ajax_GetCodeList(Model_Code model) { - String fn = GetType().Name + ".Ajax_GetCodeList"; String messageTitle = Localiser["label.codes"]; AjaxResponse_CodeList responseData = new AjaxResponse_CodeList(model); @@ -163,7 +162,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes [Route("Codes/Code/Ajax/GetCode")] public IActionResult Ajax_GetCode(Model_Code model) { - String fn = GetType().Name + ".Ajax_GetCode"; String messageTitle = Localiser["label.code"]; AjaxResponse_Code responseData = new AjaxResponse_Code(model); @@ -214,7 +212,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes [Route("Codes/Code/Ajax/StoreCode")] public IActionResult Ajax_StoreCode(Model_Code model) { - String fn = GetType().Name + ".Ajax_StoreCode"; String messageTitle = Localiser["label.code"]; AjaxResponse_Code responseData = new AjaxResponse_Code(model); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Codes/CodeTypeController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Codes/CodeTypeController-Ajax.cs index 3111608..e84c84f 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Codes/CodeTypeController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Codes/CodeTypeController-Ajax.cs @@ -71,7 +71,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes [Route("Codes/CodeType/Ajax/GetCodeTypeList")] public IActionResult Ajax_GetCodeTypeList(Model_CodeType model) { - String fn = GetType().Name + ".Ajax_GetCodeTypeList"; String messageTitle = Localiser["caption.code.types"]; AjaxResponse_CodeTypeList responseData = new AjaxResponse_CodeTypeList(model); @@ -155,7 +154,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes [Route("Codes/CodeType/Ajax/GetCodeType")] public IActionResult Ajax_GetCodeType(Model_CodeType model) { - String fn = GetType().Name + ".Ajax_GetCodeType"; String messageTitle = Localiser["caption.asset.category"]; AjaxResponse_CodeType responseData = new AjaxResponse_CodeType(model); @@ -197,7 +195,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes [Route("Codes/CodeType/Ajax/StoreCodeType")] public IActionResult Ajax_StoreCodeType(Model_CodeType model) { - String fn = GetType().Name + ".Ajax_StoreCodeType"; String messageTitle = Localiser["caption.asset.category"]; AjaxResponse_CodeType responseData = new AjaxResponse_CodeType(model); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs index 522c92b..e3c92aa 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs @@ -175,7 +175,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities [Route("Commodity/Ajax/GetList")] public IActionResult Ajax_CommodityList(Model_Commodity model) { - String fn = GetType().Name + ".Ajax_CommodityList"; AjaxResponse_CommodityList responseData = new AjaxResponse_CommodityList(model); String messageTitle = Localiser["caption.commodities"]; @@ -303,7 +302,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities [Route("Commodity/Ajax/GetItem")] public IActionResult Ajax_GetItem(Model_Commodity model) { - String fn = GetType().Name + ".Ajax_GetItem"; String messageTitle = Localiser["caption.commodity"]; AjaxResponse_Commodity responseData = new AjaxResponse_Commodity(model); @@ -321,7 +319,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities SbmCommodity commodity = CommodityMgr.GetCommodityById(commodityId); if (commodity == null) { - SaLogger.Warn(fn + " Failed to retrieve commodity for Id: '" + model.Commodity.Id + "'"); + SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve commodity for Id: '{model.Commodity.Id}'"); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"])); } @@ -342,7 +340,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities [Route("Commodity/Ajax/StoreItem")] public IActionResult Ajax_StoreItem(Model_Commodity model) { - String fn = GetType().Name + ".Ajax_StoreItem"; String messageTitle = Localiser["caption.commodity"]; AjaxResponse_Commodity responseData = new AjaxResponse_Commodity(model); @@ -361,12 +358,12 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities bool commodityExists = StringUtil.ToBool(model.Commodity.Exists); if (commodityExists && !SysId.IsValid(commodityId)) { - SaLogger.Warn(fn + " Id not specified for existing Commodity."); + SaLogger.Warn($"{SysUtil.Fn} Id not specified for existing Commodity."); return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); } if (!commodityExists && SysId.IsValid(commodityId)) { - SaLogger.Warn(fn + " Id specified for new Commodity: '" + model.Commodity.Id + "'"); + SaLogger.Warn($"{SysUtil.Fn} Id specified for new Commodity: '{model.Commodity.Id}'"); return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); } @@ -374,7 +371,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities SbmCommodity commodity = CommodityMgr.GetCommodityById(commodityId); if (commodity == null && SysId.IsValid(commodityId)) { - SaLogger.Warn(fn + " Failed to retrieve commodity for Id: '" + model.Commodity.Id + "'"); + SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve commodity for Id: '{model.Commodity.Id}'"); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"])); } @@ -404,7 +401,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities { if (!CommodityMgr.InsertCommodity(commodity, DbUpdateInfo)) { - SaLogger.Warn(fn + " Failed to insert commodity: " + CommodityMgr.ErrorStateMessage); + SaLogger.Warn($"{SysUtil.Fn} Failed to insert commodity: {CommodityMgr.ErrorStateMessage}"); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"])); } responseData.SetNotification(messageTitle, Localiser["msg.item.created"]); @@ -413,7 +410,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities { if (!CommodityMgr.UpdateCommodity(commodity, DbUpdateInfo)) { - SaLogger.Warn(fn + " Failed to update commodity [Id:" + SysId.ToString(commodity.Id) + "]: " + CommodityMgr.ErrorStateMessage); + SaLogger.Warn($"{SysUtil.Fn} Failed to update commodity [Id:{SysId.ToLong(commodity.Id)}]: {CommodityMgr.ErrorStateMessage}"); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"])); } responseData.SetNotification(messageTitle, Localiser["msg.item.updated"]); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Contacts/AssociationController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Contacts/AssociationController-Ajax.cs index 6932145..e73d25e 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Contacts/AssociationController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Contacts/AssociationController-Ajax.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using DocumentFormat.OpenXml.EMMA; +using Microsoft.AspNetCore.Mvc; +using NPOI.OpenXmlFormats.Dml.Diagram; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Web.Portal.Models; @@ -28,6 +30,13 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts public String Code { get; set; } // Address. public String AddressSummary { get; set; } + // Fields. + public class FieldData + { + // Item property values keyed to match field name. + public Dictionary Value { get; } = new Dictionary(); + } + public FieldData Field { get; } = new FieldData(); } private class AssociationItemData : AssociationListData { @@ -36,60 +45,121 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts public String OwnerName { get; set; } public String TargetId { get; set; } public String TypeCode { get; set; } - public String ReferenceExt { get; set; } - public String Group { get; set; } - public String DescDetail { get; set; } - public String Location { get; set; } - public String Role { get; set; } - public String PhoneMain { get; set; } - public String Email { get; set; } - public String NominalCodeDefault { get; set; } } private void PopulateAssociationResponseListData(SbmAssociation association, SbmAffiliate affiliateTarget, AssociationListData data) { data.Id = SysId.ToString(association.Id); - data.TargetName = affiliateTarget.GetDisplayName(); - data.TypeDesc = Internals.AssociationTypeCodes.GetDescForType(association.AssociationType); - data.Code = association.Code; - // Common properties. - data.Notes = association.Notes; - data.StatusCode = association.StatusCode; - data.StatusDesc = association.StatusDesc; } private void PopulateAssociationResponseItemData(SbmAssociation association, SbmAffiliate affiliateTarget, AssociationItemData data) { // List data. PopulateAssociationResponseListData(association, affiliateTarget, data as AssociationListData); // Association properties. + data.OwnerId = SysId.ToString(association.AffiliateIdOwner); data.TargetId = SysId.ToString(association.AffiliateIdTarget); data.TypeCode = Internals.AssociationTypeCodes.GetCodeForType(association.AssociationType); - data.ReferenceExt = association.RefExt; - data.Group = association.Group; - data.DescDetail = association.DescDetail; - data.Location = association.Location; - data.Role = association.Role; - data.PhoneMain = association.PhoneMain; - data.Email = association.Email; - data.NominalCodeDefault = association.DefaultNominalCode; - // Address. - //data.AddressSummary = AccountMgr.GetAddressSummaryFor(new ItemId((short)Sbm.ItemType.Affiliate, association.AffiliateIdTarget)); + data.TypeDesc = Internals.AssociationTypeCodes.GetDescForType(association.AssociationType); + // Owner - Check if current organisation. + if (association.AffiliateIdOwner.Equals(SessionData_Portal.Organisation.AffiliateId)) + data.Field.Value.Add($"{Model_Association.ItemField.Owner}", SessionData_Portal.Organisation.DisplayName); + else + { + // REtrieve owner contact details. + using (SbmAffiliate affiliateOwner = AccountMgr.GetAffiliateById(association.AffiliateIdOwner)) + { + if (affiliateOwner != null) + data.Field.Value.Add($"{Model_Association.ItemField.Owner}", affiliateOwner.GetDisplayName()); + } + } + data.Field.Value.Add($"{Model_Association.ItemField.Target}", affiliateTarget.GetDisplayName()); + data.Field.Value.Add($"{Model_Association.ItemField.ReferenceExt}", association.RefExt); + data.Field.Value.Add($"{Model_Association.ItemField.Group}", association.Group); + data.Field.Value.Add($"{Model_Association.ItemField.DescDetail}", association.DescDetail); + data.Field.Value.Add($"{Model_Association.ItemField.Location}", association.Location); + data.Field.Value.Add($"{Model_Association.ItemField.Role}", association.Role); + data.Field.Value.Add($"{Model_Association.ItemField.PhoneMain}", association.PhoneMain); + data.Field.Value.Add($"{Model_Association.ItemField.Email}", association.Email); + data.Field.Value.Add($"{Model_Association.ItemField.DefaultNominalCode}", association.DefaultNominalCode); + // Flags. + // Common properties. + data.StatusCode = association.StatusCode; + data.StatusDesc = association.StatusDesc; + // Cleanse field values. + data.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value)); + // Populate item list values that might be cleared during update after removing blank values to ensure that blank values are published. + data.Field.Value.Add($"{Model_Association.ItemField.Code}", association.Code); + data.Field.Value.Add($"{Model_Association.ItemField.Notes}", association.Notes); + data.Field.Value.Add($"{Model_Contact.ItemField.UpdatedOn}", Localiser.FormatDate(association.UpdateStamp.On)); + } + + //------------------------------------------------------------------- + // Association configuration. + //------------------------------------------------------------------- + private class AjaxResponse_AssociationConfig : AjaxResponse_Data + { + // Construction. + public AjaxResponse_AssociationConfig(SbmModel_Portal model) : base(model) { } + // Configuration. + public Model_Association.ListConfigData Config { get; } = new Model_Association.ListConfigData(); + public Model_Association.ItemConfigData ConfigCust { get; } = new Model_Association.ItemConfigData(); + public Model_Association.ItemConfigData ConfigSupp { get; } = new Model_Association.ItemConfigData(); + // Reference data. + public List AssociationTypes { get; } = new List(); + public List Statuses { get; } = new List(); + public String DefaultStatusCode { get; set; } + } + // Ajax request. + [HttpPost] + [Route("Association/Ajax/Config")] + [Route("Association/Ajax/GetConfig")] + public IActionResult Ajax_AssociationConfig(Model_Association model) + { + AjaxResponse_AssociationConfig responseData = new AjaxResponse_AssociationConfig(model); + String messageTitle = Localiser["label.associations"]; + + // Validate session and referrer. + if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); + if (!ValidReferer) return Forbid(); + RefreshModel(model); + + // Populate configuration data. + PopulateAssociationConfig(model, responseData); + + // Complete response. + responseData.Success = true; + return Json(responseData); + } + private void PopulateAssociationConfig(Model_Association model, AjaxResponse_AssociationConfig responseData) + { + // Configuration. + model.PopulateListConfig(responseData.Config); + model.PopulateItemConfig(responseData.ConfigCust, null, SessionData_Portal.Organisation.AffiliateId, Sbm.AssociationType.Customer); + model.PopulateItemConfig(responseData.ConfigSupp, null, SessionData_Portal.Organisation.AffiliateId, Sbm.AssociationType.Supplier); + + // Reference data - types. + List associationTypes = Internals.AssociationTypeCodes; + foreach (Sbm.AssociationType associationType in EnumUtil.GetValues()) + { + if (associationType <= 0 || associationType == Sbm.AssociationType.Internal) continue; + if (!SessionConsole.AllowAssociationType(associationType)) continue; + responseData.AssociationTypes.Add(associationTypes.GetCodeForType(associationType), Localiser.GetAssociationTypeCaption(associationType)); + } + + // Reference data - statuses. + foreach (SaStatus status in SbmAssociation.ValidStatuses.FindAll(item => item != SaStatus.Deleted)) + responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status)); + responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SbmAssociation.DefaultStatus); } //------------------------------------------------------------------- // Association list. //------------------------------------------------------------------- - private class AjaxResponse_AssociationList : AjaxResponse_Data + private class AjaxResponse_AssociationList : AjaxResponse_AssociationConfig { // Construction. public AjaxResponse_AssociationList(SbmModel_Portal model) : base(model) { } - // Configuration. - public Model_Association.ListConfigData Config { get; } = new Model_Association.ListConfigData(); // Association list. public List Associations { get; } = new List(); - // Reference data. - public List AssociationTypes { get; } = new List(); - public List Statuses { get; } = new List(); - public String DefaultStatusCode { get; set; } } // Ajax request. [HttpPost] @@ -105,22 +175,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts if (!ValidReferer) return Forbid(); RefreshModel(model); - // Configuration. - model.PopulateListConfig(responseData.Config); - - // Reference data - types. - List associationTypes = Internals.AssociationTypeCodes; - foreach (Sbm.AssociationType associationType in EnumUtil.GetValues()) - { - if (associationType <= 0 || associationType == Sbm.AssociationType.Internal) continue; - if (!SessionConsole.AllowAssociationType(associationType)) continue; - responseData.AssociationTypes.Add(associationTypes.GetCodeForType(associationType), Localiser.GetAssociationTypeCaption(associationType)); - } - - // Reference data - statuses. - foreach (SaStatus status in SbmAssociation.ValidStatuses.FindAll(item => item != SaStatus.Deleted)) - responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status)); - responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SbmAssociation.DefaultStatus); + // Populate configuration data. + PopulateAssociationConfig(model, responseData); // Item filter. SbmAssociation.Params prmAssociation = new SbmAssociation.Params(); @@ -160,18 +216,18 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts AssociationListData associationData = new AssociationListData() { Id = values.GetString(colId.DataName), - TargetName = values.GetString(colTargetName.DataName), - TypeDesc = Internals.AssociationTypeCodes.GetDescForType(associationType), - Code = values.GetString(colCode.DataName), - AddressSummary = AccountMgr.GetAssociationDataValue(colAddress, values).ToString(), - Notes = values.GetString(colNotes.DataName), StatusCode = values.GetString(colStatus.DataName), - StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)), - CreatedOn = DateUtil.Format(values.GetDate(colCreatedOn.DataName), "yyyyMMdd"), - CreatedOnFmt = Localiser.FormatDate(values.GetDate(colCreatedOn.DataName)), - UpdatedOn = DateUtil.Format(values.GetDate(colUpdatedOn.DataName), "yyyyMMdd"), - UpdatedOnFmt = Localiser.FormatDate(values.GetDate(colUpdatedOn.DataName)) }; + associationData.Field.Value.Add($"{Model_Association.ItemField.Type}", Internals.AssociationTypeCodes.GetDescForType(associationType)); + associationData.Field.Value.Add($"{Model_Association.ItemField.Target}", values.GetString(colTargetName.DataName)); + associationData.Field.Value.Add($"{Model_Association.ItemField.Code}", values.GetString(colCode.DataName)); + associationData.Field.Value.Add($"{Model_Association.ItemField.Address}", AccountMgr.GetAssociationDataValue(colAddress, values).ToString()); + associationData.Field.Value.Add($"{Model_Association.ItemField.Notes}", AccountMgr.GetAssociationDataValue(colNotes, values).ToString()); + associationData.Field.Value.Add($"{Model_Association.ItemField.Status}", SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))); + associationData.Field.Value.Add($"{Model_Association.ItemField.CreatedOn}", Localiser.FormatDate(values.GetDate(colCreatedOn.DataName))); + associationData.Field.Value.Add($"{Model_Association.ItemField.UpdatedOn}", Localiser.FormatDate(values.GetDate(colUpdatedOn.DataName))); + // Cleanse item values. + associationData.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value)); responseData.Associations.Add(associationData); } } @@ -304,7 +360,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); } // New item. - association = AccountMgr.CreateAssociation(SessionData_Portal.Organisation.AffiliateId, associationType, model.Association.AffiliateIdTarget.ToSysId()); + association = AccountMgr.CreateAssociation(SessionData_Portal.Organisation.AffiliateId, associationType, model.Association.ContactIdTarget.ToSysId()); disposables.Add(association); } diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Contacts/ContactController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Contacts/ContactController-Ajax.cs index 32ab275..e8a3b3e 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Contacts/ContactController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Contacts/ContactController-Ajax.cs @@ -1,4 +1,5 @@ using DocumentFormat.OpenXml.EMMA; +using DocumentFormat.OpenXml.ExtendedProperties; using Microsoft.AspNetCore.Mvc; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; @@ -26,78 +27,73 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts // Affiliate data. private class AffiliateListData : AjaxResponse_Data.ItemData_Base { - public String DisplayName { get; set; } - public String TypeDesc { get; set; } - public bool? IsIndividual { get; set; } - public bool? IsGroup { get; set; } - public String AddressSummary { get; set; } - public String Contact { get; set; } - public String Phone { get; set; } - public String Email { get; set; } + // Affiliate properties for list with specific handling. public long? AssociationCount { get; set; } - } - private class AffiliateItemData : AffiliateListData - { - // Affiliate properties. - public String TypeCode { get; set; } // Fields. public class FieldData { + // Item property values keyed to match field name. public Dictionary Value { get; } = new Dictionary(); } public FieldData Field { get; } = new FieldData(); } + private class AffiliateItemData : AffiliateListData + { + // Affiliate properties with specific handling. + public String TypeCode { get; set; } + public String TypeDesc { get; set; } + } private void PopulateAffiliateResponseListData(Model_Contact model, SbmAffiliate affiliate, AffiliateListData data) { data.Id = SysId.ToString(affiliate.Id); - data.DisplayName = affiliate.GetDisplayName(); - data.TypeDesc = Internals.AffiliateTypeCodes.GetDescForType(affiliate.AffiliateType); - if (affiliate.IsIndividual()) data.IsIndividual = true; - if (affiliate.IsContactGroup()) data.IsGroup = true; - // Common properties. - data.StatusCode = affiliate.StatusCode; - data.StatusDesc = affiliate.StatusDesc; } private void PopulateAffiliateResponseItemData(Model_Contact model, SbmAffiliate affiliate, AffiliateItemData data) { PopulateAffiliateResponseListData(model, affiliate, data as AffiliateListData); - // Affiliate properties. + // Affiliate type - populate for list ('Type' property populated with desc) and form (Type Code & Desc). data.TypeCode = Internals.AffiliateTypeCodes.GetCodeForType(affiliate.AffiliateType); + data.TypeDesc = Internals.AffiliateTypeCodes.GetDescForType(affiliate.AffiliateType); + data.Field.Value.Add($"{Model_Contact.ItemField.Type}", Internals.AffiliateTypeCodes.GetDescForType(affiliate.AffiliateType)); // Ogranisation. - data.Field.Value.Add(Model_Contact.ItemField.Parent.ToString(), SysId.ToString(affiliate.AffiliateIdParent)); - data.Field.Value.Add(Model_Contact.ItemField.Name.ToString(), affiliate.Name); - data.Field.Value.Add(Model_Contact.ItemField.Abbreviation.ToString(), affiliate.Abbr); - data.Field.Value.Add(Model_Contact.ItemField.Nature.ToString(), affiliate.Nature); - data.Field.Value.Add(Model_Contact.ItemField.Contact.ToString(), affiliate.Contact); - data.Field.Value.Add(Model_Contact.ItemField.PhoneMain.ToString(), affiliate.PhoneMain); - data.Field.Value.Add(Model_Contact.ItemField.PhoneAlt.ToString(), affiliate.PhoneAlt); - data.Field.Value.Add(Model_Contact.ItemField.PhoneDirect.ToString(), affiliate.PhoneDirect); - data.Field.Value.Add(Model_Contact.ItemField.PhoneFax.ToString(), affiliate.PhoneFax); - data.Field.Value.Add(Model_Contact.ItemField.Email.ToString(), affiliate.Email); - data.Field.Value.Add(Model_Contact.ItemField.Website.ToString(), affiliate.Website); - data.Field.Value.Add(Model_Contact.ItemField.CompanyNo.ToString(), affiliate.CompanyNo); - data.Field.Value.Add(Model_Contact.ItemField.VatReg.ToString(), affiliate.VatReg); + data.Field.Value.Add($"{Model_Contact.ItemField.Parent}", SysId.ToString(affiliate.AffiliateIdParent)); + data.Field.Value.Add($"{Model_Contact.ItemField.Name}", affiliate.Name); + data.Field.Value.Add($"{Model_Contact.ItemField.Abbreviation}", affiliate.Abbr); + data.Field.Value.Add($"{Model_Contact.ItemField.PhoneMain}", affiliate.PhoneMain); + data.Field.Value.Add($"{Model_Contact.ItemField.PhoneAlt}", affiliate.PhoneAlt); + data.Field.Value.Add($"{Model_Contact.ItemField.PhoneDirect}", affiliate.PhoneDirect); + data.Field.Value.Add($"{Model_Contact.ItemField.PhoneFax}", affiliate.PhoneFax); + data.Field.Value.Add($"{Model_Contact.ItemField.Website}", affiliate.Website); + data.Field.Value.Add($"{Model_Contact.ItemField.CompanyNo}", affiliate.CompanyNo); + data.Field.Value.Add($"{Model_Contact.ItemField.VatReg}", affiliate.VatReg); // Individual. - data.Field.Value.Add(Model_Contact.ItemField.Title.ToString(), affiliate.Title); - data.Field.Value.Add(Model_Contact.ItemField.Salutation.ToString(), affiliate.Salutation); - data.Field.Value.Add(Model_Contact.ItemField.FirstName.ToString(), affiliate.FirstName); - data.Field.Value.Add(Model_Contact.ItemField.Initials.ToString(), affiliate.Initials); - data.Field.Value.Add(Model_Contact.ItemField.LastName.ToString(), affiliate.LastName); - data.Field.Value.Add(Model_Contact.ItemField.PhoneMobile.ToString(), affiliate.PhoneMobile); - data.Field.Value.Add(Model_Contact.ItemField.BirthDay.ToString(), affiliate.BirthDay > 0 ? affiliate.BirthDay.ToString() : ""); - data.Field.Value.Add(Model_Contact.ItemField.BirthMonth.ToString(), affiliate.BirthMonth > 0 ? affiliate.BirthMonth.ToString() : ""); - data.Field.Value.Add(Model_Contact.ItemField.BirthYear.ToString(), affiliate.BirthYear > 0 ? affiliate.BirthYear.ToString() : ""); - data.Field.Value.Add(Model_Contact.ItemField.MaritalStatus.ToString(), affiliate.MaritalStatus); - data.Field.Value.Add(Model_Contact.ItemField.Spouse.ToString(), affiliate.Spouse); - data.Field.Value.Add(Model_Contact.ItemField.Children.ToString(), affiliate.Children); - data.Field.Value.Add(Model_Contact.ItemField.Hometown.ToString(), affiliate.Hometown); - data.Field.Value.Add(Model_Contact.ItemField.UserId.ToString(), SysId.ToString(affiliate.UserId)); + data.Field.Value.Add($"{Model_Contact.ItemField.Title}", affiliate.Title); + data.Field.Value.Add($"{Model_Contact.ItemField.Salutation}", affiliate.Salutation); + data.Field.Value.Add($"{Model_Contact.ItemField.FirstName}", affiliate.FirstName); + data.Field.Value.Add($"{Model_Contact.ItemField.Initials}", affiliate.Initials); + data.Field.Value.Add($"{Model_Contact.ItemField.LastName}", affiliate.LastName); + data.Field.Value.Add($"{Model_Contact.ItemField.PhoneMobile}", affiliate.PhoneMobile); + data.Field.Value.Add($"{Model_Contact.ItemField.BirthDay}", affiliate.BirthDay > 0 ? affiliate.BirthDay.ToString() : ""); + data.Field.Value.Add($"{Model_Contact.ItemField.BirthMonth}", affiliate.BirthMonth > 0 ? affiliate.BirthMonth.ToString() : ""); + data.Field.Value.Add($"{Model_Contact.ItemField.BirthYear}", affiliate.BirthYear > 0 ? affiliate.BirthYear.ToString() : ""); + data.Field.Value.Add($"{Model_Contact.ItemField.MaritalStatus}", affiliate.MaritalStatus); + data.Field.Value.Add($"{Model_Contact.ItemField.Spouse}", affiliate.Spouse); + data.Field.Value.Add($"{Model_Contact.ItemField.Children}", affiliate.Children); + data.Field.Value.Add($"{Model_Contact.ItemField.Hometown}", affiliate.Hometown); + data.Field.Value.Add($"{Model_Contact.ItemField.UserId}", SysId.ToString(affiliate.UserId)); // Flags. - data.Field.Value.Add(Model_Contact.ItemField.Prospect.ToString(), affiliate.Prospect ? "1" : ""); + data.Field.Value.Add($"{Model_Contact.ItemField.Prospect}", affiliate.Prospect ? "1" : ""); // Common properties. - data.Field.Value.Add(Model_Contact.ItemField.Notes.ToString(), affiliate.Notes); + data.StatusCode = affiliate.StatusCode; + data.StatusDesc = affiliate.StatusDesc; // Cleanse field values. data.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value)); + // Populate item list values that might be cleared during update after removing blank values to ensure that blank values are published. + data.Field.Value.Add($"{Model_Contact.ItemField.Nature}", affiliate.Nature); + data.Field.Value.Add($"{Model_Contact.ItemField.Contact}", affiliate.Contact); + data.Field.Value.Add($"{Model_Contact.ItemField.Phone}", affiliate.GetPhone()); + data.Field.Value.Add($"{Model_Contact.ItemField.Email}", affiliate.Email); + data.Field.Value.Add($"{Model_Contact.ItemField.Notes}", affiliate.Notes); + data.Field.Value.Add($"{Model_Contact.ItemField.UpdatedOn}", Localiser.FormatDate(affiliate.UpdateStamp.On)); } //------------------------------------------------------------------- @@ -127,7 +123,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts [Route("Contact/Ajax/GetConfig")] public IActionResult Ajax_ContactConfig(Model_Contact model) { - String fn = GetType().Name + ".Ajax_ContactConfig"; AjaxResponse_ContactConfig responseData = new AjaxResponse_ContactConfig(model); String messageTitle = Localiser["label.contacts"]; @@ -156,10 +151,12 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts responseData.OrganisationTypes.Add(new AjaxResponse_Data.ItemCodeDesc(affiliateType.Code, affiliateType.Desc)); // Reference data - titles. + responseData.Titles.Add(new AjaxResponse_Data.ItemCodeDesc("", "")); foreach (SaCode title in CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.ContactTitle))) responseData.Titles.Add(new AjaxResponse_Data.ItemCodeDesc(title.Code, title.Description)); // Reference data - salutation. + responseData.Salutations.Add(new AjaxResponse_Data.ItemCodeDesc("", "")); responseData.Salutations.Add(new AjaxResponse_Data.ItemCodeDesc("Dear", "Dear")); // Reference data - statuses. @@ -184,7 +181,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts [Route("Contact/Ajax/GetList")] public IActionResult Ajax_ContactList(Model_Contact model) { - String fn = GetType().Name + ".Ajax_ContactList"; AjaxResponse_ContactList responseData = new AjaxResponse_ContactList(model); String messageTitle = Localiser["label.contacts"]; @@ -228,11 +224,15 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts colAddress, colContact, colPhoneMain, colPhoneAlt, colPhoneMobile, colPhoneDirect, colEmail, colAssocCount, colNotes, colStatus, colCreatedOn, colUpdatedOn }; - if (responseData.Config.Column.Hide.Contains(Model_Contact.ItemColumn.Address.ToString())) + if (responseData.Config.Column.Hide.Contains($"{Model_Contact.ItemField.Address}")) columns.Remove(colAddress); - if (responseData.Config.Column.Hide.Contains(Model_Contact.ItemColumn.Email.ToString())) + if (responseData.Config.Column.Hide.Contains($"{Model_Contact.ItemField.Email}")) columns.Remove(colEmail); + // Sort Columns. + if (!prmAffiliate.SortColumns.Any()) + prmAffiliate.SortColumns.Add(colName); + // Query items. using (DbResultSet resultSet = AccountMgr.ExecuteAffiliateQuery(columns, prmAffiliate)) { @@ -243,25 +243,23 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts AffiliateListData affiliateData = new AffiliateListData() { Id = values.GetString(colId.DataName), - DisplayName = values.GetString(colName.DataName), - TypeDesc = Internals.AffiliateTypeCodes.GetDescForType(affiliateType), - AddressSummary = StringUtil.NullOnBlank(AccountMgr.GetAffiliateDataValue(colAddress, values).AsString()), - Contact = StringUtil.NullOnBlank(values.GetString(colContact.DataName)), - Phone = StringUtil.NullOnBlank(StringUtil.OnBlank(values.GetString(colPhoneMain.DataName), values.GetString(colPhoneAlt.DataName), values.GetString(colPhoneMobile.DataName), values.GetString(colPhoneDirect.DataName))), - Email = StringUtil.NullOnBlank(values.GetString(colEmail.DataName)), - Notes = StringUtil.NullOnBlank(AccountMgr.GetAffiliateDataValue(colNotes, values).ToString()), StatusCode = values.GetString(colStatus.DataName), - StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)), - CreatedOn = DateUtil.Format(values.GetDate(colCreatedOn.DataName), "yyyyMMdd"), - CreatedOnFmt = Localiser.FormatDate(values.GetDate(colCreatedOn.DataName)), - UpdatedOn = DateUtil.Format(values.GetDate(colUpdatedOn.DataName), "yyyyMMdd"), - UpdatedOnFmt = Localiser.FormatDate(values.GetDate(colUpdatedOn.DataName)) }; - if (SbmAffiliate.IsIndividual(affiliateType)) affiliateData.IsIndividual = true; - if (SbmAffiliate.IsContactGroup(affiliateType)) affiliateData.IsGroup = true; + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.Name}", values.GetString(colName.DataName)); + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.Type}", Internals.AffiliateTypeCodes.GetDescForType(affiliateType)); + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.Address}", StringUtil.NullOnBlank(AccountMgr.GetAffiliateDataValue(colAddress, values).AsString())); + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.Contact}", StringUtil.NullOnBlank(values.GetString(colContact.DataName))); + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.Phone}", StringUtil.NullOnBlank(StringUtil.OnBlank(values.GetString(colPhoneMain.DataName), values.GetString(colPhoneAlt.DataName), values.GetString(colPhoneMobile.DataName), values.GetString(colPhoneDirect.DataName)))); + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.Email}", StringUtil.NullOnBlank(values.GetString(colEmail.DataName))); + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.Notes}", StringUtil.NullOnBlank(AccountMgr.GetAffiliateDataValue(colNotes, values).ToString())); + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.Status}", SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))); + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.CreatedOn}", Localiser.FormatDate(values.GetDate(colCreatedOn.DataName))); + affiliateData.Field.Value.Add($"{Model_Contact.ItemField.UpdatedOn}", Localiser.FormatDate(values.GetDate(colUpdatedOn.DataName))); long assocCount = values.GetLong(colAssocCount.DataName); if (assocCount > 0) affiliateData.AssociationCount = assocCount; + // Cleanse item values. + affiliateData.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value)); responseData.Contacts.Add(affiliateData); } } @@ -296,7 +294,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts [Route("Contact/Ajax/GetItem")] public IActionResult Ajax_GetItem(Model_Contact model) { - String fn = GetType().Name + ".Ajax_GetItem"; String messageTitle = Localiser["label.contact"]; AjaxResponse_Affiliate responseData = new AjaxResponse_Affiliate(model); @@ -314,7 +311,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts SbmAffiliate affiliate = AccountMgr.GetAffiliateById(affiliateId); if (affiliate == null) { - SaLogger.Warn(fn + " Failed to retrieve affiliate for Id: '" + model.Contact.Id + "'"); + SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve affiliate for Id: '{model.Contact.Id}'"); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"])); } @@ -336,7 +333,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts [Route("Contact/Ajax/StoreItem")] public IActionResult Ajax_StoreItem(Model_Contact model) { - String fn = GetType().Name + ".Ajax_StoreItem"; String messageTitle = Localiser["label.contact"]; AjaxResponse_Affiliate responseData = new AjaxResponse_Affiliate(model); @@ -355,12 +351,12 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts bool contactExists = StringUtil.ToBool(model.Contact.Exists); if (contactExists && !SysId.IsValid(affiliateId)) { - SaLogger.Warn(fn + " Id not specified for existing Affiliate."); + SaLogger.Warn($"{SysUtil.Fn} Id not specified for existing Affiliate."); return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); } if (!contactExists && SysId.IsValid(affiliateId)) { - SaLogger.Warn(fn + " Id specified for new Affiliate: '" + model.Contact.Id + "'"); + SaLogger.Warn($"{SysUtil.Fn} Id specified for new Affiliate: '{model.Contact.Id}'"); return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); } @@ -368,19 +364,19 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts SbmAffiliate affiliate = AccountMgr.GetAffiliateById(affiliateId); if (affiliate == null && SysId.IsValid(affiliateId)) { - SaLogger.Warn(fn + " Failed to retrieve affiliate for Id: '" + model.Contact.Id + "'"); + SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve affiliate for Id: '{model.Contact.Id}'"); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"])); } // Create new item if required. if (affiliate == null) { - affiliate = AccountMgr.CreateAffiliate(model.GetContactType()); + affiliate = AccountMgr.CreateAffiliate(model.GetAffiliateType()); } else { if (model.Contact.Type != null) - affiliate.AffiliateType = model.GetContactType(); + affiliate.AffiliateType = model.GetAffiliateType(); } // Populate item properties. @@ -440,7 +436,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts { if (!AccountMgr.InsertAffiliate(affiliate, DbUpdateInfo)) { - SaLogger.Warn(fn + " Failed to insert affiliate: " + AccountMgr.ErrorStateMessage); + SaLogger.Warn($"{SysUtil.Fn} Failed to insert affiliate: {AccountMgr.ErrorStateMessage}"); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"])); } responseData.SetNotification(messageTitle, Localiser["msg.item.created"]); @@ -449,7 +445,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts { if (!AccountMgr.UpdateAffiliate(affiliate, DbUpdateInfo)) { - SaLogger.Warn(fn + " Failed to update affiliate [Id:" + SysId.ToString(affiliate.Id) + "]: " + AccountMgr.ErrorStateMessage); + SaLogger.Warn($"{SysUtil.Fn} Failed to update affiliate [Id: {SysId.ToLong(affiliate.Id)}]: {AccountMgr.ErrorStateMessage}"); return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"])); } responseData.SetNotification(messageTitle, Localiser["msg.item.updated"]); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association-Config.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association-Config.cs index caa2bb5..f9101ed 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association-Config.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association-Config.cs @@ -1,9 +1,13 @@ using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Accounts.Sage.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Utils; using System; +using System.Buffers; +using System.Collections.Generic; using System.Drawing; +using System.Xml.Serialization; namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts { @@ -14,44 +18,92 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts partial class Model_Association { //------------------------------------------------------------------- + + /// Prefix for field names. + public const String FieldNamePrefix = "Assoc"; + + /// Item fields. + public enum ItemField + { + Id, + Type, + Owner, + /// Target name. + Target, + Code, + ReferenceExt, + Primary, + Technician, + DescDetail, + Location, + Role, + Group, + Terminated, + /// Address summary. [list only] + Address, + /// Significant phone number. [list only] + Phone, + PhoneMain, + Email, + // Financials. + AnnualSalesTarget, + CreditLimit, + AccountBalance, + DiscountType, + DiscountRate, + PriceSet, + TaxCode, + /// Last sales transaction raised. [list only] + TransLastSaleRaised, + /// Open sales transaction value. [list only] + TransSalesValueOpen, + /// Sales transaction value current year to date. [list only] + TransSalesValueCytd, + /// Sales transaction value last calendar year. [list only] + TransSalesValueLcy, + // Accounts. + DefaultNominalCode, + // Commodities. + /// Commodity count. [list only] + CommodityCount, + CommoditySalesDefault, + // Customer codes. + AccountManager, + AccountHandler, + AccountType, + AccountRating, + ContactArea, + ContactHandler, + ContactMethod, + ContactCallCycle, + // Common. + Notes, + Status, + CreatedOn, + UpdatedOn, + } + + /// + /// Identifier used by form fields to show control specific messages generated by model validation etc. + /// - Both page and model should use this method to consistently generate the field name. + /// + public String GetFieldName(ItemField field) + { + return $"{FieldNamePrefix}{field}"; + } + // List configuration. public class ListConfigData { // List columns. public class ColumnData { - // Show column. - public class ShowData - { - public bool? Owner_Name { get; set; } - // Customer. - public bool? Trans_SalesValue_Open { get; set; } - public bool? Trans_LastSaleRaised { get; set; } - public bool? AnnualSalesTarget { get; set; } - public bool? Trans_SalesValue_Cytd { get; set; } - public bool? Trans_SalesValue_Lcy { get; set; } - public bool? CommodityCount { get; set; } - public bool? DiscountRate { get; set; } - public bool? PriceSet { get; set; } - public bool? Group { get; set; } - // Customer codes. - public bool? AccountManager { get; set; } - public bool? AccountHandler { get; set; } - public bool? ContactArea { get; set; } - public bool? ContactHandler { get; set; } - // Members. - public bool? Technician { get; set; } - public bool? Terminated { get; set; } - } - public ShowData Show { get; } = new ShowData(); + // Column name prefix. + public String Prefix { get; } = Model_Association.FieldNamePrefix; + // Hide column. + public HashSet Hide { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); // Column labels. - public class LabelData - { - // Members. - public String Technician { get; set; } - public String Terminated { get; set; } - } - public LabelData Label { get; } = new LabelData(); + public Dictionary Label { get; } = new Dictionary(StringComparer.InvariantCultureIgnoreCase); } public ColumnData Column { get; } = new ColumnData(); } @@ -66,71 +118,85 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts ListConfig = new ListConfigData(); PopulateListConfig(ListConfig); } - public void PopulateListConfig(ListConfigData listConfig) + public void PopulateListConfig(ListConfigData config) { - bool isCustomer = GetAssociationType() == Sbm.AssociationType.Customer; - bool isSupplier = GetAssociationType() == Sbm.AssociationType.Supplier; + bool modeIsRelationships = Mode == AssociationPageMode.Relationships; + bool modeIsMaintain = Mode == AssociationPageMode.Maintain; + Sbm.AssociationType associationType = GetAssociationType(); + bool typeIsCustomer = associationType == Sbm.AssociationType.Customer; + bool typeIsSupplier = associationType == Sbm.AssociationType.Supplier; + bool typeIsMember = associationType == Sbm.AssociationType.Member; bool userCanViewFinancials = SessionData_Portal.SecurityProfile_Core.UserCanViewFinancials(); + // List columns. - if (Mode == AssociationPageMode.Relationships) - listConfig.Column.Show.Owner_Name = true; - if (Mode == AssociationPageMode.Maintain) - { - if (GetAssociationType() == Sbm.AssociationType.Customer) - { - // Customers. - if (userCanViewFinancials && SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open)) - listConfig.Column.Show.Trans_SalesValue_Open = true; - if (SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised)) - listConfig.Column.Show.Trans_LastSaleRaised = true; - if (userCanViewFinancials && SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget)) - listConfig.Column.Show.AnnualSalesTarget = true; - if (userCanViewFinancials && SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd)) - listConfig.Column.Show.Trans_SalesValue_Cytd = true; - if (userCanViewFinancials && SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy)) - listConfig.Column.Show.Trans_SalesValue_Lcy = true; - // Commodities. - if (CommodityMgr.CanManageCommodityCustomers()) - listConfig.Column.Show.CommodityCount = true; - // Customer pricing. - if (userCanViewFinancials && SessionConsole.AllowOption(Sbm.ConfigOption.CustomerDiscount)) - listConfig.Column.Show.DiscountRate = true; - if (userCanViewFinancials && SessionConsole.AllowOption(Sbm.ConfigOption.CustomerPriceSet) && PriceMgr.PriceDatabaseIsValid) - listConfig.Column.Show.PriceSet = true; - // Association group. - if (SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Group)) - listConfig.Column.Show.Group = true; - // Codes. - if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.AccountManager))) - listConfig.Column.Show.AccountManager = true; - if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.AccountHandler))) - listConfig.Column.Show.AccountHandler = true; - if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.ContactArea))) - listConfig.Column.Show.ContactArea = true; - if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.ContactHandler))) - listConfig.Column.Show.ContactHandler = true; - } - else if (GetAssociationType() == Sbm.AssociationType.Supplier) - { - // Suppliers. - // Commodities. - if (CommodityMgr.CanManageCommoditySuppliers()) - listConfig.Column.Show.CommodityCount = true; - } - else if (GetAssociationType() == Sbm.AssociationType.Member) - { - // Members. - if (StringUtil.ToSysId(Filter.OwnerId).Equals(SessionData_Portal.Organisation.AffiliateId)) - listConfig.Column.Show.Technician = true; - listConfig.Column.Show.Terminated = true; - listConfig.Column.Label.Terminated = "Terminated"; - } - } + + if (associationType > 0) + config.Column.Hide.Add($"{ItemField.Type}"); + + // Owner name. + if (!modeIsRelationships) + config.Column.Hide.Add($"{ItemField.Owner}"); + + // Target name. + if (modeIsRelationships) + config.Column.Hide.Add($"{ItemField.Target}"); + + // Phone + if (modeIsRelationships) + config.Column.Hide.Add($"{ItemField.Phone}"); + + // Address. + if (modeIsRelationships) + config.Column.Hide.Add($"{ItemField.Address}"); + + // Customer financials. + if (!modeIsMaintain || !typeIsCustomer || !userCanViewFinancials || !SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open)) + config.Column.Hide.Add($"{ItemField.TransSalesValueOpen}"); + if (!modeIsMaintain || !typeIsCustomer || !SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised)) + config.Column.Hide.Add($"{ItemField.TransLastSaleRaised}"); + if (!modeIsMaintain || !typeIsCustomer || !userCanViewFinancials || !SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget)) + config.Column.Hide.Add($"{ItemField.AnnualSalesTarget}"); + if (!modeIsMaintain || !typeIsCustomer || !userCanViewFinancials || !SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd)) + config.Column.Hide.Add($"{ItemField.TransSalesValueCytd}"); + if (!modeIsMaintain || !typeIsCustomer || !userCanViewFinancials || !SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy)) + config.Column.Hide.Add($"{ItemField.TransSalesValueLcy}"); + // Customer commodities. + if (!modeIsMaintain || !typeIsCustomer || !CommodityMgr.CanManageCommodityCustomers()) + config.Column.Hide.Add($"{ItemField.CommodityCount}"); + // Customer pricing. + if (!modeIsMaintain || !typeIsCustomer || !userCanViewFinancials || !SessionConsole.AllowOption(Sbm.ConfigOption.CustomerDiscount)) + config.Column.Hide.Add($"{ItemField.DiscountRate}"); + if (!modeIsMaintain || !typeIsCustomer || !userCanViewFinancials || !SessionConsole.AllowOption(Sbm.ConfigOption.CustomerPriceSet) && PriceMgr.PriceDatabaseIsValid) + config.Column.Hide.Add($"{ItemField.PriceSet}"); + // Association group. + if (!modeIsMaintain || !typeIsCustomer || !SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Association_Group)) + config.Column.Hide.Add($"{ItemField.Group}"); + // Customer codes. + if (!modeIsMaintain || !typeIsCustomer || !CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.AccountManager))) + config.Column.Hide.Add($"{ItemField.AccountManager}"); + if (!modeIsMaintain || !typeIsCustomer || !CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.AccountHandler))) + config.Column.Hide.Add($"{ItemField.AccountHandler}"); + if (!modeIsMaintain || !typeIsCustomer || !CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.ContactArea))) + config.Column.Hide.Add($"{ItemField.ContactArea}"); + if (!modeIsMaintain || !typeIsCustomer || !CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.ContactHandler))) + config.Column.Hide.Add($"{ItemField.ContactHandler}"); + + // Supplier Commodities. + if (!modeIsMaintain || !typeIsSupplier || !CommodityMgr.CanManageCommoditySuppliers()) + config.Column.Hide.Add($"{ItemField.CommodityCount}"); + + // Members. + if (!typeIsMember || !StringUtil.ToSysId(Filter.OwnerId).Equals(SessionData_Portal.Organisation.AffiliateId)) + config.Column.Hide.Add($"{ItemField.Technician}"); + if (!typeIsMember) + config.Column.Hide.Add($"{ItemField.Terminated}"); + } //------------------------------------------------------------------- // Item configuration. + //------------------------------------------------------------------- // Legacy Association dialog tabs and panels. // Tab 1: // Organisation - Organisation @@ -153,6 +219,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts public class ItemConfigData { + // Update dialog title. + public String Title{ get; set; } + // Field name prefix. + public String Prefix { get; } = Model_Association.FieldNamePrefix; + // Control flags. public bool? ManagedByAccounts { get; set; } public bool? LocalPricing { get; set; } // Allowed actions. @@ -164,47 +235,14 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts // Item fields. public class FieldData { - // Show field. - public class ShowData - { - public bool? Owner { get; set; } - public bool? Code { get; set; } - public bool? ExtRef { get; set; } - public bool? Primary { get; set; } - public bool? Technician { get; set; } - public bool? Status { get; set; } - // Financials. - public bool? AnnualSalesTarget { get; set; } - public bool? CreditLimit { get; set; } - public bool? AccountBalance { get; set; } - public bool? DiscountType { get; set; } - public bool? DiscountRate { get; set; } - public bool? PriceSet { get; set; } - // Accounts. - public bool? DefaultNominalCode { get; set; } - // Customer. - public bool? Group { get; set; } - public bool? CommoditySalesDefault { get; set; } - // Customer codes. - public bool? AccountManager { get; set; } - public bool? AccountHandler { get; set; } - public bool? ContactArea { get; set; } - public bool? ContactHandler { get; set; } - } - public ShowData Show { get; } = new ShowData(); + // Field name prefix. + public String Prefix { get; } = Model_Association.FieldNamePrefix; + // Hide field. + public HashSet Hide { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); // Read-only field. - public class ReadOnlyData - { - } - public ReadOnlyData ReadOnly { get; } = new ReadOnlyData(); - // Field label. - public class LabelData - { - // Members. - public String Technician { get; set; } - public String Terminated { get; set; } - } - public LabelData Label { get; } = new LabelData(); + public HashSet Readonly { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); + // Field labels. + public Dictionary Label { get; } = new Dictionary(StringComparer.InvariantCultureIgnoreCase); } public FieldData Field { get; } = new FieldData(); } @@ -229,54 +267,151 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts bool isInternal = (associationType == Sbm.AssociationType.Internal); // Accounts interface. - if (Internals.AccountsDfn.ItemIsImportedFromAccounts(associationItemId)) - config.ManagedByAccounts = true; + bool managedByAccounts = Internals.AccountsDfn.ItemIsImportedFromAccounts(associationItemId); + if (managedByAccounts) config.ManagedByAccounts = true; // Determine pricing options. - if (isCustomer && Internals.AccountsDfn.UseLocalCustomerPricing()) - config.LocalPricing = true; - if (isSupplier && Internals.AccountsDfn.UseLocalSupplierPricing()) - config.LocalPricing = true; + bool localPricing = + (isCustomer && Internals.AccountsDfn.UseLocalCustomerPricing()) || + (isSupplier && Internals.AccountsDfn.UseLocalSupplierPricing()); + if (localPricing) config.LocalPricing = true; + + // Update dialog title. + config.Title = + isCustomer ? Localiser["caption.customer.update"] : + isSupplier ? Localiser["caption.supplier.update"] : + Localiser["caption.association.update"]; // Allow actions. if (SessionData_Portal.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.UpdateAssociationCode)) config.Allow.UpdateCode = true; - // Show fields. - if (ItemId.IsValid(associationItemId) && !ownerIsInternal) - config.Field.Show.Owner = true; - if (!isInternal) - config.Field.Show.Code = true; - if (!isInternal && !isMember) - config.Field.Show.Status = true; - if ((config.Field.Show.Code ?? false) && (isCustomer || isSupplier)) - config.Field.Show.ExtRef = true; - if ((config.Field.Show.Code ?? false) && !(config.Field.Show.ExtRef ?? false) && !ownerIsInternal && isMember) - config.Field.Show.Primary = true; - if ((config.Field.Show.Code ?? false) && !(config.Field.Show.ExtRef ?? false) && !(config.Field.Show.Primary ?? false) && ownerIsInternal && isMember) - config.Field.Show.Technician = true; - if (canViewFinancials) + // Item Fields. + + // Type. + config.Field.Readonly.Add($"{ItemField.Type}"); + + // Owner. + if (!ItemId.IsValid(associationItemId) || ownerIsInternal) + config.Field.Hide.Add($"{ItemField.Owner}"); + else + config.Field.Readonly.Add($"{ItemField.Owner}"); + + // Target. + config.Field.Readonly.Add($"{ItemField.Target}"); + + // Code. + if (isInternal) + config.Field.Hide.Add($"{ItemField.Code}"); + + // Status. + bool showCode = !isInternal && !isMember; + if (!showCode) + config.Field.Hide.Add($"{ItemField.Status}"); + + // External reference. + bool showExtRef = showCode && (isCustomer || isSupplier); + if (!showExtRef) + config.Field.Hide.Add($"{ItemField.ReferenceExt}"); + + // Primary. + bool showPrimary = showCode && !showExtRef && !ownerIsInternal && isMember; + if (!showPrimary) + config.Field.Hide.Add($"{ItemField.Primary}"); + + // Technician. + bool showTechnician = showCode && !showExtRef && !showPrimary && ownerIsInternal && isMember; + if (!showTechnician) + config.Field.Hide.Add($"{ItemField.Technician}"); + + // Desc detail. + if (managedByAccounts) + config.Field.Readonly.Add($"{ItemField.DescDetail}"); + + // Financials. + + // Annual Sales Target. + if (!canViewFinancials) + config.Field.Hide.Add($"{ItemField.AnnualSalesTarget}"); + else if (!canUpdateFinancials) + config.Field.Readonly.Add($"{ItemField.AnnualSalesTarget}"); + + // Default Nominal Code. + if (!managedByAccounts) + config.Field.Hide.Add($"{ItemField.DefaultNominalCode}"); + else + config.Field.Readonly.Add($"{ItemField.DefaultNominalCode}"); + + // Credit limit. + if (!canViewFinancials || !managedByAccounts) + config.Field.Hide.Add($"{ItemField.CreditLimit}"); + else if (managedByAccounts||!canUpdateFinancials) + config.Field.Readonly.Add($"{ItemField.CreditLimit}"); + + // Account balance. + if (!canViewFinancials || !managedByAccounts) + config.Field.Hide.Add($"{ItemField.AccountBalance}"); + else if (managedByAccounts || !canUpdateFinancials) + config.Field.Readonly.Add($"{ItemField.AccountBalance}"); + + // Discount. + if (!canViewFinancials || (!managedByAccounts && !SessionConsole.AllowOption(isSupplier ? Sbm.ConfigOption.SupplierDiscount : Sbm.ConfigOption.CustomerDiscount))) { - config.Field.Show.AnnualSalesTarget = true; - if (config.ManagedByAccounts ?? false) - { - config.Field.Show.CreditLimit = true; - config.Field.Show.AccountBalance = true; - } - if (SessionConsole.AllowOption(isSupplier ? Sbm.ConfigOption.SupplierDiscount : Sbm.ConfigOption.CustomerDiscount)) - { - config.Field.Show.DiscountType = true; - config.Field.Show.DiscountRate = true; - } - if (SessionConsole.AllowOption(isSupplier ? Sbm.ConfigOption.SupplierPriceSet : Sbm.ConfigOption.CustomerPriceSet) && PriceMgr.PriceDatabaseIsValid) - config.Field.Show.PriceSet = true; + config.Field.Hide.Add($"{ItemField.DiscountType}"); + config.Field.Hide.Add($"{ItemField.DiscountRate}"); } - if (config.ManagedByAccounts ?? false) + else if (!localPricing || !canUpdateFinancials) { - config.Field.Show.DefaultNominalCode = true; + config.Field.Readonly.Add($"{ItemField.DiscountType}"); + config.Field.Readonly.Add($"{ItemField.DiscountRate}"); + } + + // Price set. + if (!canViewFinancials || (!managedByAccounts && !SessionConsole.AllowOption(isSupplier ? Sbm.ConfigOption.SupplierPriceSet : Sbm.ConfigOption.CustomerPriceSet)) || !PriceMgr.PriceDatabaseIsValid) + config.Field.Hide.Add($"{ItemField.PriceSet}"); + else if (!localPricing || !canUpdateFinancials) + config.Field.Readonly.Add($"{ItemField.PriceSet}"); + + // Tax code. + if (managedByAccounts || !canUpdateFinancials) + config.Field.Readonly.Add($"{ItemField.TaxCode}"); + + // Default sales commodity. + if (!isCustomer || !CommodityMgr.ColumnExists(SbmDbDfn.ColumnIdx.Association_CommodityIdSalesDefault)) + config.Field.Hide.Add($"{ItemField.CommoditySalesDefault}"); + + // Association codes. + if (!isCustomer && !isSupplier) + { + config.Field.Hide.Add($"{ItemField.AccountManager}"); + config.Field.Hide.Add($"{ItemField.AccountHandler}"); + config.Field.Hide.Add($"{ItemField.AccountType}"); + config.Field.Hide.Add($"{ItemField.AccountRating}"); + config.Field.Hide.Add($"{ItemField.ContactArea}"); + config.Field.Hide.Add($"{ItemField.ContactHandler}"); + config.Field.Hide.Add($"{ItemField.ContactMethod}"); + config.Field.Hide.Add($"{ItemField.ContactCallCycle}"); + } + else if (managedByAccounts) + { + Sage.ItemType sageItemType = isCustomer ? Sage.ItemType.Customer : Sage.ItemType.Supplier; + if (Internals.AccountsDfn.SourcedFromSage(SbmDbDfn.ColumnIdx.Association_AccountManagerCode, sageItemType)) + config.Field.Readonly.Add($"{ItemField.AccountManager}"); + if (Internals.AccountsDfn.SourcedFromSage(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode, sageItemType)) + config.Field.Readonly.Add($"{ItemField.AccountHandler}"); + if (Internals.AccountsDfn.SourcedFromSage(SbmDbDfn.ColumnIdx.Association_AccountTypeCode, sageItemType)) + config.Field.Readonly.Add($"{ItemField.AccountType}"); + if (Internals.AccountsDfn.SourcedFromSage(SbmDbDfn.ColumnIdx.Association_AccountRatingCode, sageItemType)) + config.Field.Readonly.Add($"{ItemField.AccountRating}"); + if (Internals.AccountsDfn.SourcedFromSage(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, sageItemType)) + config.Field.Readonly.Add($"{ItemField.ContactArea}"); + if (Internals.AccountsDfn.SourcedFromSage(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode, sageItemType)) + config.Field.Readonly.Add($"{ItemField.ContactHandler}"); + if (Internals.AccountsDfn.SourcedFromSage(SbmDbDfn.ColumnIdx.Association_ContactMethodCode, sageItemType)) + config.Field.Readonly.Add($"{ItemField.ContactMethod}"); + if (Internals.AccountsDfn.SourcedFromSage(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode, sageItemType)) + config.Field.Readonly.Add($"{ItemField.ContactCallCycle}"); } - if (isCustomer && CommodityMgr.ColumnExists(SbmDbDfn.ColumnIdx.Association_CommodityIdSalesDefault)) - config.Field.Show.CommoditySalesDefault = true; } //------------------------------------------------------------------- diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association.cs index 4b1cc3d..b35b1bc 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association.cs @@ -60,8 +60,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts { public string Exists { get; set; } public string Id { get; set; } - public string AffiliateIdOwner { get; set; } - public string AffiliateIdTarget { get; set; } + public string ContactIdOwner { get; set; } + public string ContactIdTarget { get; set; } public string Type { get; set; } public string Code { get; set; } public string ReferenceExt { get; set; } diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact-Config.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact-Config.cs index d1a6e09..3f74f12 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact-Config.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact-Config.cs @@ -14,35 +14,74 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts partial class Model_Contact { //------------------------------------------------------------------- + // Contact fields. + //------------------------------------------------------------------- - /// Prefix for column names. - public const String ColumnNamePrefix = "Contact"; + /// Prefix for field names. + public const String FieldNamePrefix = "Contact"; - /// Item columns. - public enum ItemColumn + /// Item fields. + public enum ItemField { Id, Type, + Parent, Name, + FirstName, + LastName, + Initials, + Title, + Salutation, + Abbreviation, Nature, Contact, Email, + /// Most significant phone number. [list only] Phone, + PhoneMain, + PhoneAlt, + PhoneDirect, + PhoneFax, + PhoneMobile, + /// Address summary. [list only] Address, - Members, + Website, + CompanyNo, + VatReg, + DateOfBirth, + BirthDay, + BirthMonth, + BirthYear, + MaritalStatus, + Spouse, + Children, + Hometown, + UserId, + /// Form option group. + Options, Prospect, + /// Number of target associations. [list only] + Associations, + /// Number of members. [list only] + Members, + // Common properties. Notes, + Status, + CreatedOn, + UpdatedOn, } /// - /// Identifier used by list columns to show/hide column etc. - /// - Both page and model should use this method to consistently generate the column name. + /// Identifier used by form fields to show control specific messages generated by model validation etc. + /// - Both page and model should use this method to consistently generate the field name. /// - public String GetColumnName(ItemField field) + public String GetFieldName(ItemField field) { - return ColumnNamePrefix + field.ToString(); + return $"{FieldNamePrefix}{field}"; } + //------------------------------------------------------------------- + // List configuration. public class ListConfigData { @@ -50,7 +89,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts public class ColumnData { // Column name prefix. - public String Prefix { get; } = Model_Contact.ColumnNamePrefix; + public String Prefix { get; } = Model_Contact.FieldNamePrefix; // Hide column. public HashSet Hide { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); // Column labels. @@ -74,126 +113,75 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts /// public void PopulateListConfig(ListConfigData config) { - Sbm.AffiliateType affiliateType = GetContactType(); + Sbm.AffiliateType affiliateType = GetFilterContactType(); bool contactGroupsOnly = affiliateType == Sbm.AffiliateType.ContactGroup; // Contact type. if (affiliateType <= 0) - config.Column.Label.Add(ItemColumn.Type.ToString(), Localiser["label.type"]); + config.Column.Label.Add($"{ItemField.Type}", Localiser["label.type"]); else - config.Column.Hide.Add(ItemColumn.Type.ToString()); + config.Column.Hide.Add($"{ItemField.Type}"); // Contact name. - config.Column.Label.Add(ItemColumn.Name.ToString(), Localiser["label.name"]); + config.Column.Label.Add($"{ItemField.Name}", Localiser["label.name"]); // Nature. bool showNature = false; if (!contactGroupsOnly && showNature) - config.Column.Label.Add(ItemColumn.Nature.ToString(), Localiser["label.nature"]); + config.Column.Label.Add($"{ItemField.Nature}", Localiser["label.nature"]); else - config.Column.Hide.Add(ItemColumn.Nature.ToString()); + config.Column.Hide.Add($"{ItemField.Nature}"); // Email. if (!contactGroupsOnly && (affiliateType == Sbm.AffiliateType.Individual || !StringUtil.IsBlank(Filter.Email))) - config.Column.Label.Add(ItemColumn.Email.ToString(), Localiser["label.email"]); + config.Column.Label.Add($"{ItemField.Email}", Localiser["label.email"]); else - config.Column.Hide.Add(ItemColumn.Email.ToString()); + config.Column.Hide.Add($"{ItemField.Email}"); // Contact. if (!contactGroupsOnly && (affiliateType != Sbm.AffiliateType.Individual)) - config.Column.Label.Add(ItemColumn.Contact.ToString(), Localiser["label.contact"]); + config.Column.Label.Add($"{ItemField.Contact}", Localiser["label.contact"]); else - config.Column.Hide.Add(ItemColumn.Contact.ToString()); + config.Column.Hide.Add($"{ItemField.Contact}"); // Phone. if (!contactGroupsOnly) - config.Column.Label.Add(ItemColumn.Phone.ToString(), Localiser["label.phone"]); + config.Column.Label.Add($"{ItemField.Phone}", Localiser["label.phone"]); else - config.Column.Hide.Add(ItemColumn.Phone.ToString()); + config.Column.Hide.Add($"{ItemField.Phone}"); // Address. if (!contactGroupsOnly) - config.Column.Label.Add(ItemColumn.Address.ToString(), Localiser["label.address"]); + config.Column.Label.Add($"{ItemField.Address}", Localiser["label.address"]); else - config.Column.Hide.Add(ItemColumn.Address.ToString()); + config.Column.Hide.Add($"{ItemField.Address}"); // Group members. if (contactGroupsOnly) - config.Column.Label.Add(ItemColumn.Members.ToString(), Localiser["label.members"]); + config.Column.Label.Add($"{ItemField.Members}", Localiser["label.members"]); else - config.Column.Hide.Add(ItemColumn.Members.ToString()); + config.Column.Hide.Add($"{ItemField.Members}"); // Prospect group. if (contactGroupsOnly) - config.Column.Label.Add(ItemColumn.Prospect.ToString(), Localiser["label.prospect"]); + config.Column.Label.Add($"{ItemField.Prospect}", Localiser["label.prospect"]); else - config.Column.Hide.Add(ItemColumn.Prospect.ToString()); + config.Column.Hide.Add($"{ItemField.Prospect}"); // Contact notes. - config.Column.Label.Add(ItemColumn.Notes.ToString(), Localiser["label.notes"]); + config.Column.Label.Add($"{ItemField.Notes}", Localiser["label.notes"]); // Contact Id. if (SbmSystem.DebugMode) - config.Column.Label.Add(ItemColumn.Id.ToString(), Localiser["label.id"]); + config.Column.Label.Add($"{ItemField.Id}", Localiser["label.id"]); else - config.Column.Hide.Add(ItemColumn.Id.ToString()); + config.Column.Hide.Add($"{ItemField.Id}"); } //------------------------------------------------------------------- // Item configuration. //------------------------------------------------------------------- - /// Prefix for field names. - public const String FieldNamePrefix = "Contact"; - - /// Item fields. - public enum ItemField - { - Id, - Type, - Parent, - Name, - FirstName, - LastName, - Initials, - Title, - Salutation, - Abbreviation, - Nature, - Contact, - Email, - PhoneMain, - PhoneAlt, - PhoneDirect, - PhoneFax, - PhoneMobile, - Website, - CompanyNo, - VatReg, - DateOfBirth, - BirthDay, - BirthMonth, - BirthYear, - MaritalStatus, - Spouse, - Children, - Hometown, - UserId, - Options, - Prospect, - Notes, - Status, - } - - /// - /// Identifier used by form fields to show control specific messages generated by model validation etc. - /// - Both page and model should use this method to consistently generate the field name. - /// - public String GetFieldName(ItemField field) - { - return FieldNamePrefix + field.ToString(); - } - // Legacy Contact dialog tabs and panels. // - Individual // - Organisation @@ -213,7 +201,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts // Hide field. public HashSet Hide { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); // Read-only field. - public HashSet ReadOnly { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); + public HashSet Readonly { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); // Field labels. public Dictionary Label { get; } = new Dictionary(StringComparer.InvariantCultureIgnoreCase); } @@ -244,149 +232,149 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts // Id. if (SbmSystem.DebugMode) - config.Field.ReadOnly.Add(ItemField.Id.ToString()); + config.Field.Readonly.Add($"{ItemField.Id}"); else - config.Field.Hide.Add(ItemField.Id.ToString()); + config.Field.Hide.Add($"{ItemField.Id}"); // Contact type. if (!isOrganisation) - config.Field.Hide.Add(ItemField.Type.ToString()); + config.Field.Hide.Add($"{ItemField.Type}"); // Organisation name. if (!isOrganisation && !isGroup) { - config.Field.Hide.Add(ItemField.Name.ToString()); + config.Field.Hide.Add($"{ItemField.Name}"); } else { if (isIndividual) - config.Field.Label.Add(ItemField.Name.ToString(), Localiser["label.phone.home"]); + config.Field.Label.Add($"{ItemField.Name}", Localiser["label.phone.home"]); else - config.Field.Label.Add(ItemField.Name.ToString(), Localiser["label.phone"]); + config.Field.Label.Add($"{ItemField.Name}", Localiser["label.phone"]); if (importedFromAccounts) { - config.Field.ReadOnly.Add(ItemField.Name.ToString()); + config.Field.Readonly.Add($"{ItemField.Name}"); } } // Individual name. if (!isIndividual) { - config.Field.Hide.Add(ItemField.FirstName.ToString()); - config.Field.Hide.Add(ItemField.LastName.ToString()); - config.Field.Hide.Add(ItemField.Initials.ToString()); - config.Field.Hide.Add(ItemField.Title.ToString()); - config.Field.Hide.Add(ItemField.Salutation.ToString()); + config.Field.Hide.Add($"{ItemField.FirstName}"); + config.Field.Hide.Add($"{ItemField.LastName}"); + config.Field.Hide.Add($"{ItemField.Initials}"); + config.Field.Hide.Add($"{ItemField.Title}"); + config.Field.Hide.Add($"{ItemField.Salutation}"); } if (importedFromAccounts) { - config.Field.ReadOnly.Add(ItemField.FirstName.ToString()); - config.Field.ReadOnly.Add(ItemField.LastName.ToString()); - config.Field.ReadOnly.Add(ItemField.Initials.ToString()); - config.Field.ReadOnly.Add(ItemField.Title.ToString()); - config.Field.ReadOnly.Add(ItemField.Salutation.ToString()); + config.Field.Readonly.Add($"{ItemField.FirstName}"); + config.Field.Readonly.Add($"{ItemField.LastName}"); + config.Field.Readonly.Add($"{ItemField.Initials}"); + config.Field.Readonly.Add($"{ItemField.Title}"); + config.Field.Readonly.Add($"{ItemField.Salutation}"); } // Organisation - Abbreviation. if (!isOrganisation) - config.Field.Hide.Add(ItemField.Abbreviation.ToString()); + config.Field.Hide.Add($"{ItemField.Abbreviation}"); else if (importedFromAccounts) - config.Field.ReadOnly.Add(ItemField.Abbreviation.ToString()); + config.Field.Readonly.Add($"{ItemField.Abbreviation}"); // Organisation - Nature. if (!isOrganisation) - config.Field.Hide.Add(ItemField.Nature.ToString()); + config.Field.Hide.Add($"{ItemField.Nature}"); // Organisation - Contact. if (!isOrganisation) - config.Field.Hide.Add(ItemField.Contact.ToString()); + config.Field.Hide.Add($"{ItemField.Contact}"); else if (importedFromAccounts) - config.Field.ReadOnly.Add(ItemField.Contact.ToString()); + config.Field.Readonly.Add($"{ItemField.Contact}"); // Phone numbers. // NB Main Phone is shared between Organisations and Individuals (home phone). if (!isOrganisation && !isIndividual) - config.Field.Hide.Add(ItemField.PhoneMain.ToString()); + config.Field.Hide.Add($"{ItemField.PhoneMain}"); else if (importedFromAccounts) - config.Field.ReadOnly.Add(ItemField.PhoneMain.ToString()); + config.Field.Readonly.Add($"{ItemField.PhoneMain}"); // Organisation - Phone numbers. if (!isOrganisation) { - config.Field.Hide.Add(ItemField.PhoneAlt.ToString()); - config.Field.Hide.Add(ItemField.PhoneDirect.ToString()); - config.Field.Hide.Add(ItemField.PhoneFax.ToString()); + config.Field.Hide.Add($"{ItemField.PhoneAlt}"); + config.Field.Hide.Add($"{ItemField.PhoneDirect}"); + config.Field.Hide.Add($"{ItemField.PhoneFax}"); } else if (importedFromAccounts) { - config.Field.ReadOnly.Add(ItemField.PhoneAlt.ToString()); - config.Field.ReadOnly.Add(ItemField.PhoneFax.ToString()); + config.Field.Readonly.Add($"{ItemField.PhoneAlt}"); + config.Field.Readonly.Add($"{ItemField.PhoneFax}"); } // Individual - Phone numbers. if (!isIndividual) { - config.Field.Hide.Add(ItemField.PhoneMobile.ToString()); + config.Field.Hide.Add($"{ItemField.PhoneMobile}"); } else if (importedFromAccounts) { - config.Field.ReadOnly.Add(ItemField.PhoneMobile.ToString()); + config.Field.Readonly.Add($"{ItemField.PhoneMobile}"); } // Email. if (!isOrganisation && !isIndividual) - config.Field.Hide.Add(ItemField.Email.ToString()); + config.Field.Hide.Add($"{ItemField.Email}"); else { if (isOrganisation) - config.Field.Label.Add(ItemField.Email.ToString(), Localiser["label.email.domain"]); + config.Field.Label.Add($"{ItemField.Email}", Localiser["label.email.domain"]); else - config.Field.Label.Add(ItemField.Email.ToString(), Localiser["label.email"]); + config.Field.Label.Add($"{ItemField.Email}", Localiser["label.email"]); if (importedFromAccounts) - config.Field.ReadOnly.Add(ItemField.Email.ToString()); + config.Field.Readonly.Add($"{ItemField.Email}"); } // Individual. if (!isIndividual) { - config.Field.Hide.Add(ItemField.DateOfBirth.ToString()); - config.Field.Hide.Add(ItemField.MaritalStatus.ToString()); - config.Field.Hide.Add(ItemField.Spouse.ToString()); - config.Field.Hide.Add(ItemField.Children.ToString()); - config.Field.Hide.Add(ItemField.Hometown.ToString()); + config.Field.Hide.Add($"{ItemField.DateOfBirth}"); + config.Field.Hide.Add($"{ItemField.MaritalStatus}"); + config.Field.Hide.Add($"{ItemField.Spouse}"); + config.Field.Hide.Add($"{ItemField.Children}"); + config.Field.Hide.Add($"{ItemField.Hometown}"); } // Organisation - Website. if (!isOrganisation) - config.Field.Hide.Add(ItemField.Website.ToString()); + config.Field.Hide.Add($"{ItemField.Website}"); else if (importedFromAccounts) - config.Field.ReadOnly.Add(ItemField.Website.ToString()); + config.Field.Readonly.Add($"{ItemField.Website}"); // Organisation - Company Number. if (!isOrganisation) - config.Field.Hide.Add(ItemField.CompanyNo.ToString()); + config.Field.Hide.Add($"{ItemField.CompanyNo}"); // Organisation - VatReg. if (!isOrganisation) - config.Field.Hide.Add(ItemField.VatReg.ToString()); + config.Field.Hide.Add($"{ItemField.VatReg}"); else if (importedFromAccounts) - config.Field.ReadOnly.Add(ItemField.VatReg.ToString()); + config.Field.Readonly.Add($"{ItemField.VatReg}"); // Prospect. if (!isGroup) - config.Field.Hide.Add(ItemField.Prospect.ToString()); + config.Field.Hide.Add($"{ItemField.Prospect}"); // Options - hidden if no options shown. - if (config.Field.Hide.ContainsCI(ItemField.Prospect.ToString())) - config.Field.Hide.Add(ItemField.Options.ToString()); + if (config.Field.Hide.ContainsCI($"{ItemField.Prospect}")) + config.Field.Hide.Add($"{ItemField.Options}"); // Notes. if (!showNotes) - config.Field.Hide.Add(ItemField.Notes.ToString()); + config.Field.Hide.Add($"{ItemField.Notes}"); // Status. if (importedFromAccounts) - config.Field.ReadOnly.Add(ItemField.Status.ToString()); + config.Field.Readonly.Add($"{ItemField.Status}"); } diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact.cs index 02f38a8..845af0c 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact.cs @@ -1,4 +1,5 @@ using DocumentFormat.OpenXml.EMMA; +using Microsoft.AspNetCore.Mvc.Rendering; using Sarand.BusinessMgr.Net.Core.Web.App; using Sarand.BusinessMgr.Net.Core.Web.Controllers; using Sarand.BusinessMgr.Net.Standard.Base.App; @@ -40,7 +41,19 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts public FilterData Filter { get; } = new FilterData(); public Sbm.AffiliateType GetFilterContactType() { - return (Sbm.AffiliateType)Internals.AffiliateTypeCodes.GetTypeForCode(Filter.ContactType); + Sbm.AffiliateType affiliateType = (Sbm.AffiliateType)Internals.AffiliateTypeCodes.GetTypeForCode(Filter.ContactType); + if (affiliateType == 0 && !StringUtil.IsBlank(Filter.ContactType) && StringUtil.IsNumeric(Filter.ContactType, true)) + affiliateType = (Sbm.AffiliateType)StringUtil.ToInt(Filter.ContactType); + return affiliateType; + } + + /// List of Affiliate Types for filter dropdown. + public IEnumerable GetAffiliateTypeCodesForFilterSelect() + { + List affiliateTypes = GetCodesOfType(Sbm.SystemCode.AffiliateType); + if (!affiliateTypes.Any(item => item.Type == (int)Sbm.AffiliateType.AnyOrganisation)) + affiliateTypes.Insert(0, new TypeCodeDesc((int)Sbm.AffiliateType.AnyOrganisation, ((short)Sbm.AffiliateType.AnyOrganisation).ToString(), Localiser["label.organisation"])); + return new SelectList(affiliateTypes, "Code", "Desc"); } //------------------------------------------------------------------- @@ -85,7 +98,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts public SysId GetAffiliateId() { return StringUtil.ToSysId(Contact.Id); } public SaStatus GetAffiliateStatus() { return SacsSystem.GetStatusForCode(Contact.StatusCode); } public ContactData Contact { get; } = new ContactData(); - public Sbm.AffiliateType GetContactType() + public Sbm.AffiliateType GetAffiliateType() { if (StringUtil.ToBool(Contact.IsIndividual)) return Sbm.AffiliateType.Individual; @@ -109,8 +122,9 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts if (StringUtil.IsBlank(Contact.Type)) responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]); } - bool isIndividual = SbmAffiliate.IsIndividual(GetContactType()); - bool isContactGroup = SbmAffiliate.IsContactGroup(GetContactType()); + Sbm.AffiliateType affiliateType = GetAffiliateType(); + bool isIndividual = SbmAffiliate.IsIndividual(affiliateType); + bool isContactGroup = SbmAffiliate.IsContactGroup(affiliateType); bool isOrganisation = !isIndividual && !isContactGroup; // Organisation Name. @@ -289,6 +303,18 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]); else if (StringUtil.GetLength(Contact.LastName) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_LastName)) responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_LastName)]); + else if (isIndividual) + { + // Check that the individual name is unique. + SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); + if (SysId.IsValid(GetAffiliateId()) && StringUtil.ToBool(Contact.Exists)) + prmAffiliate.IdsExcluded.Add(GetAffiliateId()); + prmAffiliate.AffiliateType = Sbm.AffiliateType.Individual; + prmAffiliate.Name = SbmAffiliate.GetDisplayName(affiliateType, "", Contact.FirstName, Contact.LastName); + prmAffiliate.StatusCat = SbmAffiliate.StatusCat.NotDeleted; + if (AccountMgr.GetAffiliateCount(prmAffiliate) > 0) + responseData.SetControlError(controlName, Localiser["msg.validation.duplicate.value"]); + } } // Individual Phone Mobile. diff --git a/SaBusinessMgrCoreWebPortal/Views/Association/Index.cshtml b/SaBusinessMgrCoreWebPortal/Views/Association/Index.cshtml index ddb34a8..6919b95 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Association/Index.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Association/Index.cshtml @@ -9,6 +9,8 @@
@@ -37,23 +39,21 @@ @* Filter Panel *@
-
-
- @* Association filter - name etc. *@ -
@Localiser["label.search"]
-
- @Html.TextBoxFor(model => model.Filter.Search, new { @id = "", @class = "FilterSearch sbm-input", @maxlength = "32" }) -
-
+
@* Association Category *@ -
@Localiser["label.type"]
-
+
@Localiser["label.type"]
+
@Html.DropDownListFor(model => model.Filter.AssociationType, Model.GetAssociationTypeCodesForSelect(), Localiser["label.any"], new { @id = "", @class = "FilterAssociationType sbm-select" })
-
-
+
+ @* Association filter - name etc. *@ +
@Localiser["label.search"]
+
+ @Html.TextBoxFor(model => model.Filter.Search, new { @id = "", @class = "FilterSearch sbm-input", @maxlength = "32" }) +
+
} @@ -62,12 +62,12 @@ - - - - - - + + + + + + @@ -87,12 +87,12 @@ @* Association row template - table is ignored. *@
@Localiser["label.type"]@Localiser["label.code"]@Localiser["label.name"]@Localiser["label.address"]@Localiser["label.notes"]@Localiser["label.status"]@Localiser["label.type"]@Localiser["label.code"]@Localiser["label.name"]@Localiser["label.address"]@Localiser["label.notes"]@Localiser["label.status"]
- - - - - - + + + + + +
@* Burger menu *@ diff --git a/SaBusinessMgrCoreWebPortal/Views/Association/Panel-AssociationDialog.cshtml b/SaBusinessMgrCoreWebPortal/Views/Association/Panel-AssociationDialog.cshtml index 89a98c0..b8eb3e3 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Association/Panel-AssociationDialog.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Association/Panel-AssociationDialog.cshtml @@ -22,7 +22,7 @@ @Html.HiddenFor(model => model.Association.Exists, new { @id = "", @class = "AssociationExists sbm-input" }) @* Association Type *@ -
+
@@ -31,7 +31,30 @@
- @Html.DropDownListFor(model => model.Association.Type, Model.GetAssociationTypeCodesForSelect(), Localiser["label.select"], new { @id = "cbAssociationType", @class = "AssociationType sbm-select" }) + @Html.DropDownListFor(model => model.Association.Type, Model.GetAssociationTypeCodesForSelect(), Localiser["label.select"], new { @id = "cbAssociationType", @class = "AssociationType sbm-select sbm-auto-val" }) +
+
+
+
+
+ + @* Owner contact *@ +
+
+
+
+ +
+
+
+
+
+ @Html.HiddenFor(model => model.Association.ContactIdOwner, new { @id = "", @class = "AssociationOwnerId sbm-input" }) + +
+
+ @*
*@ +
@@ -39,7 +62,7 @@
@* Target contact *@ -
+
@@ -49,8 +72,8 @@
- @Html.HiddenFor(model => model.Association.AffiliateIdTarget, new { @id = "", @class = "AssociationId sbm-input" }) - + @Html.HiddenFor(model => model.Association.ContactIdTarget, new { @id = "", @class = "AssociationTargetId sbm-input" }) +
@@ -61,25 +84,52 @@
- @* Association Code *@ -
-
-
-
- +
+
+ + @* Association Code *@ +
+
+
+
+ +
+
+
+
+ @Html.TextBoxFor(model => model.Association.Code, new { @id = "ifAssociationCode", @class = "AssociationCode sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Association_Code) }) +
+
+
-
-
- @Html.TextBoxFor(model => model.Association.Code, new { @id = "ifAssociationCode", @class = "AssociationCode sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Association_Code) }) + +
+
+
+ + @* Association ExtRef *@ +
+
+
+
+ +
+
+
+
+ @Html.TextBoxFor(model => model.Association.ReferenceExt, new { @id = "ifAssociationExtRef", @class = "AssociationExtRef sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Association_ExtRef) }) +
+
+
-
+
@* Association status *@ -
+
@@ -88,7 +138,7 @@
- +
@@ -96,7 +146,7 @@
@* Association Notes *@ -
+
@@ -105,7 +155,7 @@
- @Html.TextAreaFor(model => model.Association.Notes, new { @id = "ifAssociationNotes", @class = "AssociationNotes sbm-textarea", @rows = "3", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Association_Notes) }) + @Html.TextAreaFor(model => model.Association.Notes, new { @id = "ifAssociationNotes", @class = "AssociationNotes sbm-textarea sbm-auto-val", @rows = "3", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Association_Notes) })
diff --git a/SaBusinessMgrCoreWebPortal/Views/Contact/Index.cshtml b/SaBusinessMgrCoreWebPortal/Views/Contact/Index.cshtml index 58408a4..727beb3 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Contact/Index.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Contact/Index.cshtml @@ -38,16 +38,20 @@ @* Filter Panel *@
-
- @* Contact filter - name etc. *@ -
@Localiser["label.search"]
-
- @Html.TextBoxFor(model => model.Filter.Search, new { @id = "", @class = "FilterSearch sbm-input", @maxlength = "32" }) +
+
+ @* Contact type *@ +
@Localiser["label.type"]
+
+ @Html.DropDownListFor(model => model.Filter.ContactType, Model.GetAffiliateTypeCodesForFilterSelect(), Localiser["label.any"], new { @id = "", @class = "FilterContactType sbm-select" }) +
- @* Contact type *@ -
@Localiser["label.type"]
-
- @Html.DropDownListFor(model => model.Filter.ContactType, Model.GetAffiliateTypeCodesForSelect(), Localiser["label.any"], new { @id = "", @class = "FilterContactType sbm-select" }) +
+ @* Contact filter - name etc. *@ +
@Localiser["label.search"]
+
+ @Html.TextBoxFor(model => model.Filter.Search, new { @id = "", @class = "FilterSearch sbm-input", @maxlength = "32" }) +
@@ -58,14 +62,14 @@ - - - - - - - - + + + + + + + + @@ -85,14 +89,14 @@ @* Item row template - table is ignored. *@
@Localiser["label.type"]@Localiser["label.name"]@Localiser["label.address"]@Localiser["label.contact"]@Localiser["label.phone"]@Localiser["label.notes"]@Localiser["label.associations"]@Localiser["label.status"]@Localiser["label.type"]@Localiser["label.name"]@Localiser["label.address"]@Localiser["label.contact"]@Localiser["label.phone"]@Localiser["label.notes"]@Localiser["label.associations"]@Localiser["label.status"]
- - - - - - - - + + + + + + + +
@* Burger menu *@ diff --git a/SaBusinessMgrCoreWebPortal/Views/Contact/Panel-ContactDialog.cshtml b/SaBusinessMgrCoreWebPortal/Views/Contact/Panel-ContactDialog.cshtml index 2a7f974..9be2327 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Contact/Panel-ContactDialog.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Contact/Panel-ContactDialog.cshtml @@ -56,7 +56,7 @@
- @Html.TextBoxFor(model => model.Contact.Abbreviation, new { @id = "ifContactAbbreviation", @class = "ContactAbbreviation sbm-input upper", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Abbrev) }) + @Html.TextBoxFor(model => model.Contact.Abbreviation, new { @id = "ifContactAbbreviation", @class = "ContactAbbreviation sbm-input sbm-auto-val upper", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Abbrev) })
@@ -76,7 +76,7 @@
- @Html.TextBoxFor(model => model.Contact.Name, new { @id = "ifContactName", @class = "ContactName sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Name) }) + @Html.TextBoxFor(model => model.Contact.Name, new { @id = "ifContactName", @class = "ContactName sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Name) })
@@ -96,7 +96,7 @@
- @Html.TextBoxFor(model => model.Contact.Nature, new { @id = "ifContactNature", @class = "ContactNature sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Nature) }) + @Html.TextBoxFor(model => model.Contact.Nature, new { @id = "ifContactNature", @class = "ContactNature sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Nature) })
@@ -117,7 +117,7 @@
- @Html.TextBoxFor(model => model.Contact.Contact, new { @id = "ifContactContact", @class = "ContactContact sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Contact) }) + @Html.TextBoxFor(model => model.Contact.Contact, new { @id = "ifContactContact", @class = "ContactContact sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Contact) })
@@ -140,7 +140,7 @@
- @Html.DropDownListFor(model => model.Contact.Title, Model.GetCodeTypeCodesForSelect(Sbm.ApplCodeType.ContactTitle), new { @id = "cbContactTitle", @class = "ContactTitle sbm-select", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Title) }) + @Html.DropDownListFor(model => model.Contact.Title, Model.GetCodeTypeCodesForSelect(Sbm.ApplCodeType.ContactTitle), new { @id = "cbContactTitle", @class = "ContactTitle sbm-select sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Title) })
@@ -161,7 +161,7 @@
- @Html.TextBoxFor(model => model.Contact.Salutation, new { @id = "ifContactSalutation", @class = "ContactSalutation sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Salutation) }) + @Html.TextBoxFor(model => model.Contact.Salutation, new { @id = "ifContactSalutation", @class = "ContactSalutation sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Salutation) })
@@ -184,7 +184,7 @@
- @Html.TextBoxFor(model => model.Contact.FirstName, new { @id = "ifContactFirstName", @class = "ContactFirstName sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_FirstName) }) + @Html.TextBoxFor(model => model.Contact.FirstName, new { @id = "ifContactFirstName", @class = "ContactFirstName sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_FirstName) })
@@ -205,7 +205,7 @@
- @Html.TextBoxFor(model => model.Contact.Initials, new { @id = "ifContactInitials", @class = "ContactInitials sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Initials) }) + @Html.TextBoxFor(model => model.Contact.Initials, new { @id = "ifContactInitials", @class = "ContactInitials sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Initials) })
@@ -225,7 +225,7 @@
- @Html.TextBoxFor(model => model.Contact.LastName, new { @id = "ifContactLastName", @class = "ContactLastName sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_LastName) }) + @Html.TextBoxFor(model => model.Contact.LastName, new { @id = "ifContactLastName", @class = "ContactLastName sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_LastName) })
@@ -245,7 +245,7 @@
- @Html.TextBoxFor(model => model.Contact.PhoneMain, new { @id = "ifContactPhoneMain", @class = "ContactPhoneMain sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneMain) }) + @Html.TextBoxFor(model => model.Contact.PhoneMain, new { @id = "ifContactPhoneMain", @class = "ContactPhoneMain sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneMain) })
@@ -266,7 +266,7 @@
- @Html.TextBoxFor(model => model.Contact.PhoneAlt, new { @id = "ifContactPhoneAlt", @class = "ContactPhoneAlt sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneAlt) }) + @Html.TextBoxFor(model => model.Contact.PhoneAlt, new { @id = "ifContactPhoneAlt", @class = "ContactPhoneAlt sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneAlt) })
@@ -283,7 +283,7 @@
- @Html.TextBoxFor(model => model.Contact.PhoneMobile, new { @id = "ifContactPhoneMobile", @class = "ContactPhoneMobile sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneMobile) }) + @Html.TextBoxFor(model => model.Contact.PhoneMobile, new { @id = "ifContactPhoneMobile", @class = "ContactPhoneMobile sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneMobile) })
@@ -306,7 +306,7 @@
- @Html.TextBoxFor(model => model.Contact.PhoneDirect, new { @id = "ifContactPhoneDirect", @class = "ContactPhoneDirect sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneDirect) }) + @Html.TextBoxFor(model => model.Contact.PhoneDirect, new { @id = "ifContactPhoneDirect", @class = "ContactPhoneDirect sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneDirect) })
@@ -327,7 +327,7 @@
- @Html.TextBoxFor(model => model.Contact.PhoneFax, new { @id = "ifContactPhoneFax", @class = "ContactPhoneFax sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneFax) }) + @Html.TextBoxFor(model => model.Contact.PhoneFax, new { @id = "ifContactPhoneFax", @class = "ContactPhoneFax sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_PhoneFax) })
@@ -347,7 +347,7 @@
- @Html.TextBoxFor(model => model.Contact.Email, new { @id = "ifContactEmail", @class = "ContactEmail sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Email) }) + @Html.TextBoxFor(model => model.Contact.Email, new { @id = "ifContactEmail", @class = "ContactEmail sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Email) })
@@ -364,7 +364,7 @@
- @Html.TextBoxFor(model => model.Contact.Website, new { @id = "ifContactWebsite", @class = "ContactWebsite sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Website) }) + @Html.TextBoxFor(model => model.Contact.Website, new { @id = "ifContactWebsite", @class = "ContactWebsite sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Website) })
@@ -384,7 +384,7 @@
- @Html.TextBoxFor(model => model.Contact.CompanyNo, new { @id = "ifContactCompanyNo", @class = "ContactCompanyNo sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_CompanyNo) }) + @Html.TextBoxFor(model => model.Contact.CompanyNo, new { @id = "ifContactCompanyNo", @class = "ContactCompanyNo sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_CompanyNo) })
@@ -405,7 +405,7 @@
- @Html.TextBoxFor(model => model.Contact.VatReg, new { @id = "ifContactVatReg", @class = "ContactVatReg sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_VatReg) }) + @Html.TextBoxFor(model => model.Contact.VatReg, new { @id = "ifContactVatReg", @class = "ContactVatReg sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_VatReg) })
@@ -426,7 +426,8 @@
- @Html.CheckBoxFor(Model => Model.Contact.Prospect, new { @id = "chkContactProspect", @class = "ContactProspect sbm-checkbox" }) + +  @Localiser["label.prospect"]
@@ -445,7 +446,7 @@
- @Html.TextAreaFor(model => model.Contact.Notes, new { @id = "ifContactNotes", @class = "ContactNotes sbm-textarea", @rows = "3", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Notes) }) + @Html.TextAreaFor(model => model.Contact.Notes, new { @id = "ifContactNotes", @class = "ContactNotes sbm-textarea sbm-auto-val", @rows = "3", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Affiliate_Notes) })
diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-base.css b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-base.css index 07e85a5..2fcfc4e 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-base.css +++ b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-base.css @@ -2,6 +2,17 @@ BusMgr Portal - Base stylesheet. */ +:root +{ + --color-OldGold: #d4af37; + --color-OliveGreen: #808000; + --color-CornflowerBlue: #6495ed; + --color-RoyalBlue: #4169e1; + --color-NavyBlue: #000080; + --color-DarkBlue: #00008B; + --color-Indigo: #4b0082; +} + body { margin: 0; @@ -195,7 +206,32 @@ td.action text-align: center; } -.fullwidth +.width5pc +{ + width: 5%; +} + +.width10pc +{ + width: 10%; +} + +.width20pc +{ + width: 20%; +} + +.width25pc +{ + width: 25%; +} + +.width50pc +{ + width: 50%; +} + +.fullwidth, .width100pc { width: 100%; } @@ -389,9 +425,9 @@ td.action z-index: 99; } -.hidden +.hidden, .sbm-hidden { - display: none; + display: none !important; } .shadow diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-data.css b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-data.css index 046f8d8..c48a38e 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-data.css +++ b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-data.css @@ -2,14 +2,13 @@ BusMgr Portal - Data stylesheet. */ +/* Data panel */ + :root { - --color-OliveGreen: #808000; --color-DataPanel-main: var(--color-OliveGreen); } -/* Data panel */ - .sbm-panel-data { margin: 6px auto; diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-form.css b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-form.css index 26ab071..cfdb1d7 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-form.css +++ b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-form.css @@ -133,6 +133,11 @@ margin: 0 0 16px 0; } +.sbm-form .sbm-form-control .sbm-form-control +{ + margin-bottom: 0; +} + .sbm-form .sbm-form-control .sbm-label { margin: 0 0 8px 0; @@ -224,8 +229,8 @@ font-size: 1rem; text-align: center; color: #fff; - background-color: #d4af37; - border: 1px solid #d4af37; + background-color: var(--color-OldGold); + border: 1px solid var(--color-OldGold); border-radius: 4px; } diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-main.css b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-main.css index 7c07b11..bd94b2d 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-main.css +++ b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-main.css @@ -11,10 +11,6 @@ --color-primary: #4b0082; --color-light: #9b71b9; --color-pale: #ebe2f1; - /* Tetrad/Square colors */ - --color-alt1: #820a00; - --color-alt2: #378200; - --color-alt3: #007882; } /* Document */ @@ -166,7 +162,7 @@ button.accept-policy a, a:hover { text-decoration: underline; - color: #d4af37; + color: var(--color-OldGold); } a:focus @@ -326,6 +322,17 @@ a:focus } /* Dialogs */ + +:root +{ + --color-dialog: var(--color-OldGold); +} + +.ui-dialog.sbm-dark-blue +{ + --color-dialog: var(--color-DarkBlue); +} + .sbm-dialog { display: none; @@ -350,7 +357,7 @@ a:focus .ui-dialog.ui-widget.ui-widget-content { border-width: 2px; - border-color: #d4af37; + border-color: var(--color-dialog); -moz-box-shadow: 4px 4px 6px #ccc; -webkit-box-shadow: 4px 4px 6px #ccc; overflow: hidden; @@ -365,8 +372,8 @@ a:focus { font-size: 1.1rem; color: #fff; - background-color: #d4af37; - border-color: #d4af37; + background-color: var(--color-dialog); + border-color: var(--color-dialog); } .ui-widget-content @@ -383,12 +390,12 @@ a:focus .ui-dialog.no-close .ui-dialog-titlebar-close { - /*display: none;*/ + display: none; } .ui-dialog .ui-dialog-buttonpane { - border-color: #d4af37; + border-color: var(--color-dialog); margin-top: .25em; padding: .2em 1em .2em .5em; } @@ -398,8 +405,8 @@ a:focus min-width: 80px; margin: .5em .25em .5em .5em; color: #fff; - background-color: #d4af37; - border-color: #d4af37; + background-color: var(--color-dialog); + border-color: var(--color-dialog); outline: none; } @@ -417,7 +424,7 @@ a:focus .ui-datepicker .ui-datepicker-header { background-color: #fff; - border: 1px solid #d4af37; + border: 1px solid var(--color-OldGold); } /* The End */ diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-assoc.js b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-assoc.js index 28e6218..efd567e 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-assoc.js +++ b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-assoc.js @@ -23,7 +23,7 @@ } as.doRefreshResults = function (response) { - sbm.debug('doRefreshResults', response); + //sbm.debug('doRefreshResults', response); delete sbm.awaitingRefreshResponse; $pnl.msgs.hide().empty(); let $table = $('table', $pnl.table).find('tbody tr').remove().end(); @@ -31,6 +31,9 @@ if (!response.success) return; // Reference data. + as.config = response.config; + as.configCust = response.configCust; + as.configSupp = response.configSupp; as.data.associationTypes = response.associationTypes; as.data.statuses = response.statuses; as.data.defaultStatusCode = response.defaultStatusCode; @@ -39,26 +42,25 @@ $pnl.bgr.invisible(); $pnl.mnu.empty(); $pnl.mnu.append(as.getFilterMenuOption(sbm.lbl.refresh, function () { as.refreshResults(); }, 'sbm-refresh')); - $pnl.mnu.append(as.getFilterMenuOption(sbm.lbl.create, function () { as.createItem(); }, 'sbm-add')); + $pnl.mnu.append(as.getFilterMenuOption(sbm.lbl.createCust, function () { as.createItem(as.configCust, sbm.lbl.createCust); }, 'sbm-add')); + $pnl.mnu.append(as.getFilterMenuOption(sbm.lbl.createSupp, function () { as.createItem(as.configSupp, sbm.lbl.createSupp); }, 'sbm-add')); $pnl.bgr.toggleVisibility(!!$('.sbm-dropdown-item', $pnl.mnu).length); + // Items. var items = response.associations || []; if (!items.length) return $pnl.msgs.append($('
' + sbm.msg.dataNoneFound + '
')).fadeIn(500); for (let itemIdx = 0; itemIdx < items.length; itemIdx++) $table.append(as.populateItem(as.getItemTemplate(), items[itemIdx])); + sbm.configureItemTable(as.config, $table); } as.populateItem = function ($item, item) { if (!item) return; - $pnl.msgs.hide().empty(); $item.prop('id', as.getItemId(item)); - $('.AssociationCode', $item).text(item.code); - $('.AssociationTargetName', $item).text(item.targetName); - $('.AssociationType', $item).text(item.typeDesc); - $('.AssociationAddress', $item).text(item.addressSummary); - $('.AssociationNotes', $item).text(item.notes); - $('.AssociationStatusDesc', $item).text(item.statusDesc).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase()); + sbm.populateItemValues(as.config, $item, item.field.value); + let prefix = as.config.column.prefix; + $('.' + prefix + 'Status', $item).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase()); // Actions. var $bgr = $('.sbm-burger', $item).hide(); let $mnu = $('ul.sbm-dropdown-menu', $bgr).empty(); @@ -66,7 +68,7 @@ { let fnUpd = function () { as.updateItem(item) }; $mnu.append(as.getItemMenuOption(sbm.lbl.edit, fnUpd, 'sbm-edit')); - $('.AssociationTargetName', $item).off('click').on('click', fnUpd).addClass('sbm-action-text'); + $('.' + prefix + 'Target', $item).off('click').on('click', fnUpd).addClass('sbm-action-text'); $item.off('dblclick').on('dblclick', fnUpd); } $bgr.toggle(!!$('.sbm-dropdown-item', $mnu).length); @@ -74,7 +76,7 @@ } as.getItemId = function (item) { - return 'Ass_' + (item || {}).id; + return 'Asn_' + (item || {}).id; } //-------------------------------------------------------------- @@ -106,25 +108,25 @@ } //-------------------------------------------------------------- - as.createItem = function () + as.createItem = function (cfg, title) { - as.clearItem(); + as.clearItem(cfg); let $ctrls = $('.sbm-input,.sbm-textarea,.sbm-select', $frm.item); $ctrls.filter('.AssociationType').val('').prop('disabled', false); $ctrls.filter('.AssociationStatus').val(as.data.defaultStatusCode); - $dlg.item.dialog('option', 'title', sbm.dlg.title.createAssociation); - as.openItemDlg(); + as.openItemDlg(cfg, title); } - as.clearItem = function () + as.clearItem = function (cfg) { - sbm.clearControlErrors($frm.item); - $('.sbm-input,.sbm-textarea,.sbm-select', $frm.item).val(''); + sbm.clearItemForm($frm.item); sbm.populateSelectCodeDesc('#cbAssociationType', as.data.associationTypes); sbm.populateSelectCodeDesc('#cbAssociationStatus', as.data.statuses); } - as.openItemDlg = function () + as.openItemDlg = function (cfg, title) { - sbm.openDialog($dlg.item, 600, 640); + sbm.configureItemControls(cfg, $frm.item); + $dlg.item.dialog('option', 'title', title); + sbm.openDialog($dlg.item, 640, 600); } //-------------------------------------------------------------- @@ -137,23 +139,22 @@ as.onUpdateItem = function (response) { //sbm.debug('onUpdateItem', response); - as.clearItem(); if (!response.success) return; + let cfg = response.config || {}; + let prefix = cfg.field.prefix; + as.clearItem(cfg); let item = response.association; + sbm.populateFormValues(cfg, $frm.item, item.field.value); let $ctrls = $('.sbm-input,.sbm-textarea,.sbm-select', $frm.item); $ctrls.filter('.AssociationId').val(item.id); $ctrls.filter('.AssociationExists').val(1); let $ctrlType = $ctrls.filter('.AssociationType'); sbm.selectOrAdd($ctrlType, item.typeCode, item.typeDesc) - if ($ctrlType.val()) $ctrlType.prop('disabled', true); + //if ($ctrlType.val()) $ctrlType.prop('disabled', true); + $ctrls.filter('.AssociationOwnerId').val(item.ownerId); $ctrls.filter('.AssociationTargetId').val(item.targetId); - $ctrls.filter('.AssociationTarget').val(item.targetName); - $ctrls.filter('.AssociationCode').val(item.code); - $ctrls.filter('.AssociationDesc').val(item.desc); - $ctrls.filter('.AssociationNotes').val(item.notes); sbm.selectOrAdd($ctrls.filter('.AssociationStatus'), item.statusCode, item.statusDesc) - $dlg.item.dialog('option', 'title', sbm.dlg.title.updateAssociation); - as.openItemDlg(); + as.openItemDlg(cfg, cfg.title || sbm.dlg.title.updateAssociation); } //-------------------------------------------------------------- @@ -168,6 +169,7 @@ sbm.refreshControlValues(response.controlValues); if (!response.success) return; $dlg.item.dialog('close'); + $pnl.msgs.hide().empty(); var item = response.association; var $item = $('#' + as.getItemId(item), $pnl.table); @@ -176,6 +178,7 @@ $item = as.getItemTemplate(); $('table tbody', $pnl.table).prepend($item).show(); } + let cfg = response.config || {}; as.populateItem($item, item); } diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-contact.js b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-contact.js index 0ae1d77..962f785 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-contact.js +++ b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-contact.js @@ -56,21 +56,17 @@ return $pnl.msgs.append($('
' + sbm.msg.dataNoneFound + '
')).fadeIn(500); for (let itemIdx = 0; itemIdx < items.length; itemIdx++) $table.append(co.populateItem(co.getItemTemplate(), items[itemIdx])); + sbm.configureItemTable(co.config, $table); } co.populateItem = function ($item, item) { if (!item) return; - $pnl.msgs.hide().empty(); $item.prop('id', co.getItemId(item)); - $('.ContactName', $item).text(item.displayName); - $('.ContactType', $item).text(item.typeDesc); + sbm.populateItemValues(co.config, $item, item.field.value); + let prefix = co.config.column.prefix; if (item.associationCount) - $('.ContactAssociationCount', $item).text(item.associationCount).on('click', function () { co.onClickAssociationCount(item); }).addClass('sbm-action-text'); - $('.ContactAddress', $item).text(item.addressSummary); - $('.ContactContact', $item).text(item.contact); - $('.ContactPhone', $item).text(item.phone); - $('.ContactNotes', $item).text(item.notes); - $('.ContactStatusDesc', $item).text(item.statusDesc).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase()); + $('.' + prefix + 'Associations', $item).text(item.associationCount).off('click').on('click', function () { co.onClickAssociationCount(item); }).addClass('sbm-action-text'); + $('.' + prefix + 'Status', $item).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase()); // Actions. var $bgr = $('.sbm-burger', $item).hide(); let $mnu = $('ul.sbm-dropdown-menu', $bgr).empty(); @@ -78,7 +74,7 @@ { let fnUpd = function () { co.updateItem(item) }; $mnu.append(co.getItemMenuOption(sbm.lbl.edit, fnUpd, 'sbm-edit')); - $('.ContactName', $item).off('click').on('click', fnUpd).addClass('sbm-action-text'); + $('.' + prefix + 'Name', $item).off('click').on('click', fnUpd).addClass('sbm-action-text'); $item.off('dblclick').on('dblclick', fnUpd); } $bgr.toggle(!!$('.sbm-dropdown-item', $mnu).length); @@ -121,10 +117,9 @@ co.createItem = function (cfg, title) { co.clearItem(cfg); - let frm = $frm.item; - $('.ContactStatus', frm).val(co.data.defaultStatusCode).prop('readonly', false); - co.configureItemControls(cfg); - co.openItemDlg(title); + let $ctrls = $('.sbm-input,.sbm-textarea,.sbm-select', $frm.item); + $ctrls.filter('.ContactStatus').val(co.data.defaultStatusCode); + co.openItemDlg(cfg, title); } co.clearItem = function (cfg) { @@ -135,30 +130,13 @@ if (cfg.isGroup) $('.ContactIsGroup', frm).val(1); sbm.populateSelectCodeDesc('#cbContactType', co.data.organisationTypes); sbm.populateSelectCodeDesc('#cbContactTitle', co.data.titles); - sbm.selectOrAdd('#cbContactTitle', "", "") sbm.populateSelectCodeDesc('#cbContactSalutation', co.data.salutations); sbm.populateSelectCodeDesc('#cbContactStatus', co.data.statuses); } - sbm.clearItemForm = function ($frm) + co.openItemDlg = function (cfg, title) { - sbm.clearControlErrors($frm); - $('.sbm-input,.sbm-textarea,.sbm-select,.sbm-checkbox', $frm).val('').prop('readonly', false).prop('disabled', false).removeAttr('checked'); - } - co.configureItemControls = function (cfg) - { - sbm.configureItemControls($frm.item, cfg); - } - sbm.configureItemControls = function ($frm, cfg) - { - //sbm.debug('configureItemControls', cfg); - let fld = cfg.field || {}; - let $ctrl = $('.sbm-form-control', $frm.item).show(); - (fld.hide || []).forEach(function (v, i, a) { $ctrl.filter('.' + cfg.field.prefix + v).hide().find('.sbm-input,.sbm-textarea,.sbm-select,.sbm-checkbox').prop('disabled', true); }); - (fld.readonly || []).forEach(function (v, i, a) { $ctrl.filter('.' + cfg.field.prefix + v).find('.sbm-input,.sbm.textarea,.sbm-select,.sbm-checkbox').prop('readonly', true).prop('disabled', true); }); - } - co.openItemDlg = function (title) - { - if (title)$dlg.item.dialog('option', 'title', title); + sbm.configureItemControls(cfg, $frm.item); + $dlg.item.dialog('option', 'title', title); sbm.openDialog($dlg.item, 640, 600); } @@ -172,25 +150,18 @@ co.onUpdateItem = function (response) { //sbm.debug('onUpdateItem', response); - co.clearItem(response.config); if (!response.success) return; + let cfg = response.config || {}; + co.clearItem(cfg); let item = response.contact; + sbm.populateFormValues(cfg, $frm.item, item.field.value); let $ctrls = $('.sbm-input,.sbm-textarea,.sbm-select,.sbm-checkbox', $frm.item); $ctrls.filter('.ContactId').val(item.id); $ctrls.filter('.ContactExists').val(1); $ctrls.filter('.ContactType').val(item.typeCode); $ctrls.filter('.ContactProspect').prop('checked', !!item.prospect); - $ctrls.filter('.ContactNotes').val(item.notes); $ctrls.filter('.ContactStatus').val(item.statusCode); - sbm.populateFieldValues(response.config, $frm.item, item.field); - co.configureItemControls(response.config); - co.openItemDlg(sbm.dlg.title.updateContact); - } - sbm.populateFieldValues = function (cfg, $frm, fld) - { - let val = (fld || {}).value || []; - let $ctrl = $('.sbm-form-control', $frm.item).show(); - for (var name in val) { $ctrl.filter('.' + cfg.field.prefix + name).find('.sbm-input,.sbm-textarea,.sbm-select').val(val[name]).end().find('.sbm-checkbox').prop('checked',!!val[name]); }; + co.openItemDlg(cfg, sbm.dlg.title.updateContact); } //-------------------------------------------------------------- @@ -205,6 +176,7 @@ sbm.refreshControlValues(response.controlValues); if (!response.success) return; $dlg.item.dialog('close'); + $pnl.msgs.hide().empty(); var item = response.contact; var $item = $('#' + co.getItemId(item), $pnl.table); @@ -219,11 +191,12 @@ //-------------------------------------------------------------- co.onClickAssociationCount = function (item) { + sbm.debug('onClickAssociationCount'); if (!item.id) return; - sbm.doPleaseWait(); - let frm = $frm.itemId; - $('.ContactId', frm).val(item.id); - frm.prop('action', sbm.url.base + 'Association').submit(); + //sbm.doPleaseWait(); + //let frm = $frm.itemId; + //$('.ContactId', frm).val(item.id); + //frm.prop('action', sbm.url.base + 'Association').submit(); } //-------------------------------------------------------------- diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-main.js b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-main.js index 128653e..30b5dc9 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-main.js +++ b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-main.js @@ -154,6 +154,41 @@ sbm.resultsPaging.fn.refreshPaging(response.paging, context, refreshFn); } + //-------------------------------------------------------------- + sbm.configureItemTable = function (cfg, $sel) + { + //sbm.debug('configureItemTable', cfg, $sel); + let col = cfg.column || {}; + let $cell = $('th,td', $sel).removeClass('hidden'); + (col.hide || []).forEach(function (v, i, a) { $cell.filter('.' + col.prefix + v).addClass('hidden'); }); + } + sbm.populateItemValues = function (cfg, $item, val) + { + //sbm.debug('populateItemValues', cfg, $item, val); + for (var name in val || []) { $item.find('.' + cfg.column.prefix + name).text(val[name]); }; + } + sbm.clearItemForm = function ($frm) + { + //sbm.clearControlErrors($frm); + $('.sbm-input,.sbm-textarea,.sbm-select', $frm).val('').prop('readonly', false).prop('disabled', false); + $('.sbm-checkbox', $frm).prop('readonly', false).prop('disabled', false).removeAttr('checked'); + } + sbm.configureItemControls = function (cfg, $frm) + { + //sbm.debug('configureItemControls', cfg); + let fld = cfg.field || {}; + let $ctrl = $('.sbm-form-control', $frm).show(); + for (var name in fld.label || {}) { /* ... */ }; + (fld.hide || []).forEach(function (v, i, a) { $ctrl.filter('.' + fld.prefix + v).hide().find('.sbm-input,.sbm-textarea,.sbm-select,.sbm-checkbox').prop('disabled', true); }); + (fld.readonly || []).forEach(function (v, i, a) { $ctrl.filter('.' + fld.prefix + v).find('.sbm-input,.sbm.textarea,.sbm-select,.sbm-checkbox').prop('readonly', true).prop('disabled', true); }); + } + sbm.populateFormValues = function (cfg, $frm, val) + { + //sbm.debug('populateFormValues', cfg, $frm, val); + 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]); }; + } + //-------------------------------------------------------------- // Page navigation. sbm.navigateTo = function (action) @@ -221,7 +256,7 @@ sbm.$dlg.alert = $('
').dialog(opt); } $('#dlgAlertMsg', sbm.$dlg.alert).html(msg.replace(/\\n/g, '
')); - let btns = []; + let btns = {}; btns[sbm.lbl.ok] = function () { $(this).dialog('close'); if (onOk) onOk(); }; sbm.$dlg.alert.dialog('option', { title: title || sbm.dlg.title.alert, buttons: btns }); sbm.openDialog(sbm.$dlg.alert); @@ -236,9 +271,10 @@ if (!sbm.isDef(sbm.$dlg.confirm)) { var opt = sbm.dlgOpts(); + opt.dialogClass += " sbm-dark-blue"; sbm.$dlg.confirm = $('
').dialog(opt); } - var btns = []; + let btns = {}; btns[sbm.lbl.yes] = function () { $(this).dialog('close'); if (onOk) onOk(); }; btns[sbm.lbl.no] = function () { $(this).dialog('close'); if (onCancel) onCancel(); }; sbm.$dlg.confirm.dialog('option', { title: title || sbm.dlg.title.confirm, buttons: btns });