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); } }
public ActionResult OuterSubject_Init() { using (FATContainer dataContainer = new FATContainer()) { OuterSubject osInfo = dataContainer.OuterSubject.Create(); osInfo.TchNodeID = Convert.ToInt32(RouteData.Values["id"]); TeachingNode tchNode = dataContainer.TeachingNode.FirstOrDefault(node => node.Row_ID == osInfo.TchNodeID); osInfo.TchRoutineID = tchNode.RoutineID; return(View(osInfo)); } }
public ActionResult CashJournal_Init() { using (FATContainer dataContainer = new FATContainer()) { CashJournal cjInfo = dataContainer.CashJournal.Create(); cjInfo.TchNodeID = Convert.ToInt32(RouteData.Values["id"]); TeachingNode tchNode = dataContainer.TeachingNode.FirstOrDefault(node => node.Row_ID == cjInfo.TchNodeID); cjInfo.TchRoutineID = tchNode.RoutineID; return(View(cjInfo)); } }
public ActionResult DetailedLedger_Init() { using (FATContainer dataContainer = new FATContainer()) { DetailedLedger dlInfo = dataContainer.DetailedLedger.Create(); dlInfo.TchNodeID = Convert.ToInt32(RouteData.Values["id"]); TeachingNode tchNode = dataContainer.TeachingNode.FirstOrDefault(node => node.Row_ID == dlInfo.TchNodeID); dlInfo.TchRoutineID = tchNode.RoutineID; return(View(dlInfo)); } }
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 EditSubjectItem() { using (FATContainer dataContainer = new FATContainer()) { TeachingNode tchNode = dataContainer.TeachingNode.Find(Convert.ToInt32(RouteData.Values["id"])); ViewBag.TchRoutineID = tchNode.RoutineID; ViewBag.TchNodeID = tchNode.Row_ID; TemplateNode tmpNode = dataContainer.TemplateNode.FirstOrDefault(n => n.Row_ID == tchNode.TmpNodeID); TemplateRoutine tmpRoutine = dataContainer.TemplateRoutine.FirstOrDefault(n => n.Row_ID == tmpNode.RoutineID); ViewBag.NodeTitle = tmpRoutine.RoutineName + " " + tmpNode.NodeName + "记账科目设置"; } return(View("EditSubjectItem1", new SubjectItem())); }
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)); } }
public TeachingNode NavigateToNextNode(int currTchRoutineID, int currTchNodeID) { TeachingRoutine tchRoutine = GetRoutine(currTchRoutineID); TeachingNode currNode = tchRoutine.NodeList[currTchNodeID]; int nodeIndex = tchRoutine.NodeList.Keys.IndexOf(currNode.Row_ID); if (nodeIndex == tchRoutine.NodeList.Count - 1) { return(null); } else { return(tchRoutine.NodeList[nodeIndex + 1]); } }
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); } }
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)); } }
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 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 InitT2RoutineData() { using (FATContainer dataContainer = new FATContainer()) { TeachingNode node = dataContainer.TeachingNode.Find(Convert.ToInt32(RouteData.Values["id"])); List <TransferCheck> tcList = dataContainer.TransferCheck.Where(info => (info.TchRoutineID == node.RoutineID)).ToList(); if (tcList.Count == 0) { TransferCheck tcInfo1 = dataContainer.TransferCheck.Create(); tcInfo1.TchRoutineID = node.RoutineID; tcInfo1.TchRoutineTag = RoutineConstDefine.T2_DebitTransferCheck_TransferCheck; dataContainer.TransferCheck.Add(tcInfo1); tcList.Add(tcInfo1); TransferCheck tcInfo2 = dataContainer.TransferCheck.Create(); tcInfo2.TchRoutineID = node.RoutineID; tcInfo2.TchRoutineTag = RoutineConstDefine.T2_DebitTransferCheck_TransferCheck; dataContainer.TransferCheck.Add(tcInfo2); tcList.Add(tcInfo2); dataContainer.SaveChanges(); } return(View(tcList)); } }
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); } }
public ActionResult AppendCase(TeachingRoutine routine) { using (FATContainer dataContainer = new FATContainer()) { dataContainer.TeachingRoutine.Add(routine); dataContainer.SaveChanges(); var tempateNodeList = from node in dataContainer.TemplateNode where node.RoutineID == routine.TmpRoutineID orderby node.NodeIndex select node; List <TeachingNode> tchNodeList = new List <TeachingNode>(); foreach (TemplateNode tmpNode in tempateNodeList) { TeachingNode newNode = new TeachingNode() { CurrStatus = 0, RelTmpNode = tmpNode, RoutineID = routine.Row_ID, TmpNodeID = tmpNode.Row_ID }; tchNodeList.Add(newNode); dataContainer.TeachingNode.Add(newNode); } dataContainer.SaveChanges(); string currPhaseName = string.Empty; foreach (TeachingNode tchNode in tchNodeList) { switch (tchNode.NodeTag) { case "Guide": { currPhaseName = tchNode.NodeName; RoutineGroup group = dataContainer.RoutineGroup.Create(); group.GroupText = string.Empty; group.GroupIdx = tchNode.GroupIdx; group.TchRoutineID = routine.Row_ID; group.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; group.RoutineIntro = string.Empty; dataContainer.RoutineGroup.Add(group); break; } #region common node case "DetailedLedger": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { DetailedLedger info = dataContainer.DetailedLedger.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.DetailedLedger.Add(info); } break; } case "CashJournal": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { CashJournal info = dataContainer.CashJournal.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.CashJournal.Add(info); } break; } case "OuterSubject": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { OuterSubject info = dataContainer.OuterSubject.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.OuterSubject.Add(info); } break; } case "CustomerLedger": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { CustomerLedger info = dataContainer.CustomerLedger.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; info.BalanceTime = DateTime.Now; dataContainer.CustomerLedger.Add(info); } break; } case "GeneralLedger": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { GeneralLedger info = dataContainer.GeneralLedger.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.GeneralLedger.Add(info); } break; } default: { if (tchNode.RelTmpNode.NodeType == "SpecialNode") { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { SubjectItem info = dataContainer.SubjectItem.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; dataContainer.SubjectItem.Add(info); } } break; } #endregion #region special node #endregion } } dataContainer.SaveChanges(); } JsonResult result = new JsonResult(); result.Data = routine; return(result); }