Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Data / System / Data / Common / RowUpdatingEventArgs.cs
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
9 namespace System.Data.Common {
10
11     using System;
12     using System.Data;
13
14 /*
15     public delegate void RowUpdatingEventHandler(object sender, RowUpdatingEventArgs e);
16 */
17
18     public class RowUpdatingEventArgs : System.EventArgs {
19         private IDbCommand _command;
20         private StatementType _statementType;
21         private DataTableMapping _tableMapping;
22         private Exception _errors;
23
24         private DataRow _dataRow;
25         private UpdateStatus _status; // UpdateStatus.Continue; /*0*/
26
27         public RowUpdatingEventArgs(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) {
28             ADP.CheckArgumentNull(dataRow, "dataRow");
29             ADP.CheckArgumentNull(tableMapping, "tableMapping");
30             switch(statementType) {
31             case StatementType.Select:
32             case StatementType.Insert:
33             case StatementType.Update:
34             case StatementType.Delete:
35                 break;
36             case StatementType.Batch:
37                 throw ADP.NotSupportedStatementType(statementType, "RowUpdatingEventArgs");                
38             default:
39                 throw ADP.InvalidStatementType(statementType);
40             }
41             _dataRow = dataRow;
42             _command = command; // maybe null
43             _statementType = statementType;
44             _tableMapping = tableMapping; 
45         }
46
47         // 
48         virtual protected IDbCommand BaseCommand {
49             get {
50                 return _command;
51             }
52             set {
53                 _command = value;
54             }
55         }
56
57         public IDbCommand Command {
58             get {
59                 return BaseCommand;
60             }
61             set {
62                 BaseCommand = value;
63             }
64         }
65
66         public Exception Errors {
67             get {
68                 return _errors;
69             }
70             set {
71                 _errors = value;
72             }
73         }
74
75         public DataRow Row {
76             get {
77                 return _dataRow;
78             }
79         }
80         
81         public StatementType StatementType {
82             get {
83                 return _statementType;
84             }
85         }
86
87         public UpdateStatus Status {
88             get {
89                 return _status;
90             }
91             set {
92                 switch(value) {
93                 case UpdateStatus.Continue:
94                 case UpdateStatus.ErrorsOccurred:
95                 case UpdateStatus.SkipCurrentRow:
96                 case UpdateStatus.SkipAllRemainingRows:
97                     _status = value;
98                     break;
99                 default:
100                     throw ADP.InvalidUpdateStatus(value);
101                 }
102             }
103         }
104
105         public DataTableMapping TableMapping {
106             get {
107                 return _tableMapping;
108             }
109         }
110     }
111 }