public async Task OnCommandClicked(CommandClickEventArgs <PolicyDetailAdapterModel> args) { PolicyDetailAdapterModel item = args.RowData as PolicyDetailAdapterModel; if (args.CommandColumn.ButtonOption.IconCss == ButtonIdHelper.ButtonIdEdit) { #region 點選 修改紀錄 按鈕 CurrentRecord = item.Clone(); EditRecordDialogTitle = "修改紀錄"; IsShowEditRecord = true; isNewRecordMode = false; #endregion } else if (args.CommandColumn.ButtonOption.IconCss == ButtonIdHelper.ButtonIdDelete) { #region 點選 刪除紀錄 按鈕 CurrentNeedDeleteRecord = item; #region 檢查關聯資料是否存在 var checkedResult = await CurrentService .BeforeDeleteCheckAsync(CurrentNeedDeleteRecord); await Task.Delay(100); if (checkedResult.Success == false) { MessageBox.Show("400px", "200px", "警告", ErrorMessageMappingHelper.Instance.GetErrorMessage(checkedResult.MessageId), MessageBox.HiddenAsync); await Task.Yield(); thisView.NeedRefresh(); return; } #endregion #region 刪除這筆紀錄 await Task.Yield(); var checkTask = ConfirmMessageBox.ShowAsync("400px", "200px", "警告", "確認要刪除這筆紀錄嗎?", ConfirmMessageBox.HiddenAsync); thisView.NeedRefresh(); var checkAgain = await checkTask; if (checkAgain == true) { var verifyRecordResult = await CurrentService.DeleteAsync(CurrentNeedDeleteRecord.Id); await TranscationResultHelper.CheckDatabaseResult(MessageBox, verifyRecordResult); dataGrid.RefreshGrid(); } #endregion #endregion } }