This commit is contained in:
Andy Howard
2024-11-26 11:33:22 +00:00
parent 8b872cc8f3
commit c8b5df5909
56 changed files with 1122 additions and 860 deletions
@@ -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); }
}