Esempio n. 1
0
        private void loadPaymentHistory(AffiliateHistory[] affiliatesHistory)
        {
            DataTable dtPaymentHistory = new DataTable("PaymentHistory");

            dtPaymentHistory.Columns.Add("ID");
            dtPaymentHistory.Columns.Add("AffiliateID");
            dtPaymentHistory.Columns.Add("Amount");
            dtPaymentHistory.Columns.Add("DatePaid");
            dtPaymentHistory.Columns.Add("Notes");

            foreach (AffiliateHistory affiliateHistory in affiliatesHistory)
            {
                dtPaymentHistory.Rows.Add(new object[]
                                          {
                                              affiliateHistory.ID,
                                              affiliateHistory.AffiliateID,
                                              affiliateHistory.Amount.ToString("C"),
                                              affiliateHistory.DatePaid,
                                              affiliateHistory.Notes,
                                          });
            }

            gvPaymentHistory.DataSource = dtPaymentHistory;
            gvPaymentHistory.DataBind();

            gvPaymentHistory.Visible = dtPaymentHistory.Rows.Count > 0;
        }
Esempio n. 2
0
        private void loadPaymentHistory(AffiliateHistory[] affiliatesHistory)
        {
            DataTable dtPaymentHistory = new DataTable("PaymentHistory");

            dtPaymentHistory.Columns.Add("ID");
            dtPaymentHistory.Columns.Add("AffiliateUsername");
            dtPaymentHistory.Columns.Add("Amount");
            dtPaymentHistory.Columns.Add("DatePaid");
            dtPaymentHistory.Columns.Add("Notes");
            dtPaymentHistory.Columns.Add("PrivateNotes");

            foreach (AffiliateHistory affiliateHistory in affiliatesHistory)
            {
                Affiliate affiliate = Affiliate.Fetch(affiliateHistory.AffiliateID);

                if (affiliate != null)
                {
                    dtPaymentHistory.Rows.Add(new object[]
                                          {
                                              affiliateHistory.ID,
                                              affiliate.Username,
                                              affiliateHistory.Amount.ToString("C"),
                                              affiliateHistory.DatePaid,
                                              affiliateHistory.Notes,
                                              affiliateHistory.PrivateNotes
                                          });    
                }
                else
                {
                    continue;
                }
            }

            gvPaymentHistory.DataSource = dtPaymentHistory;
            gvPaymentHistory.DataBind();

            gvPaymentHistory.Visible = dtPaymentHistory.Rows.Count > 0;
        }
Esempio n. 3
0
        /// <summary>
        /// Fetches affiliates history by specified arguments.
        /// It returns an empty array if there are no affiliates history in DB by specified arguments.
        /// If these arguments are null it returns all affiliates history from DB.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="affiliateID">The affiliate ID.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="datePayed">The date payed.</param>
        /// <param name="sortColumn">The sort column.</param>
        /// <returns></returns>
        private static AffiliateHistory[] Fetch(int? id, int? affiliateID, decimal? amount, DateTime? datePayed, eSortColumn sortColumn)
        {
            using (SqlConnection conn = Config.DB.Open())
            {
                SqlDataReader reader =
                    SqlHelper.ExecuteReader(conn, "FetchAffiliatesHistory", id, affiliateID, amount, datePayed, sortColumn);

                List<AffiliateHistory> lAffiliatesHistory = new List<AffiliateHistory>();

                while (reader.Read())
                {
                    AffiliateHistory affiliate = new AffiliateHistory();

                    affiliate.id = (int)reader["ID"];
                    affiliate.affiliateID = (int)reader["AffiliateID"];
                    affiliate.amount = (decimal)reader["Amount"];
                    affiliate.datePaid = (DateTime)reader["DatePaid"];
                    affiliate.notes = reader["Notes"] == DBNull.Value ? null : (string) reader["Notes"];
                    affiliate.privateNotes = reader["PrivateNotes"] == DBNull.Value ? null : (string)reader["PrivateNotes"];

                    lAffiliatesHistory.Add(affiliate);
                }

                return lAffiliatesHistory.ToArray();
            }
        }