public ActionResult CopyRecord(string id, int pots) { try { ProductRecord obj = this.service.GetGenericService <ProductRecord>().Get(id); ShippingDocument ShippingDocument = this.service.GetGenericService <ShippingDocument>().Get(obj.ShipDocID); IList <ProductRecord> ps = this.service.GetGenericService <ProductRecord>().Query().Where(m => m.ShipDocID == obj.ShipDocID).ToList(); int?MaxPots = this.service.DispatchList.CalculateTotalPot(obj.PCRate, ShippingDocument.SendCube); IList <ProductRecordItem> items = this.service.ProductRecordItemService.Query().Where(m => m.ProductRecordID == id).ToList(); if (MaxPots < ps.Count + 1) { throw new Exception("本车生产" + ShippingDocument.SendCube + "方,最多" + MaxPots + "盘,超出盘数了"); } ProductRecord temp = new ProductRecord(); temp.ID = obj.ID.Substring(0, obj.ID.LastIndexOf('_')) + "_" + pots; temp.IsManual = true; temp.PCRate = obj.PCRate; temp.PotTimes = pots; temp.ShipDocID = obj.ShipDocID; temp.BuildTime = obj.BuildTime; temp.ProduceCube = obj.ProduceCube; temp.DispatchID = obj.DispatchID; temp.ProductLineID = obj.ProductLineID; temp = this.service.GetGenericService <ProductRecord>().Add(temp); foreach (ProductRecordItem item in items) { ProductRecordItem obj1 = new ProductRecordItem(); obj1.ProductRecordID = temp.ID; obj1.SiloID = item.SiloID; obj1.StuffID = item.StuffID; obj1.TheoreticalAmount = item.TheoreticalAmount; obj1.ActualAmount = item.ActualAmount; obj1.ErrorValue = item.ErrorValue; this.service.ProductRecordItemService.Add(obj1); } return(OperateResult(true, Lang.Msg_Operate_Success, temp)); } catch (Exception ex) { return(OperateResult(false, ex.Message, false)); } }
public bool Import(string id) { using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction()) { try { bool result = true; ProductRecord obj = this.Get(id); ShippingDocument shipdoc = this.m_UnitOfWork.ShippingDocumentRepository.Get(obj.ShipDocID); ConsMixprop cm = this.m_UnitOfWork.ConsMixpropRepository.Get(shipdoc.ConsMixpropID); List <ConsMixpropItem> list = this.m_UnitOfWork.ConsMixpropItemRepository.Query().Where(m => m.ConsMixpropID == cm.ID && m.Amount > 0).ToList(); ThreadID tid; PublicService ps = new PublicService(); foreach (ConsMixpropItem c in list) { ProductRecordItem tmp = new ProductRecordItem(); tmp.ActualAmount = obj.ProduceCube * c.Amount; tmp.TheoreticalAmount = obj.ProduceCube * c.Amount; tmp.SiloID = c.SiloID; tmp.StuffID = c.Silo.StuffInfo.ID; tmp.ProductRecordID = id; tmp.ErrorValue = 0; tmp.ProductLineID = obj.ProductLineID; this.m_UnitOfWork.GetRepositoryBase <ProductRecordItem>().Add(tmp); tid = new ThreadID(); tid.currentDate = DateTime.Now; tid.typeID = tmp.StuffID; //主材id tid.typename = "0"; //主材 ps.ThreadID.Add(tid); } tx.Commit(); return(result); } catch (Exception ex) { tx.Rollback(); logger.Error(ex.Message); throw new Exception(ex.Message); } } }
/// <summary> /// 原材料信息-修改 /// </summary> /// <param name="entity"></param> /// <returns></returns> public override ActionResult Update(StuffInfo entity) { string stuffid = entity.ID; ProductRecordItem prt = this.service.ProductRecordItemService.Query() .Where(p => p.StuffID == stuffid) .FirstOrDefault(); StuffInfo tmp = this.m_ServiceBase.Get(entity.ID); //材料名不为空判断,因为浏览端在停供材料,库存调整功能,名称类型表单时禁用的 if ((tmp.StuffName != entity.StuffName || tmp.StuffTypeID != entity.StuffTypeID) && entity.StuffName != null) { if (prt != null) { //如果存在记录,则说明该材料已经使用,不允许修改 return(OperateResult(false, "该材料已经使用,不允许修改材料名称或者类型", prt)); } } if (tmp.Inventory != entity.Inventory) //表示用户修改了材料的库存 { this.service.SysLog.Log(Model.Enums.SysLogType.UpdateStuffInventory, entity.ID, entity, "库存调整为" + entity.Inventory.ToString()); } return(base.Update(entity)); }