xj qian
2024-06-25 46bf65da8237cb34a62bbe0d6d4b8ba2bb2dc7b1
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
#pragma once
 
#include "wobject/xcontrol.hpp"
#include "kobject/kdwgrid.hpp"
#include "wobject/xurl.hpp"
#include "wobject/xaserverarg.hpp"
 
 
using kdwgrid = Hxsoft::XFrame::XOffice::XCell::IGridReport;
class xdwgrid : public xcontrol
{
public:
    xdwgrid() :xcontrol(nullptr) {}
    xdwgrid(void * implptr):xcontrol(implptr){}
public:
    xdwgrid & operator =(const kcontrol* pcontrol)
    {
        this->setNativePointer((void *)pcontrol);
        return *this;
    }
public:
    kdwgrid* getKReport() { return (kdwgrid*)this->GetNativePtr(); }
public:
    int GetRow() { return getKReport()->GetRow_(); }
    int GetColumn() { return getKReport()->GetColumn_(); }
 
    int GetRowCount() { return getKReport()->GetRowCount_(); }
    int SetRow(int row) { return getKReport()->SetRow_(row); }
public:
    int GetColumnCount() { return getKReport()->GetColumnCount_(); }
    LPCTSTR GetColumnName(int col) { return getKReport()->GetColumnName_(col); }
    int GetColumnIndex(LPCTSTR pColumn) { return getKReport()->GetColumnIndex_(pColumn); }
public:
    xstring GetItemString(int nRow, int nColumn, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->GetItemString_(nRow, nColumn, dwBuffer);
    }
    xstring GetItemString(int nRow, LPCTSTR ColumnName, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->GetItemString_(nRow, ColumnName, dwBuffer);
    }
    bool SetItemString(int nRow, int nColumn, LPCTSTR lptStr, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->SetItemString_(nRow, nColumn, lptStr, dwBuffer);
    }
    bool SetItemString(int nRow, LPCTSTR ColumnName, LPCTSTR lptStr, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->SetItemString_(nRow, ColumnName, lptStr, dwBuffer);
    }
public:
    int SaveAs(LPCTSTR pXmlArg = NULL) //另存为
    {
        return getKReport()->SaveAs_(pXmlArg);
    }
    int SaveAs(KXMLDOMDocument& xml, LPCTSTR pFileName = NULL) //另存为
    {
        return getKReport()->SaveAs_(xml,pFileName);
    }
 
public:
    int InsertRow(int nRow) { return getKReport()->InsertRow_(nRow); }
    int DeleteRow(int nRow) { return getKReport()->DeleteRow_(nRow); }
public:
    int  GetXml(BSTR& bstr) { return getKReport()->GetXml_(bstr); }
    int  GetXml(BSTR& bstr, LPCTSTR pGuid) { return getKReport()->GetXml_(bstr, pGuid); }
    int  LoadXml(BSTR bstr) { return getKReport()->LoadXml_(bstr); }
    int Load(KXMLDOMElement  pElement) { return getKReport()->Load_(pElement); }
public:
    int SetReadOnly(bool bReadOnly = true) { return getKReport()->SetReadOnly_(bReadOnly); }
public:
    int SelectRow(int nRow, bool bSelect = true) { return getKReport()->SelectRow_(nRow, bSelect); }
    int SelectRow(int sRow, int eRow, bool bSelect = true) { return getKReport()->SelectRow_(sRow, eRow, bSelect); }
    int GetNextSelectRow(int nStartRow) { return getKReport()->GetNextSelectRow_(nStartRow); }
    bool IsRowSelected(int nRow) { return getKReport()->IsRowSelected_(nRow); }
    //int SetSelectBkColor(COLORREF color){return getKReport()->SetSelectBkColor_(color);}
    int SetSelectionMode(int nMode) { return getKReport()->SetSelectionMode_(nMode); } //0 unselection 1 singleSelection 2 multiselection 3 multiselectionex 
 
public:
    int DwUpdateTo(KXMLDOMDocument pXmlDoc) { return getKReport()->DwUpdateTo_(pXmlDoc); }
    int DwUpdateAllTo(KXMLDOMDocument pXmlDoc) { return getKReport()->DwUpdateAllTo_(pXmlDoc); }
public:
    int Retrieve(LPCTSTR pServer, LPCTSTR pDataUrl, LPCTSTR pArgStr) { return getKReport()->Retrieve_(pServer, pDataUrl, pArgStr); }//读取数据
    //int Retrieve(ITrans *pTrans,LPCTSTR pDataUrl, LPCTSTR pArgStr);//读取数据
    int Retrieve(LPCTSTR pDataUrl, LPCTSTR pArgStr) { return getKReport()->Retrieve_(pDataUrl, pArgStr); }//读取数据
 
    int Retrieve(KXMLDOMElement  pElement) { return getKReport()->Retrieve_(pElement); }//读取数据
    int Retrieve(KXMLDOMDocument& xml) { return  getKReport()->Retrieve_(xml); }//读取数据
 
public:
    int SetDataObject(LPCTSTR pServer, LPCTSTR pUrl) { return getKReport()->SetDataObject_(pServer, pUrl); }//设置模板对象
    //virtual int SetDataObject(ITrans *pTrans,LPCTSTR pUrl) ;//设置模板对象
    int SetDataObject(LPCTSTR pUrl) { return getKReport()->SetDataObject_(pUrl); }//设置模板对象
 
    int SetDataObject(KXMLDOMElement  pElement) { return getKReport()->SetDataObject_(pElement); }//设置模板对象
    int SetDataObject(KXMLDOMDocument  pDoc) { return getKReport()->SetDataObject_(pDoc); }
public:
    int ImportFile() { return getKReport()->ImportFile_(); }
    int ImportFile(LPCTSTR pStrFile, LPCTSTR pType = NULL, bool Header = false) { return getKReport()->ImportFile_(pStrFile, pType, Header); }
    int ImportString(LPCTSTR pStr, LPCTSTR pType = NULL, bool Header = false) { return getKReport()->ImportString_(pStr, pType, Header); }
 
public:
    int    Reset() { return getKReport()->Reset_(); }
    int    ResetUpdateStatus() { return getKReport()->ResetUpdateStatus_(); }
 
public:
    int event_ItemFocusChanged(int nRow, int nCol) { return getKReport()->event_ItemFocusChanged_(nRow, nCol); }
    int event_RowFocusChanged(int nRow, int nOldRow) { return getKReport()->event_RowFocusChanged_(nRow, nOldRow); }
    int event_GetFocus() { return getKReport()->event_GetFocus_(); }
    int event_LoseFocus() { return getKReport()->event_LoseFocus_(); }
    int event_ItemChanged(int nRow, int nCol, LPCTSTR pData) { return getKReport()->event_ItemChanged_(nRow, nCol, pData); }
    int event_ItemChanging(int nRow, int nCol, LPCTSTR pData) { return getKReport()->event_ItemChanging_(nRow, nCol, pData); }
public:
    int GetDwType() { return getKReport()->GetDwType_(); }
public:
    KXMLDOMElement  GetRowElement(int nRow) { return getKReport()->GetRowElement(nRow); }
public:
    int InsertCol(int nCol, LPCTSTR pCaption, LPCTSTR pColName, int nWidth, LPCTSTR pColPath = NULL, LPCTSTR pStyleClass = NULL,
        LPCTSTR pEditClass = NULL, LPCTSTR pFormatClass = NULL)
    {
        return  getKReport()->InsertCol(nCol, pCaption, pColName, nWidth, pColPath, pStyleClass, pEditClass, pFormatClass);
    }
    int RemoveCol(int nCol) { return getKReport()->RemoveCol(nCol); }
    int RemoveVCol(int nCol) { return getKReport()->RemoveVCol(nCol); }
    int RemoveCol(LPCTSTR pColName) { return getKReport()->RemoveCol(pColName); }
 
    int AddEditStyle(LPCTSTR pName, LPCTSTR pStr) { return getKReport()->AddEditStyle(pName, pStr); }
    int RemoveEditStyle(LPCTSTR pName, LPCTSTR pStr) { return getKReport()->RemoveEditStyle(pName, pStr); }
    int SetColEditStyle(LPCTSTR pColName, LPCTSTR pClassName) { return getKReport()->SetColEditStyle(pColName, pClassName); }
    int SetDDLBData(LPCTSTR pColName, LPCTSTR pData) { return getKReport()->SetDDLBData(pColName, pData); }
    LPCTSTR GetDDLBData(LPCTSTR pColName) { return getKReport()->GetDDLBData(pColName); }
public:
    bool ItemChangeTo(int nRow, int nColumn, LPCTSTR lptStr, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->ItemChangeTo(nRow, nColumn, lptStr, dwBuffer);
    }
    bool ItemChangeTo(int nRow, LPCTSTR ColumnName, LPCTSTR lptStr, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->ItemChangeTo(nRow, ColumnName, lptStr, dwBuffer);
    }
 
public:
    int CreateTree(LPCWSTR pPath, int nCol, int nImage1, int nImage2)
    {
        return getKReport()->CreateTree(pPath, nCol, nImage1, nImage2);
    }
    int GetContentRow(int nRow)
    {
        return getKReport()->GetContentRow(nRow);
    }
public:
    int DwUpdateAllToEx(KXMLDOMDocument pXmlDoc)
    {
        return getKReport()->DwUpdateAllToEx(pXmlDoc);
    }
public:
    int DwShareTo(kdwgrid* pPrimaryReport)
    {
        return getKReport()->DwShareTo(pPrimaryReport);
    }
public:
    int SetAskStyle(bool bAskStyle)
    {
        return getKReport()->SetAskStyle(bAskStyle);
    }
    int CreateTreeEx(LPCTSTR pPath, int nCol, int nImage1, int nImage2)
    {
        return getKReport()->CreateTreeEx(pPath, nCol,nImage1, nImage2);
    }
public:
    LPCTSTR GetItemDisplayString(int nRow, int nColumn, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport() -> GetItemDisplayString(nRow, nColumn, dwBuffer);
    }
    LPCTSTR GetItemDisplayString(int nRow, LPCTSTR ColumnName, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->GetItemDisplayString(nRow, ColumnName, dwBuffer);
    }
    bool SetItemDisplayString(int nRow, int nColumn, LPCTSTR lptStr, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->SetItemDisplayString(nRow, nColumn, lptStr, dwBuffer);
    }
    bool SetItemDisplayString(int nRow, LPCTSTR ColumnName, LPCTSTR lptStr, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->SetItemDisplayString(nRow, ColumnName, lptStr, dwBuffer);
    }
 
    LPCTSTR GetItemTipString(int nRow, int nColumn, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->GetItemTipString(nRow, nColumn, dwBuffer);
    }
    LPCTSTR GetItemTipString(int nRow, LPCTSTR ColumnName, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->GetItemTipString(nRow, ColumnName, dwBuffer);
    }
    bool SetItemTipString(int nRow, int nColumn, LPCTSTR lptStr, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->SetItemTipString(nRow, nColumn, lptStr, dwBuffer);
    }
    bool SetItemTipString(int nRow, LPCTSTR ColumnName, LPCTSTR lptStr, kdwgrid::DWBuffer dwBuffer = kdwgrid::dbuf_normal)
    {
        return getKReport()->SetItemTipString(nRow, ColumnName, lptStr, dwBuffer);
    }
public:
    int AllowSort(bool sort)
    {
        return getKReport()->AllowSort(sort);
    }
public:
    int FindByColumn(int startRow, int columnIndex, LPCTSTR columnValue)
    {
        return getKReport()->FindByColumn(startRow, columnIndex, columnValue);
    }
    int FindByColumn(int startRow, LPCTSTR column, LPCTSTR columnValue)
    {
        return getKReport()->FindByColumn(startRow,column,columnValue);
    }
 
    int SetReadOnlyColumn(int columnIndex, bool flag = true)
    {
        return getKReport()->SetReadOnlyColumn(columnIndex, flag);
    }
    int SetReadOnlyColumn(LPCTSTR column, bool flag = true)
    {
        return getKReport()->SetReadOnlyColumn(column, flag);
    }
 
    int SetColumnWidth(int columnIndex, int width = 1)
    {
        return getKReport()->SetColumnWidth(columnIndex, width);
    }
    int SetColumnWidth(LPCTSTR column, int width = 1)
    {
        return getKReport()->SetColumnWidth(column, width);
    }
    int GetColumnWidth(int columnIndex)
    {
        return getKReport()->GetColumnWidth(columnIndex);
    }
    int GetColumnWidth(LPCTSTR column)
    {
        return getKReport()->GetColumnWidth(column);
    }
    int SetColumnState(int columnIndex, bool state)
    {
        return getKReport()->SetColumnState(columnIndex, state);
    }
    int SetColumnState(LPCTSTR column, bool state)
    {
        return getKReport()->SetColumnState(column, state);
    }
 
    void SetDataToClip(LPCTSTR DataStr)
    {
        return getKReport()->SetDataToClip(DataStr);
    }
    int AcceptText()
    {
        return getKReport()->AcceptText();
    }
    int ShowRowTo(int row)
    {
        return getKReport()->ShowRowTo(row);
    }
    int GetShowRow()
    {
        return getKReport()->GetShowRow();
    }
    LPCTSTR GetTitleName(int col)
    {
        return getKReport()->GetTitleName(col);
    }
public:
    int SetRowSort(LPTSTR colName, bool colOrder = true)
    {
        return getKReport()->SetRowSort(colName, colOrder);
    }
    int SetClickEditFlag(bool f)
    {
        return getKReport()->SetClickEditFlag(f);
    }
    int Redraw()
    {
        return getKReport()->RedrawEx();
    }
    bool SetRowMove(int row, int movecount)
    {
        return getKReport()->SetRowMove(row, movecount);
    }
    int GetTreeRow(int row)
    {
        return getKReport()->GetTreeRow( row);
    }
    int GetTreeRowCount()
    {
        return getKReport()->GetTreeRowCount();
    }
    int TreeRowExpand(int row, bool exp)
    {
        return getKReport()->TreeRowExpand(row, exp);
    }
    int RetrieveDiff(KXMLDOMDocument& xml)//读取数据
    {
        return getKReport()->RetrieveDiff(xml);
    }
    int Filter(LPTSTR pColumn, LPTSTR pStr)
    {
        return getKReport()->Filter(pColumn, pStr);
    }
public:
    int SetHeaderText(int row, int col, LPTSTR name)
    {
        return getKReport()->SetHeaderText(row, col, name);
    }
    int MoveColumnTo(int fromcolumn, int tocolumn)
    {
        return getKReport()->MoveColumnTo(fromcolumn,  tocolumn);
    }
public:
    void SetEditUpperMode(bool upper)
    {
        return getKReport()->SetEditUpperMode(upper);
    }
    bool GetEditUpperMode()
    {
        return getKReport()->GetEditUpperMode();
    }
public:
    void ResetRepeats()
    {
        return getKReport()->ResetRepeats();
    }
    void AddRepeats(wchar_t* colName)
    {
        return getKReport()->AddRepeats(colName);
    }
public:
    LPCTSTR GetColumnProp(int nCol, LPCTSTR pItem)
    {
        return L"";
        //return getKReport()->GetColumnProp(nCol, pItem);
    }
 
    LPCTSTR GetColumnProp(LPCTSTR pColName, LPCTSTR pItem)
    {
        return L"";
        //return getKReport()->GetColumnProp(pColName, pItem);
    }
 
    int GetItemInt(int row, int col)
    {
        xstring str = GetItemString(row, col);
        return str.toInt();
    }
 
    int GetItemInt(int row, xstring col)
    {
        xstring str = GetItemString(row, col.c_str());
        return str.toInt();
    }
 
    double GetItemDouble(int row, int col)
    {
        xstring str = GetItemString(row, col);
        return str.toDouble();
    }
 
    double GetItemDouble(int row, string col)
    {
        xstring str = GetItemString(row, col);
        return str.toDouble();
    }
 
    bool SetItemInt(int row, int col, int str)
    {
        return SetItemString(row, col, xstring(str));
    }
 
    bool SetItemInt(int row, xstring col, int str)
    {
        return SetItemString(row, col.c_str(), xstring(str));
    }
 
    bool SetItemDouble(int row, int col, double str)
    {
        return SetItemString(row, col, xstring(str));
    }
 
    bool SetItemDouble(int row, xstring col, double str)
    {
        return SetItemString(row, col.c_str(), xstring(str));
    }
 
public:
    int openUrl(string aurl)
    {
        KXMLDOMDocument x;
        xurl::get(aurl, L"", x);
        return SetDataObject(x);
    }
 
    int openUrl(string ServerUrl, string aurl)
    {
        KXMLDOMDocument x;
        xurl::get(ServerUrl, aurl, L"", x);
        return SetDataObject(x);
    }
 
    int openSheet(string sheet)
    {
        KXMLDOMDocument x;
        xaserver::LoadUrl(L"", sheet, L"", x);
        SetDataObject(x);
        return 1;
    }
 
    int UnDeleteRow(int row)
    {
        KXMLDOMElement e = GetRowElement(row);
        if (e.selectSingleNode(L"@update.modify"))
            e.removeAttribute(L"update.delete");
        return 1;
    }
 
    int LookUpRow(string col, string value, int startRow = 1)
    {
        for (int i = startRow; i <= GetRowCount(); i++)
        {
            if (GetItemString(i, col) == value) return i;
        }
        return 0;
    }
 
    int IsRowModified(int row)
    {
        KXMLDOMElement e = GetRowElement(row);
        if (e.selectSingleNode(L"@update.modify")) return true;
        return false;
    }
 
    //cwd
    double GetItemSumDouble(string col)
    {
        double dItemSum = 0.0;
        int i;
        int icnt = GetRowCount();
        if (icnt < 1) return 0.0;
        for (i = 1; i <= icnt; i++)
        {
            double d = GetItemDouble(i, col);
            dItemSum = dItemSum + d;
        }
        //alert(dItemSum.toString());
        return dItemSum;
    }
 
    xstring GetGuid(int row)
    {
        KXMLDOMElement  e = GetRowElement(row);
        if (e) return e.getAttribute(L"guid");
        return L"";
    }
 
public:
 
    int DwRetrieve(string ServerUrl, string src, string argstr)
    {
        KXMLDOMDocument x;
        xaserver::ExecXQuery(ServerUrl, src, argstr, x);
        Retrieve(x);
        Redraw();
        return 1;
    }
 
    int DwRetrieve(string ServerUrl, string src, string arg0, string value0)
    {
        xaserverarg arg;
        arg.AddArg(arg0, value0);
        DwRetrieve(ServerUrl, src, arg.GetString());
        return 1;
    }
 
    int DwRetrieve(string ServerUrl, string src, string arg0, string value0, string arg1, string value1)
    {
        xaserverarg arg;
        arg.AddArg(arg0, value0);
        arg.AddArg(arg1, value1);
        DwRetrieve(ServerUrl, src, arg.GetString());
        return 1;
    }
};