forked from ahyahy/OneScriptForms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataRow.cs
More file actions
195 lines (169 loc) · 5.1 KB
/
DataRow.cs
File metadata and controls
195 lines (169 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
using System;
using ScriptEngine.Machine.Contexts;
using ScriptEngine.Machine;
namespace osf
{
public class DataRow
{
public ClDataRow dll_obj;
public System.Data.DataRow M_DataRow;
public DataRow(osf.DataRow p1)
{
M_DataRow = p1.M_DataRow;
OneScriptForms.AddToHashtable(M_DataRow, this);
}
public DataRow(System.Data.DataRow p1)
{
M_DataRow = p1;
OneScriptForms.AddToHashtable(M_DataRow, this);
}
public object get_Item(object index)
{
return (object)new DataItem(M_DataRow, index);
}
public int RowState
{
get { return (int)M_DataRow.RowState; }
}
public osf.DataTable Table
{
get { return ((osf.DataTableEx)M_DataRow.Table).M_Object; }
}
public void AcceptChanges()
{
M_DataRow.AcceptChanges();
}
public void BeginEdit()
{
M_DataRow.BeginEdit();
}
public void CancelEdit()
{
M_DataRow.CancelEdit();
}
public void Delete()
{
M_DataRow.Delete();
}
public void EndEdit()
{
M_DataRow.EndEdit();
}
public void RejectChanges()
{
M_DataRow.RejectChanges();
}
public void SetItem(object index, object item)
{
if (index is string)
{
M_DataRow[(string)index] = item;
}
else
{
M_DataRow[(int)index] = item;
}
System.Windows.Forms.Application.DoEvents();
}
}
[ContextClass ("КлСтрокаДанных", "ClDataRow")]
public class ClDataRow : AutoContext<ClDataRow>
{
public ClDataRow(DataRow p1)
{
DataRow DataRow1 = p1;
DataRow1.dll_obj = this;
Base_obj = DataRow1;
}
public DataRow Base_obj;
[ContextProperty("Состояние", "RowState")]
public int RowState
{
get { return (int)Base_obj.RowState; }
}
[ContextProperty("Таблица", "Table")]
public ClDataTable Table
{
get { return (ClDataTable)OneScriptForms.RevertObj(Base_obj.Table); }
}
[ContextMethod("ЗавершитьРедактирование", "EndEdit")]
public void EndEdit()
{
Base_obj.EndEdit();
}
[ContextMethod("НачатьРедактирование", "BeginEdit")]
public void BeginEdit()
{
Base_obj.BeginEdit();
}
[ContextMethod("ОтказИзменений", "RejectChanges")]
public void RejectChanges()
{
Base_obj.RejectChanges();
}
[ContextMethod("ОтменаРедактирования", "CancelEdit")]
public void CancelEdit()
{
Base_obj.CancelEdit();
}
[ContextMethod("ПринятьИзменения", "AcceptChanges")]
public void AcceptChanges()
{
Base_obj.AcceptChanges();
}
[ContextMethod("Удалить", "Delete")]
public void Delete()
{
Base_obj.Delete();
}
[ContextMethod("УстановитьЭлемент", "SetItem")]
public void SetItem(IValue p1, IValue p2)
{
dynamic p3 = p1;
if (p1.SystemType.Name == "Строка")
{
p3 = p1.AsString();
}
else if (p1.SystemType.Name == "Число")
{
p3 = Convert.ToInt32(p1.AsNumber());
}
if (p2.GetType().ToString().Contains("osf."))
{
Base_obj.SetItem(p3, OneScriptForms.RevertObj(p2));
}
else if (p2.SystemType.Name == "Строка")
{
Base_obj.SetItem(p3, p2.AsString());
}
else if (p2.SystemType.Name == "Булево")
{
Base_obj.SetItem(p3, p2.AsBoolean());
}
else if (p2.SystemType.Name == "Дата")
{
Base_obj.SetItem(p3, new System.DateTime(
p2.AsDate().Year,
p2.AsDate().Month,
p2.AsDate().Day,
p2.AsDate().Hour,
p2.AsDate().Minute,
p2.AsDate().Second
));
}
else if (p2.SystemType.Name == "Число")
{
Base_obj.SetItem(p3, p2.AsNumber());
}
}
[ContextMethod("Элемент", "Item")]
public ClDataItem Item(IValue p1)
{
if (p1.SystemType.Name == "Строка")
{
return new ClDataItem((DataItem)Base_obj.get_Item(p1.AsString()));
}
return new ClDataItem((DataItem)Base_obj.get_Item(Convert.ToInt32(p1.AsNumber())));
}
}
}