Exemple #1
0
 private void FillData()
 {
     if (!CreditCardCur.IsNew)
     {
         string ccNum = CreditCardCur.CCNumberMasked;
         if (Regex.IsMatch(ccNum, "^\\d{12}(\\d{0,7})"))                 //Credit cards can have a minimum of 12 digits, maximum of 19
         {
             int idxLast4Digits = (ccNum.Length - 4);
             ccNum = (new string('X', 12)) + ccNum.Substring(idxLast4Digits);               //replace the first 12 with 12 X's
         }
         textCardNumber.Text = ccNum;
         textAddress.Text    = CreditCardCur.Address;
         if (CreditCardCur.CCExpiration.Year > 1800)
         {
             textExpDate.Text = CreditCardCur.CCExpiration.ToString("MMyy");
         }
         textZip.Text = CreditCardCur.Zip;
         if (_isXChargeEnabled || _isPayConnectEnabled || _isPaySimpleEnabled)                 //Only fill information if using X-Charge, PayConnect, or PaySimple.
         {
             if (CreditCardCur.ChargeAmt > 0)
             {
                 textChargeAmt.Text = CreditCardCur.ChargeAmt.ToString("F");
             }
             if (CreditCardCur.DateStart.Year > 1880)
             {
                 textDateStart.Text = CreditCardCur.DateStart.ToShortDateString();
             }
             if (CreditCardCur.DateStop.Year > 1880)
             {
                 textDateStop.Text = CreditCardCur.DateStop.ToShortDateString();
             }
             textNote.Text = CreditCardCur.Note;
             if (CreditCardCur.ChargeFrequency != "")                   //No charge frequency set
             {
                 if (CreditCards.GetFrequencyType(CreditCardCur.ChargeFrequency) == ChargeFrequencyType.FixedDayOfMonth)
                 {
                     //No need to change check as it is FixedDayOfMonth default
                     textDayOfMonth.Text = CreditCards.GetDaysOfMonthForChargeFrequency(CreditCardCur.ChargeFrequency);
                 }
                 else                          //FixedDayOfWeek
                 {
                     radioWeekDay.Checked         = true;
                     comboFrequency.SelectedIndex = (int)CreditCards.GetDayOfWeekFrequency(CreditCardCur.ChargeFrequency);
                     comboDays.SelectedIndex      = (int)CreditCards.GetDayOfWeek(CreditCardCur.ChargeFrequency);
                 }
             }
         }
         if (_isPaySimpleEnabled)
         {
             textAccountType.Text = (CreditCardCur.CCSource == CreditCardSource.PaySimpleACH ? Lans.g(this, "ACH") : Lans.g(this, "Credit Card"));
         }
     }
 }
Exemple #2
0
        ///<summary>Fills comboBoxMonthSelect when appropriate, otherwise butThisMonth and butLastMonth are used.  Returns true if comboBoxMonthSelect
        ///will be used instead of butThisMonth/butLastMonth.</summary>
        private bool FillComboBoxMonthSelect()
        {
            switch (CreditCards.GetFrequencyType(_creditCardCur.ChargeFrequency))
            {
            case ChargeFrequencyType.FixedDayOfMonth:                    //EX: 2nd and 15th of each Month, instance of a singular day being charged is in GetValidPayDate(...)
                List <int> listDaysOfMonth = CreditCards.GetDaysOfMonthForChargeFrequency(_creditCardCur.ChargeFrequency).Split(',').Select(x => PIn.Int(x))
                                             .OrderByDescending(x => x).ToList();
                if (listDaysOfMonth.Count > 1)
                {
                    comboBoxMonthSelect.Items.Clear();
                    List <DateTime> listDates = new List <DateTime>();
                    listDaysOfMonth.ForEach(x => {
                        int monthOffset    = (x > DateTime.Today.Day) ? -1 : 0;
                        DateTime thisMonth = GetDateForDayOfMonth(DateTime.Today.AddMonths(monthOffset), x);                              //This Month/Closest Month
                        DateTime lastMonth = GetDateForDayOfMonth(DateTime.Today.AddMonths(monthOffset - 1), x);                          //Last Month/Previous Month
                        if (thisMonth >= _creditCardCur.DateStart)
                        {
                            listDates.Add(thisMonth);
                        }
                        if (lastMonth >= _creditCardCur.DateStart)
                        {
                            listDates.Add(lastMonth);
                        }
                    });
                    listDates.OrderByDescending(x => x).ForEach(x => comboBoxMonthSelect.Items.Add(new ODBoxItem <DateTime>(x.ToShortDateString(), x)));
                    if (comboBoxMonthSelect.Items.Count > 0)
                    {
                        comboBoxMonthSelect.SelectedIndex = 0;                              //Begin with the most recent date.
                    }
                    EnableComboBoxMonthUI();
                    return(true);
                }
                break;

            case ChargeFrequencyType.FixedWeekDay:
                DayOfWeekFrequency frequency   = CreditCards.GetDayOfWeekFrequency(_creditCardCur.ChargeFrequency);
                DayOfWeek          ccDayOfWeek = CreditCards.GetDayOfWeek(_creditCardCur.ChargeFrequency);
                if (frequency.In(DayOfWeekFrequency.Every, DayOfWeekFrequency.EveryOther))
                {
                    FillComboBoxForWeekDays(ccDayOfWeek, isEveryOther: frequency == DayOfWeekFrequency.EveryOther);
                    EnableComboBoxMonthUI();
                    return(true);
                }
                break;

            default:
                throw new ODException(Lan.g(this, "Invalid ChargeFrequency."));
            }
            return(false);           //Either the frequency is FixedDayOfMonth with 1 day per month, or it is FixedWeekDay with nth day frequency (1st, 2nd, 3rd, etc.)
        }
Exemple #3
0
        ///<summary>Returns a valid date based on the Month and Year taken from the date passed in and the Day that is set for the recurring charges.</summary>
        private DateTime GetValidPayDate(DateTime date)
        {
            int      dayOfMonth;
            DateTime retVal;

            if (PrefC.IsODHQ && PrefC.GetBool(PrefName.BillingUseBillingCycleDay))
            {
                dayOfMonth = _pat.BillingCycleDay;
                return(GetDateForDayOfMonth(date, dayOfMonth));
            }
            switch (CreditCards.GetFrequencyType(_creditCardCur.ChargeFrequency))
            {
            case ChargeFrequencyType.FixedDayOfMonth:                    //EX: 1st of Each Month (This check only accounts for a singular day of the month being run)
                List <int> listDaysOfMonth = CreditCards.GetDaysOfMonthForChargeFrequency(_creditCardCur.ChargeFrequency).Split(',').Select(x => PIn.Int(x))
                                             .OrderByDescending(x => x).ToList();
                if (listDaysOfMonth.Count == 1)                       //There is only 1 day being charged in a month
                {
                    dayOfMonth = listDaysOfMonth.First();
                    //This may result in a future date for the "This Month" button. The button will get disabled later.
                    retVal = GetDateForDayOfMonth(date, dayOfMonth);
                }
                else
                {
                    throw new ODException(Lan.g(this, "Invalid ChargeFrequency."));
                }
                break;

            case ChargeFrequencyType.FixedWeekDay:
                DayOfWeekFrequency frequency = CreditCards.GetDayOfWeekFrequency(_creditCardCur.ChargeFrequency);
                if (!frequency.In(DayOfWeekFrequency.Every, DayOfWeekFrequency.EveryOther))                        //EX: 1st Sunday of Each Month
                {
                    retVal = CreditCards.GetNthWeekdayofMonth(date, (int)frequency - 1, CreditCards.GetDayOfWeek(_creditCardCur.ChargeFrequency));
                    //This may result in a future date for the "This Month" button. The button will get disabled later.
                }
                else
                {
                    throw new ODException(Lan.g(this, "Invalid ChargeFrequency."));
                }
                break;

            default:
                throw new ODException(Lan.g(this, "Invalid ChargeFrequency."));
            }
            return(retVal);
        }