|  |  | 
 |  |  | use "maint.vd" | 
 |  |  | use "xaserver.vd" | 
 |  |  | use "xaserverarg.vd" | 
 |  |  | use "profit.vd" | 
 |  |  | use "xcell.vd" | 
 |  |  | use "vbind.vd" | 
 |  |  | use "publiccode.vd" | 
 |  |  | use "xpagecontrol.vd" | 
 |  |  | class PaymentTermEdit : public maint | 
 |  |  | #include <wobject/xstring.hpp> | 
 |  |  | #include <xcontrol/xtreeview.hpp> | 
 |  |  | #include <xcontrol/xdwgrid.hpp> | 
 |  |  | #include <xcontrol/xdwtable.hpp> | 
 |  |  | #include <wobject/xdouble.hpp> | 
 |  |  | #include <xcontrol/xlayersheet.hpp> | 
 |  |  | #include <xcontrol/xcell.hpp> | 
 |  |  |  | 
 |  |  | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" | 
 |  |  | #include "vbusiness/vframe/maint.vframe.vbusiness.hpp" | 
 |  |  | #include <xcontrol/xlayersheet.hpp> | 
 |  |  |  | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  | class  __declspec(dllexport) PaymentTermEdit : public maint | 
 |  |  | { | 
 |  |  | public: | 
 |  |  |    xdwtable dw_base; | 
 |  |  |    xdwtable   dw_p; | 
 |  |  |    xcell dw_cell; | 
 |  |  |    string sCryno; | 
 |  |  |    xstring sCryno; | 
 |  |  | public: | 
 |  |  |    PaymentTermEdit(void* implPtr, HWND hWnd) :maint(implPtr, hWnd) {} | 
 |  |  | public: | 
 |  |  |    static PaymentTermEdit* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |    { | 
 |  |  |       PaymentTermEdit* pWin = new PaymentTermEdit(implPtr, (HWND)hWnd); | 
 |  |  |       return pWin; | 
 |  |  |    } | 
 |  |  |    int OnAddrow() | 
 |  |  |    { | 
 |  |  |       dw_p = dw_base.FindDwTable("line"); | 
 |  |  |       dw_p = dw_base.FindDwTable(L"line"); | 
 |  |  |       int i; | 
 |  |  |       double dDueAmount = 0; | 
 |  |  |       double dPercnet = 100; | 
 |  |  |       for (i = 1 ; i <= dw_p.GetRowCount();i++) | 
 |  |  |       { | 
 |  |  |          dDueAmount = dw_p.GetItemDouble(i,"DueAmount"); | 
 |  |  |          dDueAmount = dw_p.GetItemDouble(i,L"DueAmount"); | 
 |  |  |          if (dDueAmount > 0) | 
 |  |  |             break; | 
 |  |  |          dPercnet = dPercnet - dw_p.GetItemDouble(i,"DuePercent"); | 
 |  |  |          dPercnet = dPercnet - dw_p.GetItemDouble(i,L"DuePercent"); | 
 |  |  |       } | 
 |  |  |       int irow = dw_p.InsertRow(0); | 
 |  |  |       dw_p.SetItemString(irow,"SeqNo",irow.toString()); | 
 |  |  |       dw_p.SetItemString(irow,L"SeqNo",xstring(irow)); | 
 |  |  |       if (dDueAmount <= 0) | 
 |  |  |          dw_p.SetItemDouble(irow,"DuePercent",dPercnet); | 
 |  |  |          dw_p.SetItemDouble(irow,L"DuePercent",dPercnet); | 
 |  |  |        | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnDeleterow() | 
 |  |  |    { | 
 |  |  |       dw_p = dw_base.FindDwTable("line"); | 
 |  |  |       dw_p = dw_base.FindDwTable(L"line"); | 
 |  |  |       int row2 = dw_p.GetRow(); | 
 |  |  |       if (row2 < 1) return 0; | 
 |  |  |       dw_p.DeleteRow(row2); | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    string OnCreateTxt() | 
 |  |  |    xstring OnCreateTxt() | 
 |  |  |    { | 
 |  |  |       //dw_1.AcceptText(); //不能加会报错 | 
 |  |  |       int irow; | 
 |  |  |       //int icnt = dw_1.GetRowCount(); | 
 |  |  |       dw_p = dw_base.FindDwTable("line"); | 
 |  |  |       dw_p = dw_base.FindDwTable(L"line"); | 
 |  |  |       int icnt = dw_p.GetRowCount(); | 
 |  |  |       if (icnt < 1) return ""; | 
 |  |  |       string sTxt; | 
 |  |  |       if (icnt < 1) return L""; | 
 |  |  |       xstring sTxt; | 
 |  |  |       //double dPercnet = 100; | 
 |  |  |       for (irow = 1;irow <= icnt ;irow ++) | 
 |  |  |       { | 
 |  |  |          string sPaymentMethod = dw_p.GetItemString(irow,"PaymentMethod"); //支付方式 | 
 |  |  |          //string sDueDays = dw_p.GetItemDisplayString(irow,"DueDays");  | 
 |  |  |          string sDueDays = dw_p.GetItemString(irow,"DueDays"); //期限 | 
 |  |  |          string sDuePercent = dw_p.GetItemString(irow,"DuePercent"); //比例 | 
 |  |  |          string sDueAmount = dw_p.GetItemString(irow,"DueAmount"); //金额 | 
 |  |  |          xstring sPaymentMethod = dw_p.GetItemString(irow,L"PaymentMethod"); //支付方式 | 
 |  |  |          //xstring sDueDays = dw_p.GetItemDisplayString(irow,L"DueDays");  | 
 |  |  |          xstring sDueDays = dw_p.GetItemString(irow,L"DueDays"); //期限 | 
 |  |  |          xstring sDuePercent = dw_p.GetItemString(irow,L"DuePercent"); //比例 | 
 |  |  |          xstring sDueAmount = dw_p.GetItemString(irow,L"DueAmount"); //金额 | 
 |  |  |           | 
 |  |  |          if (!sPaymentMethod || sPaymentMethod == "") | 
 |  |  |             sTxt = sTxt + ""; | 
 |  |  |          if (!sDueDays || sDueDays == "") | 
 |  |  |             sTxt = sTxt + ""; | 
 |  |  |          if (!sPaymentMethod || sPaymentMethod == L"") | 
 |  |  |             sTxt = sTxt + L""; | 
 |  |  |          if (!sDueDays || sDueDays == L"") | 
 |  |  |             sTxt = sTxt + L""; | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             if (sDueDays == "-1") sDueDays = " IN ADVANCE"; | 
 |  |  |             else if (sDueDays == "0") sDueDays = " AT SIGHT"; | 
 |  |  |             if (sDueDays == L"-1") sDueDays = L" IN ADVANCE"; | 
 |  |  |             else if (sDueDays == L"0") sDueDays = L" AT SIGHT"; | 
 |  |  |             else  | 
 |  |  |             { | 
 |  |  |                if (sPaymentMethod == "T/T") | 
 |  |  |                   sDueDays = " WITHIN "+sDueDays + " DAYS AFTER SHIPMENT"; | 
 |  |  |                if (sPaymentMethod == L"T/T") | 
 |  |  |                   sDueDays = L" WITHIN "+sDueDays + L" DAYS AFTER SHIPMENT"; | 
 |  |  |                else | 
 |  |  |                   sDueDays = " AT "+sDueDays + " DAYS"; | 
 |  |  |                   sDueDays = L" AT "+sDueDays + L" DAYS"; | 
 |  |  |             } | 
 |  |  |              | 
 |  |  |             if (!sDuePercent || sDuePercent == "") | 
 |  |  |             if (!sDuePercent || sDuePercent == L"") | 
 |  |  |             { | 
 |  |  |                if (!sDueAmount || sDueAmount == "") | 
 |  |  |                   sTxt = sTxt + ""; | 
 |  |  |                if (!sDueAmount || sDueAmount == L"") | 
 |  |  |                   sTxt = sTxt + L""; | 
 |  |  |                else | 
 |  |  |                { | 
 |  |  |                    | 
 |  |  |                   sTxt = sTxt + sCryno + " " + sDueAmount + " " + sPaymentMethod + sDueDays + ";"; | 
 |  |  |                   sTxt = sTxt + sCryno + L" " + sDueAmount + L" " + sPaymentMethod + sDueDays + L";"; | 
 |  |  |                } | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             { | 
 |  |  |                if (sDuePercent.find(".",0) >= 0) | 
 |  |  |                if (sDuePercent.find(L".",0) >= 0) | 
 |  |  |                { | 
 |  |  |                   while (sDuePercent.right(1) == "0") | 
 |  |  |                   while (sDuePercent.right(1) == L"0") | 
 |  |  |                   { | 
 |  |  |                      sDuePercent = sDuePercent.left(sDuePercent.length() - 1); | 
 |  |  |                   } | 
 |  |  |                   if (sDuePercent.right(1) == ".") | 
 |  |  |                   if (sDuePercent.right(1) == L".") | 
 |  |  |                      sDuePercent = sDuePercent.left(sDuePercent.length() - 1); | 
 |  |  |                } | 
 |  |  |              | 
 |  |  |                sTxt = sTxt + sDuePercent + "% " + sPaymentMethod+ sDueDays + ";"; | 
 |  |  |                sTxt = sTxt + sDuePercent + L"% " + sPaymentMethod+ sDueDays + L";"; | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |       sTxt = sTxt.mid(0,sTxt.length() - 1); | 
 |  |  |       if (sTxt != "") | 
 |  |  |          sTxt = sTxt + "."; | 
 |  |  |       if (sTxt != L"") | 
 |  |  |          sTxt = sTxt + L"."; | 
 |  |  |  | 
 |  |  |       return sTxt; | 
 |  |  |    } | 
 |  |  | 
 |  |  |    { | 
 |  |  |       dw_base.AcceptText(); | 
 |  |  |       //判断是否有必输值为空 | 
 |  |  |       dw_p = dw_base.FindDwTable("line"); | 
 |  |  |       dw_p = dw_base.FindDwTable(L"line"); | 
 |  |  |       double dPercnet = 0; | 
 |  |  |       double dAmount = 0; | 
 |  |  |       xstring sChargeAll = L""; | 
 |  |  |       if (dw_p) | 
 |  |  |       { | 
 |  |  |          int i; | 
 |  |  |          for (i=1;i <= dw_p.GetRowCount();i++) | 
 |  |  |          { | 
 |  |  |             string seqNo = dw_p.GetItemString(i,"SeqNo"); | 
 |  |  |             string sPaymentMethod = dw_p.GetItemString(i,"PaymentMethod"); | 
 |  |  |             string sDueDays = dw_p.GetItemString(i,"DueDays"); | 
 |  |  |             string sDuePercent = dw_p.GetItemString(i,"DuePercent"); | 
 |  |  |             xstring seqNo = dw_p.GetItemString(i,L"SeqNo"); | 
 |  |  |             xstring sPaymentMethod = dw_p.GetItemString(i,L"PaymentMethod"); | 
 |  |  |             xstring sDueDays = dw_p.GetItemString(i,L"DueDays"); | 
 |  |  |             xstring sDuePercent = dw_p.GetItemString(i,L"DuePercent"); | 
 |  |  |             dPercnet = dPercnet + sDuePercent.toDouble(); | 
 |  |  |             string sDueAmount = dw_p.GetItemString(i,"DueAmount"); | 
 |  |  |             xstring sDueAmount = dw_p.GetItemString(i,L"DueAmount"); | 
 |  |  |             dAmount = dAmount + sDueAmount.toDouble(); | 
 |  |  |             if (!seqNo) seqNo = ""; | 
 |  |  |             if (!sPaymentMethod) sPaymentMethod = ""; | 
 |  |  |             if (!sDueDays) sDueDays = ""; | 
 |  |  |             if (!sDuePercent) sDuePercent = ""; | 
 |  |  |             if (!sDueAmount) sDueAmount = ""; | 
 |  |  |             dw_p.SetItemString(i,"SeqNo",i.toString()); | 
 |  |  |             string sChargeAll = sPaymentMethod + sDueDays + sDuePercent + sDueAmount; | 
 |  |  |             if (sChargeAll != "") | 
 |  |  |             if (!seqNo) seqNo = L""; | 
 |  |  |             if (!sPaymentMethod) sPaymentMethod = L""; | 
 |  |  |             if (!sDueDays) sDueDays = L""; | 
 |  |  |             if (!sDuePercent) sDuePercent = L""; | 
 |  |  |             if (!sDueAmount) sDueAmount = L""; | 
 |  |  |             dw_p.SetItemString(i,L"SeqNo",xstring(i)); | 
 |  |  |             sChargeAll = sPaymentMethod + sDueDays + sDuePercent + sDueAmount; | 
 |  |  |             if (sChargeAll != L"") | 
 |  |  |             { | 
 |  |  |                if (sPaymentMethod == "") | 
 |  |  |                if (sPaymentMethod == L"") | 
 |  |  |                { | 
 |  |  |                   alert("支付方式不能为空!"); | 
 |  |  |                   alert(L"支付方式不能为空!"); | 
 |  |  |                   return 0; | 
 |  |  |                } | 
 |  |  |                if (sDueDays == "") | 
 |  |  |                if (sDueDays == L"") | 
 |  |  |                { | 
 |  |  |                   alert("期限不能为空!"); | 
 |  |  |                   alert(L"期限不能为空!"); | 
 |  |  |                   return 0; | 
 |  |  |                } | 
 |  |  |  | 
 |  |  | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |       //百分比校验 | 
 |  |  |       if (dw_p.GetRowCount() <= 1 && sChargeAll == "") | 
 |  |  |       if (dw_p.GetRowCount() <= 1 && sChargeAll == L"") | 
 |  |  |       {} | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  | 
 |  |  |          { | 
 |  |  |             if (dAmount <= 0) | 
 |  |  |             { | 
 |  |  |                alert("比率不等于100!"); | 
 |  |  |                alert(L"比率不等于100!"); | 
 |  |  |                return 0; | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |       string sTxt = OnCreateTxt(); | 
 |  |  |       dw_base.SetItemString(1,"PaymentTermEx",sTxt); | 
 |  |  |       xstring sTxt = OnCreateTxt(); | 
 |  |  |       dw_base.SetItemString(1,L"PaymentTermEx",sTxt); | 
 |  |  |  | 
 |  |  |       //CloseWindow(); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnItemChanged(ref TNotifyEvent evt,int p) | 
 |  |  |    int OnItemChanged(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR); | 
 |  |  |       string colname=hdr.colname; | 
 |  |  |       string value = hdr.data; | 
 |  |  |       DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |       xstring colname=hdr.colname; | 
 |  |  |       xstring value = hdr.data; | 
 |  |  |       int row = hdr.row; | 
 |  |  |        | 
 |  |  |       if (colname == "DueDays") | 
 |  |  |       if (colname == L"DueDays") | 
 |  |  |       { | 
 |  |  |          xdwtable dw; | 
 |  |  |          dw = dw_base.FindDwTable("line"); | 
 |  |  |          dw = dw_base.FindDwTable(L"line"); | 
 |  |  |           | 
 |  |  |          if (dw) | 
 |  |  |          { | 
 |  |  |             string sPaymentMethod = dw.GetItemString(row,"PaymentMethod"); | 
 |  |  |             if (value == "0") | 
 |  |  |             xstring sPaymentMethod = dw.GetItemString(row,L"PaymentMethod"); | 
 |  |  |             if (value == L"0") | 
 |  |  |             { | 
 |  |  |                if (sPaymentMethod == "T/T") | 
 |  |  |                if (sPaymentMethod == L"T/T") | 
 |  |  |                { | 
 |  |  |                   //alert("此支付方式期限不能为 0 (AT SIGHT)"); | 
 |  |  |                   //alert(L"此支付方式期限不能为 0 (AT SIGHT)"); | 
 |  |  |                   //return -1; | 
 |  |  |                } | 
 |  |  |             } | 
 |  |  |             else if (value == "-1") | 
 |  |  |             else if (value == L"-1") | 
 |  |  |             { | 
 |  |  |                if (sPaymentMethod != "T/T") | 
 |  |  |                if (sPaymentMethod != L"T/T") | 
 |  |  |                { | 
 |  |  |                   alert("此支付方式期限不能为 -1(IN ADVANCE)"); | 
 |  |  |                   alert(L"此支付方式期限不能为 -1(IN ADVANCE)"); | 
 |  |  |                   return -1; | 
 |  |  |                } | 
 |  |  |             } | 
 |  |  | 
 |  |  |        | 
 |  |  |       } | 
 |  |  |       //生成支付条款文本 | 
 |  |  |       if (colname == "PaymentMethod" || colname == "DueDays" || colname == "DuePercent" || colname == "DueAmount") | 
 |  |  |       if (colname == L"PaymentMethod" || colname == L"DueDays" || colname == L"DuePercent" || colname == L"DueAmount") | 
 |  |  |       { | 
 |  |  |          string sTxt = OnCreateTxt(); | 
 |  |  |          xstring sTxt = OnCreateTxt(); | 
 |  |  |  | 
 |  |  |          dw_base.SetItemString(1,"Description",sTxt); | 
 |  |  |          dw_base.SetItemString(1,L"Description",sTxt); | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnClick(ref TNotifyEvent evt,int p) | 
 |  |  |    int OnClick(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR); | 
 |  |  |       string value = hdr.data; | 
 |  |  |       string colname = hdr.colname; | 
 |  |  |       DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |       xstring value = hdr.data; | 
 |  |  |       xstring colname = hdr.colname; | 
 |  |  |       int row = hdr.row; | 
 |  |  |       xaserverarg arg=new xaserverarg; | 
 |  |  |       arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |       xaserverarg arg; | 
 |  |  | 		 | 
 |  |  |       //alert(row.toString()); | 
 |  |  |       xdwtable dw; | 
 |  |  |       dw = dw_base.FindDwTable("line"); | 
 |  |  |       dw = dw_base.FindDwTable(L"line"); | 
 |  |  |       //alert(colname); | 
 |  |  |       if (dw) | 
 |  |  |       { | 
 |  |  |          if (colname == "DuePercent") | 
 |  |  |          if (colname == L"DuePercent") | 
 |  |  |          { | 
 |  |  |             int i; | 
 |  |  |             int icnt = dw.GetRowCount(); | 
 |  |  | 
 |  |  |             double dDueAmount = 0; | 
 |  |  |             for (i = 1 ; i <= icnt ; i++) | 
 |  |  |             { | 
 |  |  |                dDueAmount = dw.GetItemDouble(i,"DueAmount"); | 
 |  |  |                dDueAmount = dw.GetItemDouble(i,L"DueAmount"); | 
 |  |  |                if (dDueAmount > 0) | 
 |  |  |                   break; | 
 |  |  |             } | 
 |  |  |             dw_cell.setNativePointer(dw_base.QueryItem("ixcell")); | 
 |  |  |             dw_cell.setNativePointer(dw_base.QueryItem(L"ixcell")); | 
 |  |  |             if (dDueAmount > 0) | 
 |  |  |             { | 
 |  |  |                dw.SetColumnProp("DuePercent","cellprotect","保护");//保护中文规格 | 
 |  |  |                dw.SetColumnProp(L"DuePercent",L"cellprotect",L"保护");//保护中文规格 | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             { | 
 |  |  |                dw.SetColumnProp("DuePercent","cellprotect","不保护");//保护中文规格 | 
 |  |  |                dw.SetColumnProp(L"DuePercent",L"cellprotect",L"不保护");//保护中文规格 | 
 |  |  |             } | 
 |  |  |                 | 
 |  |  |          } | 
 |  |  |           | 
 |  |  |          if (colname == "DueAmount") | 
 |  |  |          if (colname == L"DueAmount") | 
 |  |  |          { | 
 |  |  |             int j; | 
 |  |  |             int jcnt = dw.GetRowCount(); | 
 |  |  | 
 |  |  |             double dDuePercent = 0; | 
 |  |  |             for (j = 1 ; j <= jcnt ; j++) | 
 |  |  |             { | 
 |  |  |                dDuePercent = dw.GetItemDouble(j,"DuePercent"); | 
 |  |  |                dDuePercent = dw.GetItemDouble(j,L"DuePercent"); | 
 |  |  |                if (dDuePercent > 0) | 
 |  |  |                   break; | 
 |  |  |             } | 
 |  |  |             if (dDuePercent > 0) | 
 |  |  |             { | 
 |  |  |                dw.SetColumnProp("DueAmount","cellprotect","保护");//保护中文规格 | 
 |  |  |                dw.SetColumnProp(L"DueAmount",L"cellprotect",L"保护");//保护中文规格 | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             { | 
 |  |  |                dw.SetColumnProp("DueAmount","cellprotect","不保护");//保护中文规格 | 
 |  |  |                dw.SetColumnProp(L"DueAmount",L"cellprotect",L"不保护");//保护中文规格 | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |           | 
 |  |  | 
 |  |  |    int OnSave() | 
 |  |  |    { | 
 |  |  |       if(OnOk()<1)return 0; | 
 |  |  |       dw_base = GetControl("dw_base"); | 
 |  |  |       dw_base = GetControl(L"dw_base"); | 
 |  |  |       dw_base.AcceptText(); | 
 |  |  |       //dw_bank.AcceptText(); | 
 |  |  |       xml x = new xml; | 
 |  |  |       xaserverarg arg = new xaserverarg;		 | 
 |  |  |       x.setNativePointer(xml::CreateInstance()); | 
 |  |  |       dw_base.DwUpdateAllTo(x.GetXmlDoc());  | 
 |  |  |       //dw_bank.DwUpdateAllTo(x.GetXmlDoc());  | 
 |  |  |       //alert(x.GetXml()); | 
 |  |  |       arg.setNativePointer(arg.CreateInstance());	 | 
 |  |  |       arg.AddArg("content",x.GetXml());						 | 
 |  |  |       arg.AddArg("dbmap","FND_PaymentTerm.dbmap"); | 
 |  |  |       xml x ; | 
 |  |  |       xaserverarg arg ;		 | 
 |  |  | 		 | 
 |  |  |       dw_base.DwUpdateAllTo(x);  | 
 |  |  |       //dw_bank.DwUpdateAllTo(x);  | 
 |  |  |       //alert(x.xml()); | 
 |  |  | 			 | 
 |  |  |       arg.AddArg(L"content",x.xml());						 | 
 |  |  |       arg.AddArg(L"dbmap",L"FND_PaymentTerm.dbmap"); | 
 |  |  |       //return 0; | 
 |  |  |       if (getUrl("/sale/data/PaymentTerm/entity/company/save",arg.GetString(),x) != 1) | 
 |  |  |       if (getUrl(L"/sale/data/PaymentTerm/entity/company/save",arg.GetString(),x) != 1) | 
 |  |  |       { | 
 |  |  |          alert("保存失败!"); | 
 |  |  |          alert(L"保存失败!"); | 
 |  |  |          return 0; | 
 |  |  |       }                   | 
 |  |  |       else | 
 |  |  |       {    | 
 |  |  |          //alert(x.GetXml()); | 
 |  |  |          if(x.GetXmlDoc().selectSingleNode("error")) | 
 |  |  |          //alert(x.xml()); | 
 |  |  |          if(x.selectSingleNode(L"error")) | 
 |  |  |          { | 
 |  |  |             alert("保存出错2!"); | 
 |  |  |             alert(L"保存出错2!"); | 
 |  |  |             return 0;             | 
 |  |  |          } | 
 |  |  |          arg.AddArg("ret","Ok"); | 
 |  |  |          xwin::MessageBox(GetHWND(),"保存成功!","提示",0);	 | 
 |  |  |          //alert("保存成功"); | 
 |  |  |          arg.AddArg(L"ret",L"Ok"); | 
 |  |  |          MessageBox(GetHWND(),L"保存成功!",L"提示",0);	 | 
 |  |  |          //alert(L"保存成功"); | 
 |  |  |          dw_base.ResetUpdateStatus();    | 
 |  |  |          //dw_bank.ResetUpdateStatus();    | 
 |  |  |          //xwin::SendMessage(parenthwnd, 0x401, "maintsave", 0);//通知list窗口更新数据 | 
 |  |  |          //xwin::SendMessage(parenthwnd, 0x401, L"maintsave", 0);//通知list窗口更新数据 | 
 |  |  |       } | 
 |  |  |       //alert("保存成功"); | 
 |  |  |       //alert(L"保存成功"); | 
 |  |  |       dw_base.Redraw();    | 
 |  |  |       //dw_bank.Redraw();    | 
 |  |  |       CloseWindow(); | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |           | 
 |  |  |    int OnCmdDispatch(string comdid) | 
 |  |  |    int OnCmdDispatch(xstring comdid) | 
 |  |  |    { | 
 |  |  |       //alert(comdid); | 
 |  |  |       if(comdid=="xmOk") OnSave(); | 
 |  |  |       else if(comdid=="addrow") OnAddrow(); | 
 |  |  |       else if(comdid=="deleterow") OnDeleterow(); | 
 |  |  |       //else if(comdid=="AddRow") OnAddRow(); | 
 |  |  |       //else if(comdid=="InsertRow") OnInsertRow(); | 
 |  |  |       //else if(comdid=="DeleteRow")OnDeleteRow(); | 
 |  |  |       if(comdid==L"xmOk") OnSave(); | 
 |  |  |       else if(comdid==L"addrow") OnAddrow(); | 
 |  |  |       else if(comdid==L"deleterow") OnDeleterow(); | 
 |  |  |       //else if(comdid==L"AddRow") OnAddRow(); | 
 |  |  |       //else if(comdid==L"InsertRow") OnInsertRow(); | 
 |  |  |       //else if(comdid==L"DeleteRow")OnDeleteRow(); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    //按钮事件 | 
 |  |  |    int OnXCommand(ref TXCommandEvent evt,int p) | 
 |  |  |    int OnXCommand(TEvent* evt, LPARAM param) | 
 |  |  |    { | 
 |  |  |       return OnCmdDispatch(evt.pStrID); | 
 |  |  |       return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnAttachEvent() | 
 |  |  |    { | 
 |  |  |       //按钮事件 | 
 |  |  |       AttachEvent("WM_XCOMMAND",OnXCommand); | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", (FEvent)&PaymentTermEdit::OnXCommand); | 
 |  |  |       //获取焦点事件,用于重置工具条 | 
 |  |  |       //AttachEvent("WM_SETFOCUS",OnSetFocus); | 
 |  |  |       AttachEvent("dw_base","DWV_ITEMCHANGED",OnItemChanged); | 
 |  |  |       AttachEvent("dw_base","DWV_CLICKED",OnClick); | 
 |  |  |       //AttachEvent(L"WM_SETFOCUS",OnSetFocus); | 
 |  |  |       AttachEvent(L"dw_base",L"DWV_ITEMCHANGED", (FEvent)&PaymentTermEdit::OnItemChanged); | 
 |  |  |       AttachEvent(L"dw_base",L"DWV_CLICKED", (FEvent)&PaymentTermEdit::OnClick); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnRetrieve() | 
 |  |  |    { | 
 |  |  |       if(GetParam()) | 
 |  |  |       if(GetWinParam()) | 
 |  |  |       { | 
 |  |  |          int p = GetParam(); | 
 |  |  |          xaserverarg args = new xaserverarg; | 
 |  |  |          args.setNativePointer(p); | 
 |  |  |          string id = args.GetArgString("EntityID"); | 
 |  |  |          int p = GetArg(); | 
 |  |  |          xaserverarg args ; | 
 |  |  | 			 | 
 |  |  |          xstring id = args.GetArgString(L"EntityID"); | 
 |  |  |          //alert(id); | 
 |  |  |          if(id=="new") | 
 |  |  |          if(id==L"new") | 
 |  |  |          { | 
 |  |  |              | 
 |  |  |             //OnAddNew(); | 
 |  |  |          } | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             xml x = new xml; | 
 |  |  |             x.setNativePointer(xml::CreateInstance()); | 
 |  |  |             if(getUrl("/sale/data/PaymentTerm/entity/base12", args.GetString(), x) != 1) | 
 |  |  |             xml x ; | 
 |  |  | 				 | 
 |  |  |             if(getUrl(L"/sale/data/PaymentTerm/entity/base12", args.GetString(), x) != 1) | 
 |  |  |             { | 
 |  |  |                alert("错误"); | 
 |  |  |                alert(L"错误"); | 
 |  |  |                return -1; | 
 |  |  |             } | 
 |  |  |             //alert(x.GetXml()); | 
 |  |  |             //alert(x.xml()); | 
 |  |  |             dw_base.Retrieve(x); | 
 |  |  |             //dw_bank.Retrieve(x); | 
 |  |  |             dw_base.Redraw(); | 
 |  |  | 
 |  |  |  | 
 |  |  |    int onload() | 
 |  |  |    { | 
 |  |  |       SetArg(); | 
 |  |  |       //maint::onload(); | 
 |  |  |       //maint::onloaded(); | 
 |  |  |       dw_base = GetControl("dw_base"); | 
 |  |  |       dw_cell = new xcell; | 
 |  |  |       dw_cell.setNativePointer(dw_base.QueryItem("ixcell")); | 
 |  |  |       dw_base.openUrl("/sale/view/Payment/template/Payment/maint"); | 
 |  |  |       //alert("1233"); | 
 |  |  |       dw_base = GetControl(L"dw_base"); | 
 |  |  |       dw_base.openUrl(L"/sale/view/Payment/template/Payment/maint"); | 
 |  |  |       dw_cell = dw_base.QueryItem(L"ixcell"); | 
 |  |  |       //alert(L"1233"); | 
 |  |  |       OnRetrieve(); | 
 |  |  |       OnAttachEvent(); | 
 |  |  |       //dw_base = GetControl("dw_base"); | 
 |  |  | 		 | 
 |  |  |       //dw_base = GetControl(L"dw_base"); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |     | 
 |  |  |    int onloaded() | 
 |  |  |    {    | 
 |  |  |       //maint::onloaded(); | 
 |  |  |       //alert("response"); | 
 |  |  |       //dw_base = GetControl("dw_base"); | 
 |  |  |       //alert(L"response"); | 
 |  |  |       //dw_base = GetControl(L"dw_base"); | 
 |  |  |       //dw_cell = new xcell; | 
 |  |  |       //dw_cell.setNativePointer(dw_base.QueryItem("ixcell")); | 
 |  |  |       //dw_cell.setNativePointer(dw_base.QueryItem(L"ixcell")); | 
 |  |  |       return -1;  | 
 |  |  |    } | 
 |  |  |     |