public ActionResult Delete(ReasonViewModel vm) { if (ModelState.IsValid) { db.Configuration.AutoDetectChangesEnabled = false; PackingHeader Sd = (from H in db.PackingHeader where H.PackingHeaderId == vm.id select H).FirstOrDefault(); var PackingLine = (from L in db.PackingLine where L.PackingHeaderId == vm.id select L).ToList(); List <int> StockIdList = new List <int>(); int cnt = 0; foreach (var item in PackingLine) { if (item.StockIssueId != null) { StockIdList.Add((int)item.StockIssueId); } cnt = cnt + 1; try { item.ObjectState = Model.ObjectState.Deleted; db.PackingLine.Attach(item); db.PackingLine.Remove(item); } catch (Exception e) { string str = e.Message; } } foreach (var item in StockIdList) { if (item != null) { StockAdj Adj = (from L in db.StockAdj where L.StockOutId == item select L).FirstOrDefault(); if (Adj != null) { new StockAdjService(_unitOfWork).Delete(Adj); } new StockService(_unitOfWork).DeleteStockDB((int)item, ref db, true); } } int?StockHeaderId = null; StockHeaderId = Sd.StockHeaderId; Sd.ObjectState = Model.ObjectState.Deleted; db.PackingHeader.Attach(Sd); db.PackingHeader.Remove(Sd); if (StockHeaderId != null) { StockHeader StockHeader = (from H in db.StockHeader where H.StockHeaderId == StockHeaderId select H).FirstOrDefault(); StockHeader.ObjectState = Model.ObjectState.Deleted; db.StockHeader.Attach(StockHeader); db.StockHeader.Remove(StockHeader); } //Commit the DB try { db.SaveChanges(); db.Configuration.AutoDetectChangesEnabled = true; } catch (Exception ex) { string message = _exception.HandleException(ex); db.Configuration.AutoDetectChangesEnabled = true; TempData["CSEXC"] += message; PrepareViewBag(Sd.DocTypeId); return(PartialView("_Reason", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = Sd.DocTypeId, DocId = Sd.PackingHeaderId, ActivityType = (int)ActivityTypeContants.Deleted, UserRemark = vm.Reason, DocNo = Sd.DocNo, DocDate = Sd.DocDate, DocStatus = Sd.Status, })); return(Json(new { success = true })); } return(PartialView("_Reason", vm)); }
public StockAdj Add(StockAdj pt) { _StockAdjRepository.Insert(pt); return(pt); }
public ActionResult Delete(ReasonViewModel vm) { if (ModelState.IsValid) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); int?StockHeaderId = 0; var PackingHeader = _PackingHeaderService.GetPackingHeader(vm.id); int status = PackingHeader.Status; LogList.Add(new LogTypeViewModel { ExObj = PackingHeader, }); StockHeaderId = PackingHeader.StockHeaderId; new StockUidService(_unitOfWork).DeleteStockUidForDocHeader(PackingHeader.PackingHeaderId, PackingHeader.DocTypeId, PackingHeader.SiteId, PackingHeader.DivisionId); List <int> StockIssueIdList = new List <int>(); List <int> StockReceiveIdList = new List <int>(); var PackingLine = new PackingLineService(_unitOfWork).GetPackingLineForHeaderId(vm.id).ToList(); foreach (var item in PackingLine) { LogList.Add(new LogTypeViewModel { ExObj = item, }); if (item.StockIssueId != null) { StockIssueIdList.Add((int)item.StockIssueId); } if (item.StockReceiveId != null) { StockReceiveIdList.Add((int)item.StockReceiveId); } if (item.ProductUidId != null && item.ProductUidId != 0) { ProductUidDetail ProductUidDetail = new ProductUidService(_unitOfWork).FGetProductUidLastValues((int)item.ProductUidId, "Packing-" + vm.id.ToString()); ProductUid ProductUid = new ProductUidService(_unitOfWork).Find((int)item.ProductUidId); ProductUid.LastTransactionDocDate = item.ProductUidLastTransactionDocDate; ProductUid.LastTransactionDocId = item.ProductUidLastTransactionDocId; ProductUid.LastTransactionDocNo = item.ProductUidLastTransactionDocNo; ProductUid.LastTransactionDocTypeId = item.ProductUidLastTransactionDocTypeId; ProductUid.LastTransactionPersonId = item.ProductUidLastTransactionPersonId; ProductUid.CurrenctGodownId = item.ProductUidCurrentGodownId; ProductUid.CurrenctProcessId = item.ProductUidCurrentProcessId; ProductUid.Status = item.ProductUidStatus; //ProductUid.LastTransactionDocDate = ProductUidDetail.LastTransactionDocDate; //ProductUid.LastTransactionDocId = ProductUidDetail.LastTransactionDocId; //ProductUid.LastTransactionDocNo = ProductUidDetail.LastTransactionDocNo; //ProductUid.LastTransactionDocTypeId = ProductUidDetail.LastTransactionDocTypeId; //ProductUid.LastTransactionPersonId = ProductUidDetail.LastTransactionPersonId; //ProductUid.CurrenctGodownId = ProductUidDetail.CurrenctGodownId; //ProductUid.CurrenctProcessId = ProductUidDetail.CurrenctProcessId; new ProductUidService(_unitOfWork).Update(ProductUid); } PackingLineExtended LineExtended = new PackingLineExtendedService(_unitOfWork).Find(item.PackingLineId); if (LineExtended != null) { new PackingLineExtendedService(_unitOfWork).Delete(LineExtended); } new PackingLineService(_unitOfWork).Delete(item.PackingLineId); } foreach (var item in StockIssueIdList) { StockAdj Adj = (from L in db.StockAdj where L.StockOutId == item select L).FirstOrDefault(); if (Adj != null) { //Adj.ObjectState = Model.ObjectState.Deleted; //db.StockAdj.Remove(Adj); new StockAdjService(_unitOfWork).Delete(Adj); } new StockService(_unitOfWork).DeleteStock(item); } foreach (var item in StockReceiveIdList) { new StockService(_unitOfWork).DeleteStock(item); } new PackingHeaderService(_unitOfWork).Delete(vm.id); if (StockHeaderId != null) { new StockHeaderService(_unitOfWork).Delete((int)StockHeaderId); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); //Commit the DB try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; return(PartialView("_Reason", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = PackingHeader.DocTypeId, DocId = PackingHeader.PackingHeaderId, ActivityType = (int)ActivityTypeContants.Deleted, UserRemark = vm.Reason, DocNo = PackingHeader.DocNo, xEModifications = Modifications, DocDate = PackingHeader.DocDate, DocStatus = PackingHeader.Status, })); return(Json(new { success = true })); } return(PartialView("_Reason", vm)); }
public void Delete(StockAdj pt) { _StockAdjRepository.Delete(pt); }
public void Update(StockAdj pt) { pt.ObjectState = ObjectState.Modified; _StockAdjRepository.Update(pt); }
public StockAdj Create(StockAdj pt) { pt.ObjectState = ObjectState.Added; _StockAdjRepository.Add(pt); return(pt); }
public StockAdj Add(StockAdj pt) { _unitOfWork.Repository <StockAdj>().Insert(pt); return(pt); }
public void Update(StockAdj pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <StockAdj>().Update(pt); }
public void Delete(StockAdj pt) { _unitOfWork.Repository <StockAdj>().Delete(pt); }
public StockAdj Create(StockAdj pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <StockAdj>().Insert(pt); return(pt); }