Exemple #1
0
 /// <summary>
 ///   Update a <see cref="CellFed"/> passed as an argument .
 /// </summary>
 /// <param name="aCellFed">A <see cref="CellFed"/>.</param>
 public static void Update(CellFed aCellFed)
 {
     if (aCellFed == null)
     {
         throw new ArgumentNullException("aCellFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update CED_CellFederation");
         vStringBuilder.AppendLine("set    CED_DateJoined = @CEDDateJoined,");
         vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         vStringBuilder.AppendLine("and    FED_Key = @FEDKey");
         ObjectToData(vSqlCommand, aCellFed);
         vSqlCommand.Parameters.AddWithValue("@CEDDateJoined", aCellFed.CellFedDateJoined);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #2
0
 /// <summary>
 ///   Delete a <see cref="CellFed"/> object passed as an argument.
 /// </summary>
 /// <param name="aCellFed">The <see cref="CellFed"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aCellFed</c> argument is <c>null</c>.</exception>
 public static void Delete(CellFed aCellFed)
 {
     if (aCellFed == null)
     {
         throw new ArgumentNullException("aCellFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete CED_CellFederation");
         if (aCellFed.CelKey > 0 && aCellFed.FedKey > 0)
         {
             vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
             vStringBuilder.AppendLine("and    FED_Key = @FEDKey");
         }
         else if (aCellFed.CelKey > 0)
         {
             vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         }
         else if (aCellFed.FedKey > 0)
         {
             vStringBuilder.AppendLine("where  FED_Key = @FEDKey");
         }
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFed.CelKey);
         vSqlCommand.Parameters.AddWithValue("@FEDKey", aCellFed.FedKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #3
0
 /// <summary>
 ///   Delete a <see cref="CellFed"/> object passed as an argument.
 /// </summary>
 /// <param name="aCellFed">The <see cref="CellFed"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aCellFed</c> argument is <c>null</c>.</exception>
 public static void Delete(CellFed aCellFed)
 {
     if (aCellFed == null)
     {
         throw new ArgumentNullException("aCellFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete CED_CellFederation");
         if (aCellFed.CelKey > 0 && aCellFed.FedKey > 0)
         {
             vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
             vStringBuilder.AppendLine("and    FED_Key = @FEDKey");
         }
         else if (aCellFed.CelKey > 0)
         {
             vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         }
         else if (aCellFed.FedKey > 0)
         {
             vStringBuilder.AppendLine("where  FED_Key = @FEDKey");
         }
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFed.CelKey);
         vSqlCommand.Parameters.AddWithValue("@FEDKey", aCellFed.FedKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #4
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="CellFed"/>, with keys in the <c>aCellFed</c> argument.
 /// </summary>
 /// <param name="aCellFed">A <see cref="CellFed"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aCellFed</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(CellFed aCellFed)
 {
     if (aCellFed == null)
     {
         throw new ArgumentNullException("aCellFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and t1.CEL_Key = @CELKey");
         vStringBuilder.AppendLine("and t2.FED_Key = @FEDKey");
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFed.CelKey);
         vSqlCommand.Parameters.AddWithValue("@FEDKey", aCellFed.FedKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected CellFED not found: CEL_Key = {0}, FED_Key = {1}", aCellFed.CelKey, aCellFed.FedKey));
             }
             vSqlDataReader.Read();
             DataToObject(aCellFed, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #5
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="CellFed"/> object.
 /// </summary>
 /// <param name="aCellFed">A <see cref="Cell"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(CellFed aCellFed, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aCellFed.CelKey            = Convert.ToInt32(aSqlDataReader["CEL_Key"]);
     aCellFed.CellName          = Convert.ToString(aSqlDataReader["CEL_Name"]);
     aCellFed.FedKey            = Convert.ToInt32(aSqlDataReader["FED_Key"]);
     aCellFed.FedName           = Convert.ToString(aSqlDataReader["FED_Name"]);
     aCellFed.CellFedDateJoined = Convert.ToDateTime(aSqlDataReader["CED_DateJoined"]);
 }
Exemple #6
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="CellFed"/> object.
 /// </summary>
 /// <param name="aCellFed">A <see cref="Cell"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(CellFed aCellFed, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aCellFed.CelKey = Convert.ToInt32(aSqlDataReader["CEL_Key"]);
     aCellFed.CellName = Convert.ToString(aSqlDataReader["CEL_Name"]);
     aCellFed.FedKey = Convert.ToInt32(aSqlDataReader["FED_Key"]);
     aCellFed.FedName = Convert.ToString(aSqlDataReader["FED_Name"]);
     aCellFed.CellFedDateJoined = Convert.ToDateTime(aSqlDataReader["CED_DateJoined"]);
 }
Exemple #7
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>CellFedList</c> property a <see cref="CellFedCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="CellFed"/>, filtered by the filter properties of the passed <see cref="CellFedCollection"/>.
 /// </summary>
 /// <param name="aCellFedCollection">The <see cref="CellFedCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="CellFedCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aCellFedCollection</c> argument is <c>null</c>.</exception>
 public static void Load(CellFedCollection aCellFedCollection)
 {
     if (aCellFedCollection == null)
     {
         throw new ArgumentNullException("aCellFedCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aCellFedCollection.IsFiltered)
         {
             if (aCellFedCollection.CellFedFilter.CellfedFilter.CelKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.CEL_Key = @CELKey");
                 vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFedCollection.CellFedFilter.CellfedFilter.CelKey);
             }
             if (aCellFedCollection.CellFedFilter.CellfedFilter.FedKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FED_Key = @FEDKey");
                 vSqlCommand.Parameters.AddWithValue("@FEDKey", aCellFedCollection.CellFedFilter.CellfedFilter.FedKey);
             }
             if (aCellFedCollection.CellFedFilter.CellfedFilter.CellName != null)
             {
                 vStringBuilder.AppendFormat("and t1.CEL_Name like '%{0}%'", aCellFedCollection.CellFedFilter.CellfedFilter.CellName);
             }
             if (aCellFedCollection.CellFedFilter.CellfedFilter.FedName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FED_Name like '%{0}%'", aCellFedCollection.CellFedFilter.CellfedFilter.FedName);
             }
         }
         vStringBuilder.AppendLine("order by t1.CEL_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vCellFed = new CellFed();
                 DataToObject(vCellFed, vSqlDataReader, false);
                 aCellFedCollection.CellFedList.Add(vCellFed);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #8
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="CellFed"/> object, with keys in <c>aCellFed</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aCellFed">A <see cref="CellFed"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aCellFed</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, CellFed aCellFed)
        {
            if (aCellFed == null)
            {
                throw new ArgumentNullException("Load CellFed Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "CellFed", AccessMode.Read))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Read, "CellFed");
            //}

            CellFedData.Load(aCellFed);
        }
Exemple #9
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="CellFed"/> object, with keys in <c>aCellFed</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aCellFed">A <see cref="CellFed"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aCellFed</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, CellFed aCellFed)
        {
            if (aCellFed == null)
            {
                throw new ArgumentNullException("Load CellFed Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "CellFed", AccessMode.Read))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Read, "CellFed");
            //}

            CellFedData.Load(aCellFed);
        }
Exemple #10
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="CellFedCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is CellFedCollection))
            {
                throw new ArgumentException("Invalid assignment source", "CellFedCollection");
            }

            _isFiltered    = (aSource as CellFedCollection)._isFiltered;
            _cellFedFilter = (aSource as CellFedCollection)._cellFedFilter;
            _cellFedList.Clear();
            foreach (CellFed vCellFedSource in (aSource as CellFedCollection)._cellFedList)
            {
                CellFed vCellFedTarget = new CellFed();
                vCellFedTarget.AssignFromSource(vCellFedSource);
                _cellFedList.Add(vCellFedTarget);
            }
        }
Exemple #11
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="CellFedCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is CellFedCollection))
            {
                throw new ArgumentException("Invalid assignment source", "CellFedCollection");
            }

            _isFiltered = (aSource as CellFedCollection)._isFiltered;
            _cellFedFilter = (aSource as CellFedCollection)._cellFedFilter;
            _cellFedList.Clear();
            foreach (CellFed vCellFedSource in (aSource as CellFedCollection)._cellFedList)
            {
                CellFed vCellFedTarget = new CellFed();
                vCellFedTarget.AssignFromSource(vCellFedSource);
                _cellFedList.Add(vCellFedTarget);
            }
        }
 /// <summary>
 ///   Gets a specified <see cref="CellFed"/> by key.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param>
 /// <param name="aCellFed"><see cref="CellFed"/> object.</param>
 public static void GetCellFed(FanToken aFanToken, CellFed aCellFed)
 {
     FanCallHandler.ServiceCall <CellFed>(aFanToken, "GetCellFed", aCellFed);
 }
Exemple #13
0
 /// <summary>
 ///   Gets the <see cref="CellFed"/> by Key.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns>CellFed as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string GetCellFed(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of GetCellFed");
     }
     CellFed vCellFed = new CellFed();
     vCellFed = XmlUtils.Deserialize<CellFed>(aXmlArgument);
     CellFedBusiness.Load(aFanKey, vCellFed);
     return XmlUtils.Serialize<CellFed>(vCellFed, true);
 }
Exemple #14
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>CellFedList</c> property a <see cref="CellFedCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="CellFed"/>, filtered by the filter properties of the passed <see cref="CellFedCollection"/>.
 /// </summary>
 /// <param name="aCellFedCollection">The <see cref="CellFedCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="CellFedCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aCellFedCollection</c> argument is <c>null</c>.</exception>
 public static void Load(CellFedCollection aCellFedCollection)
 {
     if (aCellFedCollection == null)
     {
         throw new ArgumentNullException("aCellFedCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aCellFedCollection.IsFiltered)
         {
             if (aCellFedCollection.CellFedFilter.CellfedFilter.CelKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.CEL_Key = @CELKey");
                 vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFedCollection.CellFedFilter.CellfedFilter.CelKey);
             }
             if (aCellFedCollection.CellFedFilter.CellfedFilter.FedKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FED_Key = @FEDKey");
                 vSqlCommand.Parameters.AddWithValue("@FEDKey", aCellFedCollection.CellFedFilter.CellfedFilter.FedKey);
             }
             if (aCellFedCollection.CellFedFilter.CellfedFilter.CellName != null)
             {
                 vStringBuilder.AppendFormat("and t1.CEL_Name like '%{0}%'", aCellFedCollection.CellFedFilter.CellfedFilter.CellName);
             }
             if (aCellFedCollection.CellFedFilter.CellfedFilter.FedName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FED_Name like '%{0}%'", aCellFedCollection.CellFedFilter.CellfedFilter.FedName);
             }
         }
         vStringBuilder.AppendLine("order by t1.CEL_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vCellFed = new CellFed();
                 DataToObject(vCellFed, vSqlDataReader, false);
                 aCellFedCollection.CellFedList.Add(vCellFed);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #15
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="CellFed"/>, with keys in the <c>aCellFed</c> argument.
 /// </summary>
 /// <param name="aCellFed">A <see cref="CellFed"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aCellFed</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(CellFed aCellFed)
 {
     if (aCellFed == null)
     {
         throw new ArgumentNullException("aCellFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and t1.CEL_Key = @CELKey");
         vStringBuilder.AppendLine("and t2.FED_Key = @FEDKey");
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFed.CelKey);
         vSqlCommand.Parameters.AddWithValue("@FEDKey", aCellFed.FedKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected CellFED not found: CEL_Key = {0}, FED_Key = {1}", aCellFed.CelKey, aCellFed.FedKey));
             }
             vSqlDataReader.Read();
             DataToObject(aCellFed, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #16
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="CellFed"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aCell">A <see cref="CellFed"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, CellFed aCellFed)
 {
     aSqlCommand.Parameters.AddWithValue("@CELKey", aCellFed.CelKey);
     aSqlCommand.Parameters.AddWithValue("@FEDKey", aCellFed.FedKey);
     aSqlCommand.Parameters.AddWithValue("@CELFEDDateJoined", aCellFed.CellFedDateJoined);
 }
Exemple #17
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="CellFed"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aCell">A <see cref="CellFed"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, CellFed aCellFed)
 {
     aSqlCommand.Parameters.AddWithValue("@CELKey", aCellFed.CelKey);
     aSqlCommand.Parameters.AddWithValue("@FEDKey", aCellFed.FedKey);
     aSqlCommand.Parameters.AddWithValue("@CELFEDDateJoined", aCellFed.CellFedDateJoined);
 }
Exemple #18
0
 /// <summary>
 ///   Update a <see cref="CellFed"/> passed as an argument .
 /// </summary>
 /// <param name="aCellFed">A <see cref="CellFed"/>.</param>
 public static void Update(CellFed aCellFed)
 {
     if (aCellFed == null)
     {
         throw new ArgumentNullException("aCellFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update CED_CellFederation");
         vStringBuilder.AppendLine("set    CED_DateJoined = @CEDDateJoined,");
         vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         vStringBuilder.AppendLine("and    FED_Key = @FEDKey");
         ObjectToData(vSqlCommand, aCellFed);
         vSqlCommand.Parameters.AddWithValue("@CEDDateJoined", aCellFed.CellFedDateJoined);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
 /// <summary>
 ///   Gets a specified <see cref="CellFed"/> by key.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param>
 /// <param name="aCellFed"><see cref="CellFed"/> object.</param>
 public static void GetCellFed(FanToken aFanToken, CellFed aCellFed)
 {
     FanCallHandler.ServiceCall<CellFed>(aFanToken, "GetCellFed", aCellFed);
 }