public IDataReader GetWeeklyReport(IDbConnection cn, string account, DateTime date)
        {
            DateTime firstDate;
            DateTime lastDate;

            YZDateHelper.GetWeekStartEndDate(date, out firstDate, out lastDate);
            lastDate = lastDate.AddDays(1);

            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection  = cn as SqlConnection;
                cmd.CommandText = "SELECT * FROM iWeeklyReport WHERE Account = @Account AND Date >= @firstDate AND Date < @lastDate ORDER BY Date DESC,ItemID DESC";

                cmd.Parameters.Add("@Account", SqlDbType.NVarChar).Value   = account;
                cmd.Parameters.Add("@firstDate", SqlDbType.DateTime).Value = firstDate;
                cmd.Parameters.Add("@lastDate", SqlDbType.DateTime).Value  = lastDate;
                return(cmd.ExecuteReader());
            }
        }
Пример #2
0
        protected virtual WeeklyReportCollection ConvertToYearWeekResult(int year, WeeklyReportCollection reports)
        {
            WeeklyReportCollection rv = new WeeklyReportCollection();
            DateTime today            = DateTime.Today;
            int      weeks;

            if (today.Year == year)
            {
                weeks = YZDateHelper.GetWeekOfYear(today);
            }
            else
            {
                weeks = YZDateHelper.WeeksInYear(year);
            }

            DateTime firstDate = YZDateHelper.GetWeekFirstDate(year, weeks);
            DateTime lastDate  = firstDate.AddDays(6);

            for (int i = weeks; i > 0; i--)
            {
                WeeklyReport report = reports.TryGetItem(firstDate, lastDate);
                if (report == null)
                {
                    report         = new WeeklyReport();
                    report.IsEmpty = true;
                    report.ItemID  = -i;
                    report.TaskID  = -1;
                    report.Date    = lastDate;
                }
                rv.Add(report);

                report["Week"]      = i;
                report["FirstDate"] = firstDate;
                report["LastDate"]  = lastDate;

                firstDate = firstDate.AddDays(-7);
                lastDate  = lastDate.AddDays(-7);
            }

            return(rv);
        }
Пример #3
0
        public IDataReader GetWeeklyReport(IDbConnection cn, string account, DateTime date)
        {
            DateTime firstDate;
            DateTime lastDate;

            YZDateHelper.GetWeekStartEndDate(date, out firstDate, out lastDate);
            lastDate = lastDate.AddDays(1);

            using (OracleCommand cmd = new OracleCommand())
            {
                cmd.Connection = cn as OracleConnection;
                cmd.BindByName = true;

                cmd.CommandText = "SELECT * FROM iWeeklyReport WHERE Account = :Account AND \"DATE\" >= :firstDate AND \"DATE\" < :lastDate ORDER BY \"DATE\" DESC,ItemID DESC";

                cmd.Parameters.Add(":Account", OracleDbType.NVarchar2).Value = account;
                cmd.Parameters.Add(":firstDate", OracleDbType.Date).Value    = firstDate;
                cmd.Parameters.Add(":lastDate", OracleDbType.Date).Value     = lastDate;
                return(cmd.ExecuteReader());
            }
        }