Extract paired business object projects
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Currencies.
|
||||
//=======================================================================
|
||||
public abstract partial class SaReferenceDataMgr : SacsItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Create currency.
|
||||
public abstract SaCurrency CreateCurrency();
|
||||
|
||||
// Retrieve individual currencies.
|
||||
public abstract bool CurrencyExistsById(SysId id);
|
||||
public abstract bool CurrencyExistsByCode(String code);
|
||||
public abstract SaCurrency GetCurrencyById(SysId id);
|
||||
public abstract SaCurrency GetCurrencyByCode(String code);
|
||||
public abstract SaCurrency GetCurrency(SaCurrency.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate currency data.
|
||||
public bool IsValidCurrency(SaCurrency currency)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (currency == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidCurrencyData(currency.GetData(), new SaCurrency.ErrField());
|
||||
}
|
||||
public virtual bool IsValidCurrencyData(SaCurrency.Data data, SaCurrency.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
// Currency properties.
|
||||
if (errField.Code != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Code, "code", (long)SaReferenceDataDbDfn.GetColTextLen(SaReferenceDataDbDfn.ColumnIdx.Currency_Code), true))
|
||||
{
|
||||
errField.Code = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Name != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Name, "name", (long)SaReferenceDataDbDfn.GetColTextLen(SaReferenceDataDbDfn.ColumnIdx.Currency_Name), true))
|
||||
{
|
||||
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Division != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Division, "division", (long)SaReferenceDataDbDfn.GetColTextLen(SaReferenceDataDbDfn.ColumnIdx.Currency_Division)))
|
||||
{
|
||||
errField.Division = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Symbol != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Symbol, "symbol", (long)SaReferenceDataDbDfn.GetColTextLen(SaReferenceDataDbDfn.ColumnIdx.Currency_Symbol), true))
|
||||
{
|
||||
errField.Symbol = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Decimals != SacsHierarchyItem.ValidValue.Ignore && (data.Decimals < 0 || data.Decimals > 4))
|
||||
{
|
||||
errField.Decimals = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Currency decimals must be between 0 and 4");
|
||||
}
|
||||
// Validate associated data.
|
||||
if (errField.RegionId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionId))
|
||||
{
|
||||
if (!RegionExistsById(data.RegionId))
|
||||
{
|
||||
errField.RegionId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Currency's region not found");
|
||||
}
|
||||
}
|
||||
if (errField.CurrencyIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.CurrencyIdPrimary))
|
||||
{
|
||||
if (!CurrencyExistsById(data.CurrencyIdPrimary))
|
||||
{
|
||||
errField.CurrencyIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Currency's primary not found");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Currency database interface.
|
||||
public abstract bool InsertCurrency(SaCurrency currency, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateCurrency(SaCurrency currency, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool CurrencyCanBeDeleted(SaCurrency currency)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (currency == null) return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
if (currency.HasDependentCurrencies()) return SetErrorState("Has dependent currencies");
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteCurrency(SaCurrency currency, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Currency list.
|
||||
public abstract ColumnDfn GetCurrencyColumnDfn(SaCurrency.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetCurrencyQueryFilter(SaCurrency.Params prm);
|
||||
public abstract long GetCurrencyCount(SaCurrency.Params prm);
|
||||
public abstract List<SaCurrency> GetCurrencyList(SaCurrency.Params prm);
|
||||
public abstract DbResultSet ExecuteCurrencyQuery(List<ColumnDfn> columns, SaCurrency.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetCurrencyDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
/*
|
||||
switch ((SaCurrency.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaCurrency.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaCurrency.Column.Status_Desc:
|
||||
case SaCurrency.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaCurrency.Column.Status_Desc)
|
||||
{
|
||||
String statusDesc = SacsSystem.GetStatusDescForCode(statusCode);
|
||||
value = new DataValue(statusDesc);
|
||||
}
|
||||
else if (column.Id == (int)SaCurrency.Column.Status_Ind)
|
||||
{
|
||||
DataValue.TriStateType triState = DataValue.TriStateType.Unknown;
|
||||
if (status == SaStatus.Active)
|
||||
triState = DataValue.TriStateType.Green;
|
||||
else if (status == SaStatus.Inactive)
|
||||
triState = DataValue.TriStateType.Red;
|
||||
value = new DataValue(triState);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
*/
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user