/////////////////////////////////////////////////////////// // Bool.cs // Implementation of Class VendorExistanceChecker // 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 496 /// ///Confirms the presence of an Vendor ///in the AyaNova database /// [Serializable, EditorBrowsable(EditorBrowsableState.Never)] internal class VendorExistanceChecker : ReadOnlyBase { #region Attributes private bool mExists; #endregion #region Constructor /// /// Private constructor to prevent direct instantiation /// private VendorExistanceChecker() { } #endregion #region Static methods internal static bool VendorExists(Guid ID, string Name) { return ((VendorExistanceChecker)DataPortal.Fetch(new Criteria(ID, Name))).mExists; } #endregion #region DAL DATA ACCESS /// /// protected override void DataPortal_Fetch(object Criteria) { Criteria crit = (Criteria)Criteria; if (!string.IsNullOrEmpty(crit.Name)) { DBCommandWrapper dbCommandWrapper = DBUtil.DB.GetSqlStringCommandWrapper( "SELECT aID FROM aVendor 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 aVendor WHERE " + "(aID = @ID)", crit.ID )) == Guid.Empty) this.mExists = false; else this.mExists = true; } } #endregion #region criteria /// /// Criteria for identifying existing object /// [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