/// <summary> /// 执行确定命令。 /// </summary> /// <param name="sender"></param> public void OnCommitExecute(object sender) { var radGridView = sender as RadGridView; if (radGridView == null) return; if (SelSnRemInstRecord != null && SelSnRemInstRecord.AircraftId != Guid.Empty && _removeChildView) { radGridView.SelectedItems.ToList().ForEach(p => { var snRegDto = p as SnRegDTO; if (snRegDto != null) { //找到SnReg的最后一条装上记录(时间最大),且这条记录无拆下信息 var snHis = SnHistories.Where(s => s.SnRegId == snRegDto.Id).OrderBy(l => l.ActionDate).LastOrDefault(); if (snHis == null) MessageAlert("序号件:" + snRegDto.Sn + "没有找到拆装历史!请检查!"); else if (snHis.ActionType == (int) ActionType.拆下) { MessageAlert("序号件:" + snRegDto.Sn + "最近一次操作为拆下,不能再做拆下操作!请检查!"); } else { var newSh = new SnHistoryDTO { Id = RandomHelper.Next(), ActionDate = DateTime.Now, ActionNo = SelSnRemInstRecord.ActionNo, ActionType = (int) ActionType.拆下, AircraftId = SelSnRemInstRecord.AircraftId, RegNumber = SelSnRemInstRecord.RegNumber, Pn = snRegDto.Pn, Sn = snRegDto.Sn, PnRegId = snRegDto.PnRegId, SnRegId = snRegDto.Id, RemInstRecordId = SelSnRemInstRecord.Id, Status = (int) SnStatus.在库, }; Removals.Add(newSh); var snReg = SnRegs.FirstOrDefault(sn => sn.Id == snHis.SnRegId); if (snReg != null) { snHis.Status = newSh.Status; snReg.AircraftId = null; } } } }); SelRemoval = Removals.FirstOrDefault(); _addChildView = false; _removeChildView = false; } else if (SelSnRemInstRecord != null && _addChildView) { radGridView.SelectedItems.ToList().ForEach(p => { var snRegDto = p as SnRegDTO; if (snRegDto != null) { var snHis = SnHistories.Where(s => s.SnRegId == snRegDto.Id).OrderBy(l => l.ActionDate).LastOrDefault(); if (snHis != null && snHis.ActionType == (int) ActionType.装上) { MessageAlert("序号件:" + snRegDto.Sn + "最近一次操作为装上,不能再做装上操作!请检查!"); } else { var newSnHis = new SnHistoryDTO { Id = RandomHelper.Next(), ActionDate = DateTime.Now, ActionNo = SelSnRemInstRecord.ActionNo, ActionType = (int) ActionType.装上, AircraftId = SelSnRemInstRecord.AircraftId, RegNumber = SelSnRemInstRecord.RegNumber, Pn = snRegDto.Pn, Sn = snRegDto.Sn, PnRegId = snRegDto.PnRegId, SnRegId = snRegDto.Id, RemInstRecordId = SelSnRemInstRecord.Id, Status = (int) SnStatus.装机, }; var snReg = SnRegs.FirstOrDefault(sn => sn.Id == snRegDto.Id); if (snReg != null) { snReg.AircraftId = SelSnRemInstRecord.AircraftId; snReg.Status = (int) SnStatus.装机; } Installations.Add(newSnHis); SnHistories.AddNew(newSnHis); } } }); SelInstallation = Installations.FirstOrDefault(); _addChildView = false; _removeChildView = false; } RefreshCommandState(); snRegsChildView.Close(); }
private void OnNew(object obj) { if (ApuEngineSnRegWork == null) { MessageAlert("提示", "Sn不能为空"); } var snHistory = new SnHistoryDTO { Id = RandomHelper.Next(), InstallDate = DateTime.Now, SnRegId = ApuEngineSnRegWork.Id, }; //新增拆装历史 ApuEngineSnRegWork.SnHistories.Add(snHistory); }