122 lines
2.9 KiB
C#
122 lines
2.9 KiB
C#
///////////////////////////////////////////////////////////
|
|
// Bool.cs
|
|
// Implementation of Class RateExistanceChecker
|
|
// CSLA type: Read-only object
|
|
// Created on: 25-Sept-2007
|
|
// Object design: John
|
|
// Coded: 25-Sept-2007
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using CSLA.Data;
|
|
using GZTW.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
//case 500
|
|
/// <summary>
|
|
///Confirms the presence of an Rate
|
|
///in the AyaNova database
|
|
/// </summary>
|
|
[Serializable, EditorBrowsable(EditorBrowsableState.Never)]
|
|
internal class RateExistanceChecker : ReadOnlyBase
|
|
{
|
|
|
|
#region Attributes
|
|
private bool mExists;
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Private constructor to prevent direct instantiation
|
|
/// </summary>
|
|
private RateExistanceChecker()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region Static methods
|
|
|
|
|
|
|
|
|
|
internal static bool RateExists(Guid ID, string Name)
|
|
{
|
|
|
|
return ((RateExistanceChecker)DataPortal.Fetch(new Criteria(ID, Name))).mExists;
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param Bool="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
Criteria crit = (Criteria)Criteria;
|
|
if (!string.IsNullOrEmpty(crit.Name))
|
|
{
|
|
DBCommandWrapper dbCommandWrapper = DBUtil.DB.GetSqlStringCommandWrapper(
|
|
"SELECT aID FROM aRate WHERE " +
|
|
"(aName = @ANAME)"
|
|
);
|
|
dbCommandWrapper.AddInParameter("@ANAME", DbType.String, crit.Name);
|
|
if (DBUtil.ToGuid(DBUtil.DB.ExecuteScalar(dbCommandWrapper)) == Guid.Empty)
|
|
this.mExists = false;
|
|
else
|
|
this.mExists = true;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
if (DBUtil.ToGuid(DBUtil.GetScalarFromSQLString(
|
|
"SELECT aID FROM aRate WHERE " +
|
|
"(aID = @ID)", crit.ID
|
|
)) == Guid.Empty)
|
|
this.mExists = false;
|
|
else
|
|
this.mExists = true;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
public Guid ID;
|
|
public string Name;
|
|
public Criteria(Guid _ID, string _Name)
|
|
{
|
|
ID = _ID;
|
|
Name = _Name;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end class
|
|
|
|
}//end namespace GZTW.AyaNova.BLL |