private void DeleteStockEventHandler(object sender, DeleteStockEventArgs e) { if (this.View.AskMessBox("您确定要删除当前选中库存么?") == 0) { for (int i = 0; i < e.StockID.Length; i++) { StockModel stockModel = bllStock.GetModel(e.StockID[i]); if (stockModel == null) { return; } StockListModel stockListModel = bllStockList.GetModelByStockID(stockModel.StockID); if (stockListModel == null) { return; } ManageTaskListModel manaTaskList = bllTaskList.GetModelByStockListID(stockListModel.StockListID); if (manaTaskList != null) { ManageTaskModel manaTask = bllTask.GetModel(manaTaskList.TaskID); if (manaTask != null) { bllTask.Delete(manaTask.TaskID); } } Hashtable updateGsStatusHs = bllGoodsSite.GetUpdateModelHs(EnumGSStoreStatus.空货位.ToString() , EnumGSRunStatus.待用.ToString(), EnumTaskCategory.出库.ToString(), stockModel.GoodsSiteID); //获取更新货位状态Hs Hashtable deleteStockHs = bllStock.GetDeleteModelHash(e.StockID[i]); List <Hashtable> allHs = new List <Hashtable>(); allHs.Add(updateGsStatusHs); allHs.Add(deleteStockHs); bool deleteStatus = ExecuteManyHashSqls(allHs); if (deleteStatus == true) { if (this.mainPres != null) { this.mainPres.ShowLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.提示, "用户:" + this.userNameStr + ",手动删除库存ID:" + e.StockID[i] + "库存名称:" + stockListModel.GoodsSiteName + "成功!"); } } else { if (this.mainPres != null) { this.mainPres.ShowLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.提示, "用户:" + this.userNameStr + ",手动删除库存ID:" + e.StockID[i] + "库存名称:" + stockListModel.GoodsSiteName + "失败!"); } } } //List<StockListModel> modelList = bllStockList.GetModelList(queryHouseName,queryRowth,queryColumnth,queryLayerth, queryProductStasus, queryWorkFlowStatus); //this.View.RefreshDGVData(modelList); List <View_QueryStockListModel> modelList = bllQueryStockList.GetModelList(queryHouseName, queryRowth, queryColumnth, queryLayerth, queryProductStasus, queryWorkFlowStatus , queryGsRunStatus, queryGsStoreStatus, queryGsTaskType, queryProductBatchNum); this.View.RefreshDGVData(modelList); } }
/// <summary> /// 手动取消任务 /// 删除控制任务、管理任务 /// 删除控制任务接口 /// 更新货位状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CancelTaskEventHandler(object sender, ControlTaskEventArgs e) { int taskStatus = this.View.AskMessBox("您确定要手动删除选中任务么?"); try { if (taskStatus == 0) { if (e.ControlTaskIDArr.Count() > 0)//只有任务没有完成的时候才可以取消 { for (int i = 0; i < e.ControlTaskIDArr.Count(); i++) { Hashtable deleteManaHs = null; Hashtable deleteControlInterHs = null; Hashtable deleteStockHs = null; Hashtable updateGsHs = null; ControlTaskModel controlTaskModel = bllControlTask.GetModel(e.ControlTaskIDArr[i]); if (controlTaskModel == null) { continue; } if (controlTaskModel.TaskStatus == EnumTaskStatus.执行中.ToString()) { this.View.ShowMessage("信息提示", "任务在执行中不允许删除!!"); continue; } if (controlTaskModel.TaskStatus == EnumTaskStatus.错误.ToString() || controlTaskModel.TaskStatus == EnumTaskStatus.超时.ToString()) { //要调用控制层的接口,处理控制层; MainPresenter.wcs.ClearTask(controlTaskModel); } ManageTaskModel manaTaskModel = bllManaTask.GetModel(controlTaskModel.TaskID); if (manaTaskModel == null) { continue; } StockListModel stockListModel = null; StockModel stockModel = null; GoodsSiteModel gsModel = null; if (controlTaskModel.TaskTypeCode == (int)EnumTaskName.电芯入库_A1 || controlTaskModel.TaskTypeCode == (int)EnumTaskName.分容入库_A1 || controlTaskModel.TaskTypeCode == (int)EnumTaskName.电芯入库_B1 || controlTaskModel.TaskTypeCode == (int)EnumTaskName.空料框入库) //任务完成后需要更新货位状态 { stockListModel = bllStockList.GetModelByManaTaskID(controlTaskModel.TaskID); stockModel = bllStock.GetModel(stockListModel.StockID); if (stockListModel != null && stockModel != null) { deleteStockHs = bllStock.GetDeleteModelHash(stockModel.StockID);//入库任务取消要删除库存 updateGsHs = bllGoodsSite.GetUpdateModelHs(EnumGSStoreStatus.空货位.ToString(), EnumGSRunStatus.待用.ToString() , EnumTaskCategory.出入库.ToString(), stockModel.GoodsSiteID); } } else if (controlTaskModel.TaskTypeCode == (int)EnumTaskName.分容出库_A1 || controlTaskModel.TaskTypeCode == (int)EnumTaskName.电芯出库_A1) //出库删除任务不删除库存 { gsModel = bllGoodsSite.GetGoodsSite(EnumStoreHouse.A1库房, controlTaskModel.StartDevice); stockModel = bllStock.GetModelByGsID(gsModel.GoodsSiteID); if (stockModel != null) { updateGsHs = bllGoodsSite.GetUpdateModelHs(EnumGSStoreStatus.货.ToString(), EnumGSRunStatus.任务完成.ToString() , EnumTaskCategory.入库.ToString(), stockModel.GoodsSiteID); } } else if (controlTaskModel.TaskTypeCode == (int)EnumTaskName.电芯出库_B1) { gsModel = bllGoodsSite.GetGoodsSite(EnumStoreHouse.B1库房, controlTaskModel.StartDevice); stockModel = bllStock.GetModelByGsID(gsModel.GoodsSiteID); if (stockModel != null) { updateGsHs = bllGoodsSite.GetUpdateModelHs(EnumGSStoreStatus.货.ToString(), EnumGSRunStatus.任务完成.ToString() , EnumTaskCategory.入库.ToString(), stockModel.GoodsSiteID); } } else if (controlTaskModel.TaskTypeCode == (int)EnumTaskName.空料框出库) { gsModel = bllGoodsSite.GetGoodsSite(EnumStoreHouse.B1库房, controlTaskModel.StartDevice); stockModel = bllStock.GetModelByGsID(gsModel.GoodsSiteID); if (stockModel != null) { updateGsHs = bllGoodsSite.GetUpdateModelHs(EnumGSStoreStatus.空料框.ToString(), EnumGSRunStatus.任务完成.ToString() , EnumTaskCategory.入库.ToString(), stockModel.GoodsSiteID); } } deleteManaHs = bllManaTask.GetDeleteModelHash(manaTaskModel.TaskID); deleteControlInterHs = bllControlInterface.GetDeleteHash(controlTaskModel.ControlCode); List <Hashtable> hashList = new List <Hashtable>(); hashList.Add(deleteManaHs); hashList.Add(deleteControlInterHs); hashList.Add(deleteStockHs); hashList.Add(updateGsHs); bool executeTran = ExecuteManyHashSqls(hashList); if (executeTran == true) { if (mainPres != null) { mainPres.View.AddLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.提示, "用户:" + this.userNameStr + ",ID:" + controlTaskModel.ControlTaskID + "任务开始位置:" + controlTaskModel.StartDevice + "任务结束位置:" + controlTaskModel.TargetDevice + ",“" + manaTaskModel.TaskTypeName + "”任务手动删除成功!"); } } else { if (mainPres != null) { mainPres.View.AddLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.提示, "用户:" + this.userNameStr + ",ID:" + controlTaskModel.ControlTaskID + "任务开始位置:" + controlTaskModel.StartDevice + "任务结束位置:" + controlTaskModel.TargetDevice + ",“" + manaTaskModel.TaskTypeName + "”任务手动删除失败!"); } } } } DataTable dtCtrlTaskList = bllControlTask.GetCtrlDatatable(this.currentEnumTaskName, this.currentEnumTaskStatus , this.currentHouseName, this.currentCreateMode, this.currentTaskType); this.View.ShowControlTaskData(dtCtrlTaskList); } } catch (Exception ex) { mainPres.View.AddLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.错误, ex.StackTrace); } }