RowUpdatingEventArgs.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //------------------------------------------------------------------------------
  2. // <copyright file="RowUpdatingEventArgs.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // <owner current="true" primary="true">[....]</owner>
  6. // <owner current="true" primary="false">[....]</owner>
  7. //------------------------------------------------------------------------------
  8. namespace System.Data.Common {
  9. using System;
  10. using System.Data;
  11. /*
  12. public delegate void RowUpdatingEventHandler(object sender, RowUpdatingEventArgs e);
  13. */
  14. public class RowUpdatingEventArgs : System.EventArgs {
  15. private IDbCommand _command;
  16. private StatementType _statementType;
  17. private DataTableMapping _tableMapping;
  18. private Exception _errors;
  19. private DataRow _dataRow;
  20. private UpdateStatus _status; // UpdateStatus.Continue; /*0*/
  21. public RowUpdatingEventArgs(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) {
  22. ADP.CheckArgumentNull(dataRow, "dataRow");
  23. ADP.CheckArgumentNull(tableMapping, "tableMapping");
  24. switch(statementType) {
  25. case StatementType.Select:
  26. case StatementType.Insert:
  27. case StatementType.Update:
  28. case StatementType.Delete:
  29. break;
  30. case StatementType.Batch:
  31. throw ADP.NotSupportedStatementType(statementType, "RowUpdatingEventArgs");
  32. default:
  33. throw ADP.InvalidStatementType(statementType);
  34. }
  35. _dataRow = dataRow;
  36. _command = command; // maybe null
  37. _statementType = statementType;
  38. _tableMapping = tableMapping;
  39. }
  40. //
  41. virtual protected IDbCommand BaseCommand {
  42. get {
  43. return _command;
  44. }
  45. set {
  46. _command = value;
  47. }
  48. }
  49. public IDbCommand Command {
  50. get {
  51. return BaseCommand;
  52. }
  53. set {
  54. BaseCommand = value;
  55. }
  56. }
  57. public Exception Errors {
  58. get {
  59. return _errors;
  60. }
  61. set {
  62. _errors = value;
  63. }
  64. }
  65. public DataRow Row {
  66. get {
  67. return _dataRow;
  68. }
  69. }
  70. public StatementType StatementType {
  71. get {
  72. return _statementType;
  73. }
  74. }
  75. public UpdateStatus Status {
  76. get {
  77. return _status;
  78. }
  79. set {
  80. switch(value) {
  81. case UpdateStatus.Continue:
  82. case UpdateStatus.ErrorsOccurred:
  83. case UpdateStatus.SkipCurrentRow:
  84. case UpdateStatus.SkipAllRemainingRows:
  85. _status = value;
  86. break;
  87. default:
  88. throw ADP.InvalidUpdateStatus(value);
  89. }
  90. }
  91. }
  92. public DataTableMapping TableMapping {
  93. get {
  94. return _tableMapping;
  95. }
  96. }
  97. }
  98. }