Beispiel #1
0
        public ActionResult _Create(int Id) //Id ==>Process Sequence Header Id
        {
            ProcessSequenceHeader        H = new ProcessSequenceHeaderService(_unitOfWork).GetProcessSequenceHeader(Id);
            ProcessSequenceLineViewModel s = new ProcessSequenceLineViewModel();

            s.ProcessSequenceHeaderId = H.ProcessSequenceHeaderId;
            ViewBag.Status            = H.Status;
            PrepareViewBag(null);
            return(PartialView("_Create", s));
        }
Beispiel #2
0
        public ActionResult _CreateForProductCollection(int Id) //Id ==>ProductCalculationId
        {
            ProcessSequenceHeader        H = new ProcessSequenceHeaderService(_unitOfWork).GetProcessSequenceHeaderForProductCollection(Id);
            ProcessSequenceLineViewModel s = new ProcessSequenceLineViewModel();

            s.RefDocId                = Id;
            s.RefDocTypeId            = H.ReferenceDocTypeId;
            s.ProcessSequenceHeaderId = H.ProcessSequenceHeaderId;
            PrepareViewBag(null);
            return(PartialView("_Create", s));
        }
Beispiel #3
0
 private void PrepareViewBag(ProcessSequenceLineViewModel s)
 {
     if (s == null)
     {
         ViewBag.ProcessId = new SelectList(new ProcessService(_unitOfWork).GetProcessList(), "ProcessId", "ProcessName");
     }
     else
     {
         ViewBag.ProcessId = new SelectList(new ProcessService(_unitOfWork).GetProcessList(), "ProcessId", "ProcessName", s.ProcessId);
     }
 }
Beispiel #4
0
        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProcessSequenceLineViewModel ProcessSequenceLine = _ProcessSequenceLineService.GetProcessSequenceLineModel(id);

            if (ProcessSequenceLine == null)
            {
                return(HttpNotFound());
            }
            return(View(ProcessSequenceLine));
        }
Beispiel #5
0
        public ActionResult Create(ProcessSequenceLineViewModel svm, string Command)
        {
            ProcessSequenceLine   s    = Mapper.Map <ProcessSequenceLineViewModel, ProcessSequenceLine>(svm);
            ProcessSequenceHeader temp = new ProcessSequenceHeaderService(_unitOfWork).Find(s.ProcessSequenceHeaderId);

            if (ModelState.IsValid)
            {
                if (s.ProcessId == 0)
                {
                    ViewBag.Status = temp.Status;
                    PrepareViewBag(svm);
                    return(View(svm).Danger("Please fill Qty"));
                }

                if (s.Sequence == 0)
                {
                    ViewBag.Status = temp.Status;
                    PrepareViewBag(svm);
                    return(View(svm).Danger("Please fill Sequence"));
                }

                if (s.Days == 0)
                {
                    ViewBag.Status = temp.Status;
                    PrepareViewBag(svm);
                    return(View(svm).Danger("Please fill Days"));
                }

                s.CreatedDate  = DateTime.Now;
                s.ModifiedDate = DateTime.Now;
                s.CreatedBy    = User.Identity.Name;
                s.ModifiedBy   = User.Identity.Name;
                s.ObjectState  = Model.ObjectState.Added;
                _ProcessSequenceLineService.Create(s);

                ProcessSequenceHeader header = new ProcessSequenceHeaderService(_unitOfWork).Find(s.ProcessSequenceHeaderId);
                if (header.Status != (int)StatusConstants.Drafted)
                {
                    header.Status = (int)StatusConstants.Modified;
                    new ProcessSequenceHeaderService(_unitOfWork).Update(header);
                }
                _unitOfWork.Save();
                return(RedirectToAction("Create").Success("Data saved successfully"));
            }

            ViewBag.Status = temp.Status;
            PrepareViewBag(svm);
            return(View(svm));
        }
Beispiel #6
0
        public ActionResult DeletePost(ProcessSequenceLineViewModel vm)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            ProcessSequenceLine ProcessSequenceLine = _ProcessSequenceLineService.GetProcessSequenceLine(vm.ProcessSequenceLineId);

            LogList.Add(new LogTypeViewModel
            {
                ExObj = vm,
            });


            _ProcessSequenceLineService.Delete(vm.ProcessSequenceLineId);
            ProcessSequenceHeader header = new ProcessSequenceHeaderService(_unitOfWork).Find(ProcessSequenceLine.ProcessSequenceHeaderId);

            if (header.Status != (int)StatusConstants.Drafted)
            {
                header.Status = (int)StatusConstants.Modified;
                new ProcessSequenceHeaderService(_unitOfWork).Update(header);
            }

            XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

            try
            {
                _unitOfWork.Save();
            }

            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                ModelState.AddModelError("", message);
                return(PartialView("EditSize", vm));
            }

            LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
            {
                DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                DocId           = vm.ProcessSequenceHeaderId,
                DocLineId       = vm.ProcessSequenceLineId,
                ActivityType    = (int)ActivityTypeContants.Deleted,
                xEModifications = Modifications,
            }));

            return(Json(new { success = true }));
        }
Beispiel #7
0
        public ActionResult _Edit(int id)
        {
            ProcessSequenceLine temp = _ProcessSequenceLineService.GetProcessSequenceLine(id);

            ProcessSequenceHeader H = new ProcessSequenceHeaderService(_unitOfWork).GetProcessSequenceHeader(temp.ProcessSequenceHeaderId);

            ViewBag.DocNo = H.ProcessSequenceHeaderName;
            ProcessSequenceLineViewModel s = Mapper.Map <ProcessSequenceLine, ProcessSequenceLineViewModel>(temp);

            PrepareViewBag(s);

            if (temp == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("_Create", s));
        }
Beispiel #8
0
        public ActionResult _CreatePost(ProcessSequenceLineViewModel svm)
        {
            ProcessSequenceLine   s    = Mapper.Map <ProcessSequenceLineViewModel, ProcessSequenceLine>(svm);
            ProcessSequenceHeader temp = (from p in db.ProcessSequenceHeader
                                          where p.ProcessSequenceHeaderId == svm.ProcessSequenceHeaderId
                                          select p).FirstOrDefault();

            ProductCollection PColl = new ProductCollectionService(_unitOfWork).Find(svm.RefDocId.Value);


            if (ModelState.IsValid)
            {
                if (svm.ProcessSequenceLineId <= 0)
                {
                    if (temp == null)
                    {
                        int RefDocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.ProductCollection).DocumentTypeId;

                        ProcessSequenceHeader Header = new ProcessSequenceHeader();
                        Header.ProcessSequenceHeaderName = PColl.ProductCollectionName + "-" + new DivisionService(_unitOfWork).Find((int)HttpContext.Session["DivisionId"]).DivisionName;
                        Header.ReferenceDocTypeId        = RefDocTypeId;
                        Header.ReferenceDocId            = PColl.ProductCollectionId;
                        Header.CreatedBy    = User.Identity.Name;
                        Header.CreatedDate  = DateTime.Now;
                        Header.ModifiedBy   = User.Identity.Name;
                        Header.ModifiedDate = DateTime.Now;
                        Header.ObjectState  = Model.ObjectState.Added;

                        new ProcessSequenceHeaderService(_unitOfWork).Create(Header);

                        s.ProcessSequenceHeaderId = Header.ProcessSequenceHeaderId;
                    }
                    else
                    {
                        s.ProcessSequenceHeaderId = temp.ProcessSequenceHeaderId;
                    }

                    s.CreatedDate  = DateTime.Now;
                    s.ModifiedDate = DateTime.Now;
                    s.CreatedBy    = User.Identity.Name;
                    s.ModifiedBy   = User.Identity.Name;
                    s.ObjectState  = Model.ObjectState.Added;
                    _ProcessSequenceLineService.Create(s);

                    if (temp != null && temp.Status != (int)StatusConstants.Drafted)
                    {
                        temp.Status = (int)StatusConstants.Modified;
                        new ProcessSequenceHeaderService(_unitOfWork).Update(temp);
                    }

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                        DocId        = s.ProcessSequenceHeaderId,
                        DocLineId    = s.ProcessSequenceLineId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("_CreateForProductCollection", new { id = svm.RefDocId }));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    ProcessSequenceHeader header = new ProcessSequenceHeaderService(_unitOfWork).Find(svm.ProcessSequenceHeaderId);
                    int status = header.Status;
                    ProcessSequenceLine temp1 = _ProcessSequenceLineService.Find(svm.ProcessSequenceLineId);

                    ProcessSequenceLine ExRec = Mapper.Map <ProcessSequenceLine>(temp1);

                    temp1.ProcessId          = svm.ProcessId;
                    temp1.Sequence           = svm.Sequence;
                    temp1.ProductRateGroupId = svm.ProductRateGroupId;
                    temp1.Days         = svm.Days;
                    temp1.ModifiedDate = DateTime.Now;
                    temp1.ModifiedBy   = User.Identity.Name;
                    _ProcessSequenceLineService.Update(temp1);


                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp1,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                        DocId           = temp.ProcessSequenceHeaderId,
                        DocLineId       = temp1.ProcessSequenceLineId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(Json(new { success = true }));
                }
            }
            PrepareViewBag(svm);
            return(PartialView("_Create", svm));
        }
Beispiel #9
0
        public ActionResult _CreatePost(ProcessSequenceLineViewModel svm)
        {
            ProcessSequenceLine   s    = Mapper.Map <ProcessSequenceLineViewModel, ProcessSequenceLine>(svm);
            ProcessSequenceHeader temp = new ProcessSequenceHeaderService(_unitOfWork).Find(s.ProcessSequenceHeaderId);

            //if (Command == "Submit" && (s.ProductId == 0))
            //    return RedirectToAction("Submit", "ProcessSequenceHeader", new { id = s.ProcessSequenceHeaderId }).Success("Data saved successfully");
            if (s.ProcessId == 0)
            {
                PrepareViewBag(svm);
                return(View(svm).Danger("Please fill Qty"));
            }

            if (s.Sequence == 0)
            {
                PrepareViewBag(svm);
                return(View(svm).Danger("Please fill Sequence"));
            }

            if (s.Days == 0)
            {
                PrepareViewBag(svm);
                return(View(svm).Danger("Please fill Days"));
            }

            if (ModelState.IsValid)
            {
                if (svm.ProcessSequenceLineId == 0)
                {
                    s.CreatedDate  = DateTime.Now;
                    s.ModifiedDate = DateTime.Now;
                    s.CreatedBy    = User.Identity.Name;
                    s.ModifiedBy   = User.Identity.Name;
                    s.ObjectState  = Model.ObjectState.Added;
                    _ProcessSequenceLineService.Create(s);

                    ProcessSequenceHeader header = new ProcessSequenceHeaderService(_unitOfWork).Find(s.ProcessSequenceHeaderId);
                    if (header.Status != (int)StatusConstants.Drafted)
                    {
                        header.Status = (int)StatusConstants.Modified;
                        new ProcessSequenceHeaderService(_unitOfWork).Update(header);
                    }

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                        DocId        = s.ProcessSequenceHeaderId,
                        DocLineId    = s.ProcessSequenceLineId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("_Create", new { id = s.ProcessSequenceHeaderId }));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    ProcessSequenceHeader header = new ProcessSequenceHeaderService(_unitOfWork).Find(svm.ProcessSequenceHeaderId);
                    int status = header.Status;
                    ProcessSequenceLine temp1 = _ProcessSequenceLineService.Find(svm.ProcessSequenceLineId);

                    ProcessSequenceLine ExRec = Mapper.Map <ProcessSequenceLine>(temp1);

                    temp1.ProcessId    = svm.ProcessId;
                    temp1.Sequence     = svm.Sequence;
                    temp1.Days         = svm.Days;
                    temp1.ModifiedDate = DateTime.Now;
                    temp1.ModifiedBy   = User.Identity.Name;
                    _ProcessSequenceLineService.Update(temp1);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp1,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                        DocId           = temp1.ProcessSequenceHeaderId,
                        DocLineId       = temp1.ProcessSequenceLineId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(Json(new { success = true }));
                }
            }
            PrepareViewBag(svm);
            return(PartialView("_Create", svm));
        }