예제 #1
0
        public void AddHseqTaskRequest(HseqRecord record, HseqTask taskRequest, ApplicationDbContext db)
        {
            //if (record is Ncr)
            //{
            //    Ncr ncr = (Ncr)record;

            //HseqTask taskRequest = new HseqTask();

            //taskRequest.Owner = db.HseqUsers.Find(ApproverID);

            taskRequest.Owner        = db.HseqUsers.Find(taskRequest.OwnerID);
            taskRequest.Assignee     = db.HseqUsers.Find(taskRequest.AssigneeID);
            taskRequest.DateAssigned = DateTime.Now;
            if (taskRequest.DueDate == null || taskRequest.DueDate < DateTime.Now.Subtract(TimeSpan.FromDays(1)))
            {
                taskRequest.DueDate = DateTime.Now.AddDays(14);
            }
            else
            {
                taskRequest.DueDate = taskRequest.DueDate;
            }

            if (taskRequest.Status == null)
            {
                taskRequest.Status = TaskStatus.NotStarted;
            }
            taskRequest.HseqRecordID = record.HseqRecordID;
            record.Delegatables.Add(taskRequest);
            //}
        }
예제 #2
0
        //Type needs to come in
        public ActionResult Edit(int?recordId)
        {
            if (recordId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            HseqTask hseqTask = db.HseqTasks.Find(recordId);


            if (hseqTask == null)
            {
                return(HttpNotFound());
            }

            //Ncr hseqRecord = db.NcrRecords.Find(hseqTask.HseqRecordID);
            HseqRecord hseqRecord = db.HseqRecords.Find(hseqTask.HseqRecordID);

            if (hseqRecord == null)
            {
                return(HttpNotFound());
            }


            DelegatableVM delegatableVM = new DelegatableVM()
            {
                HseqRecord = hseqRecord,
                HseqTask   = hseqTask, /*hseqTask.AssigneeID = Utils.GetCurrentApplicationUser(db).HseqUserID;*/
                TaskOwners = db.HseqUsers
            };

            return(View(delegatableVM));
        }
예제 #3
0
        public ActionResult Create(DelegatableVM ncrVM)
        {
            HseqRecord ncr = null;

            if (ModelState.IsValid)
            {
                //ncr = db.NcrRecords.Find(ncrVM.HseqTask.HseqRecordID);
                ncr = db.HseqRecords.Find(ncrVM.HseqTask.HseqRecordID);
                ncrVM.HseqRecord = ncr;

                HseqTask hseqTask = ncrVM.HseqTask;

                _DelegatableService.AddHseqTaskRequest(ncr, hseqTask, db);

                db.SaveChanges();
                return(RedirectToAction("OpenAction", "HseqTasks"));
            }
            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors);
                Console.WriteLine(errors);
            }

            return(View(ncrVM));
        }
        public ActionResult TaskGridViewUpdate(HseqTaskEditViewModel taskEditVM)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (taskEditVM != null)
                    {
                        HseqTask task = db.HseqTasks.Find(taskEditVM.DelegatableID);
                        Mapper.Map(taskEditVM, task);

                        db.Entry(task).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                    return(PartialView("_TaskEditView", taskEditVM));
                }
            }
            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors);
                ViewData["EditError"] = "Please, correct all errors.";
                return(PartialView("_TaskEditView", taskEditVM));
            }
            return(PartialView("_MainContentCallbackPanel"));
        }
예제 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            HseqTask hseqTask = db.HseqTasks.Find(id);

            db.HseqTasks.Remove(hseqTask);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #6
0
        // GET: HseqTasks1/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HseqTask hseqTask = db.HseqTasks.Find(id);

            if (hseqTask == null)
            {
                return(HttpNotFound());
            }
            return(View(hseqTask));
        }
예제 #7
0
        ///////////////////////////////////////////////////////////

        public ActionResult Create(int?recordId)
        {
            if (recordId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            //Ncr ncr = db.NcrRecords.Find(recordId);
            HseqRecord hseqRecord = db.HseqRecords.Find(recordId);

            if (hseqRecord == null)
            {
                return(HttpNotFound());
            }

            HseqTask hseqTask = new HseqTask()
            {
                DueDate      = DateTime.Now.AddDays(14),
                OwnerID      = Utils.GetCurrentApplicationUser(db).HseqUserID,
                Status       = TaskStatus.NotStarted,
                HseqRecordID = hseqRecord.HseqRecordID
            };

            DelegatableVM delegatableVM = new DelegatableVM()
            {
                HseqRecord = hseqRecord,
                HseqTask   = hseqTask, /*hseqTask.AssigneeID = Utils.GetCurrentApplicationUser(db).HseqUserID;*/
                TaskOwners = db.HseqUsers
            };

            //ViewBag.DispositionTypeID = new SelectList(db.DispositionTypes, "DispositionTypeID", "Name", ncr.DispositionTypeID);
            //ViewBag.AssigneeID = new SelectList(db.HseqUsers, "HseqUserID", "FullName", ncrVM.HseqTask.AssigneeID);
            //ViewBag.ApproverID = new SelectList(db.HseqUsers, "HseqUserID", "FullName", ncrVM.HseqTask.OwnerID);

            return(View(delegatableVM));
        }
        public ActionResult MainContentCallbackPanel()

        // DXCOMMENT: Pass a data model for GridView in the PartialView method's second parameter
        {
            if (DevExpressHelper.IsCallback)
            {
                NavigationFilter.RecordTypeCheckState      = null;
                NavigationFilter.ResponsibleAreaCheckState = null;
                NavigationFilter.CoordinatorsCheckState    = null;

                NavigationFilter.RecordTypes        = null;
                NavigationFilter.ResponsibleAreaIds = null;
                NavigationFilter.CoordinatorIds     = null;

                //Checked, Unchecked, Indeterminate

                NavigationFilter.RecordTypeCheckState      = Request.Params["recordTypeCheckState"];
                NavigationFilter.ResponsibleAreaCheckState = Request.Params["responsibleAreaCheckState"];
                NavigationFilter.CoordinatorsCheckState    = Request.Params["coordinatorsCheckState"];

                //Record Type
                if (!string.IsNullOrEmpty(Request.Params["recordTypeCheckedNodes"]))
                {
                    string recordTypeNodes = Request.Params["recordTypeCheckedNodes"];

                    NavigationFilter.RecordTypes = recordTypeNodes.Split(',');

                    setActiveTab();
                }

                //Responsible Area Type
                if (!string.IsNullOrEmpty(Request.Params["responsibleAreaCheckedNodes"]))
                {
                    string responsibleAreaNodes = Request.Params["responsibleAreaCheckedNodes"];

                    NavigationFilter.ResponsibleAreaIds = Array.ConvertAll(responsibleAreaNodes.Split(','), int.Parse);
                }

                if (!string.IsNullOrEmpty(Request.Params["coordinatorsCheckedNodes"]))
                {
                    string responsibleAreaNodes = Request.Params["coordinatorsCheckedNodes"];

                    NavigationFilter.CoordinatorIds = Array.ConvertAll(responsibleAreaNodes.Split(','), int.Parse);
                }

                //ViewData["Collapsed"] = false;

                //edit
                if (!string.IsNullOrEmpty(Request.Params["EditRecord"]))
                {
                    if (!string.IsNullOrEmpty(Request.Params["currentActiveView"]) && !string.IsNullOrEmpty(Request.Params["recordId"]))
                    {
                        string currentActiveView = Request.Params["currentActiveView"];
                        int    recordId          = int.Parse(Request.Params["recordId"]);

                        if (currentActiveView.Contains("Task"))
                        {
                            HseqTask record = db.HseqTasks.Find(recordId);
                            HseqTaskEditViewModel HseqTaskEditVM = Mapper.Map <HseqTask, HseqTaskEditViewModel>(record);

                            ViewData["record"]      = HseqTaskEditVM;
                            ViewData["currentview"] = "_Task" + EDIT_VIEW_PREFIX;
                        }
                        else if (currentActiveView.Contains("Approval"))
                        {
                            HseqApprovalRequest       record             = db.HseqApprovalRequests.Find(recordId);
                            HseqApprovalEditViewModel HseqApprovalEditVM = Mapper.Map <HseqApprovalRequest, HseqApprovalEditViewModel>(record);

                            ViewData["record"]      = HseqApprovalEditVM;
                            ViewData["currentview"] = "_Approval" + EDIT_VIEW_PREFIX;
                        }

                        ////////////////////////////////////////

                        else if (currentActiveView.Contains("Ncr"))
                        {
                            Ncr record = db.NcrRecords.Find(recordId);
                            NcrEditViewModel ncrEditVM = Mapper.Map <Ncr, NcrEditViewModel>(record);

                            ViewData["record"]      = ncrEditVM;
                            ViewData["currentview"] = "_Ncr" + EDIT_VIEW_PREFIX;
                        }
                        else if (currentActiveView.Contains("Car"))
                        {
                            Car record = db.CarRecords.Find(recordId);
                            CarEditViewModel carEditVM = Mapper.Map <Car, CarEditViewModel>(record);

                            ViewData["record"]      = carEditVM;
                            ViewData["currentview"] = "_Car" + EDIT_VIEW_PREFIX;
                        }
                        else if (currentActiveView.Contains("Par"))
                        {
                            Par record = db.ParRecords.Find(recordId);
                            ParEditViewModel parEditVM = Mapper.Map <Par, ParEditViewModel>(record);

                            ViewData["record"]      = parEditVM;
                            ViewData["currentview"] = "_Par" + EDIT_VIEW_PREFIX;
                        }
                        else if (currentActiveView.Contains("Fis"))
                        {
                            Fis record = db.FisRecords.Find(recordId);
                            FisEditViewModel fisEditVM = Mapper.Map <Fis, FisEditViewModel>(record);

                            ViewData["record"]      = fisEditVM;
                            ViewData["currentview"] = "_Fis" + EDIT_VIEW_PREFIX;
                        }
                    }
                }

                //new
                else if (!string.IsNullOrEmpty(Request.Params["NewRecord"]))
                {
                    if (!string.IsNullOrEmpty(Request.Params["currentActiveView"]))
                    {
                        string currentActiveView = Request.Params["currentActiveView"];

                        if (currentActiveView.Contains("Ncr"))
                        {
                            Ncr ncr = new Ncr();
                            ncr.CaseNo      = _RecordService.GetNextCaseNumber(db);
                            ncr.RecordNo    = ncr.CaseNo;
                            ncr.CreatedBy   = _RecordService.GetCurrentApplicationUser().FullName;
                            ncr.DateCreated = DateTime.Now;
                            ncr.RecordType  = RecordType.NCR;
                            ncr.NcrSource   = NcrSource.Internal;
                            ncr.NcrState    = NcrState.New;

                            NcrCreateViewModel carVM = Mapper.Map <Ncr, NcrCreateViewModel>(ncr);

                            ViewData["record"]      = carVM;
                            ViewData["currentview"] = "_Ncr" + NEW_VIEW_PREFIX;
                        }
                        else if (currentActiveView.Contains("Car"))
                        {
                            Car car = new Car();
                            car.CaseNo      = _RecordService.GetNextCaseNumber(db);
                            car.RecordNo    = car.CaseNo;
                            car.CreatedBy   = _RecordService.GetCurrentApplicationUser().FullName;
                            car.DateCreated = DateTime.Now;
                            car.RecordType  = RecordType.CAR;

                            CarCreateViewModel carVM = Mapper.Map <Car, CarCreateViewModel>(car);

                            ViewData["record"]      = carVM;
                            ViewData["currentview"] = "_Car" + NEW_VIEW_PREFIX;
                        }
                        else if (currentActiveView.Contains("Par"))
                        {
                            Par par = new Par();
                            par.CaseNo      = _RecordService.GetNextCaseNumber(db);
                            par.RecordNo    = par.CaseNo;
                            par.CreatedBy   = _RecordService.GetCurrentApplicationUser().FullName;
                            par.DateCreated = DateTime.Now;
                            par.RecordType  = RecordType.PAR;

                            ParCreateViewModel parVM = Mapper.Map <Par, ParCreateViewModel>(par);

                            ViewData["record"]      = parVM;
                            ViewData["currentview"] = "_Par" + NEW_VIEW_PREFIX;
                        }
                        else if (currentActiveView.Contains("Fis"))
                        {
                            Fis fis = new Fis();
                            fis.CaseNo      = _RecordService.GetNextCaseNumber(db);
                            fis.RecordNo    = fis.CaseNo;
                            fis.CreatedBy   = _RecordService.GetCurrentApplicationUser().FullName;
                            fis.DateCreated = DateTime.Now;
                            fis.RecordType  = RecordType.FIS;

                            FisCreateViewModel fisVM = Mapper.Map <Fis, FisCreateViewModel>(fis);

                            ViewData["record"]      = fisVM;
                            ViewData["currentview"] = "_Fis" + NEW_VIEW_PREFIX;
                        }
                    }
                }

                //// Task ///////////////////
                else if (!string.IsNullOrEmpty(Request.Params["addTask"]))
                {
                    if (!string.IsNullOrEmpty(Request.Params["currentActiveView"]) && !string.IsNullOrEmpty(Request.Params["recordId"]))
                    {
                        string currentActiveView = Request.Params["currentActiveView"];
                        int    recordId          = int.Parse(Request.Params["recordId"]);

                        HseqTask hseqTask = new HseqTask()
                        {
                            Status = TaskStatus.NotStarted
                        };

                        HseqRecord hseqRecord = db.HseqRecords.Find(recordId);
                        hseqTask.HseqRecordID = hseqRecord.HseqRecordID;
                        hseqTask.HseqRecord   = hseqRecord;

                        HseqTaskCreateViewModel hseqTaskVM = Mapper.Map <HseqTask, HseqTaskCreateViewModel>(hseqTask);

                        ViewData["record"]      = hseqTaskVM;
                        ViewData["currentview"] = "_Task" + NEW_VIEW_PREFIX;
                    }
                }

                //// Approval ///////////////////
                else if (!string.IsNullOrEmpty(Request.Params["addApproval"]))
                {
                    if (!string.IsNullOrEmpty(Request.Params["currentActiveView"]) && !string.IsNullOrEmpty(Request.Params["recordId"]))
                    {
                        string currentActiveView = Request.Params["currentActiveView"];
                        int    recordId          = int.Parse(Request.Params["recordId"]);

                        HseqApprovalRequest hseqApproval = new HseqApprovalRequest()
                        {
                            Response     = ApprovalResult.Waiting,
                            Status       = ApprovalStatus.Active,
                            DateAssigned = DateTime.Now
                        };

                        HseqRecord hseqRecord = db.HseqRecords.Find(recordId);
                        hseqApproval.HseqRecordID = hseqRecord.HseqRecordID;
                        hseqApproval.HseqRecord   = hseqRecord;

                        HseqApprovalCreateViewModel hseqApprovalVM = Mapper.Map <HseqApprovalRequest, HseqApprovalCreateViewModel>(hseqApproval);

                        ViewData["record"]      = hseqApprovalVM;
                        ViewData["currentview"] = "_Approval" + NEW_VIEW_PREFIX;
                    }
                }

                //// Linked Record ///////////////////
                else if (!string.IsNullOrEmpty(Request.Params["createLinkedRecord"]) &&
                         !string.IsNullOrEmpty(Request.Params["linkedRecordDetails"]))
                {
                    if (!string.IsNullOrEmpty(Request.Params["recordId"]))
                    {
                        int recordId = int.Parse(Request.Params["recordId"]);

                        var linkedRecordDetails = Request.Params["linkedRecordDetails"].Split('-');
                        var sourceRecord        = linkedRecordDetails[0];
                        var targetRecord        = linkedRecordDetails[1];

                        //Ncr to Car
                        if (sourceRecord == "NCR")
                        {
                            if (targetRecord == "CAR")
                            {
                                Ncr ncr = db.NcrRecords.Find(recordId);
                                Car car = new Car(ncr)
                                {
                                    CreatedBy   = _RecordService.GetCurrentApplicationUser().FullName,
                                    DateCreated = DateTime.Now,
                                    RecordType  = RecordType.CAR
                                };

                                CarVM carVM = new CarVM()
                                {
                                    Car            = car,
                                    LinkedRecord   = true,
                                    SourceRecordId = ncr.HseqRecordID
                                };

                                ViewData["record"]      = carVM;
                                ViewData["currentview"] = "_Car" + LINKED_VIEW_PREFIX;
                            }
                        }
                    }
                }

                else
                {
                    ViewData["currentview"] = "_MainContentTabPanel";
                }
            }

            return(PartialView("_MainContentCallbackPanel"));
        }