/// <summary> /// 创建ProcessRecorder表数据 /// </summary> /// <param name="Data"></param> /// <param name="RowData"></param> /// <param name="Type"></param> public void CreateSR(SOInputDto Data, AssScrapOrderRow RowData, PROCESSMODE Type) { AssProcessRecord assProcessRecord = new AssProcessRecord { ASSID = RowData.ASSID, //资产条码 CREATEDATE = DateTime.Now, //创建时间 CREATEUSER = Data.CREATEUSER, //创建用户 HANDLEDATE = DateTime.Now, //处理时间 MODIFYDATE = DateTime.Now, //修改时间 MODIFYUSER = Data.MODIFYUSER, //修改用户 }; switch (Type) { case PROCESSMODE.清理报废: assProcessRecord.QUANTITY = RowData.SCRAPQTY; assProcessRecord.PROCESSMODE = (Int32)PROCESSMODE.清理报废; assProcessRecord.HANDLEMAN = Data.CREATEUSER; break; case PROCESSMODE.报废还原: assProcessRecord.QUANTITY = RowData.SCRAPQTY; assProcessRecord.PROCESSMODE = (Int32)PROCESSMODE.报废还原; assProcessRecord.HANDLEMAN = Data.MODIFYUSER; break; } assProcessRecord.ASSID = RowData.ASSID; switch (Type) //根据操作模式,输入操作内容 { case PROCESSMODE.清理报废: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "报废了物品编号为" + RowData.ASSID + "的资产"; break; case PROCESSMODE.报废还原: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "还原了物品编号为" + RowData.ASSID + "的资产"; break; } _unitOfWork.RegisterNew(assProcessRecord); }
/// <summary> /// 创建ProcessRecorder表数据 /// </summary> /// <param name="Data"></param> /// <param name="RowData"></param> /// <param name="Type"></param> public void CreatePR(ROInputDto Data, AssRepairOrderRow RowData, PROCESSMODE Type) { AssProcessRecord assProcessRecord = new AssProcessRecord { ASSID = RowData.ASSID, //资产条码 CREATEDATE = DateTime.Now, //创建时间 CREATEUSER = Data.CREATEUSER, //创建用户 HANDLEDATE = DateTime.Now, //处理时间 MODIFYDATE = DateTime.Now, //修改时间 MODIFYUSER = Data.MODIFYUSER, //修改用户 }; switch (Type) { case PROCESSMODE.报修: assProcessRecord.QUANTITY = RowData.WAITREPAIRQTY; assProcessRecord.PROCESSMODE = (Int32)PROCESSMODE.报修; assProcessRecord.HANDLEMAN = Data.CREATEUSER; break; case PROCESSMODE.维修完毕: assProcessRecord.QUANTITY = RowData.REPAIREDQTY; assProcessRecord.PROCESSMODE = (Int32)PROCESSMODE.维修完毕; assProcessRecord.HANDLEMAN = Data.MODIFYUSER; break; } switch (Type) //根据操作模式,输入操作内容 { case PROCESSMODE.报修: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "报修了物品编号为" + RowData.ASSID + "的资产"; break; case PROCESSMODE.维修完毕: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "维修了物品编号为" + RowData.ASSID + "的资产"; break; } _unitOfWork.RegisterNew(assProcessRecord); }
/// <summary> /// 更新报修单行项 /// </summary> /// <param name="entity"></param> /// <returns></returns> public void UpdateAssTransferOrderRow(TOInputDto entity, PROCESSMODE ProType, OperateType type) { AssTransferOrderRow assROR = new AssTransferOrderRow(); foreach (AssTransferOrderRow Row in entity.Rows) { assROR = _AssTransferOrderRowRepository.GetByID(entity.TOID, Row.TOROWID).FirstOrDefault(); if (assROR == null) { throw new Exception("调拨单行项:" + Row.TOROWID + "不存在!"); } switch (ProType) { case PROCESSMODE.调拨确认: assROR.INTRANSFERQTY = assROR.INTRANSFERQTY - Convert.ToDecimal(Row.TRANSFEREDQTY); //确认调拨数量 if (Row.INTRANSFERQTY < 0) { throw new Exception("确认数量不能超过申请调拨数量!"); } assROR.TRANSFEREDQTY = Convert.ToDecimal(assROR.TRANSFEREDQTY) + Row.TRANSFEREDQTY; break; case PROCESSMODE.调拨取消: assROR.INTRANSFERQTY = assROR.INTRANSFERQTY - Convert.ToDecimal(Row.TRANSFERCANCELQTY); //取消调拨数量 if (Row.INTRANSFERQTY < 0) { throw new Exception("取消数量不能超过申请调拨数量!"); } assROR.TRANSFERCANCELQTY = Convert.ToDecimal(assROR.TRANSFERCANCELQTY) + Row.TRANSFERCANCELQTY; break; } if (assROR.INTRANSFERQTY == 0) //如果全部调拨完毕,则修改行项状态 { if (ProType == PROCESSMODE.调拨确认) { assROR.STATUS = 1; //调拨完成 } else { assROR.STATUS = 2; //调拨取消 } } //更新OrderRow数据 _unitOfWork.RegisterDirty(assROR); if (type == OperateType.资产) { Assets SNData = _AssetsRepository.GetByID(Row.ASSID).FirstOrDefault(); if (ProType == PROCESSMODE.调拨确认) { SNData.LOCATIONID = entity.DESLOCATIONID; //区域 } //修改AssetsSN表中资产状态 SNData.STATUS = (Int32)STATUS.闲置; //资产状态 _unitOfWork.RegisterDirty(SNData); //新建调拨行项 } else { ConQuant assQuant = new ConQuant(); //修改Quant表数据 assQuant.CID = Row.CID; //资产条码 if (ProType == PROCESSMODE.调拨确认) { assQuant.QUANTITY = Convert.ToDecimal(Row.TRANSFEREDQTY); //确认调入数量 assQuant.LOCATIONID = entity.DESLOCATIONID; //区域 } else { assQuant.QUANTITY = Convert.ToDecimal(Row.TRANSFERCANCELQTY); //取消调入数量 assQuant.LOCATIONID = Row.LOCATIONID; //区域 } ConQuant aq = _ConQuantRepository.GetByCID(Row.CID, assQuant.LOCATIONID).FirstOrDefault(); if (aq == null) //如果不存在当前库存地数据,则创建一条新数据 { assQuant.CREATEDATE = DateTime.Now; assQuant.CREATEUSER = entity.MODIFYUSER; assQuant.MODIFYDATE = DateTime.Now; assQuant.MODIFYUSER = entity.MODIFYUSER; _unitOfWork.RegisterNew(assQuant); } else //已有数据,修改库存数量 { aq.QUANTITY = aq.QUANTITY + assQuant.QUANTITY; _unitOfWork.RegisterDirty(aq); } } //往AssProcessRecord表添加数据 CreatePR(entity, Row, ProType); } }
/// <summary> /// 创建ProcessRecorder表数据 /// </summary> /// <param name="Data"></param> /// <param name="RowData"></param> /// <param name="Type"></param> public void CreatePR(TOInputDto Data, AssTransferOrderRow RowData, PROCESSMODE Type) { AssProcessRecord assProcessRecord = new AssProcessRecord { ASSID = RowData.ASSID, //资产条码 CID = RowData.CID, //耗材编号 CREATEDATE = DateTime.Now, //创建时间 CREATEUSER = Data.CREATEUSER, //创建用户 HANDLEDATE = DateTime.Now, //处理时间 MODIFYDATE = DateTime.Now, //修改时间 MODIFYUSER = Data.MODIFYUSER, //修改用户 }; switch (Type) { case PROCESSMODE.调拨: assProcessRecord.QUANTITY = RowData.INTRANSFERQTY; assProcessRecord.PROCESSMODE = (Int32)PROCESSMODE.调拨; assProcessRecord.HANDLEMAN = Data.CREATEUSER; break; case PROCESSMODE.调拨确认: assProcessRecord.QUANTITY = Convert.ToDecimal(RowData.TRANSFEREDQTY); assProcessRecord.PROCESSMODE = (Int32)PROCESSMODE.调拨确认; assProcessRecord.HANDLEMAN = Data.MODIFYUSER; break; case PROCESSMODE.调拨取消: assProcessRecord.QUANTITY = Convert.ToDecimal(RowData.TRANSFERCANCELQTY); assProcessRecord.PROCESSMODE = (Int32)PROCESSMODE.调拨取消; assProcessRecord.HANDLEMAN = Data.MODIFYUSER; break; } if (String.IsNullOrEmpty(RowData.ASSID) == false) { switch (Type) //根据操作模式,输入操作内容 { case PROCESSMODE.调拨: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "调拨了物品编号为" + RowData.ASSID + "的资产"; break; case PROCESSMODE.调拨确认: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "确认调拨了物品编号为" + RowData.ASSID + "的资产"; break; case PROCESSMODE.调拨取消: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "取消调拨了物品编号为" + RowData.ASSID + "的资产"; break; } } else { assProcessRecord.CID = RowData.CID; switch (Type) //根据操作模式,输入操作内容 { case PROCESSMODE.调拨: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "调拨了耗材编号为" + RowData.CID + ",数量为" + RowData.INTRANSFERQTY; break; case PROCESSMODE.调拨确认: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "确认调拨了耗材编号为" + RowData.CID + ",数量为" + RowData.TRANSFEREDQTY; break; case PROCESSMODE.调拨取消: assProcessRecord.PROCESSCONTENT = Data.CREATEUSER + "取消调拨了耗材编号为" + RowData.CID + ",数量为" + RowData.TRANSFERCANCELQTY; break; } } _unitOfWork.RegisterNew(assProcessRecord); }
/// <summary> /// 更新调拨单 /// </summary> /// <param name="entity"></param> /// <returns></returns> public ReturnInfo UpdateAssTransferOrder(TOInputDto entity, PROCESSMODE ProType, OperateType type) { ReturnInfo RInfo = new ReturnInfo(); try { if (String.IsNullOrEmpty(entity.TOID)) { throw new Exception("调拨单编号不能为空"); } AssTransferOrder aro = _AssTransferOrderRepository.GetByID(entity.TOID).FirstOrDefault(); if (aro != null) { if (aro.STATUS == 1 || aro.STATUS == 2) { throw new Exception("只有调拨中的才能确认"); } else { List <AssTransferOrderRow> Rows = _AssTransferOrderRowRepository.GetUnTransferTOID(aro.TOID).AsNoTracking().ToList(); if (Rows.Count == entity.Rows.Count) //判断调拨单是完成还是取消 { Boolean isOver = false; foreach (AssTransferOrderRow Row in entity.Rows) //只要调拨行项中有一个确认,则调拨单属于完成 { if (Row.STATUS == 1) { isOver = true; aro.STATUS = 1; } } if (isOver == false) //否之,调拨单为取消 { aro.STATUS = 2; } } //更新报修单行项 aro.MODIFYDATE = entity.MODIFYDATE; aro.MODIFYUSER = entity.MODIFYUSER; entity.DESLOCATIONID = aro.DESLOCATIONID; _unitOfWork.RegisterDirty(aro); UpdateAssTransferOrderRow(entity, ProType, type); bool result = _unitOfWork.Commit(); RInfo.IsSuccess = result; RInfo.ErrorInfo = "修改成功!"; return(RInfo); } } else { throw new Exception("调拨单不存在!"); } } catch (Exception ex) { _unitOfWork.Rollback(); RInfo.IsSuccess = false; RInfo.ErrorInfo = ex.Message; return(RInfo); } }