RowUpdatedEventArgs.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //------------------------------------------------------------------------------
  2. // <copyright file="RowUpdatedEventArgs.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // <owner current="true" primary="true">Microsoft</owner>
  6. // <owner current="true" primary="false">Microsoft</owner>
  7. //------------------------------------------------------------------------------
  8. namespace System.Data.Common {
  9. using System;
  10. using System.ComponentModel;
  11. using System.Collections;
  12. using System.Data;
  13. /*
  14. public delegate void RowUpdatedEventHandler(object sender, RowUpdatedEventArgs e);
  15. */
  16. public class RowUpdatedEventArgs : System.EventArgs {
  17. private IDbCommand _command;
  18. private StatementType _statementType;
  19. private DataTableMapping _tableMapping;
  20. private Exception _errors;
  21. private DataRow _dataRow;
  22. private DataRow[] _dataRows;
  23. private UpdateStatus _status; // UpdateStatus.Continue; /*0*/
  24. private int _recordsAffected;
  25. public RowUpdatedEventArgs(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) {
  26. switch(statementType) {
  27. case StatementType.Select:
  28. case StatementType.Insert:
  29. case StatementType.Update:
  30. case StatementType.Delete:
  31. case StatementType.Batch:
  32. break;
  33. default:
  34. throw ADP.InvalidStatementType(statementType);
  35. }
  36. _dataRow = dataRow;
  37. _command = command;
  38. _statementType = statementType;
  39. _tableMapping = tableMapping;
  40. }
  41. public IDbCommand Command {
  42. get {
  43. return _command;
  44. }
  45. }
  46. public Exception Errors {
  47. get {
  48. return _errors;
  49. }
  50. set {
  51. _errors = value;
  52. }
  53. }
  54. public int RecordsAffected {
  55. get {
  56. return _recordsAffected;
  57. }
  58. }
  59. public DataRow Row {
  60. get {
  61. return _dataRow;
  62. }
  63. }
  64. internal DataRow[] Rows {
  65. get {
  66. return _dataRows;
  67. }
  68. }
  69. public int RowCount {
  70. get {
  71. DataRow[] dataRows = _dataRows;
  72. return ((null != dataRows) ? dataRows.Length : ((null != _dataRow) ? 1 : 0));
  73. }
  74. }
  75. public StatementType StatementType {
  76. get {
  77. return _statementType;
  78. }
  79. }
  80. public UpdateStatus Status {
  81. get {
  82. return _status;
  83. }
  84. set {
  85. switch(value) {
  86. case UpdateStatus.Continue:
  87. case UpdateStatus.ErrorsOccurred:
  88. case UpdateStatus.SkipCurrentRow:
  89. case UpdateStatus.SkipAllRemainingRows:
  90. _status = value;
  91. break;
  92. default:
  93. throw ADP.InvalidUpdateStatus(value);
  94. }
  95. }
  96. }
  97. public DataTableMapping TableMapping {
  98. get {
  99. return _tableMapping;
  100. }
  101. }
  102. internal void AdapterInit(DataRow[] dataRows) {
  103. _statementType = StatementType.Batch;
  104. _dataRows = dataRows;
  105. if ((null != dataRows) && (1 == dataRows.Length)) { // WebData 100063
  106. _dataRow = dataRows[0];
  107. }
  108. }
  109. internal void AdapterInit(int recordsAffected) {
  110. _recordsAffected = recordsAffected;
  111. }
  112. public void CopyToRows(DataRow[] array) {
  113. CopyToRows(array, 0);
  114. }
  115. public void CopyToRows(DataRow[] array, int arrayIndex) {
  116. DataRow[] dataRows = _dataRows;
  117. if (null != dataRows) {
  118. dataRows.CopyTo(array, arrayIndex);
  119. }
  120. else {
  121. if (null == array) {
  122. throw ADP.ArgumentNull("array");
  123. }
  124. array[arrayIndex] = Row;
  125. }
  126. }
  127. }
  128. }