/// <summary>
        /// Gets the statistics.
        /// </summary>
        /// <param name="sessionID">The sessionID of the current session</param>
        /// <param name="stat">The stat.</param>
        /// <param name="typeOfStat">The type of stat.</param>
        /// <param name="productID">The product ID.</param>
        /// <param name="start">The start date and time </param>
        /// <param name="end">The end date and time</param>
        /// <returns></returns>
        public List<double> GetStatistics(string sessionID, StatObject stat, StatType typeOfStat, int productID, DateTime start, DateTime end)
        {
            if (stat == StatObject.Income)
            {
                if (typeOfStat == StatType.ForEachDay)
                {

                    BillItemsTableAdapter bia = new BillItemsTableAdapter();
                    CustomerTransactionsTableAdapter cta = new CustomerTransactionsTableAdapter();
                    var transactions = cta.GetDataByTimeFrame(start, end);
                    int numOfDays = (int)(end.Date.Subtract(start.Date).TotalDays);

                    double[] re = new double[numOfDays+1];
                    foreach (var trans in transactions)
                    {
                        if (!trans.IsEndTimeNull())
                        {
                            int dayVal = (int)(trans.EndTime.Date.Subtract(start.Date).TotalDays);
                            var bills = bia.GetDataByWorkflowID(trans.WorkflowInstID);
                            re[dayVal] += (double)(from p in bills select p.Price).Sum();
                        }
                    }
                    return re.ToList();

                }
            }
            else if (stat == StatObject.PayroleExpence)
            {
                if (typeOfStat == StatType.ForEachDay)
                {
                    WorkerShiftsTableAdapter wta = new WorkerShiftsTableAdapter();
                    var shifts = wta.GetDataByTimeFrame(start, end);
                    int numOfDays = (int)(end.Date.Subtract(start.Date).TotalDays);
                    RolePayrateTableAdapter rta = new RolePayrateTableAdapter();
                    var payoutTable = rta.GetData();
                    List<double> re = new List<double>();

                    DateTime i_start = start.Date;
                    DateTime i_end = i_start.Add(new TimeSpan(1, 0, 0, 0));
                    for (int i = 0; i < numOfDays; i++)
                    {
                        decimal v = (from p in shifts
                                     where p.StartTime > i_start && p.StartTime < i_end &&
                                     p.IsEndTimeNull() == false
                                     select (from q in payoutTable where q.Role == p.Role select q.PayPerHour).FirstOrDefault()
                                     * (decimal)(p.EndTime.Subtract(p.StartTime).TotalHours)).Sum();
                        re.Add((double)v);
                        i_start = i_end;
                        i_end = i_start.Add(new TimeSpan(1, 0, 0, 0));

                    }
                    return re;
                }
            }
            return null;
        }
        /// <summary>
        /// Gets a list of the shifts for employees during a timeframe.
        /// </summary>
        /// <param name="sessionID">The sessionID of the current session</param>
        /// <param name="start">The start of the timeframe.</param>
        /// <param name="end">The end of the timeframe.</param>
        /// <returns></returns>
        public List<ShiftData> GetShiftsForEmployees(string sessionID, DateTime start, DateTime end)
        {
            List<ShiftData> re = new List<ShiftData>();
            WorkerShiftsTableAdapter wsa = new WorkerShiftsTableAdapter();
            var rows = wsa.GetDataByTimeFrame(start, end);
            foreach (var row in rows)
            {
                ShiftData sd = new ShiftData();
                sd.EmployeeID = row.EmployeeID;
                sd.StartTime = row.StartTime;
                if (row.IsEndTimeNull()) sd.EndTime = null;
                else
                    sd.EndTime = row.EndTime;
                sd.ShiftID = row.ID;
                sd.Role = row.Role;
                if (sd.EndTime != null)
                    sd.HoursWorked = (decimal)sd.EndTime.Value.Subtract(sd.StartTime).TotalHours;
                else
                    sd.HoursWorked = 0;

                re.Add(sd);
            }
            return re;
        }