| | |
| | | #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 <xcontrol/ximageview.hpp> |
| | | |
| | | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | #include "viewobject/enquiry.view.hpp" |
| | | #include "viewobject/quote.view.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) EnquiryMaintView : public xframe |
| | | { |
| | | listSupplierv3* pWin = new listSupplierv3(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | int OnRetrieve() |
| | | { |
| | | xml x; |
| | | public: |
| | | xdwgrid dw_goods; |
| | | xdwtable dw_base; |
| | | |
| | | 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) |
| | | xnode m_agentNode; //Agent Condition |
| | | xstring sheetname; |
| | | public: |
| | | EnquiryMaintView(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static EnquiryMaintView* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | return -1; |
| | | EnquiryMaintView* pWin = new EnquiryMaintView(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; |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | //焦点激活处理函数 |
| | | int OnSetFocus(TEvent* evt, LPARAM param) |
| | | { |
| | | //重置工具条 |
| | | SetAgent(); |
| | | return 1; |
| | | } |
| | | |
| | | //xcombobox下拉 |
| | | int OnSelectDdlb(TEvent evt, LPARAM p) |
| | | { |
| | | changeddlb = 1; |
| | | xstring GetEntityData(int pr) |
| | | { |
| | | dw_base.AcceptText(); |
| | | dw_goods.AcceptText(); |
| | | if (dw_base.GetItemString(1, L"EnquiryNo") == L"") |
| | | { |
| | | xstring EnquiryNo = EnquiryView::MakeBillNo(); |
| | | dw_base.SetItemString(1, L"EnquiryNo", EnquiryNo); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | dw_goods.DwUpdateAllToEx(x); |
| | | dw_base.DwUpdateAllTo(x); |
| | | return x.xml(); |
| | | } |
| | | |
| | | 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); |
| | | int SetSeqNo(xdwgrid dw_obj, xstring SeqNoColumn, int nRow) |
| | | { |
| | | if (nRow > 1) |
| | | { |
| | | int SeqNo = dw_goods.GetItemInt(nRow - 1, SeqNoColumn); |
| | | if (SeqNo != 0) SeqNo += 10; else SeqNo = nRow * 10; |
| | | dw_obj.SetItemInt(nRow, SeqNoColumn, SeqNo); |
| | | } |
| | | else |
| | | dw_obj.SetItemInt(nRow, SeqNoColumn, 10); |
| | | return 1; |
| | | } |
| | | |
| | | int Adjust() |
| | | { |
| | | xstring str; |
| | | for (int i = 1; i <= dw_goods.GetRowCount(); i++) |
| | | { |
| | | str = dw_goods.GetItemString(i, L"SupplierID"); |
| | | if (dw_goods.GetItemString(i, L"ItemID") != L"") |
| | | if (str == L"") |
| | | { |
| | | if (i > 1) |
| | | { |
| | | if (dw_goods.GetItemString(i - 1, L"SupplierID") != L"") |
| | | { |
| | | dw_goods.SetItemDisplayString(i, L"SupplierID", dw_goods.GetItemDisplayString(i - 1, L"SupplierID")); |
| | | dw_goods.ItemChangeTo(i, L"SupplierID", dw_goods.GetItemString(i - 1, L"SupplierID")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnSave() |
| | | { |
| | | dw_base.AcceptText(); |
| | | dw_goods.AcceptText(); |
| | | if (dw_base.GetItemString(1, L"Remark") != L"保存") |
| | | { |
| | | if (dw_base.GetItemString(1, L"EnquiryNo") == L"") |
| | | { |
| | | xstring EnquiryNo = EnquiryView::MakeBillNo(); |
| | | dw_base.SetItemString(1, L"EnquiryNo", EnquiryNo); |
| | | } |
| | | |
| | | if (dw_base.GetItemString(1, L"ValidDay") == L"") |
| | | { |
| | | alert(L"请输入有效期!"); |
| | | return 1; |
| | | } |
| | | /*if(dw_base.GetItemString(1,L"SupplierID")==L"") |
| | | { |
| | | alert(L"供应商为空!"); |
| | | return 1; |
| | | }*/ |
| | | if (dw_base.GetItemString(1, L"Source") == L"") |
| | | { |
| | | alert(L"请输入询价类别!"); |
| | | return 1; |
| | | } |
| | | xstring Packing = L""; |
| | | xstring Packings = L""; |
| | | Adjust(); |
| | | for (int i = 1; i <= dw_goods.GetRowCount(); i++) |
| | | { |
| | | if (dw_goods.GetItemString(i, L"ItemMiniQty") == L"") |
| | | { |
| | | alert(L"请输入起订量!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"Picture") == L"") |
| | | { |
| | | alert(L"请 " + xstring(i) + L"行,上传产品图片!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"POPrice") == L"" || dw_goods.GetItemString(i, L"POPrice") == L".000") |
| | | { |
| | | alert(L"请输入采购价!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"PriceType") == L"") |
| | | { |
| | | alert(L"请输入价格类型!"); |
| | | return 1; |
| | | } |
| | | |
| | | if (dw_goods.GetItemString(i, L"SampleFee") == L"") |
| | | { |
| | | alert(L"请输入打样费!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"TestFee") == L"") |
| | | { |
| | | alert(L"请输入测试费!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"ModelFee") == L"") |
| | | { |
| | | alert(L"请输入模具费!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"VolumeDesc") == L"") |
| | | { |
| | | alert(L"请输入包装尺码!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"WarehousingReason") == L"") |
| | | { |
| | | alert(L"请输入入库理由!"); |
| | | return 1; |
| | | } |
| | | |
| | | /*if(dw_goods.GetItemString(i,L"Packing") !=L"") |
| | | { |
| | | Packing = dw_goods.GetItemString(i,L"Packing"); |
| | | if(Packings==L"") |
| | | Packings = Packing; |
| | | else if(Packings.find(Packing) < 0) Packings+=L",L"+Packing; |
| | | }*/ |
| | | if (dw_goods.GetItemString(i, L"Packing") == L"") |
| | | { |
| | | alert(L"请输包装方式!"); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | xml xx = ViewObject::RetrieveData(L"/sale/data/Enquiry/GetPacking", L"str", dw_goods.GetItemString(i, L"Packing")); |
| | | xstring Results = xx.text(); |
| | | int ResultsInt = Results.toInt(); |
| | | if (ResultsInt == 0) |
| | | { |
| | | alert(L"第" + xstring(i) + L"行包装方式错误,请重新选择!"); |
| | | return 1; |
| | | } |
| | | } |
| | | } |
| | | trace(L"********" + Packings + L"*********"); |
| | | } |
| | | |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | dw_goods.DwUpdateAllToEx(x); |
| | | dw_base.DwUpdateAllTo(x); |
| | | |
| | | //alert(x.xml()); |
| | | |
| | | xstring error = L""; |
| | | arg.AddArg(L"content", x.xml()); |
| | | if (xurl::get(L"/sale/data/Enquiry/update", arg.GetString(), x) != 1) |
| | | { |
| | | error = x.text(); |
| | | alert(error); |
| | | } |
| | | else |
| | | { |
| | | xstring str = x.documentElement().getAttribute(L"text"); |
| | | if (str == L"true") |
| | | { |
| | | dw_goods.ResetUpdateStatus(); |
| | | dw_base.ResetUpdateStatus(); |
| | | UpdateEnquiryLineID(); |
| | | |
| | | xaserverarg arg_; |
| | | |
| | | //trace(L"\r\nSource:"+arg_.GetArgString(L"Source")); |
| | | if (arg_.GetArgString(L"Source") == L"quote") |
| | | InsertEnquiryPriceList(); |
| | | else if (arg_.GetArgString(L"Source") == L"pricebill") |
| | | InsertEnquiryPriceListByEnquiryID(); |
| | | |
| | | alert(L"保存成功!"); |
| | | HWND hWnd = 0; |
| | | if (arg_.GetArgString(L"Source") == L"pricebill") |
| | | { |
| | | if (arg_.GetArgString(L"hWnd") != L"") |
| | | { |
| | | hWnd = (HWND)arg_.GetParam(L"hWnd"); |
| | | PostMessage(hWnd, 0x401, (LPARAM)L"xmRefresh", 0); |
| | | } |
| | | } |
| | | if (arg_.GetArgString(L"Source") == L"") |
| | | { |
| | | if (arg_.GetArgString(L"hWnd") != L"") |
| | | { |
| | | hWnd = (HWND)arg_.GetParam(L"hWnd"); |
| | | PostMessage(hWnd, 0x401, (LPARAM)L"xmReresh", 0); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | alert(L"保存失败!"); |
| | | } |
| | | } |
| | | if (x) |
| | | return 1; |
| | | } |
| | | |
| | | int InsertEnquiryPriceListByEnquiryID() |
| | | { |
| | | //trace(L"\r\nInsertEnquiryPriceListByEnquiryID Start!"); |
| | | xml x = ViewObject::RetrieveData(L"/sale/data/Enquiry/InsertEnquiryPriceListByEnquiryID", L"EnquiryID", dw_base.GetGuid(1)); |
| | | //trace(L"\r\nInsertEnquiryPriceListByEnquiryID:" + dw_base.GetGuid(1)+L" "+ x.xml()); |
| | | return 1; |
| | | } |
| | | |
| | | int InsertEnquiryPriceList() |
| | | { |
| | | xaserverarg arg; |
| | | |
| | | xstring EntityIDList = arg.GetArgString(L"EntityIDList"); |
| | | xml x = ViewObject::RetrieveData(L"/sale/data/Enquiry/InsertEnquiryPriceList", L"ItemList", EntityIDList); |
| | | xml x1 = ViewObject::RetrieveData(L"/sale/data/Enquiry/Update/UpdateQuoteLine", L"ItemList", EntityIDList); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int UpdateEnquiryLineID() |
| | | { |
| | | xaserverarg arg; |
| | | |
| | | int row = dw_base.GetRow(); |
| | | if (row < 1) return 0; |
| | | |
| | | xstring EnquiryID = dw_base.GetGuid(1); |
| | | |
| | | xml x = ViewObject::RetrieveData(L"/sale/data/Enquiry/Update/UpdateEnquiryLineID", L"EnquiryID", EnquiryID); |
| | | return 1; |
| | | } |
| | | |
| | | int OnSave1() |
| | | { |
| | | dw_base.AcceptText(); |
| | | dw_goods.AcceptText(); |
| | | if (dw_base.GetItemString(1, L"EnquiryNo") == L"") |
| | | { |
| | | xstring EnquiryNo = EnquiryView::MakeBillNo(); |
| | | dw_base.SetItemString(1, L"EnquiryNo", EnquiryNo); |
| | | } |
| | | |
| | | if (dw_base.GetItemString(1, L"ValidDay") == L"") |
| | | { |
| | | alert(L"请输入有效期!"); |
| | | return 1; |
| | | } |
| | | |
| | | if (dw_base.GetItemString(1, L"Source") == L"") |
| | | { |
| | | alert(L"请输入询价类别!"); |
| | | return 1; |
| | | } |
| | | xstring Packing = L""; |
| | | xstring Packings = L""; |
| | | for (int i = 1; i <= dw_goods.GetRowCount(); i++) |
| | | { |
| | | if (dw_goods.GetItemString(i, L"ItemMiniQty") == L"") |
| | | { |
| | | alert(L"请输入起订量!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"Picture") == L"") |
| | | { |
| | | alert(L"请 " + xstring(i) + L"行,上传产品图片!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"POPrice") == L"" || dw_goods.GetItemString(i, L"POPrice") == L".000") |
| | | { |
| | | alert(L"请输入采购价!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"PriceType") == L"") |
| | | { |
| | | alert(L"请输入价格类型!"); |
| | | return 1; |
| | | } |
| | | |
| | | if (dw_goods.GetItemString(i, L"SampleFee") == L"") |
| | | { |
| | | alert(L"请输入打样费!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"TestFee") == L"") |
| | | { |
| | | alert(L"请输入测试费!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"ModelFee") == L"") |
| | | { |
| | | alert(L"请输入模具费!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"VolumeDesc") == L"") |
| | | { |
| | | alert(L"请输入包装尺码!"); |
| | | return 1; |
| | | } |
| | | if (dw_goods.GetItemString(i, L"WarehousingReason") == L"") |
| | | { |
| | | alert(L"请输入入库理由!"); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | if (dw_goods.GetItemString(i, L"Packing") != L"") |
| | | { |
| | | Packing = dw_goods.GetItemString(i, L"Packing"); |
| | | if (Packings == L"") |
| | | Packings = Packing; |
| | | else if (Packings.find(Packing) < 0) Packings += L",L" + Packing; |
| | | } |
| | | } |
| | | |
| | | trace(L"********" + Packings + L"*********"); |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | dw_base.DwUpdateAllTo(x); |
| | | KXMLDOMElement ele = x.documentElement(); |
| | | |
| | | xml x1 ; |
| | | dw_goods.DwUpdateAllToEx(x1); |
| | | KXMLDOMNodeList items = x1.selectNodes(L"Enquiry/Item"); |
| | | int len = items.length(); |
| | | bool processed = false; |
| | | KXMLDOMNode child; |
| | | KXMLDOMNode nodeColumn; |
| | | KXMLDOMElement eleItem; |
| | | KXMLDOMElement eleColumn; |
| | | xstring guid; |
| | | for (int k = 0; k < len; k++) |
| | | { |
| | | KXMLDOMElement e = items.item(k); |
| | | /*processed = false; |
| | | KXMLDOMNode col = e.selectSingleNode(L"QuoteNo"); |
| | | if(col) |
| | | { |
| | | if(col.text !=L"") |
| | | { |
| | | child = e.cloneNode(-1); |
| | | ele.appendChild(child); |
| | | child.release(); |
| | | processed = true; |
| | | } |
| | | col.release(); |
| | | } |
| | | if(!processed) |
| | | {*/ |
| | | xstring itemNew = e.getAttribute(L"update.new"); |
| | | xstring itemDelete = e.getAttribute(L"update.delete"); |
| | | xstring itemModify = e.getAttribute(L"update.modify"); |
| | | if (itemDelete == L"1") |
| | | { |
| | | eleItem = x.createElement(L"Item"); |
| | | eleItem.setAttribute(L"update.modify", L"1"); |
| | | guid = e.getAttribute(L"guid"); |
| | | eleItem.setAttribute(L"guid", guid); |
| | | |
| | | eleColumn = x.createElement(L"LineType"); |
| | | eleColumn.setAttribute(L"update.modify", L"1"); //delete |
| | | eleColumn.settext(L"1"); |
| | | eleItem.appendChild(eleColumn); |
| | | ele.appendChild(eleItem); |
| | | processed = true; |
| | | } |
| | | else if (itemModify == L"1") |
| | | { |
| | | if (itemNew != L"1") |
| | | { |
| | | //update origin row |
| | | eleItem = x.createElement(L"Item"); |
| | | eleItem.setAttribute(L"update.modify", L"1"); |
| | | guid = e.getAttribute(L"guid"); |
| | | eleItem.setAttribute(L"guid", guid); |
| | | |
| | | eleColumn = x.createElement(L"RealEnquiryLineID"); |
| | | eleColumn.setAttribute(L"update.modify", L"1"); |
| | | guid = publiccode::GetGuid(); |
| | | eleColumn.settext(guid); |
| | | eleItem.appendChild(eleColumn); |
| | | |
| | | eleColumn = x.createElement(L"LineType"); |
| | | eleColumn.setAttribute(L"update.modify", L"1"); |
| | | eleColumn.settext(L"1"); //modify |
| | | eleItem.appendChild(eleColumn); |
| | | ele.appendChild(eleItem); |
| | | |
| | | //insert new row |
| | | eleItem = e.cloneNode(-1); |
| | | eleItem.setAttribute(L"update.modify", L"1"); |
| | | eleItem.setAttribute(L"update.new", L"1"); |
| | | eleItem.setAttribute(L"guid", publiccode::GetGuid()); |
| | | |
| | | eleColumn = x.createElement(L"LineType"); |
| | | eleColumn.setAttribute(L"update.modify", L"1"); |
| | | eleColumn.settext(L"0"); //normal |
| | | eleItem.appendChild(eleColumn); |
| | | |
| | | nodeColumn = e.selectSingleNode(L"ModifyDate"); |
| | | if (!nodeColumn) |
| | | eleColumn = x.createElement(L"ModifyDate"); |
| | | else |
| | | eleColumn = nodeColumn; |
| | | eleColumn.settext(publiccode::GetCurrentDate()); |
| | | eleItem.appendChild(eleColumn); |
| | | |
| | | ele.appendChild(eleItem); |
| | | } |
| | | else |
| | | { |
| | | guid = e.getAttribute(L"guid"); |
| | | child = e.cloneNode(-1); |
| | | child.selectSingleNode(L"RealEnquiryLineID").settext(guid); |
| | | child.selectSingleNode(L"RelEnquiryLineID").settext(guid); |
| | | ele.appendChild(child); |
| | | //trace(child.xml); |
| | | } |
| | | } |
| | | //} |
| | | } |
| | | |
| | | xstring error = L""; |
| | | arg.AddArg(L"content", x.xml()); |
| | | if (xurl::get(L"/sale/data/Enquiry/update", arg.GetString(), x) != 1) |
| | | { |
| | | error = x.text(); |
| | | alert(error); |
| | | } |
| | | else |
| | | { |
| | | xstring str = x.documentElement().getAttribute(L"text"); |
| | | if (str == L"true") |
| | | { |
| | | alert(L"保存成功!"); |
| | | //dw_goods.ResetUpdateStatus(); |
| | | //dw_base.ResetUpdateStatus(); |
| | | OnRetrieve(dw_base.GetItemString(1, L"EnquiryNo")); |
| | | } |
| | | else |
| | | { |
| | | alert(L"保存失败!"); |
| | | } |
| | | } |
| | | if (x) |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int ImportProductByText(xstring str) |
| | | { |
| | | xstring CustomerID = dw_base.GetItemString(1, L"CustomerID"); |
| | | //trace(L"Customer:"+CustomerID); |
| | | xml x; |
| | | if (CustomerID == L"") |
| | | x = QuoteView::LookupProductsByText(str); |
| | | else |
| | | x = QuoteView::LookupProductsByText(str, CustomerID); |
| | | |
| | | if (!x) return 1; |
| | | KXMLDOMNodeList items = x.selectNodes(L"/Items/Item"); |
| | | //trace(L"********" + x.xml() + L"********"); |
| | | int len = items.length(); |
| | | if (str.find(L" ") < 0 && len > 0) len = 1; |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = items.item(i); |
| | | dw_goods.InsertRow(0); |
| | | int nRow = dw_goods.GetRowCount(); |
| | | SetSeqNo(dw_goods, L"SeqNo", nRow); |
| | | dw_goods.SetItemString(nRow, L"UOMCode", L"007"); |
| | | dw_goods.SetItemDisplayString(nRow, L"UOMCode", L"PCS"); |
| | | dw_goods.SetItemString(nRow, L"KOPCode", L"120"); |
| | | dw_goods.SetItemDisplayString(nRow, L"KOPCode", L"CTNS"); |
| | | dw_goods.SetItemString(nRow, L"SKUNo", e.getAttribute(L"SKUNo")); |
| | | dw_goods.SetItemString(nRow, L"ItemID", e.getAttribute(L"SKUID")); |
| | | //dw_goods.SetItemString(nRow,L"ItemName",e.getAttribute(L"EName")); |
| | | dw_goods.SetItemString(nRow, L"ItemName", e.getAttribute(L"CName")); |
| | | dw_goods.SetItemString(nRow, L"GoodsNo", e.getAttribute(L"GoodsNo")); |
| | | dw_goods.SetItemString(nRow, L"CustomerItemNo", e.getAttribute(L"CustomerItemNo")); |
| | | dw_goods.SetItemString(nRow, L"Packing", e.getAttribute(L"Packing")); |
| | | dw_goods.SetItemString(nRow, L"VolumeDesc", e.getAttribute(L"VolumeDesc")); |
| | | dw_goods.SetItemString(nRow, L"PackingRate", e.getAttribute(L"QtyPerPkg")); |
| | | dw_goods.SetItemString(nRow, L"InnerQty", e.getAttribute(L"InnerQty")); |
| | | dw_goods.SetItemString(nRow, L"VATRefundRate", e.getAttribute(L"VATRefundRate")); |
| | | dw_goods.SetItemString(nRow, L"VATRate", e.getAttribute(L"VATRate")); |
| | | dw_goods.SetItemString(nRow, L"HSCode", e.getAttribute(L"HSCode")); |
| | | //trace(L"+++++L"+e.getAttribute(L"Picture")+L"+++++L"); |
| | | dw_goods.SetItemString(nRow, L"Picture", e.getAttribute(L"Picture")); |
| | | |
| | | if (dw_goods.GetItemString(nRow, L"VolumeDesc") != L"" && |
| | | dw_goods.GetItemString(nRow, L"Packages") != L"") |
| | | { |
| | | int qty = EvalQtyPerFCL45H(nRow); |
| | | dw_goods.SetItemString(nRow, L"Packages45H", xstring(qty)); |
| | | dw_goods.SetItemDouble(nRow, L"TransportationFee", 5000.0 / qty); |
| | | } |
| | | /* |
| | | dw_goods.SetItemString(nRow,L"NwPerPkg",e.getAttribute(L"NwPerPkg")); |
| | | dw_goods.SetItemString(nRow,L"GwPerPkg",e.getAttribute(L"GwPerPkg")); |
| | | dw_goods.SetItemString(nRow,L"QTYPerPk",e.getAttribute(L"QTYPerPk")); |
| | | dw_goods.SetItemString(nRow,L"InnerQty",e.getAttribute(L"InnerQty")); |
| | | */ |
| | | } |
| | | |
| | | int row = dw_goods.GetRow(); |
| | | if (row >= 1) |
| | | { |
| | | ximageview im = GetControl(L"im1"); |
| | | im.Reset(); |
| | | xstring skuno = dw_goods.GetItemString(row, L"SKUNo"); |
| | | OnShowImage(skuno, row); |
| | | im.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | double EvalCost(int row) |
| | | { |
| | | double cost = 0.0; |
| | | cost += dw_goods.GetItemDouble(row, L"POPrice"); |
| | | cost += dw_goods.GetItemDouble(row, L"PaperCardPrice"); |
| | | cost += dw_goods.GetItemDouble(row, L"TransportationFee"); |
| | | cost += dw_goods.GetItemDouble(row, L"OtherFee"); |
| | | cost += dw_goods.GetItemDouble(row, L"ManagementFee"); |
| | | return cost; |
| | | } |
| | | |
| | | double EvalRefund(int row) |
| | | { |
| | | double VATRefundRate = dw_goods.GetItemDouble(row, L"VATRefundRate"); |
| | | double VATRefund = dw_goods.GetItemDouble(row, L"POPrice") * VATRefundRate / 117.0; |
| | | VATRefund += dw_goods.GetItemDouble(row, L"PaperCardPrice") * 13.0 / 117.0; |
| | | return VATRefund; |
| | | } |
| | | |
| | | int EvalQtyPerFCL45H(int row) |
| | | { |
| | | double vol = EvalVol(dw_goods.GetItemString(row, L"VolumeDesc")); |
| | | double packages = dw_goods.GetItemDouble(row, L"Packages"); |
| | | return xdouble((packages * 67.0 / vol)).toInt(); |
| | | } |
| | | double EvalUnitProfit(int row) |
| | | { |
| | | double ExchangeRate = dw_base.GetItemDouble(1, L"ExchangeRate"); |
| | | double FobUnitPrice = dw_goods.GetItemDouble(row, L"FobUnitPrice"); |
| | | double UnitCost = dw_goods.GetItemDouble(row, L"UnitCost"); |
| | | double VATRefund = dw_goods.GetItemDouble(row, L"VATRefund"); |
| | | return ExchangeRate * FobUnitPrice - UnitCost + VATRefund; |
| | | } |
| | | |
| | | double EvalProfitRate(int row) |
| | | { |
| | | double UnitProfit = EvalUnitProfit(row); |
| | | double UnitCost = dw_goods.GetItemDouble(row, L"UnitCost"); |
| | | return UnitProfit / UnitCost; |
| | | } |
| | | double EvalSaleProfitRate(int row) |
| | | { |
| | | double UnitProfit = EvalUnitProfit(row); |
| | | double FobUnitPrice = dw_goods.GetItemDouble(row, L"FobUnitPrice"); |
| | | return UnitProfit / FobUnitPrice; |
| | | } |
| | | |
| | | double EvalExchangeCostRate(int row) |
| | | { |
| | | double FobUnitPrice = dw_goods.GetItemDouble(row, L"FobUnitPrice"); |
| | | double UnitCost = dw_goods.GetItemDouble(row, L"UnitCost"); |
| | | double VATRefund = dw_goods.GetItemDouble(row, L"VATRefund"); |
| | | return (UnitCost - VATRefund) / FobUnitPrice; |
| | | } |
| | | |
| | | double EvalTransportationFee(int row) |
| | | { |
| | | double vol = EvalVol(dw_goods.GetItemString(row, L"VolumeDesc")); |
| | | double packages = dw_goods.GetItemDouble(row, L"Packages"); |
| | | return 80 * vol / packages; |
| | | } |
| | | |
| | | double EvalVol(xstring value) |
| | | { |
| | | double vol = 1.0; |
| | | xstring volstr = value; |
| | | int pos1 = volstr.find(L"*"); |
| | | int pos2 = volstr.find(L"X"); |
| | | int pos3 = volstr.find(L"x"); |
| | | int pos = pos1; |
| | | //trace(L"pos: "+ pos.toString() + L"pos1: "+ pos1.toString() + L"pos2: "+ pos2.toString() +L"pos3: "+ pos3.toString()); |
| | | if (pos2 > 0 && pos == -1) pos = pos2; |
| | | if (pos2 >= 0 && pos2 < pos) pos = pos2; |
| | | //trace(L"pos: "+ pos.toString() + L"pos1: "+ pos1.toString() + L"pos2: "+ pos2.toString() +L"pos3: "+ pos3.toString()); |
| | | if (pos3 > 0 && pos == -1) pos = pos3; |
| | | if (pos3 >= 0 && pos3 < pos) pos = pos3; |
| | | //trace(L"pos: "+ pos.toString() + L"pos1: "+ pos1.toString() + L"pos2: "+ pos2.toString() +L"pos3: "+ pos3.toString()); |
| | | while (pos >= 0) |
| | | { |
| | | xstring tm = volstr.left(pos); |
| | | volstr = volstr.mid(pos + 1, 9999); |
| | | vol *= tm.toDouble(); |
| | | |
| | | pos1 = volstr.find(L"*"); |
| | | pos2 = volstr.find(L"X"); |
| | | pos3 = volstr.find(L"x"); |
| | | pos = pos1; |
| | | if (pos2 > 0 && pos == -1) pos = pos2; |
| | | if (pos2 >= 0 && pos2 < pos) pos = pos2; |
| | | if (pos3 > 0 && pos == -1) pos = pos3; |
| | | if (pos3 >= 0 && pos3 < pos) pos = pos3; |
| | | } |
| | | if (volstr != L"") vol *= volstr.toDouble(); |
| | | return vol / 1000000.0; |
| | | } |
| | | |
| | | int OnShare() |
| | | { |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"EntityID", dw_base.GetGuid(1)); |
| | | //arg.AddArg(L"EntityName", GetEntityName(0)); |
| | | arg.AddArg(L"EntityName", L"Enquiry3"); |
| | | |
| | | OpenWindow(L"dev:xpage[UserGroupShare.vx]",arg ); |
| | | 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; |
| | | |
| | | double VATRefund = 0.0; |
| | | double VATRefundRate = 0.0; |
| | | if ((colname == L"GoodsNo" || colname == L"CustomerItemNo") && value != L"") |
| | | { |
| | | if (colname == L"CustomerItemNo") |
| | | { |
| | | if (dw_goods.GetItemString(row, L"GoodsNo") != L"") return 1; |
| | | } |
| | | xml x; |
| | | xstring CustomerID = dw_base.GetItemString(1, L"CustomerID"); |
| | | xstring sval = value; |
| | | if (colname == L"GoodsNo") |
| | | { |
| | | if (CustomerID != L"") |
| | | sval = L"gs:" + value; |
| | | else |
| | | sval = value; |
| | | } |
| | | if (colname == L"CustomerItemNo") |
| | | /*sval=L"cs:"+value; |
| | | if(CustomerID !=L"") |
| | | x = QuoteView::LookupProductsByText(sval,CustomerID ); |
| | | else |
| | | x = QuoteView::LookupProductsByText(sval);*/ |
| | | sval = value; |
| | | x = ViewObject::RetrieveData(L"/sale/data/Quote/LookGDN", L"str", sval); |
| | | if (!x) return 1; |
| | | KXMLDOMNodeList items = x.selectNodes(L"/Items/Item"); |
| | | trace(x.xml()); |
| | | int len = items.length(); |
| | | if (len == 0) |
| | | { |
| | | if (colname == L"GoodsNo") |
| | | { |
| | | alert(L"没有此公司型号!"); |
| | | dw_goods.SetItemString(dw_goods.GetRow(), L"GoodsNo", L""); |
| | | } |
| | | return 1; |
| | | } |
| | | if (len >= 1) |
| | | { |
| | | KXMLDOMElement e = items.item(0); |
| | | int nRow = dw_goods.GetRow(); |
| | | dw_goods.SetItemString(nRow, L"SKUNo", e.getAttribute(L"SKUNo")); |
| | | dw_goods.SetItemString(nRow, L"ItemID", e.getAttribute(L"SKUID")); |
| | | dw_goods.SetItemString(nRow, L"ItemName", e.getAttribute(L"CName")); |
| | | if (colname == L"CustomerItemNo")dw_goods.SetItemString(nRow, L"GoodsNo", e.getAttribute(L"GoodsNo")); |
| | | if (colname == L"GoodsNo")dw_goods.SetItemString(nRow, L"CustomerItemNo", e.getAttribute(L"CustomerItemNo")); |
| | | dw_goods.SetItemString(nRow, L"Packing", e.getAttribute(L"Packing")); |
| | | dw_goods.SetItemString(nRow, L"InnerQty", e.getAttribute(L"InnerQty")); |
| | | dw_goods.SetItemString(nRow, L"PackingRate", e.getAttribute(L"PackingRate")); |
| | | dw_goods.SetItemString(nRow, L"VolumeDesc", e.getAttribute(L"VolumeDesc")); |
| | | dw_goods.SetItemString(nRow, L"Packages", e.getAttribute(L"QTYPerPkg")); |
| | | dw_goods.SetItemString(nRow, L"SupplierID", e.getAttribute(L"SupplierID")); |
| | | dw_goods.SetItemDisplayString(nRow, L"SupplierID", e.getAttribute(L"SupplierID1")); |
| | | dw_goods.SetItemString(nRow, L"POCreatorID", e.getAttribute(L"POCreatorID")); |
| | | dw_goods.SetItemDisplayString(nRow, L"POCreatorID", e.getAttribute(L"POCreatorID1")); |
| | | dw_goods.SetItemString(nRow, L"Picture", e.getAttribute(L"Picture")); |
| | | |
| | | if (dw_goods.GetItemString(nRow, L"VolumeDesc") != L"" && |
| | | dw_goods.GetItemString(nRow, L"Packages") != L"") |
| | | { |
| | | int qty1 = EvalQtyPerFCL45H(nRow); |
| | | dw_goods.SetItemString(nRow, L"Packages45H", xstring(qty1)); |
| | | dw_goods.SetItemDouble(nRow, L"TransportationFee", 5000.0 / qty1); |
| | | } |
| | | dw_goods.Redraw(); |
| | | } |
| | | } |
| | | |
| | | else if (colname == L"POPrice" || colname == L"PaperCardPrice" || colname == L"TransportationFee" || |
| | | colname == L"OtherFee" || colname == L"ManagementFee") |
| | | { |
| | | dw_goods.SetItemDouble(row, L"UnitCost", EvalCost(row)); |
| | | |
| | | if ((colname == L"POPrice" || colname == L"PaperCardPrice") && dw_goods.GetItemString(row, L"VATRefundRate") != L"") |
| | | { |
| | | dw_goods.SetItemDouble(row, L"VATRefund", EvalRefund(row)); |
| | | } |
| | | } |
| | | else if (colname == L"VATRefundRate" && value != L"") |
| | | { |
| | | dw_goods.SetItemDouble(row, L"VATRefund", EvalRefund(row)); |
| | | } |
| | | else if (colname == L"VolumeDesc" || colname == L"Packages") |
| | | { |
| | | if (dw_goods.GetItemString(row, L"VolumeDesc") != L"" && |
| | | dw_goods.GetItemString(row, L"Packages") != L"") |
| | | { |
| | | int qty = EvalQtyPerFCL45H(row); |
| | | dw_goods.SetItemString(row, L"Packages45H", xstring(qty)); |
| | | dw_goods.SetItemDouble(row, L"TransportationFee", EvalTransportationFee(row)); |
| | | dw_goods.SetItemDouble(row, L"UnitCost", EvalCost(row)); |
| | | } |
| | | } |
| | | else if (colname == L"FobUnitPrice") |
| | | { |
| | | xstring CurrencyCode = dw_base.GetItemString(1, L"CurrencyCode"); |
| | | xstring expRate = L""; |
| | | xstring exchRate = L""; |
| | | |
| | | xml x0 = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"dcomp_amt"); |
| | | if (x0.selectSingleNode(L"root/item/@value")) |
| | | expRate = x0.selectSingleNode(L"root/item/@value").text(); |
| | | x0 = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate"); |
| | | if (x0.selectSingleNode(L"root/item/@value")) |
| | | exchRate = x0.selectSingleNode(L"root/item/@value").text(); |
| | | double r1 = exchRate.toDouble(); |
| | | double r2 = expRate.toDouble(); |
| | | double val = value.toDouble(); |
| | | if (CurrencyCode == L"RMB" || CurrencyCode == L"CNY") |
| | | { |
| | | if (exchRate != L"") |
| | | { |
| | | double ManagementFee = (val / r1) * r2; |
| | | double OtherFee = (val / r1) * 0.2; |
| | | dw_goods.SetItemDouble(row, L"ManagementFee", ManagementFee); |
| | | dw_goods.SetItemDouble(row, L"OtherFee", OtherFee); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | dw_goods.SetItemDouble(row, L"ManagementFee", val * 0.15); |
| | | dw_goods.SetItemDouble(row, L"OtherFee", val * 0.2); |
| | | } |
| | | dw_goods.SetItemDouble(row, L"UnitCost", EvalCost(row)); |
| | | } |
| | | if (dw_goods.GetItemString(row, L"FobUnitPrice") != L"" && |
| | | dw_goods.GetItemString(row, L"POPrice") != L"" && |
| | | dw_goods.GetItemString(row, L"VolumeDesc") != L"" && |
| | | dw_goods.GetItemString(row, L"Packages") != L"") |
| | | { |
| | | dw_goods.SetItemDouble(row, L"UnitProfit", EvalUnitProfit(row)); |
| | | dw_goods.SetItemDouble(row, L"ProfitRate", EvalProfitRate(row)); |
| | | dw_goods.SetItemDouble(row, L"SaleProfitRate", EvalSaleProfitRate(row)); |
| | | dw_goods.SetItemDouble(row, L"ExchangeCostRate", EvalExchangeCostRate(row)); |
| | | } |
| | | |
| | | dw_goods.SetItemString(row, L"ModifyDate", publiccode::GetCurrentDate()); |
| | | dw_goods.Redraw(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnBaseItemChanged(TEvent* evt, int p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | xstring colname = hdr.colname; |
| | | xstring value = hdr.data; |
| | | |
| | | xstring dwname = L"dw_base"; |
| | | if (value != L"") |
| | | { |
| | | //trace(L"\r\nsupplierid:"+value); |
| | | KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='" + dwname + L"']/trans[@for='" + colname + L"']"); |
| | | ViewObject::TransData(nlist, dw_base, hdr.row, colname, value); |
| | | } |
| | | if (colname == L"ExchangeRate") |
| | | { |
| | | if (dw_goods.GetRowCount() > 0) |
| | | { |
| | | for (int i = 1; i <= dw_goods.GetRowCount(); i++) |
| | | { |
| | | dw_goods.SetItemDouble(i, L"UnitProfit", EvalUnitProfit(i)); |
| | | dw_goods.SetItemDouble(i, L"ProfitRate", EvalProfitRate(i)); |
| | | dw_goods.SetItemDouble(i, L"SaleProfitRate", EvalSaleProfitRate(i)); |
| | | dw_goods.SetItemDouble(i, L"ExchangeCostRate", EvalExchangeCostRate(i)); |
| | | } |
| | | } |
| | | dw_goods.Redraw(); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnPriceEval() |
| | | { |
| | | OpenWindow(L"dev:xpage[eval.Enquiry3.vx]", (LPARAM)&dw_goods); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int OnRowChanged(TEvent* evt, int p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | |
| | | ximageview im = GetControl(L"im1"); |
| | | im.Reset(); |
| | | xstring skuno = dw_goods.GetItemString(row, L"SKUNo"); |
| | | OnShowImage(skuno, row); |
| | | im.Redraw(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnShowImage() |
| | | { |
| | | int rowCount = dw_goods.GetRowCount(); |
| | | xstring skunos; |
| | | for (int i = 1; i <= rowCount; i++) |
| | | { |
| | | xstring skuno = dw_goods.GetItemString(i, L"SKUNo"); |
| | | if (i == 1) |
| | | skunos = skuno; |
| | | else |
| | | skunos += L",L" + skuno; |
| | | } |
| | | |
| | | xaserverarg arg_pic; |
| | | |
| | | arg_pic.AddArg(L"SKUNoList", skunos); |
| | | arg_pic.SetParam(L"ParentWindow", GetHWND()); |
| | | arg_pic.AddArg(L"OpenFlag", L"1"); |
| | | OpenWindow(L"dev:xpage[SKU.PictureView.Product3.vx]",arg_pic); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnShowImage(xstring skuno, int row) |
| | | { |
| | | ximageview im = GetControl(L"im1"); |
| | | |
| | | xml xp ; |
| | | |
| | | xaserverarg arg_pic; |
| | | arg_pic.setNativePointer(arg_pic.CreateInstance()); |
| | | arg_pic.AddArg(L"SKUNo", skuno); |
| | | |
| | | xstring res = L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | xstring customerID = dw_base.GetItemString(1, L"CustomerID"); |
| | | xstring customerItemNo = dw_goods.GetItemString(row, L"CustomerItemNo"); |
| | | KXMLDOMNodeList nlistp; |
| | | int lenp = 0; |
| | | int ip = 0; |
| | | KXMLDOMElement xitem ; |
| | | xstring picname = L""; |
| | | xstring goodno = L""; |
| | | if (customerItemNo != L"") |
| | | { |
| | | //trace(customerID+L":"+customerItemNo); |
| | | res = L"/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKUNo"; |
| | | arg_pic.AddArg(L"CustomerID", customerID); |
| | | arg_pic.AddArg(L"CustomerItemNo", customerItemNo); |
| | | } |
| | | |
| | | bool hasIamge = false; |
| | | if (xurl::get(res, arg_pic.GetString(), xp) != 1) |
| | | { |
| | | //trace(xp.xml()); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | //trace(xp.xml()); |
| | | nlistp = xp.selectNodes(L"ImageList/image"); |
| | | lenp = nlistp.length(); |
| | | for (ip = 0; ip < lenp; ip++) |
| | | { |
| | | hasIamge = true; |
| | | xitem = nlistp.item(ip); |
| | | picname = xitem.selectSingleNode(L"PicPath").text(); |
| | | goodno = xitem.selectSingleNode(L"GoodsNo").text(); |
| | | if (picname == L"/business/products/Thumbs//") |
| | | picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg"; |
| | | im.AddImages(picname, goodno); |
| | | } |
| | | } |
| | | if (!hasIamge) |
| | | { |
| | | res = L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | if (xurl::get(res, arg_pic.GetString(), xp) != 1) |
| | | { |
| | | //trace(xp.xml()); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | nlistp = xp.selectNodes(L"ImageList/image"); |
| | | lenp = nlistp.length(); |
| | | for (ip = 0; ip < lenp; ip++) |
| | | { |
| | | xitem = nlistp.item(ip); |
| | | picname = xitem.selectSingleNode(L"PicPath").text(); |
| | | goodno = xitem.selectSingleNode(L"GoodsNo").text(); |
| | | if (picname == L"/business/products/Thumbs//") |
| | | picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg"; |
| | | im.AddImages(picname, goodno); |
| | | } |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int OnPrint() |
| | | { |
| | | if (dw_base.GetItemString(1, L"EnquiryNo") == L"") |
| | | { |
| | | alert(L"请先保存数据!"); |
| | | return 1; |
| | | } |
| | | xaserverarg& arg = *new xaserverarg; |
| | | |
| | | arg.AddArg(L"EntityName", L"Enquiry", L""); |
| | | arg.AddArg(L"EntityID", dw_base.GetItemString(1, L"EnquiryID"), L""); |
| | | arg.AddArg(L"EntityNo", dw_base.GetItemString(1, L"EnquiryNo"), L""); |
| | | |
| | | openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg); |
| | | return 1; |
| | | } |
| | | |
| | | int ReSeqNo(xstring SeqNoColumn) |
| | | { |
| | | for (int i = 1; i <= dw_goods.GetRowCount(); i++) |
| | | { |
| | | dw_goods.SetItemString(i, SeqNoColumn, xstring((i * 10))); |
| | | } |
| | | dw_goods.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnAskGoodsNo() |
| | | { |
| | | int rowCount = dw_goods.GetRowCount(); |
| | | xstring skunos = L""; |
| | | |
| | | for (int i = 1; i <= rowCount; i++) |
| | | { |
| | | if (dw_goods.GetItemString(i, L"SKUNo") != L"" && dw_goods.GetItemString(i, L"GoodsNo") == L"" && dw_goods.GetItemString(i, L"Submitter") == L"") |
| | | { |
| | | if (skunos == L"") |
| | | skunos = dw_goods.GetItemString(i, L"SKUNo"); |
| | | else |
| | | skunos += L",L" + dw_goods.GetItemString(i, L"SKUNo"); |
| | | } |
| | | } |
| | | xaserverarg arg ; |
| | | arg.AddArg(L"SKUNoList", skunos); |
| | | OpenWindow(L"dev:xpage[Product.FetchNo.vx]",arg ); |
| | | return 1; |
| | | } |
| | | |
| | | //命令发布函数 |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == L"xmNewProduct") |
| | | { |
| | | //xaserverarg arg; |
| | | // |
| | | openUrl(L"/sale/view/Enquiry3/xpage/quick/newestproduct"); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmPrint") return OnPrint(); |
| | | else if (comdid == L"xmImage") |
| | | return OnShowImage(); |
| | | else if (comdid == L"xmShare") |
| | | return OnShare(); |
| | | else if (comdid == L"xmImportProduct") |
| | | { |
| | | xstring str = xcontrol(GetControl(L"goods")).GetText(); |
| | | str = str.trim(); |
| | | if (str == L"") |
| | | { |
| | | xaserverarg arg1; |
| | | arg1.setNativePointer(arg1.CreateInstance()); |
| | | arg1.SetParam(L"HWND", GetHWND()); |
| | | arg1.AddArg(L"CustomerID", dw_base.GetItemString(1, L"CustomerID")); |
| | | OpenWindow(L"dev:xpage[Entity.Product.Select.vx]",arg1); |
| | | int row = dw_goods.GetRow(); |
| | | if (row >= 1) |
| | | { |
| | | ximageview im = GetControl(L"im1"); |
| | | im.Reset(); |
| | | xstring skuno = dw_goods.GetItemString(row, L"SKUNo"); |
| | | OnShowImage(skuno, row); |
| | | im.Redraw(); |
| | | } |
| | | } |
| | | else |
| | | ImportProductByText(str); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmSave") |
| | | { |
| | | OnSave(); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmPriceEval") |
| | | return OnPriceEval(); |
| | | else if (comdid == L"xmOpen") |
| | | { |
| | | xaserverarg arg; |
| | | |
| | | OpenWindow(L"dev:xpage[SOEnquiry.list.vx]",arg); |
| | | if (arg.GetArgString(L"id") != L"") return OnRetrieve(arg.GetArgString(L"id")); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmDeleteRow") |
| | | { |
| | | if (dw_goods.GetItemString(dw_goods.GetRow(), L"QuoteNo") != L"") |
| | | { |
| | | alert(L"产品已被应用,不能删除"); |
| | | return 1; |
| | | } |
| | | dw_goods.DeleteRow(0); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmBOMSchema") |
| | | { |
| | | OpenWindow(L"dev:xpage[ProductSchema.vx]", 0); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmProductDesc") |
| | | { |
| | | xaserverarg arg2; |
| | | |
| | | int row2 = dw_goods.GetRow(); |
| | | if (row2 < 1) return 0; |
| | | xstring str2 = dw_goods.GetItemString(row2, L"ProductDesc"); |
| | | arg2.AddArg(L"value", str2); |
| | | OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg2); |
| | | if (arg2.GetArgString(L"comdid") == L"xmOK") |
| | | { |
| | | str2 = arg2.GetArgString(L"value"); |
| | | dw_goods.AcceptText(); |
| | | dw_goods.SetItemString(row2, L"ProductDesc", str2); |
| | | dw_goods.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmReSeqNo") |
| | | { |
| | | if (MessageBox(GetHWND(), L"是否重置序号!", L"提示1", 1) == 2) |
| | | return 1; |
| | | return ReSeqNo(L"SeqNo"); |
| | | } |
| | | else if (comdid == L"xmAddRow") |
| | | { |
| | | int nRow = dw_goods.InsertRow(0); |
| | | SetSeqNo(dw_goods, L"SeqNo", nRow); |
| | | dw_goods.SetItemString(nRow, L"UOMCode", L"007"); |
| | | dw_goods.SetItemDisplayString(nRow, L"UOMCode", L"PCS"); |
| | | dw_goods.SetItemString(nRow, L"KOPCode", L"120"); |
| | | dw_goods.SetItemDisplayString(nRow, L"KOPCode", L"CTNS"); |
| | | |
| | | xaserverarg arg3; |
| | | arg3.setNativePointer(arg3.CreateInstance()); |
| | | int row3 = dw_goods.GetRow(); |
| | | if (row3 < 1) return 0; |
| | | dw_goods.SetItemString(nRow, L"SKUNo", dw_goods.GetItemString(row3, L"SKUNo")); |
| | | dw_goods.SetItemString(nRow, L"ItemID", dw_goods.GetItemString(row3, L"ItemID")); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmClose") |
| | | { |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | else if (comdid.find(L"ImportXml:", 0) == 0) |
| | | { |
| | | xstring strImport = comdid.mid(((xstring)L"ImportXml:").length(), 9999); |
| | | |
| | | ImportProductByText(strImport); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmAskGoodsNo") |
| | | { |
| | | return OnAskGoodsNo(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int OnImgDBClicked(TEvent* evt, int pr) |
| | | { |
| | | IMGNNMHDR& nmtv = *(IMGNNMHDR*)evt->notify.pnmh; |
| | | xstring src = nmtv.path; |
| | | /*if(src.length() > 60) |
| | | src = src.right(44); |
| | | else |
| | | src=src.mid(src.find(L"Thumbs", 0)+6, 50); |
| | | */ |
| | | xaserverarg& arg = *new xaserverarg; |
| | | |
| | | //arg.AddArg(L"src",L"/business/products/chanpin"+src); |
| | | arg.AddArg(L"src", src); |
| | | |
| | | //win::OpenWindow(L"dev:xpage[BigPicture.vx]",arg); |
| | | |
| | | int h = openUrl(L"/sale/view/ProductLibrary/xpage/bigpictureview", &arg); |
| | | return 1; |
| | | /* |
| | | xwin x = new xwin; |
| | | x.setNativePointer(h); |
| | | m_winHwnd = x.GetHWND(); |
| | | |
| | | xstring sh = doc.xml(); |
| | | int p = cast(sh as int); |
| | | win32::SendMessage(m_winHwnd, 0x401, p, 0); |
| | | */ |
| | | return 1; |
| | | } |
| | | |
| | | //命令处理事件 |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnItemAskStyle(TEvent* evt, int p) |
| | | { |
| | | DWASKSTYLENMHDR& hdr = *(DWASKSTYLENMHDR*)evt->notify.pnmh; |
| | | int DMS_CSSSTYLE = 0x8; |
| | | int row = hdr.row; |
| | | int col = hdr.col; |
| | | xstring colname = hdr.colname; |
| | | |
| | | int rows = dw_goods.GetRowCount(); |
| | | if (row < 1 || row > rows) |
| | | { |
| | | return 1; |
| | | } |
| | | if (colname == L"POPrice") |
| | | { |
| | | if (dw_goods.GetItemTipString(row, colname) != L"") |
| | | { |
| | | hdr.mask = DMS_CSSSTYLE; |
| | | hdr.pCssStyle = (LPTSTR)L"color:#cc0000"; |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&EnquiryMaintView::OnXCommand); |
| | | //获取焦点事件,用于重置工具条 |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&EnquiryMaintView::OnSetFocus); |
| | | AttachEvent(L"dw_goods", L"DWV_ITEMCHANGED", (FEvent)&EnquiryMaintView::OnItemChanged); |
| | | AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", (FEvent)&EnquiryMaintView::OnBaseItemChanged); |
| | | AttachEvent(L"im1", L"IMG_LDBCLICK", (FEvent)&EnquiryMaintView::OnImgDBClicked); |
| | | AttachEvent(L"dw_goods", L"DWV_ROWFOCUSCHANGED", (FEvent)&EnquiryMaintView::OnRowChanged); |
| | | AttachCloseWindow(); |
| | | AttachEvent(L"dw_goods", L"DWV_ASKSTYLE", (FEvent)&EnquiryMaintView::OnItemAskStyle); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnRetrieve(xstring id) |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"id", id); |
| | | if (getUrl(L"/sale/data/Enquiry/maint", arg.GetString(), x) != 1) |
| | | { |
| | | alert(x.text()); |
| | | 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") |
| | | else |
| | | { |
| | | alert(msg.selectSingleNode(L"@errInfo").text()); |
| | | //alert(x.xml()); |
| | | dw_base.Retrieve(x); |
| | | dw_goods.Retrieve(x); |
| | | dw_base.Redraw(); |
| | | dw_goods.Redraw(); |
| | | |
| | | if (dw_goods.GetRowCount() > 0) |
| | | { |
| | | ximageview im = GetControl(L"im1"); |
| | | im.Reset(); |
| | | xstring skuno = dw_goods.GetItemString(1, L"SKUNo"); |
| | | OnShowImage(skuno, 1); |
| | | im.Redraw(); |
| | | } |
| | | |
| | | //x.LoadXml(L"<Enquiry/>"); |
| | | //dw_base.RetrieveDiff(x); |
| | | //dw_goods.RetrieveDiff(x); |
| | | |
| | | //dw_goods.SetItemTipString(1,L"POPrice",L"21.4 2018/07/08\r\n23.4 2018/07/12"); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int Oncopy(xstring EnquiryID, xstring ItemID) |
| | | { |
| | | xaserverarg arg; |
| | | |
| | | |
| | | |
| | | dw_base.SetItemString(1, L"ValidDay", arg.GetArgString(L"ValidDay")); |
| | | dw_base.SetItemString(1, L"SONo", arg.GetArgString(L"SONo")); |
| | | dw_base.SetItemString(1, L"Remark", arg.GetArgString(L"Remark")); |
| | | dw_base.SetItemString(1, L"Source", arg.GetArgString(L"Source")); |
| | | dw_base.SetItemString(1, L"PayTerm", arg.GetArgString(L"PayTerm")); |
| | | dw_base.SetItemString(1, L"SupplierID", arg.GetArgString(L"SupplierID")); |
| | | dw_base.SetItemDisplayString(1, L"SupplierID", arg.GetArgString(L"SupplierID/@_displaystring")); |
| | | dw_base.SetItemString(1, L"CustomerContactName", arg.GetArgString(L"CustomerContactName")); |
| | | dw_base.SetItemString(1, L"ContactTel", arg.GetArgString(L"ContactTel")); |
| | | |
| | | xstring sdate = publiccode::GetCurrentDate(); |
| | | dw_base.SetItemString(1, L"EnquiryDate", sdate); |
| | | xstring suserid = publiccode::GetUser().id; |
| | | xstring susername = publiccode::GetUser().name; |
| | | dw_base.SetItemString(1, L"SalespersonID", suserid); |
| | | dw_base.SetItemDisplayString(1, L"SalespersonID", susername); |
| | | dw_base.SetItemString(1, L"CompanyID", L"E9E3C542-062C-4957-B8F4-9B92C3E351FC"); |
| | | dw_base.SetItemDisplayString(1, L"CompanyID", L"宁波家尔佳进出口有限公司"); |
| | | |
| | | //xml x = QuoteView::Oncopy(EnquiryID,ItemID); |
| | | |
| | | xml x = ViewObject::RetrieveData(L"/sale/data/Enquiry/Oncopy", L"EnquiryID", EnquiryID, L"ItemID", ItemID); |
| | | if (!x) return 1; |
| | | //alert(x.xml()); |
| | | KXMLDOMNodeList items = x.selectNodes(L"/Enquiry/Item"); |
| | | int len = items.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | |
| | | KXMLDOMElement e = items.item(i); |
| | | dw_goods.InsertRow(i); |
| | | |
| | | int nRow = dw_goods.GetRow(); |
| | | |
| | | SetSeqNo(dw_goods, L"SeqNo", nRow); |
| | | dw_goods.SetItemString(nRow, L"UOMCode", L"007"); |
| | | dw_goods.SetItemDisplayString(nRow, L"UOMCode", L"PCS"); |
| | | dw_goods.SetItemString(nRow, L"KOPCode", L"120"); |
| | | dw_goods.SetItemDisplayString(nRow, L"KOPCode", L"CTNS"); |
| | | if (e.selectSingleNode(L"ItemName"))dw_goods.SetItemString(nRow, L"ItemName", e.selectSingleNode(L"ItemName").text()); |
| | | if (e.selectSingleNode(L"GoodsNo"))dw_goods.SetItemString(nRow, L"GoodsNo", e.selectSingleNode(L"GoodsNo").text()); |
| | | if (e.selectSingleNode(L"SKUNo"))dw_goods.SetItemString(nRow, L"SKUNo", e.selectSingleNode(L"SKUNo").text()); |
| | | if (e.selectSingleNode(L"ItemMiniQty"))dw_goods.SetItemString(nRow, L"ItemMiniQty", e.selectSingleNode(L"ItemMiniQty").text()); |
| | | if (e.selectSingleNode(L"Picture"))dw_goods.SetItemString(nRow, L"Picture", e.selectSingleNode(L"Picture").text()); |
| | | if (e.selectSingleNode(L"ItemID"))dw_goods.SetItemString(nRow, L"ItemID", e.selectSingleNode(L"ItemID").text()); |
| | | if (e.selectSingleNode(L"ProductDesc"))dw_goods.SetItemString(nRow, L"ProductDesc", e.selectSingleNode(L"ProductDesc").text()); |
| | | if (e.selectSingleNode(L"Packing"))dw_goods.SetItemString(nRow, L"Packing", e.selectSingleNode(L"Packing").text()); |
| | | if (e.selectSingleNode(L"POPrice"))dw_goods.SetItemString(nRow, L"POPrice", e.selectSingleNode(L"POPrice").text()); |
| | | if (e.selectSingleNode(L"PriceType"))dw_goods.SetItemString(nRow, L"PriceType", e.selectSingleNode(L"PriceType").text()); |
| | | if (e.selectSingleNode(L"InnerQty"))dw_goods.SetItemString(nRow, L"InnerQty", e.selectSingleNode(L"InnerQty").text()); |
| | | if (e.selectSingleNode(L"PackingRate"))dw_goods.SetItemString(nRow, L"PackingRate", e.selectSingleNode(L"PackingRate").text()); |
| | | if (e.selectSingleNode(L"VolumeDesc"))dw_goods.SetItemString(nRow, L"VolumeDesc", e.selectSingleNode(L"VolumeDesc").text()); |
| | | if (e.selectSingleNode(L"SampleFee"))dw_goods.SetItemString(nRow, L"SampleFee", e.selectSingleNode(L"SampleFee").text()); |
| | | if (e.selectSingleNode(L"TestFee"))dw_goods.SetItemString(nRow, L"TestFee", e.selectSingleNode(L"TestFee").text()); |
| | | if (e.selectSingleNode(L"ModelFee"))dw_goods.SetItemString(nRow, L"ModelFee", e.selectSingleNode(L"ModelFee").text()); |
| | | if (e.selectSingleNode(L"BOMPartNo"))dw_goods.SetItemString(nRow, L"BOMPartNo", e.selectSingleNode(L"BOMPartNo").text()); |
| | | if (e.selectSingleNode(L"ModifyDate"))dw_goods.SetItemString(nRow, L"ModifyDate", e.selectSingleNode(L"ModifyDate").text()); |
| | | |
| | | if (e.selectSingleNode(L"EnquiryDate"))dw_goods.SetItemString(nRow, L"EnquiryDate", e.selectSingleNode(L"EnquiryDate").text()); |
| | | if (e.selectSingleNode(L"EnquiryPriceListID"))dw_goods.SetItemString(nRow, L"EnquiryPriceListID", e.selectSingleNode(L"EnquiryPriceListID").text()); |
| | | if (e.selectSingleNode(L"RelEnquiryLineID"))dw_goods.SetItemString(nRow, L"RelEnquiryLineID", e.selectSingleNode(L"RelEnquiryLineID").text()); |
| | | if (e.selectSingleNode(L"PirorEnquiryLineID"))dw_goods.SetItemString(nRow, L"PirorEnquiryLineID", e.selectSingleNode(L"PirorEnquiryLineID").text()); |
| | | if (e.selectSingleNode(L"RealEnquiryLineID"))dw_goods.SetItemString(nRow, L"RealEnquiryLineID", e.selectSingleNode(L"RealEnquiryLineID").text()); |
| | | if (e.selectSingleNode(L"category"))dw_goods.SetItemString(nRow, L"category", e.selectSingleNode(L"category").text()); |
| | | |
| | | |
| | | if (dw_goods.GetItemString(nRow, L"VolumeDesc") != L"" && |
| | | dw_goods.GetItemString(nRow, L"Packages") != L"") |
| | | { |
| | | int qty = EvalQtyPerFCL45H(nRow); |
| | | dw_goods.SetItemString(nRow, L"Packages45H", xstring(qty)); |
| | | dw_goods.SetItemDouble(nRow, L"TransportationFee", 5000.0 / qty); |
| | | } |
| | | |
| | | } |
| | | return 1; |
| | | } |
| | | int OnInit() |
| | | { |
| | | //公司抬头、报价人、报价日期 |
| | | xstring sdate = publiccode::GetCurrentDate(); |
| | | dw_base.SetItemString(1, L"EnquiryDate", sdate); |
| | | xstring suserid = publiccode::GetUser().id; |
| | | xstring susername = publiccode::GetUser().name; |
| | | dw_base.SetItemString(1, L"SalespersonID", suserid); |
| | | dw_base.SetItemDisplayString(1, L"SalespersonID", susername); |
| | | dw_base.SetItemString(1, L"CompanyID", L"E9E3C542-062C-4957-B8F4-9B92C3E351FC"); |
| | | dw_base.SetItemDisplayString(1, L"CompanyID", L"宁波家尔佳进出口有限公司"); |
| | | return 1; |
| | | } |
| | | |
| | | /* |
| | | pricebill: one of enquiry pricebill quote pricebill |
| | | */ |
| | | int RetrieveItemList(xstring items, xstring pricebill = L"") |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"ItemList", items); |
| | | //alert(items); |
| | | xstring dataurl = L"/sale/data/Enquiry/maint/items"; |
| | | if (pricebill == L"pricebill") dataurl = L"/sale/data/Enquiry/maint/pricelist/items"; |
| | | if (pricebill == L"quote") dataurl = L"/sale/data/Enquiry/FetchItemListByQuoteItemID"; |
| | | if (getUrl(dataurl, arg.GetString(), x) != 1) |
| | | { |
| | | alert(x.text()); |
| | | return -1; |
| | | } |
| | | 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); |
| | | //trace(L"*****" + x.xml() + L"*****"); |
| | | dw_goods.Retrieve(x); |
| | | dw_goods.Redraw(); |
| | | ReSeqNo(L"SeqNo"); |
| | | |
| | | |
| | | 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""); |
| | | if (dw_goods.GetRowCount() > 0) |
| | | { |
| | | if (dw_goods.GetItemString(1, L"customerno")) |
| | | { |
| | | dw_base.SetItemString(1, L"CustomerNo", dw_goods.GetItemString(1, L"customerno")); |
| | | } |
| | | ximageview im = GetControl(L"im1"); |
| | | im.Reset(); |
| | | xstring skuno = dw_goods.GetItemString(1, L"SKUNo"); |
| | | OnShowImage(skuno, 1); |
| | | im.Redraw(); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | if (comdid == L"action:bill.Annex") |
| | | |
| | | int onload() |
| | | { |
| | | 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")); |
| | | SetArg(); |
| | | dw_goods = GetControl(L"dw_goods"); |
| | | //dw_goods .openUrl(L"/sale/view/Enquiry3/template/goods"); |
| | | dw_goods.openUrl(L"/sale/view/Enquiry3/template/item/pricelist"); |
| | | dw_goods.SetColumnState(L"ItemID", false); |
| | | //dw_goods.SetColumnState(L"Picture",false); |
| | | dw_goods.SetColumnState(L"category", false); |
| | | dw_goods.SetColumnState(L"RealEnquiryLineID", false); |
| | | dw_goods.SetColumnState(L"RelEnquiryLineID", false); |
| | | dw_goods.SetColumnState(L"BOMPartNo", false); |
| | | |
| | | OpenWindow(L"dev:xpage[maint.Document.Supplier.v3.vx]", (LPARAM)&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")); |
| | | dw_base = GetControl(L"dw_base"); |
| | | |
| | | //OpenWindow(L"dev:xpage[maint.Document.Customer.v3.vx]", p4); |
| | | OpenWindow(L"dev:xpage[maint.Document.SupplierSD.v3.vx]", (LPARAM)&arg4); |
| | | 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) |
| | | if (GetWinParam()) |
| | | { |
| | | TypeWork = supplier_x.text(); |
| | | xaserverarg arg=GetArg(); |
| | | |
| | | |
| | | if (TypeWork.find(L"采购") >= 0) |
| | | sheetname = arg.GetArgString(L"sheetname"); |
| | | if (sheetname == L"tab_list2") |
| | | { |
| | | dw_base.openUrl(L"/sale/view/Enquiry3/template/base2"); |
| | | //dw_base.SetItemString(1,L"Source",L"客户询价"); |
| | | dw_goods.SetColumnState(L"SupplierID", true); |
| | | } |
| | | else |
| | | { |
| | | |
| | | 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); |
| | | dw_base.openUrl(L"/sale/view/Enquiry3/template/base"); |
| | | //dw_base.SetItemString(1,L"Source",L"客户询价"); |
| | | dw_goods.SetColumnState(L"SupplierID", false); |
| | | } |
| | | dw_base.SetColHeaderHeight(0); |
| | | dw_base.SetRowSelectorWidth(0); |
| | | dw_base.SetHScrollState(false); |
| | | dw_base.SetVScrollState(false); |
| | | |
| | | xstring EnquiryNo = arg.GetArgString(L"EnquiryNo"); |
| | | xstring EnquiryID = arg.GetArgString(L"EnquiryID"); |
| | | xstring ItemID = arg.GetArgString(L"ItemID"); |
| | | if (EnquiryNo == L"") EnquiryNo = arg.GetArgString(L"EntityNo"); |
| | | if (EnquiryNo != L"") |
| | | { |
| | | OnRetrieve(EnquiryNo); |
| | | |
| | | } |
| | | else if (EnquiryID != L"") { |
| | | Oncopy(EnquiryID, ItemID); |
| | | } |
| | | else |
| | | { |
| | | OnInit(); |
| | | |
| | | if (arg.GetArgString(L"CustomerID") != L"") |
| | | { |
| | | dw_base.SetItemDisplayString(1, L"SupplierID", arg.GetArgString(L"CustomerName")); |
| | | dw_base.ItemChangeTo(1, L"SupplierID", arg.GetArgString(L"CustomerID")); |
| | | xstring dwname = L"dw_base"; |
| | | xstring colname = L"SupplierID"; |
| | | xstring value = arg.GetArgString(L"CustomerID"); |
| | | KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='" + dwname + L"']/trans[@for='" + colname + L"']"); |
| | | ViewObject::TransData(nlist, dw_base, 1, colname, value); |
| | | } |
| | | |
| | | if (arg.GetArgString(L"EntityIDList") != L"") |
| | | { |
| | | RetrieveItemList(arg.GetArgString(L"EntityIDList"), arg.GetArgString(L"Source")); |
| | | } |
| | | |
| | | } |
| | | } |
| | | else |
| | | OnInit(); |
| | | |
| | | OnAttachEvent(); |
| | | |
| | | dw_base.SetEditUpperMode(true); |
| | | dw_goods.SetEditUpperMode(true); |
| | | dw_goods.SetAskStyle(true); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | |
| | | int onloaded() |
| | | { |
| | | AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&listSupplierv3::OnRowChangedEx); |
| | | |
| | | 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; |
| | | } |
| | | |
| | | }; |
| | | return 1; |
| | | } |
| | | }; |