ÿþ#include <wobject/xstring.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include <wobject/xdouble.hpp> #include <xcontrol/xlayersheet.hpp> #include <xcontrol/xdatetimepick.hpp> #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) ListManageAP : public xframe { public: xstring apType; xdwgrid dw_list; xdwgrid dw_detail1; xdwgrid dw_detail2; xdwgrid dw_detail3; xdwgrid dw_detail4; xdwgrid dw_detail5; xdwgrid dw_detail6; xdwtable dw_arg; xnode m_agentNode; //Agent Condition public: ListManageAP(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static ListManageAP* CreateInstance(void* implPtr, void* hWnd) { ListManageAP* pWin = new ListManageAP(implPtr, (HWND)hWnd); return pWin; } int SetAgent() { xstring xfNodeAgentArea = L"agentarea"; xnode anode = GetAgentNode(xfNodeAgentArea); if(m_agentNode) { SetAgentNode (anode,m_agentNode); } else { KXMLDOMElement xframeElement = GetElement(); KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); if(agent) { xstring s = agent.xml(); m_agentNode = SetAgentNode (anode,s); } } return 1; } //&q¹pÀo;mYtýQpe int OnSetFocus(TEvent* evt, LPARAM param) { //͑nå]wQag SetAgent(); return 1; } xstring GetPayType() { xcombobox cbx_type = GetControl(L"cbx_type"); int h = xcombobox::GetCurSel(cbx_type.GetHWND()); if(h<0) return L""; return xcombobox::GetLBText(cbx_type.GetHWND(), h); } xstring GetEntityName(LPARAM pr) { return L"AP3"; } xstring GetEntityIDName(LPARAM /*param*/ pr) { return L"APID"; } xstring GetEntityID(LPARAM /*param*/ pr) { return dw_list.GetItemString(dw_list.GetRow(),L"APID"); } int ViewUpdate(LPARAM pr,xstring updateItem,xaserverarg arg) { if( updateItem==L"del") { int DelRow = dw_list.GetRow(); dw_list.DeleteRow(DelRow); return 1; } return 1; } int OnBank() { xaserverarg arg ; OpenWindow(L"dev:xpage[APBank.vx]",arg); if(arg.GetArgString(L"result")==L"ok") { int ll_row = dw_list.GetNextSelectRow(1); dw_list.AcceptText(); while(ll_row > 0 && ll_row <= dw_list.GetRowCount()) { dw_list.SetItemString(ll_row,L"PayedTerm",arg.GetArgString(L"PayedTerm")); dw_list.SetItemString(ll_row,L"PayedBank",arg.GetArgString(L"PayedBank")); dw_list.SetItemString(ll_row,L"PayedBankNo",arg.GetArgString(L"PayedBankNo")); ll_row = dw_list.GetNextSelectRow(ll_row + 1); } dw_list.Redraw(); return 1; } else return 1; } int OnDoubleClickedThree(TEvent* evt, LPARAM p) { return OnModifyAP(); } int OnModifyAP() { int row = dw_detail3.GetRow(); if(row < 1) return 1; //xstring APID = dw_detail3.GetItemString(row,L"APID"); //if(APID==L"") APID = dw_detail3.GetGuid(row); KXMLDOMElement ele = dw_detail3.GetRowElement(row); xstring APID = ele.selectSingleNode(L"APID").text(); ele.Release(); xaserverarg arg; arg.AddArg(L"APID",APID); arg.AddArg(L"APType",L"001"); OpenWindow(L"dev:xpage[maint.ap.vx]", arg); return 1; } int OnDoubleClickedSix(TEvent* evt, LPARAM p) { return OnModifyAPSix(); } int OnModifyAPSix() { int row = dw_detail6.GetRow(); if(row < 1) return 1; //xstring APID = dw_detail3.GetItemString(row,L"APID"); //if(APID==L"") APID = dw_detail3.GetGuid(row); KXMLDOMElement ele = dw_detail6.GetRowElement(row); xstring APID = ele.selectSingleNode(L"APID").text(); ele.Release(); xaserverarg arg; arg.AddArg(L"APID",APID); arg.AddArg(L"APType",L"000"); OpenWindow(L"dev:xpage[maint.ap.vx]", arg); return 1; } int OnPrepayCheck() { int row = dw_list.GetRow(); if(row < 1) return 1; xstring InvoiceNo = dw_list.GetItemString(row,L"InvoiceNo"); xaserverarg arg; arg.AddArg(L"InvoiceNo",InvoiceNo); OpenWindow(L"dev:xpage[PrepayInvoiceImport.vx]",arg); return 1; } //}TäNÑS^ýQpe int OnCmdDispatch(xstring comdid) { if(comdid==L"xmBank") return OnBank(); if(comdid==L"xmSave") return OnSave(); if(comdid==L"xmRefresh" || comdid==L"xmSearch")return OnRetrieveEx(apType); if(comdid==L"xmPrePayCheck") return OnPrepayCheck(); if(comdid==L"xmAddRow") { xstring payType = GetPayType(); if(payType==L"ò]ØN'>k" || payType==L"…_ØN'>k" ) OpenWindow(L"dev:xpage[APNew.warizd.vx]"); else if(payType==L"„˜ØN'>k" || payType==L"„˜ØN'>k(ò]²Q)L" ) { xaserverarg arg1; arg1.AddArg(L"APType",apType); OpenWindow(L"dev:xpage[maint.ap.vx]", arg1); } return 1; } if(comdid==L"SupplierQuery") { OpenWindow(L"dev:xpage[list.manageSupplierID.ap.vx]"); return 1; } if(comdid==L"xmSaveAs") { dw_list.SaveAs(L""); return 1; } if(comdid==L"xmModifyRow") { int row = dw_list.GetRow(); if(row < 1) return 1; KXMLDOMElement ele = dw_list.GetRowElement(row); xstring APID = ele.selectSingleNode(L"APID").text(); ele.Release(); xaserverarg arg; arg.AddArg(L"APID",APID); arg.AddArg(L"APType",apType); OpenWindow(L"dev:xpage[maint.ap.vx]", arg); return 1; } if(comdid.find(L"action:",0)>=0) { xstring payType1 = GetPayType(); if(payType1==L"ò]ØN'>k" || payType1==L"„˜ØN'>k") ProcessFlowAction(comdid,1); } if(comdid==L"xmSplite") { OnParse(); return 1; } /*if(comdid==L"xmVATNotifyImport") { OnVATNotifyImport(); return 1; }*/ if(comdid==L"xmVATNotifyCancelOne") { OnVATNotifyCancel(dw_detail4); return 1; } if(comdid==L"xmVATNotifyCancel") { DeleteVATNotifyCancel(); return 1; } if(comdid==L"xmVATInvoiceAdd" || comdid==L"xmVATInvoiceAddOne") { int row1 = dw_list.GetRow(); if(row1 < 1) return 1; KXMLDOMElement ele1 = dw_list.GetRowElement(row1); xstring InvoiceNo = ele1.selectSingleNode(L"InvoiceNo").text(); xaserverarg arg2; arg2.AddArg(L"InvoiceNo",ele1.selectSingleNode(L"InvoiceNo").text()); if(comdid==L"xmVATInvoiceAdd") { OpenWindow(L"dev:xpage[VATInvoiceNew.vx]",arg2); } else { OpenWindow(L"dev:xpage[VATInvoiceAdd.vx]",arg2); } dw_detail5Refresh(); return 1; } if(comdid==L"xmAPVATInvoice" || comdid==L"xmAPOther") { int row2 = dw_list.GetRow(); if(row2 < 1) return 1; KXMLDOMElement ele2 = dw_list.GetRowElement(row2); xaserverarg arg3; arg3.AddArg(L"InvoiceNo",ele2.selectSingleNode(L"InvoiceNo").text()); arg3.AddArg(L"SalespersonID",ele2.selectSingleNode(L"SalespersonID").text()); arg3.AddArg(L"SalespersonIDName",ele2.selectSingleNode(L"SalespersonID/@_displaystring").text()); arg3.AddArg(L"OrgName",ele2.selectSingleNode(L"OrgName").text()); arg3.AddArg(L"NotifyAmt",dw_list.GetItemString(row2,L"NotifyAmt")); //arg3.AddArg(L"NotifyAmt",ele2.selectSingleNode(L"NotifyAmt").text()); //arg3.AddArg(L"PayedAmt",ele2.selectSingleNode(L"PayedAmt").text()); if(comdid==L"xmAPVATInvoice") { OpenWindow(L"dev:xpage[APNew.vx]",arg3 ); } else { OpenWindow(L"dev:xpage[APOther.vx]",arg3); } dw_detail6Refresh(); return 1; } if(comdid==L"xmVATNotifyImport") { OnVATNotifyImport(); return 1; } if(comdid==L"xmVATNotifySave") { OnVATNotifySave(); return 1; } if (comdid ==L"allbill") { return allbill(); } if (comdid==L"allbillno") { return allbillno(); } if (comdid==L"onebill") { return onebill(); } if (comdid==L"onebillno") { return onebillno(); } if (comdid ==L"xmVATNotifyPrint") { return OnVATNotifyPrint(); } if (comdid ==L"xmVATNotifyPrintItem") { return OnVATNotifyPrintItem(); } if(comdid==L"xmPrePayCancel") { OnAPDelete(dw_detail3); return 1; } if (comdid ==L"xmAPDelete") { OnAPDelete(dw_detail6); return 1;; } if(comdid==L"xmVATInvoiceRemove") { OnVATInvoiceRemove(); return 1; } return 0; } int DeleteVATNotifyCancel() { if(dw_detail4.GetRow() < 1) return 1; int row = dw_detail4.GetRow(); xstring VATNotifyID = dw_detail4.GetGuid(row); //alert(VATNotifyID); int res = MessageBox(GetHWND(), L"/f&Tnx¤‹ Rd–ُy˜_hyåw?",L"Ðc:y",4); if(res == 6) { xml x = ViewObject::RetrieveData(L"/sale/data/VATNotify/entity/DeleteVATNotify",L"VATNotifyID",VATNotifyID); if(!x) { alert(L" Rd–•ï‹"); return 1; } //dw_list.DeleteRow(row); alert(x.text()); dw_detail4Refresh(); } return 1; } int OnVATInvoiceRemove() { if(dw_detail5.GetRow() < 1) return 1; int row = dw_detail5.GetRow(); int MB_YESNO = 0x00000004; int IDYES = 6; if(MessageBox(GetHWND(),L"/f&Tnxš[ Rd–ÿ",L"Ðc:y",MB_YESNO)!=IDYES) return 1; xml x ; xaserverarg arg ; arg.AddArg(L"EntityID",dw_detail5.GetItemString(dw_detail5.GetRow(),L"VATInvoiceID")); // trace(sguid); if (xurl::post(L"/sale/data/VATNotify/entity/deleteOne",arg.GetString(),x) != 1) { xstring error = x.text(); trace(error); } else { if(x.selectSingleNode(L"//process")) { KXMLDOMElement e1 = x.selectSingleNode(L"//process"); xstring valid = e1.getAttribute(L"valid"); xstring finished = e1.getAttribute(L"finished"); xstring errInfo =L""; if(valid==L"0") { errInfo= e1.getAttribute(L"errInfo"); alert(errInfo); } else if(finished==L"0") { errInfo= e1.getAttribute(L"errInfo"); errInfo =L"Yt1Y%!\r\n"+errInfo; alert(errInfo); } else dw_detail5.DeleteRow(row); } } //OnRetrieve(); return 1; } int OnAPDelete(xdwgrid dw_obj) { if(dw_obj.GetRow() < 1) return 1; int row = dw_obj.GetRow(); int MB_YESNO = 0x00000004; int IDYES = 6; if(MessageBox(GetHWND(),L"/f&Tnxš[ Rd–ÿ",L"Ðc:y",MB_YESNO)!=IDYES) return 1; xml x ; xaserverarg arg ; arg.AddArg(L"EntityID",dw_obj.GetItemString(dw_obj.GetRow(),L"APID")); // trace(sguid); if (xurl::post(L"/sale/data/AP/entity/delete",arg.GetString(),x) != 1) { xstring error = x.text(); trace(error); } else { if(x.selectSingleNode(L"//process")) { KXMLDOMElement e1 = x.selectSingleNode(L"//process"); xstring valid = e1.getAttribute(L"valid"); xstring finished = e1.getAttribute(L"finished"); xstring errInfo =L""; if(valid==L"0") { errInfo= e1.getAttribute(L"errInfo"); alert(errInfo); } else if(finished==L"0") { errInfo= e1.getAttribute(L"errInfo"); errInfo =L"Yt1Y%!\r\n"+errInfo; alert(errInfo); } else dw_obj.DeleteRow(row); } } //OnRetrieve(); return 1; } int OnVATNotifyPrintItem() { xaserverarg arg; arg.AddArg(L"EntityName",L"VATNotify"); arg.AddArg(L"EntityID",L"",L""); xstring InvoiceNo = dw_detail4.GetItemString(dw_detail4.GetRow(),L"NInvoiceNo"); if(InvoiceNo==L"") InvoiceNo = dw_detail4.GetItemString(dw_detail4.GetRow(),L"InvoiceNo"); xstring SupplierID = dw_detail4.GetItemString(dw_detail4.GetRow(),L"SupplierID"); arg.AddArg(L"EntityNo",InvoiceNo,L""); arg.AddArg(L"SupplierID",SupplierID); arg.AddArg(L"VATNotifyID",dw_detail4.GetGuid(dw_detail4.GetRow())); openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", arg); return 1; } int OnVATNotifyPrint() { xaserverarg arg; arg.AddArg(L"EntityName",L"VATNotify"); arg.AddArg(L"EntityID",L"",L""); xstring InvoiceNo = dw_detail4.GetItemString(dw_detail4.GetRow(),L"NInvoiceNo"); if(InvoiceNo==L"") InvoiceNo = dw_detail4.GetItemString(dw_detail4.GetRow(),L"InvoiceNo"); xstring SupplierID = dw_detail4.GetItemString(dw_detail4.GetRow(),L"SupplierID"); arg.AddArg(L"EntityNo",InvoiceNo,L""); arg.AddArg(L"SupplierID",SupplierID); arg.AddArg(L"VATNotifyID",L""); openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", arg); return 1; } int onebillno() { int ll_row = dw_detail4.GetNextSelectRow(1); if(ll_row < 1) return 1; int MB_OKCANCEL = 1; int IDOK = 1; int ret = MessageBox(GetHWND(),L"nx¤‹ NˆN_hyT?",L"Ðc:y",MB_OKCANCEL); if(ret !=IDOK) return 1; dw_detail4.AcceptText(); while(ll_row > 0 && ll_row <= dw_detail4.GetRowCount()) { xstring ls_dtlno = dw_detail4.GetItemString(ll_row,L"InvoiceNo"); dw_detail4.ItemChangeTo(ll_row,L"NAmount",dw_detail4.GetItemString(ll_row,L"")); dw_detail4.ItemChangeTo(ll_row,L"NQuantity",dw_detail4.GetItemString(ll_row,L"")); dw_detail4.SetItemString(ll_row,L"NotifyDate",L""); dw_detail4.SetItemString(ll_row,L"NClassifyID",L""); dw_detail4.SetItemString(ll_row,L"NName",L""); dw_detail4.SetItemString(ll_row,L"NInvoiceNo",L""); ll_row = dw_detail4.GetNextSelectRow(ll_row + 1); } dw_detail4.Redraw(); return 1; } int onebill() { int ll_row = dw_detail4.GetNextSelectRow(1); if(ll_row < 1) return 1; int MB_OKCANCEL = 1; int IDOK = 1; int ret = MessageBox(GetHWND(),L"nx¤‹_hyT?",L"Ðc:y",MB_OKCANCEL); if(ret !=IDOK) return 1; dw_detail4.AcceptText(); while(ll_row > 0 && ll_row <= dw_detail4.GetRowCount()) { xstring ls_dtlno = dw_detail4.GetItemString(ll_row,L"InvoiceNo"); dw_detail4.SetItemString(ll_row,L"NInvoiceNo",ls_dtlno); dw_detail4.SetItemString(ll_row,L"NQtyUnit",dw_detail4.GetItemString(ll_row,L"QtyUnitName")); dw_detail4.SetItemString(ll_row,L"NQuantity",dw_detail4.GetItemString(ll_row,L"Quantity")); //dw_item.SetItemString(ll_row,L"NAmount",dw_item.GetItemString(ll_row,L"Amount")); xstring sdate = publiccode::GetCurrentDate(); dw_detail4.SetItemString(ll_row,L"NotifyDate",sdate); dw_detail4.ItemChangeTo(ll_row,L"NAmount",dw_detail4.GetItemString(ll_row,L"Amount")); ll_row = dw_detail4.GetNextSelectRow(ll_row + 1); } dw_detail4.Redraw(); return 1; } int allbillno() { int MB_OKCANCEL = 1; int IDOK = 1; int ret = MessageBox(GetHWND(),L"hQpe N_hy?",L"Ðc:y",MB_OKCANCEL); if(ret !=IDOK) return 1; dw_detail4.AcceptText(); for(int ll_row=1; ll_row <= dw_detail4.GetRowCount(); ll_row++) { xstring ls_dtlno = dw_detail4.GetItemString(ll_row,L"InvoiceNo"); dw_detail4.ItemChangeTo(ll_row,L"NAmount",dw_detail4.GetItemString(ll_row,L"")); dw_detail4.ItemChangeTo(ll_row,L"NQuantity",dw_detail4.GetItemString(ll_row,L"")); dw_detail4.SetItemString(ll_row,L"NotifyDate",L""); dw_detail4.SetItemString(ll_row,L"NClassifyID",L""); dw_detail4.SetItemString(ll_row,L"NName",L""); dw_detail4.SetItemString(ll_row,L"NInvoiceNo",L""); } dw_detail4.Redraw(); return 1; } int allbill() { int MB_OKCANCEL = 1; int IDOK = 1; int ret =MessageBox(GetHWND(),L"hQpe_hy?",L"Ðc:y",MB_OKCANCEL); if(ret !=IDOK) return 1; dw_detail4.AcceptText(); for(int ll_row=1; ll_row <= dw_detail4.GetRowCount(); ll_row++) { xstring ls_dtlno = dw_detail4.GetItemString(ll_row,L"InvoiceNo"); dw_detail4.SetItemString(ll_row,L"NInvoiceNo",ls_dtlno); dw_detail4.SetItemString(ll_row,L"NAmount",dw_detail4.GetItemString(ll_row,L"Amount")); dw_detail4.SetItemString(ll_row,L"NQtyUnit",dw_detail4.GetItemString(ll_row,L"QtyUnitName")); dw_detail4.SetItemString(ll_row,L"NQuantity",dw_detail4.GetItemString(ll_row,L"Quantity")); xstring sdate = publiccode::GetCurrentDate(); dw_detail4.SetItemString(ll_row,L"NotifyDate",sdate); dw_detail4.ItemChangeTo(ll_row,L"NAmount",dw_detail4.GetItemString(ll_row,L"Amount")); } dw_detail4.Redraw(); return 1; } int OnVATNotifySave() { xml x ; dw_detail4.AcceptText(); dw_detail4.DwUpdateAllToEx(x); xaserverarg arg ; arg.AddArg(L"content",x.xml()); if(xurl::get(L"/sale/data/VATNotify/base/update", arg.GetString(),x)!=1) { xstring error = x.text(); //alert(error); }else { xstring str = x.documentElement().getAttribute(L"text"); if(str == L"true") { dw_detail4.ResetUpdateStatus(); alert(L"ÝOX[bŸR!"); }else { alert(L"ÝOX[1Y%!"); } //alert(str); } return 1; } int OnVATNotifyImport() { int row1 = dw_list.GetRow(); if(row1 < 1) return 1; KXMLDOMElement ele = dw_list.GetRowElement(row1); xstring InvoiceNo = ele.selectSingleNode(L"InvoiceNo").text(); xaserverarg arg; arg.AddArg(L"InvoiceNo",ele.selectSingleNode(L"InvoiceNo").text()); xml x1 ; dw_detail1.DwUpdateAllToEx(x1); arg.AddArg(L"storeOne",x1.xml()); //trace(x1.xml()); xml x2 ; dw_detail4.DwUpdateAllToEx(x2); arg.AddArg(L"vatnotify",x2.xml()); trace(x2.xml()); OpenWindow(L"dev:xpage[VATNotityListShiftToList.vx]",arg); xstring str = arg.GetArgString(L"items"); trace(str); if(str !=L"") { xml x ; x.loadXML(str); KXMLDOMNodeList items = x.selectNodes(L"data/Item"); int len = items.length(); for(int i=0;i<len;i++) { KXMLDOMNode t = items.item(i); int row = dw_detail4.InsertRow(0); dw_detail4.SetItemString(row,L"CreateDate",publiccode::GetCurrentDate()); dw_detail4.SetItemString(row,L"CreatorID",publiccode::GetUser().id); dw_detail4.SetItemDisplayString(row,L"CreatorID",publiccode::GetUser().name); if(t.selectSingleNode(L"SupplierID"))dw_detail4.SetItemString(row,L"SupplierID",t.selectSingleNode(L"SupplierID").text()); if(t.selectSingleNode(L"SupplierID/@_displaystring"))dw_detail4.SetItemDisplayString(row,L"SupplierID",t.selectSingleNode(L"SupplierID/@_displaystring").text()); if(t.selectSingleNode(L"ClassifyID"))dw_detail4.SetItemString(row,L"ClassifyID",t.selectSingleNode(L"ClassifyID").text()); if(t.selectSingleNode(L"CustName"))dw_detail4.SetItemDisplayString(row,L"ClassifyID",t.selectSingleNode(L"CustName").text()); //if(t.selectSingleNode(L"ClassifyID"))dw_detail4.SetItemString(row,L"NClassifyID",t.selectSingleNode(L"ClassifyID").text()); //if(t.selectSingleNode(L"CustName"))dw_detail4.SetItemDisplayString(row,L"NClassifyID",t.selectSingleNode(L"CustName").text()); // if(t.selectSingleNode(L"InvoiceNo"))dw_detail4.SetItemString(row,L"NInvoiceNo",t.selectSingleNode(L"InvoiceNo").text()); if(t.selectSingleNode(L"GroupNo"))dw_detail4.SetItemString(row,L"CustGroupNo",t.selectSingleNode(L"GroupNo").text()); if(t.selectSingleNode(L"InvoiceNo"))dw_detail4.SetItemString(row,L"InvoiceNo",t.selectSingleNode(L"InvoiceNo").text()); if(t.selectSingleNode(L"Quantity"))dw_detail4.SetItemString(row,L"Quantity",t.selectSingleNode(L"Quantity").text()); if(t.selectSingleNode(L"QtyUnitName"))dw_detail4.SetItemDisplayString(row,L"Quantity",(t.selectSingleNode(L"Quantity").text()) +(xstring)(t.selectSingleNode(L"QtyUnitName").text())); if(t.selectSingleNode(L"QtyUnit"))dw_detail4.SetItemString(row,L"QtyUnit",t.selectSingleNode(L"QtyUnit").text()); if(t.selectSingleNode(L"CQuantity"))dw_detail4.SetItemString(row,L"CQuantity",t.selectSingleNode(L"CQuantity").text()); //if(t.selectSingleNode(L"CQtyUnit"))dw_detail4.SetItemDisplayString(row,L"CQuantity",(t.selectSingleNode(L"CQuantity").text())+(t.selectSingleNode(L"CQtyUnit").text())); if(t.selectSingleNode(L"CQtyUnit"))dw_detail4.SetItemString(row,L"CQtyUnit",t.selectSingleNode(L"CQtyUnit").text()); if(t.selectSingleNode(L"Amount"))dw_detail4.SetItemString(row,L"Amount",t.selectSingleNode(L"Amount").text()); if(t.selectSingleNode(L"CustName"))dw_detail4.SetItemString(row,L"CName",t.selectSingleNode(L"CustName").text()); } } return 1; } int dw_detail6Refresh() { int row1 = dw_list.GetRow(); if(row1 < 1) return 1; KXMLDOMElement ele1 = dw_list.GetRowElement(row1); xstring InvoiceNo = ele1.selectSingleNode(L"InvoiceNo").text(); xml x = ViewObject::RetrieveData(L"/sale/data/AP/AdvancePaymentList",L"InvoiceNo",InvoiceNo,L"APType",L"000"); if(x) dw_detail6.Retrieve(x); else dw_detail6.Reset(); dw_detail6.Redraw(); dw_detail6.SetReadOnly(true); return 1; } int dw_detail5Refresh() { int row1 = dw_list.GetRow(); if(row1 < 1) return 1; KXMLDOMElement ele1 = dw_list.GetRowElement(row1); xstring InvoiceNo = ele1.selectSingleNode(L"InvoiceNo").text(); xml x = ViewObject::RetrieveData(L"/sale/data/AP/VatinvoiceList",L"InvoiceNo",InvoiceNo); if(x) dw_detail5.Retrieve(x); else dw_detail5.Reset(); dw_detail5.Redraw(); dw_detail5.SetReadOnly(true); return 1; } int dw_detail4Refresh() { int row1 = dw_list.GetRow(); if(row1 < 1) return 1; KXMLDOMElement ele1 = dw_list.GetRowElement(row1); xstring InvoiceNo = ele1.selectSingleNode(L"InvoiceNo").text(); xml x = ViewObject::RetrieveData(L"/sale/data/AP/VATNotityList",L"InvoiceNo",InvoiceNo); if(x) dw_detail4.Retrieve(x); else dw_detail4.Reset(); dw_detail4.Redraw(); dw_detail4.SetSelectionMode(1); return 1; } int OnVATNotifyCancel(xdwgrid dw_obj) { int row = dw_obj.GetRow(); dw_obj.DeleteRow(row); return 1; } int OnParse() { xaserverarg arg; OpenWindow(L"dev:xpage[GdnSourceSplit.vx]",arg); if(arg.GetArgString(L"process")==L"ok") { int row = dw_detail1.GetRow(); int row1 = dw_detail1.InsertRow(0); double Amount = arg.GetArgString(L"Amount").toInt(); double Quantity = arg.GetArgString(L"Quantity").toInt(); double Amount1 =dw_detail1.GetItemString(row,L"Amount").toInt(); double Quantity1 = dw_detail1.GetItemString(row,L"Quantity").toInt(); double UnitPrice =Amount/Quantity; UnitPrice = xdouble(UnitPrice).round(4); dw_detail1.SetItemDouble(row,L"Amount",Amount1 - Amount); dw_detail1.SetItemDouble(row,L"Quantity",Quantity1 - Quantity); dw_detail1.SetItemDouble(row,L"UnitPrice", xdouble(((Amount1 - Amount)/(Quantity1 - Quantity))).round(4)); dw_detail1.SetItemString(row1,L"SupplierID",dw_detail1.GetItemString(row,L"SupplierID")); dw_detail1.SetItemDisplayString(row1,L"SupplierID",dw_detail1.GetItemDisplayString(row,L"SupplierID")); dw_detail1.SetItemString(row1,L"GoodsNo",dw_detail1.GetItemString(row,L"GoodsNo")); dw_detail1.SetItemString(row1,L"CustomerItemNo",dw_detail1.GetItemString(row,L"CustomerItemNo")); dw_detail1.SetItemString(row1,L"EName",dw_detail1.GetItemString(row,L"EName")); dw_detail1.SetItemString(row1,L"CustName",dw_detail1.GetItemString(row,L"CustName")); dw_detail1.SetItemString(row1,L"CGroupNo",dw_detail1.GetItemString(row,L"CGroupNo")); dw_detail1.SetItemString(row1,L"BOMPart",dw_detail1.GetItemString(row,L"BOMPart")); dw_detail1.SetItemString(row1,L"Material",dw_detail1.GetItemString(row,L"Material")); dw_detail1.SetItemString(row1,L"PONo",dw_detail1.GetItemString(row,L"PONo")); dw_detail1.SetItemString(row1,L"InvoiceNo",dw_detail1.GetItemString(row,L"InvoiceNo")); dw_detail1.SetItemString(row1,L"Amount",arg.GetArgString(L"Amount")); dw_detail1.SetItemString(row1,L"Quantity",arg.GetArgString(L"Quantity")); dw_detail1.SetItemDouble(row1,L"UnitPrice",UnitPrice); dw_detail1.SetItemString(row1,L"HasVATInvoice",dw_detail1.GetItemString(row,L"HasVATInvoice")); dw_detail1.SetItemString(row1,L"PurcharID",dw_detail1.GetItemString(row,L"PurcharID")); dw_detail1.SetItemDisplayString(row1,L"PurcharID",dw_detail1.GetItemDisplayString(row,L"PurcharID")); dw_detail1.SetItemString(row1,L"SalespersonID",dw_detail1.GetItemString(row,L"SalespersonID")); dw_detail1.SetItemDisplayString(row1,L"SalespersonID",dw_detail1.GetItemDisplayString(row,L"SalespersonID")); dw_detail1.SetItemString(row1,L"TracerID",dw_detail1.GetItemString(row,L"TracerID")); dw_detail1.SetItemDisplayString(row1,L"TracerID",dw_detail1.GetItemDisplayString(row,L"TracerID")); dw_detail1.SetItemString(row1,L"OutQuantity",dw_detail1.GetItemString(row,L"OutQuantity")); } return 1; } int OnItemChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname=hdr.colname; xstring value = hdr.data; if (colname == L"Quantity" || colname == L"Amount") { double quantity = dw_detail1.GetItemDouble(hdr.row,L"Quantity"); double Amount = dw_detail1.GetItemDouble(hdr.row,L"Amount"); dw_detail1.SetItemDouble(hdr.row,L"UnitPrice", xdouble(Amount / quantity).round(4)); } return 1; } int OnDoubleClicked(TEvent* evt, LPARAM p) { return OnCmdDispatch(L"xmModifyRow"); } int OnCombboChanged(TEvent* evt, LPARAM lParam) { xstring id = L""; xstring name = L""; int h = xcombobox::GetCurSel(evt->command.hCtrl); if(h > -1) { xstring txt = (string)xcombobox::GetLBText(evt->command.hCtrl, h); apType =L"---"; if(txt==L"ò]ØN'>k") { dw_list.openUrl(L"/sale/view/AP/template/AP/list1"); apType=L"000"; OnRetrieveEx(apType); } else if(txt==L"…_ØN'>k") { dw_list.openUrl(L"/sale/view/AP/template/AP/list2"); OnRetrieveEx(apType); } else if(txt==L"„˜ØN'>k") { dw_list.openUrl(L"/sale/view/AP/template/AP/list3"); apType=L"001"; OnRetrieveEx(apType); } else if(txt==L"„˜ØN'>k(ò]²Q)L") { dw_list.openUrl(L"/sale/view/AP/template/AP/list3"); apType=L"001"; OnRetrieveEx1(apType); } dw_list.SetColumnState(L"APID",false); } return 1; } //}TäNYt‹NöN int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnDoubleClickedOne(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname=hdr.colname; int row = dw_detail5.GetRow(); xstring VATInvoiceID = dw_detail5.GetItemString(row, L"VATInvoiceID"); xaserverarg arg; arg.AddArg(L"VATInvoiceID ", VATInvoiceID); OpenWindow(L"dev:xpage[maint.vatinvoice.vx]", arg); return 1; } int OnAskDataItem(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; int row = hdr.row; xstring x= hdr.colname; if (x==L"userInvoiceNo") // NÉb { xstring sInvoiceNo = dw_detail4.GetItemString(row,L"NInvoiceNo"); hdr.data = sInvoiceNo.c_str(true) ; } return 1; } int OnAttachEvent() { //Ñ~š[å]wQag¹pûQ‹NöN AttachEvent(L"WM_XCOMMAND", (FEvent)&ListManageAP::OnXCommand); //·ƒÖS&q¹p‹NöN ÿ(uŽN͑nå]wQag AttachEvent(L"WM_SETFOCUS", (FEvent)&ListManageAP::OnSetFocus); AttachEvent(L"cbx_type",L"CBN_SELCHANGE", (FEvent)&ListManageAP::OnCombboChanged);//^\'`Ä~Rbclist-NR„vpeϑØSS //AttachEvent(L"dw_list",L"DWV_DOUBLECLICKED",OnDoubleClicked);//LˆÌSûQ AttachEvent(L"dw_detail5",L"DWV_DOUBLECLICKED", (FEvent)&ListManageAP::OnDoubleClickedOne);//LˆÌSûQ AttachEvent(L"dw_list",L"DWV_ROWFOCUSCHANGED", (FEvent)&ListManageAP::OnRowChanged);//Ñ~š[Lˆôf9eæ‰ÑS‹NöNOnRowChanged AttachEvent(L"dw_detail1",L"DWV_ITEMCHANGED", (FEvent)&ListManageAP::OnItemChanged); AttachEvent(L"dw_detail3",L"DWV_DOUBLECLICKED", (FEvent)&ListManageAP::OnDoubleClickedThree);//LˆÌSûQ AttachEvent(L"dw_detail4",L"DWV_ASKDATA", (FEvent)&ListManageAP::OnAskDataItem); AttachEvent(L"dw_detail6",L"DWV_DOUBLECLICKED", (FEvent)&ListManageAP::OnDoubleClickedSix);//LˆÌSûQ return 1; } int OnSave() { xml x ; dw_list.DwUpdateAllToEx(x); xaserverarg arg ; arg.AddArg(L"content",x.xml()); //trace(x.xml()); if(xurl::get(L"/sale/data/AP/update", arg.GetString(),x)!=1) { xstring error = x.text(); alert(L"err:"+error); return 1; } xstring str = x.documentElement().getAttribute(L"text"); if(str == L"true") { dw_list.ResetUpdateStatus(); alert(L"ÝOX[bŸR!"); }else { alert(L"ÝOX[1Y%!"); } return 1; } int OnRetrieveEx1(xstring APType) { xml x ; xaserverarg arg ; arg.AddArg(L"QueryTxt",xcontrol(GetControl(L"sle_search")).GetText()); arg.AddArg(L"APType",APType); arg.AddArg(L"QueryArg",GetQueryArg()); if (getUrl(L"/sale/data/AP/list9",arg.GetString(),x)!=1) { trace(x.text()); return -1; }else { dw_list.Retrieve(x); dw_list.Redraw(); dw_list.SetReadOnly(true); dw_list.SetSelectionMode(1); } return 1; } int OnRowChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; int row = hdr.row; if(row < 1) return 1; HCURSOR hCursor = xutil::SetCursorWait(); xstring GDNID = dw_list.GetItemString(row,L"GDNID"); xstring InvoiceNo = dw_list.GetItemString(row,L"InvoiceNo"); xml x = ViewObject::RetrieveData(L"/sale/data/AP/VStoreList",L"GDNID",GDNID); //alert(x.text()); if(x) dw_detail1.Retrieve(x); else dw_detail1.Reset(); dw_detail1.Redraw(); //dw_detail1.SetReadOnly(true); x = ViewObject::RetrieveData(L"/sale/data/AP/AccountPayableList",L"GDNID",GDNID); //alert(x.text()); if(x) dw_detail2.Retrieve(x); else dw_detail2.Reset(); dw_detail2.Redraw(); dw_detail2.SetReadOnly(true); x = ViewObject::RetrieveData(L"/sale/data/AP/AdvancePaymentList",L"InvoiceNo",InvoiceNo,L"APType",L"001"); //alert(x.text()); if(x) dw_detail3.Retrieve(x); else dw_detail3.Reset(); dw_detail3.Redraw(); dw_detail3.SetReadOnly(true); x = ViewObject::RetrieveData(L"/sale/data/AP/VATNotityList",L"InvoiceNo",InvoiceNo); //alert(x.text()); if(x) dw_detail4.Retrieve(x); else dw_detail4.Reset(); dw_detail4.Redraw(); dw_detail4.SetSelectionMode(1); //dw_detail4.SetReadOnly(true); x = ViewObject::RetrieveData(L"/sale/data/AP/VatinvoiceList",L"InvoiceNo",InvoiceNo); //alert(x.text()); if(x) dw_detail5.Retrieve(x); else dw_detail5.Reset(); dw_detail5.Redraw(); dw_detail5.SetReadOnly(true); x = ViewObject::RetrieveData(L"/sale/data/AP/AdvancePaymentList",L"InvoiceNo",InvoiceNo,L"APType",L"000"); //alert(x.text()); if(x) dw_detail6.Retrieve(x); else dw_detail6.Reset(); dw_detail6.Redraw(); dw_detail6.SetReadOnly(true); xutil::RestoreCursor(hCursor); return 1; } xstring GetQueryArg() { dw_arg.AcceptText(); xml x ; dw_arg.DwUpdateAllTo(x); return x.xml(); } int OnRetrieveEx(xstring APType) { xml x ; xaserverarg arg ; arg.AddArg(L"QueryTxt",xcontrol(GetControl(L"sle_search")).GetText()); arg.AddArg(L"APType",APType); arg.AddArg(L"ShipDays",L""); arg.AddArg(L"QueryArg",GetQueryArg()); trace(L"QueryTxt===L"+ xcontrol(GetControl(L"sle_search")).GetText()+L"===QueryArg"+GetQueryArg()); if (getUrl(L"/sale/data/AP/list/invoice",arg.GetString(),x)!=1) { alert(x.text()); return -1; }else { dw_list.Retrieve(x); dw_list.Redraw(); dw_list.SetReadOnly(true); //dw_list.SetSelectionMode(1); } return 1; } int onload() { dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/AP/úQãSÑShyfÆ~hˆ"); dw_list.SetColumnState(L"APID",false); dw_list.SetColumnState(L"SupplierID",false); dw_list.SetColumnState(L"GDNID",false); dw_arg = GetControl(L"dw_arg"); dw_arg.openUrl(L"/sale/view/AR/template/queryarg"); dw_arg.SetColHeaderHeight(0); dw_arg.SetRowSelectorWidth(0); dw_arg.SetHScrollState(false); dw_arg.SetVScrollState(false); dw_arg.SetItemString(1,L"DateType",L",gg"); dw_detail1 = GetControl(L"dw_detail1"); dw_detail1.openUrl(L"/sale/view/AP/'nfÆ~hˆ"); dw_detail1.SetColumnState(L"ClassifyID",false); /*for(int m=1;m<=dw_detail1.GetColumnCount();m++) { xstring col = dw_detail1.GetColumnName(m); if(col !=L"GroupNo") dw_detail1.SetColumnProp(col,L"cellprotect",L"1"); }*/ dw_detail2 = GetControl(L"dw_detail2"); dw_detail2.openUrl(L"/sale/view/AP/”^ØN>k"); dw_detail3 = GetControl(L"dw_detail3"); dw_detail3.openUrl(L"/sale/view/AP/„˜ØN>k"); dw_detail3.SetColumnState(L"APID",false); dw_detail4 = GetControl(L"dw_detail4"); dw_detail4.openUrl(L"/sale/view/VATNotify/template/VATNotify/item"); dw_detail4.SetColumnState(L"InvoiceNo",false); dw_detail4.SetColumnState(L"CName",false); dw_detail4.SetColumnState(L"VATRate",false); dw_detail4.SetColumnState(L"VATRefundRate",false); dw_detail4.SetColumnState(L"IsFinish",false); dw_detail4.SetColumnState(L"Type",false); //dw_detail4.SetColumnState(L"CQtyUnit",false); dw_detail4.SetColumnState(L"QtyUnit",false); dw_detail4.SetColumnState(L"QtyUnitName",false); dw_detail5 = GetControl(L"dw_detail5"); dw_detail5.openUrl(L"/sale/view/VATNotify/template/VATInvoice/list"); dw_detail6 = GetControl(L"dw_detail6"); dw_detail6.openUrl(L"/sale/view/AP/template/AP/list1"); OnAttachEvent(); return 1; } int onloaded() { SetAgent(); return 1; } };