| | |
| | | #include "viewobject/view.base.hpp" |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | class __declspec(dllexport) listSupplierv3 : public listwin |
| | | { |
| | | public: |
| | | xdwgrid dw_goods; |
| | | xtreeview tv_1; |
| | | xcombobox ddlb_1; |
| | | int changeddlb; |
| | | xstring TypeWork; |
| | | xstring GoodsUrl; |
| | | xstring m_sType; //type |
| | | xstring m_sTypeTxt; //选中树的data |
| | | // xstring m_searchtxt; |
| | | int PIndex; |
| | | xnode m_agentNode; //Agent Condition |
| | | xstring m_agentCond; //Agent Node |
| | | |
| | | public: |
| | | listSupplierv3(void* implPtr, HWND hWnd) :listwin(implPtr, hWnd) {} |
| | | public: |
| | | static listSupplierv3* CreateInstance(void* implPtr, void* hWnd) |
| | | class __declspec(dllexport) simplemaintvatnotifyWin : public xframe |
| | | { |
| | | listSupplierv3* pWin = new listSupplierv3(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | int OnRetrieve() |
| | | { |
| | | xml x; |
| | | public: |
| | | xdwtable dw_profit; |
| | | xdwgrid dw_item; |
| | | xdwgrid dw_fob; |
| | | xstring InvNo; |
| | | xstring CurInvNo; |
| | | xnode m_agentNode; //Agent Condition |
| | | |
| | | xaserverarg arg; |
| | | arg.AddArg(L"pageindex", xstring(PIndex)); //第几页 |
| | | arg.AddArg(L"pagenumber", xstring(listwin::m_pageNumber)); //每页数量 |
| | | arg.AddArg(L"QueryTxt", listwin::m_QueryTxt); |
| | | arg.AddArg(L"sType", m_sType); |
| | | arg.AddArg(L"sTypeTxt", m_sTypeTxt); |
| | | trace(arg.GetString()); |
| | | //alert(L"xxxx"); |
| | | if (getUrl(GetServerUrl(), L"/sale/data/" + GetEntityName(1) + L"/entity/list", arg.GetString(), x) != 1) |
| | | public: |
| | | simplemaintvatnotifyWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static simplemaintvatnotifyWin* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | return -1; |
| | | simplemaintvatnotifyWin* pWin = new simplemaintvatnotifyWin(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | else |
| | | int SetAgent() |
| | | { |
| | | KXMLDOMElement e = x.documentElement(); |
| | | if (listwin::dw_pages && e.selectSingleNode(L"@TotalPage")) |
| | | xstring xfNodeAgentArea = L"agentarea"; |
| | | xnode anode = GetAgentNode(xfNodeAgentArea); |
| | | if (m_agentNode) |
| | | { |
| | | xstring s = e.selectSingleNode(L"@TotalPage").text(); //总数量 |
| | | listwin::dw_pages.SetMaxPage(s.toInt()); |
| | | SetAgentNode(anode, m_agentNode); |
| | | } |
| | | //alert(x.GetXml()); |
| | | dw_list.Retrieve(x); |
| | | dw_list.Redraw(); |
| | | dw_list.SetReadOnly(true); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int SetEntityData(xaserverarg arg) |
| | | { |
| | | xstring strQueryTxt = arg.GetArgString(L"QueryTxt"); |
| | | xml x; |
| | | |
| | | arg.AddArg(L"sType", m_sType); |
| | | arg.AddArg(L"sTypeTxt", m_sTypeTxt); |
| | | trace(arg.GetString()); |
| | | if (getUrl(GetServerUrl(), L"/sale/data/" + GetEntityName(1) + L"/entity/list", arg.GetString(), x) != 1) |
| | | { |
| | | alert(x.text()); |
| | | |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | KXMLDOMElement e = x.documentElement(); |
| | | if (listwin::dw_pages && e.selectSingleNode(L"@TotalPage")) |
| | | else |
| | | { |
| | | |
| | | xstring s = e.selectSingleNode(L"@TotalPage").text(); //总数量 |
| | | listwin::dw_pages.SetMaxPage(s.toInt()); |
| | | } |
| | | //trace(x.GetXml()); |
| | | listwin::dw_list.Retrieve(x); |
| | | listwin::dw_list.Redraw(); |
| | | listwin::dw_list.SetReadOnly(true); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnChangePages(TEvent* evt, LPARAM p) |
| | | { |
| | | PAGENMHDR* h = (PAGENMHDR*)evt->notify.pnmh; |
| | | int c = h->cur; |
| | | |
| | | |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | OnRetrieve(); |
| | | PIndex = c; |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | |
| | | |
| | | } |
| | | |
| | | int ViewUpdate(int pr, xstring updateItem, xaserverarg arg) |
| | | { |
| | | if (updateItem == L"refresh") |
| | | { |
| | | //trace(L"sd"); |
| | | xdwpages zz = GetControl(L"pages"); |
| | | int h = zz.SetCurPage(1); |
| | | //trace(h); |
| | | OnRetrieve(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //树选择 |
| | | int OnTreeSelChanged(TEvent evt, LPARAM p) |
| | | { |
| | | if (changeddlb != 1) |
| | | { |
| | | //alert(L"1"); |
| | | |
| | | HTREEITEM h = tv_1.GetSelectedItem(); |
| | | KXMLDOMElement& e = *(KXMLDOMElement*)tv_1.GetItemData(h); |
| | | |
| | | xstring t = e.selectSingleNode(L"@type").text(); |
| | | m_sType = t + L""; |
| | | xstring txt = e.selectSingleNode(L"@code").text(); |
| | | if (txt == L"") |
| | | txt = e.selectSingleNode(L"@name").text(); |
| | | m_sTypeTxt = txt + L""; |
| | | |
| | | //alert(m_sTypeTxt); |
| | | |
| | | PIndex = 1; |
| | | OnRetrieve(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int createSubTree(HTREEITEM h, KXMLDOMElement ele) |
| | | { |
| | | KXMLDOMNodeList nlist = ele.selectNodes(L"item"); |
| | | int i; |
| | | int s = nlist.length(); |
| | | if (s > 0) |
| | | for (i = 0; i < s; i++) |
| | | { |
| | | |
| | | KXMLDOMElement* e = new KXMLDOMElement(nlist.item(i)); |
| | | xstring name = e->selectSingleNode(L"@name").text(); |
| | | HTREEITEM hw = tv_1.InsertChildItem(h, name, (LPARAM)e, 15); |
| | | createSubTree(hw, *e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnCreateTree(xstring sType) |
| | | { |
| | | |
| | | while (tv_1.GetRootItem()) |
| | | tv_1.DeleteItem(tv_1.GetRootItem()); |
| | | |
| | | xml x; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"sType", sType); |
| | | //Tree.pref.supplier.xq |
| | | //getUrl(GetEntityName(1)+L"/entity/list",arg.GetString(),x); |
| | | //if (xaserver::ExecXQuery(GetServerUrl(),L"[Tree.pref.supplier.xq]",arg.GetString(),x)!=1) |
| | | if (getUrl(GetServerUrl(), L"/sale/data/" + GetEntityName(1) + L"/pref/list/tree", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"root/item"); |
| | | int len = nlist.length(); |
| | | if (len > 0) |
| | | { |
| | | int i; |
| | | for (i = 0; i < len; i++) |
| | | KXMLDOMElement xframeElement = GetElement(); |
| | | KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*"); |
| | | if (agent) |
| | | { |
| | | |
| | | KXMLDOMElement* e = new KXMLDOMElement(nlist.item(i)); |
| | | xstring name = e->selectSingleNode(L"@name").text(); |
| | | HTREEITEM hw = tv_1.InsertChildItem(0, name, (LPARAM)e, 15); |
| | | |
| | | createSubTree(hw, *e); |
| | | tv_1.ExpandItem(hw); |
| | | xstring s = agent.xml(); |
| | | m_agentNode = SetAgentNode(anode, s); |
| | | } |
| | | tv_1.ExpandItem(0); |
| | | } |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | //xcombobox下拉 |
| | | int OnSelectDdlb(TEvent evt, LPARAM p) |
| | | { |
| | | changeddlb = 1; |
| | | |
| | | int CB_GETCURSEL = 0x0147; |
| | | int nIndex = SendMessageW(ddlb_1.GetHWND(), CB_GETCURSEL, 0, 0); |
| | | KXMLDOMElement e = ddlb_1.GetElement();//GetitemData(wid,nIndex);//ddlb_1.GetElement(); |
| | | KXMLDOMElement e2 = e.selectSingleNode(L"item[" + xstring((nIndex + 1)) + L"]"); |
| | | xstring text = e2.selectSingleNode(L"@element").text(); |
| | | OnCreateTree(text); |
| | | changeddlb = 0; |
| | | return 1; |
| | | } |
| | | |
| | | int OnDeleteRow() |
| | | { |
| | | int row = listwin::dw_list.GetNextSelectRow(1); |
| | | if (row < 1) { |
| | | row = listwin::dw_list.GetRow(); |
| | | if (row < 1) { |
| | | //win::MessageBox(GetHWND(),L"请选中要删除的行!",L"提示",0); |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | KXMLDOMElement e = listwin::dw_list.GetRowElement(row); |
| | | //xstring sguid = e.SelectSingleNode(L"@guid").text; |
| | | //xstring sName = e.selectSingleNode(L"Name").text+L""; |
| | | xstring sguid = dw_list.GetItemString(dw_list.GetRow(), L"SupplierID"); |
| | | xstring sName = dw_list.GetItemString(dw_list.GetRow(), L"Name"); |
| | | int MB_YESNO = 0x00000004; |
| | | int IDYES = 6; |
| | | if (MessageBoxW(GetHWND(), L"确认要删除供应商 " + sName + L" 的信息吗?", L"提示", MB_YESNO) != IDYES) return 1; |
| | | xml x; |
| | | |
| | | xaserverarg arg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg(L"guid", sguid); |
| | | arg.AddArg(L"EntityID", sguid); |
| | | // trace(sguid); |
| | | if (xurl::post(GetServerUrl(), L"/sale/data/" + GetEntityName(1) + L"/entity/delete", arg.GetString(), x) != 1) |
| | | { |
| | | xstring error = x.text(); |
| | | trace(error); |
| | | } |
| | | else |
| | | { |
| | | KXMLDOMElement msg = x.selectNodes(L"process").item(0); |
| | | xstring success = msg.selectSingleNode(L"@finished").text(); |
| | | if (success == L"0") |
| | | { |
| | | alert(msg.selectSingleNode(L"@errInfo").text()); |
| | | } |
| | | else |
| | | { |
| | | MessageBoxW(GetHWND(), L"删除成功!", L"提示", 0); |
| | | listwin::dw_list.DeleteRow(row); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnRowChangedEx(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | //if(row < 1 or row > dw_list.GetRowCount()) return 1; |
| | | KXMLDOMElement ele = listwin::dw_list.GetRowElement(row); |
| | | xstring entity = ele.selectSingleNode(L"SupplierID").text(); |
| | | xml x; |
| | | |
| | | xaserverarg arg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg(L"EntityID", entity); |
| | | |
| | | |
| | | xstring no1 = publiccode::GetUser().no; |
| | | if (no1 != L"00201") |
| | | { |
| | | |
| | | if (TypeWork.find(L"采购") >= 0) |
| | | { |
| | | GoodsUrl = L"/sale/data/SupplierV3/entity/supplieritemEx"; |
| | | } |
| | | else |
| | | { |
| | | GoodsUrl = L"/sale/data/SupplierV3/entity/supplieritem"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | GoodsUrl = L"/sale/data/SupplierV3/entity/supplieritem"; |
| | | } |
| | | if (getUrl(GetServerUrl(), GoodsUrl, arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_goods.Retrieve(x); |
| | | dw_goods.Redraw(); |
| | | dw_goods.SetReadOnly(true); |
| | | } |
| | | SetAgent(L"list", entity); |
| | | return 1; |
| | | } |
| | | |
| | | int GridSearch() |
| | | { |
| | | //alert(L"你好"); |
| | | #if 0 |
| | | |
| | | xstring m_config = L"view.Supplier.v3.config"; |
| | | xdwgrid dw = listwin::dw_list; |
| | | xaserverarg& arg = *new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | xstring str = TFile::node(m_config, L"config", L"search"); |
| | | if (str != L"") { |
| | | arg.AddArg(L"sheet", str); |
| | | } |
| | | else |
| | | arg.AddArg(L"sheet", L"dev:sheet[Supplier.v3.tpl/list]"); |
| | | arg.AddArg(L"search", listwin::m_QueryTxt); |
| | | openUrl(L"view.dlg.vface/xpage/grid/column/search", &arg); |
| | | xstring ok = arg.GetArgString(L"return"); |
| | | if (ok == L"ok") { |
| | | xstring txt = arg.GetArgString(L"search"); |
| | | if (txt != L"") { |
| | | listwin::m_QueryTxt = txt; |
| | | //trace(txt); |
| | | OnRetrieve(); |
| | | } |
| | | } |
| | | #endif |
| | | return 0; |
| | | } |
| | | |
| | | int OnSelectAllRow() |
| | | { |
| | | int rows = listwin::dw_list.GetRowCount(); |
| | | if (rows < 1) return -1; |
| | | listwin::dw_list.SelectRow(1, rows, true); |
| | | listwin::dw_list.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnRClick(TEvent evt, LPARAM p) |
| | | { |
| | | return 1; |
| | | } |
| | | int OnLogOff() |
| | | { |
| | | return 1; |
| | | } |
| | | int OnChecked() |
| | | { |
| | | xstring partyno = dw_list.GetItemString(dw_list.GetRow(), L"PartyNo"); |
| | | if (partyno.find(L"N") < 0) |
| | | { |
| | | alert(L"已经是正式供应商"); |
| | | return 0; |
| | | } |
| | | xstring entityid = GetEntityID(dw_list.GetRow()); |
| | | int MB_OKCANCEL = 1; |
| | | int IDOK = 1; |
| | | int ret = MessageBoxW(GetHWND(), L"是否转成正式供应商?", L"提示", MB_OKCANCEL); |
| | | if (ret == IDOK) |
| | | { |
| | | xml x = ViewObject::RetrieveData(GetServerUrl(), L"/sale/data/SupplierV3/entity/updateno", L"entityid", entityid); |
| | | |
| | | if (xstring(x.xml()).find(L"success") > 0) |
| | | { |
| | | alert(L"处理成功"); |
| | | OnRetrieve(); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | int PreOnCmdDispatch(xstring comdid) |
| | | { |
| | | //alert(comdid); |
| | | |
| | | if (comdid.find(L"action:LogOff", 0) >= 0) return OnLogOff(); |
| | | if (comdid.find(L"action:bill.delete", 0) >= 0) |
| | | { |
| | | OnDeleteRow(); |
| | | return 0; |
| | | } |
| | | if (comdid == L"action:search1") return GridSearch(); |
| | | if (comdid == L"action:bill.refresh") |
| | | { |
| | | return OnRetrieve(); |
| | | } |
| | | if (comdid == L"action:bill.xmSaveAs") |
| | | { |
| | | xstring userno = publiccode::GetUser().no; |
| | | if (userno == L"00701" || userno == L"00601" || userno == L"admin") |
| | | { |
| | | dw_list.SaveAs(L""); |
| | | } |
| | | return 1; |
| | | } |
| | | if (comdid == L"action:bill.Annex") |
| | | |
| | | xstring GetEntityData(int pr) |
| | | { |
| | | xml x ; |
| | | dw_item.AcceptText(); |
| | | dw_item.DwUpdateAllToEx(x); |
| | | return x.xml(); |
| | | } |
| | | |
| | | //焦点激活处理函数 |
| | | int OnSetFocus(TEvent* evt, LPARAM param) |
| | | { |
| | | //重置工具条 |
| | | SetAgent(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnPrint() |
| | | { |
| | | xaserverarg& arg = *new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg(L"entityid", dw_list.GetItemString(dw_list.GetRow(), L"SupplierID")); |
| | | arg.AddArg(L"ApplyStatus", dw_list.GetItemString(dw_list.GetRow(), L"ApplyStatus")); |
| | | |
| | | OpenWindow(L"dev:xpage[maint.Document.Supplier.v3.vx]", (LPARAM)&arg); |
| | | |
| | | arg.AddArg(L"EntityName", L"VATNotify"); |
| | | arg.AddArg(L"EntityID", L"", L""); |
| | | xstring InvoiceNo = dw_item.GetItemString(dw_item.GetRow(), L"NInvoiceNo"); |
| | | if (InvoiceNo == L"") InvoiceNo = dw_item.GetItemString(dw_item.GetRow(), L"InvoiceNo"); |
| | | xstring SupplierID = dw_item.GetItemString(dw_item.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; |
| | | } |
| | | if (comdid == L"action:bill.AnnexEx") |
| | | { |
| | | xaserverarg& arg4 = *new xaserverarg; |
| | | arg4.setNativePointer(arg4.CreateInstance()); |
| | | arg4.AddArg(L"entityid", dw_list.GetItemString(dw_list.GetRow(), L"SupplierID")); |
| | | //arg4.AddArg(L"ApplyStatus",dw_list.GetItemString(dw_list.GetRow(),L"ApplyStatus")); |
| | | |
| | | //OpenWindow(L"dev:xpage[maint.Document.Customer.v3.vx]", p4); |
| | | OpenWindow(L"dev:xpage[maint.Document.SupplierSD.v3.vx]", (LPARAM)&arg4); |
| | | int OnPrintItem() |
| | | { |
| | | xaserverarg& arg = *new xaserverarg; |
| | | |
| | | arg.AddArg(L"EntityName", L"VATNotify", L""); |
| | | arg.AddArg(L"EntityID", L"", L""); |
| | | xstring InvoiceNo = dw_item.GetItemString(dw_item.GetRow(), L"NInvoiceNo"); |
| | | if (InvoiceNo == L"") InvoiceNo = dw_item.GetItemString(dw_item.GetRow(), L"InvoiceNo"); |
| | | xstring SupplierID = dw_item.GetItemString(dw_item.GetRow(), L"SupplierID"); |
| | | arg.AddArg(L"EntityNo", InvoiceNo, L""); |
| | | arg.AddArg(L"SupplierID", SupplierID); |
| | | arg.AddArg(L"VATNotifyID", dw_item.GetGuid(dw_item.GetRow())); |
| | | trace(InvoiceNo + L"====L" + dw_item.GetGuid(dw_item.GetRow())); |
| | | |
| | | openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg); |
| | | return 1; |
| | | } |
| | | if (comdid == L"action:bill.checked") |
| | | return OnChecked(); |
| | | // if(comdid==L"action:bill.import") return OnImport(); |
| | | // if(comdid.find(L"action:",0)>=0) return ProcessFlowAction(comdid,1); |
| | | //if(comdid==L"search") return GridSearch(L"view.dlg.vface/xpage/grid/column/edit"); |
| | | //if(comdid==L"showall") return ShowAll(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int PostOnAttachEvent() |
| | | { |
| | | //获得树的选择事件 |
| | | AttachEvent(L"tv_1", L"TVN_SELCHANGED", (FEvent)&listSupplierv3::OnTreeSelChanged); |
| | | AttachEvent(L"cbx_1", L"CBN_SELCHANGE", (FEvent)&listSupplierv3::OnSelectDdlb); |
| | | AttachEvent(L"pages", L"PAGE_CLICK", (FEvent)&listSupplierv3::OnChangePages); |
| | | AttachEvent(L"dw_list", L"DWV_RCLICKED", (FEvent)&listSupplierv3::OnRClick);//鼠标右键 |
| | | //AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&listSupplierv3::OnDoubleClicked); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | PIndex = 1; |
| | | listwin::m_QueryTxt = L""; //查询条件 |
| | | m_sType = L""; //type |
| | | m_sTypeTxt = L""; //选中树的data |
| | | |
| | | listwin::onload(); |
| | | |
| | | tv_1 = GetControl(L"tv_1"); |
| | | ddlb_1 = GetControl(L"cbx_1"); |
| | | |
| | | changeddlb = 0; |
| | | OnCreateTree(L"GoodsCates"); |
| | | dw_list.SetColumnState(L"SupplierID", false); |
| | | dw_list.SetColumnState(L"userNo", false); |
| | | dw_list.SetColumnState(L"YearEstablished", false); |
| | | dw_list.SetColumnState(L"LegalPerson", false); |
| | | dw_list.SetColumnState(L"ThirdPartyReport", false); |
| | | dw_list.SetColumnState(L"bAddress", false); |
| | | dw_list.SetColumnState(L"PayType", false); |
| | | dw_list.SetColumnState(L"PicPath", false); |
| | | dw_list.SetColumnState(L"SDID", false); |
| | | dw_list.SetColumnState(L"AdvantageProduct", false); |
| | | //dw_list.SetColumnState(L"ApplyStatus",false); |
| | | |
| | | dw_goods = GetControl(L"dw_goods"); |
| | | dw_goods.openUrl(GetServerUrl(), L"/sale/view/SupplierV3/template/supplier/supplieritem"); |
| | | |
| | | if (publiccode::GetUser().name != L"admin") |
| | | { |
| | | xstring s = publiccode::GetUser().id; |
| | | |
| | | xml supplier_x = ViewObject::RetrieveData(GetServerUrl(), L"/sale/data/SupplierV3/entity/FindBySaleType", L"id", s); |
| | | if (supplier_x) |
| | | int allbill() { |
| | | int MB_OKCANCEL = 1; |
| | | int IDOK = 1; |
| | | int ret =MessageBox(GetHWND(), L"全数开票?", L"提示", MB_OKCANCEL); |
| | | if (ret != IDOK) return 1; |
| | | dw_item.AcceptText(); |
| | | for (int ll_row = 1; ll_row <= dw_item.GetRowCount(); ll_row++) |
| | | { |
| | | TypeWork = supplier_x.text(); |
| | | xstring ls_dtlno = dw_item.GetItemString(ll_row, L"InvoiceNo"); |
| | | dw_item.SetItemString(ll_row, L"NInvoiceNo", ls_dtlno); |
| | | dw_item.SetItemString(ll_row, L"NAmount", dw_item.GetItemString(ll_row, L"Amount")); |
| | | xstring sdate = publiccode::GetCurrentDate(); |
| | | dw_item.SetItemString(ll_row, L"NotifyDate", sdate); |
| | | dw_item.ItemChangeTo(ll_row, L"NAmount", dw_item.GetItemString(ll_row, L"Amount")); |
| | | } |
| | | dw_item.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | if (TypeWork.find(L"采购") >= 0) |
| | | { |
| | | int allbillno() { |
| | | int MB_OKCANCEL = 1; |
| | | int IDOK = 1; |
| | | int ret =MessageBox(GetHWND(), L"全数不开票?", L"提示", MB_OKCANCEL); |
| | | if (ret != IDOK) return 1; |
| | | dw_item.AcceptText(); |
| | | for (int ll_row = 1; ll_row <= dw_item.GetRowCount(); ll_row++) |
| | | { |
| | | xstring ls_dtlno = dw_item.GetItemString(ll_row, L"InvoiceNo"); |
| | | dw_item.ItemChangeTo(ll_row, L"NAmount", dw_item.GetItemString(ll_row, L"")); |
| | | dw_item.ItemChangeTo(ll_row, L"NQuantity", dw_item.GetItemString(ll_row, L"")); |
| | | dw_item.SetItemString(ll_row, L"NQtyUnit", L""); |
| | | dw_item.SetItemString(ll_row, L"NotifyDate", L""); |
| | | dw_item.SetItemString(ll_row, L"NClassifyID", L""); |
| | | dw_item.SetItemDisplayString(ll_row, L"NClassifyID", L""); |
| | | dw_item.SetItemString(ll_row, L"NName", L""); |
| | | dw_item.SetItemString(ll_row, L"NInvoiceNo", L""); |
| | | } |
| | | dw_item.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | dw_list.SetColumnState(L"DateEx", false); |
| | | dw_list.SetColumnState(L"DateExS", false); |
| | | dw_list.SetColumnState(L"Name", false); |
| | | dw_list.SetColumnState(L"ProvinceCode", false); |
| | | dw_list.SetColumnState(L"City", false); |
| | | dw_list.SetColumnState(L"District", false); |
| | | dw_list.SetColumnState(L"Address", false); |
| | | dw_list.SetColumnState(L"CName", false); |
| | | dw_list.SetColumnState(L"TEL", false); |
| | | dw_list.SetColumnState(L"Mob", false); |
| | | dw_list.SetColumnState(L"AreaCode", false); |
| | | dw_list.SetColumnState(L"Fax", false); |
| | | dw_goods.SetColumnState(L"Price", false); |
| | | dw_goods.SetColumnState(L"PackRMBPrice", false); |
| | | dw_goods.SetColumnState(L"PartRMBPrice", false); |
| | | dw_goods.SetColumnState(L"PaperRMBPrice", false); |
| | | dw_goods.SetColumnState(L"ETD", false); |
| | | dw_goods.SetColumnState(L"InvoiceNo", false); |
| | | int onebill() |
| | | { |
| | | int ll_row = dw_item.GetNextSelectRow(1); |
| | | if (ll_row < 1) return 1; |
| | | |
| | | } |
| | | int MB_OKCANCEL = 1; |
| | | int IDOK = 1; |
| | | int ret =MessageBox(GetHWND(), L"确认开票吗?", L"提示", MB_OKCANCEL); |
| | | if (ret != IDOK) return 1; |
| | | dw_item.AcceptText(); |
| | | |
| | | while (ll_row > 0 && ll_row <= dw_item.GetRowCount()) |
| | | { |
| | | xstring ls_dtlno = dw_item.GetItemString(ll_row, L"InvoiceNo"); |
| | | dw_item.SetItemString(ll_row, L"NInvoiceNo", ls_dtlno); |
| | | //dw_item.SetItemString(ll_row,L"NAmount",dw_item.GetItemString(ll_row,L"Amount")); |
| | | xstring sdate = publiccode::GetCurrentDate(); |
| | | dw_item.SetItemString(ll_row, L"NotifyDate", sdate); |
| | | dw_item.ItemChangeTo(ll_row, L"NAmount", dw_item.GetItemString(ll_row, L"Amount")); |
| | | ll_row = dw_item.GetNextSelectRow(ll_row + 1); |
| | | } |
| | | |
| | | dw_item.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | int onebillno() { |
| | | int ll_row = dw_item.GetNextSelectRow(1); |
| | | if (ll_row < 1) return 1; |
| | | |
| | | int onloaded() |
| | | { |
| | | AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&listSupplierv3::OnRowChangedEx); |
| | | int MB_OKCANCEL = 1; |
| | | int IDOK = 1; |
| | | int ret = MessageBox(GetHWND(), L"确认不予开票吗?", L"提示", MB_OKCANCEL); |
| | | if (ret != IDOK) return 1; |
| | | dw_item.AcceptText(); |
| | | |
| | | listwin::onloaded(); |
| | | xstring EntityID; |
| | | int row = dw_list.GetRow(); |
| | | if (row<0 || row>dw_list.GetRowCount()) return 1; |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring id = listwin::m_configDoc.selectSingleNode(L"//entity/EntityID[1]").text(); |
| | | if (ele.selectSingleNode(id)) |
| | | EntityID = ele.selectSingleNode(id).text(); |
| | | listwin::SetAgent(L"list", EntityID); |
| | | return 1; |
| | | } |
| | | while (ll_row > 0 && ll_row <= dw_item.GetRowCount()) |
| | | { |
| | | xstring ls_dtlno = dw_item.GetItemString(ll_row, L"InvoiceNo"); |
| | | dw_item.ItemChangeTo(ll_row, L"NAmount", dw_item.GetItemString(ll_row, L"")); |
| | | dw_item.ItemChangeTo(ll_row, L"NQuantity", dw_item.GetItemString(ll_row, L"")); |
| | | dw_item.SetItemString(ll_row, L"NotifyDate", L""); |
| | | dw_item.SetItemString(ll_row, L"NClassifyID", L""); |
| | | dw_item.SetItemDisplayString(ll_row, L"NClassifyID", L""); |
| | | dw_item.SetItemString(ll_row, L"NQtyUnit", L""); |
| | | dw_item.SetItemString(ll_row, L"NName", L""); |
| | | dw_item.SetItemString(ll_row, L"NInvoiceNo", L""); |
| | | ll_row = dw_item.GetNextSelectRow(ll_row + 1); |
| | | } |
| | | dw_item.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | }; |
| | | int CalcRate() |
| | | { |
| | | for (int row = 1; row <= dw_fob.GetRowCount(); row++) |
| | | { |
| | | xstring InvoiceNo = dw_fob.GetItemString(row, L"InvoiceNo"); |
| | | xstring ClassifyID = dw_fob.GetItemString(row, L"ClassifyID"); |
| | | double sumAmt = GetSumAmount(InvoiceNo, ClassifyID); |
| | | double sumQty = GetSumQuantity(InvoiceNo, ClassifyID); |
| | | double fobAmt = dw_fob.GetItemDouble(row, L"FobAmt"); |
| | | double rate = sumAmt / fobAmt; |
| | | double LimitAmt = fobAmt * rate; |
| | | dw_fob.SetItemDouble(row, L"Rate", rate); |
| | | dw_fob.SetItemDouble(row, L"LimitAmt", LimitAmt); |
| | | dw_fob.SetItemDouble(row, L"RestAmt", LimitAmt - sumAmt); |
| | | } |
| | | RecalcProfitData(); |
| | | dw_fob.Redraw(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onimport() { |
| | | //OpenWindow(L"dev:xpage[import.vatnotify.vx]",0); |
| | | return 1; |
| | | } |
| | | |
| | | int OnFobItemChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | xstring colname = hdr.colname; |
| | | xstring value = hdr.data; |
| | | int row = hdr.row; |
| | | |
| | | if (colname == L"Rate" || colname == L"FobAmt") |
| | | { |
| | | xstring InvoiceNo = dw_fob.GetItemString(row, L"InvoiceNo"); |
| | | xstring ClassifyID = dw_fob.GetItemString(row, L"ClassifyID"); |
| | | double sumAmt = GetSumAmount(InvoiceNo, ClassifyID); |
| | | double sumQty = GetSumQuantity(InvoiceNo, ClassifyID); |
| | | double fobAmt = dw_fob.GetItemDouble(row, L"FobAmt"); |
| | | double rate = dw_fob.GetItemDouble(row, L"Rate"); |
| | | double LimitAmt = fobAmt * rate; |
| | | dw_fob.SetItemDouble(row, L"LimitAmt", LimitAmt); |
| | | dw_fob.SetItemDouble(row, L"RestAmt", LimitAmt - sumAmt); |
| | | dw_fob.Redraw(); |
| | | RecalcProfitData(); |
| | | return 1; |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnItemChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | xstring colname = hdr.colname; |
| | | xstring value = hdr.data; |
| | | int row = hdr.row; |
| | | xstring ClassifyID = dw_item.GetItemString(row, L"NClassifyID"); |
| | | if (ClassifyID == L"") ClassifyID = dw_item.GetItemString(row, L"ClassifyID"); |
| | | xstring InvoiceNo = dw_item.GetItemString(row, L"NInvoiceNo"); |
| | | if (InvoiceNo == L"") InvoiceNo = dw_item.GetItemString(row, L"InvoiceNo"); |
| | | int ll_find = FobLookup(ClassifyID); |
| | | |
| | | //trace(L"\r\n"+ ll_find.toString()+L":"+ ClassifyID); |
| | | |
| | | if (colname == L"NAmount") |
| | | { |
| | | if (ll_find > 0) |
| | | { |
| | | //xstring qtyUnit = dw_fob.GetItemString(ll_find,L"CQtyUnit"); |
| | | xstring qtyUnit = dw_fob.GetItemString(ll_find, L"QtyUnit"); |
| | | double limitAmt = dw_fob.GetItemDouble(ll_find, L"LimitAmt"); |
| | | double CQuantity = dw_fob.GetItemDouble(ll_find, L"CQuantity"); |
| | | double sumAmt = GetSumAmount(InvoiceNo, ClassifyID); |
| | | double amt = dw_item.GetItemDouble(row, L"NAmount"); |
| | | //double qty = CQuantity * amt /limitAmt; |
| | | double qty = dw_item.GetItemDouble(row, L"Quantity"); |
| | | if (qtyUnit.trim() != L"千克") |
| | | { |
| | | int d = xstring(qty).toInt(); |
| | | xstring s = xstring(d); |
| | | qty = s.toDouble(); |
| | | } |
| | | else |
| | | { |
| | | dw_item.SetItemDouble(row, L"NQuantity", qty); |
| | | xstring sqty = dw_item.GetItemString(row, L"NQuantity"); |
| | | qty = sqty.toDouble(); |
| | | } |
| | | double restAmt = limitAmt - sumAmt; |
| | | dw_fob.SetItemDouble(ll_find, L"RestAmt", restAmt); |
| | | dw_item.ItemChangeTo(row, L"NQuantity", xstring(qty)); |
| | | dw_fob.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | else if (colname == L"NQuantity") |
| | | { |
| | | if (ll_find > 0) |
| | | { |
| | | double CQuantity1 = dw_fob.GetItemDouble(ll_find, L"CQuantity"); |
| | | double sumQty = GetSumQuantity(InvoiceNo, ClassifyID); |
| | | double restQuantity = CQuantity1 - sumQty; |
| | | dw_fob.SetItemDouble(ll_find, L"RestQty", restQuantity); |
| | | |
| | | xstring qtyUnit2 = dw_fob.GetItemString(ll_find, L"QtyUnit"); |
| | | dw_item.SetItemString(row, L"NQtyUnit", qtyUnit2); |
| | | |
| | | dw_fob.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | else if (colname == L"NInvoiceNo") |
| | | { |
| | | row = dw_item.GetRow(); |
| | | InvoiceNo = dw_item.GetItemString(row, L"NInvoiceNo"); |
| | | if (InvoiceNo == L"") InvoiceNo = dw_item.GetItemString(row, L"InvoiceNo"); |
| | | RetrieveFob(InvoiceNo); |
| | | RetrieveProfit(InvoiceNo); |
| | | return 1; |
| | | } |
| | | else if (colname == L"NClassifyID") |
| | | { |
| | | xstring NQuantity = dw_item.GetItemString(dw_item.GetRow(), L"NQuantity"); |
| | | if (NQuantity != L"") dw_item.ItemChangeTo(dw_item.GetRow(), L"NQuantity", NQuantity); |
| | | xstring NAmount = dw_item.GetItemString(dw_item.GetRow(), L"NAmount"); |
| | | if (NAmount != L"") dw_item.ItemChangeTo(dw_item.GetRow(), L"NAmount", NAmount); |
| | | xstring sdate = publiccode::GetCurrentDate(); |
| | | dw_item.SetItemString(dw_item.GetRow(), L"NotifyDate", sdate); |
| | | |
| | | //xstring qtyUnit1 = dw_fob.GetItemString(ll_find,L"CQtyUnit"); |
| | | xstring qtyUnit1 = dw_fob.GetItemString(ll_find, L"QtyUnit"); |
| | | dw_item.SetItemString(dw_item.GetRow(), L"NQtyUnit", qtyUnit1); |
| | | dw_item.SetItemString(dw_item.GetRow(), L"VATRefundRate", dw_fob.GetItemString(ll_find, L"VATRefundRate")); |
| | | dw_item.Redraw(); |
| | | |
| | | return 1; |
| | | } |
| | | /* |
| | | if dwo.name='notifycname' then |
| | | if trim(data)='' then |
| | | this.setItem(row,'notifycustid','') |
| | | else |
| | | //cwd |
| | | if pos(data,'"') > 0 then |
| | | ll_find = dw_3.find(L"cname='"+data+L"'",0,dw_3.rowCount()) |
| | | else |
| | | ll_find = dw_3.find('cname=L"'+data+'"',0,dw_3.rowCount()) |
| | | end if |
| | | //end |
| | | // ll_find = dw_3.find('cname=L"'+data+'"',0,dw_3.rowCount()) |
| | | if ll_find > 0 then |
| | | this.setItem(row,'notifycustid',dw_3.getItemString(ll_find,'custid')) |
| | | this.setItem(row,'custunit',dw_3.getItemString(ll_find,'custunit')) |
| | | |
| | | decimal ld_rate |
| | | ls_custid = dw_3.getItemString(ll_find,'custid') |
| | | select retax into :ld_rate from code_t_custom where code_s = :ls_custid; |
| | | this.setitem(row,'retax',ld_rate) |
| | | end if |
| | | end if |
| | | if not isnull(this.getItemDecimal(row,'notifybuyamt')) then |
| | | dwoex = this.object.notifybuyamt |
| | | this.event itemchanged(row,dwoex,xstring(this.getItemDecimal(row,'notifybuyamt'))) |
| | | end if |
| | | if not isnull(this.getItemDecimal(row,'notifycustqty')) then |
| | | dwoex = this.object.notifycustqty |
| | | this.event itemchanged(row,dwoex,xstring(this.getItemDecimal(row,'notifycustqty'))) |
| | | end if |
| | | dw_1.setitem( dw_1.getrow(), 'notifydate',today()) |
| | | */ |
| | | return 1; |
| | | } |
| | | |
| | | double GetSumAmountExcept(xstring InvoiceNo, xstring ClassifyID, xstring InvoiceNoExcept) |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg = ViewObject::MakeArg(); |
| | | arg.AddArg(L"ClassifyID", ClassifyID); |
| | | arg.AddArg(L"InvoiceNo", InvoiceNo); |
| | | arg.AddArg(L"InvoiceExcept", InvoiceNoExcept); |
| | | |
| | | if (xurl::get(L"/sale/data/VATNotify/entity/suminfo", arg.GetString(), x) != 1) |
| | | { |
| | | xstring error = x.text(); |
| | | alert(L"err:" + error); |
| | | return 0.0; |
| | | } |
| | | KXMLDOMNode n = x.selectSingleNode(L"data/Item/amt"); |
| | | if (!n) return 0.0; |
| | | xstring str = n.text(); |
| | | return str.toDouble(); |
| | | } |
| | | |
| | | double GetSumQuantityExcept(xstring InvoiceNo, xstring ClassifyID, xstring InvoiceNoExcept) |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg = ViewObject::MakeArg(); |
| | | arg.AddArg(L"ClassifyID", ClassifyID); |
| | | arg.AddArg(L"InvoiceNo", InvoiceNo); |
| | | arg.AddArg(L"InvoiceExcept", InvoiceNoExcept); |
| | | |
| | | if (xurl::get(L"/sale/data/VATNotify/entity/suminfo", arg.GetString(), x) != 1) |
| | | { |
| | | xstring error = x.text(); |
| | | alert(L"err:" + error); |
| | | return 0.0; |
| | | } |
| | | KXMLDOMNode n = x.selectSingleNode(L"data/Item/qty"); |
| | | if (!n) return 0.0; |
| | | xstring str = n.text(); |
| | | return str.toDouble(); |
| | | } |
| | | |
| | | double GetSumAmount(xstring InvoiceNo, xstring ClassifyID) |
| | | { |
| | | double amt = 0; |
| | | xstring InvoiceNoExcept = dw_item.GetItemString(1, L"InvoiceNo"); |
| | | if (InvoiceNoExcept != L"") amt = GetSumAmountExcept(InvoiceNo, ClassifyID, InvoiceNoExcept); |
| | | |
| | | for (int ll_row = 1; ll_row <= dw_item.GetRowCount(); ll_row++) |
| | | { |
| | | xstring ls_dtlno = dw_item.GetItemString(ll_row, L"NInvoiceNo"); |
| | | if (ls_dtlno == L"") ls_dtlno = dw_item.GetItemString(ll_row, L"InvoiceNo"); |
| | | if (InvoiceNo == ls_dtlno) |
| | | { |
| | | xstring classifyID = dw_item.GetItemString(ll_row, L"NClassifyID"); |
| | | if (classifyID == L"") classifyID = dw_item.GetItemString(ll_row, L"ClassifyID"); |
| | | if (classifyID == ClassifyID) |
| | | amt += dw_item.GetItemDouble(ll_row, L"NAmount"); |
| | | } |
| | | } |
| | | return amt; |
| | | } |
| | | |
| | | int RecalcProfitData() |
| | | { |
| | | double fobAmt = GetSumFobAmt(); |
| | | double limitAmt = GetSumLimitAmount(); |
| | | double RefundAmt = GetSumRefund(); |
| | | double goodsAmt = limitAmt - RefundAmt; |
| | | double freight = dw_profit.GetItemDouble(1, L"Freight"); |
| | | double comm = dw_profit.GetItemDouble(1, L"Comm"); |
| | | double netAmount = fobAmt - freight - comm; |
| | | double exchCost = (limitAmt - RefundAmt) / fobAmt; |
| | | dw_profit.SetItemDouble(1, L"NetAmount", netAmount); |
| | | dw_profit.SetItemDouble(1, L"SaleAmount", fobAmt); |
| | | dw_profit.SetItemDouble(1, L"SaleCost", goodsAmt); |
| | | dw_profit.SetItemDouble(1, L"Drawback", RefundAmt); |
| | | dw_profit.SetItemDouble(1, L"ExchCost", exchCost); |
| | | dw_profit.Redraw(); |
| | | return 1; |
| | | } |
| | | double GetSumLimitAmount() |
| | | { |
| | | double amt = 0; |
| | | for (int ll_row = 1; ll_row <= dw_fob.GetRowCount(); ll_row++) |
| | | { |
| | | amt += dw_fob.GetItemDouble(ll_row, L"LimitAmt"); |
| | | } |
| | | return amt; |
| | | } |
| | | double GetSumRefund() |
| | | { |
| | | double amt = 0; |
| | | for (int ll_row = 1; ll_row <= dw_fob.GetRowCount(); ll_row++) |
| | | { |
| | | double rate = dw_fob.GetItemDouble(ll_row, L"VATRate"); |
| | | double refundRate = dw_fob.GetItemDouble(ll_row, L"VATRefundRate"); |
| | | double d = dw_fob.GetItemDouble(ll_row, L"LimitAmt"); |
| | | double val = d / (100.0 + rate) * refundRate; |
| | | amt += val; |
| | | } |
| | | return amt; |
| | | } |
| | | double GetSumFobAmt() |
| | | { |
| | | double amt = 0; |
| | | for (int ll_row = 1; ll_row <= dw_fob.GetRowCount(); ll_row++) |
| | | { |
| | | amt += dw_fob.GetItemDouble(ll_row, L"FobAmt"); |
| | | } |
| | | return amt; |
| | | } |
| | | |
| | | double GetSumQuantity(xstring InvoiceNo, xstring ClassifyID) |
| | | { |
| | | double qty = 0; |
| | | xstring InvoiceNoExcept = dw_item.GetItemString(1, L"InvoiceNo"); |
| | | if (InvoiceNoExcept != L"") qty = GetSumQuantityExcept(InvoiceNo, ClassifyID, InvoiceNoExcept); |
| | | |
| | | for (int ll_row = 1; ll_row <= dw_item.GetRowCount(); ll_row++) |
| | | { |
| | | xstring ls_dtlno = dw_item.GetItemString(ll_row, L"NInvoiceNo"); |
| | | if (ls_dtlno == L"") ls_dtlno = dw_item.GetItemString(ll_row, L"InvoiceNo"); |
| | | if (InvoiceNo == ls_dtlno) |
| | | { |
| | | xstring classifyID = dw_item.GetItemString(ll_row, L"NClassifyID"); |
| | | if (classifyID == L"") classifyID = dw_item.GetItemString(ll_row, L"ClassifyID"); |
| | | if (classifyID == ClassifyID) |
| | | { |
| | | qty += dw_item.GetItemDouble(ll_row, L"NQuantity"); |
| | | } |
| | | } |
| | | } |
| | | return qty; |
| | | } |
| | | |
| | | int FobLookup(xstring ClassifyID) |
| | | { |
| | | for (int ll_row = 1; ll_row <= dw_fob.GetRowCount(); ll_row++) |
| | | { |
| | | if (dw_fob.GetItemString(ll_row, L"ClassifyID") == ClassifyID) return ll_row; |
| | | } |
| | | return -1; |
| | | } |
| | | |
| | | int addother() { |
| | | return 1; |
| | | } |
| | | int deleteother() { |
| | | return 1; |
| | | } |
| | | //命令发布函数 |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == L"save") { |
| | | return OnSave(); |
| | | } |
| | | else if (comdid == L"xmParse") |
| | | return OnParse(); |
| | | else if (comdid == L"allbill") { |
| | | return allbill(); |
| | | } |
| | | else if (comdid == L"allbillno") { |
| | | return allbillno(); |
| | | } |
| | | else if (comdid == L"onebill") { |
| | | return onebill(); |
| | | } |
| | | else if (comdid == L"onebillno") { |
| | | return onebillno(); |
| | | } |
| | | else if (comdid == L"import") { |
| | | return onimport(); |
| | | } |
| | | else if (comdid == L"addother") { |
| | | return addother(); |
| | | } |
| | | else if (comdid == L"deleteother") { |
| | | return deleteother(); |
| | | } |
| | | else if (comdid == L"xmPrint") { |
| | | return OnPrint(); |
| | | } |
| | | else if (comdid == L"xmPrintItem") { |
| | | return OnPrintItem(); |
| | | } |
| | | else if (comdid == L"xmCalcRate") { |
| | | return CalcRate(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int OnRowChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | |
| | | xstring InvoiceNo = dw_item.GetItemString(row, L"NInvoiceNo"); |
| | | if (InvoiceNo == L"") InvoiceNo = dw_item.GetItemString(row, L"InvoiceNo"); |
| | | if (InvoiceNo != CurInvNo) |
| | | { |
| | | CurInvNo = InvoiceNo; |
| | | RetrieveFob(InvoiceNo); |
| | | RetrieveProfit(InvoiceNo); |
| | | RecalcProfitData(); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnParse() |
| | | { |
| | | xaserverarg arg; |
| | | |
| | | OpenWindow(L"dev:xpage[VATNotifyParse.vx]", arg); |
| | | if (arg.GetArgString(L"process") == L"ok") |
| | | { |
| | | int row = dw_item.GetRow(); |
| | | int row1 = dw_item.InsertRow(0); |
| | | dw_item.SetItemString(row1, L"SupplierID", dw_item.GetItemString(row, L"SupplierID")); |
| | | dw_item.SetItemDisplayString(row1, L"SupplierID", dw_item.GetItemDisplayString(row, L"SupplierID")); |
| | | dw_item.SetItemString(row1, L"Amount", arg.GetArgString(L"Amount")); |
| | | dw_item.SetItemString(row1, L"Quantity", arg.GetArgString(L"Quantity")); |
| | | dw_item.SetItemString(row1, L"CQuantity", arg.GetArgString(L"CustQuantity")); |
| | | dw_item.SetItemString(row1, L"ClassifyID", dw_item.GetItemString(row, L"ClassifyID")); |
| | | dw_item.SetItemDisplayString(row1, L"ClassifyID", dw_item.GetItemDisplayString(row, L"ClassifyID")); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //命令处理事件 |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnSave() |
| | | { |
| | | xml x ; |
| | | |
| | | dw_item.AcceptText(); |
| | | dw_item.DwUpdateAllToEx(x); |
| | | xaserverarg arg = ViewObject::MakeArg(); |
| | | arg.AddArg(L"content", x.xml()); |
| | | |
| | | |
| | | |
| | | //trace(x.xml); |
| | | //return 1; |
| | | if (xurl::get(L"/sale/data/VATNotify/base/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_item.ResetUpdateStatus(); |
| | | } |
| | | else |
| | | { |
| | | alert(L"保存失败1!"); |
| | | return 1; |
| | | } |
| | | |
| | | dw_fob.AcceptText(); |
| | | xml x1 ; |
| | | |
| | | dw_fob.DwUpdateAllToEx(x1); |
| | | arg.AddArg(L"content", x1.xml()); |
| | | int MB_OKCANCEL = 1; |
| | | int IDOK = 1; |
| | | |
| | | /* |
| | | for(int ll_row=1; ll_row <= dw_fob.GetRowCount(); ll_row++) |
| | | { |
| | | xstring RestQty = dw_fob.GetItemString(ll_row,L"RestQty"); |
| | | //xstring ClassifyID=dw_fob.GetItemString(ll_row,L"CName"); |
| | | if(RestQty !=L"0.00" ){ |
| | | //xstring qty =RestQty; |
| | | int ret = win32::MessageBox(GetHWND(),L" 存在结存数量不为0的物品,确认保存吗?",L"提示",MB_OKCANCEL); |
| | | if(ret !=IDOK) return 1; |
| | | } |
| | | } |
| | | */ |
| | | |
| | | |
| | | //return 0; |
| | | if (xurl::get(L"/sale/data/VATNotify/fob/update", arg.GetString(), x1) != 1) |
| | | { |
| | | xstring error1 = x1.text(); |
| | | alert(L"err:" + error1); |
| | | return 1; |
| | | } |
| | | str = x1.documentElement().getAttribute(L"text"); |
| | | if (str == L"true") |
| | | { |
| | | dw_fob.ResetUpdateStatus(); |
| | | alert(L"保存成功!"); |
| | | } |
| | | else |
| | | { |
| | | alert(L"保存失败2!"); |
| | | return 1; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&simplemaintvatnotifyWin::OnXCommand); |
| | | //获取焦点事件,用于重置工具条 |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&simplemaintvatnotifyWin::OnSetFocus); |
| | | AttachEvent(L"dw_item", L"DWV_ITEMCHANGED", (FEvent)&simplemaintvatnotifyWin::OnItemChanged); |
| | | AttachEvent(L"dw_fob", L"DWV_ITEMCHANGED", (FEvent)&simplemaintvatnotifyWin::OnFobItemChanged); |
| | | AttachEvent(L"dw_item", L"DWV_ROWFOCUSCHANGED", (FEvent)&simplemaintvatnotifyWin::OnRowChanged); |
| | | AttachEvent(L"dw_item", L"DWV_ASKDATA", (FEvent)&simplemaintvatnotifyWin::OnAskDataItem); |
| | | AttachCloseWindow(); |
| | | return 1; |
| | | } |
| | | |
| | | int RetrieveFob(xstring InvoiceNo, bool start = false) |
| | | { |
| | | if (!start) |
| | | { |
| | | dw_fob.Filter(L"InvoiceNo", InvoiceNo); |
| | | dw_fob.Redraw(); |
| | | if (dw_fob.GetRowCount() > 0) return 1; |
| | | } |
| | | |
| | | //start = true; |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"invoiceno", InvoiceNo); |
| | | if (getUrl(L"/sale/data/VATNotify/entity/fob", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | //trace(x.xml); |
| | | if (start) |
| | | { |
| | | dw_fob.Retrieve(x); |
| | | dw_fob.Redraw(); |
| | | } |
| | | else |
| | | { |
| | | xml x1 ; |
| | | |
| | | dw_fob.DwUpdateAllToEx(x1); |
| | | KXMLDOMElement docElement = x1.documentElement(); |
| | | if (docElement) |
| | | { |
| | | KXMLDOMNodeList lst = x.selectNodes(L"data/Item"); |
| | | int n = lst.length(); |
| | | for (int i = 0; i < n; i++) |
| | | { |
| | | KXMLDOMElement e = lst.item(i); |
| | | docElement.appendChild(e); |
| | | e.Release(); |
| | | } |
| | | docElement.Release(); |
| | | lst.Release(); |
| | | dw_fob.Retrieve(x1); |
| | | } |
| | | else |
| | | { |
| | | dw_fob.Retrieve(x); |
| | | } |
| | | dw_fob.Filter(L"InvoiceNo", InvoiceNo); |
| | | dw_fob.Redraw(); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int RetrieveProfit(xstring InvoiceNo) |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"invoiceno", InvoiceNo); |
| | | if (getUrl(L"/sale/data/VATNotify/entity/profit", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_profit.Retrieve(x); |
| | | dw_profit.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnRetrieve() |
| | | { |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | |
| | | |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | |
| | | if (GetWinParam()) |
| | | { |
| | | int pArg = GetArg(); |
| | | |
| | | } |
| | | else |
| | | { |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | if (getUrl(L"/sale/data/VATNotify/entity/base", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | xutil::RestoreCursor(hCursor); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_item.Retrieve(x); |
| | | dw_item.Redraw(); |
| | | dw_item.SetSelectionMode(1); |
| | | } |
| | | if (dw_item.GetRowCount() > 0) |
| | | { |
| | | xstring InvoiceNo = dw_item.GetItemString(1, L"NInvoiceNo"); |
| | | if (InvoiceNo == L"") InvoiceNo = dw_item.GetItemString(1, L"InvoiceNo"); |
| | | CurInvNo = InvoiceNo; |
| | | RetrieveFob(InvoiceNo); |
| | | RetrieveProfit(InvoiceNo); |
| | | RecalcProfitData(); |
| | | } |
| | | |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | //base AskData |
| | | int OnAskDataItem(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | xstring x = hdr.colname; |
| | | if (x == L"userInvoiceNo") //下拉 |
| | | { |
| | | xstring sInvoiceNo = dw_item.GetItemString(row, L"NInvoiceNo"); |
| | | hdr.data = sInvoiceNo; |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | SetArg(); |
| | | dw_item = GetControl(L"dw_item"); |
| | | dw_item.openUrl(L"/sale/view/VATNotify/template/VATNotify/item"); |
| | | dw_item.SetColumnState(L"InvoiceNo", false); |
| | | dw_item.SetColumnState(L"CName", false); |
| | | //dw_item.SetColumnState(L"CreatorID",false); |
| | | //dw_item.SetColumnState(L"CreateDate",false); |
| | | dw_item.SetColumnState(L"VATRate", false); |
| | | dw_item.SetColumnState(L"VATRefundRate", false); |
| | | dw_item.SetColumnState(L"IsFinish", false); |
| | | dw_item.SetColumnState(L"Type", false); |
| | | dw_item.SetColumnState(L"QtyUnitName", false); |
| | | dw_item.SetColumnState(L"QtyUnit", false); |
| | | dw_item.SetColumnState(L"CQtyUnit", false); |
| | | |
| | | dw_fob = GetControl(L"dw_fob"); |
| | | dw_fob.openUrl(L"/sale/view/VATNotify/template/VATNotify/fob"); |
| | | dw_profit = GetControl(L"dw_profit"); |
| | | dw_profit.openUrl(L"/sale/view/VATNotify/template/VATNotify/profit"); |
| | | dw_profit.SetColHeaderHeight(0); |
| | | dw_profit.SetRowSelectorWidth(0); |
| | | dw_profit.SetHScrollState(false); |
| | | dw_profit.SetVScrollState(false); |
| | | |
| | | InvNo = L""; |
| | | CurInvNo = L""; |
| | | xaserverarg arg; |
| | | |
| | | |
| | | if (GetWinParam()) |
| | | { |
| | | int pArg = GetArg(); |
| | | |
| | | InvNo = arg.GetArgString(L"invoiceno"); |
| | | SetWindowText(GetHWND(), InvNo); |
| | | } |
| | | CurInvNo = InvNo; |
| | | |
| | | OnRetrieve(); |
| | | OnAttachEvent(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |