Ejemplo n.º 1
0
 /// <summary>
 ///   Delete a <see cref="CellFan"/> object passed as an argument.
 /// </summary>
 /// <param name="aCellFan">The <see cref="CellFan"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aCellFan</c> argument is <c>null</c>.</exception>
 public static void Delete(CellFan aCellFan)
 {
     if (aCellFan == null)
     {
         throw new ArgumentNullException("aCellFan");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete CAN_CellFan");
         if (aCellFan.CelKey > 0 && aCellFan.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
             vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         }
         else if (aCellFan.CelKey > 0)
         {
             vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         }
         else if (aCellFan.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         }
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFan.CelKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aCellFan.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///   Delete a <see cref="CellFan"/> object passed as an argument.
 /// </summary>
 /// <param name="aCellFan">The <see cref="CellFan"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aCellFan</c> argument is <c>null</c>.</exception>
 public static void Delete(CellFan aCellFan)
 {
     if (aCellFan == null)
     {
         throw new ArgumentNullException("aCellFan");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete CAN_CellFan");
         if (aCellFan.CelKey > 0 && aCellFan.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
             vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         }
         else if (aCellFan.CelKey > 0)
         {
             vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         }
         else if (aCellFan.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         }
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFan.CelKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aCellFan.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="CellFan"/>, with keys in the <c>aCellFan</c> argument.
 /// </summary>
 /// <param name="aCellFan">A <see cref="CellFan"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aCellFan</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(CellFan aCellFan)
 {
     if (aCellFan == null)
     {
         throw new ArgumentNullException("aCellFan");
     }
     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.FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFan.CelKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aCellFan.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected CellFAN not found: CEL_Key = {0}, FAN_Key = {1}", aCellFan.CelKey, aCellFan.FanKey));
             }
             vSqlDataReader.Read();
             DataToObject(aCellFan, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 ///   Update a <see cref="CellFan"/> passed as an argument .
 /// </summary>
 /// <param name="aCellFan">A <see cref="CellFan"/>.</param>
 public static void Update(CellFan aCellFan)
 {
     if (aCellFan == null)
     {
         throw new ArgumentNullException("aCellFan");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update CAN_CellFan");
         vStringBuilder.AppendLine("set    CAN_DateJoined = @CANDateJoined,");
         vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         ObjectToData(vSqlCommand, aCellFan);
         vSqlCommand.Parameters.AddWithValue("@CANDateJoined", aCellFan.CellFanDateJoined);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="CellFan"/> object.
 /// </summary>
 /// <param name="aCellFan">A <see cref="Cell"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(CellFan aCellFan, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aCellFan.CelKey = Convert.ToInt32(aSqlDataReader["CEL_Key"]);
     aCellFan.CellName = Convert.ToString(aSqlDataReader["CEL_Name"]);
     aCellFan.FanKey = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aCellFan.FanName = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aCellFan.FanSurname = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aCellFan.CellFanDateJoined = Convert.ToDateTime(aSqlDataReader["CAN_DateJoined"]);
 }
Ejemplo n.º 6
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="CellFan"/> object.
 /// </summary>
 /// <param name="aCellFan">A <see cref="Cell"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(CellFan aCellFan, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aCellFan.CelKey            = Convert.ToInt32(aSqlDataReader["CEL_Key"]);
     aCellFan.CellName          = Convert.ToString(aSqlDataReader["CEL_Name"]);
     aCellFan.FanKey            = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aCellFan.FanName           = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aCellFan.FanSurname        = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aCellFan.CellFanDateJoined = Convert.ToDateTime(aSqlDataReader["CAN_DateJoined"]);
 }
Ejemplo n.º 7
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>CellFanList</c> property a <see cref="CellFanCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="CellFan"/>, filtered by the filter properties of the passed <see cref="CellFanCollection"/>.
 /// </summary>
 /// <param name="aCellFanCollection">The <see cref="CellFanCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="CellFanCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aCellFanCollection</c> argument is <c>null</c>.</exception>
 public static void Load(CellFanCollection aCellFanCollection)
 {
     if (aCellFanCollection == null)
     {
         throw new ArgumentNullException("aCellFanCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aCellFanCollection.IsFiltered)
         {
             if (aCellFanCollection.CellFanFilter.CellfanFilter.CelKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.CEL_Key = @CELKey");
                 vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFanCollection.CellFanFilter.CellfanFilter.CelKey);
             }
             if (aCellFanCollection.CellFanFilter.CellfanFilter.FanKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aCellFanCollection.CellFanFilter.CellfanFilter.FanKey);
             }
             if (aCellFanCollection.CellFanFilter.CellfanFilter.CellName != null)
             {
                 vStringBuilder.AppendFormat("and t1.CEL_Name like '%{0}%'", aCellFanCollection.CellFanFilter.CellfanFilter.CellName);
             }
             if (aCellFanCollection.CellFanFilter.CellfanFilter.FanName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Name like '%{0}%'", aCellFanCollection.CellFanFilter.CellfanFilter.FanName);
             }
         }
         vStringBuilder.AppendLine("order by t1.CEL_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vCellFan = new CellFan();
                 DataToObject(vCellFan, vSqlDataReader, false);
                 aCellFanCollection.CellFanList.Add(vCellFan);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="CellFan"/> object, with keys in <c>aCellFan</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aCellFan">A <see cref="CellFan"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aCellFan</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, CellFan aCellFan)
        {
            if (aCellFan == null)
            {
                throw new ArgumentNullException("Load CellFan Business");
            }

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

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

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

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

            _isFiltered = (aSource as CellFanCollection)._isFiltered;
            _cellFanFilter = (aSource as CellFanCollection)._cellFanFilter;
            _cellFanList.Clear();
            foreach (CellFan vCellFanSource in (aSource as CellFanCollection)._cellFanList)
            {
                CellFan vCellFanTarget = new CellFan();
                vCellFanTarget.AssignFromSource(vCellFanSource);
                _cellFanList.Add(vCellFanTarget);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="CellFanCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is CellFanCollection))
            {
                throw new ArgumentException("Invalid assignment source", "CellFanCollection");
            }

            _isFiltered    = (aSource as CellFanCollection)._isFiltered;
            _cellFanFilter = (aSource as CellFanCollection)._cellFanFilter;
            _cellFanList.Clear();
            foreach (CellFan vCellFanSource in (aSource as CellFanCollection)._cellFanList)
            {
                CellFan vCellFanTarget = new CellFan();
                vCellFanTarget.AssignFromSource(vCellFanSource);
                _cellFanList.Add(vCellFanTarget);
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="CellFan"/>, with keys in the <c>aCellFan</c> argument.
 /// </summary>
 /// <param name="aCellFan">A <see cref="CellFan"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aCellFan</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(CellFan aCellFan)
 {
     if (aCellFan == null)
     {
         throw new ArgumentNullException("aCellFan");
     }
     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.FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFan.CelKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aCellFan.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected CellFAN not found: CEL_Key = {0}, FAN_Key = {1}", aCellFan.CelKey, aCellFan.FanKey));
             }
             vSqlDataReader.Read();
             DataToObject(aCellFan, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>CellFanList</c> property a <see cref="CellFanCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="CellFan"/>, filtered by the filter properties of the passed <see cref="CellFanCollection"/>.
 /// </summary>
 /// <param name="aCellFanCollection">The <see cref="CellFanCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="CellFanCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aCellFanCollection</c> argument is <c>null</c>.</exception>
 public static void Load(CellFanCollection aCellFanCollection)
 {
     if (aCellFanCollection == null)
     {
         throw new ArgumentNullException("aCellFanCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aCellFanCollection.IsFiltered)
         {
             if (aCellFanCollection.CellFanFilter.CellfanFilter.CelKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.CEL_Key = @CELKey");
                 vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFanCollection.CellFanFilter.CellfanFilter.CelKey);
             }
             if (aCellFanCollection.CellFanFilter.CellfanFilter.FanKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aCellFanCollection.CellFanFilter.CellfanFilter.FanKey);
             }
             if (aCellFanCollection.CellFanFilter.CellfanFilter.CellName != null)
             {
                 vStringBuilder.AppendFormat("and t1.CEL_Name like '%{0}%'", aCellFanCollection.CellFanFilter.CellfanFilter.CellName);
             }
             if (aCellFanCollection.CellFanFilter.CellfanFilter.FanName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Name like '%{0}%'", aCellFanCollection.CellFanFilter.CellfanFilter.FanName);
             }
         }
         vStringBuilder.AppendLine("order by t1.CEL_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vCellFan = new CellFan();
                 DataToObject(vCellFan, vSqlDataReader, false);
                 aCellFanCollection.CellFanList.Add(vCellFan);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 ///   Gets a specified <see cref="CellFan"/> by key.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param>
 /// <param name="aCellFan"><see cref="CellFan"/> object.</param>
 public static void GetCellFan(FanToken aFanToken, CellFan aCellFan)
 {
     FanCallHandler.ServiceCall <CellFan>(aFanToken, "GetCellFan", aCellFan);
 }
Ejemplo n.º 15
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="CellFan"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aCell">A <see cref="CellFan"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, CellFan aCellFan)
 {
     aSqlCommand.Parameters.AddWithValue("@CELKey", aCellFan.CelKey);
     aSqlCommand.Parameters.AddWithValue("@FANKey", aCellFan.FanKey);
     aSqlCommand.Parameters.AddWithValue("@CELFANDateJoined", aCellFan.CellFanDateJoined);
 }
Ejemplo n.º 16
0
 /// <summary>
 ///   Update a <see cref="CellFan"/> passed as an argument .
 /// </summary>
 /// <param name="aCellFan">A <see cref="CellFan"/>.</param>
 public static void Update(CellFan aCellFan)
 {
     if (aCellFan == null)
     {
         throw new ArgumentNullException("aCellFan");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update CAN_CellFan");
         vStringBuilder.AppendLine("set    CAN_DateJoined = @CANDateJoined,");
         vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         ObjectToData(vSqlCommand, aCellFan);
         vSqlCommand.Parameters.AddWithValue("@CANDateJoined", aCellFan.CellFanDateJoined);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 17
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="CellFan"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aCell">A <see cref="CellFan"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, CellFan aCellFan)
 {
     aSqlCommand.Parameters.AddWithValue("@CELKey", aCellFan.CelKey);
     aSqlCommand.Parameters.AddWithValue("@FANKey", aCellFan.FanKey);
     aSqlCommand.Parameters.AddWithValue("@CELFANDateJoined", aCellFan.CellFanDateJoined);
 }
Ejemplo n.º 18
0
 /// <summary>
 ///   Gets the <see cref="CellFan"/> by Key.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns>CellFan as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string GetCellFan(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of GetCellFan");
     }
     CellFan vCellFan = new CellFan();
     vCellFan = XmlUtils.Deserialize<CellFan>(aXmlArgument);
     CellFanBusiness.Load(aFanKey, vCellFan);
     return XmlUtils.Serialize<CellFan>(vCellFan, true);
 }
Ejemplo n.º 19
0
 /// <summary>
 ///   Gets a specified <see cref="CellFan"/> by key.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param>
 /// <param name="aCellFan"><see cref="CellFan"/> object.</param>
 public static void GetCellFan(FanToken aFanToken, CellFan aCellFan)
 {
     FanCallHandler.ServiceCall<CellFan>(aFanToken, "GetCellFan", aCellFan);
 }