BusinessMgr 3.0.0.4
This commit is contained in:
@@ -397,6 +397,27 @@ namespace Sacs.Web.Components
|
||||
public List<StatData> Stats { get; } = new List<StatData>();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Reference data.
|
||||
|
||||
// Tax codes.
|
||||
public class TaxCode
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Code { get; set; }
|
||||
public string Caption { get; set; }
|
||||
public decimal Rate { get; set; }
|
||||
}
|
||||
|
||||
// Units of Measure.
|
||||
public class UomData
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Category { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Caption { get; set; }
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Form data.
|
||||
public class FormControlValue
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager.
|
||||
//=======================================================================
|
||||
public abstract partial class SaReferenceDataMgr : SacsItemMgr
|
||||
{
|
||||
@@ -16,7 +18,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaReferenceDataMgr ()
|
||||
protected SaReferenceDataMgr()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -6,31 +6,31 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Currencies.
|
||||
//=======================================================================
|
||||
public abstract partial class SaReferenceDataMgr : SacsItemMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// C u r r e n c i e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Create currency.
|
||||
public abstract SaCurrency CreateCurrency ();
|
||||
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);
|
||||
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)
|
||||
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)
|
||||
public virtual bool IsValidCurrencyData(SaCurrency.Data data, SaCurrency.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
// Currency properties.
|
||||
@@ -81,31 +81,31 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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)
|
||||
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(Msg_ItemNotSpecified);
|
||||
if (currency.HasDependentCurrencies()) return SetErrorState("Has dependent currencies");
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteCurrency (SaCurrency currency, DbUpdateInfo dbUpdateInfo);
|
||||
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);
|
||||
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)
|
||||
public virtual DataValue GetCurrencyDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
/*
|
||||
|
||||
@@ -7,31 +7,31 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Languages.
|
||||
//=======================================================================
|
||||
public abstract partial class SaReferenceDataMgr : SacsItemMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// L a n g u a g e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual languages.
|
||||
public abstract bool LanguageExistsById (SysId id);
|
||||
public abstract bool LanguageExistsByCode (String code);
|
||||
public abstract SaLanguage GetLanguageById (SysId id);
|
||||
public abstract SaLanguage GetLanguageByCode (String code);
|
||||
public abstract SaLanguage GetLanguage (SaLanguage.Params prm);
|
||||
public abstract bool LanguageExistsById(SysId id);
|
||||
public abstract bool LanguageExistsByCode(String code);
|
||||
public abstract SaLanguage GetLanguageById(SysId id);
|
||||
public abstract SaLanguage GetLanguageByCode(String code);
|
||||
public abstract SaLanguage GetLanguage(SaLanguage.Params prm);
|
||||
|
||||
// Create language.
|
||||
public abstract SaLanguage CreateLanguage ();
|
||||
public abstract SaLanguage CreateLanguage();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate language data.
|
||||
public bool IsValidLanguage (SaLanguage language)
|
||||
public bool IsValidLanguage(SaLanguage language)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (language == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidLanguageData(language.GetData(), new SaLanguage.ErrField());
|
||||
}
|
||||
public virtual bool IsValidLanguageData (SaLanguage.Data data, SaLanguage.ErrField errField)
|
||||
public virtual bool IsValidLanguageData(SaLanguage.Data data, SaLanguage.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
// Language properties.
|
||||
@@ -70,31 +70,31 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Language database interface.
|
||||
public abstract bool InsertLanguage (SaLanguage language, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateLanguage (SaLanguage language, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool LanguageCanBeDeleted (SaLanguage language)
|
||||
public abstract bool InsertLanguage(SaLanguage language, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateLanguage(SaLanguage language, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool LanguageCanBeDeleted(SaLanguage language)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (language == null) return SetErrorState(Msg_ItemNotSpecified);
|
||||
if (language.HasDependentLanguages()) return SetErrorState("Has dependent languages");
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteLanguage (SaLanguage language, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool DeleteLanguage(SaLanguage language, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Language list.
|
||||
public abstract ColumnDfn GetLanguageColumnDfn (SaLanguage.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetLanguageQueryFilter (SaLanguage.Params prm);
|
||||
public abstract long GetLanguageCount (SaLanguage.Params prm);
|
||||
public abstract List<SaLanguage> GetLanguageList (SaLanguage.Params prm);
|
||||
public abstract DbResultSet ExecuteLanguageQuery (List<ColumnDfn> columns, SaLanguage.Params prm);
|
||||
public abstract ColumnDfn GetLanguageColumnDfn(SaLanguage.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetLanguageQueryFilter(SaLanguage.Params prm);
|
||||
public abstract long GetLanguageCount(SaLanguage.Params prm);
|
||||
public abstract List<SaLanguage> GetLanguageList(SaLanguage.Params prm);
|
||||
public abstract DbResultSet ExecuteLanguageQuery(List<ColumnDfn> columns, SaLanguage.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 GetLanguageDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public virtual DataValue GetLanguageDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaLanguage.Column)column.Id)
|
||||
@@ -104,7 +104,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
default:
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Regions.
|
||||
//=======================================================================
|
||||
public abstract partial class SaReferenceDataMgr : SacsItemMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// R e g i o n s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
/// <summary>Return the valid parent type for the specified Region type.</summary>
|
||||
public static SaRegionType ParentTypeFor (SaRegionType regionType)
|
||||
public static SaRegionType ParentTypeFor(SaRegionType regionType)
|
||||
{
|
||||
if (regionType == SaRegionType.Country) return SaRegionType.Continent;
|
||||
if (regionType == SaRegionType.Province) return SaRegionType.Country;
|
||||
@@ -23,7 +23,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
return SaRegionType.Unknown;
|
||||
}
|
||||
/// <summary>Return the valid subordinate Region type for the specified Region type.</summary>
|
||||
public static SaRegionType SubordinateTypeFor (SaRegionType regionType)
|
||||
public static SaRegionType SubordinateTypeFor(SaRegionType regionType)
|
||||
{
|
||||
if (regionType == SaRegionType.Continent) return SaRegionType.Country;
|
||||
if (regionType == SaRegionType.Country) return SaRegionType.Province;
|
||||
@@ -33,24 +33,24 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual regions.
|
||||
public abstract bool RegionExistsById (SysId id);
|
||||
public abstract bool RegionExistsByType (String type);
|
||||
public abstract SaRegion GetRegionById (SysId id);
|
||||
public abstract SaRegion GetRegionByType (String type);
|
||||
public abstract SaRegion GetRegion (SaRegion.Params prm);
|
||||
public abstract bool RegionExistsById(SysId id);
|
||||
public abstract bool RegionExistsByType(String type);
|
||||
public abstract SaRegion GetRegionById(SysId id);
|
||||
public abstract SaRegion GetRegionByType(String type);
|
||||
public abstract SaRegion GetRegion(SaRegion.Params prm);
|
||||
|
||||
// Create region.
|
||||
public abstract SaRegion CreateRegion (SaRegionType regionType);
|
||||
public abstract SaRegion CreateRegion(SaRegionType regionType);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate region data.
|
||||
public bool IsValidRegion (SaRegion region)
|
||||
public bool IsValidRegion(SaRegion region)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (region == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidRegionData(region.GetData(), new SaRegion.ErrField());
|
||||
}
|
||||
public virtual bool IsValidRegionData (SaRegion.Data data, SaRegion.ErrField errField)
|
||||
public virtual bool IsValidRegionData(SaRegion.Data data, SaRegion.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
// Region properties.
|
||||
@@ -92,9 +92,9 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Region database interface.
|
||||
public abstract bool InsertRegion (SaRegion region, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateRegion (SaRegion region, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool RegionCanBeDeleted (SaRegion region)
|
||||
public abstract bool InsertRegion(SaRegion region, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateRegion(SaRegion region, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool RegionCanBeDeleted(SaRegion region)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (region == null) return SetErrorState(Msg_ItemNotSpecified);
|
||||
@@ -103,22 +103,22 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
if (region.HasDependentTaxCodes()) return SetErrorState("Has dependent tax codes");
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteRegion (SaRegion region, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool DeleteRegion(SaRegion region, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Region list.
|
||||
public abstract ColumnDfn GetRegionColumnDfn (SaRegion.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetRegionQueryFilter (SaRegion.Params prm);
|
||||
public abstract long GetRegionCount (SaRegion.Params prm);
|
||||
public abstract List<SaRegion> GetRegionList (SaRegion.Params prm);
|
||||
public abstract DbResultSet ExecuteRegionQuery (List<ColumnDfn> columns, SaRegion.Params prm);
|
||||
public abstract ColumnDfn GetRegionColumnDfn(SaRegion.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetRegionQueryFilter(SaRegion.Params prm);
|
||||
public abstract long GetRegionCount(SaRegion.Params prm);
|
||||
public abstract List<SaRegion> GetRegionList(SaRegion.Params prm);
|
||||
public abstract DbResultSet ExecuteRegionQuery(List<ColumnDfn> columns, SaRegion.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 GetRegionDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public virtual DataValue GetRegionDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaRegion.Column)column.Id)
|
||||
@@ -134,17 +134,17 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
// Status.
|
||||
case SaRegion.Column.Status_Desc:
|
||||
case SaRegion.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaRegion.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode));
|
||||
else if (column.Id == (int)SaRegion.Column.Status_Ind)
|
||||
value = new DataValue(SaRegion.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaRegion.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode));
|
||||
else if (column.Id == (int)SaRegion.Column.Status_Ind)
|
||||
value = new DataValue(SaRegion.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Tax Codes.
|
||||
//=======================================================================
|
||||
public abstract partial class SaReferenceDataMgr : SacsItemMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// T a x C o d e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public String GetTaxCode (SaTaxCodeType taxCode)
|
||||
public String GetTaxCode(SaTaxCodeType taxCode)
|
||||
{
|
||||
switch (taxCode)
|
||||
{
|
||||
@@ -27,24 +27,24 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual taxCodes.
|
||||
public abstract bool TaxCodeExistsById (SysId id);
|
||||
public abstract bool TaxCodeExistsByCode (String code);
|
||||
public abstract SaTaxCode GetTaxCodeById (SysId id);
|
||||
public abstract SaTaxCode GetTaxCodeByCode (String code);
|
||||
public abstract SaTaxCode GetTaxCode (SaTaxCode.Params prm);
|
||||
public abstract bool TaxCodeExistsById(SysId id);
|
||||
public abstract bool TaxCodeExistsByCode(String code);
|
||||
public abstract SaTaxCode GetTaxCodeById(SysId id);
|
||||
public abstract SaTaxCode GetTaxCodeByCode(String code);
|
||||
public abstract SaTaxCode GetTaxCode(SaTaxCode.Params prm);
|
||||
|
||||
// Create taxCode.
|
||||
public abstract SaTaxCode CreateTaxCode ();
|
||||
public abstract SaTaxCode CreateTaxCode();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate taxCode data.
|
||||
public bool IsValidTaxCode (SaTaxCode taxCode)
|
||||
public bool IsValidTaxCode(SaTaxCode taxCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (taxCode == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidTaxCodeData(taxCode.GetData(), new SaTaxCode.ErrField());
|
||||
}
|
||||
public virtual bool IsValidTaxCodeData (SaTaxCode.Data data, SaTaxCode.ErrField errField)
|
||||
public virtual bool IsValidTaxCodeData(SaTaxCode.Data data, SaTaxCode.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
// TaxCode properties.
|
||||
@@ -119,30 +119,30 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode database interface.
|
||||
public abstract bool InsertTaxCode (SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateTaxCode (SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool TaxCodeCanBeDeleted (SaTaxCode taxCode)
|
||||
public abstract bool InsertTaxCode(SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateTaxCode(SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool TaxCodeCanBeDeleted(SaTaxCode taxCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (taxCode.HasDependentTaxCodes()) return SetErrorState("Has dependent tax codes");
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteTaxCode (SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool DeleteTaxCode(SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode list.
|
||||
public abstract ColumnDfn GetTaxCodeColumnDfn (SaTaxCode.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetTaxCodeQueryFilter (SaTaxCode.Params prm);
|
||||
public abstract long GetTaxCodeCount (SaTaxCode.Params prm);
|
||||
public abstract List<SaTaxCode> GetTaxCodeList (SaTaxCode.Params prm);
|
||||
public abstract DbResultSet ExecuteTaxCodeQuery (List<ColumnDfn> columns, SaTaxCode.Params prm);
|
||||
public abstract ColumnDfn GetTaxCodeColumnDfn(SaTaxCode.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetTaxCodeQueryFilter(SaTaxCode.Params prm);
|
||||
public abstract long GetTaxCodeCount(SaTaxCode.Params prm);
|
||||
public abstract List<SaTaxCode> GetTaxCodeList(SaTaxCode.Params prm);
|
||||
public abstract DbResultSet ExecuteTaxCodeQuery(List<ColumnDfn> columns, SaTaxCode.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 GetTaxCodeDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public virtual DataValue GetTaxCodeDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaTaxCode.Column)column.Id)
|
||||
@@ -158,17 +158,17 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
// Status.
|
||||
case SaTaxCode.Column.Status_Desc:
|
||||
case SaTaxCode.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaTaxCode.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode));
|
||||
else if (column.Id == (int)SaTaxCode.Column.Status_Ind)
|
||||
value = new DataValue(SaTaxCode.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaTaxCode.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode));
|
||||
else if (column.Id == (int)SaTaxCode.Column.Status_Ind)
|
||||
value = new DataValue(SaTaxCode.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -7,34 +7,34 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Units of Measure.
|
||||
//=======================================================================
|
||||
public abstract partial class SaReferenceDataMgr : SacsItemMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// U n i t s o f M e a s u r e
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual unitMeasures.
|
||||
public abstract bool UnitMeasureExistsById (SysId id);
|
||||
public abstract bool UnitMeasureExistsByCode (String code);
|
||||
public abstract SaUnitMeasure GetUnitMeasureById (SysId id);
|
||||
public abstract SaUnitMeasure GetUnitMeasureByCode (String code);
|
||||
public abstract SaUnitMeasure GetUnitMeasure (SaUnitMeasure.Params prm);
|
||||
public abstract bool UnitMeasureExistsById(SysId id);
|
||||
public abstract bool UnitMeasureExistsByCode(String code);
|
||||
public abstract SaUnitMeasure GetUnitMeasureById(SysId id);
|
||||
public abstract SaUnitMeasure GetUnitMeasureByCode(String code);
|
||||
public abstract SaUnitMeasure GetUnitMeasure(SaUnitMeasure.Params prm);
|
||||
|
||||
// Create unitMeasure.
|
||||
public abstract SaUnitMeasure CreateUnitMeasure ();
|
||||
public abstract SaUnitMeasure CreateUnitMeasure();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate unitMeasure data.
|
||||
public bool IsValidUnitMeasure (SaUnitMeasure unitMeasure)
|
||||
public bool IsValidUnitMeasure(SaUnitMeasure unitMeasure)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (unitMeasure == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUnitMeasureData(unitMeasure.GetData(), new SaUnitMeasure.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUnitMeasureData (SaUnitMeasure.Data data, SaUnitMeasure.ErrField errField)
|
||||
public virtual bool IsValidUnitMeasureData(SaUnitMeasure.Data data, SaUnitMeasure.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
// UnitMeasure properties.
|
||||
@@ -128,30 +128,30 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UnitMeasure database interface.
|
||||
public abstract bool InsertUnitMeasure (SaUnitMeasure unitMeasure, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUnitMeasure (SaUnitMeasure unitMeasure, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UnitMeasureCanBeDeleted (SaUnitMeasure unitMeasure)
|
||||
public abstract bool InsertUnitMeasure(SaUnitMeasure unitMeasure, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUnitMeasure(SaUnitMeasure unitMeasure, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UnitMeasureCanBeDeleted(SaUnitMeasure unitMeasure)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (unitMeasure.HasDependentUnitsOfMeasure()) return SetErrorState("Has dependent UOMs");
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUnitMeasure (SaUnitMeasure unitMeasure, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool DeleteUnitMeasure(SaUnitMeasure unitMeasure, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UnitMeasure list.
|
||||
public abstract ColumnDfn GetUnitMeasureColumnDfn (SaUnitMeasure.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUnitMeasureQueryFilter (SaUnitMeasure.Params prm);
|
||||
public abstract long GetUnitMeasureCount (SaUnitMeasure.Params prm);
|
||||
public abstract List<SaUnitMeasure> GetUnitMeasureList (SaUnitMeasure.Params prm);
|
||||
public abstract DbResultSet ExecuteUnitMeasureQuery (List<ColumnDfn> columns, SaUnitMeasure.Params prm);
|
||||
public abstract ColumnDfn GetUnitMeasureColumnDfn(SaUnitMeasure.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUnitMeasureQueryFilter(SaUnitMeasure.Params prm);
|
||||
public abstract long GetUnitMeasureCount(SaUnitMeasure.Params prm);
|
||||
public abstract List<SaUnitMeasure> GetUnitMeasureList(SaUnitMeasure.Params prm);
|
||||
public abstract DbResultSet ExecuteUnitMeasureQuery(List<ColumnDfn> columns, SaUnitMeasure.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 GetUnitMeasureDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public virtual DataValue GetUnitMeasureDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaUnitMeasure.Column)column.Id)
|
||||
@@ -167,17 +167,17 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
// Status.
|
||||
case SaUnitMeasure.Column.Status_Desc:
|
||||
case SaUnitMeasure.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaUnitMeasure.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode));
|
||||
else if (column.Id == (int)SaUnitMeasure.Column.Status_Ind)
|
||||
value = new DataValue(SaUnitMeasure.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaUnitMeasure.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode));
|
||||
else if (column.Id == (int)SaUnitMeasure.Column.Status_Ind)
|
||||
value = new DataValue(SaUnitMeasure.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data ()
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
get { return data.TaxCodeIdLink; }
|
||||
set { CheckChanged(data.TaxCodeIdLink, value); data.TaxCodeIdLink = value; }
|
||||
}
|
||||
internal void PopulateFrom (Data data)
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
Code = data.Code;
|
||||
CodeAlt1 = data.CodeAlt1;
|
||||
@@ -128,7 +128,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
TaxCodeIdLink = data.TaxCodeIdLink;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone ()
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
@@ -158,7 +158,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaTaxCode (SysId id) : base(id)
|
||||
protected SaTaxCode(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState (SaStatus status)
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
@@ -184,8 +184,22 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities. - this is for the EffectiveOn Date 'From' & 'To'
|
||||
public bool IsEffectiveOn (DateTime effectiveDate)
|
||||
// Utilities.
|
||||
|
||||
public String GetCaption()
|
||||
{
|
||||
DateTime today = DateTime.Today;
|
||||
String caption = $"{Code} (" + (!StringUtil.IsBlank(CodeAlt1) ? $"{CodeAlt1}: " : "") + $"{TaxRate.ToString("N2")})";
|
||||
if (DateUtil.IsValid(EffectFrom) || DateUtil.IsValid(EffectTo))
|
||||
{
|
||||
String effectiveFrom = (DateUtil.IsValid(EffectFrom) ? (EffectFrom.Year == today.Year ? EffectFrom.ToString("d-MMM") : EffectFrom.ToString("d-MMM-yy")) : "");
|
||||
String effectiveTo = (DateUtil.IsValid(EffectTo) ? (EffectTo.Year == today.Year ? EffectTo.ToString("d-MMM") : EffectTo.ToString("d-MMM-yy")) : "");
|
||||
caption += $" [{effectiveFrom}->{effectiveTo}]";
|
||||
}
|
||||
return caption;
|
||||
}
|
||||
|
||||
public bool IsEffectiveOn(DateTime effectiveDate)
|
||||
{
|
||||
if (DateUtil.IsValid(EffectFrom) && EffectFrom.CompareTo(effectiveDate) > 0) return false;
|
||||
if (DateUtil.IsValid(EffectTo) && EffectTo.CompareTo(effectiveDate) < 0) return false;
|
||||
@@ -194,8 +208,8 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public Data GetData () { return data.Clone(); }
|
||||
public void SetData (Data data)
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
@@ -262,7 +276,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasDependentTaxCodes ();
|
||||
public abstract bool HasDependentTaxCodes();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
@@ -301,23 +315,23 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
public static class SaTaxCodeList
|
||||
{
|
||||
/// <summary>Check whether taxcode exists/locate in list with specified Id.</summary>
|
||||
public static bool ExistsById (this List<SaTaxCode> values, SysId taxId)
|
||||
public static bool ExistsById(this List<SaTaxCode> values, SysId taxId)
|
||||
{
|
||||
if (!SysId.IsValid(taxId)) return false;
|
||||
return values.Exists(item => item.Id.Equals(taxId));
|
||||
}
|
||||
/// <summary>Retrieve tax code with specified Id.</summary>
|
||||
public static SaTaxCode FindById (this List<SaTaxCode> values, SysId taxId)
|
||||
public static SaTaxCode FindById(this List<SaTaxCode> values, SysId taxId)
|
||||
{
|
||||
if (!SysId.IsValid(taxId)) return null;
|
||||
return values.Find(item => item.Id.Equals(taxId));
|
||||
}
|
||||
public static SaTaxCode FindByCode (this List<SaTaxCode> values, String taxCode)
|
||||
public static SaTaxCode FindByCode(this List<SaTaxCode> values, String taxCode)
|
||||
{
|
||||
if (StringUtil.IsEmpty(taxCode)) return null;
|
||||
return values.Find(item => item.Code.Equals(taxCode));
|
||||
}
|
||||
public static SaTaxCode FindByCodeEffectiveOn (this List<SaTaxCode> values, String taxCode, DateTime effectiveOn)
|
||||
public static SaTaxCode FindByCodeEffectiveOn(this List<SaTaxCode> values, String taxCode, DateTime effectiveOn)
|
||||
{
|
||||
if (StringUtil.IsEmpty(taxCode)) return null;
|
||||
if (!DateUtil.IsValid(effectiveOn)) return null;
|
||||
|
||||
@@ -209,6 +209,12 @@ namespace Sarand.Net.Standard.Base.ReferenceData
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
/// <summary>UOM caption - Multiple label is specified, otherwise Single label.</summary>
|
||||
public String GetCaption()
|
||||
{
|
||||
return StringUtil.OnBlank(Multiple, Single, Abbr, Code);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public Data GetData () { return data.Clone(); }
|
||||
|
||||
@@ -7,6 +7,7 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.Base
|
||||
{
|
||||
@@ -32,9 +33,9 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
private void LogSql(String sql)
|
||||
protected void LogSql(String fn, String sql)
|
||||
{
|
||||
SaLogger.Debug(GetType().Name + " SQL: " + sql);
|
||||
SaLogger.Debug($"{fn} SQL: {sql}");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -174,9 +175,9 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
// Database Index stats.
|
||||
public class IndexStats
|
||||
{
|
||||
public int PrimaryIndicesCreated { get; set; } = 0;
|
||||
public int IndicesCreated { get; set; } = 0;
|
||||
public int IndicesDropped { get; set; } = 0;
|
||||
public int PrimaryIndicesCreated { get; set; }
|
||||
public int IndicesCreated { get; set; }
|
||||
public int IndicesDropped { get; set; }
|
||||
public List<String> Stats
|
||||
{
|
||||
get
|
||||
@@ -194,59 +195,20 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Drop index.
|
||||
protected bool DropDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String indexName)
|
||||
protected bool ColumnsExist(String fn, DbDfnTable dfnTable, HashSet<String> columnNames)
|
||||
{
|
||||
if (database == null || HasErrorState()) return false;
|
||||
if (!database.TableExists(tableName)) return true;
|
||||
DbDfnTable dfnTbl = database.GetTableDfn(tableName, true);
|
||||
if (!dfnTbl.HasIndexByName(indexName)) // Should also check the columns and their sequence in the index.
|
||||
HashSet<String> missingColumnNames = new HashSet<string>();
|
||||
foreach (String columnName in columnNames)
|
||||
{
|
||||
// Drop index:
|
||||
// MS Access: DROP INDEX index_name ON table_name
|
||||
// MS SQL Server: DROP INDEX table_name.index_name
|
||||
// DB2/Oracle: DROP INDEX index_name
|
||||
// MySQL: ALTER TABLE table_name DROP INDEX index_name
|
||||
String query = "DROP INDEX [" + indexName + "] ON [" + tableName + "]";
|
||||
LogSql(query);
|
||||
if (database.DbmsType == DbmsType.MsSql)
|
||||
query = "DROP INDEX [" + tableName + "].[" + indexName + "]";
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
if (!database.HasErrorState())
|
||||
indexStats.IndicesDropped++;
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: " + tableName + "; Index: " + indexName + "; Exception: " + database.ErrorStateMessage);
|
||||
#endif
|
||||
SetErrorState("Failed to drop index " + indexName + " on " + tableName + " - " + database.ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
if (!dfnTable.HasColumnByName(columnName))
|
||||
missingColumnNames.Add(columnName);
|
||||
}
|
||||
else
|
||||
if (missingColumnNames.Any())
|
||||
{
|
||||
// Assume this is the Primary Key:
|
||||
String query = "ALTER TABLE [" + tableName + "] DROP CONSTRAINT [" + indexName + "]";
|
||||
LogSql(query);
|
||||
//if (database.DbmsType() == eSaDbmsMsSql)
|
||||
// sQry = "DROP INDEX ["+tableName+"].["+indexName+"]";
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
if (!database.HasErrorState())
|
||||
indexStats.IndicesDropped++;
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: " + tableName + "; Index: " + indexName + "; Exception: " + database.ErrorStateMessage);
|
||||
#endif
|
||||
SetErrorState("Failed to drop primary key " + indexName + " on " + tableName + " - " + database.ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
SaLogger.Warn($"{fn} {dfnTable.Name} Table is missing columns for index creation: {missingColumnNames.Concat(", ")}.");
|
||||
return false;
|
||||
}
|
||||
return OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -254,18 +216,19 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
protected bool CreatePrimaryDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String columnsCsv, bool dropIndicesIfNotExist = true)
|
||||
{
|
||||
if (database == null || HasErrorState()) return false;
|
||||
if (!database.TableExists(tableName)) return true;
|
||||
List<String> lColumn = StringListUtil.Split(columnsCsv, ",");
|
||||
DbDfnTable dfnTbl = database.GetTableDfn(tableName, true);
|
||||
DbDfnTable dfnTable = database.GetTableDfn(tableName, true);
|
||||
if (dfnTable == null) return true;
|
||||
HashSet<String> columnNames = new HashSet<String>(Regex.Split(columnsCsv, "[\\s,;\\-+]+").Where(s => !StringUtil.IsEmpty(s)));
|
||||
if (!ColumnsExist(SysUtil.Fn, dfnTable, columnNames)) return false;
|
||||
|
||||
String indexName = "PK_" + tableName;
|
||||
if (!dfnTbl.HasIndexByName(indexName))
|
||||
if (!dfnTable.HasIndexByName(indexName))
|
||||
{
|
||||
if (dropIndicesIfNotExist)
|
||||
{
|
||||
foreach (DbDfnIndex indexDfn in dfnTbl.Indices)
|
||||
{
|
||||
// All existing indices are dropped
|
||||
foreach (DbDfnIndex indexDfn in dfnTable.Indices)
|
||||
DropDbIndex(database, indexStats, tableName, indexDfn.Name);
|
||||
}
|
||||
}
|
||||
if (!HasErrorState())
|
||||
{
|
||||
@@ -276,10 +239,10 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
// ADD CONSTRAINT [PK_Individual_CustomerID]
|
||||
// PRIMARY KEY CLUSTERED
|
||||
// ([CustomerID] ASC)
|
||||
String query = "ALTER TABLE [" + tableName + "] ADD CONSTRAINT [" + indexName + "] PRIMARY KEY (" + lColumn.Concat(",", "[", "]") + ")";
|
||||
String query = $"ALTER TABLE [{tableName}] ADD CONSTRAINT [{indexName}] PRIMARY KEY ({columnNames.Concat(",", "[", "]")})";
|
||||
if (database.DbmsType == DbmsType.MsSql)
|
||||
query = "ALTER TABLE [" + tableName + "] ADD CONSTRAINT [" + indexName + "] PRIMARY KEY CLUSTERED (" + lColumn.Concat(",", "[", "]") + ")";
|
||||
LogSql(query);
|
||||
query = $"ALTER TABLE [{tableName}] ADD CONSTRAINT [{indexName}] PRIMARY KEY CLUSTERED ({columnNames.Concat(",", "[", "]")})";
|
||||
LogSql(SysUtil.Fn, query);
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
@@ -287,10 +250,8 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
indexStats.PrimaryIndicesCreated++;
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: %" + tableName + "; Index: " + indexName + "; Exception: " + database.ErrorStateMessage);
|
||||
#endif
|
||||
SetErrorState("Failed to create primary index " + indexName + " on " + tableName + " - " + database.ErrorStateMessage);
|
||||
SetErrorState($"Failed to create primary index {indexName} on {tableName} - {database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,20 +261,27 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create database index.
|
||||
protected bool CreateDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String indexName, String columnsCsv, bool unique = false)
|
||||
protected bool CreateDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String indexName, String columnsCsv, String includeColumnsCsv = "", bool unique = false)
|
||||
{
|
||||
if (database == null || HasErrorState()) return false;
|
||||
if (!database.TableExists(tableName)) return true;
|
||||
List<String> columns = StringListUtil.Split(columnsCsv, ",");
|
||||
DbDfnTable dfnTbl = database.GetTableDfn(tableName, true);
|
||||
// Construct the index name:
|
||||
DbDfnTable dfnTable = database.GetTableDfn(tableName, true);
|
||||
if (dfnTable == null) return true;
|
||||
HashSet<String> columnNames = new HashSet<String>(Regex.Split(columnsCsv, "[\\s,;\\-+]+").Where(s => !StringUtil.IsEmpty(s)));
|
||||
if (!ColumnsExist(SysUtil.Fn, dfnTable, columnNames)) return false;
|
||||
HashSet<String> includeColumnNames = new HashSet<String>(Regex.Split(includeColumnsCsv, "[\\s,;\\-+]+").Where(s => !StringUtil.IsEmpty(s)));
|
||||
if (!ColumnsExist(SysUtil.Fn, dfnTable, includeColumnNames)) return false;
|
||||
|
||||
// Construct the index name.
|
||||
String indexNamePrefix = "IDX_" + tableName + "_";
|
||||
if (!indexName.StartsWith(indexNamePrefix)) indexName = indexNamePrefix + indexName;
|
||||
if (!dfnTbl.HasIndexByName(indexName)) // Should also check the columns and their sequence in the index.
|
||||
|
||||
// Should also check the columns and their sequence in the index.
|
||||
if (!dfnTable.HasIndexByName(indexName))
|
||||
{
|
||||
String query = "CREATE " + (unique ? "UNIQUE " : "") + "INDEX ";
|
||||
query += "[" + indexName + "] ON [" + tableName + "] (" + columns.Concat(",", "[", "]") + ")";
|
||||
LogSql(query);
|
||||
String query = $"CREATE " + (unique ? "UNIQUE " : "") + $"INDEX [{indexName}] ON [{tableName}] ({columnNames.Concat(",", "[", "]")})";
|
||||
if (!includeColumnNames.IsEmpty())
|
||||
query += $" INCLUDE ({includeColumnNames.Concat(",", "[", "]")})";
|
||||
LogSql(SysUtil.Fn, query);
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
@@ -321,10 +289,66 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
indexStats.IndicesCreated++;
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: " + tableName + "; Index: " + indexName + "; Exception: " + database.ErrorStateMessage);
|
||||
#endif
|
||||
SetErrorState("Failed to create index " + indexName + " on " + tableName + " - " + database.ErrorStateMessage);
|
||||
SetErrorState($"Failed to create index {indexName} on {tableName} - {database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Drop index.
|
||||
protected bool DropDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String indexName)
|
||||
{
|
||||
if (database == null || HasErrorState()) return false;
|
||||
DbDfnTable dfnTable = database.GetTableDfn(tableName, true);
|
||||
if (dfnTable == null) return true;
|
||||
DbDfnIndex dfnIndex = dfnTable.GetIndexByName(indexName);
|
||||
if (dfnIndex == null)
|
||||
{
|
||||
SaLogger.Info($"{SysUtil.Fn} Index '{indexName}' does not exist on table {tableName}.");
|
||||
return true;
|
||||
}
|
||||
if (!dfnIndex.Primary)
|
||||
{
|
||||
// Drop index:
|
||||
// MS Access: DROP INDEX index_name ON table_name
|
||||
// MS SQL Server: DROP INDEX table_name.index_name
|
||||
// DB2/Oracle: DROP INDEX index_name
|
||||
// MySQL: ALTER TABLE table_name DROP INDEX index_name
|
||||
String query = $"DROP INDEX [{indexName}] ON [{tableName}]";
|
||||
LogSql(SysUtil.Fn, query);
|
||||
if (database.DbmsType == DbmsType.MsSql)
|
||||
query = $"DROP INDEX [{tableName}].[{indexName}]";
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
if (!database.HasErrorState())
|
||||
indexStats.IndicesDropped++;
|
||||
else
|
||||
{
|
||||
SetErrorState($"Failed to drop index {indexName} on {tableName} - {database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Drop Primary Key.
|
||||
String query = $"ALTER TABLE [{tableName}] DROP CONSTRAINT [{indexName}]";
|
||||
LogSql(SysUtil.Fn, query);
|
||||
//if (database.DbmsType() == eSaDbmsMsSql)
|
||||
// sQry = "DROP INDEX ["+tableName+"].["+indexName+"]";
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
if (!database.HasErrorState())
|
||||
indexStats.IndicesDropped++;
|
||||
else
|
||||
{
|
||||
SetErrorState($"Failed to drop primary key {indexName} on {tableName} - {database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
private static List<DbDfnTable> GetTableDefinitions(DbConnection dbConnection, String tableNameRestriction = null)
|
||||
{
|
||||
List<DbDfnTable> tables = new List<DbDfnTable>();
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug(SysUtil.Fn + (!StringUtil.IsEmpty(tableNameRestriction) ? " Table: " + tableNameRestriction : " "));
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Database: {dbConnection.Database}." + (!StringUtil.IsEmpty(tableNameRestriction) ? $" Table: {tableNameRestriction}." : ""));
|
||||
String[] restrictions = new String[] { null, null, tableNameRestriction }; // database, owner, table name, type
|
||||
using (DataTable tableSchema = dbConnection.GetSchema(OdbcMetaDataCollectionNames.Tables, restrictions))
|
||||
{
|
||||
@@ -502,7 +502,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
//-------------------------------------------------------------------
|
||||
private void PopulateTableColumns(DbConnection dbConnection, DbDfnTable table)
|
||||
{
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Table: {table.Name}");
|
||||
//if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Table: {table.Name}");
|
||||
short columnPos = 0;
|
||||
String[] restrictions = new String[] { null, table.Schema, table.Name, null }; // database, owner, table name, column name
|
||||
using (DataTable columnSchema = dbConnection.GetSchema(OdbcMetaDataCollectionNames.Columns, restrictions))
|
||||
|
||||
@@ -125,8 +125,10 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
private void CompareTables()
|
||||
{
|
||||
// Database schemas.
|
||||
HashSet<String> sourceTables = (config.SourceDatabase?.GetTableNames(true) ?? config.SourceTables.Select(item => item.Name)).OrderBy(item => item).ToHashSet();
|
||||
HashSet<String> targetTables = config.TargetDatabase.GetTableNames(true).OrderBy(item => item).ToHashSet();
|
||||
List<DbDfnTable> sourceTableDfns = config.SourceDatabase?.GetTableDfns(true) ?? config.SourceTables;
|
||||
List<DbDfnTable> targetTableDfns = config.TargetDatabase.GetTableDfns(true) ?? new List<DbDfnTable>();
|
||||
HashSet<String> sourceTables = sourceTableDfns.Select(item => item.Name).OrderBy(item => item).ToHashSet();
|
||||
HashSet<String> targetTables = targetTableDfns.Select(item => item.Name).OrderBy(item => item).ToHashSet();
|
||||
|
||||
for (int sourceTableIdx = 0, targetTableIdx = 0; sourceTableIdx < sourceTables.Count || targetTableIdx < targetTables.Count;)
|
||||
{
|
||||
@@ -135,8 +137,8 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
String targetTableName = (targetTableIdx < targetTables.Count ? targetTables.ElementAt(targetTableIdx) : "");
|
||||
|
||||
// Retrieve table definition from each database.
|
||||
DbDfnTable sourceTableDfn = !StringUtil.IsBlank(sourceTableName) ? config.SourceDatabase?.GetTableDfn(sourceTableName, true) ?? config.SourceTables.GetTableByName(sourceTableName) : null;
|
||||
DbDfnTable targetTableDfn = !StringUtil.IsBlank(targetTableName) ? config.TargetDatabase.GetTableDfn(targetTableName, true) : null;
|
||||
DbDfnTable sourceTableDfn = sourceTableDfns.GetTableByName(sourceTableName);
|
||||
DbDfnTable targetTableDfn = targetTableDfns.GetTableByName(sourceTableName);
|
||||
|
||||
if (!StringUtil.IsEmpty(sourceTableName) && (StringUtil.IsEmpty(targetTableName) || targetTableName.CompareTo(sourceTableName) > 0))
|
||||
{
|
||||
|
||||
@@ -10,44 +10,44 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Currencies.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// C u r r e n c i e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_Currency { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.Currency, false); } }
|
||||
public override bool DatabaseIsValid_Currency { get { return Database.TableExists(TableName_Currency); } }
|
||||
|
||||
// Retrieve Currency.
|
||||
public override SaCurrency GetCurrency (SaCurrency.Params prmCurrency)
|
||||
// Retrieve Item.
|
||||
public override SaCurrency GetCurrency(SaCurrency.Params prmCurrency)
|
||||
{
|
||||
return referenceDataMgr.GetCurrency(prmCurrency);
|
||||
}
|
||||
|
||||
// Currency list.
|
||||
public override ColumnDfn GetCurrencyColumnDfn (SaCurrency.Column columnId, String caption = "", int width = 0)
|
||||
// Item list.
|
||||
public override ColumnDfn GetCurrencyColumnDfn(SaCurrency.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyColumnDfn(columnId, caption, width);
|
||||
}
|
||||
public override List<String> GetCurrencyQueryFilter (SaCurrency.Params prm)
|
||||
public override List<String> GetCurrencyQueryFilter(SaCurrency.Params prm)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyQueryFilter(prm);
|
||||
}
|
||||
public override long GetCurrencyCount (SaCurrency.Params prmCurrency)
|
||||
public override long GetCurrencyCount(SaCurrency.Params prmCurrency)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyCount(prmCurrency);
|
||||
}
|
||||
public override List<SaCurrency> GetCurrencyList (SaCurrency.Params prmCurrency)
|
||||
public override List<SaCurrency> GetCurrencyList(SaCurrency.Params prmCurrency)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyList(prmCurrency);
|
||||
}
|
||||
public override DbResultSet ExecuteCurrencyQuery (List<ColumnDfn> columns, SaCurrency.Params prm)
|
||||
public override DbResultSet ExecuteCurrencyQuery(List<ColumnDfn> columns, SaCurrency.Params prm)
|
||||
{
|
||||
return referenceDataMgr.ExecuteCurrencyQuery(columns, prm);
|
||||
}
|
||||
public override DataValue GetCurrencyDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public override DataValue GetCurrencyDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyDataValue(column, values);
|
||||
}
|
||||
|
||||
@@ -10,44 +10,44 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Languages.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// L a n g u a g e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_Language { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.Language, false); } }
|
||||
public override bool DatabaseIsValid_Language { get { return Database.TableExists(TableName_Language); } }
|
||||
|
||||
// Retrieve Language.
|
||||
public override SaLanguage GetLanguage (SaLanguage.Params prmLanguage)
|
||||
// Retrieve Item.
|
||||
public override SaLanguage GetLanguage(SaLanguage.Params prmLanguage)
|
||||
{
|
||||
return referenceDataMgr.GetLanguage(prmLanguage);
|
||||
}
|
||||
|
||||
// Language list.
|
||||
public override ColumnDfn GetLanguageColumnDfn (SaLanguage.Column columnId, String caption = "", int width = 0)
|
||||
// Item list.
|
||||
public override ColumnDfn GetLanguageColumnDfn(SaLanguage.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageColumnDfn(columnId, caption, width);
|
||||
}
|
||||
public override List<String> GetLanguageQueryFilter (SaLanguage.Params prm)
|
||||
public override List<String> GetLanguageQueryFilter(SaLanguage.Params prm)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageQueryFilter(prm);
|
||||
}
|
||||
public override long GetLanguageCount (SaLanguage.Params prmLanguage)
|
||||
public override long GetLanguageCount(SaLanguage.Params prmLanguage)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageCount(prmLanguage);
|
||||
}
|
||||
public override List<SaLanguage> GetLanguageList (SaLanguage.Params prmLanguage)
|
||||
public override List<SaLanguage> GetLanguageList(SaLanguage.Params prmLanguage)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageList(prmLanguage);
|
||||
}
|
||||
public override DbResultSet ExecuteLanguageQuery (List<ColumnDfn> columns, SaLanguage.Params prm)
|
||||
public override DbResultSet ExecuteLanguageQuery(List<ColumnDfn> columns, SaLanguage.Params prm)
|
||||
{
|
||||
return referenceDataMgr.ExecuteLanguageQuery(columns, prm);
|
||||
}
|
||||
public override DataValue GetLanguageDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public override DataValue GetLanguageDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageDataValue(column, values);
|
||||
}
|
||||
|
||||
@@ -10,44 +10,44 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Regions.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// R e g i o n s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_Region { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.Region, false); } }
|
||||
public override bool DatabaseIsValid_Region { get { return Database.TableExists(TableName_Region); } }
|
||||
|
||||
// Retrieve Region.
|
||||
public override SaRegion GetRegion (SaRegion.Params prmRegion)
|
||||
// Retrieve Item.
|
||||
public override SaRegion GetRegion(SaRegion.Params prmRegion)
|
||||
{
|
||||
return referenceDataMgr.GetRegion(prmRegion);
|
||||
}
|
||||
|
||||
// Region list.
|
||||
public override ColumnDfn GetRegionColumnDfn (SaRegion.Column columnId, String caption = "", int width = 0)
|
||||
// Item list.
|
||||
public override ColumnDfn GetRegionColumnDfn(SaRegion.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetRegionColumnDfn(columnId, caption, width);
|
||||
}
|
||||
public override List<String> GetRegionQueryFilter (SaRegion.Params prm)
|
||||
public override List<String> GetRegionQueryFilter(SaRegion.Params prm)
|
||||
{
|
||||
return referenceDataMgr.GetRegionQueryFilter(prm);
|
||||
}
|
||||
public override long GetRegionCount (SaRegion.Params prmRegion)
|
||||
public override long GetRegionCount(SaRegion.Params prmRegion)
|
||||
{
|
||||
return referenceDataMgr.GetRegionCount(prmRegion);
|
||||
}
|
||||
public override List<SaRegion> GetRegionList (SaRegion.Params prmRegion)
|
||||
public override List<SaRegion> GetRegionList(SaRegion.Params prmRegion)
|
||||
{
|
||||
return referenceDataMgr.GetRegionList(prmRegion);
|
||||
}
|
||||
public override DbResultSet ExecuteRegionQuery (List<ColumnDfn> columns, SaRegion.Params prm)
|
||||
public override DbResultSet ExecuteRegionQuery(List<ColumnDfn> columns, SaRegion.Params prm)
|
||||
{
|
||||
return referenceDataMgr.ExecuteRegionQuery(columns, prm);
|
||||
}
|
||||
public override DataValue GetRegionDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public override DataValue GetRegionDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
return referenceDataMgr.GetRegionDataValue(column, values);
|
||||
}
|
||||
|
||||
@@ -10,23 +10,23 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Tax Codes.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// T a x C o d e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_TaxCode { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.TaxCode, false); } }
|
||||
public override bool DatabaseIsValid_TaxCode { get { return Database.TableExists(TableName_TaxCode); } }
|
||||
|
||||
// Retrieve TaxCode.
|
||||
// Retrieve Item.
|
||||
public override SaTaxCode GetTaxCode (SaTaxCode.Params prmTaxCode)
|
||||
{
|
||||
return referenceDataMgr.GetTaxCode(prmTaxCode);
|
||||
}
|
||||
|
||||
// TaxCode list.
|
||||
// Item list.
|
||||
public override ColumnDfn GetTaxCodeColumnDfn (SaTaxCode.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetTaxCodeColumnDfn(columnId, caption, width);
|
||||
|
||||
@@ -10,44 +10,44 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Units of Measure.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// U n i t s M e a s u r e
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_UnitMeasure { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.UnitMeasure, false); } }
|
||||
public override bool DatabaseIsValid_UnitMeasure { get { return Database.TableExists(TableName_UnitMeasure); } }
|
||||
|
||||
// Retrieve Unit of Measure.
|
||||
public override SaUnitMeasure GetUnitMeasure (SaUnitMeasure.Params prmUnitMeasure)
|
||||
// Retrieve Item.
|
||||
public override SaUnitMeasure GetUnitMeasure(SaUnitMeasure.Params prmUnitMeasure)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasure(prmUnitMeasure);
|
||||
}
|
||||
|
||||
// Unit of Measure list.
|
||||
public override ColumnDfn GetUnitMeasureColumnDfn (SaUnitMeasure.Column columnId, String caption = "", int width = 0)
|
||||
// Item list.
|
||||
public override ColumnDfn GetUnitMeasureColumnDfn(SaUnitMeasure.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureColumnDfn(columnId, caption, width);
|
||||
}
|
||||
public override List<String> GetUnitMeasureQueryFilter (SaUnitMeasure.Params prm)
|
||||
public override List<String> GetUnitMeasureQueryFilter(SaUnitMeasure.Params prm)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureQueryFilter(prm);
|
||||
}
|
||||
public override long GetUnitMeasureCount (SaUnitMeasure.Params prmUnitMeasure)
|
||||
public override long GetUnitMeasureCount(SaUnitMeasure.Params prmUnitMeasure)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureCount(prmUnitMeasure);
|
||||
}
|
||||
public override List<SaUnitMeasure> GetUnitMeasureList (SaUnitMeasure.Params prmUnitMeasure)
|
||||
public override List<SaUnitMeasure> GetUnitMeasureList(SaUnitMeasure.Params prmUnitMeasure)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureList(prmUnitMeasure);
|
||||
}
|
||||
public override DbResultSet ExecuteUnitMeasureQuery (List<ColumnDfn> columns, SaUnitMeasure.Params prm)
|
||||
public override DbResultSet ExecuteUnitMeasureQuery(List<ColumnDfn> columns, SaUnitMeasure.Params prm)
|
||||
{
|
||||
return referenceDataMgr.ExecuteUnitMeasureQuery(columns, prm);
|
||||
}
|
||||
public override DataValue GetUnitMeasureDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public override DataValue GetUnitMeasureDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureDataValue(column, values);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ using Sarand.Net.Standard.Dbas.Base;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console.
|
||||
//=======================================================================
|
||||
public abstract partial class SaReferenceDataConsole_Dbas : SaReferenceDataConsole
|
||||
{
|
||||
|
||||
@@ -14,12 +14,12 @@ using Sarand.Net.Standard.Base.App;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Currencies.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// C u r r e n c i e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Create Currency.
|
||||
public override SaCurrency CreateCurrency()
|
||||
{
|
||||
|
||||
@@ -14,12 +14,12 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Languages.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// L a n g u a g e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Create Language.
|
||||
public override SaLanguage CreateLanguage()
|
||||
{
|
||||
|
||||
@@ -14,12 +14,12 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Regions.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// R e g i o n s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Create Region.
|
||||
public override SaRegion CreateRegion(SaRegionType regionType)
|
||||
{
|
||||
|
||||
@@ -14,13 +14,13 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Tax Codes.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// T a x C o d e s
|
||||
//*******************************************************************
|
||||
// Create TaxCode.
|
||||
//-------------------------------------------------------------------
|
||||
// Create Item.
|
||||
public override SaTaxCode CreateTaxCode()
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -41,7 +41,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode exists.
|
||||
// Item exists.
|
||||
public override bool TaxCodeExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -56,7 +56,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get TaxCode.
|
||||
// Get Item.
|
||||
public override SaTaxCode GetTaxCode(SaTaxCode.Params prm)
|
||||
{
|
||||
return GetTaxCode(GetTaxCodeQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
@@ -105,7 +105,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item.
|
||||
// Validate Item.
|
||||
public override bool IsValidTaxCodeData(SaTaxCode.Data data, SaTaxCode.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -114,7 +114,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert item.
|
||||
// Insert Item.
|
||||
public override bool InsertTaxCode(SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -142,7 +142,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update item.
|
||||
// Update Item.
|
||||
public override bool UpdateTaxCode(SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -171,7 +171,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Delete item.
|
||||
// Delete Item.
|
||||
public override bool TaxCodeCanBeDeleted(SaTaxCode taxCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -202,7 +202,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copy data properties to and from database.
|
||||
// Copy Item properties to and from database.
|
||||
private void PopulateTo(TaxCode_Db dbTaxCode, SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
dbTaxCode._Id = taxCode.Id.ToInt();
|
||||
@@ -233,7 +233,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
private void PopulateFrom(TaxCode_Db dbTaxCode, SaTaxCode taxCode)
|
||||
{
|
||||
//taxCode.Id = new SysId(dbTaxCode._Id);
|
||||
//taxCode.Code = dbTaxCode._Code;
|
||||
taxCode.Code = dbTaxCode._Code;
|
||||
taxCode.CodeAlt1 = dbTaxCode._CodeAlt1;
|
||||
taxCode.CodeAlt2 = dbTaxCode._CodeAlt2;
|
||||
taxCode.Description = dbTaxCode._Description;
|
||||
@@ -252,7 +252,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode column definitions.
|
||||
// Item column definitions.
|
||||
private static readonly String aliasTaxCode = "aTax";
|
||||
private void SetTaxCodeColDfn
|
||||
(ColumnDfn col, String caption, int width, SaReferenceDataDbDfn.ColumnIdx dbCol,
|
||||
@@ -265,9 +265,9 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
if (dataType == DataValue.DataType.String && dbCol != SaReferenceDataDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SaReferenceDataDbDfn.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting taxcode column definition.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item column definition.
|
||||
public override ColumnDfn GetTaxCodeColumnDfn(SaTaxCode.Column columnId, string caption = "", int width = 0)
|
||||
{
|
||||
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
|
||||
@@ -354,7 +354,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode query filter.
|
||||
// Item query filter.
|
||||
public override List<string> GetTaxCodeQueryFilter(SaTaxCode.Params prm)
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
@@ -403,7 +403,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
}
|
||||
// TaxCode sort columns.
|
||||
// Item sort columns.
|
||||
public List<String> GetTaxCodeSortColumns(SaTaxCode.Params prm)
|
||||
{
|
||||
// Sort sequence:
|
||||
@@ -438,7 +438,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode count.
|
||||
// Item count.
|
||||
private long GetTaxCodeCount(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -451,7 +451,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode list.
|
||||
// Item list.
|
||||
public override List<SaTaxCode> GetTaxCodeList(SaTaxCode.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -486,7 +486,6 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode query execution.
|
||||
public override DbResultSet ExecuteTaxCodeQuery(List<ColumnDfn> columns, SaTaxCode.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
@@ -14,12 +14,12 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Units of Measure.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// U n i t s o f M e a s u r e
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Create UnitMeasure.
|
||||
public override SaUnitMeasure CreateUnitMeasure()
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
@@ -18,7 +20,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaReferenceDataMgr_Dbas (SaReferenceDataConsole_Dbas referenceDataConsole) :
|
||||
public SaReferenceDataMgr_Dbas(SaReferenceDataConsole_Dbas referenceDataConsole) :
|
||||
base()
|
||||
{
|
||||
ReferenceDataConsole = referenceDataConsole;
|
||||
|
||||
Reference in New Issue
Block a user