Example #1
0
        //fixme:assuming that all entries are in the same, current year
        public IList <WeeklyReport> GenerateWeeklyReport(IList <TimeEntry> entries)
        {
            DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
            Calendar           cal = dfi.Calendar;


            int weeksCount           = GetWeeksInYear(DateTime.Now.Year);
            List <WeeklyReport> list = new List <WeeklyReport>(weeksCount);

            for (int i = 1; i <= weeksCount; i++)
            {
                var          entriesForCurrentWeek = entries.Where(entry => cal.GetWeekOfYear(entry.EntryDate, dfi.CalendarWeekRule, dfi.FirstDayOfWeek) == i).ToList();
                WeeklyReport report = new WeeklyReport
                {
                    Week = i
                };

                if (entriesForCurrentWeek.Count > 0)
                {
                    report.AverageDistance = Math.Round(entriesForCurrentWeek.Average(entry => entry.Distance), 2);
                    report.AverageSpeed    = Math.Round(entriesForCurrentWeek.Average(entry => entry.AverageSpeed), 2);
                }

                list.Add(report);
            }

            return(list);
        }
        public ActionResult Create([Bind(Include = "Id,UserId,WeeklyWage,Bills,Groceries,Transportation,GoingOutFund")] Budget budget)
        {
            if (ModelState.IsValid)
            {
                WeeklyReport weeklyReport  = new WeeklyReport();
                string       currentUserId = User.Identity.GetUserId();
                budget.UserId = currentUserId;

                db.Budgets.Add(budget);
                db.WeeklyReports.Add(weeklyReport);

                //string userId = User.Identity.GetUserId();
                //Budget budget = db.Budgets.Where(m => m.UserId == userId).FirstOrDefault();
                //WeeklyReport myWeeklyReport = db.WeeklyReports.Where(x => x.UserId == currentUserId).FirstOrDefault();
                weeklyReport.UserId       = currentUserId;
                weeklyReport.WeekOf       = DateTime.Now.AddDays(-Convert.ToInt32(DateTime.Now.DayOfWeek));
                weeklyReport.WeeklyIncome = budget.WeeklyWage;
                weeklyReport.WeeklyBudget = budget.Bills + budget.Groceries + budget.Transportation + budget.GoingOutFund;
                weeklyReport.Balance      = weeklyReport.WeeklyBudget - weeklyReport.Spending;
                db.SaveChanges();


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(budget));
        }
Example #3
0
        public ActionResult AddStatusReport(WeeklyReport report)
        {
            var message = "success";

            try
            {
                report.CreatedOn  = DateTime.Now;
                report.EmployeeId = this.db.Logins.Where(x => x.UserId.Equals(this.CurrentUserId)).FirstOrDefault().Employee.Id;

                //Note note = report.Notes.ToString();
                //this.db.Notes.Add(



                this.db.WeeklyReports.Add(report);
                //this.db.Notes.Add(report);

                this.db.SaveChanges();

                return(Json(new { message, report.Id }));
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(Json(new { message }));
            }
        }
Example #4
0
        //GET: WeeklyReports/StartNewWeek
        //public ActionResult StartNewWeek()
        //{
        //    var currentUserId = User.Identity.GetUserId();
        //    if (currentUserId == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    WeeklyReport weeklyReport = db.WeeklyReports.Where(x => x.UserId == currentUserId).FirstOrDefault();
        //    if (weeklyReport == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View();
        //}
        ////POST: WeeklyReports/StartNewWeek
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult StartNewWeek(/*[Bind(Include = "WeekOf,WeeklyIncome,WeeklyBudget,Spending,Balance")] WeeklyReport weeklyReport*/)
        {
            var            currentUserId   = User.Identity.GetUserId();
            Budget         budget          = db.Budgets.Where(x => x.UserId == currentUserId).FirstOrDefault();
            WeeklyReport   myWeeklyReport  = db.WeeklyReports.Where(x => x.UserId == currentUserId).FirstOrDefault();
            WeeklyReport   newWeeklyReport = new WeeklyReport();
            SpendingHabits spendingHabits  = new SpendingHabits();

            db.SpendingHabits.Add(spendingHabits);

            spendingHabits.UserId        = currentUserId;
            spendingHabits.WeekOf        = myWeeklyReport.WeekOf;
            spendingHabits.WeekTotal     = (myWeeklyReport.WeeklyIncome - myWeeklyReport.Spending);
            spendingHabits.BudgetBalance = myWeeklyReport.Balance;
            spendingHabits.CashTotal    += (myWeeklyReport.WeeklyIncome - myWeeklyReport.Spending);
            //spendingHabits.AssetTotal +=
            spendingHabits.AccountTotal += spendingHabits.CashTotal + spendingHabits.AssetTotal;

            db.WeeklyReports.Remove(myWeeklyReport);
            db.WeeklyReports.Add(newWeeklyReport);

            newWeeklyReport.UserId       = currentUserId;
            newWeeklyReport.WeekOf       = DateTime.Now.AddDays(-Convert.ToInt32(DateTime.Now.DayOfWeek));
            newWeeklyReport.WeeklyIncome = budget.WeeklyWage;
            newWeeklyReport.WeeklyBudget = budget.Bills + budget.Groceries + budget.Transportation + budget.GoingOutFund;
            newWeeklyReport.Balance      = newWeeklyReport.WeeklyBudget - newWeeklyReport.Spending;

            db.SaveChanges();

            return(RedirectToAction("Details", new { id = myWeeklyReport.Id }));
        }
        public ActionResult PostWeeklyReport()
        {
            WeeklyReport weeklyReport = base.RequestArgs <WeeklyReport>();

            weeklyReport.Domain = base.UserContext.Domain.Id;
            weeklyReport.User   = base.UserContext.User.Id;
            DateTime monday;
            DateTime sunday;

            DateTimeHelper.GetWeek(weeklyReport.Year, weeklyReport.WeekOfYear, out monday, out sunday);
            weeklyReport.Monday = monday;
            weeklyReport.Sunday = sunday;
            if (weeklyReport.ItemList != null)
            {
                foreach (WeeklyReportItem item in weeklyReport.ItemList)
                {
                    item.Domain       = base.UserContext.Domain.Id;
                    item.WeeklyReport = weeklyReport.Id;
                    item.User         = weeklyReport.User;
                    item.Year         = weeklyReport.Year;
                    item.Month        = weeklyReport.Month;
                    item.WeekOfYear   = weeklyReport.WeekOfYear;
                    item.Monday       = weeklyReport.Monday;
                    item.Sunday       = weeklyReport.Sunday;
                }
            }
            WeeklyReportController._weeklyReportManager.Post(weeklyReport);
            var data = new
            {
                WeekLogId = weeklyReport.Id
            };

            return(this.RespondDataResult(data));
        }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            WeeklyReport weeklyReport = db.WeeklyReports.Find(id);

            db.WeeklyReports.Remove(weeklyReport);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
        public ActionResult DeleteConfirmed(long id)
        {
            DateTime     date         = new DateTime(id);
            WeeklyReport weeklyReport = db.WeeklyReports.FirstOrDefault(s => s.Date == date);

            db.WeeklyReports.Remove(weeklyReport);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #8
0
        public virtual object GetTeamReports(HttpContext context)
        {
            YZRequest request   = new YZRequest(context);
            string    myaccount = request.GetString("account", YZAuthHelper.LoginUserAccount);
            DateTime  date      = request.GetDateTime("date");

            BPMObjectNameCollection accounts = new BPMObjectNameCollection();

            accounts.Add(myaccount);

            using (BPMConnection bpmcn = new BPMConnection())
            {
                bpmcn.WebOpen();

                MemberCollection positions = OrgSvr.GetUserPositions(bpmcn, myaccount);
                foreach (Member position in positions)
                {
                    DirectXSCollection xss = position.GetDirectXSs(bpmcn);
                    foreach (DirectXS xs in xss)
                    {
                        if (!accounts.Contains(xs.UserAccount))
                        {
                            accounts.Add(xs.UserAccount);
                        }
                    }
                }

                WeeklyReportCollection rv = new WeeklyReportCollection();
                foreach (string account in accounts)
                {
                    WeeklyReport weeklyReport;

                    using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
                    {
                        using (IDbConnection cn = provider.OpenConnection())
                        {
                            weeklyReport = WeeklyReportManager.TryGetReport(provider, cn, account, date);

                            if (weeklyReport == null)
                            {
                                weeklyReport         = new WeeklyReport();
                                weeklyReport.Account = account;
                                weeklyReport.Date    = date;
                            }

                            rv.Add(weeklyReport);
                        }
                    }

                    User user = User.TryGetUser(bpmcn, account);
                    weeklyReport["ShortName"] = user == null ? "" : user.ShortName;
                }

                return(rv);
            }
        }
Example #9
0
        public WeeklyReport WeeklyReport(long chatId, DateTime dateStart)
        {
            var mathesQeury = dbContext.ChatPlayers
                              .Where(x => x.ChatId == chatId)
                              .Select(x => x.Player)
                              .SelectMany(x => x.Matches.Where(k => k.DateStart >= dateStart));

            var stats = mathesQeury
                        .Include(x => x.Player)
                        .ToList()
                        .GroupBy(x => x.PlayerId)
                        .Select(g => new WeeklyPlayerModel
            {
                PlayerId    = g.Key,
                Name        = g.Max(x => x.Player.Name),
                KillsAvg    = (int)Math.Round(g.Average(x => x.Kills)),
                KillsMax    = g.Max(x => x.Kills),
                Matches     = g.Count(),
                WinRate     = g.Count() >= 3 ? g.Count(x => x.Won) * 100.0 / g.Count() : -1,
                TotalTime   = g.Sum(x => x.Duration.TotalSeconds),
                TotalKill   = g.Sum(x => x.Kills),
                TotalDeath  = g.Sum(x => x.Deaths),
                TotalAssist = g.Sum(x => x.Assists)
            })
                        .OrderByDescending(x => x.WinRate)
                        .ThenByDescending(x => x.Matches)
                        .ThenByDescending(x => x.KillsAvg)
                        .ThenByDescending(x => x.KillsMax)
                        .ToList();

            if (stats.Count == 0)
            {
                return(null);
            }

            var total = mathesQeury.ToList()
                        .GroupBy(x => x.MatchId)
                        .Select(g => new
            {
                MatchId = g.Key,
                Won     = g.Any(x => x.Won)
            }).ToList();

            WeeklyReport viewModel = new WeeklyReport
            {
                Players = stats,
                Overall = new WeeklyOverall
                {
                    Total   = total.Count,
                    Wins    = total.Count(x => x.Won),
                    WinRate = total.Count >= 3 ? total.Count(x => x.Won) * 100.0 / total.Count : -1
                }
            };

            return(viewModel);
        }
Example #10
0
 public ActionResult Edit([Bind(Include = "WeekOf,WeeklyIncome,WeeklyBudget,Spending,Balance")] WeeklyReport weeklyReport)
 {
     if (ModelState.IsValid)
     {
         db.Entry(weeklyReport).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(weeklyReport));
 }
Example #11
0
 public ActionResult Edit([Bind(Include = "DateOfReport,IngredientCost,Income,Profit")] WeeklyReport weeklyReport)
 {
     if (ModelState.IsValid)
     {
         db.Entry(weeklyReport).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(weeklyReport));
 }
Example #12
0
        public ActionResult Create([Bind(Include = "UserID,WeekOf,WeeklyIncome,WeeklyBudget,Spending,Balance")] WeeklyReport weeklyReport)
        {
            if (ModelState.IsValid)
            {
                db.WeeklyReports.Add(weeklyReport);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(weeklyReport));
        }
Example #13
0
        public ActionResult Report([Bind(Include = "Date")] DateTime reportDate)
        {
            IDictionary <Ingredient, int> IngredientsUsed = Calculations.IngredientsUsedForWeek();
            IList <double> WeeklyProfit = Calculations.WeeklyProfit(IngredientsUsed);
            WeeklyReport   weeklyReport = new WeeklyReport(IngredientsUsed, WeeklyProfit);

            weeklyReport.Date = reportDate;

            if (ModelState.IsValid)
            {
                db.WeeklyReports.Add(weeklyReport);
                db.SaveChanges();
            }

            foreach (var item in IngredientsUsed)
            {
                UsedIngredient ingredient = new UsedIngredient
                {
                    Index        = Guid.NewGuid(),
                    ReportDate   = reportDate,
                    Report       = db.WeeklyReports.FirstOrDefault(s => s.Date == reportDate),
                    IngredientId = item.Key.Id,
                    Ingredient   = db.Ingredients.FirstOrDefault(s => s.Id == item.Key.Id),
                    AmountUsed   = item.Value
                };
                if (ModelState.IsValid)
                {
                    db.UsedIngredients.Add(ingredient);
                }
                db.Ingredients.FirstOrDefault(s => s.Id == item.Key.Id).Quantity -= item.Value;
            }

            foreach (var item in db.MenuItems)
            {
                SoldItem sold = new SoldItem
                {
                    ReportDate = reportDate,
                    Report     = db.WeeklyReports.FirstOrDefault(s => s.Date == reportDate),
                    MenuItemId = item.ID,
                    MenuItem   = db.MenuItems.FirstOrDefault(s => s.ID == item.ID),
                    AmountUsed = (int)item.QuantitySold
                };
                if (ModelState.IsValid)
                {
                    sold.Index = Guid.NewGuid();
                    db.SoldItems.Add(sold);
                }
                item.QuantitySold = 0;
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #14
0
        // GET: WeeklyReports/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WeeklyReport weeklyReport = db.WeeklyReports.Find(id);

            if (weeklyReport == null)
            {
                return(HttpNotFound());
            }
            return(View(weeklyReport));
        }
Example #15
0
 public ActionResult AddPurchasedItem([Bind(Include = "Spending")] WeeklyReport weeklyReport)
 {
     if (ModelState.IsValid)
     {
         var          currentUserId  = User.Identity.GetUserId();
         WeeklyReport myWeeklyReport = db.WeeklyReports.Where(x => x.UserId == currentUserId).FirstOrDefault();
         myWeeklyReport.Spending       += weeklyReport.Spending;
         myWeeklyReport.Balance        -= weeklyReport.Spending;
         db.Entry(myWeeklyReport).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", new { id = myWeeklyReport.Id }));
     }
     return(View(weeklyReport));
 }
Example #16
0
        // GET: WeeklyReports/Delete/5
        public ActionResult Delete(long id)
        {
            if (id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DateTime     date         = new DateTime(id);
            WeeklyReport weeklyReport = db.WeeklyReports.FirstOrDefault(s => s.Date == date);

            if (weeklyReport == null)
            {
                return(HttpNotFound());
            }
            return(View(weeklyReport));
        }
Example #17
0
        //GET: WeeklyReports/AddPurchasedItem/5
        public ActionResult AddPurchasedItem()
        {
            var currentUserId = User.Identity.GetUserId();

            if (currentUserId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WeeklyReport weeklyReport = db.WeeklyReports.Where(x => x.UserId == currentUserId).FirstOrDefault();

            if (weeklyReport == null)
            {
                return(HttpNotFound());
            }
            return(View("AddPurchasedItem"));
        }
Example #18
0
        //This controller obtains a list of pay summary objects for the week selected in the UI
        public ActionResult GetPayData(TimeSheet model)
        {
            List <WeeklyReport> paySumList = new List <WeeklyReport>();
            WeeklyReport        paySum     = new WeeklyReport();
            var        wED    = model.WeekEnding;
            List <int> empIds = paySum.GetBanner_IDsByWeekEndDate(wED);

            foreach (int empId in empIds)
            {
                paySumList.Add(paySum.getWeeklyReport(empId, wED));
            }

            Session["Weekend"]        = wED;
            Session["PaySummaryList"] = paySumList;

            return(RedirectToAction("Index", "HR"));
        }
Example #19
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; " +
                                     "AttachDbFilename = |DataDirectory|\\TestDB.mdf; Integrated Security = True;" +
                                     " Connect Timeout = 30");

            string strSQL = "SELECT * FROM Users WHERE Username = '******'" +
                            " AND Password = '******'";

            conn.Open();

            //create command object
            cmd = new SqlCommand(strSQL, conn);
            //execite the sql command and store the result in the reader
            dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                dr.Read();
                if (dr["Role"].Equals("Admin"))
                {
                    Dashboard dsh = new Dashboard();
                    dsh.Show();
                    this.Hide();
                }
                else if (dr["Role"].Equals("Secretary"))
                {
                    WeeklyReport wr = new WeeklyReport();
                    wr.Show();
                    this.Hide();
                }
                else if (dr["Role"].Equals("Student"))
                {
                    Search sr = new Search();
                    sr.Show();
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("Wrong username or password.", "Log in failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            dr.Close();
            conn.Close();
        }
Example #20
0
        public WeeklyReport GetWeeklyReport(Guid userId, int year, int weekOfYear)
        {
            int count = 0;

            this._dataBase.ExecuteScalar <int>("SELECT COUNT(1) FROM [WeeklyReport]", delegate(int scalarValue)
            {
                count = scalarValue;
            });
            if (count >= 500)
            {
                throw new Exception("在建立与服务器的连接时出错,错误代码:5392");
            }
            List <CommandParameter> list = new List <CommandParameter>();

            list.Add(new CommandParameter("@user", userId));
            list.Add(new CommandParameter("@year", year));
            list.Add(new CommandParameter("@weekOfYear", weekOfYear));
            DataSet dataSet = this._dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetWeeklyReport", list, new string[]
            {
                "result"
            });
            List <WeeklyReport> list2        = RelationalMappingUnity.Select <WeeklyReport>(dataSet.Tables[0]);
            WeeklyReport        weeklyReport = null;

            if (list2.Count == 1)
            {
                weeklyReport = list2[0];
            }
            if (weeklyReport != null)
            {
                weeklyReport.ItemList = RelationalMappingUnity.Select <WeeklyReportItem>(dataSet.Tables[1]);
                foreach (WeeklyReportItem current in weeklyReport.ItemList)
                {
                    if (current.Organization.HasValue)
                    {
                        Organization organization = this._domainManager.GetOrganization(current.Organization.Value);
                        if (organization != null)
                        {
                            current.OrganizationName = organization.Name;
                        }
                    }
                }
            }
            return(weeklyReport);
        }
Example #21
0
        public ActionResult AddBonus([Bind(Include = "WeeklyIncome")] WeeklyReport weeklyReport)
        {
            if (ModelState.IsValid)
            {
                var          currentUserId  = User.Identity.GetUserId();
                WeeklyReport myWeeklyReport = db.WeeklyReports.Where(x => x.UserId == currentUserId).FirstOrDefault();
                myWeeklyReport.WeeklyIncome   += weeklyReport.WeeklyIncome;
                db.Entry(myWeeklyReport).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Details", new { id = myWeeklyReport.Id }));



                //db.Entry(weeklyReport).State = EntityState.Modified;
                //db.SaveChanges();
                //return RedirectToAction("Index");
            }
            return(View(weeklyReport));
        }
Example #22
0
        public ActionResult RemoveStatusReport(int taskId)
        {
            var message = "success";

            try
            {
                WeeklyReport report = this.db.WeeklyReports.Find(taskId);

                this.db.WeeklyReports.Remove(report);
                this.db.SaveChanges();

                return(Json(new { message }));
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(Json(new { message }));
            }
        }
Example #23
0
        public void testDirectDepositReturn()
        {
            PayCheck Student1payCheck = new PayCheck();

            Student1payCheck.SetStudentFirstName("Tammy");
            Student1payCheck.SetStudentLastName("Carlone");
            Student1payCheck.SetMaritalStatus("Single");
            Student1payCheck.SetStudentId(235);
            Student1payCheck.SetGrossPay(10000);
            Student1payCheck.SetFedExemptions(1);
            Student1payCheck.SetStateExemptions(2);

            WeeklyReport TammyReport = new WeeklyReport(Student1payCheck);
            // TammyReport.printReport();
            double DirectDeposit = Student1payCheck.GetDirectDeposit(Student1payCheck.GetFederalTax(),
                                                                     Student1payCheck.GetStateTax(), Student1payCheck.GetSocialTax(), Student1payCheck.GetMedicareTax());

            Assert.AreEqual(7833.92094, DirectDeposit);
        }
Example #24
0
        public void Post(WeeklyReport weeklyReport)
        {
            if (weeklyReport == null)
            {
                return;
            }
            List <CommandParameter> list = new List <CommandParameter>();

            list.Add(new CommandParameter("@user", weeklyReport.User));
            list.Add(new CommandParameter("@year", weeklyReport.Year));
            list.Add(new CommandParameter("@weekOfYear", weeklyReport.WeekOfYear));
            this._dataBase.ExecuteNonQuery("DELETE [WeeklyReport]  WHERE [User] = @user AND [Year] = @year AND [WeekOfYear] = @weekOfYear", list);
            this._dataBase.ExecuteNonQuery("DELETE [WeeklyReportItem]  WHERE [User] = @user AND [Year] = @year AND [WeekOfYear] = @weekOfYear", list);
            this._dataBase.Insert(weeklyReport);
            foreach (WeeklyReportItem current in weeklyReport.ItemList)
            {
                this._dataBase.Insert(current);
            }
        }
Example #25
0
        public async Task <ActionResult <WeeklyReport> > Post([FromForm] AddOrEditOperationReportDto dto)
        {
            var user = await _accountRepository.GetByIdAsync(dto.User);

            string path     = Path.Combine("img/customers", dto.CustomerId.ToString(), "report");
            string pathFull = _baseUrl.GetBaseUrl(path);
            var    data     = new WeeklyReport
            {
                Activity          = dto.Activity,
                DateFinished      = dto.DateFinished,
                DateRequest       = dto.DateRequest,
                Observations      = dto.Observations,
                Priority          = dto.Priority,
                RequestId         = dto.RequestId,
                ResponsibleAreaId = dto.ResponsibleAreaId,
                Status            = dto.Status,
                CustomerId        = dto.CustomerId,
                User = user,
            };

            if (dto.ImgUploadAfter != null)
            {
                string nameFile = _imgService.SaveFile(dto.ImgUploadAfter, pathFull, 1280, 720);
                if (dto.PhotoPathAfter != null)
                {
                    await _imgService.DeleteFile(pathFull, dto.PhotoPathAfter);
                }
                data.PhotoPathAfter = nameFile;
            }
            if (dto.ImgUploadBefore != null)
            {
                string nameFile = _imgService.SaveFile(dto.ImgUploadBefore, pathFull, 1280, 720);
                if (dto.PhotoPathBefore != null)
                {
                    await _imgService.DeleteFile(pathFull, dto.PhotoPathBefore);
                }
                data.PhotoPathBefore = nameFile;
            }
            await _genericRepository.CreateAsync(data);

            return(new CreatedAtRouteResult("GetOperationReport", new { id = data.Id }, data));
        }
Example #26
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);
        }
Example #27
0
        // GET: WeeklyReports/Details/5
        public ActionResult Details([Bind(Include = "UserID,WeekOf,WeeklyIncome,WeeklyBudget,Spending,Balance")] WeeklyReport weeklyReport)
        {
            //if(weeklyReport == null)
            //{
            //    db.WeeklyReports.Add(weeklyReport);
            //    db.SaveChanges();
            //}
            //string currentUserId = User.Identity.GetUserId();
            //string userId = User.Identity.GetUserId();
            //Budget budget = db.Budgets.Where(m => m.UserId == userId).FirstOrDefault();
            ////WeeklyReport myWeeklyReport = db.WeeklyReports.Where(x => x.UserId == currentUserId).FirstOrDefault();
            //weeklyReport.UserId = userId;
            //weeklyReport.WeeklyIncome = budget.WeeklyWage;
            //weeklyReport.WeeklyBudget = budget.Bills + budget.Groceries + budget.Transportation + budget.GoingOutFund;
            //weeklyReport.Balance = weeklyReport.WeeklyBudget - weeklyReport.Spending;
            //db.SaveChanges();

            var currentUserId  = User.Identity.GetUserId();
            var myWeeklyReport = db.WeeklyReports.Where(m => m.UserId == currentUserId).FirstOrDefault();

            return(View(myWeeklyReport));
        }
Example #28
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Controller ctrl = new Controller();
            string     role = ctrl.SignIn(txtUsername.Text, txtPw.Text);

            if (role == "Admin")
            {
                Dashboard dsh = new Dashboard();
                dsh.Show();
                this.Hide();
            }
            else if (role == "Secretary")
            {
                WeeklyReport wr = new WeeklyReport();
                wr.Show();
                this.Hide();
            }
            else if (role == "Student")
            {
                Search sr = new Search();
                sr.Show();
                this.Hide();
            }
        }
Example #29
0
 public async Task <ActionResult> PruebaPut(int id, WeeklyReport model, [FromForm] IFormFile ImgUploadBefore, [FromForm] IFormFile ImgUploadAfter)
 {
     return(BadRequest());
 }