예제 #1
0
        /// <summary>
        /// Evaluates this event to determine the dates and times for which the event occurs.
        /// This method only evaluates events which occur between <paramref name="FromDate"/>
        /// and <paramref name="ToDate"/>; therefore, if you require a list of events which
        /// occur outside of this range, you must specify a <paramref name="FromDate"/> and
        /// <paramref name="ToDate"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method in called for a large number
        ///     of events, in sequence, or for a very large time span.
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        /// <returns></returns>
        public override ArrayList Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            DateTimes.Add(DTStart.Copy());
            Periods.Add(new Period(DTStart, Duration));

            // Evaluate recurrences normally
            base.Evaluate(FromDate, ToDate);

            // Remove DateTimes that already have a Period
            for (int i = DateTimes.Count - 1; i >= 0; i--)
            {
                foreach (Period p in Periods)
                {
                    if (p.StartTime == DateTimes[i])
                    {
                        DateTimes.RemoveAt(i);
                    }
                }
            }

            // Convert each calculated Date_Time into a Period.
            foreach (Date_Time dt in DateTimes)
            {
                Period p = new Period(dt, Duration);
                if (!Periods.Contains(p))
                {
                    Periods.Add(p);
                }
            }

            Periods.Sort();
            return(Periods);
        }
예제 #2
0
 private void DetermineStartingRecurrence(Recur recur, ref Date_Time dt)
 {
     if (recur.Count != int.MinValue)
     {
         dt = DTStart.Copy();
     }
     else
     {
         recur.IncrementDate(ref dt, -recur.Interval);
     }
 }
예제 #3
0
 private void ExtrapolateTimes()
 {
     if (DTEnd == null && DTStart != null && Duration != default(TimeSpan))
     {
         DTEnd = DTStart.Add(Duration);
     }
     else if (Duration == default(TimeSpan) && DTStart != null && DTEnd != null)
     {
         Duration = DTEnd.Subtract(DTStart);
     }
     else if (DTStart == null && Duration != default(TimeSpan) && DTEnd != null)
     {
         DTStart = DTEnd.Subtract(Duration);
     }
 }
예제 #4
0
        /// <summary>
        /// Evaluates this event to determine the dates and times for which the event occurs.
        /// This method only evaluates events which occur between <paramref name="FromDate"/>
        /// and <paramref name="ToDate"/>; therefore, if you require a list of events which
        /// occur outside of this range, you must specify a <paramref name="FromDate"/> and
        /// <paramref name="ToDate"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method in called for a large number
        ///     of events, in sequence, or for a very large time span.
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        /// <returns></returns>
        public override List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Make sure Duration is not null by now
            if (Duration == null)
            {
                // If a DTEnd was not provided, set one!
                if (DTEnd == null)
                {
                    DTEnd = DTStart.Copy();
                }
                Duration = DTEnd - DTStart;
            }

            // Add the event itself, before recurrence rules are evaluated
            // NOTE: this fixes a bug where (if evaluated multiple times)
            // a period can be added to the Periods collection multiple times.
            Period period = new Period(DTStart, Duration);

            if (!Periods.Contains(period))
            {
                Periods.Add(period);
            }

            // Evaluate recurrences normally
            base.Evaluate(FromDate, ToDate);

            // Ensure each period has a duration
            foreach (Period p in Periods)
            {
                if (p.EndTime == null)
                {
                    p.Duration = Duration;
                    p.EndTime  = p.StartTime + Duration;
                }
                // Ensure the Kind of time is consistent with DTStart
                else if (p.EndTime.Kind != DTStart.Kind)
                {
                    p.EndTime.Value = new DateTime(p.EndTime.Year, p.EndTime.Month, p.EndTime.Day,
                                                   p.EndTime.Hour, p.EndTime.Minute, p.EndTime.Second, DTStart.Kind);
                }
            }

            return(Periods);
        }
예제 #5
0
 protected void btnsetStart_OnClick(object sender, EventArgs e)
 {
     if (DTStart.IsDateEmpty)
     {
         DAL.Common.Alert("活动开始时间不可为空!");
         DTStart.Focus();
         return;
     }
     else
     {
         long userId = DAL.UserDAL.GetUserId();
         if (string.IsNullOrEmpty(Request.QueryString["ad"])) //Url中没有传递活动ID参数,则页面是新建活动,才做此项处理
         {
             DateTime dt = DTStart.SelectedDate;
             //dt = dt.ToLongTimeString();
             List <LADLL.QuerylearningActivity> myAc = DAL.LearningActivityDal.GetMySameActivities(userId, dt);
             if (myAc.Count > 0) //判断与选定时间点最近的活动记录数,如果有,则列出;
             {
                 gvFavs.DataSource = myAc;
                 //gvFavs.Columns.Remove();
                 gvFavs.DataBind();
                 chooseDiv.Visible = true;
                 newlaDiv.Visible  = false;
             }
             else //如果无,则只能新增
             {
                 chooseDiv.Visible = false;
                 newlaDiv.Visible  = true;
             }
         }
         lbStart.Visible       = true;
         lbStart.Text          = DTStart.SelectedDate.ToString();
         DTStart.Visible       = false;
         btnsetStart.Visible   = false;
         btnresetStart.Visible = true;
     }
 }
        }//end checkOut

        private double billingCapCalc(string eventID, string guardianID, string transactionDate, double eventFee)
        {
            string   familyID     = guardianID.Remove(guardianID.Length - 1);
            double   cap          = 100;
            int      billingStart = 20;
            int      billingEnd   = 19;
            DateTime DTStart;
            DateTime DTEnd;

            if (DateTime.Now.Day > billingEnd)
            {
                DTStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, billingStart);
                int endMonth = DTStart.Month + 1;
                if (endMonth == 13)
                {
                    int endYear = DTStart.Year + 1;
                    DTEnd = new DateTime(endYear, 1, billingEnd);
                }
                else
                {
                    DTEnd = new DateTime(DateTime.Now.Year, endMonth, billingEnd);
                }
            }
            else
            {
                DTEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, billingEnd);
                int startMonth = DTEnd.Month - 1;
                if (startMonth == 0)
                {
                    int startYear = DTEnd.Year - 1;
                    DTStart = new DateTime(startYear, 12, billingStart);
                }
                else
                {
                    DTStart = new DateTime(DateTime.Now.Year, startMonth, billingStart);
                }
            }

            string start = DTStart.ToString("yyyy-MM-dd");
            string end   = DTEnd.ToString("yyyy-MM-dd");

            if (eventID.CompareTo("000002") == 0 || eventID.CompareTo("000003") == 0)
            {
                string sql = "select sum(TransactionTotal) " +
                             "from AllowedConnections natural join ChildcareTransaction " +
                             "where Family_ID = @familyID and Event_ID IN ('000002', '000003') and TransactionDate between '" + start + "' and '" + end + "'";

                SQLiteCommand command = new SQLiteCommand(sql, conn);
                command.Parameters.Add(new SQLiteParameter("@familyID", familyID));

                object recordFound = null;
                try{
                    conn.Open();
                    recordFound = command.ExecuteScalar();
                    conn.Close();
                }
                catch (Exception) {
                    conn.Close();
                    MessageBox.Show("Database connection error: Unable to check if charge exceeds monthly maximum for normal care.");
                }

                double sum;
                if (recordFound == DBNull.Value || recordFound == null)
                {
                    return(0);
                }
                else
                {
                    sum = Convert.ToDouble(recordFound);
                }

                double total = sum + eventFee;

                double capdiff = total - cap;

                if (capdiff > 0 && capdiff < eventFee)
                {
                    return(capdiff);
                }
                else if (capdiff >= eventFee)
                {
                    return(eventFee);
                }
            }
            return(0.0);
        }//end billingCapReached