#include #include #include #include #include #include #include #include #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) QuickInputNewProductExWin : public xwin { public: QuickInputNewProductExWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} public: static QuickInputNewProductExWin* CreateInstance(void* implPtr, void* hWnd) { return new QuickInputNewProductExWin(implPtr, (HWND)hWnd); } public: xdwtable dw_detail; xdwtable dw_props; xdwtable dw_base; xdwgrid dw_list; xnode m_agentNode; //Agent Condition xstring m_refno; xaserverarg parg; 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; } //¶ÁÈ¡²úÆ·Ê÷µÄ×ÓÏî xml RetrieveGoodsTreeChildItems(xstring sno) { xml x ; xaserverarg arg ; arg.AddArg(L"no",sno); if(xurl::get(L"/sale/data/SO/goods/goodslib/ChildFolderList", arg.GetString(),x)!=1) { xstring error = x.text(); //alert(error); return 0; }else return x; } //²åÈë²úÆ·ÀàÏîµÄ×ÓÏî int MakeGoodsFolder(xstring sno,int level ) { xcombobox cbx_type = GetControl(L"cbx_category"); xml x = RetrieveGoodsTreeChildItems(sno); if(!x) return 0; KXMLDOMNodeList nlist = x.selectNodes(L"//Item"); int len = nlist.length(); for (int i = 0; i < len; i++) { KXMLDOMElement e = nlist.item(i); xstring name = e.getAttribute(L"cname"); xstring no= e.getAttribute(L"no"); if(level == 1) cbx_type.AddItem(no +L" "+ name); else cbx_type.AddItem(L" "+ no +L" " + name); if(level ==1) MakeGoodsFolder(no,level + 1); } return 1; } //½¹µã¼¤»î´¦Àíº¯Êý int OnSetFocus(TEvent* evt, LPARAM param) { //ÖØÖù¤¾ßÌõ SetAgent(); return 1; } xstring GetNo() { xstring typ=L"C"; if(m_refno.left(1)==L"[") typ=L"N"; xml x; xaserverarg arg ; arg.AddArg(L"count", L"1" ); arg.AddArg(L"type", typ ); if(xurl::get(L"/sale/data/SO/goods/usegoods/goodslib/asknos", arg.GetString(),x)!=1)return L""; return x.text(); } int OnSave() { int row = 0; for( row = 1;row <= dw_list.GetRowCount();row++) { if(dw_list.GetItemString(row,L"Cname") == L"") { alert(L"µÚ"+xstring(row)+L"ÐÐÇëÊäÈëÖÐÎÄÃû³Æ"); return 0; } if(dw_list.GetItemString(row,L"PackingRate") == L"") { alert(L"µÚ"+ xstring(row) +L"ÐÐÇëÊäÈë°ü×°·½Ê½"); return 0; } if(dw_list.GetItemString(row,L"InnerQty") == L"") { alert(L"µÚ"+ xstring(row) +L"ÐÐÇëÊäÈëÄÚ×°Êý"); return 0; } if(dw_list.GetItemString(row,L"PackingRate") == L"") { alert(L"µÚ"+ xstring(row) +L"ÐÐÇëÊäÈëÍâ×°Êý"); return 0; } if(dw_list.GetItemString(row,L"PackageL") == L"") { alert(L"µÚ"+ xstring(row) +L"ÐÐÇëÊäÈ볤¶È"); return 0; } if(dw_list.GetItemString(row,L"PackageW") == L"") { alert(L"µÚ"+ xstring(row) +L"ÐÐÇëÊäÈë¿í¶È"); return 0; } if(dw_list.GetItemString(row,L"PackageH") == L"") { alert(L"µÚ"+ xstring(row) +L"ÐÐÇëÊäÈë¸ß¶È"); return 0; } } for(row = 1;row <= dw_list.GetRowCount();row++) { dw_list.SetItemString(row,L"No",GetNo()); } dw_list.Redraw(); xml x ; dw_list.AcceptText(); dw_list.DwUpdateAllToEx(x); xaserverarg arg ; arg.AddArg(L"content",x.xml()); if(xurl::get(L"/sale/data/ProductLibrary3/update/newestproduct", arg.GetString(),x)!=1) { xstring error = x.text(); alert(error); return 1; }else { alert(L"±£´æ³É¹¦!"); dw_base.ResetUpdateStatus(); dw_list.ResetUpdateStatus(); if(parg)parg.AddArg(L"data.modify",L"1"); } return 1; } int OnAddItem() { dw_list.InsertRow(0); int row = dw_list.GetRowCount(); xstring sdate = publiccode::GetCurrentDate(); xstring suserid = publiccode::GetUser().id; xstring categoryID = dw_base.GetItemString(1,L"CategoryID"); xstring supplierID = dw_base.GetItemString(1,L"SupplierID"); dw_list.SetItemString(row,L"FolderID",parg.GetArgString(L"guid")); if(categoryID)dw_list.SetItemString(row,L"CategoryID",categoryID); if(supplierID)dw_list.SetItemString(row,L"SupplierID",supplierID); dw_list.SetItemString(row,L"CreateID",suserid); dw_list.SetItemString(row,L"CreateDate",sdate); dw_list.SetItemString(row,L"ModifierID",suserid); dw_list.SetItemString(row,L"ModifyDate",sdate); return 1; } //ÃüÁî·¢²¼º¯Êý int OnCmdDispatch(xstring comdid) { if(comdid == L"xmAdd") { OnAddItem(); } else if(comdid == L"xmDelete") { dw_list.DeleteRow(dw_list.GetRow()); } else if(comdid == L"xmSave") { OnSave(); } else if(comdid==L"xmCancel") { CloseWindow(); return 1; } return 0; } int OnCategoryChanged(TEvent* evt, int lParam) { xstring id = L""; xstring name = L""; xcombobox cbx_type = GetControl(L"cbx_category"); int h = cbx_type.GetCurSel(); xstring str = cbx_type.GetLBText(h); str = str.trim(); return 1; } int OnItemChanged(TEvent* evt, int p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname=hdr.colname; xstring value = hdr.data; int row = hdr.row; if(colname == L"CategoryID" || colname == L"SupplierID") { xstring categoryID = dw_base.GetItemString(1,L"CategoryID"); xstring supplierID = dw_base.GetItemString(1,L"SupplierID"); for(int i=1;i<=dw_list.GetRowCount();i++) { dw_list.SetItemString(i,L"CategoryID",categoryID); dw_list.SetItemString(i,L"SupplierID",supplierID); } } return 1; } //ÃüÁî´¦Àíʼþ int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnAttachEvent() { //°ó¶¨¹¤¾ßÌõµã»÷ʼþ AttachEvent(L"WM_XCOMMAND", (FEvent)&QuickInputNewProductExWin::OnXCommand); //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ AttachEvent(L"WM_SETFOCUS", (FEvent)&QuickInputNewProductExWin::OnSetFocus); AttachEvent(L"dw_base",L"DWV_ITEMCHANGED", (FEvent)&QuickInputNewProductExWin::OnItemChanged); AttachEvent(L"cbx_category",L"CBN_SELCHANGE", (FEvent)&QuickInputNewProductExWin::OnCategoryChanged); return 1; } int OnInit() { dw_base.SetItemString(1,L"CategoryID",L"EF37E57D-5833-4AF9-BA5E-01CCF39C1F20"); dw_base.SetItemDisplayString(1,L"CategoryID",L"ÀñÆ·"); dw_base.Redraw(); OnAddItem(); return 1; } int onload() { SetArg(); dw_base = GetControl(L"dw_base"); dw_base.openUrl(L"/sale/view/ProductLibrary/template/newitemgroup"); dw_base.SetColHeaderHeight(0); dw_base.SetRowSelectorWidth(0); dw_base.SetHScrollState(false); dw_base.SetVScrollState(false); dw_base.SetEditUpperMode(true); dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/ProductLibrary/template/newProductItem"); dw_list.SetColumnState(L"CategoryID",false); dw_list.SetColumnState(L"FolderID",false); dw_list.SetColumnState(L"SupplierID",false); dw_list.SetColumnState(L"CreateID",false); dw_list.SetColumnState(L"CreateDate",false); dw_list.SetColumnState(L"ModifierID",false); dw_list.SetColumnState(L"ModifyDate",false); if(GetWinParam()) { parg = GetArg(); xcombobox cbx_type = GetControl(L"cbx_category"); xstring txt = parg.GetArgString(L"CategoryNo").trim() + L" " + parg.GetArgString(L"CName").trim(); cbx_type.AddItem(txt, (LPARAM)parg.GetArgString(L"guid").c_str(true)); //leak cbx_type.SetText(txt); } OnAttachEvent(); OnInit(); return 1; } int onloaded() { SetAgent(); return 1; } };