private void loadCommissions(AffiliateCommission[] affiliateCommissions)
        {
            DataTable dtCommissions = new DataTable("Commissions");

            dtCommissions.Columns.Add("ID");
            dtCommissions.Columns.Add("Username");
            dtCommissions.Columns.Add("Amount");
            dtCommissions.Columns.Add("TimeStamp");
            dtCommissions.Columns.Add("Notes");

            foreach (AffiliateCommission affiliateCommission in affiliateCommissions)
            {
                dtCommissions.Rows.Add(new object[]
                                          {
                                              affiliateCommission.ID,
                                              affiliateCommission.Username,
                                              affiliateCommission.Amount.ToString("C"),
                                              affiliateCommission.TimeStamp,
                                              affiliateCommission.Notes,
                                          });
            }

            gvCommissions.DataSource = dtCommissions;
            gvCommissions.DataBind();

            gvCommissions.Visible = dtCommissions.Rows.Count > 0;
        }
        /// <summary>
        /// Fetches affiliate commissions by specified arguments.
        /// It returns an empty array if there are no affiliate commissions in DB by specified arguments.
        /// If these arguments are null it returns all affiliate commissions from DB.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="affiliateID">The affiliate ID.</param>
        /// <param name="paymentHistoryID">The payment history ID.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="timeStamp">The time stamp.</param>
        /// <param name="sortColumn">The sort column.</param>
        /// <returns></returns>
        private static AffiliateCommission[] Fetch(int? id, int? affiliateID, int? paymentHistoryID, string username, decimal? amount, DateTime? timeStamp, eSortColumn sortColumn)
        {
            using (SqlConnection conn = Config.DB.Open())
            {
                SqlDataReader reader = (SqlDataReader) 
                    SqlHelper.GetDB().ExecuteReader( "FetchAffiliateCommissions", id, affiliateID, paymentHistoryID, username, amount,
                                            timeStamp, sortColumn);

                List<AffiliateCommission> lAffiliateCommissions = new List<AffiliateCommission>();

                while (reader.Read())
                {
                    AffiliateCommission affiliateCommission = new AffiliateCommission();

                    affiliateCommission.id = (int) reader["ID"];
                    affiliateCommission.affiliateID = (int) reader["AffiliateID"];
                    affiliateCommission.paymentHistoryID = reader["PaymentHistoryID"] == DBNull.Value ? null : (int?) reader["PaymentHistoryID"];
                    affiliateCommission.username = (string) reader["Username"];
                    affiliateCommission.amount = (decimal) reader["Amount"];
                    affiliateCommission.timeStamp = (DateTime) reader["TimeStamp"];
                    affiliateCommission.notes = (string) reader["Notes"];

                    lAffiliateCommissions.Add(affiliateCommission);
                }

                return lAffiliateCommissions.ToArray();
            }
        }