þÿ#include <wobject/xstring.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include <wobject/xdouble.hpp> #include <xcontrol/xlayersheet.hpp> #include <xcontrol/xdatetimepick.hpp> #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" #include <xcontrol/xexcel.hpp> #include <win32/xfile.hpp> using xml = KXMLDOMDocument; class __declspec(dllexport) SalaryslipList : public xframe { public: xdwgrid dw_list; xdatetimepick sdate; xdatetimepick edate; xnode m_agentNode; //Agent Condition public: SalaryslipList(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static SalaryslipList* CreateInstance(void* implPtr, void* hWnd) { SalaryslipList* pWin = new SalaryslipList(implPtr, (HWND)hWnd); return pWin; } int SetAgent() { xstring xfNodeAgentArea = L"agentarea"; xnode anode = GetAgentNode(xfNodeAgentArea); if (m_agentNode) { SetAgentNode(anode, m_agentNode); } else { KXMLDOMElement xframeElement = GetElement(); KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*"); if (agent) { xstring s = agent.xml(); m_agentNode = SetAgentNode(anode, s); } } return 1; } //q&p¹oÀm;YtQýep int OnSetFocus(TEvent* evt, LPARAM param) { //‘Ín]åQwga SetAgent(); return 1; } xstring GetOpenFileName(xstring initFileName, const string filter, xstring ext) { //xstring path = GetOpenFileName(L"", // "JPEG e‡Nö(*.jpg)\0*.jpg;*.jpeg;*.png;*.gif;*.bmp\0Qhèe‡Nö(*.*)\0*.*\0", // "jpg"); wchar_t szFileName[4096]; wchar_t szPath[4096]; szFileName[0] = 0; szPath[0] = 0; if (initFileName != L"") { int len = initFileName.length(); const wchar_t* tmp = initFileName.c_str(); for (int i = 0; i < len + 1; i++) { szPath[i] = tmp[i]; } } int nFilterIndex = 1; OPENFILENAMEW ofn; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = 0; ofn.hInstance = 0; ofn.lpstrFilter = filter; //"JPEG e‡Nö(*.jpg)\0*.jpg;*.jpeg;*.png;*.gif;*.bmp\0Qhèe‡Nö(*.*)\0*.*\0"; ofn.lpstrCustomFilter = 0; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = nFilterIndex; ofn.lpstrFile = szPath; ofn.nMaxFile = 4096; ofn.lpstrFileTitle = szFileName; ofn.nMaxFileTitle = 4096; ofn.lpstrTitle = L"‹÷c[še‡NöT "; ofn.lpstrDefExt = ext; //"jpg"; ofn.lpstrInitialDir = 0; ofn.Flags = 0x00001000/*OFN_FILEMUSTEXIST*/| 0x00080000 /*OFN_EXPLORER*/; ofn.lCustData = 0; ofn.lpfnHook = 0; ofn.lpTemplateName = 0; ofn.nFileOffset = 0; ofn.nFileExtension = 0; //debugbreak(); if (xfile::GetOpenFileName(ofn)) { return szPath; } else return L""; } int OnImport() { xstring file = GetOpenFileName(L"", L"Excel1e‡Nö(*.xlsx)\0*.xlsx;*.xls\0Excel97e‡Nö(*.xls)\0*.xls\0PDFe‡Nö(*.pdf)\0*.pdf\0", L"xlsx"); if (file == L"") return 1; xexcel excel; if (!excel.GetNativePtr()) { alert(L"N €ýÞc¥Excel"); return 1; } excel.OpenDocument(file); excel.put_Visible(true); int rows = excel.GetValidRow(); int cols = excel.GetValidColumn(); BSTR val = excel.GetCellString(1, 1); SysFreeString(val); excel.Quit(); return 1; } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { HCURSOR hCursor = 0; if (comdid == L"xmSearch") { OnRetrieve(); } else if (comdid == L"xmAdd") { xaserverarg arg; arg.AddArg(L"HWND", xstring((__int64)GetHWND())); OpenWindow(L"dev:xpage[maint.salaryslip.vx]", arg); } else if (comdid == L"xmEdit") { xaserverarg arg; xstring SalaryslipID = dw_list.GetGuid(dw_list.GetRow()); arg.AddArg(L"SalaryslipID", SalaryslipID); arg.AddArg(L"HWND", xstring((__int64)GetHWND())); OpenWindow(L"dev:xpage[maint.salaryslip.vx]", arg); return 1; } else if (comdid == L"xmDelete") { xstring SalaryslipNo = dw_list.GetItemString(1, L"SalaryslipNo").trim(); xstring EntityID = dw_list.GetGuid(dw_list.GetRow()); int MB_OKCANCEL = 1; int IDOK = 1; int ret = MessageBox(GetHWND(), L"xn‹¤R –d]åD" + SalaryslipNo + L"?", L"cÐy:", MB_OKCANCEL); if (ret == IDOK) { ViewObject::RetrieveData(L"/sale/data/expense3/delete/salaryslip", L"EntityID", EntityID); OnRetrieve(); } return 1; } else if (comdid == L"xmRefresh") { OnRetrieve(); return 1; } else if (comdid == L"xmImport") { OnImport(); return 1; } else if (comdid == L"xmAnalysis") { hCursor = xutil::SetCursorWait(); xstring str = dw_list.DataAnalysis(L""); xaserverarg arga; arga.AddArg(L"html", str); OpenWindow(L"dev:xpage[data.vanalysis.vx]", arga); xutil::RestoreCursor(hCursor); return 1; } return 0; } int OnDoubleClicked(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname = hdr.colname; int row = hdr.row; HCURSOR hCursor = xutil::SetCursorWait(); xaserverarg arg; xstring SalaryslipID = dw_list.GetGuid(row); arg.AddArg(L"SalaryslipID", SalaryslipID); OpenWindow(L"dev:xpage[maint.salaryslip.vx]", arg); xutil::RestoreCursor(hCursor); return 1; } //T}NäYtN‹Nö int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnAttachEvent() { //~Ñ[š]åQwgap¹QûN‹Nö AttachEvent(L"WM_XCOMMAND", (FEvent)&SalaryslipList::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&SalaryslipList::OnSetFocus); AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&SalaryslipList::OnDoubleClicked); return 1; } int OnRetrieve() { xml x ; xaserverarg arg; xstring sdatetxt = L""; xstring edatetxt = L""; if (sdate.IsChecked()) sdatetxt = sdate.GetText(); if (edate.IsChecked()) edatetxt = edate.GetText(); xcontrol query = GetControl(L"sl_search"); xstring keyword = query.GetText(); arg.AddArg(L"keyword", keyword); arg.AddArg(L"sdate", sdatetxt); arg.AddArg(L"edate", edatetxt); HCURSOR hCursor = xutil::SetCursorWait(); if (getUrl(L"/sale/data/expense3/view/salaryslip", arg.GetString(), x) != 1) { trace(x.text()); return -1; } else { dw_list.Retrieve(x); dw_list.Redraw(); dw_list.SetReadOnly(true); } xutil::RestoreCursor(hCursor); return 1; } int onload() { sdate = GetControl(L"sdate"); edate = GetControl(L"edate"); dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/expense3/Salaryslip/list"); xstring currdate = publiccode::GetCurrentDate(); int curryear = currdate.mid(0, 4).toInt(); sdate.SetDatetime(curryear - 1, 1, 1); OnAttachEvent(); OnRetrieve(); dw_list.SetReadOnly(true); return 1; } int onloaded() { SetAgent(); return 1; } };