| | |
| | | #include <xcontrol/xlayersheet.hpp> |
| | | |
| | | #include "vbusiness/vframe/maint.vframe.vbusiness.hpp" |
| | | #include "vbusiness/vframe/maint.vframe.vbusiness.hpp" |
| | | #include "vbusiness/vframe/responsewin.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | |
| | | class __declspec(dllexport) TemplatePrintDialog : public responsewin |
| | | DeclWinObject_(TemplatePrintDialog, responsewin) |
| | | { |
| | | CreateWinObject_(TemplatePrintDialog, responsewin) |
| | | |
| | | public: |
| | | xaserverarg arg_param; |
| | | xstring m_EntityName; |
| | | xstring m_EntityID; |
| | | xstring m_EntityNo; |
| | | xstring m_Dir; |
| | | xstring m_filePath; |
| | | xstring strNode; |
| | | xdwgrid dw_list; |
| | | xdwgrid dw_doclist; |
| | | xole ole_1; |
| | | bool bupdate; |
| | | xaserverarg arg_param; |
| | | xstring m_EntityName; |
| | | xstring m_EntityID; |
| | | xstring m_EntityNo; |
| | | xstring m_Dir; |
| | | xstring m_filePath; |
| | | xstring strNode; |
| | | xdwgrid dw_list; |
| | | xdwgrid dw_doclist; |
| | | bool bupdate; |
| | | public: |
| | | TemplatePrintDialog(void* implPtr, HWND hWnd) :maint(implPtr, hWnd) {} |
| | | TemplatePrintDialog(void* implPtr, HWND hWnd) :responsewin(implPtr, hWnd) {} |
| | | public: |
| | | static TemplatePrintDialog* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | TemplatePrintDialog* pWin = new TemplatePrintDialog(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | return new TemplatePrintDialog(implPtr, (HWND)hWnd); |
| | | } |
| | | int OnHtml() |
| | | public: |
| | | int OnRetrieve() |
| | | { |
| | | xstring username = publiccode::GetUser()->name; |
| | | if (username != L"admin" && m_Dir != username) |
| | | { |
| | | xstring s1=L"<catalog>"+ |
| | | " <book id='bk101'>"+ |
| | | " <author>Gambardella, Matthew</author>"+ |
| | | " <title>XML Developer's Guide</title>"+ |
| | | " <genre>Computer</genre>"+ |
| | | " <price>44.95</price>"+ |
| | | " <publish_date>2000-10-01</publish_date>"+ |
| | | " <description>An in-depth look at creating applications "+ |
| | | " with XML.</description>"+ |
| | | " </book>"+ |
| | | " <book id='bk102'>"+ |
| | | " <author>Ralls, Kim</author>"+ |
| | | " <title>Midnight Rain</title>"+ |
| | | " <genre>Fantasy</genre>"+ |
| | | " <price>5.95</price>"+ |
| | | " <publish_date>2000-12-16</publish_date>"+ |
| | | " <description>A former architect battles corporate zombies, L"+ |
| | | " an evil sorceress, and her own childhood to become queen "+ |
| | | " of the world.</description>"+ |
| | | " </book>"+ |
| | | " </catalog>"; |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | x.LoadXml(s1); |
| | | //trace(x.GetXml()); |
| | | bupdate = false; |
| | | } |
| | | else |
| | | { |
| | | bupdate = true; |
| | | } |
| | | xml x; |
| | | |
| | | //xstring s2=L"<?xml version='1.0'?>"+ |
| | | xstring s2= |
| | | "<xsl:stylesheet version='1.0'"+ |
| | | " xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >"+ |
| | | "<xsl:output method='xml' indent='yes'/>"+ |
| | | "<xsl:template match='catalog'>"+ |
| | | "<HTML>"+ |
| | | " <HEAD>"+ |
| | | " <TITLE>Books catalog - listing for Books.xml</TITLE>"+ |
| | | " </HEAD>"+ |
| | | " <BODY><FONT FACE='Verdana'>"+ |
| | | " <H3>My Books Catalog</H3>"+ |
| | | " <TABLE CELLPADDING='5' CELLSPACING='2'>"+ |
| | | " <xsl:for-each select='book'>"+ |
| | | " <TR>"+ |
| | | " <TD ALIGN='LEFT'><FONT SIZE='2'><B>ID:</B>  <xsl:value-of select='@id'/><BR/>"+ |
| | | " <B>Author:</B>  <xsl:value-of select='author'/><BR/>"+ |
| | | " <B>Title:</B>  <xsl:value-of select='title'/><BR/>"+ |
| | | " <B>Genre:</B>  <xsl:value-of select='genre'/><BR/>"+ |
| | | " <B>Price:</B>  <xsl:value-of select='price'/><BR/>"+ |
| | | " <B>Published on:</B>  <xsl:value-of select='publish_date'/><BR/>"+ |
| | | " <B>Description:</B>  <xsl:value-of select='description'/></FONT></TD>"+ |
| | | " </TR>"+ |
| | | " </xsl:for-each>"+ |
| | | "</TABLE>"+ |
| | | "</FONT>"+ |
| | | "</BODY>"+ |
| | | "</HTML>"+ |
| | | "</xsl:template>"+ |
| | | "</xsl:stylesheet>" ; |
| | | xml xsl = new xml; |
| | | xsl.setNativePointer(xml::CreateInstance()); |
| | | xsl.LoadXml(s2); |
| | | //trace(xsl.GetXml()); |
| | | xaserverarg arg; |
| | | |
| | | xstring strHtml = x.GetXmlDoc().transformNode(xsl.GetXmlDoc()); |
| | | //strHtml = str.mid(21,99999); |
| | | ole_1.LoadHtml(strHtml); |
| | | //html_1.SetContent(strHtml); |
| | | //alert(strHtml); |
| | | arg.AddArg(L"Entity", m_EntityName); |
| | | arg.AddArg(L"Dir", m_Dir); |
| | | dw_list.Reset(); |
| | | if (xurl::get(L"/sale/data/SysPrintTemplate/listDialog", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | xstring s = x.xml(); |
| | | dw_list.Retrieve(x); |
| | | } |
| | | dw_list.Redraw(); |
| | | //dw_list.SetReadOnly(true); |
| | | if (dw_list.GetRowCount() > 0) |
| | | dw_list.SelectRow(1, true); |
| | | return 1; |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int OnRetrieve() |
| | | { |
| | | xstring username = publiccode::GetUser().name; |
| | | if(username != L"admin" && m_Dir != username ) |
| | | { |
| | | bupdate = false; |
| | | }else |
| | | { |
| | | bupdate = true; |
| | | } |
| | | xml x; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"Entity",m_EntityName); |
| | | arg.AddArg(L"Dir",m_Dir); |
| | | dw_list.Reset(); |
| | | if (xurl::get(L"/sale/data/SysPrintTemplate/listDialog",arg.GetString(),x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | }else |
| | | { |
| | | xstring s = x.xml(); |
| | | dw_list.Retrieve(x); |
| | | } |
| | | dw_list.Redraw(); |
| | | //dw_list.SetReadOnly(true); |
| | | if (dw_list.GetRowCount()>0) |
| | | dw_list.SelectRow(1,true); |
| | | return 1; |
| | | } |
| | | |
| | | int OnNewTempl() |
| | | { |
| | | OpenWindow(L"dev:xpage[Maint.Template.Print.vx]"); |
| | | return 1; |
| | | } |
| | | |
| | | int OnMaintTempl() |
| | | { |
| | | int row = dw_list.GetRow(); |
| | | if(row<0 || row>dw_list.GetRowCount()) |
| | | { |
| | | alert(L"请选择要维护的模板!"); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring sguid = ele.selectSingleNode(L"ID").text(); |
| | | xstring sTemplName = ele.selectSingleNode(L"TemplName").text(); |
| | | //xstring sFile = m_filePath + sguid+L".xsl"; |
| | | xstring sFile = m_filePath + ele.selectSingleNode(L"urlPath").text(); |
| | | arg_param.AddArg(L"xsl",sFile); |
| | | arg_param.AddArg(L"return",L"cancel"); |
| | | |
| | | OpenWindow(L"dev:xpage[Maint.Template.Print.vx]",cast(arg_param.GetString() as int)); |
| | | CloseWindow(); |
| | | |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnAddDir() |
| | | { |
| | | return 0; |
| | | } |
| | | int OnAddTempl() |
| | | { |
| | | if (m_Dir==L"") |
| | | { |
| | | alert(L"请选择模板目录!"); |
| | | return 0; |
| | | } |
| | | xstring sguid = publiccode::GetGuid(); |
| | | xstring sname= sguid +L".xsl"; |
| | | xstring suri= L"rpttemplate"+L"\\"+m_EntityName; //rpttemplate\SO |
| | | //suri = L"supplier00"; |
| | | xstring ret = xaserver::UploadFile(suri, sname, this.GetHWND(),L"",false); |
| | | if (ret == L"-1") |
| | | { |
| | | alert(L"上传的文件没选择!"); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | xml x=new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | xaserverarg args = new xaserverarg; |
| | | args.setNativePointer(args.CreateInstance()); |
| | | args.AddArg(L"sID",sguid); |
| | | args.AddArg(L"sEntity",m_EntityName); |
| | | args.AddArg(L"sDir",m_Dir); |
| | | args.AddArg(L"urlPath", sname); |
| | | //alert(m_Dir); |
| | | while(ret.find(L"\\",0)>=0) |
| | | ret = ret.mid(ret.find(L"\\",0) + 1,9999); |
| | | |
| | | args.AddArg(L"sTemplName",ret); |
| | | //trace(args.GetString()); |
| | | if (url::get(L"/sale/data/SysPrintTemplate/Save",args.GetString(),x) != 1) |
| | | { |
| | | trace(L"error:"+x.GetXml()); |
| | | alert(L"保存出错了!"); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | alert(L"上传模板成功!"); |
| | | OnRetrieve(); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnDelTempl() |
| | | { |
| | | |
| | | int row = dw_list.GetRow(); |
| | | if(row<0 || row>dw_list.GetRowCount()) |
| | | { |
| | | alert(L"请选择要删除的模板!"); |
| | | return 0; |
| | | } |
| | | else |
| | | { |
| | | if (win32::MessageBox(GetHWND(),L"确定要删除选中的模板?",L"提示",1) == 2) |
| | | return 0; |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring sguid = ele.selectSingleNode(L"ID").text; |
| | | xml x=new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | xaserverarg args = new xaserverarg; |
| | | args.setNativePointer(args.CreateInstance()); |
| | | args.AddArg(L"sID",sguid); |
| | | if (url::get(L"/sale/data/SysPrintTemplate/Delete",args.GetString(),x) != 1) |
| | | { |
| | | trace(L"error:"+x.GetXml()); |
| | | alert(L"删除出错了!"); |
| | | return 0; |
| | | } |
| | | else |
| | | { |
| | | alert(L"删除成功!"); |
| | | OnRetrieve(); |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int OnDocListDoubleClicked(ref TNotifyEvent evt,int p) |
| | | { |
| | | int hCursor = xutil::SetCursorWait(); |
| | | OnOpenDocument(); |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDoubleClicked(ref TNotifyEvent evt,int p) |
| | | { |
| | | int hCursor = xutil::SetCursorWait(); |
| | | OnOk(); |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | int OnNewTempl() |
| | | { |
| | | OpenWindow(L"dev:xpage[Maint.Template.Print.vx]"); |
| | | return 1; |
| | | } |
| | | |
| | | int OnOpenDocument() |
| | | int OnMaintTempl() |
| | | { |
| | | int row = dw_list.GetRow(); |
| | | if (row<0 || row>dw_list.GetRowCount()) |
| | | { |
| | | if(dw_doclist.GetRowCount() < 1) return 1; |
| | | xstring documentid = dw_doclist.GetRowElement(dw_doclist.GetRow()).getAttribute(L"guid"); |
| | | //xstring billid = dw_docList |
| | | arg_param.AddArg(L"DocumentID",documentid); |
| | | arg_param.AddArg(L"return",L"ok"); |
| | | arg_param.AddArg(L"action",L"open"); |
| | | alert(L"请选择要维护的模板!"); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring sguid = ele.selectSingleNode(L"ID").text(); |
| | | xstring sTemplName = ele.selectSingleNode(L"TemplName").text(); |
| | | //xstring sFile = m_filePath + sguid+L".xsl"; |
| | | xstring sFile = m_filePath + ele.selectSingleNode(L"urlPath").text(); |
| | | arg_param.AddArg(L"xsl", sFile); |
| | | arg_param.AddArg(L"return", L"cancel"); |
| | | |
| | | OpenWindow(L"dev:xpage[Maint.Template.Print.vx]", arg_param); |
| | | CloseWindow(); |
| | | return 1; |
| | | |
| | | } |
| | | |
| | | int OnOk() |
| | | return 1; |
| | | } |
| | | |
| | | int OnAddDir() |
| | | { |
| | | return 0; |
| | | } |
| | | int OnAddTempl() |
| | | { |
| | | if (m_Dir == L"") |
| | | { |
| | | int row = dw_list.GetRow(); |
| | | if(row<0 || row>dw_list.GetRowCount()) |
| | | { |
| | | alert(L"请选择要打印的模板!"); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | trace(L"\r\n---------------"); |
| | | trace(ele.xml); |
| | | |
| | | xstring sguid = ele.selectSingleNode(L"ID").text; |
| | | xstring pre = L""; |
| | | if(ele.selectSingleNode(L"TemplPre")) pre = ele.selectSingleNode(L"TemplPre").text; |
| | | xstring sTemplName = ele.selectSingleNode(L"TemplName").text; |
| | | //xstring sFile = m_filePath + sguid+L".xsl"; |
| | | trace(sTemplName); |
| | | xstring sFile = m_filePath + ele.selectSingleNode(L"urlPath").text; |
| | | arg_param.AddArg(L"xsl",sFile); |
| | | arg_param.AddArg(L"return",L"ok"); |
| | | arg_param.AddArg(L"template-name",sTemplName); |
| | | arg_param.AddArg(L"template-guid",sguid); |
| | | arg_param.AddArg(L"template-pre",pre); |
| | | arg_param.AddArg(L"action",L"new"); |
| | | trace(arg_param.GetString()); |
| | | CloseWindow(); |
| | | /*xaserver::CreateDirectory(L"C:/Temp"); |
| | | int openRet = xaserver::DownLoadFile(GetServerUrl(),m_filePath+file,sTemplName,L"C:/Temp/"+sTemplName); |
| | | if(openRet < 0) |
| | | { |
| | | alert(L"文件打开失败!"); |
| | | return 0; |
| | | } |
| | | |
| | | int GENERIC_READ = 0x80000000; |
| | | int GENERIC_WRITE = 0x40000000; |
| | | int FILE_SHARE_READ = 0x00000001; |
| | | int FILE_SHARE_WRITE = 0x00000002; |
| | | int OPEN_EXISTING = 3; |
| | | int FILE_ATTRIBUTE_ARCHIVE =0x00000020; |
| | | int hFile = xwin::CreateFile(L"C:/Temp/"+sTemplName,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0); |
| | | if (hFile >0) |
| | | { |
| | | //int GMEM_MOVEABLE=0x0002; |
| | | //int GMEM_ZEROINIT=0x0040; |
| | | //int MEMSIZE; |
| | | //int hMemory = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,MEMSIZE); |
| | | //int pMemory = GlobalLock(hMemory); |
| | | //int SizeReadWrite; |
| | | //xwin::ReadFile(hFile,pMemory,MEMSIZE - 1,SizeReadWrite,0); |
| | | int filesize = xwin::GetFileSize(hFile,0); |
| | | trace(L"filesize = %d",filesize); |
| | | xstring buffer = L"".space(filesize+1); |
| | | int readsize = new int; |
| | | xwin::ReadFile(hFile,buffer,filesize,readsize,0); |
| | | trace(buffer); |
| | | xwin::CloseHandle(hFile); |
| | | //GlobalUnlock(pMemory); |
| | | //GlobalFree(hMemory); |
| | | } */ |
| | | /*openRet = xwin::ShellExecute(0,L"open",L"C:/Temp/"+sTemplName,L"",L"",5); |
| | | if(openRet < 32) |
| | | { |
| | | alert(L"文件打开失败2!"); |
| | | return 0; |
| | | }*/ |
| | | } |
| | | alert(L"请选择模板目录!"); |
| | | return 0; |
| | | } |
| | | |
| | | int OnSave() |
| | | xstring sguid = publiccode::GetGuid(); |
| | | xstring sname = sguid + L".xsl"; |
| | | xstring suri = L"rpttemplate\\" + m_EntityName; //rpttemplate\SO |
| | | //suri = L"supplier00"; |
| | | xstring ret = xaserver::UploadFile(suri, sname, GetHWND(), L"", false); |
| | | if (ret == L"-1") |
| | | { |
| | | dw_list.AcceptText(); |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | dw_list.DwUpdateAllToEx(x.GetXmlDoc()); |
| | | |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(xaserverarg::CreateInstance()); |
| | | arg.AddArg(L"content",x.GetXml()); |
| | | |
| | | if (url::get(L"/sale/data/SysPrintTemplate/updateinfo",arg.GetString(),x) != 1) |
| | | alert(L"上传的文件没选择!"); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | xml x; |
| | | xaserverarg args; |
| | | args.AddArg(L"sID", sguid); |
| | | args.AddArg(L"sEntity", m_EntityName); |
| | | args.AddArg(L"sDir", m_Dir); |
| | | args.AddArg(L"urlPath", sname); |
| | | //alert(m_Dir); |
| | | while (ret.find(L"\\", 0) >= 0) |
| | | ret = ret.mid(ret.find(L"\\", 0) + 1, 9999); |
| | | |
| | | args.AddArg(L"sTemplName", ret); |
| | | //trace(args.GetString()); |
| | | if (xurl::get(L"/sale/data/SysPrintTemplate/Save", args.GetString(), x) != 1) |
| | | { |
| | | trace(L"error:"+x.GetXml()); |
| | | trace((xstring)L"error:" + x.xml()); |
| | | alert(L"保存出错了!"); |
| | | return 1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | dw_list.ResetUpdateStatus(); |
| | | alert(L"保存成功!"); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int PreOnCmdDispatch(xstring comdid) |
| | | { |
| | | //返回0——不在执行以下代码;返回其他——执行以下代码。 |
| | | if(comdid.left(8) == L"xmPanel:"){ |
| | | xstring no = comdid.mid(8, 99); |
| | | //int id = no.toInt(); |
| | | |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | x.LoadXml(strNode); |
| | | KXMLDOMDocument doc= x.GetXmlDoc(); |
| | | KXMLDOMElement e = doc.documentElement; |
| | | xstring slable =e.selectSingleNode(L"//xtoolbutton[@name='"+comdid+L"']/@caption").text; |
| | | m_Dir = slable; |
| | | OnRetrieve(); |
| | | |
| | | return 1; |
| | | } |
| | | if (comdid==L"xmAddDir") return OnAddDir(); |
| | | if (comdid==L"xmAddTempl" && bupdate) return OnAddTempl(); |
| | | if (comdid==L"xmDelTempl" && bupdate) return OnDelTempl(); |
| | | if (comdid==L"xmMaintTempl" && bupdate) return OnMaintTempl(); |
| | | if (comdid==L"xmNewTempl" && bupdate) return OnNewTempl(); |
| | | if (comdid==L"xmHtml") return OnHtml(); |
| | | if (comdid==L"xmOk") return OnOk(); |
| | | if (comdid==L"xmSave") return OnSave(); |
| | | if(comdid==L"xmOpen") return OnOpenDocument(); |
| | | else if (comdid==L"xmCancel") |
| | | { |
| | | arg_param.AddArg(L"return",L"cancel"); |
| | | CloseWindow(); |
| | | return 1; |
| | | alert(L"上传模板成功!"); |
| | | OnRetrieve(); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnDelTempl() |
| | | { |
| | | |
| | | int row = dw_list.GetRow(); |
| | | if (row<0 || row>dw_list.GetRowCount()) |
| | | { |
| | | alert(L"请选择要删除的模板!"); |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | int PostOnAttachEvent() |
| | | else |
| | | { |
| | | //AttachEvent(L"dw_list",L"DWV_ROWFOCUSCHANGED",OnRowChanged); |
| | | //AttachEvent(L"dw_list",L"DWV_CLICKED",OnClicked); |
| | | //AttachEvent(L"dw_list",L"DWV_RCLICKED",OnRClicked); |
| | | //AttachEvent(L"dw_list",L"DWV_ITEMCHANGED",OnItemChanged); |
| | | //AttachEvent(L"dw_list",L"DWV_CHILDCONTENT",OnChildContent); |
| | | AttachEvent(L"dw_doclist",L"DWV_DOUBLECLICKED",OnDocListDoubleClicked); |
| | | AttachEvent(L"dw_list",L"DWV_DOUBLECLICKED",OnDoubleClicked); |
| | | return 1; |
| | | } |
| | | |
| | | int SetAgent() |
| | | { |
| | | PUser puser = new PUser; |
| | | puser = publiccode::GetUser(); |
| | | xstring susername = puser.name; |
| | | if (susername !=L"admin") |
| | | if (MessageBox(GetHWND(), L"确定要删除选中的模板?", L"提示", 1) == 2) |
| | | return 0; |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring sguid = ele.selectSingleNode(L"ID").text(); |
| | | xml x; |
| | | xaserverarg args; |
| | | args.AddArg(L"sID", sguid); |
| | | if (xurl::get(L"/sale/data/SysPrintTemplate/Delete", args.GetString(), x) != 1) |
| | | { |
| | | xstring xfNodeAgentArea = L"DirButton"; |
| | | xnode anode = GetAgentNode(xfNodeAgentArea); |
| | | KXMLDOMElement xframeElement = GetElement(); |
| | | xstring tools=L"<vbox name='DirButton' height='48' />"; |
| | | SetAgentNode(anode, tools); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int CreateDir() |
| | | { |
| | | PUser puser = new PUser; |
| | | puser = publiccode::GetUser(); |
| | | xstring susername = puser.name; |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg(L"EntityName",m_EntityName,L""); |
| | | arg.AddArg(L"EntityID",m_EntityID,L""); |
| | | arg.AddArg(L"susername",susername,L""); // |
| | | if (url::get(L"/sale/data/SysPrintTemplate/Dir",arg.GetString(),x) != 1) |
| | | { |
| | | trace(x.GetXmlDoc().text); |
| | | return -1; |
| | | }else |
| | | { |
| | | xstring s = x.GetXml(); |
| | | } |
| | | KXMLDOMNodeList nlist = x.GetXmlDoc().selectNodes(L"//Entity"); |
| | | int i; |
| | | int nlen = nlist.length; |
| | | xstring toolStr = L"<vbox name='Dir'>"; |
| | | xstring deptName= publiccode::GetUser().deptname; |
| | | if(deptName==L"跟单部" && m_EntityName==L"GDN3"){ |
| | | for(i=2; i<nlen; i++) |
| | | { |
| | | KXMLDOMElement e1 = nlist.item(i); |
| | | xstring sDir1 = e1.selectSingleNode(L"@Dir").text; |
| | | xstring str1 = L"<xtoolbutton image='15' caption='"+sDir1+L"' height='24' name='xmPanel:"+i.toString()+L"' style='background-color:none #ceecce none #ffffff'/>"; |
| | | |
| | | toolStr += str1; |
| | | if (i==2) |
| | | m_Dir = sDir1; |
| | | } |
| | | }else if(deptName.find(L"业务")>=0 && m_EntityName==L"GDN3" ) |
| | | { |
| | | for(i=1; i<2; i++) |
| | | { |
| | | KXMLDOMElement e2 = nlist.item(i); |
| | | xstring sDir2 = e2.selectSingleNode(L"@Dir").text; |
| | | xstring str2 = L"<xtoolbutton image='15' caption='"+sDir2+L"' height='24' name='xmPanel:"+i.toString()+L"' style='background-color:none #ceecce none #ffffff'/>"; |
| | | |
| | | toolStr += str2; |
| | | if (i==1) |
| | | m_Dir = sDir2; |
| | | } |
| | | for(i=4; i<nlen; i++) |
| | | { |
| | | KXMLDOMElement e3 = nlist.item(i); |
| | | xstring sDir3 = e3.selectSingleNode(L"@Dir").text; |
| | | xstring str3 = L"<xtoolbutton image='15' caption='"+sDir3+L"' height='24' name='xmPanel:"+i.toString()+L"' style='background-color:none #ceecce none #ffffff'/>"; |
| | | |
| | | toolStr += str3; |
| | | } |
| | | }else{ |
| | | for(i=0; i<nlen; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring sDir = e.selectSingleNode(L"@Dir").text; |
| | | xstring str = L"<xtoolbutton image='15' caption='"+sDir+L"' height='24' name='xmPanel:"+i.toString()+L"' style='background-color:none #ceecce none #ffffff'/>"; |
| | | |
| | | toolStr += str; |
| | | if (i==0) |
| | | m_Dir = sDir; |
| | | } |
| | | } |
| | | |
| | | toolStr += L"</vbox>"; |
| | | strNode = toolStr; |
| | | //trace(toolStr); |
| | | xnode anode = GetAgentNode(L"Dir"); |
| | | xwin::SetAgentNode(anode,toolStr) ; |
| | | |
| | | OnRetrieve(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnInit() |
| | | { |
| | | SetAgent(); |
| | | dw_list = this.GetControl(L"dw_list"); |
| | | dw_list.openUrl(L"/sale/view/view.base/template/PrintView/listDialog"); |
| | | dw_list.SetReadOnly(true); |
| | | dw_list.SetSelectionMode(4); |
| | | dw_list.SetColumnState(L"ID",false); |
| | | |
| | | dw_doclist = GetControl(L"dw_doclist"); |
| | | dw_doclist.openUrl(L"/sale/view/GDN/template/doclist"); |
| | | |
| | | xstring sUrl = GetServerUrl(); |
| | | sUrl = sUrl.mid(0, sUrl.length() - 19); |
| | | m_filePath = L"/business/rpttemplate"; |
| | | arg_param = new xaserverarg; |
| | | if (GetParam()) |
| | | { |
| | | int p = GetParam(); |
| | | arg_param.setNativePointer(p); |
| | | m_EntityName = arg_param.GetArgString(L"EntityName"); |
| | | m_EntityID = arg_param.GetArgString(L"EntityID"); |
| | | m_EntityNo = arg_param.GetArgString(L"EntityNo"); |
| | | |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(xaserverarg::CreateInstance()); |
| | | arg.AddArg(L"EntityName", m_EntityName); |
| | | arg.AddArg(L"EntityID", m_EntityID); |
| | | arg.AddArg(L"EntityNo", m_EntityNo); |
| | | xml x =new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | if(url::get(L"/sale/data/DocumentList3/bill/doclist", arg.GetString(),x)!=1) |
| | | { |
| | | xstring error = x.GetXmlDoc().text; |
| | | trace(error); |
| | | }else |
| | | { |
| | | dw_doclist.Retrieve(x); |
| | | dw_doclist.SetReadOnly(true); |
| | | } |
| | | trace((xstring)L"error:" + x.xml()); |
| | | alert(L"删除出错了!"); |
| | | return 0; |
| | | } |
| | | else |
| | | { |
| | | arg_param.setNativePointer(arg_param.CreateInstance()); |
| | | m_EntityName = L"SO"; |
| | | m_EntityID =L"00000000-0000-0000-0000-000000000000"; |
| | | alert(L"删除成功!"); |
| | | OnRetrieve(); |
| | | } |
| | | } |
| | | |
| | | m_Dir = L""; |
| | | m_filePath = m_filePath + L"/" + m_EntityName+L"/"; |
| | | //trace(m_filePath); |
| | | |
| | | CreateDir(); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int OnDocListDoubleClicked(TEvent * evt, int p) |
| | | { |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | OnOpenDocument(); |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDoubleClicked(TEvent * evt, int p) |
| | | { |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | OnOk(); |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | int OnOpenDocument() |
| | | { |
| | | if (dw_doclist.GetRowCount() < 1) return 1; |
| | | xstring documentid = dw_doclist.GetRowElement(dw_doclist.GetRow()).getAttribute(L"guid"); |
| | | //xstring billid = dw_docList |
| | | arg_param.AddArg(L"DocumentID", documentid); |
| | | arg_param.AddArg(L"return", L"ok"); |
| | | arg_param.AddArg(L"action", L"open"); |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnOk() |
| | | { |
| | | int row = dw_list.GetRow(); |
| | | if (row<0 || row>dw_list.GetRowCount()) |
| | | { |
| | | alert(L"请选择要打印的模板!"); |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | responsewin::onload(); |
| | | |
| | | /*if (GetParam()) |
| | | else |
| | | { |
| | | xstring action = arg_param.GetArgString(L"action"); |
| | | if(action==L"open" || (action==L"" && dw_doclist.GetRowCount() > 0)) |
| | | SwitchLayer(L"sheet2",L"frame"); |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | trace(L"\r\n---------------"); |
| | | trace(ele.xml()); |
| | | |
| | | xstring sguid = ele.selectSingleNode(L"ID").text(); |
| | | xstring pre = L""; |
| | | if (ele.selectSingleNode(L"TemplPre")) pre = ele.selectSingleNode(L"TemplPre").text(); |
| | | xstring sTemplName = ele.selectSingleNode(L"TemplName").text(); |
| | | //xstring sFile = m_filePath + sguid+L".xsl"; |
| | | trace(sTemplName); |
| | | xstring sFile = m_filePath + ele.selectSingleNode(L"urlPath").text(); |
| | | arg_param.AddArg(L"xsl", sFile); |
| | | arg_param.AddArg(L"return", L"ok"); |
| | | arg_param.AddArg(L"template-name", sTemplName); |
| | | arg_param.AddArg(L"template-guid", sguid); |
| | | arg_param.AddArg(L"template-pre", pre); |
| | | arg_param.AddArg(L"action", L"new"); |
| | | trace(arg_param.GetString()); |
| | | CloseWindow(); |
| | | /*xaserver::CreateDirectory(L"C:/Temp"); |
| | | int openRet = xaserver::DownLoadFile(GetServerUrl(),m_filePath+file,sTemplName,L"C:/Temp/"+sTemplName); |
| | | if(openRet < 0) |
| | | { |
| | | alert(L"文件打开失败!"); |
| | | return 0; |
| | | } |
| | | |
| | | int GENERIC_READ = 0x80000000; |
| | | int GENERIC_WRITE = 0x40000000; |
| | | int FILE_SHARE_READ = 0x00000001; |
| | | int FILE_SHARE_WRITE = 0x00000002; |
| | | int OPEN_EXISTING = 3; |
| | | int FILE_ATTRIBUTE_ARCHIVE =0x00000020; |
| | | int hFile = xwin::CreateFile(L"C:/Temp/"+sTemplName,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0); |
| | | if (hFile >0) |
| | | { |
| | | //int GMEM_MOVEABLE=0x0002; |
| | | //int GMEM_ZEROINIT=0x0040; |
| | | //int MEMSIZE; |
| | | //int hMemory = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,MEMSIZE); |
| | | //int pMemory = GlobalLock(hMemory); |
| | | //int SizeReadWrite; |
| | | //xwin::ReadFile(hFile,pMemory,MEMSIZE - 1,SizeReadWrite,0); |
| | | int filesize = xwin::GetFileSize(hFile,0); |
| | | trace(L"filesize = %d",filesize); |
| | | xstring buffer = L"".space(filesize+1); |
| | | int readsize = new int; |
| | | xwin::ReadFile(hFile,buffer,filesize,readsize,0); |
| | | trace(buffer); |
| | | xwin::CloseHandle(hFile); |
| | | //GlobalUnlock(pMemory); |
| | | //GlobalFree(hMemory); |
| | | } */ |
| | | /*openRet = xwin::ShellExecute(0,L"open",L"C:/Temp/"+sTemplName,L"",L"",5); |
| | | if(openRet < 32) |
| | | { |
| | | alert(L"文件打开失败2!"); |
| | | return 0; |
| | | }*/ |
| | | } |
| | | */ |
| | | return 0; |
| | | } |
| | | |
| | | int OnSave() |
| | | { |
| | | dw_list.AcceptText(); |
| | | xml x; |
| | | |
| | | dw_list.DwUpdateAllToEx(x); |
| | | |
| | | xaserverarg arg; |
| | | arg.setNativePointer(xaserverarg::CreateInstance()); |
| | | arg.AddArg(L"content", x.xml()); |
| | | |
| | | if (xurl::get(L"/sale/data/SysPrintTemplate/updateinfo", arg.GetString(), x) != 1) |
| | | { |
| | | trace((xstring)L"error:" + x.xml()); |
| | | alert(L"保存出错了!"); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | dw_list.ResetUpdateStatus(); |
| | | alert(L"保存成功!"); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | |
| | | int PreOnCmdDispatch(xstring comdid) |
| | | { |
| | | //responsewin::onload(); |
| | | |
| | | //返回0——不在执行以下代码;返回其他——执行以下代码。 |
| | | if (comdid.left(8) == L"xmPanel:") { |
| | | xstring no = comdid.mid(8, 99); |
| | | //int id = no.toInt(); |
| | | |
| | | xml x; |
| | | |
| | | x.loadXML(strNode); |
| | | KXMLDOMDocument doc = x; |
| | | KXMLDOMElement e = doc.documentElement(); |
| | | xstring slable = e.selectSingleNode(L"//xtoolbutton[@name='" + comdid + L"']/@caption").text(); |
| | | m_Dir = slable; |
| | | OnRetrieve(); |
| | | |
| | | return 1; |
| | | } |
| | | if (comdid == L"xmAddDir") return OnAddDir(); |
| | | if (comdid == L"xmAddTempl" && bupdate) return OnAddTempl(); |
| | | if (comdid == L"xmDelTempl" && bupdate) return OnDelTempl(); |
| | | if (comdid == L"xmMaintTempl" && bupdate) return OnMaintTempl(); |
| | | if (comdid == L"xmNewTempl" && bupdate) return OnNewTempl(); |
| | | //if (comdid==L"xmHtml") return OnHtml(); |
| | | if (comdid == L"xmOk") return OnOk(); |
| | | if (comdid == L"xmSave") return OnSave(); |
| | | if (comdid == L"xmOpen") return OnOpenDocument(); |
| | | else if (comdid == L"xmCancel") |
| | | { |
| | | arg_param.AddArg(L"return", L"cancel"); |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | int PostOnAttachEvent() |
| | | { |
| | | //AttachEvent(L"dw_list",L"DWV_ROWFOCUSCHANGED",OnRowChanged); |
| | | //AttachEvent(L"dw_list",L"DWV_CLICKED",OnClicked); |
| | | //AttachEvent(L"dw_list",L"DWV_RCLICKED",OnRClicked); |
| | | //AttachEvent(L"dw_list",L"DWV_ITEMCHANGED",OnItemChanged); |
| | | //AttachEvent(L"dw_list",L"DWV_CHILDCONTENT",OnChildContent); |
| | | AttachEvent(L"dw_doclist", L"DWV_DOUBLECLICKED", (FEvent)&TemplatePrintDialog::OnDocListDoubleClicked); |
| | | AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&TemplatePrintDialog::OnDoubleClicked); |
| | | return 1; |
| | | } |
| | | |
| | | int SetAgent() |
| | | { |
| | | PUser& puser = *publiccode::GetUser(); |
| | | xstring susername = puser.name; |
| | | if (susername != L"admin") |
| | | { |
| | | xstring xfNodeAgentArea = L"DirButton"; |
| | | xnode anode = GetAgentNode(xfNodeAgentArea); |
| | | KXMLDOMElement xframeElement = GetElement(); |
| | | xstring tools = L"<vbox name='DirButton' height='48' />"; |
| | | SetAgentNode(anode, tools); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int CreateDir() |
| | | { |
| | | PUser& puser = *publiccode::GetUser(); |
| | | xstring susername = puser.name; |
| | | xml x; |
| | | |
| | | xaserverarg arg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg(L"EntityName", m_EntityName, L""); |
| | | arg.AddArg(L"EntityID", m_EntityID, L""); |
| | | arg.AddArg(L"susername", susername, L""); // |
| | | if (xurl::get(L"/sale/data/SysPrintTemplate/Dir", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | xstring s = x.xml(); |
| | | } |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"//Entity"); |
| | | int i; |
| | | int nlen = nlist.length(); |
| | | xstring toolStr = L"<vbox name='Dir'>"; |
| | | xstring deptName = publiccode::GetUser()->deptname; |
| | | if (deptName == L"跟单部" && m_EntityName == L"GDN3") { |
| | | for (i = 2; i < nlen; i++) |
| | | { |
| | | KXMLDOMElement e1 = nlist.item(i); |
| | | xstring sDir1 = e1.selectSingleNode(L"@Dir").text(); |
| | | xstring str1 = L"<xtoolbutton image='15' caption='" + sDir1 + L"' height='24' name='xmPanel:" + xstring(i) + L"' style='background-color:none #ceecce none #ffffff'/>"; |
| | | |
| | | toolStr += str1; |
| | | if (i == 2) |
| | | m_Dir = sDir1; |
| | | } |
| | | } |
| | | else if (deptName.find(L"业务") >= 0 && m_EntityName == L"GDN3") |
| | | { |
| | | for (i = 1; i < 2; i++) |
| | | { |
| | | KXMLDOMElement e2 = nlist.item(i); |
| | | xstring sDir2 = e2.selectSingleNode(L"@Dir").text(); |
| | | xstring str2 = L"<xtoolbutton image='15' caption='" + sDir2 + L"' height='24' name='xmPanel:" + xstring(i) + L"' style='background-color:none #ceecce none #ffffff'/>"; |
| | | |
| | | toolStr += str2; |
| | | if (i == 1) |
| | | m_Dir = sDir2; |
| | | } |
| | | for (i = 4; i < nlen; i++) |
| | | { |
| | | KXMLDOMElement e3 = nlist.item(i); |
| | | xstring sDir3 = e3.selectSingleNode(L"@Dir").text(); |
| | | xstring str3 = L"<xtoolbutton image='15' caption='" + sDir3 + L"' height='24' name='xmPanel:" + xstring(i) + L"' style='background-color:none #ceecce none #ffffff'/>"; |
| | | |
| | | toolStr += str3; |
| | | } |
| | | } |
| | | else { |
| | | for (i = 0; i < nlen; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring sDir = e.selectSingleNode(L"@Dir").text(); |
| | | xstring str = L"<xtoolbutton image='15' caption='" + sDir + L"' height='24' name='xmPanel:" + xstring(i) + L"' style='background-color:none #ceecce none #ffffff'/>"; |
| | | |
| | | toolStr += str; |
| | | if (i == 0) |
| | | m_Dir = sDir; |
| | | } |
| | | } |
| | | |
| | | toolStr += L"</vbox>"; |
| | | strNode = toolStr; |
| | | //trace(toolStr); |
| | | xnode anode = GetAgentNode(L"Dir"); |
| | | xwin::SetAgentNode(anode, toolStr); |
| | | |
| | | OnRetrieve(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnInit() |
| | | { |
| | | SetAgent(); |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.openUrl(L"/sale/view/view.base/template/PrintView/listDialog"); |
| | | dw_list.SetReadOnly(true); |
| | | dw_list.SetSelectionMode(4); |
| | | dw_list.SetColumnState(L"ID", false); |
| | | |
| | | dw_doclist = GetControl(L"dw_doclist"); |
| | | dw_doclist.openUrl(L"/sale/view/GDN/template/doclist"); |
| | | |
| | | xstring sUrl = GetServerUrl(); |
| | | sUrl = sUrl.mid(0, sUrl.length() - 19); |
| | | m_filePath = L"/business/rpttemplate"; |
| | | arg_param; |
| | | if (GetWinParam()) |
| | | { |
| | | arg_param = GetArg(); |
| | | m_EntityName = arg_param.GetArgString(L"EntityName"); |
| | | m_EntityID = arg_param.GetArgString(L"EntityID"); |
| | | m_EntityNo = arg_param.GetArgString(L"EntityNo"); |
| | | |
| | | xaserverarg arg; |
| | | arg.setNativePointer(xaserverarg::CreateInstance()); |
| | | arg.AddArg(L"EntityName", m_EntityName); |
| | | arg.AddArg(L"EntityID", m_EntityID); |
| | | arg.AddArg(L"EntityNo", m_EntityNo); |
| | | xml x = new xml; |
| | | |
| | | if (xurl::get(L"/sale/data/DocumentList3/bill/doclist", arg.GetString(), x) != 1) |
| | | { |
| | | xstring error = x.text(); |
| | | trace(error); |
| | | } |
| | | else |
| | | { |
| | | dw_doclist.Retrieve(x); |
| | | dw_doclist.SetReadOnly(true); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | arg_param.setNativePointer(arg_param.CreateInstance()); |
| | | m_EntityName = L"SO"; |
| | | m_EntityID = L"00000000-0000-0000-0000-000000000000"; |
| | | } |
| | | |
| | | m_Dir = L""; |
| | | m_filePath = m_filePath + L"/" + m_EntityName + L"/"; |
| | | //trace(m_filePath); |
| | | |
| | | CreateDir(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | SetArg(); |
| | | responsewin::onload(); |
| | | |
| | | /*if (GetParam()) |
| | | { |
| | | xstring action = arg_param.GetArgString(L"action"); |
| | |
| | | SwitchLayer(L"sheet2",L"frame"); |
| | | } |
| | | */ |
| | | |
| | | return 1; |
| | | } |
| | | }; |