public void CreateLineStatus(int id, ref ApplicationDbContext Context) { RequisitionLineStatus Stat = new RequisitionLineStatus(); Stat.RequisitionLineId = id; Stat.ObjectState = Model.ObjectState.Added; Context.RequisitionLineStatus.Add(Stat); }
public void UpdateStatusQty(string QtyType, decimal Qty, DateTime date, int Id, ref ApplicationDbContext Context, bool IsDbBased) { RequisitionLineStatus Stat = Find(Id); switch (QtyType) { case RequisitionStatusQtyConstants.CancelQty: { Stat.CancelQty = Qty; Stat.CancelDate = date; break; } case RequisitionStatusQtyConstants.IssueQty: { Stat.IssueQty = Qty; Stat.IssueDate = date; break; } case RequisitionStatusQtyConstants.ReceiveQty: { Stat.ReceiveQty = Qty; Stat.ReceiveDate = date; break; } default: { break; } } Stat.ObjectState = Model.ObjectState.Modified; if (IsDbBased) { Context.RequisitionLineStatus.Add(Stat); } else { Update(Stat); } }
public ActionResult DeletePost(RequisitionLineViewModel vm) { bool BeforeSave = true; try { BeforeSave = MaterialRequestDocEvents.beforeLineDeleteEvent(this, new StockEventArgs(vm.RequisitionHeaderId, vm.RequisitionLineId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } if (!BeforeSave) { TempData["CSEXC"] += "Validation failed before delete."; } if (BeforeSave && !EventException) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); //RequisitionLine RequisitionLine = _RequisitionLineService.Find(vm.RequisitionLineId); RequisitionLine RequisitionLine = (from p in db.RequisitionLine where p.RequisitionLineId == vm.RequisitionLineId select p).FirstOrDefault(); RequisitionLineStatus LineStat = (from p in db.RequisitionLineStatus where p.RequisitionLineId == vm.RequisitionLineId select p).FirstOrDefault(); RequisitionHeader header = new RequisitionHeaderService(_unitOfWork).Find(RequisitionLine.RequisitionHeaderId); RequisitionLine ExRec = new RequisitionLine(); ExRec = Mapper.Map <RequisitionLine>(RequisitionLine); LogList.Add(new LogTypeViewModel { ExObj = ExRec, }); //new RequisitionLineStatusService(_unitOfWork).Delete(RequisitionLine.RequisitionLineId); if (LineStat != null) { LineStat.ObjectState = Model.ObjectState.Deleted; db.RequisitionLineStatus.Remove(LineStat); } RequisitionLine.ObjectState = Model.ObjectState.Deleted; db.RequisitionLine.Remove(RequisitionLine); //_RequisitionLineService.Delete(RequisitionLine); if (header.Status != (int)StatusConstants.Drafted) { header.Status = (int)StatusConstants.Modified; header.ModifiedBy = User.Identity.Name; header.ModifiedDate = DateTime.Now; header.ObjectState = Model.ObjectState.Modified; db.RequisitionHeader.Add(header); //new RequisitionHeaderService(_unitOfWork).Update(header); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { MaterialRequestDocEvents.onLineDeleteEvent(this, new StockEventArgs(RequisitionLine.RequisitionHeaderId, RequisitionLine.RequisitionLineId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; ViewBag.LineMode = "Delete"; return(PartialView("_Create", vm)); } try { MaterialRequestDocEvents.afterLineDeleteEvent(this, new StockEventArgs(RequisitionLine.RequisitionHeaderId, RequisitionLine.RequisitionLineId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = header.DocTypeId, DocId = header.RequisitionHeaderId, DocLineId = RequisitionLine.RequisitionLineId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = header.DocNo, xEModifications = Modifications, DocDate = header.DocDate, DocStatus = header.Status, })); } return(Json(new { success = true })); }
public RequisitionLineStatus Add(RequisitionLineStatus pt) { _unitOfWork.Repository <RequisitionLineStatus>().Insert(pt); return(pt); }
public void Update(RequisitionLineStatus pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <RequisitionLineStatus>().Update(pt); }
public void Delete(RequisitionLineStatus pt) { _unitOfWork.Repository <RequisitionLineStatus>().Delete(pt); }
public RequisitionLineStatus Create(RequisitionLineStatus pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <RequisitionLineStatus>().Insert(pt); return(pt); }
public void DeleteLineStatus(int id) { RequisitionLineStatus Stat = Find(id); Delete(Stat); }
public bool CancelPendingWeavingRequisitions(int HeaderId, string UserName, int DocType) { bool Success = false; var PendingRequisitionLines = (from p in db.ViewRequisitionBalance where p.RequisitionHeaderId == HeaderId && p.BalanceQty > 0 select new { p.RequisitionLineId, p.BalanceQty, p.PersonId }).ToList(); int SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; var ReasonId = (from p in db.RequisitionSetting where p.DocTypeId == DocType && p.DivisionId == DivisionId && p.SiteId == SiteId select p.DefaultReasonId).FirstOrDefault(); if (!ReasonId.HasValue) { ReasonId = new ReasonService(_unitOfWork).GetReasonList(TransactionDocCategoryConstants.RequisitionCancel).FirstOrDefault().ReasonId; } if (PendingRequisitionLines.Count() > 0) { RequisitionCancelHeader Header = new RequisitionCancelHeader(); Header.CreatedBy = UserName; Header.CreatedDate = DateTime.Now; Header.DivisionId = DivisionId; Header.DocDate = DateTime.Now; Header.DocTypeId = DocType; Header.SiteId = SiteId; Header.DocNo = new DocumentTypeService(_unitOfWork).FGetNewDocNo("DocNo", ConfigurationManager.AppSettings["DataBaseSchema"] + ".RequisitionCancelHeaders", Header.DocTypeId, Header.DocDate, Header.DivisionId, Header.SiteId); Header.ModifiedBy = UserName; Header.ModifiedDate = DateTime.Now; Header.PersonId = PendingRequisitionLines.FirstOrDefault().PersonId; Header.ReasonId = ReasonId.Value; Header.ObjectState = Model.ObjectState.Added; db.RequisitionCancelHeader.Add(Header); foreach (var item in PendingRequisitionLines) { RequisitionCancelLine Line = new RequisitionCancelLine(); Line.CreatedBy = UserName; Line.CreatedDate = DateTime.Now; Line.ModifiedBy = UserName; Line.ModifiedDate = DateTime.Now; Line.Qty = item.BalanceQty; Line.RequisitionLineId = item.RequisitionLineId; Line.RequisitionCancelHeaderId = Header.RequisitionCancelHeaderId; Line.ObjectState = Model.ObjectState.Added; db.RequisitionCancelLine.Add(Line); RequisitionLineStatus LineStatus = db.RequisitionLineStatus.Find(item.RequisitionLineId); if (LineStatus != null) { LineStatus.CancelQty = (LineStatus.CancelQty ?? 0) + Line.Qty; LineStatus.ObjectState = Model.ObjectState.Modified; db.RequisitionLineStatus.Add(LineStatus); } } try { db.SaveChanges(); } catch (Exception Ex) { Success = false; } Success = true; } return(Success); }