LiFan
10 天以前 63eebabbfee1bc84850b36967ecac5116a28b73f
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
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <wobject/xdouble.hpp>
#include <xcontrol/xlayersheet.hpp>
 
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
#include "adt/xarray.hpp"
 
using xml = KXMLDOMDocument;
class __declspec(dllexport) CartermList : public listwin
{
public:
    //xdwgrid    dw_list;
    //xdwpages dw_pages;
    //xstring m_QueryTxt;
    //KXMLDOMDocument m_configDoc;
    //static int dw_hWnd;
 
public:
    CartermList(void* implPtr, HWND hWnd) :listwin(implPtr, hWnd) {}
public:
    static CartermList* CreateInstance(void* implPtr, void* hWnd)
    {
        CartermList* pWin = new CartermList(implPtr, (HWND)hWnd);
        return pWin;
    }
 
 
 
    xstring GetGuid() {
        return publiccode::GetGuid();
    }
    int OnAddrow()
    {
        dw_list.InsertRow(0);
        int rows = dw_list.GetRowCount();
        dw_list.SetRow(rows);
        dw_list.SetItemString(rows, L"PartyID", GetGuid());
        dw_list.SetItemString(rows, L"ContactID", GetGuid());
        dw_list.SetItemString(rows, L"PAStatus", L"1");
        dw_list.SetItemString(rows, L"PStatus", L"1");
        dw_list.SetItemString(rows, L"PCStatus", L"1");
        dw_list.SetItemString(rows, L"Type", L"7");
        return 1;
    }
    int OnInsertRow()
    {
        int row = dw_list.GetRow();
        if (row<1 || row>dw_list.GetRowCount()) return 0;
        dw_list.InsertRow(row);
        dw_list.SetItemString(row, L"PartyID", GetGuid());
        dw_list.SetItemString(row, L"ContactID", GetGuid());
        dw_list.SetItemString(row, L"PAStatus", L"1");
        dw_list.SetItemString(row, L"PStatus", L"1");
        dw_list.SetItemString(row, L"PCStatus", L"1");
        dw_list.SetItemString(row, L"Type", L"7");
        return 1;
    }
 
    int ViewUpdate(LPARAM pr, xstring updateItem, xaserverarg   arg)
    {
        if (updateItem == L"del")
        {
            int DelRow = dw_list.GetRow();
            dw_list.DeleteRow(DelRow);
 
        }
 
        return 1;
    }
 
    int OnDeleteRow()
    {
        int rows = dw_list.GetRowCount();
        
        int row2 = dw_list.GetPrevSelectRow(rows);
        while (row2 > 0) {
            dw_list.DeleteRow(row2);
            row2 = dw_list.GetPrevSelectRow(row2 - 1);
        }
        
        dw_list.SelectRow(0, false);
        return 1;
    }
 
    int OnSave()
    {
        /*xstring no = dw_list.GetItemString(1,L"CarTermNo");
        if(no==L""){
            alert(L"ÇëÊäÈë³µ¶Ó±àÂ룡");
            return -1;
        }
        xstring SName = dw_list.GetItemString(1,L"Name");
        if(SName==L""){
            alert(L"ÇëÊäÈë³µ¶ÓÃû³Æ£¡");
            return -1;
        }
        xstring ContacterName = dw_list.GetItemString(1,L"ContacterName");
        if(ContacterName==L""){
            alert(L"ÇëÊäÈëÁªÏµÈËÃû³Æ£¡");
            return -1;
        }    */
        xml x;
 
        dw_list.AcceptText();
        dw_list.DwUpdateAllToEx(x);
        trace(x.xml());
        xaserverarg arg;
 
        arg.AddArg(L"content", x.xml());
        arg.AddArg(L"dbmap", L"CarTerm.dbmap");
        if (xurl::get(L"/sale/data/CarTerm/entity/carterm/save", arg.GetString(), x) != 1)
        {
            trace(L"error:" + (xstring)x.xml());
            alert(L"±£´æÊ§°Ü!");
            return 0;
        }
        else
        {
            trace(x.xml());
            if (x.selectSingleNode(L"error"))
            {
                alert(L"±£´æ³ö´í2!");
                return 0;
            }
            alert(L"±£´æ³É¹¦£¡");
            dw_list.ResetUpdateStatus();
        }
        dw_list.Redraw();
        return 0;
    }
    int OnCmdDispatch(xstring comdid)
    {
        if (comdid.find(L"action:bill.row.add", 0) >= 0) {
            OnAddrow();
        }
        else if (comdid.find(L"bill.row.insert", 0) >= 0) {
            OnInsertRow();
        }
        else if (comdid.find(L"bill.row.delete", 0) >= 0) {
            OnDeleteRow();
        }
        else if (comdid.find(L"bill.save", 0) >= 0) {
            //trace(1);
            OnSave();
        }
        return 0;
    }
 
    int OnXCommand(TEvent* evt, LPARAM param)
    {
        return OnCmdDispatch(evt->xcommand.pStrID);
    }
 
    int OnAttachEvent()
    {
        AttachEvent(L"WM_XCOMMAND", (FEvent)&CartermList::OnXCommand);
        return 1;
    }
 
    int onload()
    {
        SetAgent();
        OnAttachEvent();
        listwin::onload();
        dw_list.SetReadOnly(false);
        return -1;
    }
 
};