public ActionResult StartRoutine(int teachingRoutineID)
        {
            DateTime currDate   = DateTime.Now.Date;
            int      currUserID = CurrentUser.GetUserID();

            using (FATContainer dataContainer = new FATContainer())
            {
                TeachingRoutine tchRoutine = SharedCasePool.GetCasePool().GetRoutine(teachingRoutineID);
                TeachingNode    firstNode  = tchRoutine.NodeList[tchRoutine.NodeList.Keys[0]];
                StudentActivity activity   = dataContainer.StudentActivity.FirstOrDefault(act => (act.UserID == currUserID) && (act.TimeMark >= currDate) && (act.TchRoutineID == teachingRoutineID));
                if (activity == null)
                {
                    activity = dataContainer.StudentActivity.Create();
                }
                activity.TchNodeID    = firstNode.Row_ID;
                activity.IsFinished   = 0;
                activity.TchRoutineID = teachingRoutineID;
                activity.UserID       = CurrentUser.GetUserID();
                activity.TimeMark     = DateTime.Now.Date;
                if (activity.Row_ID == 0)
                {
                    dataContainer.StudentActivity.Add(activity);
                    dataContainer.SaveChanges();
                }
                else
                {
                    dataContainer.Entry <StudentActivity>(activity).CurrentValues.SetValues(activity);
                    dataContainer.SaveChanges();
                }

                JsonResult result = new JsonResult();
                result.Data = string.Format("{0}/{1}/{2}", firstNode.NodeType, firstNode.NodeTag, firstNode.Row_ID);
                return(result);
            }
        }
Exemple #2
0
        public ActionResult InitIndividualSavingData()
        {
            using (FATContainer dataContainer = new FATContainer())
            {
                int             tchRoutineID = Convert.ToInt32(RouteData.Values["tchRoutineID"]);
                TeachingRoutine routine      = SharedCasePool.GetCasePool().GetRoutine(tchRoutineID);

                //all tags: DWHQ_Deposit DWHQ_Withdraw DWHQ_Interest DWHQ_Clear DWZZ_Deposit DWZZ_Withdraw DWLZ_Deposit DWLZ_Withdraw DWZL_Deposit DWZL_Withdraw DWZL_Interest DWTI_Deposit DWTI_Interest DWTI_Withdraw
                //Section controls which section should be displayed and filled
                ViewBag.Section = routine.RelTmpRoutine.RoutineTag.Split('_')[1];

                IndividualSaving info = dataContainer.IndividualSaving.FirstOrDefault(item => (item.TchRoutineID == tchRoutineID));
                if (info == null)
                {
                    info = dataContainer.IndividualSaving.Create();
                    info.TchRoutineID      = tchRoutineID;
                    info.AccountCreateTime = DateTime.Now;
                    info.DepositTime       = DateTime.Now;
                    info.WithdrawTime      = DateTime.Now;
                    info.InterestTime      = DateTime.Now;
                    dataContainer.IndividualSaving.Add(info);
                    dataContainer.SaveChanges();
                }
                return(View("IndividualSaving", info));
            }
        }
        public ActionResult ListStudiedRoutine()
        {
            using (FATContainer dataContainer = new FATContainer())
            {
                JsonResult             result       = new JsonResult();
                DateTime               currDate     = DateTime.Now.Date;
                List <StudentActivity> activityList = dataContainer.StudentActivity.Where(act => act.TimeMark >= currDate).OrderBy(act => act.IsFinished).ToList();
                SharedCasePool         casePool     = SharedCasePool.GetCasePool();
                foreach (StudentActivity activity in activityList)
                {
                    TeachingRoutine routine = casePool.GetRoutine(activity.TchRoutineID);
                    if (routine == null)
                    {
                        result.Data = CommFunctions.WrapClientGridData(new List <StudentActivity>());
                        return(result);
                    }
                    activity.CaseName       = routine.CaseName;
                    activity.TmpRoutineName = routine.RelTmpRoutine.RoutineName;

                    if (activity.TchNodeID == -1)
                    {
                        activity.TmpNodeName = "(已完成)";
                    }
                    else
                    {
                        activity.TmpNodeName = routine.NodeList[activity.TchNodeID].RelTmpNode.NodeName;
                        activity.NodeType    = routine.NodeList[activity.TchNodeID].RelTmpNode.NodeType;
                        activity.NodeTag     = routine.NodeList[activity.TchNodeID].RelTmpNode.Tag;
                    }
                }
                activityList.Clear();
                result.Data = CommFunctions.WrapClientGridData(activityList);
                return(result);
            }
        }
        public ActionResult LoadSubNode(int teachingRoutineID)
        {
            TeachingRoutine routine = SharedCasePool.GetCasePool().GetRoutine(teachingRoutineID);
            JsonResult      result  = new JsonResult();

            result.Data = CommFunctions.WrapClientGridData(routine.NodeList.Values.OrderBy(node => node.Index).ToList());
            return(result);
        }
Exemple #5
0
        public ActionResult SubjectFiller()
        {
            int             tchRoutineID = Convert.ToInt32(RouteData.Values["rid"]);
            int             tchNodeID    = Convert.ToInt32(RouteData.Values["nid"]);
            TeachingRoutine routine      = SharedCasePool.GetCasePool().GetRoutine(tchRoutineID);

            using (FATContainer dataContainer = new FATContainer())
            {
                List <SubjectItem> subjectList = dataContainer.SubjectItem.Where(s => s.TchNodeID == tchNodeID && s.TchRoutineID == tchRoutineID).OrderBy(s => s.SubjectOrient).ToList();
                ViewBag.ResourceFile = "T1_DebitTransferCheck_S12";
                return(View(subjectList));
            }
        }
Exemple #6
0
 public ActionResult Guide()
 {
     using (FATContainer dataContainer = new FATContainer())
     {
         TeachingNode    node       = dataContainer.TeachingNode.Find(Convert.ToInt32(RouteData.Values["id"]));
         TeachingRoutine tchRoutine = SharedCasePool.GetCasePool().GetRoutine(node.RoutineID);
         ViewBag.CurrGroup    = tchRoutine.NodeList[node.Row_ID].GroupIdx;
         ViewBag.TchNodeID    = node.Row_ID;
         ViewBag.CaseName     = tchRoutine.CaseName;
         ViewBag.RoutineIntro = tchRoutine.GroupList[tchRoutine.NodeList[node.Row_ID].GroupIdx].RoutineIntro;
         return(View("RoutineStepProgress", tchRoutine));
     }
 }
        public ActionResult ChangeCaseStatus(bool isEnabled, int tchRoutineID)
        {
            using (FATContainer dataContainer = new FATContainer())
            {
                TeachingRoutine cachedRoutine = SharedCasePool.GetCasePool().GetRoutine(tchRoutineID);
                cachedRoutine.CurrStatus = Convert.ToInt16(isEnabled ? 1 : 0);

                TeachingRoutine dbRoutine = dataContainer.TeachingRoutine.Find(tchRoutineID);
                dbRoutine.CurrStatus = cachedRoutine.CurrStatus;

                dataContainer.SaveChanges();
            }
            return(null);
        }
Exemple #8
0
 public ActionResult GeneralLedger()
 {
     using (FATContainer dataContainer = new FATContainer())
     {
         TeachingNode         node    = dataContainer.TeachingNode.Find(Convert.ToInt32(RouteData.Values["id"]));
         List <GeneralLedger> glList  = dataContainer.GeneralLedger.Where(info => (info.TchNodeID == node.Row_ID) && (info.TchRoutineID == node.RoutineID)).ToList();
         TeachingRoutine      routine = SharedCasePool.GetCasePool().GetRoutine(node.RoutineID);
         ViewBag.RoutineName = routine.RelTmpRoutine.RoutineName;
         node             = routine.FindNode(node.Row_ID);
         ViewBag.NodeName = node.NodeName;
         ViewData[ConstDefine.ViewData_CaseText] = SharedCasePool.GetCasePool().GetRoutine(node.RoutineID).GroupList[node.GroupIdx].GroupText;
         return(View(glList));
     }
 }
Exemple #9
0
        public ActionResult UpdateCase(int tchRoutineID, string caseName, string caseText)
        {
            using (FATContainer dataContainer = new FATContainer())
            {
                TeachingRoutine cachedRoutine = SharedCasePool.GetCasePool().GetRoutine(tchRoutineID);
                cachedRoutine.CaseName = caseName;

                TeachingRoutine dbRoutine = dataContainer.TeachingRoutine.Find(tchRoutineID);
                dataContainer.Entry <TeachingRoutine>(dbRoutine).CurrentValues.SetValues(cachedRoutine);

                dataContainer.SaveChanges();
            }
            return(null);
        }
Exemple #10
0
 public ActionResult ResetRoutine(int activityID)
 {
     using (FATContainer dataContainer = new FATContainer())
     {
         StudentActivity activity   = dataContainer.StudentActivity.First(act => act.Row_ID == activityID);
         TeachingRoutine tchRoutine = SharedCasePool.GetCasePool().GetRoutine(activity.TchRoutineID);
         activity.IsFinished = 0;
         activity.TchNodeID  = tchRoutine.NodeList[tchRoutine.NodeList.Keys[0]].Row_ID;
         dataContainer.SaveChanges();
         JsonResult   result    = new JsonResult();
         TeachingNode firstNode = tchRoutine.NodeList[tchRoutine.NodeList.Keys[0]];
         result.Data = string.Format("{0}/{1}/{2}", firstNode.NodeType, firstNode.NodeTag, firstNode.Row_ID);
         return(result);
     }
 }
Exemple #11
0
 public ActionResult BankDraft()
 {
     using (FATContainer dataContainer = new FATContainer())
     {
         int             tchRoutineID = dataContainer.TeachingNode.Find(Convert.ToInt32(RouteData.Values["id"])).RoutineID;
         TeachingRoutine routine      = SharedCasePool.GetCasePool().GetRoutine(tchRoutineID);
         TeachingNode    node         = routine.NodeList[Convert.ToInt32(RouteData.Values["id"])];
         BankDraft       tcInfo       = dataContainer.BankDraft.FirstOrDefault(info => (info.TchRoutineID == node.RoutineID));
         ViewData[ConstDefine.ViewData_CaseText] = SharedCasePool.GetCasePool().GetRoutine(node.RoutineID).GroupList[node.GroupIdx].GroupText;
         ViewBag.RoutineName = routine.RelTmpRoutine.RoutineName;
         ViewBag.NodeName    = node.RelTmpNode.NodeName;
         ViewBag.TchNodeID   = node.Row_ID;
         return(View("BankDraft_" + node.Index, tcInfo));
     }
 }
Exemple #12
0
 public ActionResult GetNextNode(int teachingRoutineID, int teachingNodeID)
 {
     using (FATContainer dataContainer = new FATContainer())
     {
         TeachingNode    nextNode = SharedCasePool.GetCasePool().NavigateToNextNode(teachingRoutineID, teachingNodeID);
         StudentActivity activity = dataContainer.StudentActivity.FirstOrDefault(act => act.UserID == CurrentUser.GetUserID() && act.TimeMark == DateTime.Now.Date && act.TchRoutineID == teachingRoutineID);
         if (activity == null)
         {
             activity = dataContainer.StudentActivity.Create();
         }
         JsonResult result = new JsonResult();
         if (nextNode == null)
         {
             CurrentUser.SetLastFinishedRoutineID(teachingRoutineID);
             result.Data = "/Teachings/TeachingInit/SelectT1Case";
             if (activity.Row_ID == 0)
             {
                 activity.TchNodeID    = -1;
                 activity.IsFinished   = 1;
                 activity.TchRoutineID = teachingRoutineID;
                 activity.UserID       = CurrentUser.GetUserID();
                 activity.TimeMark     = DateTime.Now.Date;
                 dataContainer.StudentActivity.Add(activity);
                 dataContainer.SaveChanges();
             }
             else
             {
                 activity.TchNodeID  = -1;
                 activity.IsFinished = 1;
                 dataContainer.Entry <StudentActivity>(activity).CurrentValues.SetValues(activity);
                 dataContainer.SaveChanges();
             }
         }
         else
         {
             TeachingRoutine routine = SharedCasePool.GetCasePool().GetRoutine(teachingNodeID);
             if (routine.NodeList.Keys.IndexOf(activity.TchNodeID) < routine.NodeList.Keys.IndexOf(nextNode.Row_ID))
             {
                 activity.TchNodeID  = nextNode.Row_ID;
                 activity.IsFinished = 0;
                 //dataContainer.Entry<StudentActivity>(activity).CurrentValues.SetValues(activity);
                 dataContainer.SaveChanges();
             }
             result.Data = string.Format("{0}/{1}/{2}", nextNode.NodeType, nextNode.NodeTag, nextNode.Row_ID);
         }
         return(result);
     }
 }
        public ActionResult UpdateCase(int tchRoutineID, string caseName)
        {
            using (FATContainer dataContainer = new FATContainer())
            {
                TeachingRoutine cachedRoutine = SharedCasePool.GetCasePool().GetRoutine(tchRoutineID);
                cachedRoutine.CaseName = caseName;

                TeachingRoutine dbRoutine = dataContainer.TeachingRoutine.Find(tchRoutineID);
                dataContainer.Entry <TeachingRoutine>(dbRoutine).CurrentValues.SetValues(cachedRoutine);

                dataContainer.SaveChanges();
            }
            SharedCasePool.GetCasePool().ReloadRoutine(tchRoutineID);
            JsonResult result = new JsonResult();

            result.Data = string.Empty;
            return(result);
        }
        //combine text in textList with: 1. ID   2.CaseText   3.CaseIntro    with the splitter: ~
        public ActionResult UpdateGroupText(int tchRoutineID, List <string> textList)
        {
            using (FATContainer dataContainer = new FATContainer())
            {
                foreach (string strVar in textList)
                {
                    string[]     arr      = strVar.Split('~');
                    RoutineGroup groupObj = dataContainer.RoutineGroup.Find(Convert.ToInt32(arr[0]));
                    groupObj.GroupText    = arr[1];
                    groupObj.RoutineIntro = arr[2];
                }

                dataContainer.SaveChanges();
            }
            SharedCasePool.GetCasePool().ReloadRoutine(tchRoutineID);
            JsonResult result = new JsonResult();

            result.Data = string.Empty;
            return(result);
        }
Exemple #15
0
        public ActionResult InterestVoucher()
        {
            using (FATContainer dataContainer = new FATContainer())
            {
                int              tchRoutineID = dataContainer.TeachingNode.Find(Convert.ToInt32(RouteData.Values["id"])).RoutineID;
                TeachingRoutine  routine      = SharedCasePool.GetCasePool().GetRoutine(tchRoutineID);
                TeachingNode     node         = routine.NodeList[Convert.ToInt32(RouteData.Values["id"])];
                IndividualSaving targetObj    = dataContainer.IndividualSaving.FirstOrDefault(info => (info.TchRoutineID == node.RoutineID));
                ViewData[ConstDefine.ViewData_CaseText] = SharedCasePool.GetCasePool().GetRoutine(node.RoutineID).GroupList[node.GroupIdx].GroupText;
                ViewBag.RoutineName  = routine.RelTmpRoutine.RoutineName;
                ViewBag.NodeName     = node.RelTmpNode.NodeName;
                ViewBag.TchNodeID    = node.Row_ID;
                ViewBag.TchRoutineID = routine.Row_ID;

                Type       type   = Type.GetType("FATS.BusinessObject.Converters.InterestVoucherConverter");
                MethodInfo method = type.GetMethod(routine.RelTmpRoutine.RoutineTag, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);

                V_InterestVoucher modalInfo = (V_InterestVoucher)method.Invoke(null, new Object[] { targetObj });

                return(View("IndividualSaving_Interest", modalInfo));
            }
        }
        public ActionResult Edit()
        {
            TeachingRoutine routine = SharedCasePool.GetCasePool().GetRoutine(Convert.ToInt32(RouteData.Values["id"]));

            return(View("T1RoutineDetail", routine));
        }
Exemple #17
0
        public ActionResult GetNavigationContext(int teachingRoutineID, int teachingNodeID)
        {
            using (FATContainer dataContainer = new FATContainer())
            {
                TeachingRoutine routine      = SharedCasePool.GetCasePool().GetRoutine(teachingRoutineID);
                int             currNodeIdx  = routine.NodeList.Keys.IndexOf(teachingNodeID);
                int             maxNodeCount = routine.NodeList.Count;
                DateTime        currDate     = DateTime.Now.Date;
                int             currUserID   = CurrentUser.GetUserID();
                StudentActivity activity     = dataContainer.StudentActivity.FirstOrDefault(act => act.UserID == currUserID && act.TimeMark >= currDate && act.TchRoutineID == teachingRoutineID);
                ClientContext   context      = new ClientContext();
                context.IsTeacher = CurrentUser.GetUserInfo().IsTeacher;
                if (currNodeIdx == 0)
                {
                    context.PrevTchNodeID   = -1;
                    context.PrevTchNodeTag  = string.Empty;
                    context.PrevTchNodeType = string.Empty;
                }
                else
                {
                    TeachingNode prevNode = routine.NodeList[routine.NodeList.Keys[currNodeIdx - 1]];
                    context.PrevTchNodeID  = prevNode.Row_ID;
                    context.PrevTchNodeTag = prevNode.NodeTag;
                    context.PrevTchNodeTag = prevNode.NodeType;
                }
                if (currNodeIdx == maxNodeCount - 1)
                {
                    context.NextTchNodeID   = -1;
                    context.NextTchNodeTag  = string.Empty;
                    context.NextTchNodeType = string.Empty;
                }
                else
                {
                    TeachingNode nextNode = routine.NodeList[routine.NodeList.Keys[currNodeIdx + 1]];
                    context.NextTchNodeID   = nextNode.Row_ID;
                    context.NextTchNodeTag  = nextNode.NodeTag;
                    context.NextTchNodeType = nextNode.NodeType;
                }
                context.TchRoutineID = routine.Row_ID;

                //normally it won't occur
                //i wonder if the code is necessary, just the protection for the unexpected bug?
                if (activity == null)
                {
                    context.IsFinished    = 0;
                    activity              = dataContainer.StudentActivity.Create();
                    activity.TchNodeID    = teachingNodeID;
                    activity.IsFinished   = 0;
                    activity.TchRoutineID = teachingRoutineID;
                    activity.UserID       = CurrentUser.GetUserID();
                    activity.TimeMark     = DateTime.Now.Date;
                    dataContainer.StudentActivity.Add(activity);
                    dataContainer.SaveChanges();
                }
                else
                {
                    if (activity.IsFinished == 1)
                    {
                        context.IsFinished = 1;
                    }
                    else
                    {
                        int currActivityIdx = routine.NodeList.Keys.IndexOf(activity.TchNodeID);
                        context.IsFinished = (currNodeIdx < currActivityIdx) ? 1 : 0;
                        if (currNodeIdx > currActivityIdx)
                        {
                            activity.TchNodeID = routine.NodeList[teachingNodeID].Row_ID;
                            dataContainer.SaveChanges();
                        }
                    }
                }

                JsonResult result = new JsonResult();
                result.Data = context;
                return(result);
            }
        }
Exemple #18
0
        public ActionResult SelectNode()
        {
            TeachingRoutine routine = SharedCasePool.GetCasePool().GetRoutine(Convert.ToInt32(RouteData.Values["id"]));

            return(View(routine));
        }