Beispiel #1
0
        public ActionResult EditCoachRevenueIndicator(MonthlyCoachRevenueIndicatorQueryViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;
            if (viewModel.KeyID != null)
            {
                viewModel.PeriodID = viewModel.DecryptKeyValue();
            }

            var indicator = models.GetTable <MonthlyIndicator>().Where(c => c.PeriodID == viewModel.PeriodID).FirstOrDefault();

            if (indicator == null)
            {
                return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml", model: "資料錯誤!!"));
            }

            var item = models.GetTable <MonthlyCoachRevenueIndicator>()
                       .Where(c => c.PeriodID == viewModel.PeriodID && c.CoachID == viewModel.CoachID).FirstOrDefault();

            if (item != null)
            {
                viewModel.AchievementGoal     = item.AchievementGoal;
                viewModel.CompleteLessonsGoal = item.CompleteLessonsGoal;
                viewModel.BRCount             = item.BRCount;
                viewModel.AverageLessonPrice  = item.AverageLessonPrice;
            }
            else
            {
                viewModel.AverageLessonPrice = indicator.CalculateAverageLessonPrice(models, viewModel.CoachID);
            }

            return(View("~/Views/BusinessConsole/Module/SelectCoachAchievementGoal.cshtml", indicator));
        }
Beispiel #2
0
        public ActionResult ProcessCoachRevenueIndicator(MonthlyCoachRevenueIndicatorQueryViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;
            if (viewModel.KeyID != null)
            {
                viewModel.PeriodID = viewModel.DecryptKeyValue();
            }

            var item = models.GetTable <MonthlyCoachRevenueIndicator>().Where(c => c.PeriodID == viewModel.PeriodID && c.CoachID == viewModel.CoachID).FirstOrDefault();

            if (item == null)
            {
                return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml", model: "資料錯誤!!"));
            }

            return(View("~/Views/BusinessConsole/Module/ProcessCoachRevenueIndicator.cshtml", item));
        }
Beispiel #3
0
        public ActionResult DeleteCoachRevenueIndicator(MonthlyCoachRevenueIndicatorQueryViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;
            if (viewModel.KeyID != null)
            {
                viewModel.PeriodID = viewModel.DecryptKeyValue();
            }

            var count = models.ExecuteCommand("delete [KPI].MonthlyCoachRevenueIndicator where PeriodID={0} and CoachID={1}", viewModel.PeriodID, viewModel.CoachID);

            if (count > 0)
            {
                return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { result = false, message = "刪除失敗!!" }, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public ActionResult ApplyCoachAchievement(MonthlyCoachRevenueIndicatorQueryViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;
            if (viewModel.KeyID != null)
            {
                viewModel.PeriodID = viewModel.DecryptKeyValue();
            }

            if (!viewModel.Year.HasValue || !viewModel.Month.HasValue)
            {
                viewModel.Year  = DateTime.Today.Year;
                viewModel.Month = DateTime.Today.Month;
            }

            var item = viewModel.AssertMonthlyIndicator(models);

            return(View("~/Views/BusinessConsole/Module/SelectCoachAchievementGoal.cshtml", item));
        }
Beispiel #5
0
        // GET: AchievementConsole
        public ActionResult InquireMonthlyCoachRevenue(MonthlyCoachRevenueIndicatorQueryViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;

            int?coachID = viewModel.CoachID;

            if (viewModel.KeyID != null)
            {
                coachID = viewModel.DecryptKeyValue();
            }

            IQueryable <MonthlyIndicator> indicatorItems = viewModel.InquireMonthlyIndicator(models);

            IQueryable <MonthlyCoachRevenueIndicator> items = models.GetTable <MonthlyCoachRevenueIndicator>()
                                                              .Where(c => c.CoachID == viewModel.CoachID)
                                                              .Join(indicatorItems, c => c.PeriodID, m => m.PeriodID, (c, m) => c);

            return(View("~/Views/AchievementConsole/Module/InquireMonthlyCoachRevenue.cshtml", items));
        }
Beispiel #6
0
        public ActionResult MakeStrategyAnalysis(MonthlyCoachRevenueIndicatorQueryViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;
            if (viewModel.KeyID != null)
            {
                viewModel.PeriodID = viewModel.DecryptKeyValue();
            }

            var item = models.GetTable <MonthlyBranchIndicator>().Where(c => c.PeriodID == viewModel.PeriodID && c.BranchID == viewModel.BranchID).FirstOrDefault();

            if (item == null)
            {
                return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml", model: "資料錯誤!!"));
            }

            viewModel.RiskPrediction = item.RiskPrediction;
            viewModel.Strategy       = item.Strategy;
            viewModel.Comment        = item.Comment;

            return(View("~/Views/BusinessConsole/Module/MakeStrategyAnalysis.cshtml", item));
        }
Beispiel #7
0
        public ActionResult CommitStrategyAnalysis(MonthlyCoachRevenueIndicatorQueryViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;
            if (viewModel.KeyID != null)
            {
                viewModel.PeriodID = viewModel.DecryptKeyValue();
            }

            var item = models.GetTable <MonthlyBranchIndicator>().Where(c => c.PeriodID == viewModel.PeriodID && c.BranchID == viewModel.BranchID).FirstOrDefault();

            if (item == null)
            {
                return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml", model: "資料錯誤!!"));
            }

            item.RiskPrediction = viewModel.RiskPrediction;
            item.Strategy       = viewModel.Strategy;
            //item.Comment = viewModel.Comment;

            models.SubmitChanges();

            return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
        }