private void UpdateDataGridResult(IDbCommand command) { dataGridResult.CancelEdit(); DateTime start = DateTime.Now; try { IDataReader reader = null; try { reader = command.ExecuteReader(); DataGridControllerResult.Load(reader, Target); } catch (Exception t) { Db2SourceContext ctx = Target.Context; ctx.OnLog(ctx.GetExceptionMessage(t), LogStatus.Error, command.CommandText); return; } } finally { DateTime end = DateTime.Now; TimeSpan time = end - start; string s = string.Format("{0}:{1:00}:{2:00}.{3:000}", (int)time.TotalHours, time.Minutes, time.Seconds, time.Milliseconds); textBlockGridResult.Text = string.Format("{0}件見つかりました。 所要時間 {1}", DataGridControllerResult.Rows.Count, s); } }
private void UpdateDataGridResult(IDbCommand command) { DateTime start = DateTime.Now; try { try { using (IDataReader reader = command.ExecuteReader()) { DataGridControllerResult.Load(reader); } } catch (Exception t) { MessageBox.Show(Target.Context.GetExceptionMessage(t), "エラー", MessageBoxButton.OK, MessageBoxImage.Error); return; } } finally { DateTime end = DateTime.Now; TimeSpan time = end - start; string s = string.Format("{0}:{1:00}:{2:00}.{3:000}", (int)time.TotalHours, time.Minutes, time.Seconds, time.Milliseconds); textBlockGridResult.Text = string.Format("{0}件見つかりました。 所要時間 {1}", DataGridControllerResult.Rows.Count, s); } }
private void UpdateDataGridResult(IDbCommand command) { DateTime start = DateTime.Now; try { IDbTransaction txn = command.Connection.BeginTransaction(); try { command.Transaction = txn; using (IDataReader reader = command.ExecuteReader()) { IEnumerable l = dataGridParameters.ItemsSource; dataGridParameters.ItemsSource = null; dataGridParameters.ItemsSource = l; DataGridControllerResult.Load(reader); if (0 <= reader.RecordsAffected) { AddLog(string.Format("{0}行反映しました。", reader.RecordsAffected), null, LogStatus.Normal, true); } else { tabControlResult.SelectedItem = tabItemDataGrid; } } txn.Commit(); } catch { txn.Rollback(); throw; } finally { command.Transaction = null; txn.Dispose(); } } catch (Exception t) { Db2SourceContext ctx = Target.Context; string msg = ctx.GetExceptionMessage(t); AddLog(msg, command.CommandText, LogStatus.Error, true); //MessageBox.Show(msg, "エラー", MessageBoxButton.OK, MessageBoxImage.Error); return; } finally { DateTime end = DateTime.Now; TimeSpan time = end - start; string s = string.Format("{0}:{1:00}:{2:00}.{3:000}", (int)time.TotalHours, time.Minutes, time.Seconds, time.Milliseconds); AddLog(string.Format("実行しました (所要時間 {0})", s), command.CommandText, LogStatus.Aux, false); textBlockGridResult.Text = string.Format("{0}件見つかりました。 所要時間 {1}", DataGridControllerResult.Rows.Count, s); } }