public UnitSaveResponse Execute(UnitSaveRequest request) { UnitSaveResponse unitSaveResponse = new UnitSaveResponse(); if (request.DID == 0) { UnitInfo unitInfo = new UnitInfo(); unitInfo.UnitName = request.Name; unitInfo.UnitNO = request.NO; ServiceHelper.LoadService <IProductionService>().AddUnit(unitInfo); unitSaveResponse.UnitDID = unitInfo.UnitDID; } else { UnitInfo unit = ServiceHelper.LoadService <IProductionService>().GetUnit(request.DID); unit.UnitName = request.Name; unit.UnitNO = request.NO; ServiceHelper.LoadService <IProductionService>().UpdateUnit(unit); unitSaveResponse.UnitDID = unit.UnitDID; } return(unitSaveResponse); }
private void btnOK_Click(object sender, RoutedEventArgs e) { if (this.model == null) { return; } if (string.IsNullOrEmpty(this.model.UnitNO)) { int num1 = (int)MessageBox.Show("请输入部件编号", "提示"); } else if (string.IsNullOrEmpty(this.model.UnitName)) { int num2 = (int)MessageBox.Show("请输入部件名称", "提示"); } else { UnitSaveResponse unitSaveResponse = LocalApi.Execute(new UnitSaveRequest() { DID = this.model.UnitDID, Name = this.model.UnitName, NO = this.model.UnitNO }); this.DialogResult = new bool?(true); this.Close(); } }