public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } int ProductTypeId = (from p in db.Product where p.ProductId == id select new { ProductTypeId = p.ProductGroup.ProductTypeId }).FirstOrDefault().ProductTypeId; BomDetail BomDetail = _BomDetailService.Find(id); if (BomDetail == null) { return(HttpNotFound()); } var settings = new ProductTypeSettingsService(_unitOfWork).GetProductTypeSettingsForDocument(ProductTypeId); //BomDetail.ProductTypeSettings = Mapper.Map<ProductTypeSettings, ProductTypeSettingsViewModel>(settings); return(View(BomDetail)); }
public ActionResult DeletePost(ProductConsumptionLineViewModel vm) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); BomDetail BomDetail = _BomDetailService.Find(vm.BomDetailId); LogList.Add(new LogTypeViewModel { ExObj = BomDetail, }); _BomDetailService.Delete(vm.BomDetailId); 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.ProductConsumption).DocumentTypeId, DocId = vm.BomDetailId, ActivityType = (int)ActivityTypeContants.Deleted, xEModifications = Modifications, })); return(Json(new { success = true })); }
public IList <BomDetail> GetBomView_Cost(string itemCode, DateTime effDate) { Item item = itemMgr.LoadItem(itemCode); string bomCode = item.Bom != null ? item.Bom.Code : item.Code; IList <BomDetail> bomDetailList = this.GetFlatBomDetail(bomCode, effDate); IList <BomDetail> bomViewList = new List <BomDetail>(); IList <BomDetail> costBomViewList = new List <BomDetail>(); bomViewList = this.GetAllBomDetailTree(bomDetailList, effDate); bomViewList = this.GetNoOverloadBomDetail(bomViewList); if (bomViewList != null && bomViewList.Count > 0) { bomViewList = this.GetCostBomDetail(bomViewList); Bom bom = bomMgr.LoadBom(bomCode); foreach (BomDetail bomDetail in bomViewList) { BomDetail costBomDetail = new BomDetail(); CloneHelper.CopyProperty(bomDetail, costBomDetail, BomCompDetail); costBomDetail.Bom = bom; costBomViewList.Add(costBomDetail); } } return(this.GetNoOverloadBomDetail(costBomViewList)); }
private void SaveItem() { int id = GetQueryIntValue("id"); string t = GetQueryValue("t"); using (var appdb = new AppContext()) { if (t == "pmh") { ProBomHeader pmh = appdb.probombase.Where(u => u.SN == id).FirstOrDefault(); pmh.Remark = tbxRemark.Text.Trim(); appdb.SaveChanges(); } else if (t == "pmd") { ProBomDetail pmd = appdb.probomdtl.Where(u => u.SN == id).FirstOrDefault(); pmd.Remark = tbxRemark.Text.Trim(); appdb.SaveChanges(); } else if (t == "probmd") { BomDetail pmd = appdb.bomdtl.Where(u => u.SN == id).FirstOrDefault(); pmd.Remark = tbxRemark.Text.Trim(); pmd.IsValid = 1; appdb.SaveChanges(); } } }
protected override void DeleteObject(object obj) { if (obj.GetType() == typeof(BomDetail)) { BomDetail bomDetail = (BomDetail)obj; BomDetail newBomDetail = this.bomDetailMgr.GetBomDetail(bomDetail.Bom.Code, bomDetail.Item.Code); if (newBomDetail != null) { newBomDetail.EndDate = DateTime.Today.AddDays(-1); this.bomDetailMgr.UpdateBomDetail(newBomDetail); log.Debug("Update BomDetail to inactive"); // this.bomDetailMgr.DeleteBomDetail(newBomDetail.Id); } } else if (obj.GetType() == typeof(MesBomDetail)) { MesBomDetail bomDetail = (MesBomDetail)obj; MesBomDetail newBomDetail = this.mesBomDetailMgr.GetBomDetail(bomDetail.Bom.Code, bomDetail.Item.Code); if (newBomDetail != null) { newBomDetail.EndDate = DateTime.Today.AddDays(-1); this.mesBomDetailMgr.UpdateBomDetail(newBomDetail); log.Debug("Update MesBomDetail to inactive"); } IList <MesBom> mesBomList = mesBomDetailMgr.GetRelatedBomDetail(bomDetail); if (mesBomList != null && mesBomList.Count > 0) { foreach (MesBom mesBom in mesBomList) { mesBom.TransferFlag = true; mesBomMgr.UpdateBom(mesBom); } } } }
public void AutoReplaceAbstractItem(OrderLocationTransaction orderLocationTransaction) { OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; //OrderOperation orderOperation = orderHead.GetOrderOperationByOperation(orderLocationTransaction.Operation.Value); //取得抽象件的子件 BomDetail bomDetail = this.bomDetailMgr.GetDefaultBomDetailForAbstractItem( orderLocationTransaction.Item, orderHead.Routing, orderHead.StartTime, orderLocationTransaction.OrderDetail.DefaultLocationFrom); if (bomDetail != null) { //删除抽象件 this.DeleteOrderLocationTransaction(orderLocationTransaction); orderDetail.RemoveOrderLocationTransaction(orderLocationTransaction); if (orderLocationTransaction.Operation != 0) { //删除对应的OrderOp this.orderOperationMgr.TryDeleteOrderOperation(orderHead, orderLocationTransaction.Operation); } //尝试分解子件 string bomCode = this.bomMgr.FindBomCode(bomDetail.Item); IList <BomDetail> bomDetailList = this.bomDetailMgr.GetFlatBomDetail(bomCode, orderHead.StartTime); if (bomDetailList != null && bomDetailList.Count > 0) { //子件有Bom foreach (BomDetail subBomDetail in bomDetailList) { //循环插入子件的Bom OrderLocationTransaction newOrderLocationTransaction = this.AddNewMaterial(orderDetail, subBomDetail, orderLocationTransaction.Location, orderLocationTransaction.OrderedQty); if (newOrderLocationTransaction != null && newOrderLocationTransaction.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_A) { //如果子件的Bom还包含抽象件,嵌套调用替换抽象零件方法 this.AutoReplaceAbstractItem(newOrderLocationTransaction); } } } else { //子件没有Bom,用子件直接替换抽象件 this.AddNewMaterial(orderDetail, bomDetail, orderLocationTransaction.Location, orderLocationTransaction.OrderedQty); } } else { throw new BusinessErrorException("Bom.Error.NotFoundForItem", orderLocationTransaction.Item.Code); } }
public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BomDetail BomDetail = _BomDetailService.Find(id); if (BomDetail == null) { return(HttpNotFound()); } return(View(BomDetail)); }
public BomDetail AddBomDetail(BomDetail newBomDetail) { BomDetail bomDetail = null; try { _bomDetailDal.Add(newBomDetail); bomDetail = newBomDetail; } catch (RepositoryException ex) { throw new AisinoMesServiceException("添加物料清单明细信息失败!", ex); } return(bomDetail); }
public BomDetail UpdateBomDetail(BomDetail updBomDetail) { BomDetail bomDetail = null; try { _bomDetailDal.Update(updBomDetail); bomDetail = updBomDetail; } catch (RepositoryException ex) { throw new AisinoMesServiceException("修改物料清单明细信息失败!", ex); } return(bomDetail); }
protected override void CreateOrUpdateObject(object obj) { if (obj.GetType() == typeof(BomDetail)) { BomDetail bomDetail = (BomDetail)obj; BomDetail newBomDetail = this.bomDetailMgr.GetBomDetail(bomDetail.Bom.Code, bomDetail.Item.Code); if (newBomDetail == null) { this.bomDetailMgr.CreateBomDetail(bomDetail); log.Debug("Create BomDetail:" + bomDetail.Bom.Code + "," + bomDetail.Item.Code + "," + bomDetail.RateQty.ToString("0.########")); } else { CloneHelper.CopyProperty(bomDetail, newBomDetail, this.fields); this.bomDetailMgr.UpdateBomDetail(newBomDetail); log.Debug("Update BomDetail:" + bomDetail.Bom.Code + "," + bomDetail.Item.Code + "," + bomDetail.RateQty.ToString("0.########")); } } else if (obj.GetType() == typeof(MesBomDetail)) { MesBomDetail bomDetail = (MesBomDetail)obj; MesBomDetail newBomDetail = this.mesBomDetailMgr.GetBomDetail(bomDetail.Bom.Code, bomDetail.Item.Code); if (newBomDetail == null) { this.mesBomDetailMgr.CreateBomDetail(bomDetail); log.Debug("Create MesBomDetail:" + bomDetail.Bom.Code + "," + bomDetail.Item.Code + "," + bomDetail.RateQty.ToString("0.########")); } else { CloneHelper.CopyProperty(bomDetail, newBomDetail, this.fields); this.mesBomDetailMgr.UpdateBomDetail(newBomDetail); log.Debug("Update MesBomDetail:" + bomDetail.Bom.Code + "," + bomDetail.Item.Code + "," + bomDetail.RateQty.ToString("0.########")); } IList <MesBom> mesBomList = mesBomDetailMgr.GetRelatedBomDetail(bomDetail); if (mesBomList != null && mesBomList.Count > 0) { foreach (MesBom mesBom in mesBomList) { mesBom.TransferFlag = true; mesBomMgr.UpdateBom(mesBom); } } } }
protected void ODS_BomDetail_Inserting(object sender, ObjectDataSourceMethodEventArgs e) { string parcode = ((Controls_TextBox)(this.FV_BomDetail.FindControl("tbParCode"))).Text.Trim(); string compcode = ((Controls_TextBox)(this.FV_BomDetail.FindControl("tbCompCode"))).Text.Trim(); string uom = ((Controls_TextBox)(this.FV_BomDetail.FindControl("tbUom"))).Text.Trim(); string location = ((Controls_TextBox)(this.FV_BomDetail.FindControl("tbLocation"))).Text.Trim(); com.Sconit.Control.CodeMstrDropDownList ddlBackFlushMethod = (com.Sconit.Control.CodeMstrDropDownList) this.FV_BomDetail.FindControl("ddlBackFlushMethod"); bomdetail = (BomDetail)e.InputParameters[0]; bomdetail.Bom = TheBomMgr.LoadBom(parcode); item = TheItemMgr.LoadItem(compcode); bomdetail.Item = item; if (item != null) { //default compcode and uom if (uom.Trim() == "") { bomdetail.Uom = item.Uom; } else { bomdetail.Uom = TheUomMgr.LoadUom(uom); } } if (location == "") { bomdetail.Location = null; } else { bomdetail.Location = TheLocationMgr.LoadLocation(location); } if (ddlBackFlushMethod.SelectedIndex != -1) { bomdetail.BackFlushMethod = ddlBackFlushMethod.SelectedValue; } bomdetail.ScrapPercentage = bomdetail.ScrapPercentage / 100; if (TheBomDetailMgr.CheckUniqueExist(bomdetail.Bom.Code, bomdetail.Item.Code, bomdetail.Operation, bomdetail.Reference, bomdetail.StartDate)) { ShowWarningMessage("MasterData.BomDetail.WarningMessage.UniqueExistError"); e.Cancel = true; } }
public void DeleteBomDetail(BomDetail delBomDetail) { try { _unitOfWork.AddAction(delBomDetail, DataActions.Delete); //删除路线工段表中对应的路线记录 List <BomDetailSection> bomDetailSectionLst = _bomDetailSectionDal.Find(d => d.bom_detail_id == delBomDetail.id).Entities.ToList(); foreach (BomDetailSection bomDetailSection in bomDetailSectionLst) { _unitOfWork.AddAction(bomDetailSection, DataActions.Delete); } _unitOfWork.Save(); } catch (RepositoryException ex) { throw new AisinoMesServiceException("删除物料清单明细信息失败!", ex); } }
protected void ODS_BomDetail_Updating(object sender, ObjectDataSourceMethodEventArgs e) { string parcode = ((TextBox)(this.FV_BomDetail.FindControl("tbParCode"))).Text.Trim(); string compcode = ((TextBox)(this.FV_BomDetail.FindControl("tbCompCode"))).Text.Trim(); string uom = ((Controls_TextBox)(this.FV_BomDetail.FindControl("tbUom"))).Text.Trim(); string location = ((Controls_TextBox)(this.FV_BomDetail.FindControl("tbLocation"))).Text.Trim(); string endTime = ((TextBox)(this.FV_BomDetail.FindControl("tbEndTime"))).Text.Trim(); com.Sconit.Control.CodeMstrDropDownList ddlBackFlushMethod = (com.Sconit.Control.CodeMstrDropDownList) this.FV_BomDetail.FindControl("ddlBackFlushMethod"); bomdetail = (BomDetail)e.InputParameters[0]; bomdetail.Bom = TheBomMgr.LoadBom(parcode); item = TheItemMgr.LoadItem(compcode); bomdetail.Item = item; if (item != null) { //default compcode and uom if (uom.Trim() == string.Empty) { bomdetail.Uom = item.Uom; } else { bomdetail.Uom = TheUomMgr.LoadUom(uom); } } if (location == string.Empty) { bomdetail.Location = null; } else { bomdetail.Location = TheLocationMgr.LoadLocation(location); } if (ddlBackFlushMethod.SelectedIndex != -1) { bomdetail.BackFlushMethod = ddlBackFlushMethod.SelectedValue; } if (endTime != string.Empty) { bomdetail.EndDate = DateTime.Parse(endTime); } bomdetail.ScrapPercentage = bomdetail.ScrapPercentage / 100; }
public ActionResult DeletePost(ProductConsumptionLineViewModel vm) { BomDetail BomDetail = _BomDetailService.Find(vm.BomDetailId); _BomDetailService.Delete(vm.BomDetailId); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("EditSize", vm)); } return(Json(new { success = true })); }
private void UpdateView() { bomdetail = TheBomDetailMgr.LoadBomDetail(Convert.ToInt32(this.code)); TextBox tbParCode = (TextBox)(this.FV_BomDetail.FindControl("tbParCode")); TextBox tbCompCode = (TextBox)(this.FV_BomDetail.FindControl("tbCompCode")); TextBox tbOp = (TextBox)(this.FV_BomDetail.FindControl("tbOp")); TextBox tbReference = (TextBox)(this.FV_BomDetail.FindControl("tbReference")); TextBox tbStartTime = (TextBox)(this.FV_BomDetail.FindControl("tbStartTime")); TextBox tbEndTime = (TextBox)(this.FV_BomDetail.FindControl("tbEndTime")); TextBox tbRateQty = (TextBox)(this.FV_BomDetail.FindControl("tbRateQty")); Controls_TextBox tbUom = (Controls_TextBox)(this.FV_BomDetail.FindControl("tbUom")); Controls_TextBox tbStruType = (Controls_TextBox)(this.FV_BomDetail.FindControl("tbStruType")); TextBox tbScrapPercentage = (TextBox)(this.FV_BomDetail.FindControl("tbScrapPercentage")); Controls_TextBox tbLocation = (Controls_TextBox)(this.FV_BomDetail.FindControl("tbLocation")); CheckBox cbNeedPrint = (CheckBox)(this.FV_BomDetail.FindControl("cbNeedPrint")); CheckBox cbIsShipScan = (CheckBox)(this.FV_BomDetail.FindControl("cbIsShipScan")); TextBox tbPriority = (TextBox)(this.FV_BomDetail.FindControl("tbPriority")); com.Sconit.Control.CodeMstrDropDownList ddlBackFlushMethod = (com.Sconit.Control.CodeMstrDropDownList) this.FV_BomDetail.FindControl("ddlBackFlushMethod"); tbParCode.Text = bomdetail.Bom.Code; tbCompCode.Text = bomdetail.Item.Code; tbOp.Text = bomdetail.Operation.ToString(); tbReference.Text = bomdetail.Reference; tbStartTime.Text = bomdetail.StartDate.ToString("yyyy-MM-dd HH:mm"); if (bomdetail.EndDate != null) { tbEndTime.Text = ((DateTime)bomdetail.EndDate).ToString("yyyy-MM-dd HH:mm"); } tbRateQty.Text = bomdetail.RateQty.ToString("0.########"); tbUom.Text = bomdetail.Uom.Code; tbStruType.Text = bomdetail.StructureType; tbScrapPercentage.Text = (100 * bomdetail.ScrapPercentage).ToString("0.########"); if (bomdetail.Location != null) { tbLocation.Text = bomdetail.Location.Code; } tbPriority.Text = bomdetail.Priority.ToString(); if (bomdetail.BackFlushMethod != string.Empty) { ddlBackFlushMethod.SelectedValue = bomdetail.BackFlushMethod; } }
public OrderLocationTransaction AddNewMaterial(OrderDetail orderDetail, BomDetail bomDetail, Location orgLocation, decimal orgOrderedQty) { //如果是选装件并且默认不安装,不添加新物料 if (bomDetail.StructureType != BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_O || bomDetail.Priority != 0) { foreach (OrderLocationTransaction orderLocationTransaction in orderDetail.OrderLocationTransactions) { if (orderLocationTransaction.Item.Code == bomDetail.Item.Code && orderLocationTransaction.Operation == bomDetail.Operation) { //合并相同物料 //decimal orderedQty = orderDetail.OrderedQty * orgOrderedQty * bomDetail.RateQty * (1 + bomDetail.ScrapPercentage); decimal orderedQty = orgOrderedQty * bomDetail.RateQty * (1 + bomDetail.ScrapPercentage); if (orderLocationTransaction.Uom.Code != bomDetail.Uom.Code) { orderedQty = this.uomConversionMgr.ConvertUomQty(orderLocationTransaction.Item.Code, bomDetail.Uom, orderedQty, orderLocationTransaction.Uom); } orderLocationTransaction.UnitQty += orgOrderedQty * bomDetail.RateQty * (1 + bomDetail.ScrapPercentage); orderLocationTransaction.OrderedQty += orderedQty; this.UpdateOrderLocationTransaction(orderLocationTransaction); return(orderLocationTransaction); } } Location bomLocFrom = bomDetail.Location != null ? bomDetail.Location : orgLocation; OrderLocationTransaction newOrderLocationTransaction = this.GenerateOrderLocationTransaction(orderDetail, bomDetail.Item, bomDetail, bomDetail.Uom, bomDetail.Operation, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO, orgOrderedQty * bomDetail.RateQty * (1 + bomDetail.ScrapPercentage), bomLocFrom, bomDetail.IsShipScanHu, bomDetail.HuLotSize, bomDetail.NeedPrint, bomDetail.BackFlushMethod, null, null); this.CreateOrderLocationTransaction(newOrderLocationTransaction); orderDetail.AddOrderLocationTransaction(newOrderLocationTransaction); this.orderOperationMgr.TryAddOrderOperation(orderDetail.OrderHead, bomDetail.Operation, bomDetail.Reference); return(newOrderLocationTransaction); } return(null); }
private void ProcessCurrentBomDetail(IList <BomDetail> flatBomDetailList, BomDetail currentBomDetail, DateTime efftiveDate) { if (currentBomDetail.StructureType == BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_N) //普通结构(N) { ProcessCurrentBomDetailByItemType(flatBomDetailList, currentBomDetail, efftiveDate); } else if (currentBomDetail.StructureType == BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_O) //选配件(O) { currentBomDetail.OptionalItemGroup = currentBomDetail.Bom.Code; //默认用BomCode作为选配件的组号 ProcessCurrentBomDetailByItemType(flatBomDetailList, currentBomDetail, efftiveDate); } else if (currentBomDetail.StructureType == BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_X) //虚结构(X) { //如果是虚结构(X),不把自己加到返回表里,继续向下分解 NestingGetNextLevelBomDetail(flatBomDetailList, currentBomDetail, efftiveDate); } else { throw new TechnicalException("no such kind fo bomdetail structure type " + currentBomDetail.StructureType); } }
public bool CheckAddBomDetail(BomDetail addBomDetail, BomMaster selectBomMaster, bool isBomMaster) { if (!isBomMaster) { return(false); } foreach (BomMaster bomMaster in addBomDetail.GoodsKind.BomMasters) { if (bomMaster.BomDetails.Any(d => d.GoodsKind.goods_kind_id == selectBomMaster.GoodsKind.goods_kind_id)) { isBomMaster = false; break; } else { foreach (BomDetail bomDetail in bomMaster.BomDetails) { isBomMaster = CheckAddBomDetail(bomDetail, selectBomMaster, isBomMaster); } } } return(isBomMaster); }
public ActionResult _CreatePost(DesignConsumptionLineViewModel svm) { if (ModelState.IsValid) { FinishedProduct product = new FinishedProduct(); if (svm.BaseProductId == 0) { ProductQuality Quality = new ProductQualityService(_unitOfWork).Find(svm.QualityName); string ConsumptionProductName = ""; if (svm.ColourName != "" && svm.ColourName != null) { ConsumptionProductName = svm.DesignName.ToString().Trim() + "-" + svm.ColourName.ToString().Trim() + "-Bom"; } else { ConsumptionProductName = svm.DesignName.ToString().Trim() + "-Bom"; } int ProductGroupId = new ProductGroupService(_unitOfWork).Find(svm.DesignName).ProductGroupId; product.ProductCode = ConsumptionProductName; product.ProductName = ConsumptionProductName; product.ProductGroupId = new ProductGroupService(_unitOfWork).Find(ProductGroupConstants.Bom).ProductGroupId; product.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; product.IsActive = true; product.ReferenceDocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductGroup).DocumentTypeId; product.ReferenceDocId = ProductGroupId; product.StandardWeight = svm.Weight; product.CreatedDate = DateTime.Now; product.ModifiedDate = DateTime.Now; product.CreatedBy = User.Identity.Name; product.ModifiedBy = User.Identity.Name; product.ObjectState = Model.ObjectState.Added; product.IsSample = false; product.ProductQualityId = Quality.ProductQualityId; new ProductService(_unitOfWork).Create(product); ProductGroup ProductGroup = new ProductGroupService(_unitOfWork).Find(svm.DesignName); Colour Colour = new ColourService(_unitOfWork).Find(svm.ColourName); if (ProductGroup != null && Colour != null) { var ProductList = (from p in db.FinishedProduct where p.ProductGroupId == ProductGroup.ProductGroupId && p.ColourId == Colour.ColourId select new { ProductId = p.ProductId }).ToList(); foreach (var item in ProductList) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = item.ProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = 100; bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId; bomdetail.BaseProcessId = svm.BaseProcessId; bomdetail.ProductId = product.ProductId; bomdetail.Qty = 1; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); } } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.DesignColourConsumption).DocumentTypeId, DocId = product.ProductId, ActivityType = (int)ActivityTypeContants.Added, })); } else { //product = new FinishedProductService(_unitOfWork).Find(svm.BaseProductId); product.ProductId = svm.BaseProductId; } if (svm.BomDetailId == 0) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = svm.ConsumptionPer; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId; bomdetail.BaseProcessId = svm.BaseProcessId; bomdetail.ProductId = svm.ProductId; bomdetail.Qty = svm.Qty; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); if (bomdetail.BaseProductId == bomdetail.ProductId) { PrepareViewBag(svm); //return View(svm).Danger(DataValidationMsg); ModelState.AddModelError("", "Invalid Product is Selected!"); return(PartialView("_Create", svm)); } 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.DesignConsumption).DocumentTypeId, DocId = bomdetail.BomDetailId, ActivityType = (int)ActivityTypeContants.Added, })); if (svm.ContentType == "Main Contents") { return(RedirectToAction("_CreateMainContentForBaseProduct", new { id = product.ProductId })); } else if (svm.ContentType == "OverTuft Contents") { return(RedirectToAction("_CreateOverTuftContentForBaseProduct", new { id = product.ProductId })); } else { return(RedirectToAction("_CreateOtherContentForBaseProduct", new { id = product.ProductId })); } } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); BomDetail bomdetail = _BomDetailService.Find(svm.BomDetailId); BomDetail ExRec = Mapper.Map <BomDetail>(bomdetail); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = svm.ConsumptionPer; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.ProductId = svm.ProductId; bomdetail.Qty = svm.Qty; bomdetail.ModifiedDate = DateTime.Now; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Modified; _BomDetailService.Update(bomdetail); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = bomdetail, }); 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.DesignConsumption).DocumentTypeId, DocId = bomdetail.BomDetailId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(Json(new { success = true })); } } PrepareViewBag(svm); return(PartialView("_Create", svm)); }
public virtual void UpdateBomDetail(BomDetail entity) { Update(entity); }
public virtual void DeleteBomDetail(BomDetail entity) { Delete(entity); }
public virtual void DeleteBomDetail(BomDetail entity) { entityDao.DeleteBomDetail(entity); }
public virtual void CreateBomDetail(BomDetail entity) { Create(entity); }
public virtual void UpdateBomDetail(BomDetail entity) { entityDao.UpdateBomDetail(entity); }
public virtual void CreateBomDetail(BomDetail entity) { entityDao.CreateBomDetail(entity); }
public ActionResult CopyFromExisting(CopyFromExistingDesignConsumptionViewModel vm) { if (ModelState.IsValid) { Product OldProduct = _ProductService.Find(vm.ProductId); FinishedProduct NewProduct = new FinishedProduct(); ProductGroup productgroup = new ProductGroupService(_unitOfWork).Find(vm.ProductGroupId); if (productgroup.ProductGroupName.Length > 20) { NewProduct.ProductCode = productgroup.ProductGroupName.ToString().Substring(0, 20); } else { NewProduct.ProductCode = productgroup.ProductGroupName.ToString().Substring(0, productgroup.ProductGroupName.Length); } NewProduct.ProductName = productgroup.ProductGroupName; NewProduct.ProductGroupId = new ProductGroupService(_unitOfWork).Find(ProductGroupConstants.Bom).ProductGroupId; NewProduct.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; NewProduct.IsActive = true; NewProduct.CreatedDate = DateTime.Now; NewProduct.ModifiedDate = DateTime.Now; NewProduct.CreatedBy = User.Identity.Name; NewProduct.ModifiedBy = User.Identity.Name; NewProduct.ReferenceDocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductGroup).DocumentTypeId; NewProduct.ReferenceDocId = productgroup.ProductGroupId; NewProduct.IsSample = false; NewProduct.ObjectState = Model.ObjectState.Added; _ProductService.Create(NewProduct); var ProductList = (from p in db.Product where p.ProductGroupId == productgroup.ProductGroupId select new { ProductId = p.ProductId }).ToList(); foreach (var item in ProductList) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = item.ProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = 100; bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId; bomdetail.ProductId = NewProduct.ProductId; bomdetail.Qty = 1; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); } IEnumerable <BomDetail> BomDetailList = new BomDetailService(_unitOfWork).GetBomDetailList(OldProduct.ProductId); foreach (BomDetail item in BomDetailList) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = NewProduct.ProductId; bomdetail.BatchQty = item.BatchQty; bomdetail.ConsumptionPer = item.ConsumptionPer; bomdetail.Dimension1Id = item.Dimension1Id; bomdetail.ProcessId = item.ProcessId; bomdetail.ProductId = item.ProductId; bomdetail.Qty = item.Qty; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("CopyFromExisting", vm)); } return(Json(new { success = true, Url = "/DesignConsumptionHeader/Edit/" + NewProduct.ProductId })); } return(PartialView("CopyFromExisting", vm)); }
public ActionResult Create(DesignConsumptionHeaderViewModel svm) { if (ModelState.IsValid) { if (svm.BaseProductId == 0) { FinishedProduct product = new FinishedProduct(); if (svm.ProductGroupName.Length > 20) { product.ProductCode = svm.ProductGroupName.ToString().Substring(0, 20); } else { product.ProductCode = svm.ProductGroupName.ToString().Substring(0, svm.ProductGroupName.Length); } product.ProductName = svm.ProductGroupName; product.ProductGroupId = new ProductGroupService(_unitOfWork).Find(ProductGroupConstants.Bom).ProductGroupId; product.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; product.IsActive = true; product.ReferenceDocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductGroup).DocumentTypeId; product.ReferenceDocId = svm.ProductGroupId; product.IsSample = false; product.CreatedDate = DateTime.Now; product.ModifiedDate = DateTime.Now; product.CreatedBy = User.Identity.Name; product.ModifiedBy = User.Identity.Name; product.ObjectState = Model.ObjectState.Added; _ProductService.Create(product); ProductGroup ProductGroup = new ProductGroupService(_unitOfWork).Find(svm.ProductGroupName); if (ProductGroup != null) { var ProductList = (from p in db.Product where p.ProductGroupId == ProductGroup.ProductGroupId select new { ProductId = p.ProductId }).ToList(); foreach (var item in ProductList) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = item.ProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = 100; bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId; bomdetail.ProductId = product.ProductId; bomdetail.Qty = 1; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); } } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View(svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.DesignConsumption).DocumentTypeId, DocId = product.ProductId, ActivityType = (int)ActivityTypeContants.Added, })); //return RedirectToAction("Create").Success("Data saved successfully"); return(RedirectToAction("Edit", new { id = product.ProductId }).Success("Data saved Successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); Product product = _ProductService.Find(svm.BaseProductId); Product ExRec = Mapper.Map <Product>(product); if (svm.ProductGroupName.Length > 20) { product.ProductCode = svm.ProductGroupName.ToString().Substring(0, 20); } else { product.ProductCode = svm.ProductGroupName.ToString().Substring(0, svm.ProductGroupName.Length); } product.ProductName = svm.ProductGroupName; product.ReferenceDocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductGroup).DocumentTypeId; product.ReferenceDocId = svm.ProductGroupId; product.ModifiedBy = User.Identity.Name; product.ModifiedDate = DateTime.Now; StringBuilder logstring = new StringBuilder(); _ProductService.Update(product); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = product, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View("Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.DesignConsumption).DocumentTypeId, DocId = product.ProductId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(RedirectToAction("Index").Success("Data saved successfully")); } } PrepareViewBag(); return(View(svm)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string k = GetQueryValue("k"); foreach (Control ctrl in SimpleForm1.Controls) { if (ctrl.GetType().Name == "FormRow") { foreach (Control subctrl in ctrl.Controls) { //Alert.Show(subctrl.GetType().Name); if (subctrl.GetType().Name == "TextBox") { FineUIPro.TextBox tb = (FineUIPro.TextBox)subctrl; if (tb.ID != "txtQuantity" && tb.ID != "txtUsingQuantity") { tb.Readonly = true; } } else if (subctrl.GetType().Name == "NumberBox") { NumberBox numbox = (NumberBox)subctrl; if (numbox.ID != "txtQuantity") { numbox.Readonly = true; } } else if (subctrl.GetType().Name == "TextArea") { FineUIPro.TextArea tb = (FineUIPro.TextArea)subctrl; tb.Readonly = true; } } } } using (var appdb = new AppContext()) { int sn = GetQueryIntValue("id"); int fsn = GetQueryIntValue("fsn"); BomHeader item = appdb.bombase .Where(u => u.SN == fsn).FirstOrDefault(); txtOrderNo.Text = item.OrderNo; txtProNo.Text = item.ProNo; txtProName.Text = item.ProName; //txtClinetNo.Text = item.ClientNo; txtQuantity.Text = ""; BomDetail current = appdb.bomdtl .Where(u => u.SN == sn).FirstOrDefault(); if (current == null) { // 参数错误,首先弹出Alert对话框然后关闭弹出窗口 Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference()); return; } txtItemNo.Text = current.ItemNo; txtItemName.Text = current.ItemName; txtMaterial.Text = current.Material; txtSclass.Text = current.Sclass; txtSpec.Text = current.Spec; txtSurfaceDeal.Text = current.SurfaceDeal; txtUsingQuantity.Text = current.OrderUsingQuantity.ToString(); txtMakeThod.Text = current.MainFrom; //Instruction ins = appdb.instruction // .Where(u => u.OrderNo == item.OrderNo && u.ProNo == item.ProNo && u.ItemNo == current.ItemNo).FirstOrDefault() ; //var instructionsql = from a in appdb.instruction // where a.OrderNo == item.OrderNo && a.ProNo == item.ProNo && a.ItemNo == current.ItemNo // group a by new // { // a.ItemNo // } into g // select new // { // g.Key.ItemNo, // confirmquantity = (double)g.Sum(p => p.ConfirmQuantity) // }; //double? cfq= appdb.instruction.SqlQuery("select itemno,sum(ConfirmQuantity) from instruction where orderno='"+item.OrderNo+"' and prono='"+item.ProNo+"' and itemno='"+current.ItemNo+"' group by itemno",new object[]{}).FirstOrDefault().ConfirmQuantity; SQLHelper.DbHelperSQL.SetConnectionString(""); string sql = "select sum(ConfirmQuantity) from instruction where orderno='" + item.OrderNo + "' and prono='" + item.ProNo + "' and itemno='" + current.ItemNo + "'"; object sq = SQLHelper.DbHelperSQL.GetSingle(sql); if (sq != null) { txtUsingQuantity.Text = (current.OrderUsingQuantity - (double.Parse(sq.ToString()))).ToString(); } else { txtUsingQuantity.Text = current.OrderUsingQuantity.ToString(); } //if(instructionsql!=null) //{ // var ss = instructionsql.FirstOrDefault(); // if (ss != null) // { // txtUsingQuantity.Text = (current.UsingQuantity - ss.confirmquantity).ToString(); // } //} } LoadData(); } }
public ActionResult _CreatePost(ProductConsumptionLineViewModel svm) { if (ModelState.IsValid) { if (svm.BomDetailId == 0) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; //bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Silai).ProcessId; bomdetail.BaseProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Manufacturing).ProcessId; bomdetail.ProductId = svm.ProductId; bomdetail.ProcessId = svm.ProcessId; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.Dimension2Id = svm.Dimension2Id; bomdetail.Dimension3Id = svm.Dimension3Id; bomdetail.Dimension4Id = svm.Dimension4Id; bomdetail.Qty = svm.Qty; bomdetail.MBQ = svm.MBQ; bomdetail.StdCost = svm.StdCost; bomdetail.StdTime = svm.StdTime; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", svm)); } return(RedirectToAction("_Create", new { id = svm.BaseProductId })); } else { BomDetail bomdetail = _BomDetailService.Find(svm.BomDetailId); StringBuilder logstring = new StringBuilder(); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; bomdetail.BaseProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Manufacturing).ProcessId; bomdetail.ProductId = svm.ProductId; bomdetail.ProcessId = svm.ProcessId; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.Dimension2Id = svm.Dimension2Id; bomdetail.Dimension3Id = svm.Dimension3Id; bomdetail.Dimension4Id = svm.Dimension4Id; bomdetail.Qty = svm.Qty; bomdetail.MBQ = svm.MBQ; bomdetail.StdCost = svm.StdCost; bomdetail.StdTime = svm.StdTime; bomdetail.ModifiedDate = DateTime.Now; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Modified; _BomDetailService.Update(bomdetail); //Saving the Activity Log ActivityLog al = new ActivityLog() { ActivityType = (int)ActivityTypeContants.Modified, DocId = bomdetail.BomDetailId, CreatedDate = DateTime.Now, Narration = logstring.ToString(), CreatedBy = User.Identity.Name, //DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(TransactionDocCategoryConstants.BomDetail).DocumentTypeId, }; new ActivityLogService(_unitOfWork).Create(al); //End of Saving the Activity Log try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", svm)); } return(Json(new { success = true })); } } PrepareViewBag(svm); return(PartialView("_Create", svm)); }
public ActionResult _EditWithSKU(DesignConsumptionLineViewModel svm) { if (ModelState.IsValid) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); BomDetail bomdetail = _BomDetailService.Find(svm.BomDetailId); int?ExistingDim1Id = bomdetail.Dimension1Id; int ExistingProductId = bomdetail.ProductId; BomDetail ExRec = Mapper.Map <BomDetail>(bomdetail); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.ProductId = svm.ProductId; bomdetail.ModifiedDate = DateTime.Now; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Modified; _BomDetailService.Update(bomdetail); var product = db.Product.Find(bomdetail.BaseProductId); var pendingSKUConsumptionToUpdate = (from p in db.Product join pg in db.ProductGroups on p.ProductGroupId equals pg.ProductGroupId join pt in db.ProductTypes on pg.ProductTypeId equals pt.ProductTypeId join bd1 in db.BomDetail on p.ProductId equals bd1.BaseProductId join bd2 in db.BomDetail on bd1.ProductId equals bd2.BaseProductId where pg.ProductGroupName == product.ProductName && bd2.Dimension1Id == ExistingDim1Id && bd2.ProductId == ExistingProductId && bd2.BomDetailId != bomdetail.BomDetailId group bd2 by bd2.BomDetailId into g orderby g.Key select g.FirstOrDefault()).ToList(); foreach (var item in pendingSKUConsumptionToUpdate) { item.ProductId = bomdetail.ProductId; item.Dimension1Id = bomdetail.Dimension1Id; item.ObjectState = Model.ObjectState.Modified; _BomDetailService.Update(item); } LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = bomdetail, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); Modifications.Add("Updated in All SKU and Shades."); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_EditWithSKU", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.DesignConsumption).DocumentTypeId, DocId = bomdetail.BomDetailId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(Json(new { success = true })); } PrepareViewBag(svm); return(PartialView("_EditWithSKU", svm)); }