private Dictionary <string, string> Validate()
        {
            Dictionary <string, string> ValErrors = new Dictionary <string, string>();

            if (String.IsNullOrEmpty(txtName.Text))
            {
                ValErrors.Add("Name", "Name is required.");
            }
            if (PaymentMethodID == 0 && PaymentMethod.GetPaymentMethods(txtName.Text.Trim(), false).Count > 0)
            {
                ValErrors.Add("Name", "A payment method already exists with the name " + txtName.Text.Trim());
            }
            if (tglCreditCard.Checked)
            {
                if (string.IsNullOrEmpty(txtAccountLastFour.Text))
                {
                    ValErrors.Add("Account Last 4", "Last 4 numbers of account number is required.");
                }
                else if (!System.Text.RegularExpressions.Regex.IsMatch(txtAccountLastFour.Text.Trim(), @"^\d{4}$"))
                {
                    ValErrors.Add("Account Last 4", "Last four numbers of account number must be numeric.");
                }

                if (pickerAccountOwner.PersonAliasId <= 0)
                {
                    ValErrors.Add("Account Owner", "Account Owner is required.");
                }

                if (ddlExpMonth.Text == "Month" || ddlExpYear.Text == "Year")
                {
                    ValErrors.Add("Expiration Date", "Expiration Date is required.");
                }

                if (PaymentMethodID == 0 && GetExpirationDate() < DateTime.Now.Date)
                {
                    ValErrors.Add("Expiration Date", "Expiration Date must be in the future.");
                }
                if (GetExpirationDate() == DateTime.MinValue)
                {
                    ValErrors.Add("Expiration Date", "Expiration Date is not valid.");
                }
            }

            return(ValErrors);
        }
        private void LoadPaymentMethods()
        {
            ConfigureGrid();

            List <PaymentMethod> PayMethods = PaymentMethod.GetPaymentMethods(chkActiveOnly.Checked).OrderBy(x => x.Name).ToList();

            SortProperty sortProperty = dgPayMethods.SortProperty;

            if (sortProperty != null)
            {
                if (sortProperty.Direction == SortDirection.Ascending)
                {
                    PayMethods = PayMethods.OrderBy(r => r.GetType().GetProperty(sortProperty.Property) != null?r.GetType().GetProperty(sortProperty.Property).GetValue(r):null).ToList();
                }
                else
                {
                    PayMethods = PayMethods.OrderByDescending(r => r.GetType().GetProperty(sortProperty.Property) != null?r.GetType().GetProperty(sortProperty.Property).GetValue(r):null).ToList();
                }
            }
            else
            {
                PayMethods = PayMethods.OrderBy(pm => pm.PaymentMethodID).ToList();
            }

            if (!String.IsNullOrEmpty(txtFilterPaymentMethodName.Text))
            {
                PayMethods.RemoveAll(p => !(p.Name.ToLower().Contains(txtFilterPaymentMethodName.Text.ToLower())));
            }
            if (chkFilterCreditCard.Checked)
            {
                PayMethods.RemoveAll(p => p.CreditCardID == 0);
            }

            DataTable dt = BuildDataTable(PayMethods);

            dgPayMethods.DataSource = dt;
            dgPayMethods.DataBind();
        }